Skip to content

Commit

Permalink
1.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
billylindeman committed Mar 26, 2021
1 parent bc7ec5d commit fcd3724
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion-sdk-js",
"version": "1.6.2",
"version": "1.6.3",
"description": "A js sdk for ion sfu",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
18 changes: 11 additions & 7 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export default class Client {
ontrack?: (track: MediaStreamTrack, stream: RemoteStream) => void;
ondatachannel?: (ev: RTCDataChannelEvent) => void;
onspeaker?: (ev: string[]) => void;
onerrnegotiate?: (role: Role, err: Error, offer?: RTCSessionDescriptionInit, answer?: RTCSessionDescriptionInit) => void;
onerrnegotiate?: (
role: Role,
err: Error,
offer?: RTCSessionDescriptionInit,
answer?: RTCSessionDescriptionInit,
) => void;

constructor(
signal: Signal,
Expand Down Expand Up @@ -185,7 +190,7 @@ export default class Client {
throw Error(ERR_NO_SESSION);
}

let answer: RTCSessionDescriptionInit|undefined;
let answer: RTCSessionDescriptionInit | undefined;
try {
await this.transports[Role.sub].pc.setRemoteDescription(description);
this.transports[Role.sub].candidates.forEach((c) => this.transports![Role.sub].pc.addIceCandidate(c));
Expand All @@ -196,18 +201,17 @@ export default class Client {
} catch (err) {
/* tslint:disable-next-line:no-console */
console.error(err);
if(this.onerrnegotiate) this.onerrnegotiate(Role.sub, err, description, answer)
if (this.onerrnegotiate) this.onerrnegotiate(Role.sub, err, description, answer);
}

}

private async onNegotiationNeeded() {
if (!this.transports) {
throw Error(ERR_NO_SESSION);
}

let offer: RTCSessionDescriptionInit|undefined;
let answer: RTCSessionDescriptionInit|undefined;
let offer: RTCSessionDescriptionInit | undefined;
let answer: RTCSessionDescriptionInit | undefined;
try {
offer = await this.transports[Role.pub].pc.createOffer();
await this.transports[Role.pub].pc.setLocalDescription(offer);
Expand All @@ -216,7 +220,7 @@ export default class Client {
} catch (err) {
/* tslint:disable-next-line:no-console */
console.error(err);
if(this.onerrnegotiate) this.onerrnegotiate(Role.pub, err, offer, answer);
if (this.onerrnegotiate) this.onerrnegotiate(Role.pub, err, offer, answer);
}
}
}
10 changes: 5 additions & 5 deletions src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,25 @@ export class LocalStream extends MediaStream {

let selCodec: RTCRtpCodecCapability | undefined;
if (this.constraints.preferredCodecProfile && kind === 'video') {
const allCodecProfiles = cap.codecs.filter((c) => c.mimeType.toLowerCase() === `video/${this.constraints.codec.toLowerCase()}`);
const allCodecProfiles = cap.codecs.filter(
(c) => c.mimeType.toLowerCase() === `video/${this.constraints.codec.toLowerCase()}`,
);
if (!allCodecProfiles) {
return;
}
selCodec = allCodecProfiles.find(
(c) =>
c.sdpFmtpLine &&
c.sdpFmtpLine?.indexOf(`profile-level-id=${this.constraints.preferredCodecProfile}`) >= 0
c.sdpFmtpLine && c.sdpFmtpLine?.indexOf(`profile-level-id=${this.constraints.preferredCodecProfile}`) >= 0,
);
if (!selCodec) {
// get first one
selCodec = allCodecProfiles[0];

}
} else {
selCodec = cap.codecs.find(
(c) =>
c.mimeType.toLowerCase() === `video/${this.constraints.codec.toLowerCase()}` ||
c.mimeType.toLowerCase() === `audio/opus`
c.mimeType.toLowerCase() === `audio/opus`,
);
}
if (selCodec) {
Expand Down

0 comments on commit fcd3724

Please sign in to comment.