@stream-io/video-client 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.browser.es.js +5 -6
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +5 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +5 -6
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/sdp-munging.ts +7 -11
- package/src/rtc/publisher.ts +1 -1
package/package.json
CHANGED
|
@@ -69,7 +69,7 @@ const getMediaSection = (sdp: string, mediaType: 'video' | 'audio') => {
|
|
|
69
69
|
sdp.split(/(\r\n|\r|\n)/).forEach((line) => {
|
|
70
70
|
const isValidLine = /^([a-z])=(.*)/.test(line);
|
|
71
71
|
if (!isValidLine) return;
|
|
72
|
-
/*
|
|
72
|
+
/*
|
|
73
73
|
NOTE: according to https://www.rfc-editor.org/rfc/rfc8866.pdf
|
|
74
74
|
Each media description starts with an "m=" line and continues to the next media description or the end of the whole session description, whichever comes first
|
|
75
75
|
*/
|
|
@@ -170,7 +170,7 @@ export const removeCodec = (
|
|
|
170
170
|
sdp: string,
|
|
171
171
|
mediaType: 'video' | 'audio',
|
|
172
172
|
codecToRemove: string,
|
|
173
|
-
) => {
|
|
173
|
+
): string => {
|
|
174
174
|
const section = getMediaSection(sdp, mediaType);
|
|
175
175
|
const mediaSection = section?.media;
|
|
176
176
|
if (!mediaSection) {
|
|
@@ -190,30 +190,26 @@ export const removeCodec = (
|
|
|
190
190
|
mediaSection.original,
|
|
191
191
|
`${mediaSection.mediaWithPorts} ${newCodecOrder}`,
|
|
192
192
|
)
|
|
193
|
-
.replace(new RegExp(`${rtpMap.original}[\r\n
|
|
194
|
-
.replace(
|
|
195
|
-
fmtp?.original ? new RegExp(`${fmtp?.original}[\r\n|\r|\n]`) : '',
|
|
196
|
-
'',
|
|
197
|
-
); // remove the corresponding fmtp line
|
|
193
|
+
.replace(new RegExp(`${rtpMap.original}[\r\n]+`), '') // remove the corresponding rtpmap line
|
|
194
|
+
.replace(fmtp?.original ? new RegExp(`${fmtp?.original}[\r\n]+`) : '', ''); // remove the corresponding fmtp line
|
|
198
195
|
};
|
|
199
196
|
|
|
200
197
|
/**
|
|
201
198
|
* Gets the fmtp line corresponding to opus
|
|
202
199
|
*/
|
|
203
|
-
const getOpusFmtp = (sdp: string) => {
|
|
200
|
+
const getOpusFmtp = (sdp: string): Fmtp | undefined => {
|
|
204
201
|
const section = getMediaSection(sdp, 'audio');
|
|
205
202
|
const rtpMap = section?.rtpMap.find((r) => r.codec.toLowerCase() === 'opus');
|
|
206
203
|
const codecId = rtpMap?.payload;
|
|
207
204
|
if (codecId) {
|
|
208
|
-
|
|
209
|
-
return fmtp;
|
|
205
|
+
return section?.fmtp.find((f) => f.payload === codecId);
|
|
210
206
|
}
|
|
211
207
|
};
|
|
212
208
|
|
|
213
209
|
/**
|
|
214
210
|
* Returns an SDP with DTX enabled or disabled.
|
|
215
211
|
*/
|
|
216
|
-
export const toggleDtx = (sdp: string, enable: boolean) => {
|
|
212
|
+
export const toggleDtx = (sdp: string, enable: boolean): string => {
|
|
217
213
|
const opusFmtp = getOpusFmtp(sdp);
|
|
218
214
|
if (opusFmtp) {
|
|
219
215
|
const matchDtx = /usedtx=(\d)/.exec(opusFmtp.config);
|
package/src/rtc/publisher.ts
CHANGED
|
@@ -342,7 +342,7 @@ export class Publisher {
|
|
|
342
342
|
const offer = await this.publisher.createOffer();
|
|
343
343
|
let sdp = offer.sdp;
|
|
344
344
|
if (sdp) {
|
|
345
|
-
toggleDtx(sdp, this.isDtxEnabled);
|
|
345
|
+
sdp = toggleDtx(sdp, this.isDtxEnabled);
|
|
346
346
|
if (isReactNative()) {
|
|
347
347
|
if (this.preferredVideoCodec) {
|
|
348
348
|
sdp = setPreferredCodec(sdp, 'video', this.preferredVideoCodec);
|