Skip to content

Commit

Permalink
Subscribe to published mic track for linked participant only
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherry committed Oct 31, 2024
1 parent 805e7f6 commit 70c43c7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions agents/src/multimodal/multimodal_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,19 @@ export class MultimodalAgent extends EventEmitter {
}
this.#linkParticipant(participant.identity);
});
room.on(RoomEvent.TrackPublished, () => {
// in case we are connected before the participant has published, we'd need to re-subscribe
this.#subscribeToMicrophone();
});
room.on(
RoomEvent.TrackPublished,
(trackPublication: RemoteTrackPublication, participant: RemoteParticipant) => {
if (
this.linkedParticipant &&
participant.identity === this.linkedParticipant.identity &&
trackPublication.source === TrackSource.SOURCE_MICROPHONE &&
!trackPublication.subscribed
) {
trackPublication.setSubscribed(true);
}
},
);
room.on(RoomEvent.TrackSubscribed, this.#handleTrackSubscription.bind(this));

this.room = room;
Expand Down

0 comments on commit 70c43c7

Please sign in to comment.