mirror of
https://github.com/koush/scrypted.git
synced 2026-02-09 16:52:18 +00:00
watch for bad audio stream setup
This commit is contained in:
4
plugins/hikvision/package-lock.json
generated
4
plugins/hikvision/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/hikvision",
|
||||
"version": "0.0.26",
|
||||
"version": "0.0.28",
|
||||
"description": "HikVision Plugin for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -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],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user