diff --git a/rtmp/rtmp_test.go b/rtmp/rtmp_test.go index 3efbdec8..06b1979a 100644 --- a/rtmp/rtmp_test.go +++ b/rtmp/rtmp_test.go @@ -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) {