Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote: cleanup remote hint now that rebroadcast uses external by default #594

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions plugins/remote/src/main.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -111,28 +111,15 @@ class ScryptedRemoteInstance extends ScryptedDeviceBase implements DeviceProvide
deviceManager.getDeviceState(device.nativeId).batteryLevel = (<Battery>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 = (<VideoCamera><any>remoteDevice).getVideoStream;
(<VideoCamera><any>remoteDevice).getVideoStream = async (options?: RequestMediaStreamOptions): Promise<MediaObject> => {
if (!options) {
options = {};
}
(<any>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;
(<DeviceProvider><any>remoteDevice).getDevice = async (nativeId: string): Promise<Device> => {
return <Device>plugin.devices.get(nativeId);
return <Device>this.devices.get(nativeId);
}
(<DeviceProvider><any>remoteDevice).releaseDevice = async (id: string, nativeId: string): Promise<any> => {
// don't delete the device from the remote
plugin.releaseDevice(id, nativeId);
this.releaseDevice(id, nativeId);
}
}
}
Expand Down