Use participant identity and track sid everywhere

This commit is contained in:
Antonio Scandurra 2022-10-18 12:05:59 +02:00
parent a42a703b35
commit 8c6de99159
2 changed files with 27 additions and 23 deletions

View file

@ -318,28 +318,32 @@ impl Room {
}); });
} }
this.remote_participants.insert( let location = ParticipantLocation::from_proto(participant.location)
peer_id, .unwrap_or(ParticipantLocation::External);
RemoteParticipant { if let Some(remote_participant) = this.remote_participants.get_mut(&peer_id)
user: user.clone(), {
projects: participant.projects, remote_participant.projects = participant.projects;
location: ParticipantLocation::from_proto(participant.location) remote_participant.location = location;
.unwrap_or(ParticipantLocation::External), } else {
tracks: Default::default(), this.remote_participants.insert(
}, peer_id,
); RemoteParticipant {
user: user.clone(),
projects: participant.projects,
location,
tracks: Default::default(),
},
);
if let Some((room, _)) = this.live_kit_room.as_ref() { if let Some((room, _)) = this.live_kit_room.as_ref() {
println!("getting video tracks for peer id {}", peer_id.0.to_string()); let tracks = room.remote_video_tracks(&peer_id.0.to_string());
let tracks = room.remote_video_tracks(&peer_id.0.to_string()); for track in tracks {
dbg!(tracks.len()); this.remote_video_track_updated(
for track in tracks { RemoteVideoTrackUpdate::Subscribed(track),
dbg!(track.sid(), track.publisher_id()); cx,
this.remote_video_track_updated( )
RemoteVideoTrackUpdate::Subscribed(track), .log_err();
cx, }
)
.log_err();
} }
} }
} }

View file

@ -15,13 +15,13 @@ class LKRoomDelegate: RoomDelegate {
func room(_ room: Room, participant: RemoteParticipant, didSubscribe publication: RemoteTrackPublication, track: Track) { func room(_ room: Room, participant: RemoteParticipant, didSubscribe publication: RemoteTrackPublication, track: Track) {
if track.kind == .video { if track.kind == .video {
self.onDidSubscribeToRemoteVideoTrack(self.data, participant.identity as CFString, track.id as CFString, Unmanaged.passUnretained(track).toOpaque()) self.onDidSubscribeToRemoteVideoTrack(self.data, participant.identity as CFString, track.sid! as CFString, Unmanaged.passUnretained(track).toOpaque())
} }
} }
func room(_ room: Room, participant: RemoteParticipant, didUnsubscribe publication: RemoteTrackPublication, track: Track) { func room(_ room: Room, participant: RemoteParticipant, didUnsubscribe publication: RemoteTrackPublication, track: Track) {
if track.kind == .video { if track.kind == .video {
self.onDidUnsubscribeFromRemoteVideoTrack(self.data, participant.sid as CFString, track.id as CFString) self.onDidUnsubscribeFromRemoteVideoTrack(self.data, participant.identity as CFString, track.sid! as CFString)
} }
} }
} }