File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,23 @@ async def publish_frames(source: livekit.VideoSource):
2424
2525 rgb = colorsys .hsv_to_rgb (hue , 1.0 , 1.0 )
2626 rgb = [int (x * 255 ) for x in rgb ]
27- argb_color = rgb + [255 ]
2827
29- for i in range (0 , len (arr ), 4 ):
30- arr [i :i + 4 ] = argb_color
28+ argb_color = np .array (rgb + [255 ], dtype = np .uint8 )
29+ arr .flat [::4 ] = argb_color [0 ]
30+ arr .flat [1 ::4 ] = argb_color [1 ]
31+ arr .flat [2 ::4 ] = argb_color [2 ]
32+ arr .flat [3 ::4 ] = argb_color [3 ]
3133
3234 source .capture_frame (frame )
3335
34- hue += framerate / 2 # 3s for a full cycle
36+ hue += framerate / 3 # 3s for a full cycle
3537 if hue >= 1.0 :
36- hue -= 1 .0
38+ hue = 0 .0
3739
38- await asyncio .sleep (framerate )
40+ try :
41+ await asyncio .sleep (framerate )
42+ except asyncio .CancelledError :
43+ break
3944
4045
4146async def main ():
@@ -63,6 +68,8 @@ async def main():
6368 await room .run ()
6469 except asyncio .CancelledError :
6570 logging .info ("closing the room" )
71+ source_task .cancel ()
72+ await source_task
6673 await room .close ()
6774
6875
You can’t perform that action at this time.
0 commit comments