Skip to content

Commit 9159131

Browse files
authored
Merge pull request #137 from shiguredo/feature/amd-amf
AMD-AMF 対応
2 parents 8b174d3 + 37df07d commit 9159131

File tree

9 files changed

+450
-19
lines changed

9 files changed

+450
-19
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
# TEST_CHANNEL_ID_PREFIX=
33
# TEST_API_URL=
44
# TEST_SECRET_KEY=
5+
## none, verbose, info, warning, error を指定できます
6+
# TEST_LIBWEBRTC_LOG=
57
# OPENH264_PATH=
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: e2e-test-amd-amf
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- ".github/workflows/e2e-test-amd-amf.yml"
8+
- "tests/test_amd_amf.py"
9+
# C++ SDK のアップデートしたときテストするため
10+
- "VERSION"
11+
schedule:
12+
# UTC の 01:00 は JST だと 10:00 。
13+
# 1-5 で 月曜日から金曜日
14+
- cron: "0 1 * * 1-5"
15+
16+
env:
17+
TEST_SIGNALING_URLS: ${{ secrets.TEST_SIGNALING_URLS }}
18+
TEST_CHANNEL_ID_PREFIX: ${{ secrets.TEST_CHANNEL_ID_PREFIX }}
19+
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}
20+
TEST_API_URL: ${{ secrets.TEST_API_URL }}
21+
AMD_AMF: true
22+
23+
jobs:
24+
e2e_test_amf:
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
python_version:
29+
# TODO: push 時には 3.13 でテストする、schedule 時には全部でテストする
30+
# - "3.11"
31+
# - "3.12"
32+
- "3.13"
33+
runs-on:
34+
group: Self
35+
labels: [self-hosted, linux, x64, AMD-AMF]
36+
timeout-minutes: 10
37+
if:
38+
${{
39+
contains(github.event.head_commit.message, '[e2e]') ||
40+
contains(github.ref, 'feature/e2e-test') ||
41+
github.event_name == 'workflow_dispatch' ||
42+
github.event_name == 'push' ||
43+
github.event_name == 'schedule'
44+
}}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: astral-sh/setup-uv@v5
48+
with:
49+
enable-cache: false
50+
- run: |
51+
uv python pin ${{ matrix.python_version }}
52+
uv sync
53+
uv run python run.py ubuntu-24.04_x86_64
54+
uv run pytest tests/test_amd_amf.py -v
55+
56+
# slack_notify_succeeded:
57+
# needs: [e2e_test_ubuntu, e2e_test_macos, e2e_test_windows]
58+
# runs-on: ubuntu-24.04
59+
# if: success()
60+
# steps:
61+
# - name: Slack Notification
62+
# uses: rtCamp/action-slack-notify@v2
63+
# env:
64+
# SLACK_CHANNEL: sora-python-sdk
65+
# SLACK_COLOR: good
66+
# SLACK_TITLE: SUCCEEDED
67+
# SLACK_ICON_EMOJI: ":star-struck:"
68+
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
69+
70+
slack_notify_failed:
71+
needs: [e2e_test_amf]
72+
runs-on: ubuntu-24.04
73+
if: failure()
74+
steps:
75+
- name: Slack Notification
76+
uses: rtCamp/action-slack-notify@v2
77+
env:
78+
SLACK_CHANNEL: sora-python-sdk
79+
SLACK_COLOR: danger
80+
SLACK_TITLE: "FAILED"
81+
SLACK_ICON_EMOJI: ":japanese_ogre:"
82+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

.github/workflows/e2e-test.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ name: e2e-test
22

