mirror of https://bitbucket.org/ausocean/av.git
rtmp: got handle errors that should stop the encoding with a middle man rtmpSender
This commit is contained in:
parent
b63c55ae48
commit
61c1ff6ee4
|
@ -184,8 +184,9 @@ func TestFromFrame(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const frameRate = 25
|
const frameRate = 25
|
||||||
flvEncoder, err := flv.NewEncoder(s, true, true, frameRate)
|
rs := &rtmpSender{s: s}
|
||||||
if err != nil && err != errTinyPacket {
|
flvEncoder, err := flv.NewEncoder(rs, true, true, frameRate)
|
||||||
|
if err != nil {
|
||||||
t.Errorf("Failed to create flv encoder with error: %v", err)
|
t.Errorf("Failed to create flv encoder with error: %v", err)
|
||||||
}
|
}
|
||||||
err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate))
|
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.
|
// TestFromFile tests streaming from an video file comprising raw H.264.
|
||||||
// The test file is supplied via the RTMP_TEST_FILE environment variable.
|
// The test file is supplied via the RTMP_TEST_FILE environment variable.
|
||||||
func TestFromFile(t *testing.T) {
|
func TestFromFile(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue