mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 18:12:04 +00:00
webrtc: fix race condition in address gathering
This commit is contained in:
4
plugins/webrtc/package-lock.json
generated
4
plugins/webrtc/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.18",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.18",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
"@scrypted/sdk": "file:../../sdk",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/webrtc",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.18",
|
||||
"scripts": {
|
||||
"scrypted-setup-project": "scrypted-setup-project",
|
||||
"prescrypted-setup-project": "scrypted-package-json",
|
||||
|
||||
@@ -72,14 +72,14 @@ class WebRTCMixin extends SettingsMixinDeviceBase<RTCSignalingClient & VideoCame
|
||||
if ((this.type === ScryptedDeviceType.Speaker || this.type === ScryptedDeviceType.SmartSpeaker)
|
||||
&& this.mixinDeviceInterfaces.includes(ScryptedInterface.RTCSignalingChannel)) {
|
||||
|
||||
this.console.log('starting webrtc speaker intercom');
|
||||
this.console.log('starting webrtc speaker intercom');
|
||||
|
||||
const pc = new RTCPeerConnection();
|
||||
const atrack = new MediaStreamTrack({ kind: 'audio' });
|
||||
const audioTransceiver = pc.addTransceiver(atrack);
|
||||
const weriftSignalingSession = new WeriftSignalingSession(this.console, pc);
|
||||
const control = await this.mixinDevice.startRTCSignalingSession(weriftSignalingSession);
|
||||
|
||||
|
||||
const forwarder = await createTrackForwarder({
|
||||
timeStart: Date.now(),
|
||||
videoTransceiver: undefined,
|
||||
@@ -509,7 +509,7 @@ export class WebRTCPlugin extends AutoenableMixinProvider implements DeviceCreat
|
||||
|
||||
export async function fork() {
|
||||
return {
|
||||
async createConnection(message: any, port: number, clientSession: RTCSignalingSession, maximumCompatibilityMode: boolean, transcodeWidth: number, sessionSupportsH264High: boolean, options: { disableIntercom?: boolean; configuration: RTCConfiguration, weriftConfiguration: PeerConfig; }) {
|
||||
async createConnection(message: any, portOrDummy: number | boolean, clientSession: RTCSignalingSession, maximumCompatibilityMode: boolean, transcodeWidth: number, sessionSupportsH264High: boolean, options: { disableIntercom?: boolean; configuration: RTCConfiguration, weriftConfiguration: PeerConfig; }) {
|
||||
const cleanup = new Deferred<string>();
|
||||
cleanup.promise.catch(e => this.console.log('cleaning up rtc connection:', e.message));
|
||||
cleanup.promise.finally(() => setTimeout(() => process.exit(), 10000));
|
||||
@@ -529,7 +529,8 @@ export async function fork() {
|
||||
}
|
||||
}
|
||||
|
||||
if (port) {
|
||||
if (typeof portOrDummy === 'number') {
|
||||
const port = portOrDummy;
|
||||
const socket = net.connect(port, '127.0.0.1');
|
||||
cleanup.promise.finally(() => socket.destroy());
|
||||
|
||||
@@ -548,8 +549,10 @@ export async function fork() {
|
||||
}
|
||||
else {
|
||||
pc.createDataChannel('dummy');
|
||||
const offer = await pc.createOffer();
|
||||
pc.setLocalDescription(offer);
|
||||
if (portOrDummy) {
|
||||
const offer = await pc.createOffer();
|
||||
pc.setLocalDescription(offer);
|
||||
}
|
||||
}
|
||||
|
||||
return connection;
|
||||
|
||||
Reference in New Issue
Block a user