33
on:
44
workflow_dispatch:
5-
workflow_run:
6-
workflows: ["build"]
7-
types:
8-
- completed
9-
# push:
10-
# paths-ignore:
11-
# - "**.md"
12-
# - ".github/workflows/e2e-test-intel-vpl.yml"
13-
# - ".github/workflows/e2e-test-apple-video-toolbox.yml"
14-
# - ".github/workflows/e2e-test-nvidia-video-codec-sdk.yml"
15-
# - "tests/test_intel_vpl.py"
16-
# - "tests/test_apple_video_toolbox.py"
17-
# - "tests/test_nvidia_video_codec_sdk.py"
5+
push:
6+
paths-ignore:
7+
- "**.md"
8+
- ".github/workflows/e2e-test-intel-vpl.yml"
9+
- ".github/workflows/e2e-test-amd-amf.yml"
10+
- ".github/workflows/e2e-test-apple-video-toolbox.yml"
11+
- ".github/workflows/e2e-test-nvidia-video-codec-sdk.yml"
12+
- "tests/test_intel_vpl.py"
13+
- "tests/test_amd_amf.py"
14+
- "tests/test_apple_video_toolbox.py"
15+
- "tests/test_nvidia_video_codec_sdk.py"
1816
schedule:
1917
# UTC の 01:00 は JST だと 10:00 。
2018
# 1-5 で 月曜日から金曜日
@@ -28,7 +26,7 @@ env:
2826
OPENH264_VERSION: 2.6.0
2927

3028
jobs:
31-
# workflow_run 経由で実行される最小限の E2E テスト
29+
# push 経由で実行される最小限の E2E テスト
3230
e2e_test_minimal:
3331
strategy:
3432
fail-fast: false
@@ -41,7 +39,7 @@ jobs:
4139
openh264_arch: "linux64"
4240
runs-on: ${{ matrix.platform.runs-on}}
4341
timeout-minutes: 15
44-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
42+
if: ${{ github.event_name == 'push' }}
4543
steps:
4644
- uses: actions/checkout@v4
4745
- uses: tailscale/github-action@v3

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
- @melpon
3232
- [ADD] Windows で OpenH264 が利用できるようにする
3333
- @melpon
34+
- [ADD] AMD AMF に対応する
35+
- @melpon
3436
- [ADD] `send_message()` を追加する
3537
- `on_message()` と合わせる
3638
- `send_data_channel()` のシンタックスシュガー
@@ -126,6 +128,9 @@
126128
- @voluntas
127129
- [CHANGE] サンプルアプリの E2E テストを一旦削除する
128130
- @voluntas
131+
- [ADD] .env.template に TEST_LIBWEBRTC_LOG を追加する
132+
- none, verbose, error, warning, info, のいずれかを指定可能
133+
- @voluntas
129134
- [ADD] Ubuntu 24.04 armv8 向けの E2E テストを追加する
130135
- @voluntas
131136
- [ADD] pyjwt を dev-dependencies に追加する
@@ -142,6 +147,8 @@
142147
- @voluntas
143148
- [ADD] examples に E2E テストを追加する
144149
- @voluntas
150+
- [ADD] AMD AMF の E2E テストを追加する
151+
- @voluntas
145152
- [ADD] Intel VPL の E2E テストを追加する
146153
- @voluntas
147154
- [ADD] Intel VPL の E2E テストに AV1 を追加する

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SORA_CPP_SDK_VERSION=2025.2.0-canary.13
1+
SORA_CPP_SDK_VERSION=2025.2.0-canary.14
22
WEBRTC_BUILD_VERSION=m132.6834.5.8
33
BOOST_VERSION=1.87.0
44
CMAKE_VERSION=3.31.6

src/sora_factory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ SoraFactory::SoraFactory(
3939
context_config.video_codec_factory_config.capability_config.cuda_context =
4040
sora::CudaContext::Create();
4141
}
42+
if (sora::AMFContext::CanCreate()) {
43+
context_config.video_codec_factory_config.capability_config.amf_context =
44+
sora::AMFContext::Create();
45+
}
4246
context_config.video_codec_factory_config.preference = video_codec_preference;
4347

4448
// Audio デバイスは使わない、 use_audio_device を true にしただけでデバイスを掴んでしまうので常に false

