pull/358/head
q191201771 7 months ago
parent afe3a8c635
commit 3ad5736308

@ -92,12 +92,12 @@ func main() {
switch pullType {
case PullTypeHttpflv:
httpflvPullSession = httpflv.NewPullSession()
err = httpflvPullSession.Pull(pullUrl, func(tag httpflv.Tag) {
httpflvPullSession = httpflv.NewPullSession().WithOnReadFlvTag(func(tag httpflv.Tag) {
handleReadPayloadFn(tag.Payload())
})
if err != nil {
if err = httpflvPullSession.Start(pullUrl); err != nil {
nazalog.Fatalf("pull flv failed. err=%+v", err)
return
}
nazalog.Info("pull flv succ.")
defer httpflvPullSession.Dispose()

@ -37,8 +37,7 @@ func main() {
defer flvfile.Close()
session := httpflv.NewPullSession()
err = session.Pull(url, func(tag httpflv.Tag) {
session := httpflv.NewPullSession().WithOnReadFlvTag(func(tag httpflv.Tag) {
if tag.Header.Type == httpflv.TagTypeMetadata {
// TODO(chef): httpflv.PullSession支持返回flv header可供业务方选择使用 202210
// 根据metadata填写flv头
@ -69,6 +68,8 @@ func main() {
flvfile.Write(tag.Raw)
})
err = session.Start(url)
nazalog.Assert(nil, err)
err = <-session.WaitChan()
nazalog.Assert(nil, err)

@ -91,7 +91,7 @@ func (session *PullSession) Start(rawUrl string) error {
return session.pull(rawUrl)
}
// Pull deprecated. use Start instead.
// Pull deprecated. use WithOnReadFlvTag and Start instead.
func (session *PullSession) Pull(rawUrl string, onReadFlvTag OnReadFlvTag) error {
return session.WithOnReadFlvTag(onReadFlvTag).Start(rawUrl)
}

@ -232,13 +232,13 @@ func entry() {
var flvErr error
httpflvPullSession = httpflv.NewPullSession(func(option *httpflv.PullSessionOption) {
option.ReadTimeoutMs = 10000
})
err := httpflvPullSession.Pull(httpflvPullUrl, func(tag httpflv.Tag) {
err := httpFlvWriter.WriteTag(tag)
assert.Equal(t, nil, err)
}).WithOnReadFlvTag(func(tag httpflv.Tag) {
errWrite := httpFlvWriter.WriteTag(tag)
assert.Equal(t, nil, errWrite)
httpflvPullTagCount.Increment()
})
Log.Assert(nil, err)
errStart := httpflvPullSession.Start(httpflvPullUrl)
Log.Assert(nil, errStart)
flvErr = <-httpflvPullSession.WaitChan()
Log.Debug(flvErr)

Loading…
Cancel
Save