homekit: transcode cleanup

This commit is contained in:
Koushik Dutta
2021-11-01 11:48:55 -07:00
parent 82b5b018b9
commit e526f3c40d
5 changed files with 16 additions and 8 deletions

View File

@@ -118,8 +118,6 @@ export function getH264EncoderArgs() {
encoderArgs[name] = [
'-c:v',
encoder,
'-b:v',
'${request.video.max_bit_rate * 10}k',
]
}
return encoderArgs;

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.115",
"version": "0.0.117",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.115",
"version": "0.0.117",
"dependencies": {
"hap-nodejs": "file:../../external/HAP-NodeJS",
"lodash": "^4.17.21",

View File

@@ -40,5 +40,5 @@
"@types/qrcode": "^1.4.1",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.115"
"version": "0.0.117"
}

View File

@@ -4,6 +4,11 @@ import { getH264DecoderArgs, getH264EncoderArgs } from "../../../common/src/ffmp
const { log, systemManager, deviceManager } = sdk;
const extraEncoderArgs = [
'-b:v',
'${request.video.max_bit_rate * 2}k',
];
export class CameraMixin extends SettingsMixinDeviceBase<any> implements Settings {
constructor(mixinDevice: any, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: { [key: string]: any }, providerNativeId: string) {
super(mixinDevice, mixinDeviceState, {
@@ -84,8 +89,8 @@ export class CameraMixin extends SettingsMixinDeviceBase<any> implements Setting
}
if (showTranscodeArgs) {
const encoderArgs = getH264EncoderArgs();
const decoderArgs = getH264DecoderArgs();
const encoderArgs = getH264EncoderArgs();
settings.push({
title: 'Video Decoder Arguments',
@@ -167,7 +172,10 @@ export class CameraMixin extends SettingsMixinDeviceBase<any> implements Setting
if (key === 'h264EncoderArguments') {
const encoderArgs = getH264EncoderArgs();
const substitute = encoderArgs[value.toString()]?.join(' ');
const args = encoderArgs[value.toString()];
if (args)
args.push(...extraEncoderArgs);
const substitute = args?.join(' ');
value = substitute ? `\`${substitute}\`` : value;
}

View File

@@ -36,7 +36,9 @@ export function bindCharacteristic(device: ScryptedDevice, event: ScryptedInterf
service.getCharacteristic(characteristic).on(CharacteristicEventTypes.GET, callback => {
try {
if (device.interfaces.includes(ScryptedInterface.Refresh)) {
(device as ScryptedDevice & Refresh).refresh(event, true);
// it's not possible to determine if this is user initiated.
// homekit seems to aggressively call get...
(device as ScryptedDevice & Refresh).refresh(event, false);
}
callback(null, map());
}