@lvce-editor/renderer-process 30.28.0 → 30.29.1
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/rendererProcessMain.js +19 -6
- package/package.json +1 -1
|
@@ -9645,6 +9645,15 @@ const startWebRtcAudioStream = async options => {
|
|
|
9645
9645
|
dc.addEventListener('message', e => {
|
|
9646
9646
|
port.postMessage(e.data);
|
|
9647
9647
|
});
|
|
9648
|
+
port.onmessage = event => {
|
|
9649
|
+
const {
|
|
9650
|
+
data
|
|
9651
|
+
} = event;
|
|
9652
|
+
if (dc.readyState !== 'open') {
|
|
9653
|
+
return;
|
|
9654
|
+
}
|
|
9655
|
+
dc.send(data);
|
|
9656
|
+
};
|
|
9648
9657
|
|
|
9649
9658
|
// 3. Standard WebRTC offer/answer handshake against the Realtime API.
|
|
9650
9659
|
const offer = await pc.createOffer();
|
|
@@ -9652,10 +9661,12 @@ const startWebRtcAudioStream = async options => {
|
|
|
9652
9661
|
pcs[uid] = {
|
|
9653
9662
|
audioCtx,
|
|
9654
9663
|
connection: pc,
|
|
9664
|
+
dataChannel: dc,
|
|
9655
9665
|
micAnalyzer,
|
|
9656
9666
|
micStream,
|
|
9657
9667
|
port,
|
|
9658
|
-
remoteAnalyzer: remoteAnalyzerInstance
|
|
9668
|
+
remoteAnalyzer: remoteAnalyzerInstance,
|
|
9669
|
+
remoteAudio
|
|
9659
9670
|
};
|
|
9660
9671
|
return offer.sdp;
|
|
9661
9672
|
};
|
|
@@ -9679,10 +9690,7 @@ const setRemoteDescription = async options => {
|
|
|
9679
9690
|
};
|
|
9680
9691
|
|
|
9681
9692
|
// TODO this has a race conditon when start/stop is pressed fast
|
|
9682
|
-
const stopWebRtcAudioStream = async
|
|
9683
|
-
const {
|
|
9684
|
-
uid
|
|
9685
|
-
} = options;
|
|
9693
|
+
const stopWebRtcAudioStream = async uid => {
|
|
9686
9694
|
const pc = pcs[uid];
|
|
9687
9695
|
if (!pc) {
|
|
9688
9696
|
return;
|
|
@@ -9691,15 +9699,20 @@ const stopWebRtcAudioStream = async options => {
|
|
|
9691
9699
|
const {
|
|
9692
9700
|
audioCtx,
|
|
9693
9701
|
connection,
|
|
9702
|
+
dataChannel,
|
|
9694
9703
|
micStream,
|
|
9695
|
-
port
|
|
9704
|
+
port,
|
|
9705
|
+
remoteAudio
|
|
9696
9706
|
} = pc;
|
|
9697
9707
|
delete pcs[uid];
|
|
9708
|
+
connection.ontrack = null;
|
|
9698
9709
|
connection.close();
|
|
9710
|
+
dataChannel.close();
|
|
9699
9711
|
for (const t of micStream.getTracks()) {
|
|
9700
9712
|
t.stop();
|
|
9701
9713
|
}
|
|
9702
9714
|
port.close();
|
|
9715
|
+
remoteAudio.srcObject = null;
|
|
9703
9716
|
if (audioCtx) {
|
|
9704
9717
|
await audioCtx.close();
|
|
9705
9718
|
}
|