77TOKEN = os .environ .get ("LIVEKIT_TOKEN" )
88URL = os .environ .get ("LIVEKIT_URL" )
99
10+
1011async def main ():
1112 logging .basicConfig (level = logging .INFO )
12- logger = logging .getLogger (__name__ )
1313 room = rtc .Room ()
1414
1515 @room .on ("participant_connected" )
1616 def on_participant_connected (participant : rtc .RemoteParticipant ):
1717 logging .info (
18- "participant connected: %s %s" , participant .sid , participant .identity )
18+ "participant connected: %s %s" , participant .sid , participant .identity
19+ )
1920
2021 async def receive_frames (stream : rtc .VideoStream ):
2122 async for frame in stream :
@@ -24,7 +25,11 @@ async def receive_frames(stream: rtc.VideoStream):
2425
2526 # track_subscribed is emitted whenever the local participant is subscribed to a new track
2627 @room .on ("track_subscribed" )
27- def on_track_subscribed (track : rtc .Track , publication : rtc .RemoteTrackPublication , participant : rtc .RemoteParticipant ):
28+ def on_track_subscribed (
29+ track : rtc .Track ,
30+ publication : rtc .RemoteTrackPublication ,
31+ participant : rtc .RemoteParticipant ,
32+ ):
2833 logging .info ("track subscribed: %s" , publication .sid )
2934 if track .kind == rtc .TrackKind .KIND_VIDEO :
3035 video_stream = rtc .VideoStream (track )
@@ -43,7 +48,8 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
4348 print (f"participant identity: { participant .identity } " )
4449 print (f"participant name: { participant .name } " )
4550 print (f"participant kind: { participant .kind } " )
46- print (f"participant track publications: { participant .track_publications } " )
51+ print (f"participant track publications: {
52+ participant .track_publications } " )
4753 for tid , publication in participant .track_publications .items ():
4854 print (f"\t track id: { tid } " )
4955 print (f"\t \t track publication: { publication } " )
@@ -52,7 +58,6 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
5258 print (f"\t \t track source: { publication .source } " )
5359
5460 print (f"participant metadata: { participant .metadata } " )
55-
5661
5762
5863if __name__ == "__main__" :
@@ -62,4 +67,3 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
6267 exit (1 )
6368
6469 asyncio .run (main ())
65-
0 commit comments