rtmp: got handle errors that should stop the encoding with a middle man rtmpSender

This commit is contained in:
saxon 2019-01-11 18:19:58 +10:30
parent b63c55ae48
commit 61c1ff6ee4
1 changed files with 15 additions and 2 deletions

View File

@ -184,8 +184,9 @@ func TestFromFrame(t *testing.T) {
}
const frameRate = 25
flvEncoder, err := flv.NewEncoder(s, true, true, frameRate)
if err != nil && err != errTinyPacket {
rs := &rtmpSender{s: s}
flvEncoder, err := flv.NewEncoder(rs, true, true, frameRate)
if err != nil {
t.Errorf("Failed to create flv encoder with error: %v", err)
}
err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate))
@ -198,6 +199,18 @@ func TestFromFrame(t *testing.T) {
}
}
type rtmpSender struct {
s *Session
}
func (rs *rtmpSender) Write(p []byte) (int, error) {
n, err := rs.s.Write(p)
if err != errTinyPacket && err != nil {
return 0, err
}
return n, nil
}
// TestFromFile tests streaming from an video file comprising raw H.264.
// The test file is supplied via the RTMP_TEST_FILE environment variable.
func TestFromFile(t *testing.T) {