7
7
TOKEN = os .environ .get ("LIVEKIT_TOKEN" )
8
8
URL = os .environ .get ("LIVEKIT_URL" )
9
9
10
+
10
11
async def main ():
11
12
logging .basicConfig (level = logging .INFO )
12
- logger = logging .getLogger (__name__ )
13
13
room = rtc .Room ()
14
14
15
15
@room .on ("participant_connected" )
16
16
def on_participant_connected (participant : rtc .RemoteParticipant ):
17
17
logging .info (
18
- "participant connected: %s %s" , participant .sid , participant .identity )
18
+ "participant connected: %s %s" , participant .sid , participant .identity
19
+ )
19
20
20
21
async def receive_frames (stream : rtc .VideoStream ):
21
22
async for frame in stream :
@@ -24,7 +25,11 @@ async def receive_frames(stream: rtc.VideoStream):
24
25
25
26
# track_subscribed is emitted whenever the local participant is subscribed to a new track
26
27
@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
+ ):
28
33
logging .info ("track subscribed: %s" , publication .sid )
29
34
if track .kind == rtc .TrackKind .KIND_VIDEO :
30
35
video_stream = rtc .VideoStream (track )
@@ -43,7 +48,8 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
43
48
print (f"participant identity: { participant .identity } " )
44
49
print (f"participant name: { participant .name } " )
45
50
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 } " )
47
53
for tid , publication in participant .track_publications .items ():
48
54
print (f"\t track id: { tid } " )
49
55
print (f"\t \t track publication: { publication } " )
@@ -52,7 +58,6 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
52
58
print (f"\t \t track source: { publication .source } " )
53
59
54
60
print (f"participant metadata: { participant .metadata } " )
55
-
56
61
57
62
58
63
if __name__ == "__main__" :
@@ -62,4 +67,3 @@ def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublicatio
62
67
exit (1 )
63
68
64
69
asyncio .run (main ())
65
-
0 commit comments