Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
q191201771 committed Jun 26, 2024
1 parent afe3a8c commit 3ad5736
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/demo/calcrtmpdelay/calcrtmpdelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions app/demo/pullhttpflv/pullhttpflv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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头
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/httpflv/client_pull_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/innertest/innertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3ad5736

Please sign in to comment.