Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better error for ICE Server SyntaxError #3694

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/webrtc/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2220,14 +2220,30 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
CallEvent.Error,
new CallError(
CallErrorCode.NoUserMedia,
"Couldn't start capturing media! Is your microphone set up and " + "does this app have permission?",
"Couldn't start capturing media! Is your microphone set up and does this app have permission?",
err,
),
this,
);
this.terminate(CallParty.Local, CallErrorCode.NoUserMedia, false);
};

private placeCallFailed = (err: Error): void => {
if (this.successor) {
this.successor.placeCallFailed(err);
return;
}

logger.warn(`Call ${this.callId} placeCallWithCallFeeds() failed - ending call`, err);

this.emit(
CallEvent.Error,
new CallError(CallErrorCode.IceFailed, "Couldn't start call! Invalid ICE server configuration.", err),
this,
);
this.terminate(CallParty.Local, CallErrorCode.IceFailed, false);
};

private onIceConnectionStateChanged = (): void => {
if (this.callHasEnded()) {
return; // because ICE can still complete as we're ending the call
Expand Down Expand Up @@ -2775,6 +2791,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
}
this.state = CallState.WaitLocalMedia;

let callFeed: CallFeed;
try {
const stream = await this.client.getMediaHandler().getUserMediaStream(audio, video);

Expand All @@ -2783,7 +2800,7 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
setTracksEnabled(stream.getAudioTracks(), true);
setTracksEnabled(stream.getVideoTracks(), true);

const callFeed = new CallFeed({
callFeed = new CallFeed({
client: this.client,
roomId: this.roomId,
userId: this.client.getUserId()!,
Expand All @@ -2793,11 +2810,17 @@ export class MatrixCall extends TypedEventEmitter<CallEvent, CallEventHandlerMap
audioMuted: false,
videoMuted: false,
});
await this.placeCallWithCallFeeds([callFeed]);
} catch (e) {
this.getUserMediaFailed(<Error>e);
return;
}

try {
await this.placeCallWithCallFeeds([callFeed]);
} catch (e) {
this.placeCallFailed(<Error>e);
return;
}
}

/**
Expand Down
Loading