matter-all-in-one-addon 2.3.1 → 2.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -8
- package/dist/camera/ai/camera-ai-detector.d.ts +0 -2
- package/dist/camera/ai/camera-ai-detector.js +52 -57
- package/dist/camera/ai/camera-ai-detector.js.map +1 -1
- package/dist/camera/browser-preview.d.ts +9 -0
- package/dist/camera/browser-preview.js +135 -0
- package/dist/camera/browser-preview.js.map +1 -0
- package/dist/camera/camera-source-resolver.js +5 -3
- package/dist/camera/camera-source-resolver.js.map +1 -1
- package/dist/camera/camera-types.d.ts +0 -2
- package/dist/camera/cameraui/cameraui-client.js +91 -30
- package/dist/camera/cameraui/cameraui-client.js.map +1 -1
- package/dist/camera/cameraui/cameraui-homekit-bridge.js +13 -4
- package/dist/camera/cameraui/cameraui-homekit-bridge.js.map +1 -1
- package/dist/camera/cameraui/cameraui-storage.js.map +1 -1
- package/dist/camera/cameraui/cameraui-types.d.ts +6 -2
- package/dist/camera/cameraui/ha-camera-entity.js +5 -2
- package/dist/camera/cameraui/ha-camera-entity.js.map +1 -1
- package/dist/camera/homekit/ffmpeg-helper.js +17 -35
- package/dist/camera/homekit/ffmpeg-helper.js.map +1 -1
- package/dist/camera/homekit/hevc/fmp4-hevc.js +3 -1
- package/dist/camera/homekit/hevc/fmp4-hevc.js.map +1 -1
- package/dist/camera/homekit/hevc/hevc-recording.d.ts +0 -2
- package/dist/camera/homekit/hevc/hevc-recording.js +28 -63
- package/dist/camera/homekit/hevc/hevc-recording.js.map +1 -1
- package/dist/camera/homekit/hevc/multi-tier-rtp.d.ts +1 -15
- package/dist/camera/homekit/hevc/multi-tier-rtp.js +70 -228
- package/dist/camera/homekit/hevc/multi-tier-rtp.js.map +1 -1
- package/dist/camera/homekit/hevc/sframe-rtp.d.ts +0 -2
- package/dist/camera/homekit/hevc/sframe-rtp.js +0 -25
- package/dist/camera/homekit/hevc/sframe-rtp.js.map +1 -1
- package/dist/camera/homekit/hevc/sframe.d.ts +1 -11
- package/dist/camera/homekit/hevc/sframe.js +18 -133
- package/dist/camera/homekit/hevc/sframe.js.map +1 -1
- package/dist/camera/homekit/hevc/types.js +81 -9
- package/dist/camera/homekit/hevc/types.js.map +1 -1
- package/dist/camera/homekit/hevc/webrtc-session.d.ts +3 -17
- package/dist/camera/homekit/hevc/webrtc-session.js +55 -229
- package/dist/camera/homekit/hevc/webrtc-session.js.map +1 -1
- package/dist/camera/homekit/homekit-camera-recording.delegate.d.ts +0 -1
- package/dist/camera/homekit/homekit-camera-recording.delegate.js +115 -43
- package/dist/camera/homekit/homekit-camera-recording.delegate.js.map +1 -1
- package/dist/camera/homekit/homekit-camera-stream.delegate.d.ts +4 -7
- package/dist/camera/homekit/homekit-camera-stream.delegate.js +388 -201
- package/dist/camera/homekit/homekit-camera-stream.delegate.js.map +1 -1
- package/dist/camera/homekit/homekit-camera.accessory.d.ts +7 -34
- package/dist/camera/homekit/homekit-camera.accessory.js +207 -169
- package/dist/camera/homekit/homekit-camera.accessory.js.map +1 -1
- package/dist/camera/homekit/live-view-telemetry.d.ts +0 -4
- package/dist/camera/homekit/live-view-telemetry.js.map +1 -1
- package/dist/camera/homekit/tuya-hap-talkback.d.ts +41 -0
- package/dist/camera/homekit/tuya-hap-talkback.js +326 -0
- package/dist/camera/homekit/tuya-hap-talkback.js.map +1 -0
- package/dist/camera/matter/camera-endpoint.builder.js +9 -7
- package/dist/camera/matter/camera-endpoint.builder.js.map +1 -1
- package/dist/camera/matter/camera-session-manager.d.ts +1 -0
- package/dist/camera/matter/camera-session-manager.js +2 -0
- package/dist/camera/matter/camera-session-manager.js.map +1 -1
- package/dist/camera/matter/camera-webrtc-adapter.js +32 -15
- package/dist/camera/matter/camera-webrtc-adapter.js.map +1 -1
- package/dist/camera/motion/ffmpeg-motion-detector.js +28 -14
- package/dist/camera/motion/ffmpeg-motion-detector.js.map +1 -1
- package/dist/camera/nest/nest-camera-adapter.js +9 -5
- package/dist/camera/nest/nest-camera-adapter.js.map +1 -1
- package/dist/camera/ptz/ptz-capabilities.js +3 -1
- package/dist/camera/ptz/ptz-capabilities.js.map +1 -1
- package/dist/camera/ptz/ptz-legacy-discovery.js.map +1 -1
- package/dist/camera/ptz/ptz-mqtt-publisher.js +50 -12
- package/dist/camera/ptz/ptz-mqtt-publisher.js.map +1 -1
- package/dist/camera/ptz/ptz-zones-manager.js +6 -1
- package/dist/camera/ptz/ptz-zones-manager.js.map +1 -1
- package/dist/camera/scrypted/scrypted-camera-card.js +3 -1
- package/dist/camera/scrypted/scrypted-camera-card.js.map +1 -1
- package/dist/camera/scrypted/scrypted-camera-discovery-adapter.js +7 -5
- package/dist/camera/scrypted/scrypted-camera-discovery-adapter.js.map +1 -1
- package/dist/camera/scrypted/scrypted-client-discovery-adapter.js.map +1 -1
- package/dist/camera/scrypted/scrypted-client.js +6 -5
- package/dist/camera/scrypted/scrypted-client.js.map +1 -1
- package/dist/camera/scrypted/scrypted-discovery-provider.js.map +1 -1
- package/dist/camera/scrypted/scrypted-homekit-bridge.js +6 -4
- package/dist/camera/scrypted/scrypted-homekit-bridge.js.map +1 -1
- package/dist/camera/scrypted/scrypted-reconnect-manager.js.map +1 -1
- package/dist/camera/scrypted/scrypted-runtime-facade.js +2 -2
- package/dist/camera/scrypted/scrypted-runtime-facade.js.map +1 -1
- package/dist/camera/scrypted/scrypted-runtime-ingest.js +3 -1
- package/dist/camera/scrypted/scrypted-runtime-ingest.js.map +1 -1
- package/dist/camera/scrypted/scrypted-storage.js +12 -6
- package/dist/camera/scrypted/scrypted-storage.js.map +1 -1
- package/dist/camera/scrypted/scrypted-stream-validator.js +25 -7
- package/dist/camera/scrypted/scrypted-stream-validator.js.map +1 -1
- package/dist/camera/tuya-webrtc-session.d.ts +53 -0
- package/dist/camera/tuya-webrtc-session.js +261 -0
- package/dist/camera/tuya-webrtc-session.js.map +1 -0
- package/dist/converters/sensor.converter.js +4 -1
- package/dist/converters/sensor.converter.js.map +1 -1
- package/dist/device-profiles.js +3 -1
- package/dist/device-profiles.js.map +1 -1
- package/dist/entities/air_quality.entity.js +3 -1
- package/dist/entities/air_quality.entity.js.map +1 -1
- package/dist/entities/base.entity.js +45 -17
- package/dist/entities/base.entity.js.map +1 -1
- package/dist/entities/camera.entity.d.ts +1 -0
- package/dist/entities/camera.entity.js +24 -2
- package/dist/entities/camera.entity.js.map +1 -1
- package/dist/entities/composite-device.entity.js +37 -13
- package/dist/entities/composite-device.entity.js.map +1 -1
- package/dist/entities/energy_tariff.entity.js.map +1 -1
- package/dist/entities/pet_feeder.entity.d.ts +1 -0
- package/dist/entities/pet_feeder.entity.js +12 -0
- package/dist/entities/pet_feeder.entity.js.map +1 -1
- package/dist/entities/vacuum.entity.js +16 -5
- package/dist/entities/vacuum.entity.js.map +1 -1
- package/dist/frontend/assets/index-1k-iTL-m.js +26 -0
- package/dist/frontend/assets/{index-NrzHqycm.css → index-CJdlkpIy.css} +1 -1
- package/dist/frontend/index.html +2 -2
- package/dist/hap/hap-generic-accessory.d.ts +4 -0
- package/dist/hap/hap-generic-accessory.js +512 -122
- package/dist/hap/hap-generic-accessory.js.map +1 -1
- package/dist/homeAssistant.d.ts +1 -0
- package/dist/homeAssistant.js +23 -5
- package/dist/homeAssistant.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mqtt/mqtt-client.js.map +1 -1
- package/dist/mqtt/mqtt.entity.js +41 -17
- package/dist/mqtt/mqtt.entity.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.js +83 -13
- package/dist/platform.js.map +1 -1
- package/dist/utils/atomic-json-store.js +5 -1
- package/dist/utils/atomic-json-store.js.map +1 -1
- package/dist/utils/ha-state.js +3 -1
- package/dist/utils/ha-state.js.map +1 -1
- package/dist/utils/light-color.js +3 -5
- package/dist/utils/light-color.js.map +1 -1
- package/dist/utils/matter-command-response.js.map +1 -1
- package/dist/utils/matter-firmware.js +1 -2
- package/dist/utils/matter-firmware.js.map +1 -1
- package/dist/utils/matter-protocol.d.ts +1 -0
- package/dist/utils/matter-protocol.js +30 -0
- package/dist/utils/matter-protocol.js.map +1 -0
- package/package.json +27 -19
- package/dist/camera/camera-entity-control.d.ts +0 -12
- package/dist/camera/camera-entity-control.js +0 -24
- package/dist/camera/camera-entity-control.js.map +0 -1
- package/dist/camera/homekit/hevc/bootstrap.d.ts +0 -9
- package/dist/camera/homekit/hevc/bootstrap.js +0 -47
- package/dist/camera/homekit/hevc/bootstrap.js.map +0 -1
- package/dist/camera/homekit/hevc/recording-output.d.ts +0 -2
- package/dist/camera/homekit/hevc/recording-output.js +0 -33
- package/dist/camera/homekit/hevc/recording-output.js.map +0 -1
- package/dist/camera/homekit/media-policy.d.ts +0 -25
- package/dist/camera/homekit/media-policy.js +0 -102
- package/dist/camera/homekit/media-policy.js.map +0 -1
- package/dist/camera/homekit/route-address.d.ts +0 -2
- package/dist/camera/homekit/route-address.js +0 -27
- package/dist/camera/homekit/route-address.js.map +0 -1
- package/dist/camera/homekit/rtp-relay.d.ts +0 -21
- package/dist/camera/homekit/rtp-relay.js +0 -112
- package/dist/camera/homekit/rtp-relay.js.map +0 -1
- package/dist/camera/homekit/startup-timing.d.ts +0 -8
- package/dist/camera/homekit/startup-timing.js +0 -14
- package/dist/camera/homekit/startup-timing.js.map +0 -1
- package/dist/camera/source-adapter.d.ts +0 -132
- package/dist/camera/source-adapter.js +0 -282
- package/dist/camera/source-adapter.js.map +0 -1
- package/dist/frontend/assets/index-Bka3TVAQ.js +0 -21
- package/vendor/hap-nodejs/LICENSE +0 -176
- package/vendor/hap-nodejs/MIAO.md +0 -5
- package/vendor/hap-nodejs/PATCH.md +0 -37
- package/vendor/hap-nodejs/README.md +0 -86
- package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.js +0 -128
- package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.js +0 -159
- package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Camera_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Camera_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Camera_accessory.js +0 -545
- package/vendor/hap-nodejs/dist/accessories/Camera_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Fan_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Fan_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Fan_accessory.js +0 -74
- package/vendor/hap-nodejs/dist/accessories/Fan_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.js +0 -78
- package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -106
- package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Light_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Light_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Light_accessory.js +0 -145
- package/vendor/hap-nodejs/dist/accessories/Light_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Lock_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Lock_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Lock_accessory.js +0 -76
- package/vendor/hap-nodejs/dist/accessories/Lock_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.js +0 -45
- package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.js +0 -79
- package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.js +0 -44
- package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.js +0 -128
- package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/TV_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/TV_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/TV_accessory.js +0 -101
- package/vendor/hap-nodejs/dist/accessories/TV_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
- package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.js +0 -44
- package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
- package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.js +0 -17
- package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
- package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.js +0 -19
- package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
- package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.js +0 -145
- package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.js.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/types.d.ts +0 -78
- package/vendor/hap-nodejs/dist/accessories/types.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/accessories/types.js +0 -88
- package/vendor/hap-nodejs/dist/accessories/types.js.map +0 -1
- package/vendor/hap-nodejs/dist/index.d.ts +0 -50
- package/vendor/hap-nodejs/dist/index.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/index.js +0 -54
- package/vendor/hap-nodejs/dist/index.js.map +0 -1
- package/vendor/hap-nodejs/dist/internal-types.d.ts +0 -76
- package/vendor/hap-nodejs/dist/internal-types.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/internal-types.js +0 -80
- package/vendor/hap-nodejs/dist/internal-types.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Accessory.d.ts +0 -521
- package/vendor/hap-nodejs/dist/lib/Accessory.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Accessory.js +0 -1762
- package/vendor/hap-nodejs/dist/lib/Accessory.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Advertiser.d.ts +0 -190
- package/vendor/hap-nodejs/dist/lib/Advertiser.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Advertiser.js +0 -592
- package/vendor/hap-nodejs/dist/lib/Advertiser.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Bridge.d.ts +0 -12
- package/vendor/hap-nodejs/dist/lib/Bridge.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Bridge.js +0 -19
- package/vendor/hap-nodejs/dist/lib/Bridge.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Characteristic.d.ts +0 -1768
- package/vendor/hap-nodejs/dist/lib/Characteristic.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Characteristic.js +0 -2532
- package/vendor/hap-nodejs/dist/lib/Characteristic.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/HAPServer.d.ts +0 -299
- package/vendor/hap-nodejs/dist/lib/HAPServer.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/HAPServer.js +0 -968
- package/vendor/hap-nodejs/dist/lib/HAPServer.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Service.d.ts +0 -598
- package/vendor/hap-nodejs/dist/lib/Service.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/Service.js +0 -797
- package/vendor/hap-nodejs/dist/lib/Service.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.d.ts +0 -102
- package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.js +0 -317
- package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.d.ts +0 -38
- package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.js +0 -174
- package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.d.ts +0 -59
- package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.js +0 -267
- package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.d.ts +0 -379
- package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.js +0 -1021
- package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.d.ts +0 -325
- package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.js +0 -800
- package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.d.ts +0 -20
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.js +0 -48
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.d.ts +0 -618
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.js +0 -911
- package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/index.d.ts +0 -8
- package/vendor/hap-nodejs/dist/lib/camera/index.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/camera/index.js +0 -11
- package/vendor/hap-nodejs/dist/lib/camera/index.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.d.ts +0 -452
- package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.js +0 -868
- package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/CameraController.d.ts +0 -410
- package/vendor/hap-nodejs/dist/lib/controller/CameraController.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/CameraController.js +0 -658
- package/vendor/hap-nodejs/dist/lib/controller/CameraController.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/Controller.d.ts +0 -197
- package/vendor/hap-nodejs/dist/lib/controller/Controller.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/Controller.js +0 -32
- package/vendor/hap-nodejs/dist/lib/controller/Controller.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.d.ts +0 -59
- package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.js +0 -102
- package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/RemoteController.d.ts +0 -434
- package/vendor/hap-nodejs/dist/lib/controller/RemoteController.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/RemoteController.js +0 -1178
- package/vendor/hap-nodejs/dist/lib/controller/RemoteController.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.d.ts +0 -380
- package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.js +0 -947
- package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/index.d.ts +0 -7
- package/vendor/hap-nodejs/dist/lib/controller/index.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/controller/index.js +0 -10
- package/vendor/hap-nodejs/dist/lib/controller/index.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.d.ts +0 -73
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.js +0 -205
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.d.ts +0 -186
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.js +0 -880
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.d.ts +0 -351
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.js +0 -878
- package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/index.d.ts +0 -4
- package/vendor/hap-nodejs/dist/lib/datastream/index.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/datastream/index.js +0 -7
- package/vendor/hap-nodejs/dist/lib/datastream/index.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -2245
- package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.js +0 -4957
- package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.d.ts +0 -584
- package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.js +0 -1518
- package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.d.ts +0 -34
- package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.js +0 -624
- package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.d.ts +0 -22
- package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.js +0 -734
- package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/index.d.ts +0 -3
- package/vendor/hap-nodejs/dist/lib/definitions/index.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/definitions/index.js +0 -6
- package/vendor/hap-nodejs/dist/lib/definitions/index.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/gen/HomeKit.d.ts +0 -8
- package/vendor/hap-nodejs/dist/lib/gen/HomeKit.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/gen/HomeKit.js +0 -9
- package/vendor/hap-nodejs/dist/lib/gen/HomeKit.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.d.ts +0 -91
- package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.js +0 -311
- package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.d.ts +0 -46
- package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.js +0 -277
- package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.d.ts +0 -75
- package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.js +0 -190
- package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/HAPStorage.d.ts +0 -26
- package/vendor/hap-nodejs/dist/lib/model/HAPStorage.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/HAPStorage.js +0 -79
- package/vendor/hap-nodejs/dist/lib/model/HAPStorage.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.d.ts +0 -33
- package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.js +0 -114
- package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.d.ts +0 -83
- package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.js +0 -127
- package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/checkName.d.ts +0 -8
- package/vendor/hap-nodejs/dist/lib/util/checkName.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/checkName.js +0 -28
- package/vendor/hap-nodejs/dist/lib/util/checkName.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/clone.d.ts +0 -7
- package/vendor/hap-nodejs/dist/lib/util/clone.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/clone.js +0 -22
- package/vendor/hap-nodejs/dist/lib/util/clone.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/color-utils.d.ts +0 -18
- package/vendor/hap-nodejs/dist/lib/util/color-utils.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/color-utils.js +0 -442
- package/vendor/hap-nodejs/dist/lib/util/color-utils.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/eventedhttp.d.ts +0 -251
- package/vendor/hap-nodejs/dist/lib/util/eventedhttp.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/eventedhttp.js +0 -714
- package/vendor/hap-nodejs/dist/lib/util/eventedhttp.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/hapCrypto.d.ts +0 -50
- package/vendor/hap-nodejs/dist/lib/util/hapCrypto.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/hapCrypto.js +0 -185
- package/vendor/hap-nodejs/dist/lib/util/hapCrypto.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/hapStatusError.d.ts +0 -16
- package/vendor/hap-nodejs/dist/lib/util/hapStatusError.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/hapStatusError.js +0 -29
- package/vendor/hap-nodejs/dist/lib/util/hapStatusError.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/net-utils.d.ts +0 -21
- package/vendor/hap-nodejs/dist/lib/util/net-utils.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/net-utils.js +0 -79
- package/vendor/hap-nodejs/dist/lib/util/net-utils.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/once.d.ts +0 -7
- package/vendor/hap-nodejs/dist/lib/util/once.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/once.js +0 -22
- package/vendor/hap-nodejs/dist/lib/util/once.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/promise-utils.d.ts +0 -14
- package/vendor/hap-nodejs/dist/lib/util/promise-utils.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/promise-utils.js +0 -29
- package/vendor/hap-nodejs/dist/lib/util/promise-utils.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/request-util.d.ts +0 -36
- package/vendor/hap-nodejs/dist/lib/util/request-util.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/request-util.js +0 -108
- package/vendor/hap-nodejs/dist/lib/util/request-util.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/time.d.ts +0 -9
- package/vendor/hap-nodejs/dist/lib/util/time.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/time.js +0 -23
- package/vendor/hap-nodejs/dist/lib/util/time.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/tlv.d.ts +0 -90
- package/vendor/hap-nodejs/dist/lib/util/tlv.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/tlv.js +0 -318
- package/vendor/hap-nodejs/dist/lib/util/tlv.js.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/uuid.d.ts +0 -23
- package/vendor/hap-nodejs/dist/lib/util/uuid.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/lib/util/uuid.js +0 -78
- package/vendor/hap-nodejs/dist/lib/util/uuid.js.map +0 -1
- package/vendor/hap-nodejs/dist/types.d.ts +0 -276
- package/vendor/hap-nodejs/dist/types.d.ts.map +0 -1
- package/vendor/hap-nodejs/dist/types.js +0 -11
- package/vendor/hap-nodejs/dist/types.js.map +0 -1
- package/vendor/hap-nodejs/package.json +0 -53
- package/vendor/hap-nodejs/src/lib/util/hapCrypto.ts +0 -208
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StreamStartupTiming } from "./startup-timing.js";
|
|
3
|
-
import { routeAddress } from "./route-address.js";
|
|
4
|
-
import { CameraSourceAdapter } from "../source-adapter.js";
|
|
5
|
-
import { h264AudioPlan, h264VideoPlan, verifiedH264Encoder, } from "./media-policy.js";
|
|
1
|
+
import { TuyaHapTalkback } from "./tuya-hap-talkback.js";
|
|
6
2
|
import { EventEmitter } from "node:events";
|
|
7
3
|
import fs from "node:fs/promises";
|
|
8
4
|
import fsSync from "node:fs";
|
|
@@ -11,7 +7,7 @@ import { spawn } from "node:child_process";
|
|
|
11
7
|
import dgram from "node:dgram";
|
|
12
8
|
import { isIPv4, isIPv6 } from "node:net";
|
|
13
9
|
import { CameraSourceResolver } from "../camera-source-resolver.js";
|
|
14
|
-
import { getFfmpegVersion, resolveFfmpegPath, supportsFdkAac, checkAudioPassthroughCompatibility, } from "./ffmpeg-helper.js";
|
|
10
|
+
import { getFfmpegVersion, resolveFfmpegPath, sanitizeUrlCredentials, supportsFdkAac, checkAudioPassthroughCompatibility, detectPrimaryNetworkInterface, probeCameraSource, } from "./ffmpeg-helper.js";
|
|
15
11
|
import { createSessionTelemetry, finishSessionTelemetry, mergeFfmpegProgress, mergeFfmpegStreamHeader, retainRecentSessions, sanitizeDiagnosticText, } from "./live-view-telemetry.js";
|
|
16
12
|
export const FALLBACK_JPEG_BUFFER = Buffer.from("/9j/4AAQSkZJRgABAgAAAQABAAD//gAPTGF2YzYwLjMuMTAwAP/bAEMACAYGBwYHCAgICAgICQkJCgoKCQkJCQoKCgoKCgwMDAoKCgoKCgoMDAwMDQ4NDQ0MDQ4ODw8PEhIRERUVFRkZH//EAEwAAQEAAAAAAAAAAAAAAAAAAAAHAQEBAAAAAAAAAAAAAAAAAAAAARABAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/AABEIAPABQAMBIgACEQADEQD/2gAMAwEAAhEDEQA/AI2AoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//9k=", "base64");
|
|
17
13
|
function isJpeg(buffer) {
|
|
@@ -177,6 +173,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
177
173
|
activeSessionCount() {
|
|
178
174
|
return this.activeSessions.size;
|
|
179
175
|
}
|
|
176
|
+
twoWayAudioSupported;
|
|
180
177
|
isTakingSnapshot = false;
|
|
181
178
|
lastSnapshotTime = 0;
|
|
182
179
|
constructor(platform, entityId, capabilities, streamSource, record) {
|
|
@@ -186,6 +183,11 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
186
183
|
this.capabilities = capabilities;
|
|
187
184
|
this.streamSource = streamSource;
|
|
188
185
|
this.record = record;
|
|
186
|
+
const cameraIdentity = `${this.entityId} ${String(this.streamSource.metadata?.name || "")} ${String(this.streamSource.metadata?.model || "")}`;
|
|
187
|
+
const isTuyaOrFeeder = this.streamSource.metadata?.isOmniTuyaDirect === true ||
|
|
188
|
+
/(?:\bomni\b|\btuya\b|comedero|feeder|acf100)/i.test(cameraIdentity);
|
|
189
|
+
this.twoWayAudioSupported =
|
|
190
|
+
this.streamSource.metadata?.omniTwoWayAudio === true || isTuyaOrFeeder;
|
|
189
191
|
this.loadPersistedSnapshot();
|
|
190
192
|
}
|
|
191
193
|
isTapoC120() {
|
|
@@ -298,8 +300,6 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
298
300
|
output,
|
|
299
301
|
fallbackReason,
|
|
300
302
|
});
|
|
301
|
-
if (session.startup)
|
|
302
|
-
session.telemetry.startup = session.startup;
|
|
303
303
|
}
|
|
304
304
|
finishTelemetry(session, state, error) {
|
|
305
305
|
if (!session.telemetry || session.telemetry.state !== "active")
|
|
@@ -313,7 +313,6 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
313
313
|
return;
|
|
314
314
|
if (/^Output #\d+/i.test(line.trim())) {
|
|
315
315
|
session.ffmpegOutputHeaderSeen = true;
|
|
316
|
-
session.startup?.mark("T4");
|
|
317
316
|
return;
|
|
318
317
|
}
|
|
319
318
|
const progress = mergeFfmpegProgress(session.telemetry.output, line);
|
|
@@ -408,7 +407,10 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
408
407
|
this.lastSnapshotBuffer !== FALLBACK_JPEG_BUFFER) {
|
|
409
408
|
finish("safety-cached-fallback", this.lastSnapshotBuffer);
|
|
410
409
|
}
|
|
411
|
-
|
|
410
|
+
// Let the bounded HA snapshot, direct HTTP snapshot, and final FFmpeg
|
|
411
|
+
// capture complete before returning an older cached image. These paths
|
|
412
|
+
// have explicit upper bounds of 1.2s + 1.5s + 2s respectively.
|
|
413
|
+
}, 5200);
|
|
412
414
|
try {
|
|
413
415
|
let haEntityToQuery = this.entityId.startsWith("camera.")
|
|
414
416
|
? this.entityId
|
|
@@ -479,7 +481,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
479
481
|
}
|
|
480
482
|
}
|
|
481
483
|
catch (error) {
|
|
482
|
-
this.platform?.log?.debug?.(`[HomeKitCamera][${this.entityId}] Snapshot HTTP failed: ${
|
|
484
|
+
this.platform?.log?.debug?.(`[HomeKitCamera][${this.entityId}] Snapshot HTTP failed: ${String(error)}`);
|
|
483
485
|
}
|
|
484
486
|
}
|
|
485
487
|
const ffmpegPath = resolveFfmpegPath();
|
|
@@ -489,8 +491,9 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
489
491
|
return;
|
|
490
492
|
}
|
|
491
493
|
const args = ["-hide_banner", "-loglevel", "error"];
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
+
if (sourceUrl.startsWith("rtsp://")) {
|
|
495
|
+
const isDemandingCam = this.isTapoC402() || this.isWyze() || this.isEzviz();
|
|
496
|
+
args.push("-probesize", isDemandingCam ? "1048576" : this.isTapoC120() ? "131072" : "65536", "-analyzeduration", isDemandingCam ? "1000000" : "0", "-rtsp_transport", "tcp", "-timeout", "3000000", "-fflags", "+nobuffer+flush_packets", "-flags", "low_delay");
|
|
494
497
|
}
|
|
495
498
|
else if (sourceUrl.startsWith("http://") ||
|
|
496
499
|
sourceUrl.startsWith("https://")) {
|
|
@@ -527,7 +530,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
527
530
|
});
|
|
528
531
|
}
|
|
529
532
|
catch (error) {
|
|
530
|
-
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] Snapshot fatal error: ${
|
|
533
|
+
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] Snapshot fatal error: ${String(error)}`);
|
|
531
534
|
finish("fatal-error", this.lastSnapshotBuffer);
|
|
532
535
|
}
|
|
533
536
|
}
|
|
@@ -540,7 +543,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
540
543
|
// Purge any zombie sessions (process died but Map entry survived) before
|
|
541
544
|
// setting up a new one — otherwise the old dead entry corrupts cleanup.
|
|
542
545
|
for (const [sid, s] of [...this.activeSessions.entries()]) {
|
|
543
|
-
if (s.process
|
|
546
|
+
if (!s.process || s.process.killed || s.process.exitCode !== null) {
|
|
544
547
|
this.platform?.log?.notice?.(`[HomeKitCamera][${this.entityId}] Purging zombie session=${sid} before new prepare`);
|
|
545
548
|
if (s.pipeController) {
|
|
546
549
|
try {
|
|
@@ -554,9 +557,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
554
557
|
}
|
|
555
558
|
catch { }
|
|
556
559
|
}
|
|
557
|
-
s.
|
|
558
|
-
s.videoRelay?.close();
|
|
559
|
-
s.audioRelay?.close();
|
|
560
|
+
s.talkback?.close();
|
|
560
561
|
this.activeSessions.delete(sid);
|
|
561
562
|
}
|
|
562
563
|
}
|
|
@@ -587,19 +588,11 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
587
588
|
request.audio.srtp_salt,
|
|
588
589
|
]);
|
|
589
590
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
session.
|
|
593
|
-
if (request.audio)
|
|
594
|
-
session.audioRelay = await RtpDatagramRelay.create(request.targetAddress, request.audio.port, () => session.startup?.mark("T6"));
|
|
595
|
-
}
|
|
596
|
-
catch (error) {
|
|
597
|
-
session.videoRelay?.close();
|
|
598
|
-
session.audioRelay?.close();
|
|
599
|
-
session.releaseReader?.();
|
|
600
|
-
this.activeSessions.delete(session.sessionId);
|
|
601
|
-
throw error;
|
|
591
|
+
if (request.audio && this.twoWayAudioSupported && session.audioKeySalt) {
|
|
592
|
+
session.talkback = new TuyaHapTalkback(request.targetAddress, session.audioKeySalt, () => this.platform.ha.requestOmniTuyaCameraWebRtc(this.streamSource.metadata?.sourceCameraEntityId || this.entityId), (message) => this.platform?.log?.notice?.(`[HomeKitCamera] ${message}`));
|
|
593
|
+
session.talkbackPort = await session.talkback.prepare();
|
|
602
594
|
}
|
|
595
|
+
this.activeSessions.set(request.sessionID, session);
|
|
603
596
|
// Install watchdog timer: if startStream is never called by iOS (e.g. user cancelled
|
|
604
597
|
// live view before connection established), auto-clean the orphaned session after 45s.
|
|
605
598
|
const zombieTimer = setTimeout(() => {
|
|
@@ -607,9 +600,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
607
600
|
const s = this.activeSessions.get(request.sessionID);
|
|
608
601
|
if (s && !s.process) {
|
|
609
602
|
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] [Session][${request.sessionID}] session-timeout: prepareStream completed but startStream was not called after ${HomeKitCameraStreamingDelegate.PREPARE_TIMEOUT_MS / 1000}s — clearing orphan session`);
|
|
610
|
-
|
|
611
|
-
s.videoRelay?.close();
|
|
612
|
-
s.audioRelay?.close();
|
|
603
|
+
session.talkback?.close();
|
|
613
604
|
this.activeSessions.delete(request.sessionID);
|
|
614
605
|
if (this.activeSessions.size === 0) {
|
|
615
606
|
this.platform?.log?.notice?.(`[HomeKitCamera][${this.entityId}] [Session] session-end (cleared last orphan session)`);
|
|
@@ -626,12 +617,17 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
626
617
|
request.sourceAddress.startsWith("::ffff:")
|
|
627
618
|
? request.sourceAddress.slice("::ffff:".length)
|
|
628
619
|
: request.sourceAddress;
|
|
629
|
-
const addressOverride =
|
|
630
|
-
|
|
620
|
+
const addressOverride = request.addressVersion === "ipv4"
|
|
621
|
+
? isIPv4(sourceAddress || "")
|
|
622
|
+
? sourceAddress
|
|
623
|
+
: detectPrimaryNetworkInterface()?.ip
|
|
624
|
+
: isIPv6(sourceAddress || "")
|
|
625
|
+
? sourceAddress
|
|
626
|
+
: undefined;
|
|
631
627
|
const response = {
|
|
632
628
|
...(addressOverride ? { addressOverride } : {}),
|
|
633
629
|
video: {
|
|
634
|
-
port:
|
|
630
|
+
port: localVideoPort,
|
|
635
631
|
ssrc: session.videoSsrc,
|
|
636
632
|
srtp_key: request.video.srtp_key,
|
|
637
633
|
srtp_salt: request.video.srtp_salt,
|
|
@@ -640,7 +636,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
640
636
|
if (request.audio) {
|
|
641
637
|
const audioPort = session.localAudioPort || localAudioPort || localVideoPort + 1;
|
|
642
638
|
response.audio = {
|
|
643
|
-
port: audioPort,
|
|
639
|
+
port: session.talkbackPort || audioPort,
|
|
644
640
|
ssrc: session.audioSsrc,
|
|
645
641
|
srtp_key: request.audio.srtp_key,
|
|
646
642
|
srtp_salt: request.audio.srtp_salt,
|
|
@@ -651,7 +647,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
651
647
|
callback(undefined, response);
|
|
652
648
|
}
|
|
653
649
|
catch (error) {
|
|
654
|
-
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] HAP SetupEndpoints failed: ${
|
|
650
|
+
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] HAP SetupEndpoints failed: ${String(error)}`);
|
|
655
651
|
if (!callbackCompleted) {
|
|
656
652
|
callbackCompleted = true;
|
|
657
653
|
callback(error);
|
|
@@ -690,18 +686,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
690
686
|
callback(new Error(`Session ${request.sessionID} was not prepared`));
|
|
691
687
|
return;
|
|
692
688
|
}
|
|
693
|
-
|
|
694
|
-
const done = (error) => {
|
|
695
|
-
if (completed)
|
|
696
|
-
return;
|
|
697
|
-
completed = true;
|
|
698
|
-
callback(error);
|
|
699
|
-
};
|
|
700
|
-
void this.startStream(session, request, done).catch((error) => {
|
|
701
|
-
if (this.activeSessions.get(request.sessionID) === session)
|
|
702
|
-
this.stopStream(request.sessionID);
|
|
703
|
-
done(new Error(sanitizeDiagnosticText(error instanceof Error ? error.message : String(error)) || "Camera session failed"));
|
|
704
|
-
});
|
|
689
|
+
void this.startStream(session, request, callback);
|
|
705
690
|
return;
|
|
706
691
|
}
|
|
707
692
|
if (request.type === "reconfigure" /* StreamRequestTypes.RECONFIGURE */) {
|
|
@@ -726,49 +711,176 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
726
711
|
return url;
|
|
727
712
|
}
|
|
728
713
|
async startStream(session, request, callback) {
|
|
729
|
-
session.
|
|
730
|
-
session.startup.metrics.retries = 0;
|
|
714
|
+
session.talkback?.configure(request.audio);
|
|
731
715
|
const video = request.video;
|
|
716
|
+
const isC120 = this.isTapoC120();
|
|
732
717
|
const measuredFps = this.capabilities.measuredVideo?.fps;
|
|
733
718
|
const declaredFps = this.capabilities.maxFps ||
|
|
734
|
-
(measuredFps && measuredFps > 0
|
|
719
|
+
(measuredFps && measuredFps > 0
|
|
720
|
+
? Math.round(measuredFps)
|
|
721
|
+
: isC120
|
|
722
|
+
? 15
|
|
723
|
+
: 30);
|
|
735
724
|
const requestedFps = video?.fps;
|
|
736
725
|
const cameraMaxFps = this.capabilities.maxFps ||
|
|
737
726
|
(measuredFps && measuredFps > 0
|
|
738
727
|
? Math.max(15, Math.round(measuredFps))
|
|
739
|
-
:
|
|
728
|
+
: isC120
|
|
729
|
+
? 20
|
|
730
|
+
: 30);
|
|
740
731
|
const effectiveFps = resolveLiveViewFps(requestedFps, measuredFps, this.capabilities.maxFps, cameraMaxFps);
|
|
741
732
|
const ffmpegPath = resolveFfmpegPath();
|
|
742
|
-
const readerAdapter = new CameraSourceAdapter(this.platform, this.entityId, this.streamSource, this.capabilities, this.record);
|
|
743
|
-
if (readerAdapter.provider === "omni_tuya")
|
|
744
|
-
session.releaseReader = readerAdapter.acquireReader(session);
|
|
745
733
|
// Pause recording/motion readers BEFORE allocating an Omni session.
|
|
746
734
|
// Tuya allocation by a competing reader can invalidate the live URL.
|
|
747
735
|
this.emit("session-start", session.sessionId);
|
|
748
736
|
await new Promise((resolve) => setImmediate(resolve));
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
737
|
+
let sourceUrl = this.getCleanSourceUrl();
|
|
738
|
+
// An already-paired HAP camera may have been created before Omni metadata
|
|
739
|
+
// was persisted. Its durable record still contains the real HA camera
|
|
740
|
+
// entity. Treat a Tuya record with that entity as renewable; a saved RTSP
|
|
741
|
+
// URL is only a stale diagnostic value and must never decide Live View.
|
|
742
|
+
const recordedHaCameraEntityId = this.record?.sourceCameraEntityId;
|
|
743
|
+
const isRecordedTuyaCamera = /tuya/i.test(`${this.record?.manufacturer || ""} ${this.record?.model || ""} ${this.record?.name || ""}`);
|
|
744
|
+
const isRenewableOmniCandidate = Boolean(this.streamSource.metadata?.isOmniTuyaDirect === true ||
|
|
745
|
+
(isRecordedTuyaCamera &&
|
|
746
|
+
/^camera\.[a-z0-9_]+$/.test(recordedHaCameraEntityId || "")));
|
|
747
|
+
// Dynamically refresh ephemeral HA stream URLs (e.g. C402 HLS tokens or missing URLs)
|
|
748
|
+
if (!sourceUrl ||
|
|
749
|
+
this.streamSource.sourceType === "hls" ||
|
|
750
|
+
this.streamSource.sourceType === "ha_proxy" ||
|
|
751
|
+
this.streamSource.metadata?.isOmniTuyaDirect === true ||
|
|
752
|
+
isRenewableOmniCandidate ||
|
|
753
|
+
this.isTapoC402() ||
|
|
754
|
+
this.isTapoC120()) {
|
|
755
|
+
let haEntityId = this.streamSource.metadata?.sourceCameraEntityId ||
|
|
756
|
+
recordedHaCameraEntityId ||
|
|
757
|
+
this.entityId;
|
|
758
|
+
if (this.streamSource.metadata?.isCameraUi ||
|
|
759
|
+
this.entityId.startsWith("cameraui_")) {
|
|
760
|
+
const realCam = this.streamSource.metadata?.realEntities?.find((e) => /^camera\.[a-z0-9_]+$/.test(e.id || "") &&
|
|
761
|
+
this.platform?.ha?.hassStates?.has(e.id));
|
|
762
|
+
if (realCam?.id) {
|
|
763
|
+
haEntityId = realCam.id;
|
|
764
|
+
}
|
|
765
|
+
else if (this.isTapoC402()) {
|
|
766
|
+
haEntityId = this.platform?.ha?.hassStates?.has("camera.tapo_frente_de_calle")
|
|
767
|
+
? "camera.tapo_frente_de_calle"
|
|
768
|
+
: this.platform?.ha?.hassStates?.has("camera.tapo_c402")
|
|
769
|
+
? "camera.tapo_c402"
|
|
770
|
+
: haEntityId;
|
|
771
|
+
}
|
|
772
|
+
else if (this.isTapoC120()) {
|
|
773
|
+
haEntityId = this.platform?.ha?.hassStates?.has("camera.tapo_c120")
|
|
774
|
+
? "camera.tapo_c120"
|
|
775
|
+
: this.platform?.ha?.hassStates?.has("camera.tapo_spot")
|
|
776
|
+
? "camera.tapo_spot"
|
|
777
|
+
: this.platform?.ha?.hassStates?.has("camera.c120")
|
|
778
|
+
? "camera.c120"
|
|
779
|
+
: this.platform?.ha?.hassStates?.has("camera.tapo_c120_hd")
|
|
780
|
+
? "camera.tapo_c120_hd"
|
|
781
|
+
: haEntityId;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
const hasKnownHaCamera = Boolean(this.streamSource.metadata?.sourceCameraEntityId ||
|
|
785
|
+
this.streamSource.metadata?.isOmniTuyaDirect === true);
|
|
786
|
+
if (!/^camera\.[a-z0-9_]+$/.test(haEntityId) ||
|
|
787
|
+
(!this.platform?.ha?.hassStates?.has(haEntityId) && !hasKnownHaCamera)) {
|
|
788
|
+
haEntityId = "";
|
|
789
|
+
}
|
|
790
|
+
if (!haEntityId && this.streamSource.sourceType === "ha_proxy") {
|
|
791
|
+
sourceUrl = "";
|
|
792
|
+
}
|
|
793
|
+
if (this.platform?.ha) {
|
|
794
|
+
const state = haEntityId
|
|
795
|
+
? this.platform.ha.hassStates?.get(haEntityId)
|
|
796
|
+
: undefined;
|
|
797
|
+
const wasOmniTuyaSource = isRenewableOmniCandidate;
|
|
798
|
+
let renewedOmniSource = false;
|
|
799
|
+
if (haEntityId && this.platform.ha.requestOmniTuyaCameraStream) {
|
|
800
|
+
try {
|
|
801
|
+
const freshTuyaUrl = await this.platform.ha.requestOmniTuyaCameraStream(haEntityId);
|
|
802
|
+
if (freshTuyaUrl) {
|
|
803
|
+
this.streamSource = {
|
|
804
|
+
...this.streamSource,
|
|
805
|
+
sourceType: "rtsp",
|
|
806
|
+
url: freshTuyaUrl,
|
|
807
|
+
metadata: {
|
|
808
|
+
...this.streamSource.metadata,
|
|
809
|
+
sourceCameraEntityId: haEntityId,
|
|
810
|
+
isOmniTuyaDirect: true,
|
|
811
|
+
},
|
|
812
|
+
};
|
|
813
|
+
sourceUrl = this.getCleanSourceUrl();
|
|
814
|
+
renewedOmniSource = true;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
catch {
|
|
818
|
+
// The signed Tuya URL must not enter Home Assistant or add-on logs.
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (wasOmniTuyaSource && !renewedOmniSource) {
|
|
822
|
+
// Never reuse an expired signed URL. Ask HA for a fresh camera
|
|
823
|
+
// stream (which may be backed by go2rtc), then fall back to HA's
|
|
824
|
+
// authenticated camera proxy. A later HomeKit open tries Omni again.
|
|
825
|
+
const fallback = state
|
|
826
|
+
? await CameraSourceResolver.resolveOmniTuyaFallback(this.platform, haEntityId, state, { allowCameraProxy: false })
|
|
827
|
+
: undefined;
|
|
828
|
+
if (fallback?.url) {
|
|
829
|
+
this.streamSource = fallback;
|
|
830
|
+
sourceUrl = this.getCleanSourceUrl();
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
sourceUrl = "";
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
else if (!renewedOmniSource && state) {
|
|
837
|
+
try {
|
|
838
|
+
const fresh = await CameraSourceResolver.resolve(this.platform, haEntityId, state);
|
|
839
|
+
if (fresh && fresh.url) {
|
|
840
|
+
this.streamSource = {
|
|
841
|
+
...fresh,
|
|
842
|
+
metadata: {
|
|
843
|
+
...this.streamSource.metadata,
|
|
844
|
+
...fresh.metadata,
|
|
845
|
+
sourceCameraEntityId: fresh.metadata?.sourceCameraEntityId || haEntityId,
|
|
846
|
+
},
|
|
847
|
+
};
|
|
848
|
+
sourceUrl = this.getCleanSourceUrl();
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
catch { }
|
|
852
|
+
}
|
|
853
|
+
if (!wasOmniTuyaSource &&
|
|
854
|
+
haEntityId &&
|
|
855
|
+
(!sourceUrl || this.streamSource.sourceType === "ha_proxy") &&
|
|
856
|
+
this.platform.ha.requestCameraStream) {
|
|
857
|
+
try {
|
|
858
|
+
const freshUrl = await this.platform.ha.requestCameraStream(haEntityId);
|
|
859
|
+
if (freshUrl) {
|
|
860
|
+
this.streamSource.url = freshUrl;
|
|
861
|
+
this.streamSource.sourceType = "hls";
|
|
862
|
+
sourceUrl = this.getCleanSourceUrl();
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
catch { }
|
|
866
|
+
}
|
|
867
|
+
if (!wasOmniTuyaSource &&
|
|
868
|
+
haEntityId &&
|
|
869
|
+
!sourceUrl &&
|
|
870
|
+
this.platform.ha.getCameraProxyStreamUrl) {
|
|
871
|
+
const proxyUrl = this.platform.ha.getCameraProxyStreamUrl(haEntityId);
|
|
872
|
+
if (proxyUrl) {
|
|
873
|
+
this.streamSource.url = proxyUrl;
|
|
874
|
+
this.streamSource.sourceType = "ha_proxy";
|
|
875
|
+
sourceUrl = this.getCleanSourceUrl();
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
763
879
|
}
|
|
764
|
-
session.startup?.mark("T1");
|
|
765
|
-
if (session.startup)
|
|
766
|
-
session.startup.metrics.allocation1Ms =
|
|
767
|
-
performance.now() - allocationStarted;
|
|
768
880
|
if (!ffmpegPath || !sourceUrl) {
|
|
769
881
|
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] HAP START rejected: ${!ffmpegPath ? "FFmpeg unavailable" : "stream source unavailable"}`);
|
|
770
882
|
callback(new Error("FFmpeg or RTSP source is unavailable"));
|
|
771
|
-
this.
|
|
883
|
+
this.emit("session-end", session.sessionId);
|
|
772
884
|
return;
|
|
773
885
|
}
|
|
774
886
|
// Omni issues a new single-session RTSP URL for each HomeKit open. The
|
|
@@ -779,17 +891,14 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
779
891
|
this.capabilities.audioCodec !== "none" &&
|
|
780
892
|
Number.isFinite(this.capabilities.audioSampleRate) &&
|
|
781
893
|
(this.capabilities.audioSampleRate || 0) > 0;
|
|
782
|
-
let probeConsumedReader = false;
|
|
783
894
|
if (!audioFormatKnown) {
|
|
784
|
-
const probeStarted = performance.now();
|
|
785
895
|
try {
|
|
786
|
-
const
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
896
|
+
const probe = await probeCameraSource(sourceUrl, {
|
|
897
|
+
timeoutMs: 4000,
|
|
898
|
+
transport: "tcp",
|
|
899
|
+
allowFallback: false,
|
|
900
|
+
});
|
|
791
901
|
if (probe.valid) {
|
|
792
|
-
this.capabilities.audioProvenance = "PROBED";
|
|
793
902
|
this.capabilities.hasAudio = probe.hasAudio;
|
|
794
903
|
this.capabilities.audioCodec = probe.hasAudio
|
|
795
904
|
? (probe.audioCodec || "incompatible")
|
|
@@ -806,27 +915,17 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
806
915
|
}
|
|
807
916
|
// Metadata probing is a separate RTSP reader. Allocate another signed
|
|
808
917
|
// URL for the actual live process instead of reopening the probe URL.
|
|
809
|
-
if (
|
|
810
|
-
const allocation2Started = performance.now();
|
|
918
|
+
if (!audioFormatKnown) {
|
|
811
919
|
const freshUrl = await this.platform?.ha?.requestOmniTuyaCameraStream?.(this.streamSource.metadata?.sourceCameraEntityId || this.entityId);
|
|
812
920
|
if (!freshUrl) {
|
|
813
921
|
callback(new Error("Omni could not renew the live stream after probing"));
|
|
814
|
-
this.
|
|
922
|
+
this.emit("session-end", session.sessionId);
|
|
815
923
|
return;
|
|
816
924
|
}
|
|
817
925
|
this.streamSource.url = freshUrl;
|
|
818
926
|
sourceUrl = this.getCleanSourceUrl();
|
|
819
|
-
if (session.startup)
|
|
820
|
-
session.startup.metrics.allocation2Ms =
|
|
821
|
-
performance.now() - allocation2Started;
|
|
822
927
|
}
|
|
823
928
|
}
|
|
824
|
-
if (this.activeSessions.get(session.sessionId) !== session) {
|
|
825
|
-
session.releaseReader?.();
|
|
826
|
-
callback(new Error("HAP session ended during source resolution"));
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
session.startup?.mark("T2");
|
|
830
929
|
// HomeKit on iOS can request default low bitrates (e.g. 299k).
|
|
831
930
|
// Ensure a high-fidelity floor: at least 3500k-5000k for 2K (Tapo/Wyze), 6000k-8000k for 4K.
|
|
832
931
|
const qualityFloor = video.width >= 3840
|
|
@@ -858,43 +957,45 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
858
957
|
if (callbackSettled)
|
|
859
958
|
return;
|
|
860
959
|
callbackSettled = true;
|
|
861
|
-
session.startup?.mark("T7");
|
|
862
960
|
callback(error);
|
|
863
961
|
};
|
|
864
|
-
if (this.activeSessions.get(session.sessionId) !== session) {
|
|
865
|
-
session.releaseReader?.();
|
|
866
|
-
settle(new Error("HAP session ended before media spawn"));
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
962
|
this.spawnFfmpegProcess(session, request, settle, false);
|
|
870
963
|
}
|
|
871
964
|
spawnFfmpegProcess(session, request, settle, forceTranscode = false) {
|
|
872
965
|
const ffmpegPath = resolveFfmpegPath() || "ffmpeg";
|
|
873
966
|
const sourceUrl = this.getCleanSourceUrl();
|
|
874
967
|
const video = request.video;
|
|
968
|
+
const isTapoC120 = this.isTapoC120();
|
|
875
969
|
const measuredFps = this.capabilities.measuredVideo?.fps;
|
|
876
970
|
const declaredFps = this.capabilities.maxFps ||
|
|
877
|
-
(measuredFps && measuredFps > 0
|
|
971
|
+
(measuredFps && measuredFps > 0
|
|
972
|
+
? Math.round(measuredFps)
|
|
973
|
+
: isTapoC120
|
|
974
|
+
? 15
|
|
975
|
+
: 30);
|
|
878
976
|
const requestedFps = video?.fps;
|
|
879
977
|
const cameraMaxFps = this.capabilities.maxFps ||
|
|
880
978
|
(measuredFps && measuredFps > 0
|
|
881
979
|
? Math.max(15, Math.round(measuredFps))
|
|
882
|
-
:
|
|
980
|
+
: isTapoC120
|
|
981
|
+
? 20
|
|
982
|
+
: 30);
|
|
883
983
|
const effectiveFps = resolveLiveViewFps(requestedFps, measuredFps, this.capabilities.maxFps, cameraMaxFps);
|
|
884
984
|
const mtu = video.mtu || 1378;
|
|
885
985
|
const args = this.buildStreamArgs(session, request, forceTranscode);
|
|
886
|
-
|
|
986
|
+
const isTapoC402 = this.isTapoC402();
|
|
987
|
+
const isTapoCamera = isTapoC402 || isTapoC120;
|
|
988
|
+
this.platform?.log?.notice?.(`[HomeKitCamera][${this.entityId}] HAP START ${video.width}x${video.height} forceTranscode=${forceTranscode} profile=${h264Profile(video.profile)} level=${h264Level(video.level)} mtu=${mtu} fps[declarado=${declaredFps}, solicitado=${requestedFps ?? "omitted"}, medido=${measuredFps ?? "unmeasured"}, efectivo=${effectiveFps ?? "auto"}] source=${sanitizeUrlCredentials(sourceUrl || "")} ffmpeg=${ffmpegPath} ${getFfmpegVersion(ffmpegPath) || "unknown"}`);
|
|
887
989
|
const isHaProxyStream = this.streamSource.sourceType === "ha_proxy" ||
|
|
888
990
|
this.streamSource.sourceType === "mjpeg" ||
|
|
889
991
|
Boolean(sourceUrl &&
|
|
890
992
|
(sourceUrl.includes("/api/camera_proxy_stream/") ||
|
|
891
993
|
sourceUrl.includes("/api/camera_proxy/")));
|
|
892
994
|
try {
|
|
893
|
-
const spawnStarted = performance.now();
|
|
894
995
|
const process = spawn(ffmpegPath, args, {
|
|
895
996
|
stdio: [
|
|
896
997
|
isHaProxyStream ? "pipe" : "ignore",
|
|
897
|
-
"pipe",
|
|
998
|
+
isTapoC402 || isTapoC120 ? "pipe" : "ignore",
|
|
898
999
|
"pipe",
|
|
899
1000
|
this.streamSource.metadata?.isOmniTuyaDirect === true &&
|
|
900
1001
|
/^rtsps?:\/\//i.test(sourceUrl || "")
|
|
@@ -903,11 +1004,6 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
903
1004
|
],
|
|
904
1005
|
});
|
|
905
1006
|
session.process = process;
|
|
906
|
-
process.once("spawn", () => {
|
|
907
|
-
if (session.startup)
|
|
908
|
-
session.startup.metrics.ffmpegSpawnMs =
|
|
909
|
-
performance.now() - spawnStarted;
|
|
910
|
-
});
|
|
911
1007
|
const recordingPipe = process.stdio[3];
|
|
912
1008
|
if (recordingPipe && typeof recordingPipe !== "string") {
|
|
913
1009
|
recordingPipe.on("data", (chunk) => {
|
|
@@ -925,11 +1021,22 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
925
1021
|
for (const line of chunk.toString().split(/\r?\n/)) {
|
|
926
1022
|
this.recordFfmpegProgress(session, line);
|
|
927
1023
|
}
|
|
1024
|
+
if ((!isTapoC402 && !isTapoC120) || startupConfirmed)
|
|
1025
|
+
return;
|
|
1026
|
+
progress = `${progress}${chunk.toString()}`.slice(-2048);
|
|
1027
|
+
for (const match of progress.matchAll(/(?:^|\n)frame=\s*(\d+)/g)) {
|
|
1028
|
+
if (Number(match[1]) > 0) {
|
|
1029
|
+
startupConfirmed = true;
|
|
1030
|
+
if (startupTimer)
|
|
1031
|
+
clearTimeout(startupTimer);
|
|
1032
|
+
this.platform?.log?.notice?.(`[HomeKitCamera][${this.entityId}] ${isTapoC402 ? "C402" : "C120"} HAP startup confirmed by first video frame`);
|
|
1033
|
+
settle();
|
|
1034
|
+
break;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
928
1037
|
});
|
|
929
1038
|
process.stderr?.on("data", (chunk) => {
|
|
930
1039
|
const text = chunk.toString();
|
|
931
|
-
if (/Input #|Stream #0/.test(text))
|
|
932
|
-
session.startup?.mark("T3");
|
|
933
1040
|
for (const line of text.split(/\r?\n/)) {
|
|
934
1041
|
this.recordFfmpegProgress(session, line);
|
|
935
1042
|
if (/pblack:\d+/.test(line)) {
|
|
@@ -943,11 +1050,26 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
943
1050
|
stderr = `${stderr}\n${safe}`.slice(-1200);
|
|
944
1051
|
});
|
|
945
1052
|
const guard = setTimeout(() => {
|
|
946
|
-
if (
|
|
1053
|
+
if (!isTapoC402 &&
|
|
1054
|
+
!isTapoC120 &&
|
|
1055
|
+
process.exitCode === null &&
|
|
1056
|
+
!process.killed) {
|
|
1057
|
+
this.platform?.log?.notice?.(`[HomeKitCamera][${this.entityId}] HAP START callback success; FFmpeg active session=${session.sessionId}`);
|
|
947
1058
|
settle();
|
|
948
|
-
|
|
1059
|
+
}
|
|
1060
|
+
else if (!isTapoC402 && !isTapoC120) {
|
|
949
1061
|
settle(new Error("FFmpeg exited during HAP startup"));
|
|
1062
|
+
}
|
|
950
1063
|
}, 400);
|
|
1064
|
+
if (isTapoC402 || isTapoC120) {
|
|
1065
|
+
clearTimeout(guard);
|
|
1066
|
+
startupTimer = setTimeout(() => {
|
|
1067
|
+
if (startupConfirmed)
|
|
1068
|
+
return;
|
|
1069
|
+
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] ${isTapoC402 ? "C402" : "C120"} timeout waiting for first video frame (6s); settling callback`);
|
|
1070
|
+
settle();
|
|
1071
|
+
}, 6000);
|
|
1072
|
+
}
|
|
951
1073
|
process.once("error", (error) => {
|
|
952
1074
|
clearTimeout(guard);
|
|
953
1075
|
if (startupTimer)
|
|
@@ -955,15 +1077,10 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
955
1077
|
settle(error);
|
|
956
1078
|
});
|
|
957
1079
|
process.once("close", (code) => {
|
|
958
|
-
if (this.activeSessions.get(session.sessionId) !== session ||
|
|
959
|
-
session.process !== process)
|
|
960
|
-
return;
|
|
961
1080
|
clearTimeout(guard);
|
|
962
1081
|
if (startupTimer)
|
|
963
1082
|
clearTimeout(startupTimer);
|
|
964
1083
|
session.process = undefined;
|
|
965
|
-
if (code !== 0)
|
|
966
|
-
new CameraSourceAdapter(this.platform, this.entityId, this.streamSource, this.capabilities, this.record).invalidate();
|
|
967
1084
|
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] FFmpeg closed code=${code} ${stderr.trim()}`);
|
|
968
1085
|
// Automatic fallback recovery: if initial attempt failed (e.g. missing audio track or incompatible passthrough),
|
|
969
1086
|
// retry immediately with safe transcoding and/or silent audio fallback
|
|
@@ -971,9 +1088,6 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
971
1088
|
!session.retried &&
|
|
972
1089
|
this.activeSessions.has(session.sessionId)) {
|
|
973
1090
|
session.retried = true;
|
|
974
|
-
if (session.startup)
|
|
975
|
-
session.startup.metrics.retries =
|
|
976
|
-
(session.startup.metrics.retries || 0) + 1;
|
|
977
1091
|
this.finishTelemetry(session, "failed", stderr || `FFmpeg exited with code ${code}`);
|
|
978
1092
|
const isOmniStreamNotFound = this.streamSource.metadata?.isOmniTuyaDirect === true &&
|
|
979
1093
|
/(?:DESCRIBE failed:\s*404|404\s+Stream Not Found)/i.test(stderr);
|
|
@@ -990,18 +1104,14 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
990
1104
|
}
|
|
991
1105
|
this.platform?.log?.error?.(`[HomeKitCamera][${this.entityId}] Omni RTSP returned 404 and Home Assistant could not provide a fallback stream.`);
|
|
992
1106
|
settle(new Error("Omni RTSP stream not found; HA fallback unavailable"));
|
|
993
|
-
session.
|
|
994
|
-
session.audioRelay?.close();
|
|
995
|
-
session.releaseReader?.();
|
|
1107
|
+
session.talkback?.close();
|
|
996
1108
|
this.activeSessions.delete(session.sessionId);
|
|
997
1109
|
if (this.activeSessions.size === 0)
|
|
998
1110
|
this.emit("session-end");
|
|
999
1111
|
})().catch((error) => {
|
|
1000
|
-
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] Could not switch Omni Live View to Home Assistant fallback: ${
|
|
1112
|
+
this.platform?.log?.warn?.(`[HomeKitCamera][${this.entityId}] Could not switch Omni Live View to Home Assistant fallback: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
1001
1113
|
settle(new Error("Omni RTSP fallback failed"));
|
|
1002
|
-
session.
|
|
1003
|
-
session.audioRelay?.close();
|
|
1004
|
-
session.releaseReader?.();
|
|
1114
|
+
session.talkback?.close();
|
|
1005
1115
|
this.activeSessions.delete(session.sessionId);
|
|
1006
1116
|
if (this.activeSessions.size === 0)
|
|
1007
1117
|
this.emit("session-end");
|
|
@@ -1032,9 +1142,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1032
1142
|
// Clean up the ghost session entry so the next HomeKit reconnect
|
|
1033
1143
|
// finds a clean Map — otherwise stopStream() later can't properly
|
|
1034
1144
|
// emit session-end and activeSessions grows with stale entries.
|
|
1035
|
-
session.
|
|
1036
|
-
session.audioRelay?.close();
|
|
1037
|
-
session.releaseReader?.();
|
|
1145
|
+
session.talkback?.close();
|
|
1038
1146
|
this.activeSessions.delete(session.sessionId);
|
|
1039
1147
|
if (this.activeSessions.size === 0) {
|
|
1040
1148
|
this.emit("session-end");
|
|
@@ -1046,33 +1154,41 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1046
1154
|
}
|
|
1047
1155
|
}
|
|
1048
1156
|
buildStreamArgs(session, request, forceTranscode = false) {
|
|
1049
|
-
if (["hevc", "h265"].includes(this.capabilities.videoCodec))
|
|
1050
|
-
throw new Error("HEVC requires SecureVideoController");
|
|
1051
1157
|
const sourceUrl = this.getCleanSourceUrl();
|
|
1052
1158
|
if (!sourceUrl) {
|
|
1053
1159
|
return [];
|
|
1054
1160
|
}
|
|
1055
1161
|
const video = request.video;
|
|
1162
|
+
const isTapoC120 = this.isTapoC120();
|
|
1056
1163
|
const measuredFps = this.capabilities.measuredVideo?.fps;
|
|
1057
1164
|
const declaredFps = this.capabilities.maxFps ||
|
|
1058
|
-
(measuredFps && measuredFps > 0
|
|
1165
|
+
(measuredFps && measuredFps > 0
|
|
1166
|
+
? Math.round(measuredFps)
|
|
1167
|
+
: isTapoC120
|
|
1168
|
+
? 15
|
|
1169
|
+
: 30);
|
|
1059
1170
|
const requestedFps = video.fps;
|
|
1060
1171
|
const cameraMaxFps = this.capabilities.maxFps ||
|
|
1061
1172
|
(measuredFps && measuredFps > 0
|
|
1062
1173
|
? Math.max(15, Math.round(measuredFps))
|
|
1063
|
-
:
|
|
1174
|
+
: isTapoC120
|
|
1175
|
+
? 20
|
|
1176
|
+
: 30);
|
|
1064
1177
|
const resolvedFps = resolveLiveViewFps(requestedFps, measuredFps, this.capabilities.maxFps, cameraMaxFps);
|
|
1065
1178
|
const mtu = video.mtu || 1378;
|
|
1066
1179
|
const host = formatHost(session.targetAddress);
|
|
1067
|
-
const videoUrl = session.
|
|
1068
|
-
|
|
1069
|
-
: `srtp://${host}:${session.videoPort}` +
|
|
1070
|
-
`?rtcpport=${session.videoPort}&localrtcpport=${session.localVideoPort}&pkt_size=${mtu}&buffer_size=1048576${session.localAddress ? `&localaddr=${encodeURIComponent(session.localAddress)}` : ""}`;
|
|
1180
|
+
const videoUrl = `srtp://${host}:${session.videoPort}` +
|
|
1181
|
+
`?rtcpport=${session.videoPort}&localrtcpport=${session.localVideoPort}&pkt_size=${mtu}&buffer_size=1048576`;
|
|
1071
1182
|
const isHaProxyStream = this.streamSource.sourceType === "ha_proxy" ||
|
|
1072
1183
|
this.streamSource.sourceType === "mjpeg" ||
|
|
1073
1184
|
Boolean(sourceUrl &&
|
|
1074
1185
|
(sourceUrl.includes("/api/camera_proxy_stream/") ||
|
|
1075
1186
|
sourceUrl.includes("/api/camera_proxy/")));
|
|
1187
|
+
// Camera.UI/go2rtc can accept RTSP before its next keyframe is available.
|
|
1188
|
+
// A 32 KiB / zero-duration probe then exits with "non-existing PPS" after
|
|
1189
|
+
// HAP has already accepted the Live View request. C402 needs a complete
|
|
1190
|
+
// GOP to join reliably; video remains strict H.264 passthrough.
|
|
1191
|
+
const isTapoC402 = this.isTapoC402();
|
|
1076
1192
|
const args = [
|
|
1077
1193
|
"-hide_banner",
|
|
1078
1194
|
"-loglevel",
|
|
@@ -1082,7 +1198,13 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1082
1198
|
"-protocol_whitelist",
|
|
1083
1199
|
"pipe,udp,rtp,file,crypto,srtp,tcp,tls,http,https,lavfi,rtsp,rtsps",
|
|
1084
1200
|
];
|
|
1085
|
-
|
|
1201
|
+
if (isTapoC402 || isTapoC120) {
|
|
1202
|
+
args.push("-progress", "pipe:1", "-stats_period", "0.25");
|
|
1203
|
+
}
|
|
1204
|
+
else {
|
|
1205
|
+
// Progress is diagnostics only. It does not alter RTP/SRTP, codecs, or media flow.
|
|
1206
|
+
args.push("-progress", "pipe:2", "-stats_period", "0.5");
|
|
1207
|
+
}
|
|
1086
1208
|
if (isHaProxyStream) {
|
|
1087
1209
|
// Home Assistant's continuous camera proxy emits multipart JPEG frames.
|
|
1088
1210
|
// The old PNG decoder rejected those frames, so HAP published but never
|
|
@@ -1091,7 +1213,31 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1091
1213
|
}
|
|
1092
1214
|
else if (sourceUrl.startsWith("rtsp://") ||
|
|
1093
1215
|
sourceUrl.startsWith("rtsps://")) {
|
|
1094
|
-
args.push("-rtsp_transport", "tcp", "-timeout", "10000000",
|
|
1216
|
+
args.push("-rtsp_transport", "tcp", "-timeout", "10000000",
|
|
1217
|
+
// C402 needs 2MB for its long GOP analysis.
|
|
1218
|
+
// C120 at 1080p passthrough uses 128KB and 200ms for instant start.
|
|
1219
|
+
// EZVIZ 1080p uses 128KB and 200ms analyze duration for instant startup without waiting.
|
|
1220
|
+
// Wyze and other network RTSP cameras use 64KB-128KB for fast startup.
|
|
1221
|
+
"-probesize", isTapoC402
|
|
1222
|
+
? "2097152"
|
|
1223
|
+
: isTapoC120 || this.isEzviz()
|
|
1224
|
+
? "131072"
|
|
1225
|
+
: "65536", "-analyzeduration", isTapoC402
|
|
1226
|
+
? "3000000"
|
|
1227
|
+
: isTapoC120 || this.isEzviz()
|
|
1228
|
+
? "200000"
|
|
1229
|
+
: "100000");
|
|
1230
|
+
if (isTapoC402) {
|
|
1231
|
+
args.push("-fflags", "+genpts+discardcorrupt", "-flags", "low_delay");
|
|
1232
|
+
}
|
|
1233
|
+
else if (isTapoC120) {
|
|
1234
|
+
// C120: Wallclock timestamping to eliminate RTP jitter buffer drops and 3-10s jumping
|
|
1235
|
+
args.push("-use_wallclock_as_timestamps", "1", "-fflags", "+nobuffer+flush_packets+genpts+discardcorrupt", "-flags", "low_delay");
|
|
1236
|
+
}
|
|
1237
|
+
else {
|
|
1238
|
+
args.push("-fflags", "+nobuffer+flush_packets+genpts+discardcorrupt", "-flags", "low_delay");
|
|
1239
|
+
}
|
|
1240
|
+
args.push("-thread_queue_size", isTapoC120 ? "1024" : "512", "-i", sourceUrl);
|
|
1095
1241
|
}
|
|
1096
1242
|
else if (sourceUrl.startsWith("http://") ||
|
|
1097
1243
|
sourceUrl.startsWith("https://")) {
|
|
@@ -1099,20 +1245,43 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1099
1245
|
if (sourceUrl.startsWith("https://")) {
|
|
1100
1246
|
args.push("-tls_verify", "0");
|
|
1101
1247
|
}
|
|
1102
|
-
|
|
1248
|
+
if (this.streamSource.metadata?.scryptedToken) {
|
|
1249
|
+
const sToken = String(this.streamSource.metadata.scryptedToken).trim();
|
|
1250
|
+
if (sToken) {
|
|
1251
|
+
args.push("-headers", `Authorization: ${sToken.startsWith("Bearer ") ? sToken : `Bearer ${sToken}`}\r\n`);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
else if (this.entityId.startsWith("camera.") ||
|
|
1255
|
+
this.streamSource.metadata?.sourceCameraEntityId ||
|
|
1256
|
+
this.streamSource.metadata?.isDirectHa) {
|
|
1257
|
+
// HA's camera/stream URLs are protected by the HA API token. Refreshing
|
|
1258
|
+
// the URL per HomeKit session is insufficient if FFmpeg omits auth.
|
|
1259
|
+
const token = this.platform?.ha?.getAccessToken?.() ||
|
|
1260
|
+
this.platform?.ha?.wsAccessToken;
|
|
1261
|
+
if (token) {
|
|
1262
|
+
args.push("-headers", `Authorization: Bearer ${token}\r\n`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1103
1265
|
args.push("-i", sourceUrl);
|
|
1104
1266
|
}
|
|
1105
1267
|
else {
|
|
1106
1268
|
args.push("-i", sourceUrl);
|
|
1107
1269
|
}
|
|
1108
|
-
const audioPlan = h264AudioPlan(this.capabilities);
|
|
1109
1270
|
const hasAudioRequested = Boolean(request.audio &&
|
|
1110
1271
|
session.audioPort &&
|
|
1111
1272
|
session.localAudioPort &&
|
|
1112
1273
|
session.audioSsrc &&
|
|
1113
|
-
session.audioKeySalt
|
|
1114
|
-
|
|
1115
|
-
|
|
1274
|
+
session.audioKeySalt);
|
|
1275
|
+
const needsSilentAudio = hasAudioRequested &&
|
|
1276
|
+
(isHaProxyStream ||
|
|
1277
|
+
this.capabilities.hasAudio === false ||
|
|
1278
|
+
this.capabilities.audioCodec === "none");
|
|
1279
|
+
const sampleRate = request.audio?.sample_rate === 24 /* AudioStreamingSamplerate.KHZ_24 */
|
|
1280
|
+
? 24000
|
|
1281
|
+
: 16000;
|
|
1282
|
+
if (needsSilentAudio) {
|
|
1283
|
+
args.push("-re", "-f", "lavfi", "-i", `anullsrc=channel_layout=mono:sample_rate=${sampleRate}`);
|
|
1284
|
+
}
|
|
1116
1285
|
const codec = (this.capabilities.videoCodec || "h264").toLowerCase();
|
|
1117
1286
|
// HAP's RTP VideoStream service advertises H.264 profiles only. Copying
|
|
1118
1287
|
// HEVC into that RTP session makes FFmpeg appear healthy while Apple Home
|
|
@@ -1120,14 +1289,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1120
1289
|
// remains native up to this output boundary, then is converted solely for
|
|
1121
1290
|
// Both Tapo C402 and C120 are native 1080p H.264 streams; they use pure copy passthrough
|
|
1122
1291
|
// (-c:v copy) with zero software transcoding and zero CPU load.
|
|
1123
|
-
const
|
|
1124
|
-
? h264VideoPlan(this.capabilities, this.capabilities.resolution.width > 1920 ||
|
|
1125
|
-
this.capabilities.resolution.height > 1080 ||
|
|
1126
|
-
forceTranscode
|
|
1127
|
-
? verifiedH264Encoder()
|
|
1128
|
-
: undefined, forceTranscode)
|
|
1129
|
-
: undefined;
|
|
1130
|
-
const needsTapoVideoNormalization = h264Plan?.mode === "normalization";
|
|
1292
|
+
const needsTapoVideoNormalization = false;
|
|
1131
1293
|
const isHevc = codec === "hevc" ||
|
|
1132
1294
|
codec === "h265" ||
|
|
1133
1295
|
this.capabilities.strategy === "passthrough_hevc";
|
|
@@ -1159,33 +1321,46 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1159
1321
|
videoPassArgs.push("-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-max_interleave_delta", "100000", "-payload_type", String(video.pt || 99), "-ssrc", String(session.videoSsrc), "-srtp_out_suite", suiteName(session.videoCryptoSuite), "-srtp_out_params", session.videoKeySalt.toString("base64"), videoUrl);
|
|
1160
1322
|
args.push(...videoPassArgs);
|
|
1161
1323
|
}
|
|
1162
|
-
else if (needsTapoVideoNormalization
|
|
1163
|
-
|
|
1164
|
-
|
|
1324
|
+
else if (needsTapoVideoNormalization) {
|
|
1325
|
+
// HAP supports H.264 only through level 4.0, whose maximum frame size
|
|
1326
|
+
// is 1920x1080. Clamp a cached 2K request as well, so an existing Home
|
|
1327
|
+
// pairing recovers before it receives the refreshed capabilities.
|
|
1328
|
+
const targetWidth = Math.min(1920, Math.max(2, Math.floor((video.width || 1920) / 2) * 2));
|
|
1329
|
+
const targetHeight = Math.min(1080, Math.max(2, Math.floor((video.height || 1080) / 2) * 2));
|
|
1330
|
+
const tapoFps = Math.min(resolvedFps ?? 15, isTapoC120 ? 20 : 15);
|
|
1331
|
+
const keyframeInterval = Math.max(15, tapoFps * 2);
|
|
1332
|
+
this.startTelemetry(session, request, session.retried ? "fallback" : "normalization", {
|
|
1165
1333
|
codec: "h264",
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1334
|
+
profile: "high",
|
|
1335
|
+
level: "4.0",
|
|
1336
|
+
width: targetWidth,
|
|
1337
|
+
height: targetHeight,
|
|
1338
|
+
declaredFps,
|
|
1339
|
+
requestedFps,
|
|
1340
|
+
measuredFps,
|
|
1341
|
+
effectiveFps: tapoFps,
|
|
1342
|
+
configuredFps: tapoFps,
|
|
1343
|
+
bitrateKbps: 4500,
|
|
1169
1344
|
pixFmt: "yuv420p",
|
|
1170
1345
|
metadataSource: "effective-command",
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1346
|
+
}, session.retried
|
|
1347
|
+
? "FFmpeg restarted after an initial stream failure"
|
|
1348
|
+
: isTapoC120 && video.width === 1920
|
|
1349
|
+
? "Apple Home solicitó 1080p; normalizando flujo 2K C120 a HAP High L4.0"
|
|
1350
|
+
: undefined);
|
|
1351
|
+
this.platform?.log?.notice?.(`[Stream][${this.entityId}] Normalizando Tapo ${isTapoC402 ? "C402" : "C120"} H.264 a HAP High L4.0 ${targetWidth}x${targetHeight}@${tapoFps} (declarado=${declaredFps}, solicitado=${requestedFps ?? "omitted"}, medido=${measuredFps ?? "unmeasured"}, efectivo=${tapoFps})`);
|
|
1352
|
+
args.push("-map", "0:v:0", "-an", "-vf", `scale=${targetWidth}:${targetHeight}:flags=fast_bilinear`, "-c:v", "libx264", "-preset", "veryfast", "-tune", "zerolatency", "-profile:v", "high", "-level:v", "4.0", "-pix_fmt", "yuv420p", "-r", String(tapoFps), "-g", String(keyframeInterval), "-keyint_min", String(tapoFps), "-sc_threshold", "0", "-b:v", "4500k", "-maxrate", "5000k", "-bufsize", "5000k", "-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-payload_type", String(video.pt || 99), "-ssrc", String(session.videoSsrc), "-srtp_out_suite", suiteName(session.videoCryptoSuite), "-srtp_out_params", session.videoKeySalt.toString("base64"), videoUrl);
|
|
1175
1353
|
}
|
|
1176
1354
|
else {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
const
|
|
1182
|
-
const scale = Math.min(1, 1920 / sourceWidth, 1080 / sourceHeight);
|
|
1183
|
-
const targetWidth = Math.max(2, Math.floor((sourceWidth * scale) / 2) * 2);
|
|
1184
|
-
const targetHeight = Math.max(2, Math.floor((sourceHeight * scale) / 2) * 2);
|
|
1355
|
+
// HEVC source or requiresTranscoding=true: transcode to H.264 for HAP.
|
|
1356
|
+
// Apple Home only accepts H.264 RTP. HEVC cameras (Vimtag PTZ, any camera
|
|
1357
|
+
// whose stored strategy was passthrough_hevc) must go through libx264.
|
|
1358
|
+
const targetWidth = Math.max(2, Math.floor((video.width || 1920) / 2) * 2);
|
|
1359
|
+
const targetHeight = Math.max(2, Math.floor((video.height || 1080) / 2) * 2);
|
|
1185
1360
|
const hevcFps = resolvedFps ?? this.capabilities.maxFps ?? 20;
|
|
1186
1361
|
const keyframeInterval = Math.max(15, hevcFps * 2);
|
|
1187
1362
|
const targetBitrate = targetWidth >= 2560 ? 4500 : targetWidth >= 1920 ? 3500 : 2000;
|
|
1188
|
-
this.platform?.log?.notice?.(`[Stream][${this.entityId}]
|
|
1363
|
+
this.platform?.log?.notice?.(`[Stream][${this.entityId}] HEVC→H.264 transcoding ${targetWidth}x${targetHeight}@${hevcFps}fps bitrate=${targetBitrate}k (source codec: ${this.capabilities.videoCodec || "unknown"})`);
|
|
1189
1364
|
this.startTelemetry(session, request, session.retried ? "fallback" : "transcode", {
|
|
1190
1365
|
codec: "h264",
|
|
1191
1366
|
profile: "high",
|
|
@@ -1203,25 +1378,16 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1203
1378
|
}, session.retried
|
|
1204
1379
|
? "FFmpeg restarted after an initial stream failure"
|
|
1205
1380
|
: undefined);
|
|
1206
|
-
args.push("-map", "0:v:0", "-an", "-vf", `scale=${targetWidth}:${targetHeight}:flags=fast_bilinear`, "-c:v",
|
|
1207
|
-
? ["-preset", "veryfast", "-tune", "zerolatency"]
|
|
1208
|
-
: ["-realtime", "1"]), "-profile:v", "high", "-level:v", "4.0", "-pix_fmt", "yuv420p", "-r", String(hevcFps), "-g", String(keyframeInterval), "-keyint_min", String(hevcFps), ...(encoder === "libx264" ? ["-sc_threshold", "0"] : []), "-b:v", `${targetBitrate}k`, "-maxrate", `${targetBitrate + 500}k`, "-bufsize", `${targetBitrate + 500}k`, "-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-payload_type", String(video.pt || 99), "-ssrc", String(session.videoSsrc), "-srtp_out_suite", suiteName(session.videoCryptoSuite), "-srtp_out_params", session.videoKeySalt.toString("base64"), videoUrl);
|
|
1381
|
+
args.push("-map", "0:v:0", "-an", "-vf", `scale=${targetWidth}:${targetHeight}:flags=fast_bilinear`, "-c:v", "libx264", "-preset", "veryfast", "-tune", "zerolatency", "-profile:v", "high", "-level:v", "4.0", "-pix_fmt", "yuv420p", "-r", String(hevcFps), "-g", String(keyframeInterval), "-keyint_min", String(hevcFps), "-sc_threshold", "0", "-b:v", `${targetBitrate}k`, "-maxrate", `${targetBitrate + 500}k`, "-bufsize", `${targetBitrate + 500}k`, "-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-payload_type", String(video.pt || 99), "-ssrc", String(session.videoSsrc), "-srtp_out_suite", suiteName(session.videoCryptoSuite), "-srtp_out_params", session.videoKeySalt.toString("base64"), videoUrl);
|
|
1209
1382
|
}
|
|
1210
1383
|
if (hasAudioRequested &&
|
|
1211
1384
|
session.audioKeySalt &&
|
|
1212
1385
|
session.audioSsrc &&
|
|
1213
1386
|
request.audio) {
|
|
1214
1387
|
const localAudioPort = session.localAudioPort || session.localVideoPort + 1;
|
|
1215
|
-
const audioUrl = session.
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
`?rtcpport=${session.audioPort}&localrtcpport=${localAudioPort}&pkt_size=188`;
|
|
1219
|
-
const isOpus = audioPlan.codec === "opus" &&
|
|
1220
|
-
request.audio.codec === "OPUS" /* AudioStreamingCodecType.OPUS */;
|
|
1221
|
-
if (request.audio.codec === "OPUS" /* AudioStreamingCodecType.OPUS */ && !isOpus)
|
|
1222
|
-
throw new Error("Opus requires a validated native Opus source");
|
|
1223
|
-
if (audioPlan.codec === "opus" && !isOpus)
|
|
1224
|
-
throw new Error("Audio codec was not advertised for this native Opus source");
|
|
1388
|
+
const audioUrl = `srtp://${host}:${session.audioPort}` +
|
|
1389
|
+
`?rtcpport=${session.audioPort}&localrtcpport=${localAudioPort}&pkt_size=188`;
|
|
1390
|
+
const isOpus = request.audio.codec === "OPUS" /* AudioStreamingCodecType.OPUS */;
|
|
1225
1391
|
const targetCodec = isOpus ? "opus" : "aac_eld";
|
|
1226
1392
|
// Apple HomeKit RTP Live View expects AAC-ELD (or Opus) audio packets.
|
|
1227
1393
|
// RTSP cameras provide AAC-LC, PCMA, or PCMU, which must be transcoded to AAC-ELD/AAC mono
|
|
@@ -1232,19 +1398,31 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1232
1398
|
expectedChannels: 1,
|
|
1233
1399
|
};
|
|
1234
1400
|
const audioCompat = checkAudioPassthroughCompatibility(this.capabilities.audioCodec, this.capabilities.audioSampleRate, this.capabilities.audioChannels, targetReq);
|
|
1235
|
-
if (
|
|
1236
|
-
this.platform?.log?.notice?.(`[Stream][${this.entityId}] Audio fuente es
|
|
1401
|
+
if (audioCompat.compatible) {
|
|
1402
|
+
this.platform?.log?.notice?.(`[Stream][${this.entityId}] Audio fuente es AAC compatible: transmitiendo con passthrough (-c:a copy)`);
|
|
1237
1403
|
args.push("-map", "0:a:0?", "-vn", "-c:a", "copy", "-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-payload_type", String(request.audio.pt || 110), "-ssrc", String(session.audioSsrc), "-srtp_out_suite", suiteName(session.audioCryptoSuite || session.videoCryptoSuite), "-srtp_out_params", session.audioKeySalt.toString("base64"), audioUrl);
|
|
1238
1404
|
}
|
|
1239
|
-
else if (
|
|
1240
|
-
this.platform?.log?.notice?.(`[Stream][${this.entityId}] Transcodificando exclusivamente audio fuente (${this.capabilities.audioCodec || "desconocido"}) a AAC-ELD para Apple Home`);
|
|
1405
|
+
else if (isOpus || supportsFdkAac()) {
|
|
1406
|
+
this.platform?.log?.notice?.(`[Stream][${this.entityId}] Transcodificando exclusivamente audio fuente (${this.capabilities.audioCodec || "desconocido"}) a ${isOpus ? "Opus" : "AAC-ELD"} para Apple Home`);
|
|
1241
1407
|
const audioBitrate = Math.min(request.audio.max_bit_rate || 24, 24);
|
|
1242
|
-
|
|
1408
|
+
if (needsSilentAudio) {
|
|
1409
|
+
args.push("-map", "1:a:0", "-vn");
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
args.push("-map", "0:a:0?", "-vn");
|
|
1413
|
+
}
|
|
1414
|
+
if (isOpus) {
|
|
1415
|
+
args.push("-c:a", "libopus", "-application", "lowdelay", "-frame_duration", "20", "-packet_loss", "5");
|
|
1416
|
+
}
|
|
1417
|
+
else {
|
|
1418
|
+
args.push("-c:a", "libfdk_aac", "-profile:a", "aac_eld", "-flags", "+global_header");
|
|
1419
|
+
}
|
|
1243
1420
|
args.push("-af", "aresample=async=1:first_pts=0", "-ar", String(sampleRate), "-ac", "1", "-b:a", `${audioBitrate}k`, "-f", "rtp", "-fflags", "+nobuffer+flush_packets", "-max_delay", "0", "-max_interleave_delta", "100000", "-payload_type", String(request.audio.pt || 110), "-ssrc", String(session.audioSsrc), "-srtp_out_suite", suiteName(session.audioCryptoSuite || session.videoCryptoSuite), "-srtp_out_params", session.audioKeySalt.toString("base64"), audioUrl);
|
|
1244
1421
|
}
|
|
1245
1422
|
else {
|
|
1246
1423
|
// Never send AAC-LC to a HomeKit session that negotiated AAC-ELD.
|
|
1247
|
-
//
|
|
1424
|
+
// The accessory advertises Opus instead when libfdk_aac is missing;
|
|
1425
|
+
// this guard also protects an older pairing with cached capabilities.
|
|
1248
1426
|
this.platform?.log?.warn?.(`[Stream][${this.entityId}] Omitiendo audio AAC-ELD: FFmpeg no incluye libfdk_aac; se conserva el video para HomeKit`);
|
|
1249
1427
|
}
|
|
1250
1428
|
}
|
|
@@ -1253,7 +1431,7 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1253
1431
|
// The detector's separate RTSP reader is paused during Live View.
|
|
1254
1432
|
if (this.streamSource.metadata?.isOmniTuyaDirect === true &&
|
|
1255
1433
|
/^rtsps?:\/\//i.test(sourceUrl)) {
|
|
1256
|
-
args.push("-map", "0:v:0", "-vf", "fps=
|
|
1434
|
+
args.push("-map", "0:v:0", "-vf", "fps=2,scale=160:90,format=gray,tblend=all_mode=difference,blackframe=amount=0:thresh=12", "-an", "-f", "null", "-");
|
|
1257
1435
|
// Keep HKSV alive during Live View without asking Omni for a second
|
|
1258
1436
|
// signed RTSP session. The accessory feeds this fMP4 pipe into the
|
|
1259
1437
|
// recording delegate while its normal prebuffer reader is paused.
|
|
@@ -1261,8 +1439,19 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1261
1439
|
if (this.capabilities.hasAudio) {
|
|
1262
1440
|
const recordingAudio = this.record?.hksvRecordingConfiguration
|
|
1263
1441
|
?.audioCodec;
|
|
1264
|
-
const
|
|
1265
|
-
const
|
|
1442
|
+
const requestedSampleRate = recordingAudio?.samplerate;
|
|
1443
|
+
const sampleRate = requestedSampleRate === 0 /* AudioRecordingSamplerate.KHZ_8 */
|
|
1444
|
+
? 8000
|
|
1445
|
+
: requestedSampleRate === 1 /* AudioRecordingSamplerate.KHZ_16 */
|
|
1446
|
+
? 16000
|
|
1447
|
+
: requestedSampleRate === 2 /* AudioRecordingSamplerate.KHZ_24 */
|
|
1448
|
+
? 24000
|
|
1449
|
+
: requestedSampleRate === 4 /* AudioRecordingSamplerate.KHZ_44_1 */
|
|
1450
|
+
? 44100
|
|
1451
|
+
: requestedSampleRate === 5 /* AudioRecordingSamplerate.KHZ_48 */
|
|
1452
|
+
? 48000
|
|
1453
|
+
: 32000;
|
|
1454
|
+
const channels = Math.max(1, Math.min(2, Number(recordingAudio?.audioChannels) || 1));
|
|
1266
1455
|
args.push("-map", "0:a:0?", "-c:a", "aac", "-af", "aresample=async=1:first_pts=0", "-ar", String(sampleRate), "-ac", String(channels), "-b:a", `${Math.max(16, Math.min(64, Number(recordingAudio?.bitrate) || 32))}k`);
|
|
1267
1456
|
}
|
|
1268
1457
|
else {
|
|
@@ -1364,11 +1553,9 @@ export class HomeKitCameraStreamingDelegate extends EventEmitter {
|
|
|
1364
1553
|
}
|
|
1365
1554
|
stopStream(sessionId) {
|
|
1366
1555
|
const session = this.activeSessions.get(sessionId);
|
|
1367
|
-
session?.videoRelay?.close();
|
|
1368
|
-
session?.audioRelay?.close();
|
|
1369
1556
|
if (!session)
|
|
1370
1557
|
return;
|
|
1371
|
-
session.
|
|
1558
|
+
session.talkback?.close();
|
|
1372
1559
|
// Clear prepare watchdog timer if still pending
|
|
1373
1560
|
const timer = this.prepareTimeouts.get(sessionId);
|
|
1374
1561
|
if (timer !== undefined) {
|