mirror of
https://github.com/koush/scrypted.git
synced 2026-02-09 16:52:18 +00:00
unifi-protect: fix login timeout. use rtsps by default.
This commit is contained in:
1
plugins/unifi-protect/.vscode/launch.json
vendored
1
plugins/unifi-protect/.vscode/launch.json
vendored
@@ -10,6 +10,7 @@
|
||||
"port": 10081,
|
||||
"request": "attach",
|
||||
"skipFiles": [
|
||||
"**/plugin-remote-worker.*",
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"preLaunchTask": "scrypted: deploy+debug",
|
||||
|
||||
4
plugins/unifi-protect/package-lock.json
generated
4
plugins/unifi-protect/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.102",
|
||||
"version": "0.0.104",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.102",
|
||||
"version": "0.0.104",
|
||||
"license": "Apache",
|
||||
"dependencies": {
|
||||
"@koush/unifi-protect": "file:../../external/unifi-protect",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/unifi-protect",
|
||||
"version": "0.0.102",
|
||||
"version": "0.0.104",
|
||||
"description": "Unifi Protect Plugin for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -189,17 +189,6 @@ export class UnifiCamera extends ScryptedDeviceBase implements Notifier, Interco
|
||||
return mediaManager.createMediaObject(Buffer.from(data), 'image/jpeg');
|
||||
}
|
||||
|
||||
getDefaultOrderedVideoStreamOptions(vsos: MediaStreamOptions[]) {
|
||||
if (!vsos || !vsos.length)
|
||||
return vsos;
|
||||
const defaultStream = this.getDefaultStream(vsos);
|
||||
if (!defaultStream)
|
||||
return vsos;
|
||||
vsos = vsos.filter(vso => vso.id !== defaultStream?.id);
|
||||
vsos.unshift(defaultStream);
|
||||
return vsos;
|
||||
}
|
||||
|
||||
getDefaultStream(vsos: MediaStreamOptions[]) {
|
||||
let defaultStreamIndex = vsos.findIndex(vso => vso.id === this.storage.getItem('defaultStream'));
|
||||
if (defaultStreamIndex === -1)
|
||||
@@ -309,13 +298,14 @@ export class UnifiCamera extends ScryptedDeviceBase implements Notifier, Interco
|
||||
const rtspChannel = camera.channels.find(check => check.id.toString() === vso.id);
|
||||
|
||||
const { rtspAlias } = rtspChannel;
|
||||
const u = `rtsp://${this.protect.getSetting('ip')}:7447/${rtspAlias}`
|
||||
const u = `rtsps://${this.protect.getSetting('ip')}:7441/${rtspAlias}`
|
||||
|
||||
return mediaManager.createMediaObject({
|
||||
const data = Buffer.from(JSON.stringify({
|
||||
url: u,
|
||||
container: 'rtsp',
|
||||
mediaStreamOptions: this.createMediaStreamOptions(rtspChannel),
|
||||
} as MediaStreamUrl, ScryptedMimeTypes.MediaStreamUrl);
|
||||
} as MediaStreamUrl));
|
||||
return mediaManager.createMediaObject(data, ScryptedMimeTypes.MediaStreamUrl);
|
||||
}
|
||||
|
||||
createMediaStreamOptions(channel: ProtectCameraChannelConfig) {
|
||||
@@ -346,10 +336,10 @@ export class UnifiCamera extends ScryptedDeviceBase implements Notifier, Interco
|
||||
|
||||
async getVideoStreamOptions(): Promise<MediaStreamOptions[]> {
|
||||
const camera = this.findCamera();
|
||||
const video: MediaStreamOptions[] = camera.channels
|
||||
const vsos = camera.channels
|
||||
.map(channel => this.createMediaStreamOptions(channel));
|
||||
|
||||
return this.getDefaultOrderedVideoStreamOptions(video);
|
||||
return vsos;
|
||||
}
|
||||
|
||||
async setVideoStreamOptions(options: MediaStreamOptions): Promise<void> {
|
||||
@@ -361,7 +351,7 @@ export class UnifiCamera extends ScryptedDeviceBase implements Notifier, Interco
|
||||
const channel = camera.channels.find(channel => channel.id.toString() === options.id);
|
||||
|
||||
const sanitizedBitrate = Math.min(channel.maxBitrate, Math.max(channel.minBitrate, bitrate));
|
||||
this.console.log('bitrate change requested', bitrate, 'clamped to', sanitizedBitrate);
|
||||
this.console.log(channel.name, 'bitrate change requested', bitrate, 'clamped to', sanitizedBitrate);
|
||||
channel.bitrate = sanitizedBitrate;
|
||||
const cameraResult = await this.protect.api.updateCameraChannels(camera);
|
||||
if (!cameraResult) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { UnifiLock } from "./lock";
|
||||
const { deviceManager } = sdk;
|
||||
|
||||
const filter = [
|
||||
'channels',
|
||||
'recordingSchedules',
|
||||
'stats',
|
||||
'wifiConnectionState',
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from '@koush/unifi-protect'
|
||||
// export * from '@koush/unifi-protect'
|
||||
export * from '@koush/unifi-protect/src/index'
|
||||
// export * from '../../../external/unifi-protect/src/index'
|
||||
|
||||
Reference in New Issue
Block a user