src/sora_sdk_ext.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ NB_MODULE(sora_sdk_ext, m) {
579579
.value("CISCO_OPENH264", sora::VideoCodecImplementation::kCiscoOpenH264)
580580
.value("INTEL_VPL", sora::VideoCodecImplementation::kIntelVpl)
581581
.value("NVIDIA_VIDEO_CODEC_SDK",
582-
sora::VideoCodecImplementation::kNvidiaVideoCodecSdk);
582+
sora::VideoCodecImplementation::kNvidiaVideoCodecSdk)
583+
.value("AMD_AMF", sora::VideoCodecImplementation::kAmdAmf);
583584

584585
nb::enum_<webrtc::VideoCodecType>(m, "SoraVideoCodecType",
585586
nb::is_arithmetic())
@@ -606,7 +607,11 @@ NB_MODULE(sora_sdk_ext, m) {
606607
.def_ro("vpl_impl_value",
607608
&sora::VideoCodecCapability::Parameters::vpl_impl_value)
608609
.def_ro("nvcodec_gpu_device_name",
609-
&sora::VideoCodecCapability::Parameters::nvcodec_gpu_device_name);
610+
&sora::VideoCodecCapability::Parameters::nvcodec_gpu_device_name)
611+
.def_ro("amf_runtime_version",
612+
&sora::VideoCodecCapability::Parameters::amf_runtime_version)
613+
.def_ro("amf_embedded_version",
614+
&sora::VideoCodecCapability::Parameters::amf_embedded_version);
610615
nb::class_<sora::VideoCodecCapability::Codec>(video_codec_capability, "Codec")
611616
.def_ro("type", &sora::VideoCodecCapability::Codec::type)
612617
.def_ro("encoder", &sora::VideoCodecCapability::Codec::encoder)
@@ -623,7 +628,12 @@ NB_MODULE(sora_sdk_ext, m) {
623628
[](std::optional<std::string> openh264) -> sora::VideoCodecCapability {
624629
sora::VideoCodecCapabilityConfig config;
625630
config.openh264_path = openh264;
626-
config.cuda_context = sora::CudaContext::Create();
631+
if (sora::CudaContext::CanCreate()) {
632+
config.cuda_context = sora::CudaContext::Create();
633+
}
634+
if (sora::AMFContext::CanCreate()) {
635+
config.amf_context = sora::AMFContext::Create();
636+
}
627637
return sora::GetVideoCodecCapability(config);
628638
},
629639
"openh264"_a = nb::none());

tests/client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import queue
34
import threading
45
import time
@@ -8,12 +9,14 @@
89

910
import numpy
1011

12+
import sora_sdk
1113
from sora_sdk import (
1214
Sora,
1315
SoraAudioSink,
1416
SoraAudioSource,
1517
SoraConnection,
1618
SoraDegradationPreference,
19+
SoraLoggingSeverity,
1720
SoraMediaTrack,
1821
SoraSignalingDirection,
1922
SoraSignalingErrorCode,
@@ -89,6 +92,21 @@ def __init__(
8992
self._video_width: int = video_width
9093
self._video_height: int = video_height
9194

95+
if webrtc_log := os.environ.get("TEST_LIBWEBRTC_LOG"):
96+
match webrtc_log:
97+
case "none":
98+
sora_sdk.enable_libwebrtc_log(SoraLoggingSeverity.NONE)
99+
case "verbose":
100+
sora_sdk.enable_libwebrtc_log(SoraLoggingSeverity.VERBOSE)
101+
case "info":
102+
sora_sdk.enable_libwebrtc_log(SoraLoggingSeverity.INFO)
103+
case "warning":
104+
sora_sdk.enable_libwebrtc_log(SoraLoggingSeverity.WARNING)
105+
case "error":
106+
sora_sdk.enable_libwebrtc_log(SoraLoggingSeverity.ERROR)
107+
case _:
108+
pass
109+
92110
self._sora: Sora = Sora(
93111
openh264=openh264_path, video_codec_preference=video_codec_preference
94112
)

0 commit comments

Comments
 (0)