MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / on_track

Function on_track

avp_stream/visual/client.py:24–53  ·  view source on GitHub ↗
(track)

Source from the content-addressed store, hash-verified

22
23 @pc.on("track")
24 async def on_track(track):
25 nonlocal video_task
26 print(f"DEBUG: Track callback triggered, kind={track.kind}")
27 logging.info("Track received: kind=%s", track.kind)
28 if track.kind != "video":
29 print("DEBUG: Track is not video, ignoring")
30 return
31
32 print("DEBUG: Setting video_track_received event")
33 video_track_received.set()
34
35 print("DEBUG: Starting frame receiving loop")
36 while True:
37 try:
38 frame = await track.recv()
39 print("DEBUG: Frame received")
40 img = frame.to_ndarray(format="bgr24")
41
42 cv2.imshow("Remote camera", img)
43 # break on 'q'
44 if cv2.waitKey(1) & 0xFF == ord("q"):
45 print("DEBUG: 'q' key pressed, exiting")
46 break
47 except Exception as e:
48 logging.error("Error receiving frame: %s", e)
49 break
50
51 logging.info("Stopping video display")
52 cv2.destroyAllWindows()
53 await pc.close()
54
55 @pc.on("iceconnectionstatechange")
56 async def on_ice_state_change():

Callers

nothing calls this directly

Calls 3

printFunction · 0.50
setMethod · 0.45
recvMethod · 0.45

Tested by

no test coverage detected