Skip to content

Commit

Permalink
Program and Discard
Browse files Browse the repository at this point in the history
  • Loading branch information
oldma3095 committed Dec 13, 2024
1 parent e80f3cc commit ffb44b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions program.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit ffb44b5

Please sign in to comment.