@@ -67,9 +67,8 @@ def create_token(identity: str, room_name: str) -> str:
6767def unique_room_name (base : str ) -> str :
6868 return f"{ base } -{ uuid .uuid4 ().hex [:8 ]} "
6969
70- def _solid_color_rgba_frame (
71- width : int , height : int , rgb : tuple [int , int , int ]
72- ) -> rtc .VideoFrame :
70+
71+ def _solid_color_rgba_frame (width : int , height : int , rgb : tuple [int , int , int ]) -> rtc .VideoFrame :
7372 """Build a solid-color 640x480 RGBA `VideoFrame` for the given RGB triple."""
7473 pixels = np .empty ((height , width , 4 ), dtype = np .uint8 )
7574 pixels [:, :, 0 ] = rgb [0 ]
@@ -169,9 +168,7 @@ def on_track_subscribed(
169168 assert subscribed_track is not None
170169
171170 # Request RGBA frames from the SFU so we don't have to convert per frame.
172- video_stream = rtc .VideoStream (
173- subscribed_track , format = rtc .VideoBufferType .RGBA
174- )
171+ video_stream = rtc .VideoStream (subscribed_track , format = rtc .VideoBufferType .RGBA )
175172
176173 received_frames : list [np .ndarray ] = []
177174 stop_collecting = asyncio .Event ()
@@ -197,9 +194,11 @@ async def collect_frames() -> None:
197194 vf = event .frame
198195 if vf .type != rtc .VideoBufferType .RGBA :
199196 vf = vf .convert (rtc .VideoBufferType .RGBA )
200- arr = np .frombuffer (
201- bytes (vf .data .cast ("B" )), dtype = np .uint8
202- ).reshape (vf .height , vf .width , 4 ).copy ()
197+ arr = (
198+ np .frombuffer (bytes (vf .data .cast ("B" )), dtype = np .uint8 )
199+ .reshape (vf .height , vf .width , 4 )
200+ .copy ()
201+ )
203202 received_frames .append (arr )
204203 if stop_collecting .is_set ():
205204 break
@@ -228,8 +227,7 @@ async def collect_frames() -> None:
228227
229228 # Classify each received frame against the 5-color palette.
230229 classified = [
231- _classify_frame_color (f , VIDEO_COLOR_SEQUENCE )[0 ]
232- for f in received_frames
230+ _classify_frame_color (f , VIDEO_COLOR_SEQUENCE )[0 ] for f in received_frames
233231 ]
234232
235233 # Reduce to stable runs: ignore single-frame transitions at color boundaries.
@@ -271,8 +269,7 @@ async def collect_frames() -> None:
271269 expected_names = {name for name , _ in VIDEO_COLOR_SEQUENCE }
272270 missing = expected_names - saved .keys ()
273271 assert not missing , (
274- f"Did not capture a frame for colors: { missing } . "
275- f"Classified stream: { classified } "
272+ f"Did not capture a frame for colors: { missing } . Classified stream: { classified } "
276273 )
277274 finally :
278275 await publisher_room .disconnect ()
0 commit comments