@@ -106,6 +106,11 @@ async def _on_track_published(self, event: sfu_events.TrackPublishedEvent):
106106 track_key = (user_id , session_id , track_type_int )
107107 is_agent_track = (user_id == self .agent_user_id )
108108
109+ # Skip processing the agent's own tracks - we don't subscribe to them
110+ if is_agent_track :
111+ self .logger .debug (f"Skipping agent's own track: { track_type_int } from { user_id } " )
112+ return
113+
109114 # First check if track already exists in map (e.g., from previous unpublish/republish)
110115 if track_key in self ._track_map :
111116 self ._track_map [track_key ]["published" ] = True
@@ -115,15 +120,14 @@ async def _on_track_published(self, event: sfu_events.TrackPublishedEvent):
115120 )
116121
117122 # Emit TrackAddedEvent so agent can switch to this track
118- if not is_agent_track :
119- self .events .send (
120- events .TrackAddedEvent (
121- plugin_name = "getstream" ,
122- track_id = track_id ,
123- track_type = track_type_int ,
124- user = event .participant ,
125- )
123+ self .events .send (
124+ events .TrackAddedEvent (
125+ plugin_name = "getstream" ,
126+ track_id = track_id ,
127+ track_type = track_type_int ,
128+ user = event .participant ,
126129 )
130+ )
127131 return
128132
129133 # Wait for pending track to be populated (with 10 second timeout)
@@ -161,17 +165,15 @@ async def _on_track_published(self, event: sfu_events.TrackPublishedEvent):
161165 f"Trackmap published: { track_type_int } from { user_id } , track_id: { track_id } (waited { elapsed :.2f} s)"
162166 )
163167
164- # Only emit TrackAddedEvent for remote participants, not for agent's own tracks
165- if not is_agent_track :
166- # NOW spawn TrackAddedEvent with correct type
167- self .events .send (
168- events .TrackAddedEvent (
169- plugin_name = "getstream" ,
170- track_id = track_id ,
171- track_type = track_type_int ,
172- user = event .participant ,
173- )
168+ # Emit TrackAddedEvent with correct type
169+ self .events .send (
170+ events .TrackAddedEvent (
171+ plugin_name = "getstream" ,
172+ track_id = track_id ,
173+ track_type = track_type_int ,
174+ user = event .participant ,
174175 )
176+ )
175177 else :
176178 raise TimeoutError (
177179 f"Timeout waiting for pending track: { track_type_int } ({ expected_kind } ) from user { user_id } , "
@@ -395,10 +397,10 @@ async def open_demo(self, call: Call) -> str:
395397 "token" : token ,
396398 "skip_lobby" : "true" ,
397399 "user_name" : name ,
398- "video_encoder" : "vp8" ,
399- "bitrate" : 12000000 ,
400+ "video_encoder" : "h264" , # Use H.264 instead of VP8 for better compatibility
401+ "bitrate" : 12000000 ,
400402 "w" : 1920 ,
401- "h" : 1080 ,
403+ "h" : 1080 ,
402404 "channel_type" : self .channel_type ,
403405 }
404406
0 commit comments