From afe3a8c635ae7fa733da128e796d6da6807d6411 Mon Sep 17 00:00:00 2001 From: q191201771 <191201771@qq.com> Date: Tue, 25 Jun 2024 10:41:18 +0800 Subject: [PATCH] patch --- pkg/httpflv/client_pull_session.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/pkg/httpflv/client_pull_session.go b/pkg/httpflv/client_pull_session.go index 6fffef79..56af37bc 100644 --- a/pkg/httpflv/client_pull_session.go +++ b/pkg/httpflv/client_pull_session.go @@ -85,29 +85,15 @@ func (session *PullSession) WithOnReadFlvTag(onReadFlvTag OnReadFlvTag) *PullSes // 1. `http://{domain}/{app_name}/{stream_name}.flv` // 2. `http://{ip}/{domain}/{app_name}/{stream_name}.flv` func (session *PullSession) Start(rawUrl string) error { - return session.Pull(rawUrl, session.onReadFlvTag) + if session.onReadFlvTag == nil { + Log.Warnf("[%s] Start. onReadFlvTag not set.", session.UniqueKey()) + } + return session.pull(rawUrl) } // Pull deprecated. use Start instead. func (session *PullSession) Pull(rawUrl string, onReadFlvTag OnReadFlvTag) error { - Log.Debugf("[%s] pull. url=%s", session.UniqueKey(), rawUrl) - - var ( - ctx context.Context - cancel context.CancelFunc - ) - if session.option.PullTimeoutMs == 0 { - ctx, cancel = context.WithCancel(context.Background()) - } else { - ctx, cancel = context.WithTimeout(context.Background(), time.Duration(session.option.PullTimeoutMs)*time.Millisecond) - } - defer cancel() - - err := session.pullContext(ctx, rawUrl, onReadFlvTag) - if err != nil { - _ = session.dispose(err) - } - return err + return session.WithOnReadFlvTag(onReadFlvTag).Start(rawUrl) } // ---------------------------------------------------------------------------------------------------------------------