Skip to content

Commit

Permalink
コードの統一
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Sep 18, 2024
1 parent ba333e6 commit c9abab8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 51 deletions.
48 changes: 8 additions & 40 deletions tests/test_macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"""


def test_macos_h264_sendonly(setup):
@pytest.mark.parametrize(
"video_codec_type",
["H264", "H265"],
)
def test_macos_video_hwa_sendonly(setup, video_codec_type):
signaling_urls = setup.get("signaling_urls")
channel_id_prefix = setup.get("channel_id_prefix")
metadata = setup.get("metadata")
Expand All @@ -23,7 +27,7 @@ def test_macos_h264_sendonly(setup):
channel_id,
audio=False,
video=True,
video_codec_type="H264",
video_codec_type=video_codec_type,
metadata=metadata,
use_hwa=True,
)
Expand All @@ -34,43 +38,7 @@ def test_macos_h264_sendonly(setup):
assert sendonly.connect_message is not None
assert sendonly.connect_message["channel_id"] == channel_id
assert "video" in sendonly.connect_message
assert sendonly.connect_message["video"]["codec_type"] == "H264"

sendonly_stats = sendonly.get_stats()

sendonly.disconnect()

# codec が無かったら StopIteration 例外が上がる
codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
# H.264 が採用されているかどうか確認する
assert codec_stats["mimeType"] == "video/H264"

# outbound-rtp が無かったら StopIteration 例外が上がる
outbound_rtp_stats = next(s for s in sendonly_stats if s.get("type") == "outbound-rtp")
assert outbound_rtp_stats["encoderImplementation"] == "VideoToolbox"
assert outbound_rtp_stats["bytesSent"] > 0
assert outbound_rtp_stats["packetsSent"] > 0


def test_macos_h265_sendonly(setup):
signaling_urls = setup.get("signaling_urls")
channel_id_prefix = setup.get("channel_id_prefix")
metadata = setup.get("metadata")

channel_id = f"{channel_id_prefix}_{__name__}_{sys._getframe().f_code.co_name}_{uuid.uuid4()}"

sendonly = Sendonly(
signaling_urls,
channel_id,
audio=False,
video=True,
video_codec_type="H265",
metadata=metadata,
use_hwa=True,
)
sendonly.connect(fake_video=True)

time.sleep(5)
assert sendonly.connect_message["video"]["codec_type"] == video_codec_type

sendonly_stats = sendonly.get_stats()

Expand All @@ -79,7 +47,7 @@ def test_macos_h265_sendonly(setup):
# codec が無かったら StopIteration 例外が上がる
codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
# H.264 が採用されているかどうか確認する
assert codec_stats["mimeType"] == "video/H265"
assert codec_stats["mimeType"] == f"video/{video_codec_type}"

# outbound-rtp が無かったら StopIteration 例外が上がる
outbound_rtp_stats = next(s for s in sendonly_stats if s.get("type") == "outbound-rtp")
Expand Down
18 changes: 7 additions & 11 deletions tests/test_openh264.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ def test_openh264_sendonly_recvonly(setup):
assert inbound_rtp_stats["packetsReceived"] > 0


@pytest.fixture(
params=[
@pytest.mark.parametrize(
"video_codec_type,expected_implementation",
[
("H264", "SimulcastEncoderAdapter (OpenH264, OpenH264, OpenH264)"),
]
],
)
def video_codec_params(request):
return request.param


def test_openh264_simulcast(setup, video_codec_params):
video_codec, expected_implementation = video_codec_params
def test_openh264_simulcast(setup, video_codec_type, expected_implementation):
signaling_urls = setup.get("signaling_urls")
channel_id_prefix = setup.get("channel_id_prefix")
metadata = setup.get("metadata")
Expand All @@ -90,7 +86,7 @@ def test_openh264_simulcast(setup, video_codec_params):
simulcast=True,
audio=False,
video=True,
video_codec_type=video_codec,
video_codec_type=video_codec_type,
video_bit_rate=3000,
metadata=metadata,
video_width=1280,
Expand All @@ -108,7 +104,7 @@ def test_openh264_simulcast(setup, video_codec_params):

# codec が無かったら StopIteration 例外が上がる
sendonly_codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
assert sendonly_codec_stats["mimeType"] == f"video/{video_codec}"
assert sendonly_codec_stats["mimeType"] == f"video/{video_codec_type}"

# 複数のoutbound-rtp統計情報を取得
outbound_rtp_stats = [
Expand Down

0 comments on commit c9abab8

Please sign in to comment.