always reevaluate remote media when receiving a new remote track

not just when we don't know the stream already
this caused the video track to not appear when the other party sends the
invite.
Also added more logging
This commit is contained in:
Bruno Windels 2022-04-27 17:33:27 +02:00
parent 230ccd95ab
commit be04eeded0

View File

@ -902,6 +902,9 @@ export class PeerCall implements IDisposable {
private onRemoteTrack(track: Track, streams: ReadonlyArray<Stream>, log: ILogItem) { private onRemoteTrack(track: Track, streams: ReadonlyArray<Stream>, log: ILogItem) {
log.set("kind", track.kind);
log.set("id", track.id);
log.set("streams", streams.map(s => s.id));
if (streams.length === 0) { if (streams.length === 0) {
log.log({l: `ignoring ${track.kind} streamless track`, id: track.id}); log.log({l: `ignoring ${track.kind} streamless track`, id: track.id});
return; return;
@ -932,39 +935,49 @@ export class PeerCall implements IDisposable {
disposeListener, disposeListener,
stream stream
}); });
this.updateRemoteMedia(log);
} }
this.updateRemoteMedia(log);
} }
private updateRemoteMedia(log: ILogItem): void { private updateRemoteMedia(log: ILogItem): void {
this._remoteMedia.userMedia = undefined; log.wrap("reevaluating remote media", log => {
this._remoteMedia.screenShare = undefined; this._remoteMedia.userMedia = undefined;
if (this.remoteSDPStreamMetadata) { this._remoteMedia.screenShare = undefined;
for (const streamDetails of this._remoteStreams.values()) { if (this.remoteSDPStreamMetadata) {
const {stream} = streamDetails; for (const streamDetails of this._remoteStreams.values()) {
const metaData = this.remoteSDPStreamMetadata[stream.id]; const {stream} = streamDetails;
if (metaData) { const metaData = this.remoteSDPStreamMetadata[stream.id];
if (metaData.purpose === SDPStreamMetadataPurpose.Usermedia) { if (metaData) {
this._remoteMedia.userMedia = stream; if (metaData.purpose === SDPStreamMetadataPurpose.Usermedia) {
const audioReceiver = this.findReceiverForStream(TrackKind.Audio, stream.id); this._remoteMedia.userMedia = stream;
if (audioReceiver) { const audioReceiver = this.findReceiverForStream(TrackKind.Audio, stream.id);
audioReceiver.track.enabled = !metaData.audio_muted; if (audioReceiver) {
audioReceiver.track.enabled = !metaData.audio_muted;
}
const videoReceiver = this.findReceiverForStream(TrackKind.Video, stream.id);
if (videoReceiver) {
videoReceiver.track.enabled = !metaData.video_muted;
}
this._remoteMuteSettings = new MuteSettings(
metaData.audio_muted || !audioReceiver?.track,
metaData.video_muted || !videoReceiver?.track
);
log.log({
l: "setting userMedia",
micMuted: this._remoteMuteSettings.microphone,
cameraMuted: this._remoteMuteSettings.camera
});
} else if (metaData.purpose === SDPStreamMetadataPurpose.Screenshare) {
this._remoteMedia.screenShare = stream;
log.log("setting screenShare");
} }
const videoReceiver = this.findReceiverForStream(TrackKind.Video, stream.id); } else {
if (videoReceiver) { log.log({l: "no metadata yet for stream, ignoring for now", id: stream.id});
videoReceiver.track.enabled = !metaData.video_muted;
}
this._remoteMuteSettings = new MuteSettings(
metaData.audio_muted || !audioReceiver?.track,
metaData.video_muted || !videoReceiver?.track
);
} else if (metaData.purpose === SDPStreamMetadataPurpose.Screenshare) {
this._remoteMedia.screenShare = stream;
} }
} }
} }
} this.options.emitUpdate(this, undefined);
this.options.emitUpdate(this, undefined); });
} }
private updateLocalMedia(localMedia: LocalMedia, logItem: ILogItem): Promise<void> { private updateLocalMedia(localMedia: LocalMedia, logItem: ILogItem): Promise<void> {