Skip to content

Commit

Permalink
Add SetMetadata for FormatContext (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr3h1v authored Aug 22, 2024
1 parent e986c9e commit 9b42cf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions format_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func (fc *FormatContext) Metadata() *Dictionary {
return newDictionaryFromC(fc.c.metadata)
}

func (fc *FormatContext) SetMetadata(d *Dictionary) {
if d == nil {
fc.c.metadata = nil
} else {
fc.c.metadata = d.c
}
}

func (fc *FormatContext) NbStreams() int {
return int(fc.c.nb_streams)
}
Expand Down
10 changes: 10 additions & 0 deletions format_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func TestFormatContext(t *testing.T) {
require.NotNil(t, s3)
require.Equal(t, 1, s3.Index())

d := NewDictionary()
d.Set("k", "v", 0)
fc3.SetMetadata(d)
e := fc3.Metadata().Get("k", nil, 0)
require.NotNil(t, e)
require.Equal(t, "v", e.Value())

fc3.SetMetadata(nil)
require.Nil(t, fc3.Metadata())

fc4 := AllocFormatContext()
require.NotNil(t, fc4)
defer fc4.Free()
Expand Down

0 comments on commit 9b42cf0

Please sign in to comment.