|
|
@@ -256,6 +256,19 @@ export default function TraceablePeerConnection(
|
|
256
|
256
|
this._usesTransceiverCodecPreferences
|
|
257
|
257
|
&& logger.info('Using RTCRtpTransceiver#setCodecPreferences for codec selection');
|
|
258
|
258
|
|
|
|
259
|
+ // We currently need these flags only for FF and that's why we are updating them only for unified plan.
|
|
|
260
|
+ if (this._usesUnifiedPlan) {
|
|
|
261
|
+ /**
|
|
|
262
|
+ * Indicates whether an audio track has ever been added to the peer connection.
|
|
|
263
|
+ */
|
|
|
264
|
+ this._hasHadAudioTrack = false;
|
|
|
265
|
+
|
|
|
266
|
+ /**
|
|
|
267
|
+ * Indicates whether a video track has ever been added to the peer connection.
|
|
|
268
|
+ */
|
|
|
269
|
+ this._hasHadAudioTrack = false;
|
|
|
270
|
+ }
|
|
|
271
|
+
|
|
259
|
272
|
/**
|
|
260
|
273
|
* @type {number} The max number of stats to keep in this.stats. Limit to
|
|
261
|
274
|
* 300 values, i.e. 5 minutes; set to 0 to disable
|
|
|
@@ -1672,6 +1685,13 @@ TraceablePeerConnection.prototype.addTrack = function(track, isInitiator = false
|
|
1672
|
1685
|
logger.debug(`${this} TPC.addTrack using unified plan`);
|
|
1673
|
1686
|
try {
|
|
1674
|
1687
|
this.tpcUtils.addTrack(track, isInitiator);
|
|
|
1688
|
+ if (track) {
|
|
|
1689
|
+ if (track.isAudioTrack()) {
|
|
|
1690
|
+ this._hasHadAudioTrack = true;
|
|
|
1691
|
+ } else {
|
|
|
1692
|
+ this._hasHadVideoTrack = true;
|
|
|
1693
|
+ }
|
|
|
1694
|
+ }
|
|
1675
|
1695
|
} catch (error) {
|
|
1676
|
1696
|
logger.error(`${this} Adding track=${track} failed: ${error?.message}`);
|
|
1677
|
1697
|
|
|
|
@@ -1753,7 +1773,17 @@ TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
|
|
1753
|
1773
|
}
|
|
1754
|
1774
|
|
|
1755
|
1775
|
if (this._usesUnifiedPlan) {
|
|
1756
|
|
- return this.tpcUtils.replaceTrack(null, track).then(() => false);
|
|
|
1776
|
+ return this.tpcUtils.replaceTrack(null, track).then(() => {
|
|
|
1777
|
+ if (track) {
|
|
|
1778
|
+ if (track.isAudioTrack()) {
|
|
|
1779
|
+ this._hasHadAudioTrack = true;
|
|
|
1780
|
+ } else {
|
|
|
1781
|
+ this._hasHadVideoTrack = true;
|
|
|
1782
|
+ }
|
|
|
1783
|
+ }
|
|
|
1784
|
+
|
|
|
1785
|
+ return false;
|
|
|
1786
|
+ });
|
|
1757
|
1787
|
}
|
|
1758
|
1788
|
|
|
1759
|
1789
|
this._addStream(webRtcStream);
|
|
|
@@ -1985,6 +2015,14 @@ TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
|
|
1985
|
2015
|
|
|
1986
|
2016
|
return promise
|
|
1987
|
2017
|
.then(transceiver => {
|
|
|
2018
|
+ if (newTrack) {
|
|
|
2019
|
+ if (newTrack.isAudioTrack()) {
|
|
|
2020
|
+ this._hasHadAudioTrack = true;
|
|
|
2021
|
+ } else {
|
|
|
2022
|
+ this._hasHadVideoTrack = true;
|
|
|
2023
|
+ }
|
|
|
2024
|
+ }
|
|
|
2025
|
+
|
|
1988
|
2026
|
oldTrack && this.localTracks.delete(oldTrack.rtcId);
|
|
1989
|
2027
|
newTrack && this.localTracks.set(newTrack.rtcId, newTrack);
|
|
1990
|
2028
|
|