react-native-webrtc 106.0.0-beta.5 → 106.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +2 -2
  2. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +18 -24
  3. package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +1 -1
  4. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +39 -62
  5. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +54 -48
  6. package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +23 -22
  7. package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +1 -1
  8. package/ios/RCTWebRTC/WebRTCModule.h +0 -8
  9. package/ios/RCTWebRTC/WebRTCModule.m +1 -20
  10. package/lib/commonjs/MediaStreamTrack.js +16 -0
  11. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  12. package/lib/commonjs/RTCPeerConnection.js +92 -109
  13. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  14. package/lib/commonjs/RTCRtpSender.js +6 -5
  15. package/lib/commonjs/RTCRtpSender.js.map +1 -1
  16. package/lib/commonjs/RTCRtpTransceiver.js +11 -42
  17. package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
  18. package/lib/commonjs/index.js +3 -0
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/MediaStreamTrack.js +17 -1
  21. package/lib/module/MediaStreamTrack.js.map +1 -1
  22. package/lib/module/RTCPeerConnection.js +92 -107
  23. package/lib/module/RTCPeerConnection.js.map +1 -1
  24. package/lib/module/RTCRtpSender.js +6 -5
  25. package/lib/module/RTCRtpSender.js.map +1 -1
  26. package/lib/module/RTCRtpTransceiver.js +11 -37
  27. package/lib/module/RTCRtpTransceiver.js.map +1 -1
  28. package/lib/module/index.js +2 -0
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/typescript/MediaStreamTrack.d.ts +9 -2
  31. package/lib/typescript/RTCPeerConnection.d.ts +5 -5
  32. package/lib/typescript/RTCRtpTransceiver.d.ts +2 -5
  33. package/package.json +2 -2
  34. package/src/MediaStreamTrack.ts +16 -1
  35. package/src/RTCPeerConnection.ts +94 -114
  36. package/src/RTCRtpSender.ts +6 -7
  37. package/src/RTCRtpTransceiver.ts +15 -38
  38. package/src/index.ts +2 -0
@@ -6,10 +6,8 @@ import { addListener, removeListener } from './EventEmitter';
6
6
  import Logger from './Logger';
7
7
  import MediaStream from './MediaStream';
8
8
  import MediaStreamTrack from './MediaStreamTrack';
9
- import MediaStreamTrackEvent from './MediaStreamTrackEvent';
10
9
  import RTCDataChannel from './RTCDataChannel';
11
10
  import RTCDataChannelEvent from './RTCDataChannelEvent';
12
- import RTCErrorEvent from './RTCErrorEvent';
13
11
  import RTCEvent from './RTCEvent';
14
12
  import RTCIceCandidate from './RTCIceCandidate';
15
13
  import RTCIceCandidateEvent from './RTCIceCandidateEvent';
@@ -43,32 +41,32 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
43
41
 
44
42
  _defineProperty(this, "iceConnectionState", 'new');
45
43
 
46
- _defineProperty(this, "_peerConnectionId", void 0);
44
+ _defineProperty(this, "_pcId", void 0);
47
45
 
48
46
  _defineProperty(this, "_transceivers", []);
49
47
 
50
48
  _defineProperty(this, "_remoteStreams", new Map());
51
49
 
52
- this._peerConnectionId = nextPeerConnectionId++;
53
- WebRTCModule.peerConnectionInit(configuration, this._peerConnectionId);
50
+ this._pcId = nextPeerConnectionId++;
51
+ WebRTCModule.peerConnectionInit(configuration, this._pcId);
54
52
 
55
53
  this._registerEvents();
56
54
 
57
- log.debug(`${this._peerConnectionId} ctor`);
55
+ log.debug(`${this._pcId} ctor`);
58
56
  }
59
57
 
