Skip to content

Commit

Permalink
SetStreamIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
oldma3095 committed Dec 18, 2024
1 parent 4fb268f commit 13bb060
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions program.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ func (p *Program) StreamIndex() *uint {
return &u
}

// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7967d41af4812ed61a28762e988c7a02
func (p *Program) SetStreamIndex(n uint) {
if p.c.stream_index != nil {
*p.c.stream_index = C.uint(n)
}
}

// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#ae9dab38d4694e3da9cba0f882f4e43d3
func (p *Program) Metadata() *Dictionary {
return newDictionaryFromC(p.c.metadata)
Expand Down
7 changes: 6 additions & 1 deletion program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestProgram(t *testing.T) {
require.Equal(t, 2, p.ID())
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)
Expand All @@ -34,8 +33,14 @@ func TestProgram(t *testing.T) {
s := fc.NewStream(nil)
s.SetID(2)
require.Equal(t, 0, p.NbStreams())
require.Nil(t, p.StreamIndex(), nil)
p.AddStream(s)
require.Equal(t, 1, p.NbStreams())
require.Equal(t, uint(0), *p.StreamIndex())
var streamIndex uint = 1
p.SetStreamIndex(streamIndex)
require.Equal(t, streamIndex, *p.StreamIndex())
s.SetIndex(int(streamIndex))
ss := p.Streams()
require.Equal(t, 1, len(ss))
require.Equal(t, s.ID(), ss[0].ID())
Expand Down

0 comments on commit 13bb060

Please sign in to comment.