diff --git a/format_context.go b/format_context.go index 63304db..598da91 100644 --- a/format_context.go +++ b/format_context.go @@ -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) } diff --git a/format_context_test.go b/format_context_test.go index 156964a..79ba427 100644 --- a/format_context_test.go +++ b/format_context_test.go @@ -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()