mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-27 04:46:10 +08:00

Video/AudioTrack.NewRTPReader() internally closes encoder on error. It caused double free if user closes reader after error.
47 lines
907 B
Go
47 lines
907 B
Go
package mmal
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
|
|
"github.com/pion/mediadevices/pkg/codec/internal/codectest"
|
|
"github.com/pion/mediadevices/pkg/frame"
|
|
"github.com/pion/mediadevices/pkg/prop"
|
|
)
|
|
|
|
func TestEncoder(t *testing.T) {
|
|
t.Run("SimpleRead", func(t *testing.T) {
|
|
p, err := NewParams()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
codectest.VideoEncoderSimpleReadTest(t, &p,
|
|
prop.Media{
|
|
Video: prop.Video{
|
|
Width: 256,
|
|
Height: 144,
|
|
FrameFormat: frame.FormatI420,
|
|
},
|
|
},
|
|
image.NewYCbCr(
|
|
image.Rect(0, 0, 256, 144),
|
|
image.YCbCrSubsampleRatio420,
|
|
),
|
|
)
|
|
})
|
|
t.Run("CloseTwice", func(t *testing.T) {
|
|
p, err := NewParams()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
codectest.VideoEncoderCloseTwiceTest(t, &p, prop.Media{
|
|
Video: prop.Video{
|
|
Width: 640,
|
|
Height: 480,
|
|
FrameRate: 30,
|
|
FrameFormat: frame.FormatI420,
|
|
},
|
|
})
|
|
})
|
|
}
|