From eed8fd9d14b83a4209752071640c6defe92fe101 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Wed, 1 Mar 2023 16:39:19 -0500 Subject: [PATCH] remote: cleanup remote hint now that rebroadcast uses external by default --- plugins/remote/src/main.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/plugins/remote/src/main.ts b/plugins/remote/src/main.ts index 8cd6beae38..653deb1d06 100644 --- a/plugins/remote/src/main.ts +++ b/plugins/remote/src/main.ts @@ -1,4 +1,4 @@ -import { Device, DeviceProvider, DeviceCreator, DeviceCreatorSettings, ScryptedDevice, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, Setting, Settings, Battery, VideoCamera, SettingValue, RequestMediaStreamOptions, MediaObject, DeviceManifest} from '@scrypted/sdk'; +import { Device, DeviceProvider, DeviceCreator, DeviceCreatorSettings, ScryptedDevice, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, Setting, Settings, Battery, SettingValue, DeviceManifest} from '@scrypted/sdk'; import sdk from '@scrypted/sdk'; import { StorageSettings } from '@scrypted/sdk/storage-settings'; import { connectScryptedClient, ScryptedClientStatic } from '@scrypted/client'; @@ -111,28 +111,15 @@ class ScryptedRemoteInstance extends ScryptedDeviceBase implements DeviceProvide deviceManager.getDeviceState(device.nativeId).batteryLevel = (remoteDevice).batteryLevel; } - // since the remote may be using rebroadcast, explicitly request the external - // address for video streams - if (device.interfaces.includes(ScryptedInterface.VideoCamera)) { - const remoteGetVideoStream = (remoteDevice).getVideoStream; - (remoteDevice).getVideoStream = async (options?: RequestMediaStreamOptions): Promise => { - if (!options) { - options = {}; - } - (options).route = "external"; - return await remoteGetVideoStream(options); - } - } - - // for device providers, we need to translate the nativeId + // for device providers, we intercept calls to load device representations + // stored within this plugin instance, instead of directly from the remote if (device.interfaces.includes(ScryptedInterface.DeviceProvider)) { - const plugin = this; (remoteDevice).getDevice = async (nativeId: string): Promise => { - return plugin.devices.get(nativeId); + return this.devices.get(nativeId); } (remoteDevice).releaseDevice = async (id: string, nativeId: string): Promise => { // don't delete the device from the remote - plugin.releaseDevice(id, nativeId); + this.releaseDevice(id, nativeId); } } }