Add CameraOperatingMode service
Diff
characteristic/event_snapshots_active.go | 19 +++++++++++++++++++
characteristic/homekit_camera_active.go | 19 +++++++++++++++++++
characteristic/periodic_snapshots_active.go | 19 +++++++++++++++++++
service/camera_operating_mode.go | 32 ++++++++++++++++++++++++++++++++
service/data_stream_management.go | 1 +
cmd/hkbi/main.go | 12 +++++++++++-
6 files changed, 100 insertions(+), 2 deletions(-)
@@ -1,0 +1,19 @@
package characteristic
import "github.com/brutella/hap/characteristic"
const TypeEventSnapshotsActive = "223"
type EventSnapshotsActive struct {
*characteristic.Bool
}
func NewEventSnapshotsActive() *EventSnapshotsActive {
c := characteristic.NewBool(TypeEventSnapshotsActive)
c.Format = characteristic.FormatBool
c.Permissions = []string{characteristic.PermissionRead, characteristic.PermissionWrite, characteristic.PermissionEvents}
c.SetValue(false)
return &EventSnapshotsActive{c}
}
@@ -1,0 +1,19 @@
package characteristic
import "github.com/brutella/hap/characteristic"
const TypeHomeKitCameraActive = "21B"
type HomeKitCameraActive struct {
*characteristic.Bool
}
func NewHomeKitCameraActive() *HomeKitCameraActive {
c := characteristic.NewBool(TypeHomeKitCameraActive)
c.Format = characteristic.FormatBool
c.Permissions = []string{characteristic.PermissionRead, characteristic.PermissionWrite, characteristic.PermissionEvents}
c.SetValue(false)
return &HomeKitCameraActive{c}
}
@@ -1,0 +1,19 @@
package characteristic
import "github.com/brutella/hap/characteristic"
const TypePeriodicSnapshotsActive = "225"
type PeriodicSnapshotsActive struct {
*characteristic.Bool
}
func NewPeriodicSnapshotsActive() *PeriodicSnapshotsActive {
c := characteristic.NewBool(TypePeriodicSnapshotsActive)
c.Format = characteristic.FormatBool
c.Permissions = []string{characteristic.PermissionRead, characteristic.PermissionWrite, characteristic.PermissionEvents}
c.SetValue(false)
return &PeriodicSnapshotsActive{c}
}
@@ -1,0 +1,32 @@
package service
import (
"github.com/brutella/hap/service"
characteristic2 "github.com/w4/hkbi/characteristic"
)
const TypeCameraOperatingMode = "21A"
type CameraOperatingMode struct {
*service.S
EventSnapshotsActive *characteristic2.EventSnapshotsActive
HomeKitCameraActive *characteristic2.HomeKitCameraActive
PeriodicSnapshotsActive *characteristic2.PeriodicSnapshotsActive
}
func NewCameraOperatingMode() *CameraOperatingMode {
s := CameraOperatingMode{}
s.S = service.New(TypeCameraOperatingMode)
s.EventSnapshotsActive = characteristic2.NewEventSnapshotsActive()
s.AddC(s.EventSnapshotsActive.C)
s.HomeKitCameraActive = characteristic2.NewHomeKitCameraActive()
s.AddC(s.HomeKitCameraActive.C)
s.PeriodicSnapshotsActive = characteristic2.NewPeriodicSnapshotsActive()
s.AddC(s.PeriodicSnapshotsActive.C)
return &s
}
@@ -1,0 +1,1 @@
package service
@@ -15,6 +15,7 @@
"github.com/brutella/hap/service"
"github.com/brutella/hap/tlv8"
"github.com/w4/hkbi/blueiris"
service2 "github.com/w4/hkbi/service"
"io"
"math/rand"
"net"
@@ -132,10 +133,13 @@
hasDiscoveredNewCameras = true
}
startListeningForStreams(camera.Id, cam.StreamManagement1, globalState, &config, bi.BaseUrl)
startListeningForStreams(camera.Id, cam.StreamManagement2, globalState, &config, bi.BaseUrl)
cameraOperatingMode := service2.NewCameraOperatingMode()
cam.AddS(cameraOperatingMode.S)
motionSensor := service.NewMotionSensor()
motionSensorActive := characteristic.NewActive()
@@ -316,6 +320,10 @@
func startListeningForStreams(cameraName string, mgmt *service.CameraRTPStreamManagement, globalState *GlobalState, config *Config, blueirisBase *url.URL) {
active := characteristic.NewActive()
mgmt.AddC(active.C)
setTlv8Payload(mgmt.StreamingStatus.Bytes, rtp.StreamingStatus{Status: rtp.StreamingStatusAvailable})
setTlv8Payload(mgmt.SupportedRTPConfiguration.Bytes, rtp.NewConfiguration(rtp.CryptoSuite_AES_CM_128_HMAC_SHA1_80))