mirror of
https://github.com/koush/scrypted.git
synced 2026-09-17 17:20:39 +01:00
amcrest/hikvision: add setKeepAlive to tcp socket to see if that detects terminated connections
This commit is contained in:
4
plugins/amcrest/package-lock.json
generated
4
plugins/amcrest/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/amcrest",
|
||||
"version": "0.0.101",
|
||||
"version": "0.0.102",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/amcrest",
|
||||
"version": "0.0.101",
|
||||
"version": "0.0.102",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/amcrest",
|
||||
"version": "0.0.101",
|
||||
"version": "0.0.102",
|
||||
"description": "Amcrest Plugin for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -21,7 +21,7 @@ export enum AmcrestEvent {
|
||||
}
|
||||
|
||||
export const amcrestHttpsAgent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
export class AmcrestCameraClient {
|
||||
@@ -57,6 +57,7 @@ export class AmcrestCameraClient {
|
||||
url,
|
||||
});
|
||||
const stream = response.data as IncomingMessage;
|
||||
stream.socket.setKeepAlive(true);
|
||||
let activityTimeout: NodeJS.Timeout;
|
||||
const resetActivityTimeout = () => {
|
||||
clearTimeout(activityTimeout);
|
||||
|
||||
4
plugins/hikvision/package-lock.json
generated
4
plugins/hikvision/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/hikvision",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/hikvision",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/hikvision",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"description": "HikVision Plugin for Scrypted",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Readable } from 'stream';
|
||||
import AxiosDigestAuth from '@koush/axios-digest-auth';
|
||||
import { EventEmitter } from "stream";
|
||||
import { IncomingMessage } from 'http';
|
||||
|
||||
function getChannel(channel: string) {
|
||||
return channel || '101';
|
||||
@@ -117,7 +118,8 @@ export class HikVisionCameraAPI {
|
||||
url,
|
||||
responseType: 'stream',
|
||||
});
|
||||
const stream = response.data as Readable;
|
||||
const stream = response.data as IncomingMessage;
|
||||
stream.socket.setKeepAlive(true);
|
||||
|
||||
stream.on('data', (buffer: Buffer) => {
|
||||
const data = buffer.toString();
|
||||
|
||||
@@ -81,6 +81,7 @@ export async function createRTCPeerConnectionSource(options: {
|
||||
|
||||
const pc = await peerConnection.promise;
|
||||
audioTransceiver = pc.addTransceiver("audio", setup.audio as any);
|
||||
audioTransceiver.mid = '0';
|
||||
audioTransceiver.onTrack.subscribe((track) => {
|
||||
track.onReceiveRtp.subscribe(rtp => {
|
||||
if (!gotAudio) {
|
||||
@@ -93,6 +94,7 @@ export async function createRTCPeerConnectionSource(options: {
|
||||
});
|
||||
|
||||
const videoTransceiver = pc.addTransceiver("video", setup.video as any);
|
||||
videoTransceiver.mid = '1';
|
||||
videoTransceiver.onTrack.subscribe((track) => {
|
||||
track.onReceiveRtp.subscribe(rtp => {
|
||||
if (!gotVideo) {
|
||||
@@ -157,8 +159,10 @@ export async function createRTCPeerConnectionSource(options: {
|
||||
if (type === 'offer')
|
||||
doSetup(setup);
|
||||
const pc = await peerConnection.promise;
|
||||
if (setup.datachannel)
|
||||
if (setup.datachannel) {
|
||||
pc.createDataChannel(setup.datachannel.label, setup.datachannel.dict);
|
||||
pc.sctpTransport.mid = '2';
|
||||
}
|
||||
|
||||
const gatheringPromise = pc.iceGatheringState === 'complete' ? Promise.resolve(undefined) : new Promise(resolve => pc.iceGatheringStateChange.subscribe(state => {
|
||||
if (state === 'complete')
|
||||
|
||||
Reference in New Issue
Block a user