@whereby.com/assistant-sdk 1.2.112 → 1.2.114
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/dist/index.cjs +35 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +35 -8
- package/dist/legacy-esm.js +35 -8
- package/dist/polyfills.cjs +1 -4
- package/dist/tools.cjs +23 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -53,14 +53,10 @@ const { nonstandard: { RTCAudioSink, RTCAudioSource }, } = wrtc;
|
|
|
53
53
|
class AudioSource extends RTCAudioSource {
|
|
54
54
|
}
|
|
55
55
|
class AudioSink extends RTCAudioSink {
|
|
56
|
-
constructor(track) {
|
|
57
|
-
super(track);
|
|
58
|
-
this._sink = new RTCAudioSink(track);
|
|
59
|
-
}
|
|
60
56
|
subscribe(cb) {
|
|
61
|
-
this.
|
|
57
|
+
this.ondata = cb;
|
|
62
58
|
return () => {
|
|
63
|
-
this.
|
|
59
|
+
this.ondata = undefined;
|
|
64
60
|
};
|
|
65
61
|
}
|
|
66
62
|
}
|
|
@@ -517,6 +513,8 @@ class AudioMixer extends EventEmitter.EventEmitter {
|
|
|
517
513
|
this.mixableSlots.set(slot, "");
|
|
518
514
|
}
|
|
519
515
|
getCombinedAudioStream() {
|
|
516
|
+
if (!this.combinedAudioStream)
|
|
517
|
+
this.setupMediaStream();
|
|
520
518
|
return this.combinedAudioStream;
|
|
521
519
|
}
|
|
522
520
|
handleRemoteParticipants(participants) {
|
|
@@ -527,6 +525,8 @@ class AudioMixer extends EventEmitter.EventEmitter {
|
|
|
527
525
|
if (pid && !liveIds.has(pid))
|
|
528
526
|
this.detachMixable(pid);
|
|
529
527
|
}
|
|
528
|
+
if (!this.rtcAudioSource)
|
|
529
|
+
this.setupMediaStream();
|
|
530
530
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
531
531
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
532
532
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -548,6 +548,8 @@ class AudioMixer extends EventEmitter.EventEmitter {
|
|
|
548
548
|
if (screensharesWithAudio.length === 0) {
|
|
549
549
|
return;
|
|
550
550
|
}
|
|
551
|
+
if (!this.rtcAudioSource)
|
|
552
|
+
this.setupMediaStream();
|
|
551
553
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
552
554
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
553
555
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -562,14 +564,27 @@ class AudioMixer extends EventEmitter.EventEmitter {
|
|
|
562
564
|
this.attachMixableIfNeeded(Object.assign(Object.assign({}, s), { type: "screenshare" }));
|
|
563
565
|
}
|
|
564
566
|
stopAudioMixer() {
|
|
567
|
+
var _a;
|
|
568
|
+
for (const binding of Object.values(this.activeSlots)) {
|
|
569
|
+
if (!binding)
|
|
570
|
+
continue;
|
|
571
|
+
try {
|
|
572
|
+
binding.stop();
|
|
573
|
+
}
|
|
574
|
+
catch (e) {
|
|
575
|
+
console.error("Failed to stop existing audio track", { error: e });
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
(_a = this.combinedAudioStream) === null || _a === void 0 ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
565
579
|
if (this.ffmpegProcess) {
|
|
566
580
|
this.mixer.stopFFmpegProcess(this.ffmpegProcess);
|
|
567
581
|
this.ffmpegProcess = null;
|
|
568
582
|
}
|
|
569
583
|
this.mixableSlots = new Map(Array.from({ length: MIXER_SLOTS }, (_, i) => [i, ""]));
|
|
570
584
|
this.activeSlots = {};
|
|
571
|
-
//
|
|
572
|
-
this.
|
|
585
|
+
// The media stream is recreated lazily if the mixer is used again
|
|
586
|
+
this.combinedAudioStream = null;
|
|
587
|
+
this.rtcAudioSource = null;
|
|
573
588
|
}
|
|
574
589
|
}
|
|
575
590
|
|
|
@@ -592,6 +607,7 @@ class VideoSink extends RTCVideoSink {
|
|
|
592
607
|
class Assistant extends EventEmitter {
|
|
593
608
|
constructor({ assistantKey }) {
|
|
594
609
|
super();
|
|
610
|
+
this.audioMixer = null;
|
|
595
611
|
this.combinedAudioSink = null;
|
|
596
612
|
this.remoteMediaTracks = {};
|
|
597
613
|
this.roomUrl = null;
|
|
@@ -602,6 +618,8 @@ class Assistant extends EventEmitter {
|
|
|
602
618
|
}
|
|
603
619
|
if (["left", "kicked"].includes(status)) {
|
|
604
620
|
this.stateSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
621
|
+
this.stateSubscriptions = [];
|
|
622
|
+
this.stopCombinedAudio();
|
|
605
623
|
this.emit(ASSISTANT_LEFT_ROOM, { roomUrl: this.roomUrl || "" });
|
|
606
624
|
}
|
|
607
625
|
};
|
|
@@ -713,12 +731,21 @@ class Assistant extends EventEmitter {
|
|
|
713
731
|
const stream = audioMixer.getCombinedAudioStream();
|
|
714
732
|
const audioTracks = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks();
|
|
715
733
|
if (audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.length) {
|
|
734
|
+
this.audioMixer = audioMixer;
|
|
716
735
|
this.combinedAudioSink = new AudioSink(audioTracks[0]);
|
|
717
736
|
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(audioMixer.handleRemoteParticipants.bind(audioMixer)));
|
|
718
737
|
return this.combinedAudioSink;
|
|
719
738
|
}
|
|
739
|
+
audioMixer.stopAudioMixer();
|
|
720
740
|
return null;
|
|
721
741
|
}
|
|
742
|
+
stopCombinedAudio() {
|
|
743
|
+
var _a, _b;
|
|
744
|
+
(_a = this.combinedAudioSink) === null || _a === void 0 ? void 0 : _a.stop();
|
|
745
|
+
this.combinedAudioSink = null;
|
|
746
|
+
(_b = this.audioMixer) === null || _b === void 0 ? void 0 : _b.stopAudioMixer();
|
|
747
|
+
this.audioMixer = null;
|
|
748
|
+
}
|
|
722
749
|
}
|
|
723
750
|
|
|
724
751
|
function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
package/dist/index.d.cts
CHANGED
|
@@ -127,8 +127,6 @@ declare const RTCAudioSource: {
|
|
|
127
127
|
declare class AudioSource extends RTCAudioSource {
|
|
128
128
|
}
|
|
129
129
|
declare class AudioSink extends RTCAudioSink {
|
|
130
|
-
private _sink;
|
|
131
|
-
constructor(track: MediaStreamTrack);
|
|
132
130
|
subscribe(cb: (d: {
|
|
133
131
|
samples: Int16Array;
|
|
134
132
|
sampleRate: number;
|
|
@@ -179,6 +177,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
179
177
|
private client;
|
|
180
178
|
private roomConnection;
|
|
181
179
|
private localMedia;
|
|
180
|
+
private audioMixer;
|
|
182
181
|
private combinedAudioSink;
|
|
183
182
|
private remoteMediaTracks;
|
|
184
183
|
private roomUrl;
|
|
@@ -195,6 +194,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
195
194
|
stopLocalMedia(): void;
|
|
196
195
|
getLocalMedia(): LocalMediaClient;
|
|
197
196
|
getCombinedAudioSink(): AudioSink | null;
|
|
197
|
+
private stopCombinedAudio;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
interface TriggerOptions {
|
package/dist/index.d.mts
CHANGED
|
@@ -127,8 +127,6 @@ declare const RTCAudioSource: {
|
|
|
127
127
|
declare class AudioSource extends RTCAudioSource {
|
|
128
128
|
}
|
|
129
129
|
declare class AudioSink extends RTCAudioSink {
|
|
130
|
-
private _sink;
|
|
131
|
-
constructor(track: MediaStreamTrack);
|
|
132
130
|
subscribe(cb: (d: {
|
|
133
131
|
samples: Int16Array;
|
|
134
132
|
sampleRate: number;
|
|
@@ -179,6 +177,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
179
177
|
private client;
|
|
180
178
|
private roomConnection;
|
|
181
179
|
private localMedia;
|
|
180
|
+
private audioMixer;
|
|
182
181
|
private combinedAudioSink;
|
|
183
182
|
private remoteMediaTracks;
|
|
184
183
|
private roomUrl;
|
|
@@ -195,6 +194,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
195
194
|
stopLocalMedia(): void;
|
|
196
195
|
getLocalMedia(): LocalMediaClient;
|
|
197
196
|
getCombinedAudioSink(): AudioSink | null;
|
|
197
|
+
private stopCombinedAudio;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
interface TriggerOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -127,8 +127,6 @@ declare const RTCAudioSource: {
|
|
|
127
127
|
declare class AudioSource extends RTCAudioSource {
|
|
128
128
|
}
|
|
129
129
|
declare class AudioSink extends RTCAudioSink {
|
|
130
|
-
private _sink;
|
|
131
|
-
constructor(track: MediaStreamTrack);
|
|
132
130
|
subscribe(cb: (d: {
|
|
133
131
|
samples: Int16Array;
|
|
134
132
|
sampleRate: number;
|
|
@@ -179,6 +177,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
179
177
|
private client;
|
|
180
178
|
private roomConnection;
|
|
181
179
|
private localMedia;
|
|
180
|
+
private audioMixer;
|
|
182
181
|
private combinedAudioSink;
|
|
183
182
|
private remoteMediaTracks;
|
|
184
183
|
private roomUrl;
|
|
@@ -195,6 +194,7 @@ declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
|
195
194
|
stopLocalMedia(): void;
|
|
196
195
|
getLocalMedia(): LocalMediaClient;
|
|
197
196
|
getCombinedAudioSink(): AudioSink | null;
|
|
197
|
+
private stopCombinedAudio;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
interface TriggerOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -51,14 +51,10 @@ const { nonstandard: { RTCAudioSink, RTCAudioSource }, } = wrtc;
|
|
|
51
51
|
class AudioSource extends RTCAudioSource {
|
|
52
52
|
}
|
|
53
53
|
class AudioSink extends RTCAudioSink {
|
|
54
|
-
constructor(track) {
|
|
55
|
-
super(track);
|
|
56
|
-
this._sink = new RTCAudioSink(track);
|
|
57
|
-
}
|
|
58
54
|
subscribe(cb) {
|
|
59
|
-
this.
|
|
55
|
+
this.ondata = cb;
|
|
60
56
|
return () => {
|
|
61
|
-
this.
|
|
57
|
+
this.ondata = undefined;
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
|
@@ -515,6 +511,8 @@ class AudioMixer extends EventEmitter {
|
|
|
515
511
|
this.mixableSlots.set(slot, "");
|
|
516
512
|
}
|
|
517
513
|
getCombinedAudioStream() {
|
|
514
|
+
if (!this.combinedAudioStream)
|
|
515
|
+
this.setupMediaStream();
|
|
518
516
|
return this.combinedAudioStream;
|
|
519
517
|
}
|
|
520
518
|
handleRemoteParticipants(participants) {
|
|
@@ -525,6 +523,8 @@ class AudioMixer extends EventEmitter {
|
|
|
525
523
|
if (pid && !liveIds.has(pid))
|
|
526
524
|
this.detachMixable(pid);
|
|
527
525
|
}
|
|
526
|
+
if (!this.rtcAudioSource)
|
|
527
|
+
this.setupMediaStream();
|
|
528
528
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
529
529
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
530
530
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -546,6 +546,8 @@ class AudioMixer extends EventEmitter {
|
|
|
546
546
|
if (screensharesWithAudio.length === 0) {
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
|
+
if (!this.rtcAudioSource)
|
|
550
|
+
this.setupMediaStream();
|
|
549
551
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
550
552
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
551
553
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -560,14 +562,27 @@ class AudioMixer extends EventEmitter {
|
|
|
560
562
|
this.attachMixableIfNeeded(Object.assign(Object.assign({}, s), { type: "screenshare" }));
|
|
561
563
|
}
|
|
562
564
|
stopAudioMixer() {
|
|
565
|
+
var _a;
|
|
566
|
+
for (const binding of Object.values(this.activeSlots)) {
|
|
567
|
+
if (!binding)
|
|
568
|
+
continue;
|
|
569
|
+
try {
|
|
570
|
+
binding.stop();
|
|
571
|
+
}
|
|
572
|
+
catch (e) {
|
|
573
|
+
console.error("Failed to stop existing audio track", { error: e });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
(_a = this.combinedAudioStream) === null || _a === void 0 ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
563
577
|
if (this.ffmpegProcess) {
|
|
564
578
|
this.mixer.stopFFmpegProcess(this.ffmpegProcess);
|
|
565
579
|
this.ffmpegProcess = null;
|
|
566
580
|
}
|
|
567
581
|
this.mixableSlots = new Map(Array.from({ length: MIXER_SLOTS }, (_, i) => [i, ""]));
|
|
568
582
|
this.activeSlots = {};
|
|
569
|
-
//
|
|
570
|
-
this.
|
|
583
|
+
// The media stream is recreated lazily if the mixer is used again
|
|
584
|
+
this.combinedAudioStream = null;
|
|
585
|
+
this.rtcAudioSource = null;
|
|
571
586
|
}
|
|
572
587
|
}
|
|
573
588
|
|
|
@@ -590,6 +605,7 @@ class VideoSink extends RTCVideoSink {
|
|
|
590
605
|
class Assistant extends EventEmitter$1 {
|
|
591
606
|
constructor({ assistantKey }) {
|
|
592
607
|
super();
|
|
608
|
+
this.audioMixer = null;
|
|
593
609
|
this.combinedAudioSink = null;
|
|
594
610
|
this.remoteMediaTracks = {};
|
|
595
611
|
this.roomUrl = null;
|
|
@@ -600,6 +616,8 @@ class Assistant extends EventEmitter$1 {
|
|
|
600
616
|
}
|
|
601
617
|
if (["left", "kicked"].includes(status)) {
|
|
602
618
|
this.stateSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
619
|
+
this.stateSubscriptions = [];
|
|
620
|
+
this.stopCombinedAudio();
|
|
603
621
|
this.emit(ASSISTANT_LEFT_ROOM, { roomUrl: this.roomUrl || "" });
|
|
604
622
|
}
|
|
605
623
|
};
|
|
@@ -711,12 +729,21 @@ class Assistant extends EventEmitter$1 {
|
|
|
711
729
|
const stream = audioMixer.getCombinedAudioStream();
|
|
712
730
|
const audioTracks = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks();
|
|
713
731
|
if (audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.length) {
|
|
732
|
+
this.audioMixer = audioMixer;
|
|
714
733
|
this.combinedAudioSink = new AudioSink(audioTracks[0]);
|
|
715
734
|
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(audioMixer.handleRemoteParticipants.bind(audioMixer)));
|
|
716
735
|
return this.combinedAudioSink;
|
|
717
736
|
}
|
|
737
|
+
audioMixer.stopAudioMixer();
|
|
718
738
|
return null;
|
|
719
739
|
}
|
|
740
|
+
stopCombinedAudio() {
|
|
741
|
+
var _a, _b;
|
|
742
|
+
(_a = this.combinedAudioSink) === null || _a === void 0 ? void 0 : _a.stop();
|
|
743
|
+
this.combinedAudioSink = null;
|
|
744
|
+
(_b = this.audioMixer) === null || _b === void 0 ? void 0 : _b.stopAudioMixer();
|
|
745
|
+
this.audioMixer = null;
|
|
746
|
+
}
|
|
720
747
|
}
|
|
721
748
|
|
|
722
749
|
function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
package/dist/legacy-esm.js
CHANGED
|
@@ -51,14 +51,10 @@ const { nonstandard: { RTCAudioSink, RTCAudioSource }, } = wrtc;
|
|
|
51
51
|
class AudioSource extends RTCAudioSource {
|
|
52
52
|
}
|
|
53
53
|
class AudioSink extends RTCAudioSink {
|
|
54
|
-
constructor(track) {
|
|
55
|
-
super(track);
|
|
56
|
-
this._sink = new RTCAudioSink(track);
|
|
57
|
-
}
|
|
58
54
|
subscribe(cb) {
|
|
59
|
-
this.
|
|
55
|
+
this.ondata = cb;
|
|
60
56
|
return () => {
|
|
61
|
-
this.
|
|
57
|
+
this.ondata = undefined;
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
|
@@ -515,6 +511,8 @@ class AudioMixer extends EventEmitter {
|
|
|
515
511
|
this.mixableSlots.set(slot, "");
|
|
516
512
|
}
|
|
517
513
|
getCombinedAudioStream() {
|
|
514
|
+
if (!this.combinedAudioStream)
|
|
515
|
+
this.setupMediaStream();
|
|
518
516
|
return this.combinedAudioStream;
|
|
519
517
|
}
|
|
520
518
|
handleRemoteParticipants(participants) {
|
|
@@ -525,6 +523,8 @@ class AudioMixer extends EventEmitter {
|
|
|
525
523
|
if (pid && !liveIds.has(pid))
|
|
526
524
|
this.detachMixable(pid);
|
|
527
525
|
}
|
|
526
|
+
if (!this.rtcAudioSource)
|
|
527
|
+
this.setupMediaStream();
|
|
528
528
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
529
529
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
530
530
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -546,6 +546,8 @@ class AudioMixer extends EventEmitter {
|
|
|
546
546
|
if (screensharesWithAudio.length === 0) {
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
|
+
if (!this.rtcAudioSource)
|
|
550
|
+
this.setupMediaStream();
|
|
549
551
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
550
552
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
551
553
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -560,14 +562,27 @@ class AudioMixer extends EventEmitter {
|
|
|
560
562
|
this.attachMixableIfNeeded(Object.assign(Object.assign({}, s), { type: "screenshare" }));
|
|
561
563
|
}
|
|
562
564
|
stopAudioMixer() {
|
|
565
|
+
var _a;
|
|
566
|
+
for (const binding of Object.values(this.activeSlots)) {
|
|
567
|
+
if (!binding)
|
|
568
|
+
continue;
|
|
569
|
+
try {
|
|
570
|
+
binding.stop();
|
|
571
|
+
}
|
|
572
|
+
catch (e) {
|
|
573
|
+
console.error("Failed to stop existing audio track", { error: e });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
(_a = this.combinedAudioStream) === null || _a === void 0 ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
563
577
|
if (this.ffmpegProcess) {
|
|
564
578
|
this.mixer.stopFFmpegProcess(this.ffmpegProcess);
|
|
565
579
|
this.ffmpegProcess = null;
|
|
566
580
|
}
|
|
567
581
|
this.mixableSlots = new Map(Array.from({ length: MIXER_SLOTS }, (_, i) => [i, ""]));
|
|
568
582
|
this.activeSlots = {};
|
|
569
|
-
//
|
|
570
|
-
this.
|
|
583
|
+
// The media stream is recreated lazily if the mixer is used again
|
|
584
|
+
this.combinedAudioStream = null;
|
|
585
|
+
this.rtcAudioSource = null;
|
|
571
586
|
}
|
|
572
587
|
}
|
|
573
588
|
|
|
@@ -590,6 +605,7 @@ class VideoSink extends RTCVideoSink {
|
|
|
590
605
|
class Assistant extends EventEmitter$1 {
|
|
591
606
|
constructor({ assistantKey }) {
|
|
592
607
|
super();
|
|
608
|
+
this.audioMixer = null;
|
|
593
609
|
this.combinedAudioSink = null;
|
|
594
610
|
this.remoteMediaTracks = {};
|
|
595
611
|
this.roomUrl = null;
|
|
@@ -600,6 +616,8 @@ class Assistant extends EventEmitter$1 {
|
|
|
600
616
|
}
|
|
601
617
|
if (["left", "kicked"].includes(status)) {
|
|
602
618
|
this.stateSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
619
|
+
this.stateSubscriptions = [];
|
|
620
|
+
this.stopCombinedAudio();
|
|
603
621
|
this.emit(ASSISTANT_LEFT_ROOM, { roomUrl: this.roomUrl || "" });
|
|
604
622
|
}
|
|
605
623
|
};
|
|
@@ -711,12 +729,21 @@ class Assistant extends EventEmitter$1 {
|
|
|
711
729
|
const stream = audioMixer.getCombinedAudioStream();
|
|
712
730
|
const audioTracks = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks();
|
|
713
731
|
if (audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.length) {
|
|
732
|
+
this.audioMixer = audioMixer;
|
|
714
733
|
this.combinedAudioSink = new AudioSink(audioTracks[0]);
|
|
715
734
|
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(audioMixer.handleRemoteParticipants.bind(audioMixer)));
|
|
716
735
|
return this.combinedAudioSink;
|
|
717
736
|
}
|
|
737
|
+
audioMixer.stopAudioMixer();
|
|
718
738
|
return null;
|
|
719
739
|
}
|
|
740
|
+
stopCombinedAudio() {
|
|
741
|
+
var _a, _b;
|
|
742
|
+
(_a = this.combinedAudioSink) === null || _a === void 0 ? void 0 : _a.stop();
|
|
743
|
+
this.combinedAudioSink = null;
|
|
744
|
+
(_b = this.audioMixer) === null || _b === void 0 ? void 0 : _b.stopAudioMixer();
|
|
745
|
+
this.audioMixer = null;
|
|
746
|
+
}
|
|
720
747
|
}
|
|
721
748
|
|
|
722
749
|
function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
package/dist/polyfills.cjs
CHANGED
|
@@ -120,9 +120,6 @@ global.RTCRtpSender = wrtc.RTCRtpSender;
|
|
|
120
120
|
global.RTCRtpTransceiver = wrtc.RTCRtpTransceiver;
|
|
121
121
|
global.RTCSctpTransport = wrtc.RTCSctpTransport;
|
|
122
122
|
global.RTCSessionDescription = wrtc.RTCSessionDescription;
|
|
123
|
-
|
|
124
|
-
// with one so window listeners (e.g. "offline") attach instead of throwing; nothing fires in Node.
|
|
125
|
-
const windowEventTarget = new EventTarget();
|
|
126
|
-
global.window = Object.assign(Object.assign({}, global), { location: { pathname: "" }, screen: { width: 0 }, setInterval: global.setInterval, addEventListener: windowEventTarget.addEventListener.bind(windowEventTarget), removeEventListener: windowEventTarget.removeEventListener.bind(windowEventTarget), dispatchEvent: windowEventTarget.dispatchEvent.bind(windowEventTarget) }); // make sure all the classes / setInterval are available on window for rtcstats
|
|
123
|
+
global.window = Object.assign(Object.assign({}, global), { location: { pathname: "" }, screen: { width: 0 }, setInterval: global.setInterval }); // make sure all the classes / setInterval are available on window for rtcstats
|
|
127
124
|
|
|
128
125
|
exports.setWebsocketOrigin = setWebsocketOrigin;
|
package/dist/tools.cjs
CHANGED
|
@@ -6,14 +6,10 @@ var wrtc = require('@roamhq/wrtc');
|
|
|
6
6
|
|
|
7
7
|
const { nonstandard: { RTCAudioSink, RTCAudioSource }, } = wrtc;
|
|
8
8
|
class AudioSink extends RTCAudioSink {
|
|
9
|
-
constructor(track) {
|
|
10
|
-
super(track);
|
|
11
|
-
this._sink = new RTCAudioSink(track);
|
|
12
|
-
}
|
|
13
9
|
subscribe(cb) {
|
|
14
|
-
this.
|
|
10
|
+
this.ondata = cb;
|
|
15
11
|
return () => {
|
|
16
|
-
this.
|
|
12
|
+
this.ondata = undefined;
|
|
17
13
|
};
|
|
18
14
|
}
|
|
19
15
|
}
|
|
@@ -470,6 +466,8 @@ class AudioMixer extends events.EventEmitter {
|
|
|
470
466
|
this.mixableSlots.set(slot, "");
|
|
471
467
|
}
|
|
472
468
|
getCombinedAudioStream() {
|
|
469
|
+
if (!this.combinedAudioStream)
|
|
470
|
+
this.setupMediaStream();
|
|
473
471
|
return this.combinedAudioStream;
|
|
474
472
|
}
|
|
475
473
|
handleRemoteParticipants(participants) {
|
|
@@ -480,6 +478,8 @@ class AudioMixer extends events.EventEmitter {
|
|
|
480
478
|
if (pid && !liveIds.has(pid))
|
|
481
479
|
this.detachMixable(pid);
|
|
482
480
|
}
|
|
481
|
+
if (!this.rtcAudioSource)
|
|
482
|
+
this.setupMediaStream();
|
|
483
483
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
484
484
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
485
485
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -501,6 +501,8 @@ class AudioMixer extends events.EventEmitter {
|
|
|
501
501
|
if (screensharesWithAudio.length === 0) {
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
|
+
if (!this.rtcAudioSource)
|
|
505
|
+
this.setupMediaStream();
|
|
504
506
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
505
507
|
this.ffmpegProcess = DEBUG_MIXER_OUTPUT
|
|
506
508
|
? this.mixer.spawnFFmpegProcessDebug(this.rtcAudioSource)
|
|
@@ -515,14 +517,27 @@ class AudioMixer extends events.EventEmitter {
|
|
|
515
517
|
this.attachMixableIfNeeded(Object.assign(Object.assign({}, s), { type: "screenshare" }));
|
|
516
518
|
}
|
|
517
519
|
stopAudioMixer() {
|
|
520
|
+
var _a;
|
|
521
|
+
for (const binding of Object.values(this.activeSlots)) {
|
|
522
|
+
if (!binding)
|
|
523
|
+
continue;
|
|
524
|
+
try {
|
|
525
|
+
binding.stop();
|
|
526
|
+
}
|
|
527
|
+
catch (e) {
|
|
528
|
+
console.error("Failed to stop existing audio track", { error: e });
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
(_a = this.combinedAudioStream) === null || _a === void 0 ? void 0 : _a.getTracks().forEach((track) => track.stop());
|
|
518
532
|
if (this.ffmpegProcess) {
|
|
519
533
|
this.mixer.stopFFmpegProcess(this.ffmpegProcess);
|
|
520
534
|
this.ffmpegProcess = null;
|
|
521
535
|
}
|
|
522
536
|
this.mixableSlots = new Map(Array.from({ length: MIXER_SLOTS }, (_, i) => [i, ""]));
|
|
523
537
|
this.activeSlots = {};
|
|
524
|
-
//
|
|
525
|
-
this.
|
|
538
|
+
// The media stream is recreated lazily if the mixer is used again
|
|
539
|
+
this.combinedAudioStream = null;
|
|
540
|
+
this.rtcAudioSource = null;
|
|
526
541
|
}
|
|
527
542
|
}
|
|
528
543
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@whereby.com/assistant-sdk",
|
|
3
3
|
"description": "Assistant SDK for whereby.com",
|
|
4
4
|
"author": "Whereby AS",
|
|
5
|
-
"version": "1.2.
|
|
5
|
+
"version": "1.2.114",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"eslint": "^9.29.0",
|
|
51
51
|
"prettier": "^3.5.3",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
|
+
"@whereby.com/eslint-config": "0.1.0",
|
|
53
54
|
"@whereby.com/jest-config": "0.1.0",
|
|
54
55
|
"@whereby.com/prettier-config": "0.1.0",
|
|
55
|
-
"@whereby.com/eslint-config": "0.1.0",
|
|
56
56
|
"@whereby.com/rollup-config": "0.1.1",
|
|
57
57
|
"@whereby.com/tsconfig": "0.1.0"
|
|
58
58
|
},
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"express": "5.1.0",
|
|
65
65
|
"uuid": "^11.0.3",
|
|
66
66
|
"ws": "^8.18.0",
|
|
67
|
-
"@whereby.com/core": "1.21.
|
|
67
|
+
"@whereby.com/core": "1.21.2"
|
|
68
68
|
},
|
|
69
69
|
"prettier": "@whereby.com/prettier-config",
|
|
70
70
|
"scripts": {
|