Fix nil pointer dereference
This commit is contained in:
parent
7e90bb87ce
commit
cb9ce6f1dc
@ -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 {
|
||||
|
||||
49
restream/app/progress_test.go
Normal file
49
restream/app/progress_test.go
Normal file
@ -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)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user