mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 06:03:27 +00:00
webrtc: werift fixes + object leaks
This commit is contained in:
2
external/werift
vendored
2
external/werift
vendored
Submodule external/werift updated: e779c81f8f...121d562f16
4
plugins/webrtc/package-lock.json
generated
4
plugins/webrtc/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.2.85",
|
||||
"version": "0.2.86",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.2.85",
|
||||
"version": "0.2.86",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
"@scrypted/sdk": "file:../../sdk",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.2.85",
|
||||
"version": "0.2.86",
|
||||
"scripts": {
|
||||
"scrypted-setup-project": "scrypted-setup-project",
|
||||
"prescrypted-setup-project": "scrypted-package-json",
|
||||
|
||||
@@ -588,6 +588,15 @@ export class WebRTCConnectionManagement implements RTCConnectionManagement {
|
||||
requestMediaStream = async () => mediaObject;
|
||||
}
|
||||
|
||||
const wrapped: RequestMediaStream = async options => {
|
||||
if (!requestMediaStream)
|
||||
throw new Error("RequestMediaStream can't be called twice");
|
||||
const rms = requestMediaStream;
|
||||
requestMediaStream = undefined;
|
||||
const mo = rms(options);
|
||||
return sdk.connectRPCObject(mo);
|
||||
}
|
||||
|
||||
let intercom = sdk.systemManager.getDeviceById<Intercom>(mediaObject.sourceId);
|
||||
if (!intercom.interfaces?.includes(ScryptedInterface.Intercom))
|
||||
intercom = undefined;
|
||||
@@ -609,7 +618,7 @@ export class WebRTCConnectionManagement implements RTCConnectionManagement {
|
||||
const ret = await createTrackForwarder({
|
||||
timeStart,
|
||||
...logIsLocalIceTransport(console, this.pc),
|
||||
requestMediaStream,
|
||||
requestMediaStream: wrapped,
|
||||
videoTransceiver,
|
||||
audioTransceiver,
|
||||
maximumCompatibilityMode: this.maximumCompatibilityMode,
|
||||
|
||||
@@ -747,6 +747,13 @@ export async function fork() {
|
||||
try {
|
||||
const ret = await createConnection(clientSession, requireOpus, maximumCompatibilityMode, clientOptions, options);
|
||||
ret.waitClosed().finally(() => delayProcessExit());
|
||||
// let states: typeof ret.pc.iceConnectionState[] = [];
|
||||
// ret.pc.iceConnectionStateChange.subscribe(state => {
|
||||
// states.push(state);
|
||||
// });
|
||||
// setInterval(() => {
|
||||
// console.log('Connection is still active', ret.pc.connectionState, ret.pc.iceConnectionState);
|
||||
// }, 10000);
|
||||
return ret;
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
@@ -54,14 +54,15 @@ export function waitIceConnected(pc: RTCPeerConnection) {
|
||||
})
|
||||
}
|
||||
|
||||
export function waitClosed(pc: RTCPeerConnection) {
|
||||
export async function waitClosed(pc: RTCPeerConnection) {
|
||||
const connectPromise = statePromise(pc.connectionStateChange, () => {
|
||||
return isPeerConnectionClosed(pc);
|
||||
});
|
||||
const iceConnectPromise = statePromise(pc.iceConnectionStateChange, () => {
|
||||
return isPeerIceConnectionClosed(pc);
|
||||
});
|
||||
return Promise.any([connectPromise, iceConnectPromise]);
|
||||
await Promise.any([connectPromise, iceConnectPromise]);
|
||||
await pc.close();
|
||||
}
|
||||
|
||||
export function logConnectionState(console: Console, pc: RTCPeerConnection) {
|
||||
|
||||
Reference in New Issue
Block a user