소스 검색

ref(Sdp) Modify SDPTransformUtil.selectMedia() to return all m-lines for a given media type.

dev1
Jaya Allamsetty 3 년 전
부모
커밋
135eed57af

+ 5
- 5
modules/RTC/TraceablePeerConnection.js 파일 보기

@@ -1346,7 +1346,7 @@ const enforceSendRecv = function(localDescription, options) {
1346 1346
     }
1347 1347
 
1348 1348
     const transformer = new SdpTransformWrap(localDescription.sdp);
1349
-    const audioMedia = transformer.selectMedia(MediaType.AUDIO);
1349
+    const audioMedia = transformer.selectMedia(MediaType.AUDIO)?.[0];
1350 1350
     let changed = false;
1351 1351
 
1352 1352
     if (audioMedia && audioMedia.direction !== MediaDirection.SENDRECV) {
@@ -1359,7 +1359,7 @@ const enforceSendRecv = function(localDescription, options) {
1359 1359
         changed = true;
1360 1360
     }
1361 1361
 
1362
-    const videoMedia = transformer.selectMedia(MediaType.VIDEO);
1362
+    const videoMedia = transformer.selectMedia(MediaType.VIDEO)?.[0];
1363 1363
 
1364 1364
     if (videoMedia && videoMedia.direction !== MediaDirection.SENDRECV) {
1365 1365
         videoMedia.direction = MediaDirection.SENDRECV;
@@ -2079,7 +2079,7 @@ TraceablePeerConnection.prototype._ensureSimulcastGroupIsLast = function(localSd
2079 2079
 TraceablePeerConnection.prototype._adjustLocalMediaDirection = function(localDescription) {
2080 2080
     const transformer = new SdpTransformWrap(localDescription.sdp);
2081 2081
     let modifiedDirection = false;
2082
-    const audioMedia = transformer.selectMedia(MediaType.AUDIO);
2082
+    const audioMedia = transformer.selectMedia(MediaType.AUDIO)?.[0];
2083 2083
 
2084 2084
     if (audioMedia) {
2085 2085
         const desiredAudioDirection = this.getDesiredMediaDirection(MediaType.AUDIO);
@@ -2093,7 +2093,7 @@ TraceablePeerConnection.prototype._adjustLocalMediaDirection = function(localDes
2093 2093
         logger.warn(`${this} No "audio" media found in the local description`);
2094 2094
     }
2095 2095
 
2096
-    const videoMedia = transformer.selectMedia(MediaType.VIDEO);
2096
+    const videoMedia = transformer.selectMedia(MediaType.VIDEO)?.[0];
2097 2097
 
2098 2098
     if (videoMedia) {
2099 2099
         const desiredVideoDirection = this.getDesiredMediaDirection(MediaType.VIDEO);
@@ -2129,7 +2129,7 @@ TraceablePeerConnection.prototype._adjustRemoteMediaDirection = function(remoteD
2129 2129
     const transformer = new SdpTransformWrap(remoteDescription.sdp);
2130 2130
 
2131 2131
     [ MediaType.AUDIO, MediaType.VIDEO ].forEach(mediaType => {
2132
-        const media = transformer.selectMedia(mediaType);
2132
+        const media = transformer.selectMedia(mediaType)?.[0];
2133 2133
         const hasLocalSource = this.hasAnyTracksOfType(mediaType);
2134 2134
         const hasRemoteSource = this.getRemoteTracks(null, mediaType).length > 0;
2135 2135
 

+ 3
- 3
modules/sdp/LocalSdpMunger.js 파일 보기

@@ -58,7 +58,7 @@ export default class LocalSdpMunger {
58 58
                     + 'Strange things may happen !', localVideos);
59 59
         }
60 60
 
61
-        const videoMLine = transformer.selectMedia('video');
61
+        const videoMLine = transformer.selectMedia(MediaType.VIDEO)?.[0];
62 62
 
63 63
         if (!videoMLine) {
64 64
             logger.debug(
@@ -305,14 +305,14 @@ export default class LocalSdpMunger {
305 305
         }
306 306
 
307 307
         const transformer = new SdpTransformWrap(sessionDesc.sdp);
308
-        const audioMLine = transformer.selectMedia('audio');
308
+        const audioMLine = transformer.selectMedia(MediaType.AUDIO)?.[0];
309 309
 
310 310
         if (audioMLine) {
311 311
             this._transformMediaIdentifiers(audioMLine);
312 312
             this._injectSourceNames(audioMLine);
313 313
         }
314 314
 
315
-        const videoMLine = transformer.selectMedia('video');
315
+        const videoMLine = transformer.selectMedia(MediaType.VIDEO)?.[0];
316 316
 
317 317
         if (videoMLine) {
318 318
             this._transformMediaIdentifiers(videoMLine);

+ 4
- 2
modules/sdp/RtxModifier.js 파일 보기

@@ -1,5 +1,7 @@
1 1
 import { getLogger } from '@jitsi/logger';
2 2
 
3
+import * as MediaType from '../../service/RTC/MediaType';
4
+
3 5
 import SDPUtil from './SDPUtil';
4 6
 import { parseSecondarySSRC, SdpTransformWrap } from './SdpTransformUtil';
5 7
 
@@ -99,7 +101,7 @@ export default class RtxModifier {
99 101
      */
100 102
     modifyRtxSsrcs(sdpStr) {
101 103
         const sdpTransformer = new SdpTransformWrap(sdpStr);
102
-        const videoMLine = sdpTransformer.selectMedia('video');
104
+        const videoMLine = sdpTransformer.selectMedia(MediaType.VIDEO)?.[0];
103 105
 
104 106
         if (!videoMLine) {
105 107
             logger.debug(`No 'video' media found in the sdp: ${sdpStr}`);
@@ -168,7 +170,7 @@ export default class RtxModifier {
168 170
      */
169 171
     stripRtx(sdpStr) {
170 172
         const sdpTransformer = new SdpTransformWrap(sdpStr);
171
-        const videoMLine = sdpTransformer.selectMedia('video');
173
+        const videoMLine = sdpTransformer.selectMedia(MediaType.VIDEO)?.[0];
172 174
 
173 175
         if (!videoMLine) {
174 176
             logger.debug(`No 'video' media found in the sdp: ${sdpStr}`);

+ 3
- 1
modules/sdp/SdpConsistency.js 파일 보기

@@ -1,5 +1,7 @@
1 1
 import { getLogger } from '@jitsi/logger';
2 2
 
3
+import * as MediaType from '../../service/RTC/MediaType';
4
+
3 5
 import {
4 6
     parsePrimarySSRC,
5 7
     parseSecondarySSRC,
@@ -72,7 +74,7 @@ export default class SdpConsistency {
72 74
      */
73 75
     makeVideoPrimarySsrcsConsistent(sdpStr) {
74 76
         const sdpTransformer = new SdpTransformWrap(sdpStr);
75
-        const videoMLine = sdpTransformer.selectMedia('video');
77
+        const videoMLine = sdpTransformer.selectMedia(MediaType.VIDEO)?.[0];
76 78
 
77 79
         if (!videoMLine) {
78 80
             logger.debug(`${this.logPrefix} no 'video' media found in the sdp: ${sdpStr}`);

+ 10
- 10
modules/sdp/SdpTransformUtil.js 파일 보기

@@ -408,19 +408,19 @@ export class SdpTransformWrap {
408 408
     }
409 409
 
410 410
     /**
411
-     * Selects the first media SDP of given name.
412
-     * @param {string} mediaType the name of the media e.g. 'audio', 'video',
413
-     * 'data'.
414
-     * @return {MLineWrap|null} return {@link MLineWrap} instance for the media
415
-     * line or <tt>null</tt> if not found. The object returned references
416
-     * the underlying SDP state held by this <tt>SdpTransformWrap</tt> instance
417
-     * (it's not a copy).
411
+     * Selects all the m-lines from the SDP for a given media type.
412
+     *
413
+     * @param {string} mediaType the name of the media e.g. 'audio', 'video', 'data'.
414
+     * @return {MLineWrap|null} return {@link MLineWrap} instance for the media line or <tt>null</tt> if not found. The
415
+     * object returned references the underlying SDP state held by this <tt>SdpTransformWrap</tt> instance (it's not a
416
+     * copy).
418 417
      */
419 418
     selectMedia(mediaType) {
420
-        const selectedMLine
421
-            = this.parsedSDP.media.find(mLine => mLine.type === mediaType);
419
+        const selectedMLines = this.parsedSDP.media
420
+            .filter(mLine => mLine.type === mediaType)
421
+            .map(mLine => new MLineWrap(mLine));
422 422
 
423
-        return selectedMLine ? new MLineWrap(selectedMLine) : null;
423
+        return selectedMLines ?? null;
424 424
     }
425 425
 
426 426
     /**

+ 1
- 1
types/auto/modules/sdp/SdpConsistency.d.ts 파일 보기

@@ -20,7 +20,7 @@ export default class SdpConsistency {
20 20
      *  makeVideoPrimarySsrcsConsistent
21 21
      */
22 22
     clearVideoSsrcCache(): void;
23
-    cachedPrimarySsrc: number;
23
+    cachedPrimarySsrc: any;
24 24
     injectRecvOnly: boolean;
25 25
     /**
26 26
      * Explicitly set the primary ssrc to be used in

+ 6
- 7
types/auto/modules/sdp/SdpTransformUtil.d.ts 파일 보기

@@ -35,13 +35,12 @@ export class SdpTransformWrap {
35 35
     constructor(rawSDP: string);
36 36
     parsedSDP: any;
37 37
     /**
38
-     * Selects the first media SDP of given name.
39
-     * @param {string} mediaType the name of the media e.g. 'audio', 'video',
40
-     * 'data'.
41
-     * @return {MLineWrap|null} return {@link MLineWrap} instance for the media
42
-     * line or <tt>null</tt> if not found. The object returned references
43
-     * the underlying SDP state held by this <tt>SdpTransformWrap</tt> instance
44
-     * (it's not a copy).
38
+     * Selects all the m-lines from the SDP for a given media type.
39
+     *
40
+     * @param {string} mediaType the name of the media e.g. 'audio', 'video', 'data'.
41
+     * @return {MLineWrap|null} return {@link MLineWrap} instance for the media line or <tt>null</tt> if not found. The
42
+     * object returned references the underlying SDP state held by this <tt>SdpTransformWrap</tt> instance (it's not a
43
+     * copy).
45 44
      */
46 45
     selectMedia(mediaType: string): MLineWrap | null;
47 46
     /**

Loading…
취소
저장