60
58
  createOffer(options) {
61
- log.debug(`${this._peerConnectionId} createOffer`);
59
+ log.debug(`${this._pcId} createOffer`);
62
60
  return new Promise((resolve, reject) => {
63
- WebRTCModule.peerConnectionCreateOffer(this._peerConnectionId, RTCUtil.normalizeOfferOptions(options), (successful, data) => {
61
+ WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options), (successful, data) => {
64
62
  if (successful) {
65
- log.debug(`${this._peerConnectionId} createOffer OK`);
63
+ log.debug(`${this._pcId} createOffer OK`);
66
64
 
67
65
  this._updateTransceivers(data.transceiversInfo);
68
66
 
69
67
  resolve(data.sdpInfo);
70
68
  } else {
71
- log.debug(`${this._peerConnectionId} createOffer ERROR`);
69
+ log.debug(`${this._pcId} createOffer ERROR`);
72
70
  reject(data);
73
71
  }
74
72
  });
@@ -76,17 +74,17 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
76
74
  }
77
75
 
78
76
  createAnswer() {
79
- log.debug(`${this._peerConnectionId} createAnswer`);
77
+ log.debug(`${this._pcId} createAnswer`);
80
78
  return new Promise((resolve, reject) => {
81
- WebRTCModule.peerConnectionCreateAnswer(this._peerConnectionId, {}, (successful, data) => {
79
+ WebRTCModule.peerConnectionCreateAnswer(this._pcId, {}, (successful, data) => {
82
80
  if (successful) {
83
- log.debug(`${this._peerConnectionId} createAnswer OK`);
81
+ log.debug(`${this._pcId} createAnswer OK`);
84
82
 
85
83
  this._updateTransceivers(data.transceiversInfo);
86
84
 
87
85
  resolve(data.sdpInfo);
88
86
  } else {
89
- log.debug(`${this._peerConnectionId} createAnswer ERROR`);
87
+ log.debug(`${this._pcId} createAnswer ERROR`);
90
88
  reject(data);
91
89
  }
92
90
  });
@@ -94,11 +92,11 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
94
92
  }
95
93
 
96
94
  setConfiguration(configuration) {
97
- WebRTCModule.peerConnectionSetConfiguration(configuration, this._peerConnectionId);
95
+ WebRTCModule.peerConnectionSetConfiguration(configuration, this._pcId);
98
96
  }
99
97
 
100
98
  async setLocalDescription(sessionDescription) {
101
- log.debug(`${this._peerConnectionId} setLocalDescription`);
99
+ log.debug(`${this._pcId} setLocalDescription`);
102
100
  let desc;
103
101
 
104
102
  if (sessionDescription) {
@@ -119,18 +117,18 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
119
117
  const {
120
118
  sdpInfo,
121
119
  transceiversInfo
122
- } = await WebRTCModule.peerConnectionSetLocalDescription(this._peerConnectionId, desc);
120
+ } = await WebRTCModule.peerConnectionSetLocalDescription(this._pcId, desc);
123
121
  this.localDescription = new RTCSessionDescription(sdpInfo);
124
122
 
125
123
  this._updateTransceivers(transceiversInfo);
126
124
 
127
- log.debug(`${this._peerConnectionId} setLocalDescription OK`);
125
+ log.debug(`${this._pcId} setLocalDescription OK`);
128
126
  }
129
127
 
130
128
  setRemoteDescription(sessionDescription) {
131
129
  var _sessionDescription$s2, _desc$type;
132
130
 
133
- log.debug(`${this._peerConnectionId} setRemoteDescription`);
131
+ log.debug(`${this._pcId} setRemoteDescription`);
134
132
 
135
133
  if (!sessionDescription) {
136
134
  return Promise.reject(new Error('No session description provided'));
@@ -146,11 +144,11 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
146
144
  }
147
145
 
148
146
  return new Promise((resolve, reject) => {
149
- WebRTCModule.peerConnectionSetRemoteDescription(desc, this._peerConnectionId, (successful, data) => {
147
+ WebRTCModule.peerConnectionSetRemoteDescription(desc, this._pcId, (successful, data) => {
150
148
  if (successful) {
151
149
  var _data$newTransceivers;
152
150
 
153
- log.debug(`${this._peerConnectionId} setRemoteDescription OK`);
151
+ log.debug(`${this._pcId} setRemoteDescription OK`);
154
152
  this.remoteDescription = new RTCSessionDescription(data.sdpInfo);
155
153
  (_data$newTransceivers = data.newTransceivers) === null || _data$newTransceivers === void 0 ? void 0 : _data$newTransceivers.forEach(t => {
156
154
  const {
@@ -178,29 +176,28 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
178
176
  }
179
177
 
180
178
  async addIceCandidate(candidate) {
181
- log.debug(`${this._peerConnectionId} addIceCandidate`);
179
+ log.debug(`${this._pcId} addIceCandidate`);
182
180
 
183
181
  if (!candidate || !candidate.candidate) {
184
182
  // XXX end-of cantidates is not implemented: https://bugs.chromium.org/p/webrtc/issues/detail?id=9218
185
183
  return;
186
184
  }
187
185
 
188
- const newSdp = await WebRTCModule.peerConnectionAddICECandidate(this._peerConnectionId, candidate.toJSON ? candidate.toJSON() : candidate);
186
+ const newSdp = await WebRTCModule.peerConnectionAddICECandidate(this._pcId, candidate.toJSON ? candidate.toJSON() : candidate);
189
187
  this.remoteDescription = new RTCSessionDescription(newSdp);
190
188
  }
191
189
  /**
192
190
  * @brief Adds a new track to the {@link RTCPeerConnection},
193
- * and indicates that it is contained in the specified {@link MediaStream} array.
194
- * This method has to be synchronous as the W3C API expects a track to be return
191
+ * and indicates that it is contained in the specified {@link MediaStream}s.
192
+ * This method has to be synchronous as the W3C API expects a track to be returned
195
193
  * @param {MediaStreamTrack} track The track to be added
196
- * @param {MediaStream[]} streams An array of streams the track needs to be added to
194
+ * @param {...MediaStream} streams One or more {@link MediaStream}s the track needs to be added to
197
195
  * https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack
198
196
  */
199
197
 
200
198
 
201
199
  addTrack(track) {
202
- let streams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
203
- log.debug(`${this._peerConnectionId} addTrack`);
200
+ log.debug(`${this._pcId} addTrack`);
204
201
 
205
202
  if (this.connectionState === 'closed') {
206
203
  throw new Error('Peer Connection is closed');
@@ -210,8 +207,12 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
210
207
  throw new Error('Track already exists in a sender');
211
208
  }
212
209
 
210
+ for (var _len = arguments.length, streams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
211
+ streams[_key - 1] = arguments[_key];
212
+ }
213
+
213
214
  const streamIds = streams.map(s => s.id);
214
- const result = WebRTCModule.peerConnectionAddTrack(this._peerConnectionId, track.id, {
215
+ const result = WebRTCModule.peerConnectionAddTrack(this._pcId, track.id, {
215
216
  streamIds
216
217
  });
217
218
 
@@ -257,7 +258,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
257
258
  }
258
259
 
259
260
  addTransceiver(source, init) {
260
- log.debug(`${this._peerConnectionId} addTransceiver`);
261
+ log.debug(`${this._pcId} addTransceiver`);
261
262
  let src = {};
262
263
 
263
264
  if (source === 'audio') {
@@ -279,7 +280,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
279
280
  init.streamIds = init.streams.map(stream => stream.id);
280
281
  }
281
282
 
282
- const result = WebRTCModule.peerConnectionAddTransceiver(this._peerConnectionId, { ...src,
283
+ const result = WebRTCModule.peerConnectionAddTransceiver(this._pcId, { ...src,
283
284
  init: { ...init
284
285
  }
285
286
  });
@@ -318,9 +319,9 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
318
319
  }
319
320
 
320
321
  removeTrack(sender) {
321
- log.debug(`${this._peerConnectionId} removeTrack`);
322
+ log.debug(`${this._pcId} removeTrack`);
322
323
 
323
- if (this._peerConnectionId !== sender._peerConnectionId) {
324
+ if (this._pcId !== sender._peerConnectionId) {
324
325
  throw new Error('Sender does not belong to this peer connection');
325
326
  }
326
327
 
@@ -336,14 +337,18 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
336
337
 
337
338
  if (existingSender.track === null) {
338
339
  return;
339
- }
340
+ } // Blocking!
340
341
 
341
- WebRTCModule.peerConnectionRemoveTrack(this._peerConnectionId, sender.id);
342
+
343
+ WebRTCModule.peerConnectionRemoveTrack(this._pcId, sender.id);
344
+ existingSender._track = null;
345
+ const [existingTransceiver] = this.getTransceivers().filter(t => t.sender.id === existingSender.id);
346
+ existingTransceiver._direction = existingTransceiver.direction === 'sendrecv' ? 'recvonly' : 'inactive';
342
347
  }
343
348
 
344
349
  getStats() {
345
- log.debug(`${this._peerConnectionId} getStats`);
346
- return WebRTCModule.peerConnectionGetStats(this._peerConnectionId).then(data =>
350
+ log.debug(`${this._pcId} getStats`);
351
+ return WebRTCModule.peerConnectionGetStats(this._pcId).then(data =>
347
352
  /* On both Android and iOS it is faster to construct a single
348
353
  JSON string representing the Map of StatsReports and have it
349
354
  pass through the React Native bridge rather than the Map of
@@ -370,26 +375,25 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
370
375
  }
371
376
 
372
377
  close() {
373
- log.debug(`${this._peerConnectionId} close`); // According to the W3C spec: https://w3c.github.io/webrtc-pc/#rtcpeerconnection-interface
374
- // transceivers have to be stopped
378
+ log.debug(`${this._pcId} close`);
379
+ WebRTCModule.peerConnectionClose(this._pcId); // Mark transceivers as stopped.
375
380
 
376
381
  this._transceivers.forEach(_ref => {
377
382
  let {
378
383
  transceiver
379
384
  } = _ref;
380
- transceiver.stop();
381
- });
382
385
 
383
- WebRTCModule.peerConnectionClose(this._peerConnectionId);
386
+ transceiver._setStopped();
387
+ });
384
388
  }
385
389
 
386
390
  restartIce() {
387
- WebRTCModule.peerConnectionRestartIce(this._peerConnectionId);
391
+ WebRTCModule.peerConnectionRestartIce(this._pcId);
388
392
  }
389
393
 
390
394
  _registerEvents() {
391
395
  addListener(this, 'peerConnectionOnRenegotiationNeeded', ev => {
392
- if (ev.id !== this._peerConnectionId) {
396
+ if (ev.pcId !== this._pcId) {
393
397
  return;
394
398
  } // @ts-ignore
395
399
 
@@ -397,7 +401,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
397
401
  this.dispatchEvent(new RTCEvent('negotiationneeded'));
398
402
  });
399
403
  addListener(this, 'peerConnectionIceConnectionChanged', ev => {
400
- if (ev.id !== this._peerConnectionId) {
404
+ if (ev.pcId !== this._pcId) {
401
405
  return;
402
406
  }
403
407
 
@@ -412,7 +416,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
412
416
  this.dispatchEvent(new RTCEvent('iceconnectionstatechange'));
413
417
  });
414
418
  addListener(this, 'peerConnectionStateChanged', ev => {
415
- if (ev.id !== this._peerConnectionId) {
419
+ if (ev.pcId !== this._pcId) {
416
420
  return;
417
421
  }
418
422
 
@@ -427,7 +431,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
427
431
  this.dispatchEvent(new RTCEvent('connectionstatechange'));
428
432
  });
429
433
  addListener(this, 'peerConnectionSignalingStateChanged', ev => {
430
- if (ev.id !== this._peerConnectionId) {
434
+ if (ev.pcId !== this._pcId) {
431
435
  return;
432
436
  }
433
437
 
@@ -437,12 +441,12 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
437
441
  }); // Consider moving away from this event: https://github.com/WebKit/WebKit/pull/3953
438
442
 
439
443
  addListener(this, 'peerConnectionOnTrack', ev => {
440
- if (ev.id !== this._peerConnectionId) {
444
+ if (ev.pcId !== this._pcId) {
441
445
  return;
442
446
  }
443
447
 
444
- log.debug(`${this._peerConnectionId} ontrack`);
445
- const track = new MediaStreamTrack(ev.receiver.track);
448
+ log.debug(`${this._pcId} ontrack`);
449
+ let track;
446
450
  let transceiver; // Make sure transceivers are stored in timestamp order. Also, we have to make
447
451
  // sure we do not add a transceiver if it exists.
448
452
 
@@ -455,10 +459,19 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
455
459
  transceiver
456
460
  } = _ref2;
457
461
  return transceiver.id === ev.transceiver.id;
458
- });
462
+ }); // We need to fire this event for an existing track sometimes, like
463
+ // when the transceiver direction (on the sending side) switches from
464
+ // sendrecv to recvonly and then back.
465
+
459
466
 
460
- if (!oldTransceiver) {
461
- // Creating objects out of the event data.
467
+ if (oldTransceiver) {
468
+ transceiver = oldTransceiver;
469
+ track = transceiver._receiver._track;
470
+ transceiver._mid = ev.transceiver.mid;
471
+ transceiver._currentDirection = ev.transceiver.currentDirection;
472
+ transceiver._direction = ev.transceiver.direction;
473
+ } else {
474
+ track = new MediaStreamTrack(ev.receiver.track);
462
475
  const sender = new RTCRtpSender({ ...ev.transceiver.sender
463
476
  });
464
477
  const receiver = new RTCRtpReceiver({ ...ev.receiver,
@@ -470,12 +483,6 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
470
483
  });
471
484
 
472
485
  this._insertTransceiverSorted(ev.transceiverOrder, transceiver);
473
- } else {
474
- transceiver = oldTransceiver;
475
- transceiver._receiver._track = track;
476
- transceiver._mid = ev.transceiver.mid;
477
- transceiver._currentDirection = ev.transceiver.currentDirection;
478
- transceiver._direction = ev.transceiver.direction;
479
486
  } // Get the stream object from the event. Create if necessary.
480
487
 
481
488
 
@@ -494,7 +501,10 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
494
501
 
495
502
  const stream = this._remoteStreams.get(streamInfo.streamId);
496
503
 
497
- stream === null || stream === void 0 ? void 0 : stream._tracks.push(track);
504
+ if (!(stream !== null && stream !== void 0 && stream._tracks.includes(track))) {
505
+ stream === null || stream === void 0 ? void 0 : stream._tracks.push(track);
506
+ }
507
+
498
508
  return stream;
499
509
  });
500
510
  const eventData = {
@@ -504,43 +514,36 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
504
514
  receiver: transceiver.receiver
505
515
  }; // @ts-ignore
506
516
 
507
- this.dispatchEvent(new RTCTrackEvent('track', eventData));
517
+ this.dispatchEvent(new RTCTrackEvent('track', eventData)); // Dispatch an unmute event for the track.
518
+
519
+ track._setMutedInternal(false);
508
520
  });
509
521
  addListener(this, 'peerConnectionOnRemoveTrack', ev => {
510
- if (ev.peerConnectionId !== this._peerConnectionId) {
522
+ if (ev.pcId !== this._pcId) {
511
523
  return;
512
524
  }
513
525
 
514
- log.debug(`${this._peerConnectionId} onremovetrack`); // Based on the W3C specs https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack,
515
- // we need to remove the track from any media streams
516
- // that were previously passed to the `track` event.
526
+ log.debug(`${this._pcId} onremovetrack`); // As per the spec:
527
+ // - Remove the track from any media streams that were previously passed to the `track` event.
528
+ // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack,
529
+ // - Mark the track as muted:
530
+ // https://w3c.github.io/webrtc-pc/#process-remote-track-removal
517
531
 
518
532
  for (const stream of this._remoteStreams.values()) {
519
- const trackIdx = stream._tracks.findIndex(t => t.id === ev.trackId);
533
+ const [track] = stream._tracks.filter(t => t.id === ev.trackId);
520
534
 
521
- if (trackIdx !== -1) {
522
- stream._tracks.splice(trackIdx, 1);
523
- }
524
- }
525
- });
526
- addListener(this, 'peerConnectionOnRemoveTrackSuccessful', ev => {
527
- if (ev.peerConnectionId !== this._peerConnectionId) {
528
- return;
529
- }
535
+ if (track) {
536
+ const trackIdx = stream._tracks.indexOf(track);
530
537
 
531
- const [existingSender] = this.getSenders().filter(s => s.id === ev.senderId);
532
- const oldTrack = existingSender._track;
538
+ stream._tracks.splice(trackIdx, 1); // Dispatch a mute event for the track.
533
539
 
534
- if (oldTrack) {
535
- oldTrack._muted = true;
536
- }
537
540
 
538
- existingSender._track = null;
539
- const [existingTransceiver] = this.getTransceivers().filter(t => t.sender.id === existingSender.id);
540
- existingTransceiver._direction = existingTransceiver.direction === 'sendrecv' ? 'recvonly' : 'inactive';
541
+ track._setMutedInternal(true);
542
+ }
543
+ }
541
544
  });
542
545
  addListener(this, 'peerConnectionGotICECandidate', ev => {
543
- if (ev.id !== this._peerConnectionId) {
546
+ if (ev.pcId !== this._pcId) {
544
547
  return;
545
548
  }
546
549
 
@@ -552,7 +555,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
552
555
  }));
553
556
  });
554
557
  addListener(this, 'peerConnectionIceGatheringChanged', ev => {
555
- if (ev.id !== this._peerConnectionId) {
558
+ if (ev.pcId !== this._pcId) {
556
559
  return;
557
560
  }
558
561
 
@@ -570,7 +573,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
570
573
  this.dispatchEvent(new RTCEvent('icegatheringstatechange'));
571
574
  });
572
575
  addListener(this, 'peerConnectionDidOpenDataChannel', ev => {
573
- if (ev.id !== this._peerConnectionId) {
576
+ if (ev.pcId !== this._pcId) {
574
577
  return;
575
578
  }
576
579
 
@@ -579,34 +582,16 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
579
582
  this.dispatchEvent(new RTCDataChannelEvent('datachannel', {
580
583
  channel
581
584
  }));
582
- }); // Since the current underlying architecture performs certain actions
583
- // Asynchronously when the outer web API expects synchronous behaviour
584
- // This is the only way to report error on operations for those who wish
585
- // to handle them.
586
-
587
- addListener(this, 'peerConnectionOnError', ev => {
588
- if (ev.info.peerConnectionId !== this._peerConnectionId) {
589
- return;
590
- }
591
-
592
- log.error(`onerror: ${JSON.stringify(ev)}`); // @ts-ignore
593
-
594
- this.dispatchEvent(new RTCErrorEvent('error', ev.func, ev.message));
595
585
  });
596
586
  addListener(this, 'mediaStreamTrackMuteChanged', ev => {
597
- if (ev.peerConnectionId !== this._peerConnectionId) {
587
+ if (ev.pcId !== this._pcId) {
598
588
  return;
599
589
  }
600
590
 
601
591
  const [track] = this.getReceivers().map(r => r.track).filter(t => (t === null || t === void 0 ? void 0 : t.id) === ev.trackId);
602
592
 
603
593
  if (track) {
604
- track._muted = ev.muted;
605
- const eventName = ev.muted ? 'mute' : 'unmute'; // @ts-ignore
606
-
607
- track.dispatchEvent(new MediaStreamTrackEvent(eventName, {
608
- track
609
- }));
594
+ track._setMutedInternal(ev.muted);
610
595
  }
611
596
  });
612
597
  }
@@ -632,7 +617,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
632
617
  }
633
618
  }
634
619
 
635
- const channelInfo = WebRTCModule.createDataChannel(this._peerConnectionId, label, dataChannelDict);
620
+ const channelInfo = WebRTCModule.createDataChannel(this._pcId, label, dataChannelDict);
636
621
 
637
622
  if (channelInfo === null) {
638
623
  throw new TypeError('Failed to create new DataChannel');