-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FCE-207] Fix error on muted track renegotiation #18
Changes from 1 commit
6426fe0
8da58bc
2bff900
35f3abe
e5a43e2
b89cf0f
8d71dbf
810935b
56e8fb4
e9f0062
5374d40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,23 +8,21 @@ | |
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist/src" | ||
"dist/**" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/fishjam-dev/react-client-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/fishjam-dev/react-client-sdk#readme", | ||
"repository": "github:fishjam-cloud/web-client-sdk", | ||
"homepage": "https://github.com/fishjam-cloud/web-client-sdk#readme", | ||
"bugs": "https://github.com/fishjam-cloud/web-client-sdk/issues", | ||
"keywords": [ | ||
"webrtc", | ||
"membrane", | ||
"fishjam" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/fishjam-dev/react-client-sdk.git" | ||
}, | ||
"exports": { | ||
".": "./dist/index.js" | ||
".": { | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
|
@@ -41,7 +39,7 @@ | |
"format:check": "prettier --check . --ignore-path ./.eslintignore", | ||
"lint:fix": "eslint . --ext .ts,.tsx --fix", | ||
"lint:check": "eslint . --ext .ts,.tsx", | ||
"prepare": "tsc" | ||
"prepack": "yarn workspace @fishjam-dev/ts-client build && yarn build" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.42.1", | ||
|
@@ -64,11 +62,12 @@ | |
"typescript": "^5.4.0" | ||
}, | ||
"dependencies": { | ||
"@fishjam-dev/ts-client": "*", | ||
"@fishjam-dev/ts-client": "workspace:*", | ||
"events": "3.3.0", | ||
"lodash.isequal": "4.5.0" | ||
}, | ||
"directories": { | ||
"example": "examples" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
"description": "Typescript client library for Fishjam", | ||
"license": "Apache-2.0", | ||
"author": "Software Mansion (https://swmansion.com)", | ||
"repository": "github:fishjam-dev/ts-client-sdk", | ||
"homepage": "https://github.com/fishjam-dev/ts-client-sdk#readme", | ||
"bugs": "https://github.com/fishjam-dev/ts-client-sdk/issues", | ||
"repository": "github:fishjam-cloud/web-client-sdk", | ||
"homepage": "https://github.com/fishjam-cloud/web-client-sdk#readme", | ||
"bugs": "https://github.com/fishjam-cloud/web-client-sdk/issues", | ||
"keywords": [ | ||
"webrtc", | ||
"membrane", | ||
|
@@ -15,10 +15,21 @@ | |
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
"files": [ | ||
"dist/src" | ||
"dist/src/**" | ||
], | ||
"exports": { | ||
".": "./dist/src/index.js" | ||
".": { | ||
"import": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts" | ||
}, | ||
"./protos": { | ||
"import": "./dist/src/protos/index.js", | ||
"types": "./dist/src/protos/index.d.ts" | ||
}, | ||
"./webrtc": { | ||
"import": "./dist/src/webrtc/index.js", | ||
"types": "./dist/src/webrtc/index.d.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
|
@@ -32,7 +43,8 @@ | |
"test": "vitest run tests/**", | ||
"test:e2e": "NODE_OPTIONS=--dns-result-order=ipv4first playwright test", | ||
"test:coverage": "vitest run tests/** --coverage", | ||
"prepare": "tsc" | ||
"prepare": "tsc", | ||
"prepack": "yarn build" | ||
}, | ||
"dependencies": { | ||
"events": "^3.3.0", | ||
|
@@ -73,5 +85,6 @@ | |
"*.(js|ts|tsx)": [ | ||
"npm run lint:check" | ||
] | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { EndpointWithTrackContext, TrackContextImpl } from "./internal"; | ||
import { RemoteTrackId } from "./types"; | ||
|
||
export const getMidToTrackId = <EndpointMetadata, TrackMetadata>( | ||
connection: RTCPeerConnection | undefined, | ||
localTrackIdToTrack: Map<RemoteTrackId, TrackContextImpl<EndpointMetadata, TrackMetadata>>, | ||
midToTrackId: Map<string, string> = new Map(), | ||
localEndpoint: EndpointWithTrackContext<EndpointMetadata, TrackMetadata>, | ||
): Record<string, string> | null => { | ||
if (!connection) return null; | ||
|
||
const active = getActive(connection, localTrackIdToTrack) | ||
const muted = getMuted(midToTrackId, localEndpoint) | ||
|
||
return { ...active, ...muted }; | ||
}; | ||
|
||
export const getActive = <EndpointMetadata, TrackMetadata>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is active? isn't the name lacking something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the code and comments, i'd go for getActiveTracks/mutedTracks |
||
connection: RTCPeerConnection, | ||
localTrackIdToTrack: Map<RemoteTrackId, TrackContextImpl<EndpointMetadata, TrackMetadata>>, | ||
): Record<string, string> | null => | ||
connection.getTransceivers() | ||
.filter((transceiver) => transceiver.sender.track?.id && transceiver.mid) | ||
.reduce((acc, transceiver) => { | ||
const localTrackId = transceiver.sender.track!.id; | ||
const mid = transceiver!.mid!; | ||
|
||
const trackContext = Array.from(localTrackIdToTrack.values()).find( | ||
(trackContext) => trackContext?.track?.id === localTrackId, | ||
)!; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move it to a function? |
||
|
||
acc[mid] = trackContext.trackId; | ||
|
||
return acc | ||
}, {} as Record<string, string>); | ||
|
||
|
||
export const getMuted = <EndpointMetadata, TrackMetadata>( | ||
midToTrackId: Map<string, string> = new Map(), | ||
localEndpoint: EndpointWithTrackContext<EndpointMetadata, TrackMetadata>, | ||
): Record<string, string> => { | ||
return [...midToTrackId.entries()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. midToTrackId.entries() would not be enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need it to map the result of |
||
.filter(([_mid, trackId]) => localEndpoint.tracks.get(trackId)) | ||
.reduce((acc, [mid, trackId]) => { | ||
acc[mid] = trackId; | ||
|
||
return acc | ||
}, {} as Record<string, string>); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly this function should return muted tracks, where do we filter out tracks that are not muted here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed the names of these functions in this file, and I've added some comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo
TrackType
sounds better thanTrackKind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it because
MediaStreamTrack
has a kind fieldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe update the variable name as well to
kind: TrackKind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @czerwiukk. lets rename function parameter name to
kind
.