-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
Servus,
as previously mentioned, I have been playing with hap as well and used your library to test the correctness of my implementation.
While trying to debug my tlv8 unmarshal implementation, I found a bug in the tlv8.Unmarshal function. Please find below a test which marshals a struct, unmarshals it and compare the initial and final structs.
func TestMarhsalUnmarshalDefaultVideoStreamConfiguration(t *testing.T) {
want := rtp.DefaultVideoStreamConfiguration()
buf, err := Marshal(want)
if err != nil {
t.Fatal(err)
}
var is rtp.VideoStreamConfiguration
err = Unmarshal(buf, &is)
if err != nil {
t.Fatal(err)
}
if reflect.DeepEqual(is, want) == false {
t.Fatalf("is=%+v want=%+v", is, want)
}
}I get the following error (as you can see the Parameters, Levels and other attributes differ):
is={Codecs:[{Type:0 Parameters:{Profiles:[] Levels:[] Packetizations:[]} Attributes:[{Width:1920 Height:1080 Framerate:30} {Width:1280 Height:720 Framerate:30} {Width:640 Height:360 Framerate:30} {Width:480 Height:270 Framerate:30} {Width:320 Height:180 Framerate:30} {Width:1280 Height:960 Framerate:30} {Width:1024 Height:768 Framerate:30} {Width:640 Height:480 Framerate:30} {Width:480 Height:360 Framerate:30} {Width:320 Height:240 Framerate:15}]}]}
want={Codecs:[{Type:0 Parameters:{Profiles:[{Id:0} {Id:1} {Id:2}] Levels:[{Level:0} {Level:1} {Level:2}] Packetizations:[{Mode:0}]} Attributes:[{Width:1920 Height:1080 Framerate:30} {Width:1280 Height:720 Framerate:30} {Width:640 Height:360 Framerate:30} {Width:480 Height:270 Framerate:30} {Width:320 Height:180 Framerate:30} {Width:1280 Height:960 Framerate:30} {Width:1024 Height:768 Framerate:30} {Width:640 Height:480 Framerate:30} {Width:480 Height:360 Framerate:30} {Width:320 Height:240 Framerate:15}]}]}
FYI, my tlv8 implementation is split in 2 steps:
- construct an (un)marshaller based exclusively on the
reflect.Type(a nested tree offunc(io.Reader, reflect.Value) error) - call this (un)marshaller with the
reflect.Value
This way, the first step can be cached based on the type and the whole process is a bit cleaner and faster.
I will never repeat it enough: huge thanks for your amazing work on this library!
Metadata
Metadata
Assignees
Labels
No labels