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.
44 lines
838 B
Go
44 lines
838 B
Go
package opus
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/pion/mediadevices/pkg/codec/internal/codectest"
|
|
"github.com/pion/mediadevices/pkg/prop"
|
|
"github.com/pion/mediadevices/pkg/wave"
|
|
)
|
|
|
|
func TestEncoder(t *testing.T) {
|
|
t.Run("SimpleRead", func(t *testing.T) {
|
|
p, err := NewParams()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
codectest.AudioEncoderSimpleReadTest(t, &p,
|
|
prop.Media{
|
|
Audio: prop.Audio{
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
},
|
|
wave.NewInt16Interleaved(wave.ChunkInfo{
|
|
Len: 960,
|
|
SamplingRate: 48000,
|
|
Channels: 2,
|
|
}),
|
|
)
|
|
})
|
|
t.Run("CloseTwice", func(t *testing.T) {
|
|
p, err := NewParams()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
codectest.AudioEncoderCloseTwiceTest(t, &p, prop.Media{
|
|
Audio: prop.Audio{
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
})
|
|
})
|
|
}
|