Skip to content

Commit

Permalink
fix validateDescription for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Dec 22, 2020
1 parent ca048b2 commit ddcd650
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
7 changes: 4 additions & 3 deletions examples/client-demo/src/containers/remote/media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 4 additions & 1 deletion packages/werift/rtc/peerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down
14 changes: 8 additions & 6 deletions packages/werift/rtc/sdp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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];
}

Expand Down
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit ddcd650

Please sign in to comment.