From ddcd650dd08d14721bebbb87927fe2bf9d819c0b Mon Sep 17 00:00:00 2001 From: shinyoshiaki Date: Tue, 22 Dec 2020 18:33:33 +0900 Subject: [PATCH] fix validateDescription for firefox --- .../src/containers/remote/media.tsx | 7 ++++--- packages/werift/rtc/peerConnection.ts | 5 ++++- packages/werift/rtc/sdp.ts | 14 +++++++------ tsconfig.json | 21 +++++++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 tsconfig.json diff --git a/examples/client-demo/src/containers/remote/media.tsx b/examples/client-demo/src/containers/remote/media.tsx index 182cad1..761d175 100644 --- a/examples/client-demo/src/containers/remote/media.tsx +++ b/examples/client-demo/src/containers/remote/media.tsx @@ -11,12 +11,13 @@ export const Media: FC<{ info: MediaInfo }> = ({ info }) => { useEffect(() => { client.events.onTrack.subscribe((stream, { mediaId }) => { if (mediaId !== info.mediaId) return; - stream.onremovetrack = () => { - setStream(undefined); - }; videoRef.current.srcObject = stream; setStream(stream); }); + client.events.onUnsubscribe.subscribe(({ mediaId }) => { + if (mediaId !== info.mediaId) return; + setStream(undefined); + }); }, []); const changeQuality = (info: MediaInfo, type: SubscriberType) => { diff --git a/packages/werift/rtc/peerConnection.ts b/packages/werift/rtc/peerConnection.ts index c22cf9b..9452d2e 100644 --- a/packages/werift/rtc/peerConnection.ts +++ b/packages/werift/rtc/peerConnection.ts @@ -509,7 +509,10 @@ export class RTCPeerConnection { } description.media.forEach((media) => { - if (!media.iceParams.usernameFragment || !media.iceParams.password) + if ( + media.direction !== "inactive" && + (!media.iceParams.usernameFragment || !media.iceParams.password) + ) throw new Error("ICE username fragment or password is missing"); }); diff --git a/packages/werift/rtc/sdp.ts b/packages/werift/rtc/sdp.ts index a81f5b5..6c1f096 100644 --- a/packages/werift/rtc/sdp.ts +++ b/packages/werift/rtc/sdp.ts @@ -36,11 +36,11 @@ export class SessionDescription { static parse(sdp: string) { const dtlsFingerprints: RTCDtlsFingerprint[] = []; - let dtlsRole = ""; - let iceOptions = undefined; - let iceLite = false; - let icePassword = ""; - let iceUsernameFragment = ""; + let dtlsRole: string; + let iceOptions: string; + let iceLite: boolean = false; + let icePassword: string; + let iceUsernameFragment: string; const [sessionLines, mediaGroups] = groupLines(sdp); @@ -495,7 +495,9 @@ export class GroupDescription { function ipAddressFromSdp(sdp: string) { const m = sdp.match(/^IN (IP4|IP6) ([^ ]+)$/); - if (!m) throw new Error("exception"); + if (!m) { + throw new Error("exception"); + } return m[2]; } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..dc3d2bf --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["esnext", "ES2020"], + "declaration": true, + "outDir": "lib", + "strict": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "importHelpers": true, + "pretty": true, + "sourceMap": true, + "inlineSources": true, + "noUnusedLocals": false, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false + }, + "include": ["packages"] +}