1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Set the type of the call based on the tracks

Remove the old hack of inspecting the SDP which no longer seems to
be necessary.
This commit is contained in:
David Baker
2020-10-08 15:42:39 +01:00
parent f518ea95f4
commit 49f2d1501c

View File

@@ -416,23 +416,20 @@ export class MatrixCall extends EventEmitter {
return; return;
} }
// According to previous comments in this file, firefox at some point did not
// add streams until media started ariving on them. Testing latest firefox
// (81 at time of writing), this is no longer a problem, so let's do it the correct way.
if (!this.remoteStream || this.remoteStream.getTracks().length === 0) {
logger.error("No remote stream or no tracks after setting remote description!");
this.terminate(CallParty.Local, CallErrorCode.SetRemoteDescription, false);
return;
}
this.type = this.remoteStream.getTracks().some(t => t.kind === 'video') ? CallType.Video : CallType.Voice;
this.setState(CallState.Ringing); this.setState(CallState.Ringing);
this.direction = CallDirection.Inbound; this.direction = CallDirection.Inbound;
// firefox and OpenWebRTC's RTCPeerConnection doesn't add streams until it
// starts getting media on them so we need to figure out whether a video
// channel has been offered by ourselves.
// XXX: This comment is probably outdated: check & remove this if so
if (
this.msg.offer &&
this.msg.offer.sdp &&
this.msg.offer.sdp.indexOf('m=video') > -1
) {
this.type = CallType.Video;
} else {
this.type = CallType.Voice;
}
if (event.getLocalAge()) { if (event.getLocalAge()) {
setTimeout(() => { setTimeout(() => {
if (this.state == CallState.Ringing) { if (this.state == CallState.Ringing) {
@@ -918,10 +915,6 @@ export class MatrixCall extends EventEmitter {
private onTrack = (ev: RTCTrackEvent) => { private onTrack = (ev: RTCTrackEvent) => {
logger.debug(`Track id ${ev.track.id} of kind ${ev.track.kind} added`); logger.debug(`Track id ${ev.track.id} of kind ${ev.track.kind} added`);
if (ev.track.kind == 'video') {
this.type = CallType.Video;
}
// This is relatively complex as we may get any number of tracks that may // This is relatively complex as we may get any number of tracks that may
// be in any number of streams, or not in streams at all, etc. // be in any number of streams, or not in streams at all, etc.
// I'm not entirely sure how this API is supposed to be used: it would // I'm not entirely sure how this API is supposed to be used: it would