Skip to content

Commit 985852d

Browse files
committed
テスト整理
1 parent 7776a20 commit 985852d

File tree

1 file changed

+68
-122
lines changed

1 file changed

+68
-122
lines changed

tests/test_apple_video_toolbox.py

Lines changed: 68 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"video_codec_type",
1616
["H264", "H265"],
1717
)
18-
def test_macos_video_hwa_sendonly(setup, video_codec_type):
18+
def test_apple_video_toolbox_sendonly(setup, video_codec_type):
1919
signaling_urls = setup.get("signaling_urls")
2020
channel_id_prefix = setup.get("channel_id_prefix")
2121
metadata = setup.get("metadata")
@@ -56,6 +56,70 @@ def test_macos_video_hwa_sendonly(setup, video_codec_type):
5656
assert outbound_rtp_stats["packetsSent"] > 0
5757

5858

59+
@pytest.mark.skipif(
60+
os.environ.get("APPLE_VIDEO_TOOLBOX") is None, reason="Apple Video Toolbox でのみ実行する"
61+
)
62+
@pytest.mark.parametrize(
63+
"video_codec_type",
64+
["H264", "H265"],
65+
)
66+
def test_apple_video_toolbox_sendonly_recvonly(setup, video_codec_type):
67+
signaling_urls = setup.get("signaling_urls")
68+
channel_id_prefix = setup.get("channel_id_prefix")
69+
metadata = setup.get("metadata")
70+
71+
channel_id = f"{channel_id_prefix}_{__name__}_{sys._getframe().f_code.co_name}_{uuid.uuid4()}"
72+
73+
sendonly = SoraClient(
74+
signaling_urls,
75+
SoraRole.SENDONLY,
76+
channel_id,
77+
audio=False,
78+
video=True,
79+
video_codec_type=video_codec_type,
80+
metadata=metadata,
81+
)
82+
sendonly.connect(fake_video=True)
83+
84+
recvonly = SoraClient(
85+
signaling_urls,
86+
SoraRole.RECVONLY,
87+
channel_id,
88+
metadata=metadata,
89+
)
90+
recvonly.connect()
91+
92+
time.sleep(5)
93+
94+
sendonly_stats = sendonly.get_stats()
95+
recvonly_stats = recvonly.get_stats()
96+
97+
sendonly.disconnect()
98+
recvonly.disconnect()
99+
100+
# codec が無かったら StopIteration 例外が上がる
101+
sendonly_codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
102+
# 指定した video_codec_type が採用されているかどうか確認する
103+
assert sendonly_codec_stats["mimeType"] == f"video/{video_codec_type}"
104+
105+
# outbound-rtp が無かったら StopIteration 例外が上がる
106+
outbound_rtp_stats = next(s for s in sendonly_stats if s.get("type") == "outbound-rtp")
107+
assert outbound_rtp_stats["encoderImplementation"] == "VideoToolbox"
108+
assert outbound_rtp_stats["bytesSent"] > 0
109+
assert outbound_rtp_stats["packetsSent"] > 0
110+
111+
# codec が無かったら StopIteration 例外が上がる
112+
recvonly_codec_stats = next(s for s in recvonly_stats if s.get("type") == "codec")
113+
# 指定した video_codec_type が採用されているかどうか確認する
114+
assert recvonly_codec_stats["mimeType"] == f"video/{video_codec_type}"
115+
116+
# outbound-rtp が無かったら StopIteration 例外が上がる
117+
inbound_rtp_stats = next(s for s in recvonly_stats if s.get("type") == "inbound-rtp")
118+
assert inbound_rtp_stats["decoderImplementation"] == "VideoToolbox"
119+
assert inbound_rtp_stats["bytesReceived"] > 0
120+
assert inbound_rtp_stats["packetsReceived"] > 0
121+
122+
59123
@pytest.mark.skipif(
60124
os.environ.get("APPLE_VIDEO_TOOLBOX") is None, reason="Apple Video Toolbox でのみ実行する"
61125
)
@@ -90,7 +154,7 @@ def test_macos_video_hwa_sendonly(setup, video_codec_type):
90154
("H265", "VideoToolbox", 200, 320, 180, 1),
91155
],
92156
)
93-
def test_macos_simulcast(
157+
def test_apple_video_toolbox_simulcast(
94158
setup,
95159
video_codec_type,
96160
expected_implementation,
@@ -187,124 +251,6 @@ def test_macos_simulcast(
187251
)
188252

189253

190-
@pytest.mark.skipif(
191-
os.environ.get("APPLE_VIDEO_TOOLBOX") is None, reason="Apple Video Toolbox でのみ実行する"
192-
)
193-
def test_macos_h264_sendonly_recvonly(setup):
194-
signaling_urls = setup.get("signaling_urls")
195-
channel_id_prefix = setup.get("channel_id_prefix")
196-
metadata = setup.get("metadata")
197-
198-
channel_id = f"{channel_id_prefix}_{__name__}_{sys._getframe().f_code.co_name}_{uuid.uuid4()}"
199-
200-
sendonly = SoraClient(
201-
signaling_urls,
202-
SoraRole.SENDONLY,
203-
channel_id,
204-
audio=False,
205-
video=True,
206-
video_codec_type="H264",
207-
metadata=metadata,
208-
)
209-
sendonly.connect()
210-
211-
recvonly = SoraClient(
212-
signaling_urls,
213-
SoraRole.RECVONLY,
214-
channel_id,
215-
metadata=metadata,
216-
)
217-
recvonly.connect()
218-
219-
time.sleep(5)
220-
221-
sendonly_stats = sendonly.get_stats()
222-
recvonly_stats = recvonly.get_stats()
223-
224-
sendonly.disconnect()
225-
recvonly.disconnect()
226-
227-
# codec が無かったら StopIteration 例外が上がる
228-
sendonly_codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
229-
# H.264 が採用されているかどうか確認する
230-
assert sendonly_codec_stats["mimeType"] == "video/H264"
231-
232-
# outbound-rtp が無かったら StopIteration 例外が上がる
233-
outbound_rtp_stats = next(s for s in sendonly_stats if s.get("type") == "outbound-rtp")
234-
assert outbound_rtp_stats["encoderImplementation"] == "VideoToolbox"
235-
assert outbound_rtp_stats["bytesSent"] > 0
236-
assert outbound_rtp_stats["packetsSent"] > 0
237-
238-
# codec が無かったら StopIteration 例外が上がる
239-
recvonly_codec_stats = next(s for s in recvonly_stats if s.get("type") == "codec")
240-
# H.264 が採用されているかどうか確認する
241-
assert recvonly_codec_stats["mimeType"] == "video/H264"
242-
243-
# outbound-rtp が無かったら StopIteration 例外が上がる
244-
inbound_rtp_stats = next(s for s in recvonly_stats if s.get("type") == "inbound-rtp")
245-
assert inbound_rtp_stats["decoderImplementation"] == "VideoToolbox"
246-
assert inbound_rtp_stats["bytesReceived"] > 0
247-
assert inbound_rtp_stats["packetsReceived"] > 0
248-
249-
250-
@pytest.mark.skipif(
251-
os.environ.get("APPLE_VIDEO_TOOLBOX") is None, reason="Apple Video Toolbox でのみ実行する"
252-
)
253-
def test_macos_h265_sendonly_recvonly(setup):
254-
signaling_urls = setup.get("signaling_urls")
255-
channel_id_prefix = setup.get("channel_id_prefix")
256-
metadata = setup.get("metadata")
257-
258-
channel_id = f"{channel_id_prefix}_{__name__}_{sys._getframe().f_code.co_name}_{uuid.uuid4()}"
259-
260-
sendonly = SoraClient(
261-
signaling_urls,
262-
SoraRole.SENDONLY,
263-
channel_id,
264-
audio=False,
265-
video=True,
266-
video_codec_type="H265",
267-
metadata=metadata,
268-
)
269-
sendonly.connect()
270-
271-
recvonly = SoraClient(
272-
signaling_urls,
273-
SoraRole.RECVONLY,
274-
channel_id,
275-
metadata=metadata,
276-
)
277-
recvonly.connect()
278-
279-
time.sleep(5)
280-
281-
sendonly_stats = sendonly.get_stats()
282-
recvonly_stats = recvonly.get_stats()
283-
284-
sendonly.disconnect()
285-
recvonly.disconnect()
286-
287-
# codec が無かったら StopIteration 例外が上がる
288-
sendonly_codec_stats = next(s for s in sendonly_stats if s.get("type") == "codec")
289-
assert sendonly_codec_stats["mimeType"] == "video/H265"
290-
291-
# outbound-rtp が無かったら StopIteration 例外が上がる
292-
outbound_rtp_stats = next(s for s in sendonly_stats if s.get("type") == "outbound-rtp")
293-
assert outbound_rtp_stats["encoderImplementation"] == "VideoToolbox"
294-
assert outbound_rtp_stats["bytesSent"] > 0
295-
assert outbound_rtp_stats["packetsSent"] > 0
296-
297-
# codec が無かったら StopIteration 例外が上がる
298-
recvonly_codec_stats = next(s for s in recvonly_stats if s.get("type") == "codec")
299-
assert recvonly_codec_stats["mimeType"] == "video/H265"
300-
301-
# outbound-rtp が無かったら StopIteration 例外が上がる
302-
inbound_rtp_stats = next(s for s in recvonly_stats if s.get("type") == "inbound-rtp")
303-
assert inbound_rtp_stats["decoderImplementation"] == "VideoToolbox"
304-
assert inbound_rtp_stats["bytesReceived"] > 0
305-
assert inbound_rtp_stats["packetsReceived"] > 0
306-
307-
308254
@pytest.mark.skipif(
309255
os.environ.get("APPLE_VIDEO_TOOLBOX") is None, reason="Apple Video Toolbox でのみ実行する"
310256
)
@@ -322,7 +268,7 @@ def test_macos_h265_sendonly_recvonly(setup):
322268
("H265", "VideoToolbox", 1000, 320, 180),
323269
],
324270
)
325-
def test_macos_simulcast_authz_scale_resolution_to(
271+
def test_apple_video_toolbox_simulcast_authz_scale_resolution_to(
326272
setup,
327273
video_codec_type,
328274
encoder_implementation,
@@ -384,7 +330,7 @@ def test_macos_simulcast_authz_scale_resolution_to(
384330
)
385331
sendonly.connect(fake_video=True)
386332

387-
time.sleep(10)
333+
time.sleep(5)
388334

389335
# "type": "offer" の SDP で Simulcast があるかどうか
390336
assert sendonly.offer_message is not None

0 commit comments

Comments
 (0)