From ffe00eefdf41ebab8a77f08cd601cf419338c892 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Mon, 9 May 2022 20:41:52 -0700 Subject: [PATCH] homekit: use werift src --- plugins/homekit/package-lock.json | 52 ++++++------------- plugins/homekit/package.json | 2 +- .../types/camera/camera-dynamic-bitrate.ts | 2 +- .../src/types/camera/camera-recording.ts | 2 +- .../types/camera/camera-streaming-ffmpeg.ts | 2 +- .../types/camera/camera-streaming-session.ts | 2 +- .../camera/camera-streaming-srtp-sender.ts | 10 ++-- .../src/types/camera/camera-streaming-srtp.ts | 2 +- .../src/types/camera/camera-streaming.ts | 11 ++-- .../src/types/camera/h264-packetizer.ts | 2 +- .../src/types/camera/opus-repacketizer.ts | 2 +- 11 files changed, 33 insertions(+), 56 deletions(-) diff --git a/plugins/homekit/package-lock.json b/plugins/homekit/package-lock.json index e76ac986d..d66c91e68 100644 --- a/plugins/homekit/package-lock.json +++ b/plugins/homekit/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.274", "dependencies": { "@koush/qrcode-terminal": "^0.12.0", - "@koush/werift": "file:../../external/werift/packages/webrtc", + "@koush/werift-src": "file:../../external/werift", "check-disk-space": "^3.3.0", "hap-nodejs": "file:../../external/HAP-NodeJS", "lodash": "^4.17.21", @@ -108,7 +108,8 @@ }, "../../external/werift/packages/webrtc": { "name": "@koush/werift", - "version": "0.14.5-beta7", + "version": "0.14.5", + "extraneous": true, "license": "MIT", "dependencies": { "@fidm/x509": "^1.2.1", @@ -160,7 +161,7 @@ }, "../../sdk": { "name": "@scrypted/sdk", - "version": "0.0.195", + "version": "0.0.196", "dev": true, "license": "ISC", "dependencies": { @@ -245,8 +246,8 @@ "qrcode-terminal": "bin/qrcode-terminal.js" } }, - "node_modules/@koush/werift": { - "resolved": "../../external/werift/packages/webrtc", + "node_modules/@koush/werift-src": { + "resolved": "../../external/werift", "link": true }, "node_modules/@scrypted/common": { @@ -334,49 +335,26 @@ "resolved": "https://registry.npmjs.org/@koush/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz", "integrity": "sha512-u7Yf6CBRDQg6u46O2ideBchEVLEL6KtfqdzQflVWVMJghVcfYA/HYI7V62jXKg/npZZBrUXTbggWGisYFtI3lA==" }, - "@koush/werift": { - "version": "file:../../external/werift/packages/webrtc", + "@koush/werift-src": { + "version": "file:../../external/werift", "requires": { - "@fidm/x509": "^1.2.1", - "@minhducsun2002/leb128": "^0.2.0", - "@peculiar/webcrypto": "^1.1.6", - "@peculiar/x509": "^1.2.2", - "@shinyoshiaki/ebml-builder": "^0.0.1", - "@types/aes-js": "^3.1.1", - "@types/buffer-crc32": "^0.2.0", - "@types/debug": "^4.1.7", - "@types/elliptic": "^6.4.14", - "@types/ip": "^1.1.0", "@types/jest": "^27.0.3", - "@types/lodash": "^4.14.178", "@types/node": "^17.0.0", - "@types/uuid": "^8.3.3", "@typescript-eslint/eslint-plugin": "^5.7.0", "@typescript-eslint/parser": "^5.7.0", - "aes-js": "^3.1.2", - "binary-data": "^0.6.0", - "buffer-crc32": "^0.2.13", - "date-fns": "^2.27.0", - "debug": "^4.3.3", - "elliptic": "^6.5.3", + "eslint": "^8.4.1", + "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", - "int64-buffer": "^1.0.1", - "ip": "^1.1.5", + "eslint-plugin-simple-import-sort": "^7.0.0", "jest": "^27.4.5", - "jspack": "^0.0.4", - "lodash": "^4.17.20", - "nano-time": "^1.0.0", + "lerna": "^4.0.0", "node-actionlint": "^1.2.1", - "p-cancelable": "^2.1.1", + "organize-imports-cli": "^0.9.0", "prettier": "^2.5.1", - "rx.mini": "^1.1.0", "ts-jest": "^27.1.1", "ts-node": "^10.4.0", - "turbo-crc32": "^1.0.1", - "tweetnacl": "^1.0.3", - "typedoc": "^0.22.10", - "typescript": "^4.5.4", - "uuid": "^8.3.2" + "ts-node-dev": "^1.1.7", + "typescript": "^4.5.4" } }, "@scrypted/common": { diff --git a/plugins/homekit/package.json b/plugins/homekit/package.json index 6076d1880..0df2c0470 100644 --- a/plugins/homekit/package.json +++ b/plugins/homekit/package.json @@ -29,7 +29,7 @@ "realfs": true }, "dependencies": { - "@koush/werift": "file:../../external/werift/packages/webrtc", + "@koush/werift-src": "file:../../external/werift", "@koush/qrcode-terminal": "^0.12.0", "check-disk-space": "^3.3.0", "hap-nodejs": "file:../../external/HAP-NodeJS", diff --git a/plugins/homekit/src/types/camera/camera-dynamic-bitrate.ts b/plugins/homekit/src/types/camera/camera-dynamic-bitrate.ts index 3f16a1225..b3cc5e2f4 100644 --- a/plugins/homekit/src/types/camera/camera-dynamic-bitrate.ts +++ b/plugins/homekit/src/types/camera/camera-dynamic-bitrate.ts @@ -1,4 +1,4 @@ -import { RtcpRrPacket } from '@koush/werift/lib/rtp/src/rtcp/rr'; +import type { RtcpRrPacket } from '@koush/werift-src/packages/rtp/src/rtcp/rr'; export class DynamicBitrateSession { currentBitrate: number; diff --git a/plugins/homekit/src/types/camera/camera-recording.ts b/plugins/homekit/src/types/camera/camera-recording.ts index 0113589c2..e31533415 100644 --- a/plugins/homekit/src/types/camera/camera-recording.ts +++ b/plugins/homekit/src/types/camera/camera-recording.ts @@ -201,7 +201,7 @@ export async function* handleFragmentsRequests(device: ScryptedDevice & VideoCam // starting on a non keyframe. unsure, so skip that one. // rebroadcast plugin rtsp mode is the culprit here, and there's no fix. rebroadcast // will send an extra fragment, so one can be skipped safely without any loss. - let needSkip = ffmpegInput.mediaStreamOptions?.prebuffer && ffmpegInput.container !== 'mp4'; + let needSkip = false; //ffmpegInput.mediaStreamOptions?.prebuffer && ffmpegInput.container !== 'mp4'; for await (const box of generator) { const { header, type, data } = box; // console.log('motion fragment box', type); diff --git a/plugins/homekit/src/types/camera/camera-streaming-ffmpeg.ts b/plugins/homekit/src/types/camera/camera-streaming-ffmpeg.ts index 45bfde34c..1ca86c9aa 100644 --- a/plugins/homekit/src/types/camera/camera-streaming-ffmpeg.ts +++ b/plugins/homekit/src/types/camera/camera-streaming-ffmpeg.ts @@ -1,3 +1,4 @@ +import { RtpPacket } from '@koush/werift-src/packages/rtp/src/rtp/rtp'; import { getDebugModeH264EncoderArgs } from '@scrypted/common/src/ffmpeg-hardware-acceleration'; import { createBindZero } from '@scrypted/common/src/listen-cluster'; import { ffmpegLogInitialOutput, safeKillFFmpeg, safePrintFFmpegArguments } from '@scrypted/common/src/media-helpers'; @@ -5,7 +6,6 @@ import { addTrackControls, parseSdp, replacePorts } from '@scrypted/common/src/s import sdk, { FFmpegInput, MediaStreamDestination, ScryptedDevice, VideoCamera } from '@scrypted/sdk'; import child_process from 'child_process'; import { Writable } from 'stream'; -import { RtpPacket } from '@koush/werift/lib/rtp/src/rtp/rtp'; import { AudioStreamingCodecType, SRTPCryptoSuites } from '../../hap'; import { CameraStreamingSession, waitForFirstVideoRtcp } from './camera-streaming-session'; import { startCameraStreamSrtp } from './camera-streaming-srtp'; diff --git a/plugins/homekit/src/types/camera/camera-streaming-session.ts b/plugins/homekit/src/types/camera/camera-streaming-session.ts index f2780149c..7d6dea43b 100644 --- a/plugins/homekit/src/types/camera/camera-streaming-session.ts +++ b/plugins/homekit/src/types/camera/camera-streaming-session.ts @@ -1,6 +1,6 @@ +import type { Config } from '@koush/werift-src/packages/rtp/src/srtp/session'; import { ResponseMediaStreamOptions } from '@scrypted/sdk'; import dgram from 'dgram'; -import type { Config } from '@koush/werift/lib/rtp/src/srtp/session'; import { PrepareStreamRequest, StartStreamRequest } from '../../hap'; export interface CameraStreamingSession { diff --git a/plugins/homekit/src/types/camera/camera-streaming-srtp-sender.ts b/plugins/homekit/src/types/camera/camera-streaming-srtp-sender.ts index 87cbbed91..2ba920b5c 100644 --- a/plugins/homekit/src/types/camera/camera-streaming-srtp-sender.ts +++ b/plugins/homekit/src/types/camera/camera-streaming-srtp-sender.ts @@ -1,9 +1,9 @@ +import { RtcpSenderInfo, RtcpSrPacket } from '@koush/werift-src/packages/rtp/src/rtcp/sr'; +import { RtpPacket } from '@koush/werift-src/packages/rtp/src/rtp/rtp'; +import type { Config } from '@koush/werift-src/packages/rtp/src/srtp/session'; +import { SrtcpSession } from '@koush/werift-src/packages/rtp/src/srtp/srtcp'; +import { SrtpSession } from '@koush/werift-src/packages/rtp/src/srtp/srtp'; import dgram from 'dgram'; -import { RtcpSenderInfo, RtcpSrPacket } from '@koush/werift/lib/rtp/src/rtcp/sr'; -import { RtpPacket } from '@koush/werift/lib/rtp/src/rtp/rtp'; -import { Config } from '@koush/werift/lib/rtp/src/srtp/session'; -import { SrtcpSession } from '@koush/werift/lib/rtp/src/srtp/srtcp'; -import { SrtpSession } from '@koush/werift/lib/rtp/src/srtp/srtp'; import { AudioStreamingSamplerate } from '../../hap'; import { ntpTime } from './camera-utils'; import { H264Repacketizer } from './h264-packetizer'; diff --git a/plugins/homekit/src/types/camera/camera-streaming-srtp.ts b/plugins/homekit/src/types/camera/camera-streaming-srtp.ts index 299978fd8..c343aa28d 100644 --- a/plugins/homekit/src/types/camera/camera-streaming-srtp.ts +++ b/plugins/homekit/src/types/camera/camera-streaming-srtp.ts @@ -1,10 +1,10 @@ +import { RtpPacket } from '@koush/werift-src/packages/rtp/src/rtp/rtp'; import { readLength } from '@scrypted/common/src/read-stream'; import { getSpsPps, parseSdp } from '@scrypted/common/src/sdp-utils'; import { FFmpegInput } from '@scrypted/sdk'; import net from 'net'; import { Readable } from 'stream'; import { RtspClient } from '../../../../../common/src/rtsp-server'; -import { RtpPacket } from '@koush/werift/lib/rtp/src/rtp/rtp'; import { CameraStreamingSession, waitForFirstVideoRtcp } from './camera-streaming-session'; import { createCameraStreamSender } from './camera-streaming-srtp-sender'; diff --git a/plugins/homekit/src/types/camera/camera-streaming.ts b/plugins/homekit/src/types/camera/camera-streaming.ts index 4c7ec3500..19e739484 100644 --- a/plugins/homekit/src/types/camera/camera-streaming.ts +++ b/plugins/homekit/src/types/camera/camera-streaming.ts @@ -1,15 +1,14 @@ +import type { RtcpRrPacket } from '@koush/werift-src/packages/rtp/src/rtcp/rr'; +import { RtcpPacketConverter } from '@koush/werift-src/packages/rtp/src/rtcp/rtcp'; +import { RtpPacket } from '@koush/werift-src/packages/rtp/src/rtp/rtp'; +import { ProtectionProfileAes128CmHmacSha1_80 } from '@koush/werift-src/packages/rtp/src/srtp/const'; +import { SrtcpSession } from '@koush/werift-src/packages/rtp/src/srtp/srtcp'; import { bindUdp, closeQuiet } from '@scrypted/common/src/listen-cluster'; -import { safeKillFFmpeg } from '@scrypted/common/src/media-helpers'; import { timeoutPromise } from '@scrypted/common/src/promise-utils'; import sdk, { Camera, FFmpegInput, Intercom, MediaStreamOptions, RequestMediaStreamOptions, ScryptedDevice, ScryptedInterface, ScryptedMimeTypes, VideoCamera, VideoCameraConfiguration } from '@scrypted/sdk'; import dgram, { SocketType } from 'dgram'; import { once } from 'events'; import os from 'os'; -import { RtcpRrPacket } from '@koush/werift/lib/rtp/src/rtcp/rr'; -import { RtcpPacketConverter } from '@koush/werift/lib/rtp/src/rtcp/rtcp'; -import { RtpPacket } from '@koush/werift/lib/rtp/src/rtp/rtp'; -import { ProtectionProfileAes128CmHmacSha1_80 } from '@koush/werift/lib/rtp/src/srtp/const'; -import { SrtcpSession } from '@koush/werift/lib/rtp/src/srtp/srtcp'; import { HomeKitSession } from '../../common'; import { AudioStreamingCodecType, CameraController, CameraStreamingDelegate, PrepareStreamCallback, PrepareStreamRequest, PrepareStreamResponse, StartStreamRequest, StreamingRequest, StreamRequestCallback, StreamRequestTypes } from '../../hap'; import { startRtpSink } from '../../rtp/rtp-ffmpeg-input'; diff --git a/plugins/homekit/src/types/camera/h264-packetizer.ts b/plugins/homekit/src/types/camera/h264-packetizer.ts index 36e75e25d..6026739b8 100644 --- a/plugins/homekit/src/types/camera/h264-packetizer.ts +++ b/plugins/homekit/src/types/camera/h264-packetizer.ts @@ -1,4 +1,4 @@ -import { RtpHeader, RtpPacket } from "@koush/werift/lib/rtp/src/rtp/rtp"; +import type { RtpPacket } from "@koush/werift-src/packages/rtp/src/rtp/rtp"; // https://yumichan.net/video-processing/video-compression/introduction-to-h264-nal-unit/ const NAL_TYPE_STAP_A = 24; diff --git a/plugins/homekit/src/types/camera/opus-repacketizer.ts b/plugins/homekit/src/types/camera/opus-repacketizer.ts index 086e618e4..91442a47a 100644 --- a/plugins/homekit/src/types/camera/opus-repacketizer.ts +++ b/plugins/homekit/src/types/camera/opus-repacketizer.ts @@ -1,4 +1,4 @@ -import { RtpPacket } from "@koush/werift/lib/rtp/src/rtp/rtp"; +import type { RtpPacket } from "@koush/werift-src/packages/rtp/src/rtp/rtp"; // https://datatracker.ietf.org/doc/html/rfc6716