mirror of
https://github.com/pion/webrtc.git
synced 2025-09-26 19:21:12 +08:00
Allow IVFWriter Framerate to be modified
Before was hardcoded to 30/1 Resolves #696
This commit is contained in:
@@ -352,3 +352,12 @@ func WithWidthAndHeight(width, height uint16) Option {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithFrameRate(numerator, denominator uint32) Option {
|
||||
return func(i *IVFWriter) error {
|
||||
i.timebaseNumerator = numerator
|
||||
i.timebaseDenominator = denominator
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@@ -401,3 +401,18 @@ func TestIVFWriter_WithWidthAndHeight(t *testing.T) {
|
||||
0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
}, buffer.Bytes())
|
||||
}
|
||||
|
||||
func TestIVFWriter_WithFrameRate(t *testing.T) {
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
writer, err := NewWith(buffer, WithFrameRate(60, 1))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.NoError(t, writer.WriteRTP(&rtp.Packet{Payload: []byte{}}))
|
||||
assert.NoError(t, writer.Close())
|
||||
|
||||
assert.Equal(t, []byte{
|
||||
0x44, 0x4b, 0x49, 0x46, 0x00, 0x00, 0x20, 0x00, 0x56, 0x50, 0x38, 0x30, 0x80, 0x02, 0xe0, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
}, buffer.Bytes())
|
||||
}
|
||||
|
Reference in New Issue
Block a user