From 4525f51f59ea77e27f18784309639cef3084d394 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sun, 30 Jan 2022 15:55:50 -0800 Subject: [PATCH] rebroadcast/ring/google-device-access: stop harassing the user to change settings on their camera when their camera does not support it. --- plugins/google-device-access/package-lock.json | 4 ++-- plugins/google-device-access/package.json | 2 +- plugins/google-device-access/src/main.ts | 2 ++ plugins/prebuffer-mixin/package-lock.json | 4 ++-- plugins/prebuffer-mixin/package.json | 2 +- plugins/prebuffer-mixin/src/main.ts | 18 +++++++++++++----- plugins/ring/package-lock.json | 4 ++-- plugins/ring/package.json | 2 +- plugins/ring/src/main.ts | 2 ++ sdk/gen/types.input.ts | 1 + sdk/package-lock.json | 4 ++-- sdk/package.json | 2 +- sdk/scrypted_python/scrypted_sdk/types.py | 3 +++ sdk/types.d.ts | 1 + sdk/types.ts | 1 + 15 files changed, 35 insertions(+), 17 deletions(-) diff --git a/plugins/google-device-access/package-lock.json b/plugins/google-device-access/package-lock.json index ee0011339..b31b5ef60 100644 --- a/plugins/google-device-access/package-lock.json +++ b/plugins/google-device-access/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/google-device-access", - "version": "0.0.77", + "version": "0.0.78", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/google-device-access", - "version": "0.0.77", + "version": "0.0.78", "dependencies": { "@googleapis/smartdevicemanagement": "^0.2.0", "axios": "^0.21.1", diff --git a/plugins/google-device-access/package.json b/plugins/google-device-access/package.json index f2ff05631..beceacf08 100644 --- a/plugins/google-device-access/package.json +++ b/plugins/google-device-access/package.json @@ -45,5 +45,5 @@ "@types/node": "^14.17.11", "@types/url-parse": "^1.4.3" }, - "version": "0.0.77" + "version": "0.0.78" } diff --git a/plugins/google-device-access/src/main.ts b/plugins/google-device-access/src/main.ts index b66ac8cb4..9dfffd51c 100644 --- a/plugins/google-device-access/src/main.ts +++ b/plugins/google-device-access/src/main.ts @@ -32,12 +32,14 @@ function getSdmRtspMediaStreamOptions(): MediaStreamOptions { codec: 'aac', }, source: 'cloud', + userConfigurable: false, }; } function getSdmRtcMediaStreamOptions(signalingMime: string): MediaStreamOptions { const ret = getRtcMediaStreamOptions('webrtc', 'WebRTC', signalingMime); ret.source = 'cloud'; + ret.userConfigurable = false; return ret; } diff --git a/plugins/prebuffer-mixin/package-lock.json b/plugins/prebuffer-mixin/package-lock.json index 828014684..f52bd1358 100644 --- a/plugins/prebuffer-mixin/package-lock.json +++ b/plugins/prebuffer-mixin/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.144", + "version": "0.1.145", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.144", + "version": "0.1.145", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/prebuffer-mixin/package.json b/plugins/prebuffer-mixin/package.json index d4da18350..7c93a6245 100644 --- a/plugins/prebuffer-mixin/package.json +++ b/plugins/prebuffer-mixin/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/prebuffer-mixin", - "version": "0.1.144", + "version": "0.1.145", "description": "Rebroadcast and Prebuffer for VideoCameras.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/prebuffer-mixin/src/main.ts b/plugins/prebuffer-mixin/src/main.ts index fe48c50fa..8a9364ba1 100644 --- a/plugins/prebuffer-mixin/src/main.ts +++ b/plugins/prebuffer-mixin/src/main.ts @@ -182,7 +182,7 @@ class PrebufferSession { { title: 'Rebroadcast Mode', group, - description: 'The stream format to use when rebroadcasting. RTP will increase startup time but may resolve PCM audio issues.', + description: 'THIS FEATURE IS IN TESTING. DO NOT CHANGE THIS FROM MPEG-TS. The stream format to use when rebroadcasting. RTP will increase startup time but may resolve PCM audio issues.', placeholder: 'MPEG-TS', choices: [ 'MPEG-TS', @@ -280,9 +280,10 @@ class PrebufferSession { ? advertisedAudioCodec?.toLowerCase() : this.detectedAudioCodec?.toLowerCase(); - if (!probingAudioCodec) { - const audioIncompatible = !COMPATIBLE_AUDIO_CODECS.includes(assumedAudioCodec); - + // after probing the audio codec is complete, alert the user with appropriate instructions. + // assume the codec is user configurable unless the camera explictly reports otherwise. + const audioIncompatible = !COMPATIBLE_AUDIO_CODECS.includes(assumedAudioCodec); + if (!probingAudioCodec && mso?.userConfigurable !== false) { if (audioIncompatible) { // show an alert that rebroadcast needs an explicit setting by the user. if (isUsingDefaultAudioConfig) { @@ -318,12 +319,19 @@ class PrebufferSession { const detectedNoAudio = this.detectedAudioCodec === null; + // if the camera reports audio is incompatible and the user can't do anything about it + // enable transcoding by default. however, still allow the user to change the settings + // in case something changed. + const mustTranscode = isUsingDefaultAudioConfig && audioIncompatible; + if (mustTranscode) + this.console.log('camera reports it is not user configurable. transcoding due to incompatible codec', assumedAudioCodec); + if (audioSoftMuted || probingAudioCodec || detectedNoAudio) { // no audio? explicitly disable it. acodec = ['-an']; this.audioDisabled = true; } - else if (pcmAudio) { + else if (pcmAudio || mustTranscode) { acodec = ['-an']; } else if (reencodeAudio || (advertisedAudioCodec && !COMPATIBLE_AUDIO_CODECS.includes(advertisedAudioCodec))) { diff --git a/plugins/ring/package-lock.json b/plugins/ring/package-lock.json index 293c455b8..65546c4b3 100644 --- a/plugins/ring/package-lock.json +++ b/plugins/ring/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/ring", - "version": "0.0.32", + "version": "0.0.33", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/ring", - "version": "0.0.32", + "version": "0.0.33", "dependencies": { "@homebridge/camera-utils": "^2.0.4", "@types/node": "^16.6.1", diff --git a/plugins/ring/package.json b/plugins/ring/package.json index 000b424ab..94667a7ed 100644 --- a/plugins/ring/package.json +++ b/plugins/ring/package.json @@ -37,5 +37,5 @@ "devDependencies": { "@scrypted/sdk": "file:../../sdk" }, - "version": "0.0.32" + "version": "0.0.33" } diff --git a/plugins/ring/src/main.ts b/plugins/ring/src/main.ts index e96302f74..60b8ed203 100644 --- a/plugins/ring/src/main.ts +++ b/plugins/ring/src/main.ts @@ -206,6 +206,7 @@ class RingCameraDevice extends ScryptedDeviceBase implements BufferConverter, De codec: 'pcm', }, source: 'cloud', + userConfigurable: false, }; } @@ -219,6 +220,7 @@ class RingCameraDevice extends ScryptedDeviceBase implements BufferConverter, De audio: { }, source: 'cloud', + userConfigurable: false, }; } diff --git a/sdk/gen/types.input.ts b/sdk/gen/types.input.ts index d47325cc3..fc8918e4e 100644 --- a/sdk/gen/types.input.ts +++ b/sdk/gen/types.input.ts @@ -381,6 +381,7 @@ export interface MediaStreamOptions { metadata?: any; source?: MediaStreamSource; + userConfigurable?: boolean; } export interface ResponseMediaStreamOptions extends MediaStreamOptions { diff --git a/sdk/package-lock.json b/sdk/package-lock.json index 9659dc3f9..3d9202b33 100644 --- a/sdk/package-lock.json +++ b/sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/sdk", - "version": "0.0.151", + "version": "0.0.152", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/sdk", - "version": "0.0.151", + "version": "0.0.152", "license": "ISC", "dependencies": { "@babel/plugin-proposal-class-properties": "^7.14.5", diff --git a/sdk/package.json b/sdk/package.json index 3f88c4d49..6a88438fe 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/sdk", - "version": "0.0.151", + "version": "0.0.152", "description": "", "main": "index.js", "scripts": { diff --git a/sdk/scrypted_python/scrypted_sdk/types.py b/sdk/scrypted_python/scrypted_sdk/types.py index eb4baf482..7e2395277 100644 --- a/sdk/scrypted_python/scrypted_sdk/types.py +++ b/sdk/scrypted_python/scrypted_sdk/types.py @@ -176,6 +176,7 @@ class ResponseMediaStreamOptions(TypedDict): prebuffer: float refreshAt: float source: MediaStreamSource + userConfigurable: bool video: VideoStreamOptions pass @@ -327,6 +328,7 @@ class MediaStreamOptions(TypedDict): name: str prebuffer: float source: MediaStreamSource + userConfigurable: bool video: VideoStreamOptions pass @@ -378,6 +380,7 @@ class RequestMediaStreamOptions(TypedDict): prebuffer: float refreshAt: float source: MediaStreamSource + userConfigurable: bool video: VideoStreamOptions pass diff --git a/sdk/types.d.ts b/sdk/types.d.ts index 8cbc4061d..bf451d9d7 100644 --- a/sdk/types.d.ts +++ b/sdk/types.d.ts @@ -505,6 +505,7 @@ export interface MediaStreamOptions { */ metadata?: any; source?: MediaStreamSource; + userConfigurable?: boolean; } export interface ResponseMediaStreamOptions extends MediaStreamOptions { /** diff --git a/sdk/types.ts b/sdk/types.ts index a22b7c40f..4ec8d001f 100644 --- a/sdk/types.ts +++ b/sdk/types.ts @@ -1030,6 +1030,7 @@ export interface MediaStreamOptions { metadata?: any; source?: MediaStreamSource; + userConfigurable?: boolean; } export interface ResponseMediaStreamOptions extends MediaStreamOptions {