|
@@ -1572,6 +1572,7 @@ TraceablePeerConnection.prototype.containsTrack = function(track) {
|
1572
|
1572
|
/**
|
1573
|
1573
|
* Add {@link JitsiLocalTrack} to this TPC.
|
1574
|
1574
|
* @param {JitsiLocalTrack} track
|
|
1575
|
+ * @param {boolean} isInitiator indicates if the endpoint is the offerer.
|
1575
|
1576
|
* @returns {Promise<void>} - resolved when done.
|
1576
|
1577
|
*/
|
1577
|
1578
|
TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false) {
|
|
@@ -1585,50 +1586,55 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
|
1585
|
1586
|
}
|
1586
|
1587
|
|
1587
|
1588
|
this.localTracks.set(rtcId, track);
|
1588
|
|
- if (browser.usesUnifiedPlan() && isInitiator) {
|
1589
|
|
- this.tpcUtils.addTrack(track, isInitiator);
|
1590
|
|
-
|
1591
|
|
- return Promise.resolve();
|
1592
|
|
- }
|
1593
|
1589
|
|
1594
|
|
- const webrtcStream = track.getOriginalStream();
|
1595
|
|
-
|
1596
|
|
- if (webrtcStream) {
|
1597
|
|
- this._addStream(webrtcStream);
|
1598
|
|
-
|
1599
|
|
- // It's not ok for a track to not have a WebRTC stream if:
|
1600
|
|
- } else if (!browser.doesVideoMuteByStreamRemove()
|
1601
|
|
- || track.isAudioTrack()
|
1602
|
|
- || (track.isVideoTrack() && !track.isMuted())) {
|
1603
|
|
- return Promise.reject(new Error(`${this} no WebRTC stream for: ${track}`));
|
1604
|
|
- }
|
|
1590
|
+ // For p2p unified case, use addTransceiver API to add the tracks on the peerconnection.
|
|
1591
|
+ if (browser.usesUnifiedPlan() && this.isP2P) {
|
|
1592
|
+ this.tpcUtils.addTrack(track, isInitiator);
|
|
1593
|
+ } else {
|
|
1594
|
+ // In all other cases, i.e., plan-b and unified plan bridge case, use addStream API to
|
|
1595
|
+ // add the track to the peerconnection.
|
|
1596
|
+ // TODO - addTransceiver doesn't generate a MSID for the stream, which is needed for signaling
|
|
1597
|
+ // the ssrc to Jicofo. Switch to using UUID as MSID when addTransceiver is used in Unified plan
|
|
1598
|
+ // JVB connection case as well.
|
|
1599
|
+ const webrtcStream = track.getOriginalStream();
|
|
1600
|
+
|
|
1601
|
+ if (webrtcStream) {
|
|
1602
|
+ this._addStream(webrtcStream);
|
|
1603
|
+
|
|
1604
|
+ // It's not ok for a track to not have a WebRTC stream if:
|
|
1605
|
+ } else if (!browser.doesVideoMuteByStreamRemove()
|
|
1606
|
+ || track.isAudioTrack()
|
|
1607
|
+ || (track.isVideoTrack() && !track.isMuted())) {
|
|
1608
|
+ return Promise.reject(new Error(`${this} no WebRTC stream for: ${track}`));
|
|
1609
|
+ }
|
1605
|
1610
|
|
1606
|
|
- // Muted video tracks do not have WebRTC stream
|
1607
|
|
- if (browser.usesPlanB() && browser.doesVideoMuteByStreamRemove()
|
1608
|
|
- && track.isVideoTrack() && track.isMuted()) {
|
1609
|
|
- const ssrcInfo = this.generateNewStreamSSRCInfo(track);
|
|
1611
|
+ // Muted video tracks do not have WebRTC stream
|
|
1612
|
+ if (browser.usesPlanB() && browser.doesVideoMuteByStreamRemove()
|
|
1613
|
+ && track.isVideoTrack() && track.isMuted()) {
|
|
1614
|
+ const ssrcInfo = this.generateNewStreamSSRCInfo(track);
|
1610
|
1615
|
|
1611
|
|
- this.sdpConsistency.setPrimarySsrc(ssrcInfo.ssrcs[0]);
|
1612
|
|
- const simGroup
|
1613
|
|
- = ssrcInfo.groups.find(groupInfo => groupInfo.semantics === 'SIM');
|
|
1616
|
+ this.sdpConsistency.setPrimarySsrc(ssrcInfo.ssrcs[0]);
|
|
1617
|
+ const simGroup
|
|
1618
|
+ = ssrcInfo.groups.find(groupInfo => groupInfo.semantics === 'SIM');
|
1614
|
1619
|
|
1615
|
|
- if (simGroup) {
|
1616
|
|
- this.simulcast.setSsrcCache(simGroup.ssrcs);
|
1617
|
|
- }
|
1618
|
|
- const fidGroups
|
1619
|
|
- = ssrcInfo.groups.filter(
|
1620
|
|
- groupInfo => groupInfo.semantics === 'FID');
|
|
1620
|
+ if (simGroup) {
|
|
1621
|
+ this.simulcast.setSsrcCache(simGroup.ssrcs);
|
|
1622
|
+ }
|
|
1623
|
+ const fidGroups
|
|
1624
|
+ = ssrcInfo.groups.filter(
|
|
1625
|
+ groupInfo => groupInfo.semantics === 'FID');
|
1621
|
1626
|
|
1622
|
|
- if (fidGroups) {
|
1623
|
|
- const rtxSsrcMapping = new Map();
|
|
1627
|
+ if (fidGroups) {
|
|
1628
|
+ const rtxSsrcMapping = new Map();
|
1624
|
1629
|
|
1625
|
|
- fidGroups.forEach(fidGroup => {
|
1626
|
|
- const primarySsrc = fidGroup.ssrcs[0];
|
1627
|
|
- const rtxSsrc = fidGroup.ssrcs[1];
|
|
1630
|
+ fidGroups.forEach(fidGroup => {
|
|
1631
|
+ const primarySsrc = fidGroup.ssrcs[0];
|
|
1632
|
+ const rtxSsrc = fidGroup.ssrcs[1];
|
1628
|
1633
|
|
1629
|
|
- rtxSsrcMapping.set(primarySsrc, rtxSsrc);
|
1630
|
|
- });
|
1631
|
|
- this.rtxModifier.setSsrcCache(rtxSsrcMapping);
|
|
1634
|
+ rtxSsrcMapping.set(primarySsrc, rtxSsrc);
|
|
1635
|
+ });
|
|
1636
|
+ this.rtxModifier.setSsrcCache(rtxSsrcMapping);
|
|
1637
|
+ }
|
1632
|
1638
|
}
|
1633
|
1639
|
}
|
1634
|
1640
|
|