watch for bad audio stream setup

This commit is contained in:
Koushik Dutta
2021-09-13 13:41:34 -07:00
parent ed8df458a4
commit 41d5d21136
4 changed files with 21 additions and 7 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/hikvision",
"version": "0.0.26",
"version": "0.0.28",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/hikvision",
"version": "0.0.26",
"version": "0.0.28",
"license": "Apache",
"dependencies": {
"@mhoc/axios-digest-auth": "^0.7.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/hikvision",
"version": "0.0.26",
"version": "0.0.28",
"description": "HikVision Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -23,6 +23,11 @@ async function readEvent(readable: Readable): Promise<HikVisionCameraEvent | voi
console.log('unhandled', Buffer.concat(buffers).toString());
}
export interface HikVisionCameraStreamSetup {
videoCodecType: string;
audioCodecType: string;
}
export class HikVisionCameraAPI {
digestAuth: AxiosDigestAuth;
@@ -33,7 +38,7 @@ export class HikVisionCameraAPI {
});
}
async isH264Stream(): Promise<boolean> {
async checkStreamSetup(): Promise<HikVisionCameraStreamSetup> {
const response = await this.digestAuth.request({
method: "GET",
responseType: 'text',
@@ -42,7 +47,13 @@ export class HikVisionCameraAPI {
// this is bad:
// <videoCodecType opt="H.264,H.265">H.265</videoCodecType>
return response.data.indexOf('>H.265</videoCodecType>') === -1;
const vcodec = response.data.match(/>(.*?)<\/videoCodecType>/);
const acodec = response.data.match(/>(.*?)<\/audioCompressionType>/);
return {
videoCodecType: vcodec[1],
audioCodecType: acodec[1],
}
}

View File

@@ -42,9 +42,13 @@ class HikVisionCamera extends RtspSmartCamera implements Camera {
const client = new HikVisionCameraAPI(this.getHttpAddress(), this.getUsername(), this.getPassword());
(async() => {
if (!await client.isH264Stream()) {
const streamSetup = await client.checkStreamSetup();
if (streamSetup.videoCodecType !== 'H.264') {
this.log.a('This camera is configured for H.265 on the main channel. Configuring it it for H.264 is recommended for optimal performance.');
}
if (streamSetup.audioCodecType !== 'AAC') {
this.log.a('This camera is configured for H.265 on the main channel. Configuring it it for AAC is recommended for optimal performance.');
}
})();
return client;
}
@@ -63,7 +67,6 @@ class HikVisionProvider extends RtspProvider {
getAdditionalInterfaces() {
return [
ScryptedInterface.Camera,
ScryptedInterface.AudioSensor,
ScryptedInterface.MotionSensor,
];
}