|
@@ -317,6 +317,13 @@ export default function TraceablePeerConnection(
|
317
|
317
|
*/
|
318
|
318
|
this._senderMaxHeights = new Map();
|
319
|
319
|
|
|
320
|
+ /**
|
|
321
|
+ * Holds the RTCRtpTransceiver mids that the local tracks are attached to, mapped per their
|
|
322
|
+ * {@link JitsiLocalTrack.rtcId}.
|
|
323
|
+ * @type {Map<string, string>}
|
|
324
|
+ */
|
|
325
|
+ this._localTrackTransceiverMids = new Map();
|
|
326
|
+
|
320
|
327
|
// override as desired
|
321
|
328
|
this.trace = (what, info) => {
|
322
|
329
|
logger.debug(what, info);
|
|
@@ -1966,6 +1973,30 @@ TraceablePeerConnection.prototype.findSenderForTrack = function(track) {
|
1966
|
1973
|
}
|
1967
|
1974
|
};
|
1968
|
1975
|
|
|
1976
|
+/**
|
|
1977
|
+ * Processes the local description SDP and caches the mids of the mlines associated with the given tracks.
|
|
1978
|
+ *
|
|
1979
|
+ * @param {Array<JitsiLocalTrack>} localTracks - local tracks that are added to the peerconnection.
|
|
1980
|
+ * @returns {void}
|
|
1981
|
+ */
|
|
1982
|
+TraceablePeerConnection.prototype.processLocalSdpForTransceiverInfo = function(localTracks) {
|
|
1983
|
+ const localSdp = this.peerconnection.localDescription?.sdp;
|
|
1984
|
+
|
|
1985
|
+ if (!localSdp) {
|
|
1986
|
+ return;
|
|
1987
|
+ }
|
|
1988
|
+
|
|
1989
|
+ for (const localTrack of localTracks) {
|
|
1990
|
+ const mediaType = localTrack.getType();
|
|
1991
|
+ const parsedSdp = transform.parse(localSdp);
|
|
1992
|
+ const mLine = parsedSdp.media.find(mline => mline.type === mediaType);
|
|
1993
|
+
|
|
1994
|
+ if (!this._localTrackTransceiverMids.has(localTrack.rtcId)) {
|
|
1995
|
+ this._localTrackTransceiverMids.set(localTrack.rtcId, mLine.mid.toString());
|
|
1996
|
+ }
|
|
1997
|
+ }
|
|
1998
|
+};
|
|
1999
|
+
|
1969
|
2000
|
/**
|
1970
|
2001
|
* Replaces <tt>oldTrack</tt> with <tt>newTrack</tt> from the peer connection.
|
1971
|
2002
|
* Either <tt>oldTrack</tt> or <tt>newTrack</tt> can be null; replacing a valid
|
|
@@ -2011,17 +2042,21 @@ TraceablePeerConnection.prototype.replaceTrack = function(oldTrack, newTrack) {
|
2011
|
2042
|
|
2012
|
2043
|
return promise
|
2013
|
2044
|
.then(transceiver => {
|
|
2045
|
+ if (oldTrack) {
|
|
2046
|
+ this.localTracks.delete(oldTrack.rtcId);
|
|
2047
|
+ this._localTrackTransceiverMids.delete(oldTrack.rtcId);
|
|
2048
|
+ }
|
|
2049
|
+
|
2014
|
2050
|
if (newTrack) {
|
2015
|
2051
|
if (newTrack.isAudioTrack()) {
|
2016
|
2052
|
this._hasHadAudioTrack = true;
|
2017
|
2053
|
} else {
|
2018
|
2054
|
this._hasHadVideoTrack = true;
|
2019
|
2055
|
}
|
|
2056
|
+ this._localTrackTransceiverMids.set(newTrack.rtcId, transceiver?.mid?.toString());
|
|
2057
|
+ this.localTracks.set(newTrack.rtcId, newTrack);
|
2020
|
2058
|
}
|
2021
|
2059
|
|
2022
|
|
- oldTrack && this.localTracks.delete(oldTrack.rtcId);
|
2023
|
|
- newTrack && this.localTracks.set(newTrack.rtcId, newTrack);
|
2024
|
|
-
|
2025
|
2060
|
// Update the local SSRC cache for the case when one track gets replaced with another and no
|
2026
|
2061
|
// renegotiation is triggered as a result of this.
|
2027
|
2062
|
if (oldTrack && newTrack) {
|