arnacon-webrtc-service 0.2.5 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arnacon-webrtc-service",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Arnacon WebRTC core runtime and service modules",
5
5
  "main": "./webRTCservice/core.js",
6
6
  "type": "commonjs",
@@ -260,9 +260,15 @@ class CandidateMLineStrictPeerConnection extends FakePeerConnection {
260
260
  class ParserMLineRecoveryPeerConnection extends FakePeerConnection {
261
261
  constructor(opts = {}) {
262
262
  super(opts);
263
+ const makeSender = () => ({
264
+ track: null,
265
+ async replaceTrack(nextTrack) {
266
+ this.track = nextTrack || null;
267
+ },
268
+ });
263
269
  this.transceivers = [
264
- { kind: "application", mid: "0", setDirection() {}, sender: { replaceTrack: async () => {}, track: null } },
265
- { kind: "audio", mid: "1", setDirection() {}, sender: { replaceTrack: async () => {}, track: null } },
270
+ { kind: "application", mid: "0", setDirection() {}, sender: makeSender() },
271
+ { kind: "audio", mid: "1", setDirection() {}, sender: makeSender() },
266
272
  ];
267
273
  this.failOnce = true;
268
274
  }
@@ -373,15 +373,23 @@ class WebRtcNegotiation extends CallNegotiationPort {
373
373
  // Final fallback: try creating/binding a fresh audio transceiver if the
374
374
  // implementation supports it.
375
375
  if (typeof pc.addTransceiver === "function") {
376
+ let created = null;
376
377
  try {
377
- const created = track
378
+ created = track
378
379
  ? pc.addTransceiver(track, { direction: "sendrecv" })
379
380
  : pc.addTransceiver("audio", { direction: "sendrecv" });
380
- if (created) {
381
- try { created.mid = offerMid; } catch (_) {}
382
- this._primeAudioTransceiver(created, track);
383
- }
384
381
  } catch (_) {}
382
+ // Some stacks reject addTransceiver(track) when that track is already
383
+ // attached; retry with kind-only to still create the missing MID slot.
384
+ if (!created) {
385
+ try {
386
+ created = pc.addTransceiver("audio", { direction: "sendrecv" });
387
+ } catch (_) {}
388
+ }
389
+ if (created) {
390
+ try { created.mid = offerMid; } catch (_) {}
391
+ this._primeAudioTransceiver(created, track);
392
+ }
385
393
  }
386
394
 
387
395
  if (!hasExactMid()) {
@@ -98,7 +98,8 @@ async function addIceCandidates(pc, candidates, RTCIceCandidate) {
98
98
  return (
99
99
  /m[-\s]?line not found/i.test(msg) ||
100
100
  /iceParams/i.test(msg) ||
101
- /media section/i.test(msg)
101
+ /media section/i.test(msg) ||
102
+ /reading 'kind'/i.test(msg)
102
103
  );
103
104
  };
104
105
  for (const c of (candidates || [])) {