Browse Source

ref(SDP) Convert to ES6 class. (#2572)

* ref(SDP) Convert to ES6 class.

* ref(SDP) Use enum for URNs associated with XMPP extensions.

* ref(XMPP) Replace more XEP URN constants with enum.

* fix(RTC) Fixes mediaType lookup based on source-name.
release-8443
Jaya Allamsetty 1 year ago
parent
commit
ef92c2a044
No account linked to committer's email address

+ 606
- 675
modules/sdp/SDP.js
File diff suppressed because it is too large
View File


+ 8
- 5
modules/sdp/SDPDiffer.js View File

@@ -1,4 +1,6 @@
1 1
 
2
+import { XEP } from '../../service/xmpp/XMPPExtensioProtocols';
3
+
2 4
 import SDPUtil from './SDPUtil';
3 5
 
4 6
 // this could be useful in Array.prototype.
@@ -159,9 +161,10 @@ SDPDiffer.prototype.toJingle = function(modify) {
159 161
 
160 162
         modify.c('content', { name: media.mid });
161 163
 
162
-        modify.c('description',
163
-            { xmlns: 'urn:xmpp:jingle:apps:rtp:1',
164
-                media: media.mid });
164
+        modify.c('description', {
165
+            xmlns: XEP.RTP_MEDIA,
166
+            media: media.mid
167
+        });
165 168
 
166 169
         // FIXME: not completely sure this operates on blocks and / or handles
167 170
         // different ssrcs correctly
@@ -172,7 +175,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
172 175
             const sourceName = SDPUtil.parseSourceNameLine(ssrcLines);
173 176
             const videoType = SDPUtil.parseVideoTypeLine(ssrcLines);
174 177
 
175
-            modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
178
+            modify.c('source', { xmlns: XEP.SOURCE_ATTRIBUTES });
176 179
             modify.attrs({
177 180
                 name: sourceName,
178 181
                 videoType,
@@ -198,7 +201,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
198 201
 
199 202
                 modify.c('ssrc-group', {
200 203
                     semantics: ssrcGroup.semantics,
201
-                    xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0'
204
+                    xmlns: XEP.SOURCE_ATTRIBUTES
202 205
                 });
203 206
 
204 207
                 ssrcGroup.ssrcs.forEach(ssrc => {

+ 5
- 4
modules/xmpp/JingleHelperFunctions.js View File

@@ -4,6 +4,7 @@ import $ from 'jquery';
4 4
 import { $build } from 'strophe.js';
5 5
 
6 6
 import { MediaType } from '../../service/RTC/MediaType';
7
+import { XEP } from '../../service/xmpp/XMPPExtensioProtocols';
7 8
 
8 9
 const logger = getLogger(__filename);
9 10
 
@@ -15,7 +16,7 @@ const logger = getLogger(__filename);
15 16
  */
16 17
 function _createSourceExtension(owner, sourceCompactJson) {
17 18
     const node = $build('source', {
18
-        xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
19
+        xmlns: XEP.SOURCE_ATTRIBUTES,
19 20
         ssrc: sourceCompactJson.s,
20 21
         name: sourceCompactJson.n
21 22
     });
@@ -41,13 +42,13 @@ function _createSourceExtension(owner, sourceCompactJson) {
41 42
  */
42 43
 function _createSsrcGroupExtension(ssrcGroupCompactJson) {
43 44
     const node = $build('ssrc-group', {
44
-        xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
45
+        xmlns: XEP.SOURCE_ATTRIBUTES,
45 46
         semantics: _getSemantics(ssrcGroupCompactJson[0])
46 47
     });
47 48
 
48 49
     for (let i = 1; i < ssrcGroupCompactJson.length; i++) {
49 50
         node.c('source', {
50
-            xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
51
+            xmlns: XEP.SOURCE_ATTRIBUTES,
51 52
             ssrc: ssrcGroupCompactJson[i]
52 53
         }).up();
53 54
     }
@@ -83,7 +84,7 @@ function _getOrCreateRtpDescription(iq, mediaType) {
83 84
         description = description[0];
84 85
     } else {
85 86
         description = $build('description', {
86
-            xmlns: 'urn:xmpp:jingle:apps:rtp:1',
87
+            xmlns: XEP.RTP_MEDIA,
87 88
             media: mediaType
88 89
         }).node;
89 90
         content.appendChild(description);

+ 8
- 7
modules/xmpp/JingleSessionPC.js View File

@@ -13,6 +13,7 @@ import {
13 13
     VIDEO_CODEC_CHANGED
14 14
 } from '../../service/statistics/AnalyticsEvents';
15 15
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
16
+import { XEP } from '../../service/xmpp/XMPPExtensioProtocols';
16 17
 import { SS_DEFAULT_FRAME_RATE } from '../RTC/ScreenObtainer';
17 18
 import FeatureFlags from '../flags/FeatureFlags';
18 19
 import SDP from '../sdp/SDP';
@@ -68,7 +69,7 @@ function getEndpointId(jidOrEndpointId) {
68 69
 function _addSourceElement(description, s, ssrc_, msid) {
69 70
 
70 71
     description.c('source', {
71
-        xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
72
+        xmlns: XEP.SOURCE_ATTRIBUTES,
72 73
         ssrc: ssrc_,
73 74
         name: s.source
74 75
     })
@@ -713,7 +714,7 @@ export default class JingleSessionPC extends JingleSession {
713 714
 
714 715
                 return;
715 716
             }
716
-            ice.xmlns = 'urn:xmpp:jingle:transports:ice-udp:1';
717
+            ice.xmlns = XEP.ICE_UDP_TRANSPORT;
717 718
 
718 719
             if (this.usedrip) {
719 720
                 if (this.dripContainer.length === 0) {
@@ -768,7 +769,7 @@ export default class JingleSessionPC extends JingleSession {
768 769
                 const ice
769 770
                     = SDPUtil.iceparams(localSDP.media[mid], localSDP.session);
770 771
 
771
-                ice.xmlns = 'urn:xmpp:jingle:transports:ice-udp:1';
772
+                ice.xmlns = XEP.ICE_UDP_TRANSPORT;
772 773
                 cand.c('content', {
773 774
                     creator: this.initiatorJid === this.localJid
774 775
                         ? 'initiator' : 'responder',
@@ -1834,7 +1835,7 @@ export default class JingleSessionPC extends JingleSession {
1834 1835
                 xmlns: 'urn:xmpp:jingle:1',
1835 1836
                 name: mediaType
1836 1837
             }).c('description', {
1837
-                xmlns: 'urn:xmpp:jingle:apps:rtp:1',
1838
+                xmlns: XEP.RTP_MEDIA,
1838 1839
                 media: mediaType
1839 1840
             });
1840 1841
 
@@ -1850,16 +1851,16 @@ export default class JingleSessionPC extends JingleSession {
1850 1851
                     if (rtx !== '-1') {
1851 1852
                         _addSourceElement(node, src, rtx, msid);
1852 1853
                         node.c('ssrc-group', {
1853
-                            xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
1854
+                            xmlns: XEP.SOURCE_ATTRIBUTES,
1854 1855
                             semantics: 'FID'
1855 1856
                         })
1856 1857
                             .c('source', {
1857
-                                xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
1858
+                                xmlns: XEP.SOURCE_ATTRIBUTES,
1858 1859
                                 ssrc
1859 1860
                             })
1860 1861
                             .up()
1861 1862
                             .c('source', {
1862
-                                xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
1863
+                                xmlns: XEP.SOURCE_ATTRIBUTES,
1863 1864
                                 ssrc: rtx
1864 1865
                             })
1865 1866
                             .up()

+ 8
- 7
modules/xmpp/xmpp.js View File

@@ -7,6 +7,7 @@ import 'strophejs-plugin-disco';
7 7
 import * as JitsiConnectionErrors from '../../JitsiConnectionErrors';
8 8
 import * as JitsiConnectionEvents from '../../JitsiConnectionEvents';
9 9
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
10
+import { XEP } from '../../service/xmpp/XMPPExtensioProtocols';
10 11
 import browser from '../browser';
11 12
 import { E2EEncryption } from '../e2ee/E2EEncryption';
12 13
 import FeatureFlags from '../flags/FeatureFlags';
@@ -218,13 +219,13 @@ export default class XMPP extends Listenable {
218 219
     initFeaturesList() {
219 220
         // http://xmpp.org/extensions/xep-0167.html#support
220 221
         // http://xmpp.org/extensions/xep-0176.html#support
221
-        this.caps.addFeature('urn:xmpp:jingle:1');
222
-        this.caps.addFeature('urn:xmpp:jingle:apps:rtp:1');
223
-        this.caps.addFeature('urn:xmpp:jingle:transports:ice-udp:1');
224
-        this.caps.addFeature('urn:xmpp:jingle:apps:dtls:0');
225
-        this.caps.addFeature('urn:xmpp:jingle:transports:dtls-sctp:1');
226
-        this.caps.addFeature('urn:xmpp:jingle:apps:rtp:audio');
227
-        this.caps.addFeature('urn:xmpp:jingle:apps:rtp:video');
222
+        this.caps.addFeature(XEP.JINGLE);
223
+        this.caps.addFeature(XEP.RTP_MEDIA);
224
+        this.caps.addFeature(XEP.ICE_UDP_TRANSPORT);
225
+        this.caps.addFeature(XEP.DTLS_SRTP);
226
+        this.caps.addFeature(XEP.SCTP_DATA_CHANNEL);
227
+        this.caps.addFeature(XEP.RTP_AUDIO);
228
+        this.caps.addFeature(XEP.RTP_VIDEO);
228 229
         this.caps.addFeature('http://jitsi.org/json-encoded-sources');
229 230
 
230 231
         if (!(this.options.disableRtx || !browser.supportsRTX())) {

+ 6
- 1
service/RTC/MediaType.ts View File

@@ -7,5 +7,10 @@ export enum MediaType {
7 7
     /**
8 8
      * The video type.
9 9
      */
10
-    VIDEO = 'video'
10
+    VIDEO = 'video',
11
+
12
+    /**
13
+     * The application type (data over bridge channel).
14
+     */
15
+    APPLICATION = 'application'
11 16
 }

+ 74
- 0
service/xmpp/XMPPExtensioProtocols.ts View File

@@ -0,0 +1,74 @@
1
+
2
+export enum XEP {
3
+    /**
4
+     * XEP-0338 - Signals the usage of bundled media, i.e., allows the use of a single set of ICE candidates for
5
+     * multiple media descriptions.
6
+     * https://xmpp.org/extensions/attic/xep-0338-1.0.0.html
7
+     */
8
+    BUNDLE_MEDIA = 'urn:xmpp:jingle:apps:grouping:0',
9
+
10
+    /**
11
+     * XEP-0320 - Signals the use of DTLS-SRTP in Jingle session.
12
+     * https://xmpp.org/extensions/xep-0320.html
13
+     */
14
+    DTLS_SRTP = 'urn:xmpp:jingle:apps:dtls:0',
15
+
16
+    /**
17
+     * XEP-0176 - Signaling ICE-UDP transport method.
18
+     * https://xmpp.org/extensions/xep-0176.html
19
+     */
20
+    ICE_UDP_TRANSPORT = 'urn:xmpp:jingle:transports:ice-udp:1',
21
+
22
+    /**
23
+     * XEP-0166 - Jingle.
24
+     * https://xmpp.org/extensions/xep-0166.html
25
+     */
26
+    JINGLE = 'urn:xmpp:jingle:1',
27
+
28
+    /**
29
+     * XEP-0327 - Rayo for allowing third-party control over media sessions.
30
+     */
31
+    RAYO = 'urn:xmpp:rayo:client:1',
32
+
33
+    /**
34
+     * XEP-0167 - Signals support for RTP audio.
35
+     * https://xmpp.org/extensions/xep-0167.html#support
36
+     */
37
+    RTP_AUDIO = 'urn:xmpp:jingle:apps:rtp:audio',
38
+
39
+    /**
40
+     * XEP-0293 - Signals the use of RTP Feedback Negotiation.
41
+     * https://xmpp.org/extensions/xep-0293.html
42
+     */
43
+    RTP_FEEDBACK = 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0',
44
+
45
+    /**
46
+     * XEP-0167 - Signals support for RTP video.
47
+     * https://xmpp.org/extensions/xep-0167.html#support
48
+     */
49
+    RTP_VIDEO = 'urn:xmpp:jingle:apps:rtp:video',
50
+
51
+    /**
52
+     * XEP-0294 - Signals the use of RTP Header Extensions.
53
+     * https://xmpp.org/extensions/xep-0294.html
54
+     */
55
+    RTP_HEADER_EXTENSIONS = 'urn:xmpp:jingle:apps:rtp:rtp-hdrext:0',
56
+
57
+    /**
58
+     * XEP-0167 - Signals parameters necessary for media sessions using RTP.
59
+     * https://xmpp.org/extensions/xep-0167.html
60
+     */
61
+    RTP_MEDIA = 'urn:xmpp:jingle:apps:rtp:1',
62
+
63
+    /**
64
+     * XEP-0343 - Signaling WebRTC datachannels (bridge channel) in Jingle that uses DTLS/SCTP on top of ICE.
65
+     * https://xmpp.org/extensions/xep-0343.html
66
+     */
67
+    SCTP_DATA_CHANNEL = 'urn:xmpp:jingle:transports:dtls-sctp:1',
68
+
69
+    /**
70
+     * XEP-0339 - Signals Source-Specific Media Attributes in Jingle.
71
+     * https://xmpp.org/extensions/xep-0339.html
72
+     */
73
+    SOURCE_ATTRIBUTES = 'urn:xmpp:jingle:apps:rtp:ssma:0'
74
+}

Loading…
Cancel
Save