google-device-access: nre fix

This commit is contained in:
Koushik Dutta
2022-01-19 23:10:35 -08:00
parent acacf3dce9
commit 7066bd6e89
9 changed files with 33 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
{
"scrypted.debugHost": "127.0.0.1",
"scrypted.debugHost": "192.168.2.119",
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/google-device-access",
"version": "0.0.45",
"version": "0.0.52",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/google-device-access",
"version": "0.0.45",
"version": "0.0.52",
"dependencies": {
"@googleapis/smartdevicemanagement": "^0.2.0",
"axios": "^0.21.1",

View File

@@ -43,5 +43,5 @@
"@types/node": "^14.17.11",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.45"
"version": "0.0.52"
}

View File

@@ -59,7 +59,7 @@ class NestCamera extends ScryptedDeviceBase implements VideoCamera, MotionSensor
this.console.log(result.data);
const expirationDate = new Date(expiresAt);
const refreshAt = expirationDate.getTime();
return mediaManager.createFFmpegMediaObject({
url: u,
mediaStreamOptions: {
@@ -347,7 +347,7 @@ class GoogleSmartDeviceAccess extends ScryptedDeviceBase implements OauthClient,
const traits = payload.resourceUpdate?.traits;
const events = payload.resourceUpdate?.events;
const nativeId = payload.resourceUpdate.name.split('/').pop();
const nativeId = payload.resourceUpdate?.name.split('/').pop();
const device = this.devices.get(nativeId);
if (device) {
if (traits) {

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.160",
"version": "0.0.161",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.160",
"version": "0.0.161",
"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.160"
"version": "0.0.161"
}

View File

@@ -23,6 +23,7 @@ import { CharacteristicEventTypes, DataStreamConnection, Service, WithUUID } fro
import { RecordingManagement } from 'hap-nodejs/src/lib/camera';
import { defaultObjectDetectionContactSensorTimeout } from '../camera-mixin';
import os from 'os';
import { levelToFfmpeg, profileToFfmpeg } from './camera/camera-utils';
const { log, mediaManager, deviceManager, systemManager } = sdk;
@@ -225,7 +226,7 @@ addSupportedType({
const videomtu = request.video.mtu;
// seems fine? no idea what to use here. this is the mtu for sending audio to homekit.
// 400 seems fine? no idea what to use here. this is the mtu for sending audio to homekit.
// from my observation of talkback packets, the max packet size is ~370, so
// I'm just guessing that HomeKit wants something similar for the audio it receives.
// going higher causes choppiness. going lower may cause other issues.
@@ -282,6 +283,8 @@ addSupportedType({
'-pix_fmt', 'yuv420p',
'-color_range', 'mpeg',
"-bf", "0",
"-profile:v", profileToFfmpeg(request.video.profile),
'-level:v', levelToFfmpeg(request.video.level),
"-b:v", request.video.max_bit_rate.toString() + "k",
"-bufsize", (2 * request.video.max_bit_rate).toString() + "k",
"-maxrate", request.video.max_bit_rate.toString() + "k",

View File

@@ -9,6 +9,7 @@ import { AudioRecordingCodecType, AudioRecordingSamplerateValues, CameraRecordin
import { FFMpegFragmentedMP4Session, startFFMPegFragmetedMP4Session } from '@scrypted/common/src/ffmpeg-mp4-parser-session';
import { evalRequest } from './camera-transcode';
import { parseFragmentedMP4 } from '@scrypted/common/src/stream-parser';
import { levelToFfmpeg, profileToFfmpeg } from './camera-utils';
const { log, mediaManager, deviceManager } = sdk;
@@ -109,19 +110,13 @@ export async function* handleFragmentsRequests(device: ScryptedDevice & VideoCam
];
}
const profile = configuration.videoCodec.profile === H264Profile.HIGH ? 'high'
: configuration.videoCodec.profile === H264Profile.MAIN ? 'main' : 'baseline';
const level = configuration.videoCodec.level === H264Level.LEVEL4_0 ? '4.0'
: configuration.videoCodec.level === H264Level.LEVEL3_2 ? '3.2' : '3.1';
let videoArgs: string[];
if (transcodeRecording) {
const h264EncoderArguments = storage.getItem('h264EncoderArguments') || '';
videoArgs = h264EncoderArguments
? evalRequest(h264EncoderArguments, request) : [
'-profile:v', profile,
'-level:v', level,
"-profile:v", profileToFfmpeg(request.video.profile),
'-level:v', levelToFfmpeg(request.video.level),
'-b:v', `${configuration.videoCodec.bitrate}k`,
'-force_key_frames', `expr:gte(t,n_forced*${iframeIntervalSeconds})`,
'-r', configuration.videoCodec.resolution[2].toString(),

View File

@@ -0,0 +1,17 @@
import { H264Profile, H264Level } from "../../hap";
export function profileToFfmpeg(profile: H264Profile): string {
if (profile === H264Profile.HIGH)
return "high";
if (profile === H264Profile.MAIN)
return "main";
return "baseline";
}
export function levelToFfmpeg(level: H264Level): string {
if (level === H264Level.LEVEL4_0)
return '4.0';
if (level === H264Level.LEVEL3_2)
return '3.2';
return '3.1';
}