diff --git a/restream/app/progress.go b/restream/app/progress.go index 7982aff8..d747ba67 100644 --- a/restream/app/progress.go +++ b/restream/app/progress.go @@ -68,7 +68,13 @@ func (p *ProgressIO) UnmarshalParser(pp *parse.ProgressIO) { p.Sampling = pp.Sampling p.Layout = pp.Layout p.Channels = pp.Channels - p.AVstream.UnmarshalParser(pp.AVstream) + + if pp.AVstream != nil { + p.AVstream = &AVstream{} + p.AVstream.UnmarshalParser(pp.AVstream) + } else { + p.AVstream = nil + } } func (p *ProgressIO) MarshalParser() parse.ProgressIO { diff --git a/restream/app/progress_test.go b/restream/app/progress_test.go new file mode 100644 index 00000000..368a6052 --- /dev/null +++ b/restream/app/progress_test.go @@ -0,0 +1,49 @@ +package app + +import ( + "testing" + + "github.com/datarhei/core/v16/ffmpeg/parse" + "github.com/stretchr/testify/require" +) + +func TestProgressIO(t *testing.T) { + original := parse.ProgressIO{ + Address: "", + Index: 0, + Stream: 0, + Format: "", + Type: "", + Codec: "", + Coder: "", + Frame: 0, + Keyframe: 0, + Framerate: struct { + Min float64 + Max float64 + Average float64 + }{}, + FPS: 0, + Packet: 0, + PPS: 0, + Size: 0, + Bitrate: 0, + Extradata: 0, + Pixfmt: "", + Quantizer: 0, + Width: 0, + Height: 0, + Sampling: 0, + Layout: "", + Channels: 0, + AVstream: &parse.AVstream{}, + } + + p := ProgressIO{ + AVstream: nil, + } + p.UnmarshalParser(&original) + restored := p.MarshalParser() + + require.Equal(t, original, restored) +}