Supereg / secure-video-specification

Documentation and examples of the HomeKit Secure-Video Specification
MIT License
216 stars 13 forks source link

packet spec seems to have conflicting information #5

Closed koush closed 2 years ago

koush commented 3 years ago

I'm having some trouble to get HomeKit to accept the mock files that you have in your examples. I did notice there seemed to be conflicting information about the dataSend data event construction:

image

The spec indicates that "packets" is an array, but then following examples show it as a dictionary:

{
  "header": {
    "protocol": "dataSend",
    "event": "data"
  },
  "message": {
    "streamId": 1,
    "packets": {
      "metadata": {
        "dataType": "mediaInitialization",
        "dataSequenceNumber": 1,
        "isLastDataChunk": true,
        "dataChunkSequenceNumber": 1
      },
      "data": "contents of ./chunks/mediaInitialization.mp4"
    }
  } 
}

So I think it should be this according to your written spec:


{
  "header": {
    "protocol": "dataSend",
    "event": "data"
  },
  "message": {
    "streamId": 1,
    "packets": [
      {
        "metadata": {
          "dataType": "mediaInitialization",
          "dataSequenceNumber": 1,
          "isLastDataChunk": true,
          "dataChunkSequenceNumber": 1
        },
        "data": "contents of ./chunks/mediaInitialization.mp4"
      }
    ]
  } 
}
koush commented 3 years ago

Have confirmed that the examples are incorrect, because after correcting, everything works. HSV support in HAP-NodeJS!

Supereg commented 3 years ago

Here is a full example of a communication that worked for me https://github.com/Supereg/secure-video-specification/tree/master/examples Those are incorrect?

Supereg commented 3 years ago

The "array of dictionaries" comes from the public spec. The dataSend data event is not special to HKSV but a generalized way of sending data through the HK Data Stream. It is e.g. also used for voice data transmission for the Siri functionality of HomeKit Apple TV Remotes. And there you would actually send an array of packets.

But good to know, that they force a plain dictionary for HKSV.

I'll edit the spec.

Supereg commented 3 years ago

Okay, wait a sec, what is now expected from homed, an array of length 1 or a dictionary?

koush commented 3 years ago

Okay, wait a sec, what is now expected from homed, an array of length 1 or a dictionary?

Currently, my implementation is working with an array of packets length 1. I will double check with a dictionary and get back to you. Maybe a dictionary works too?

koush commented 3 years ago

I can confirm that a dictionary does not work, at least using HAP-NodeJS to encode the payload.

I believe the spec samples are incorrect here.