fix(homekit): fix HKSV recording by correcting HDS protocol and adding GOP buffering
The HKSV recording was failing because: 1. The dataSend.data message structure was wrong - `packets` was a flat integer instead of an array of objects with `data` and `metadata` fields matching the HAP-NodeJS specification 2. Each video/audio frame was sent as a separate mediaFragment, but Home Hub expects GOP-based fragments (~2-4 seconds of accumulated data) 3. Large fragments were not chunked (max 256 KiB per chunk) Changes: - Fix HDS dataSend.data message structure to use proper packets array with nested data/metadata (dataType, dataSequenceNumber, dataChunkSequenceNumber, isLastDataChunk, dataTotalSize) - Add 256 KiB chunking for large media fragments - Buffer moof+mdat pairs in hksvConsumer and flush on keyframe boundaries (GOP-based fragmentation) - Pre-start consumer at pair-verify for instant init segment delivery - Add write-response support to HAP PUT handler for ch131 DataStream setup - Fix HAP service linking to match HAP-NodeJS reference - Add default SelectedCameraRecordingConfiguration (ch209) value - Start continuous motion generator at pair-verify with dedup protection
This commit is contained in:
@@ -69,12 +69,15 @@ func ServerHandler(server Server) HandlerFunc {
|
||||
IID uint64 `json:"iid"`
|
||||
Value any `json:"value"`
|
||||
Event any `json:"ev"`
|
||||
R *bool `json:"r,omitempty"`
|
||||
} `json:"characteristics"`
|
||||
}
|
||||
if err := json.NewDecoder(req.Body).Decode(&v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var writeResponses []hap.JSONCharacter
|
||||
|
||||
for _, c := range v.Value {
|
||||
if c.Value != nil {
|
||||
server.SetCharacteristic(conn, c.AID, c.IID, c.Value)
|
||||
@@ -93,6 +96,25 @@ func ServerHandler(server Server) HandlerFunc {
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.R != nil && *c.R {
|
||||
// write-response: return updated value
|
||||
accs := server.GetAccessories(conn)
|
||||
for _, acc := range accs {
|
||||
if char := acc.GetCharacterByID(c.IID); char != nil {
|
||||
writeResponses = append(writeResponses, hap.JSONCharacter{
|
||||
AID: c.AID,
|
||||
IID: c.IID,
|
||||
Status: 0,
|
||||
Value: char.Value,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(writeResponses) > 0 {
|
||||
return makeResponse(hap.MimeJSON, hap.JSONCharacters{Value: writeResponses})
|
||||
}
|
||||
|
||||
res := &http.Response{
|
||||
|
||||
Reference in New Issue
Block a user