diff --git a/program.go b/program.go index f71a0d9..e00ef0d 100644 --- a/program.go +++ b/program.go @@ -77,8 +77,12 @@ func (p *Program) SetDiscard(d Discard) { } // https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7967d41af4812ed61a28762e988c7a02 -func (p *Program) StreamIndex() uint { - return uint(C.uint(*p.c.stream_index)) +func (p *Program) StreamIndex() *uint { + if p.c.stream_index == nil { + return nil + } + u := uint(C.uint(*p.c.stream_index)) + return &u } // https://ffmpeg.org/doxygen/7.0/structAVProgram.html#ae9dab38d4694e3da9cba0f882f4e43d3 diff --git a/program_test.go b/program_test.go index cc5c7f3..fb33bbc 100644 --- a/program_test.go +++ b/program_test.go @@ -16,14 +16,22 @@ func TestProgram(t *testing.T) { require.Equal(t, 2, p.ID()) p.SetFlags(1) require.Equal(t, 1, p.Flags()) - p.SetProgramNumber(101) - require.Equal(t, 101, p.ProgramNumber()) p.SetDiscard(DiscardAll) require.Equal(t, DiscardAll, p.Discard()) + require.Nil(t, p.StreamIndex(), nil) d := NewDictionary() require.NoError(t, d.Set("service_name", "test_service_name", 0)) p.SetMetadata(d) require.Equal(t, p.Metadata().Get("service_name", nil, 0).Value(), "test_service_name") + p.SetProgramNumber(101) + require.Equal(t, 101, p.ProgramNumber()) + require.Equal(t, p.PmtPid(), 0) + require.Equal(t, p.PcrPid(), 0) + require.Equal(t, p.PmtVersion(), -1) + require.Equal(t, p.StartTime(), int64(-9223372036854775808)) + require.Equal(t, p.EndTime(), int64(-9223372036854775808)) + require.Equal(t, p.PtsWrapReference(), int64(-9223372036854775808)) + require.Equal(t, p.PtsWrapBehavior(), 0) s := fc.NewStream(nil) s.SetID(2) require.Equal(t, 0, p.NbStreams())