|
@@ -578,10 +578,11 @@ SDP.prototype.fromJingle = function(jingle) {
|
578
|
578
|
|
579
|
579
|
// translate a jingle content element into an an SDP media part
|
580
|
580
|
SDP.prototype.jingle2media = function(content) {
|
581
|
|
- const desc = content.find('description');
|
|
581
|
+ const desc = content.find('>description');
|
|
582
|
+ const transport = content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
|
582
|
583
|
let media = '';
|
583
|
|
- const sctp = content.find(
|
584
|
|
- '>transport>sctpmap[xmlns="urn:xmpp:jingle:transports:dtls-sctp:1"]');
|
|
584
|
+ const sctp = transport.find(
|
|
585
|
+ '>sctpmap[xmlns="urn:xmpp:jingle:transports:dtls-sctp:1"]');
|
585
|
586
|
|
586
|
587
|
let tmp = { media: desc.attr('media') };
|
587
|
588
|
|
|
@@ -590,7 +591,7 @@ SDP.prototype.jingle2media = function(content) {
|
590
|
591
|
// estos hack to reject an m-line.
|
591
|
592
|
tmp.port = '0';
|
592
|
593
|
}
|
593
|
|
- if (content.find('>transport>fingerprint[xmlns="urn:xmpp:jingle:apps:dtls:0"]').length) {
|
|
594
|
+ if (transport.find('>fingerprint[xmlns="urn:xmpp:jingle:apps:dtls:0"]').length) {
|
594
|
595
|
tmp.proto = sctp.length ? 'DTLS/SCTP' : 'RTP/SAVPF';
|
595
|
596
|
} else {
|
596
|
597
|
tmp.proto = 'RTP/AVPF';
|
|
@@ -610,7 +611,7 @@ SDP.prototype.jingle2media = function(content) {
|
610
|
611
|
} else {
|
611
|
612
|
tmp.fmt
|
612
|
613
|
= desc
|
613
|
|
- .find('payload-type')
|
|
614
|
+ .find('>payload-type')
|
614
|
615
|
.map((_, payloadType) => payloadType.getAttribute('id'))
|
615
|
616
|
.get();
|
616
|
617
|
media += `${SDPUtil.buildMLine(tmp)}\r\n`;
|
|
@@ -620,17 +621,16 @@ SDP.prototype.jingle2media = function(content) {
|
620
|
621
|
if (!sctp.length) {
|
621
|
622
|
media += 'a=rtcp:1 IN IP4 0.0.0.0\r\n';
|
622
|
623
|
}
|
623
|
|
- tmp
|
624
|
|
- = content.find(
|
625
|
|
- '>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
|
626
|
|
- if (tmp.length) {
|
627
|
|
- if (tmp.attr('ufrag')) {
|
628
|
|
- media += `${SDPUtil.buildICEUfrag(tmp.attr('ufrag'))}\r\n`;
|
|
624
|
+
|
|
625
|
+ // XEP-0176 ICE parameters
|
|
626
|
+ if (transport.length) {
|
|
627
|
+ if (transport.attr('ufrag')) {
|
|
628
|
+ media += `${SDPUtil.buildICEUfrag(transport.attr('ufrag'))}\r\n`;
|
629
|
629
|
}
|
630
|
|
- if (tmp.attr('pwd')) {
|
631
|
|
- media += `${SDPUtil.buildICEPwd(tmp.attr('pwd'))}\r\n`;
|
|
630
|
+ if (transport.attr('pwd')) {
|
|
631
|
+ media += `${SDPUtil.buildICEPwd(transport.attr('pwd'))}\r\n`;
|
632
|
632
|
}
|
633
|
|
- tmp.find('>fingerprint[xmlns="urn:xmpp:jingle:apps:dtls:0"]').each((_, fingerprint) => {
|
|
633
|
+ transport.find('>fingerprint[xmlns="urn:xmpp:jingle:apps:dtls:0"]').each((_, fingerprint) => {
|
634
|
634
|
media += `a=fingerprint:${fingerprint.getAttribute('hash')}`;
|
635
|
635
|
media += ` ${$(fingerprint).text()}`;
|
636
|
636
|
media += '\r\n';
|
|
@@ -639,6 +639,26 @@ SDP.prototype.jingle2media = function(content) {
|
639
|
639
|
}
|
640
|
640
|
});
|
641
|
641
|
}
|
|
642
|
+
|
|
643
|
+ // XEP-0176 ICE candidates
|
|
644
|
+ transport.find('>candidate')
|
|
645
|
+ .each((_, candidate) => {
|
|
646
|
+ let protocol = candidate.getAttribute('protocol');
|
|
647
|
+
|
|
648
|
+ protocol
|
|
649
|
+ = typeof protocol === 'string' ? protocol.toLowerCase() : '';
|
|
650
|
+
|
|
651
|
+ if ((this.removeTcpCandidates
|
|
652
|
+ && (protocol === 'tcp' || protocol === 'ssltcp'))
|
|
653
|
+ || (this.removeUdpCandidates && protocol === 'udp')) {
|
|
654
|
+ return;
|
|
655
|
+ } else if (this.failICE) {
|
|
656
|
+ candidate.setAttribute('ip', '1.1.1.1');
|
|
657
|
+ }
|
|
658
|
+
|
|
659
|
+ media += SDPUtil.candidateFromJingle(candidate);
|
|
660
|
+ });
|
|
661
|
+
|
642
|
662
|
switch (content.attr('senders')) {
|
643
|
663
|
case 'initiator':
|
644
|
664
|
media += 'a=sendonly\r\n';
|
|
@@ -659,17 +679,17 @@ SDP.prototype.jingle2media = function(content) {
|
659
|
679
|
// see http://code.google.com/p/libjingle/issues/detail?id=309 -- no spec
|
660
|
680
|
// though
|
661
|
681
|
// and http://mail.jabber.org/pipermail/jingle/2011-December/001761.html
|
662
|
|
- if (desc.find('rtcp-mux').length) {
|
|
682
|
+ if (desc.find('>rtcp-mux').length) {
|
663
|
683
|
media += 'a=rtcp-mux\r\n';
|
664
|
684
|
}
|
665
|
685
|
|
666
|
|
- desc.find('payload-type').each((_, payloadType) => {
|
|
686
|
+ desc.find('>payload-type').each((_, payloadType) => {
|
667
|
687
|
media += `${SDPUtil.buildRTPMap(payloadType)}\r\n`;
|
668
|
688
|
if ($(payloadType).find('>parameter').length) {
|
669
|
689
|
media += `a=fmtp:${payloadType.getAttribute('id')} `;
|
670
|
690
|
media
|
671
|
691
|
+= $(payloadType)
|
672
|
|
- .find('parameter')
|
|
692
|
+ .find('>parameter')
|
673
|
693
|
.map((__, parameter) => {
|
674
|
694
|
const name = parameter.getAttribute('name');
|
675
|
695
|
|
|
@@ -699,30 +719,9 @@ SDP.prototype.jingle2media = function(content) {
|
699
|
719
|
hdrExt.getAttribute('uri')}\r\n`;
|
700
|
720
|
});
|
701
|
721
|
|
702
|
|
- content
|
703
|
|
- .find(
|
704
|
|
- '>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]'
|
705
|
|
- + '>candidate')
|
706
|
|
- .each((_, transport) => {
|
707
|
|
- let protocol = transport.getAttribute('protocol');
|
708
|
|
-
|
709
|
|
- protocol
|
710
|
|
- = typeof protocol === 'string' ? protocol.toLowerCase() : '';
|
711
|
|
-
|
712
|
|
- if ((this.removeTcpCandidates
|
713
|
|
- && (protocol === 'tcp' || protocol === 'ssltcp'))
|
714
|
|
- || (this.removeUdpCandidates && protocol === 'udp')) {
|
715
|
|
- return;
|
716
|
|
- } else if (this.failICE) {
|
717
|
|
- transport.setAttribute('ip', '1.1.1.1');
|
718
|
|
- }
|
719
|
|
-
|
720
|
|
- media += SDPUtil.candidateFromJingle(transport);
|
721
|
|
- });
|
722
|
|
-
|
723
|
722
|
// XEP-0339 handle ssrc-group attributes
|
724
|
|
- content
|
725
|
|
- .find('description>ssrc-group[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]')
|
|
723
|
+ desc
|
|
724
|
+ .find('>ssrc-group[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]')
|
726
|
725
|
.each((_, ssrcGroup) => {
|
727
|
726
|
const semantics = ssrcGroup.getAttribute('semantics');
|
728
|
727
|
const ssrcs
|
|
@@ -737,8 +736,8 @@ SDP.prototype.jingle2media = function(content) {
|
737
|
736
|
});
|
738
|
737
|
|
739
|
738
|
tmp
|
740
|
|
- = content.find(
|
741
|
|
- 'description>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
|
|
739
|
+ = desc.find(
|
|
740
|
+ '>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
|
742
|
741
|
tmp.each((_, source) => {
|
743
|
742
|
const ssrc = source.getAttribute('ssrc');
|
744
|
743
|
|