|
@@ -9,6 +9,7 @@ import JitsiLocalTrack from './JitsiLocalTrack';
|
9
|
9
|
import JitsiTrackError from '../../JitsiTrackError';
|
10
|
10
|
import * as JitsiTrackErrors from '../../JitsiTrackErrors';
|
11
|
11
|
import Listenable from '../util/Listenable';
|
|
12
|
+import { safeCounterIncrement } from '../util/MathUtil';
|
12
|
13
|
import * as MediaType from '../../service/RTC/MediaType';
|
13
|
14
|
import browser from '../browser';
|
14
|
15
|
import RTCEvents from '../../service/RTC/RTCEvents';
|
|
@@ -23,8 +24,13 @@ const logger = getLogger(__filename);
|
23
|
24
|
* The counter used to generated id numbers assigned to peer connections
|
24
|
25
|
* @type {number}
|
25
|
26
|
*/
|
26
|
|
-let peerConnectionIdCounter = 1;
|
|
27
|
+let peerConnectionIdCounter = 0;
|
27
|
28
|
|
|
29
|
+/**
|
|
30
|
+ * The counter used to generate id number for the local
|
|
31
|
+ * <code>MediaStreamTrack</code>s.
|
|
32
|
+ * @type {number}
|
|
33
|
+ */
|
28
|
34
|
let rtcTrackIdCounter = 0;
|
29
|
35
|
|
30
|
36
|
/**
|
|
@@ -42,7 +48,7 @@ function createLocalTracks(tracksInfo, options) {
|
42
|
48
|
} else if (trackInfo.videoType === VideoType.CAMERA) {
|
43
|
49
|
deviceId = options.cameraDeviceId;
|
44
|
50
|
}
|
45
|
|
- rtcTrackIdCounter += 1;
|
|
51
|
+ rtcTrackIdCounter = safeCounterIncrement(rtcTrackIdCounter);
|
46
|
52
|
const localTrack = new JitsiLocalTrack({
|
47
|
53
|
...trackInfo,
|
48
|
54
|
deviceId,
|
|
@@ -85,7 +91,7 @@ function _newCreateLocalTracks(mediaStreamMetaData = []) {
|
85
|
91
|
// FIXME Move rtcTrackIdCounter to a static method in JitsiLocalTrack
|
86
|
92
|
// so RTC does not need to handle ID management. This move would be
|
87
|
93
|
// safer to do once the old createLocalTracks is removed.
|
88
|
|
- rtcTrackIdCounter += 1;
|
|
94
|
+ rtcTrackIdCounter = safeCounterIncrement(rtcTrackIdCounter);
|
89
|
95
|
|
90
|
96
|
return new JitsiLocalTrack({
|
91
|
97
|
deviceId,
|
|
@@ -441,6 +447,7 @@ export default class RTC extends Listenable {
|
441
|
447
|
{ abtestSuspendVideo: options.abtestSuspendVideo });
|
442
|
448
|
}
|
443
|
449
|
|
|
450
|
+ peerConnectionIdCounter = safeCounterIncrement(peerConnectionIdCounter);
|
444
|
451
|
const newConnection
|
445
|
452
|
= new TraceablePeerConnection(
|
446
|
453
|
this,
|
|
@@ -450,7 +457,6 @@ export default class RTC extends Listenable {
|
450
|
457
|
isP2P, options);
|
451
|
458
|
|
452
|
459
|
this.peerConnections.set(newConnection.id, newConnection);
|
453
|
|
- peerConnectionIdCounter += 1;
|
454
|
460
|
|
455
|
461
|
return newConnection;
|
456
|
462
|
}
|