Skip to content

Commit 4e41609

Browse files
authored
Merge pull request yutopp#35 from octu0/playback-support
[proposal] add playback support
2 parents c41e2e8 + 7e7a1d4 commit 4e41609

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

conn.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package rtmp
99

1010
import (
1111
"bufio"
12+
"context"
1213
"github.com/hashicorp/go-multierror"
1314
"github.com/pkg/errors"
1415
"github.com/sirupsen/logrus"
@@ -131,6 +132,10 @@ func (c *Conn) Close() error {
131132
return result
132133
}
133134

135+
func (c *Conn) Write(ctx context.Context, chunkStreamID int, timestamp uint32, cmsg *ChunkMessage) error {
136+
return c.streamer.Write(ctx, chunkStreamID, timestamp, cmsg)
137+
}
138+
134139
func (c *Conn) handleMessageLoop() (err error) {
135140
defer func() {
136141
if r := recover(); r != nil {

message/body_decoder.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,15 @@ func DecodeBodyPlay(_ io.Reader, d AMFDecoder, v *AMFConvertible) error {
222222
}
223223
var start int64
224224
if err := d.Decode(&start); err != nil {
225-
return errors.Wrap(err, "Failed to decode 'play' args[2]")
225+
//
226+
// io.EOF occurs when the start position is not specified.
227+
// 'NetStream.play(streamName,null)'
228+
// set start to 0 to avoid it.
229+
//
230+
if err != io.EOF {
231+
return errors.Wrap(err, "Failed to decode 'play' args[2]")
232+
}
233+
start = 0
226234
}
227235

228236
var cmd NetStreamPlay

0 commit comments

Comments
 (0)