diff --git a/README.md b/README.md index c8c81ad..6ff7bff 100644 --- a/README.md +++ b/README.md @@ -17,37 +17,10 @@ import ( ```yaml hdl: - http: - listenaddr: :8080 # 网关地址,用于访问API - listenaddrtls: "" # 用于HTTPS方式访问API的端口配置 - certfile: "" - keyfile: "" - cors: true # 是否自动添加cors头 - username: "" # 用户名和密码,用于API访问时的基本身份认证 - password: "" - publish: - pubaudio: true # 是否发布音频流 - pubvideo: true # 是否发布视频流 - kickexist: false # 剔出已经存在的发布者,用于顶替原有发布者 - publishtimeout: 10s # 发布流默认过期时间,超过该时间发布者没有恢复流将被删除 - delayclosetimeout: 0 # 自动关闭触发后延迟的时间(期间内如果有新的订阅则取消触发关闭),0为关闭该功能,保持连接。 - waitclosetimeout: 0 # 发布者断开后等待时间,超过该时间发布者没有恢复流将被删除,0为关闭该功能,由订阅者决定是否删除 - buffertime: 0 # 缓存时间,用于时光回溯,0为关闭缓存 - subscribe: - subaudio: true # 是否订阅音频流 - subvideo: true # 是否订阅视频流 - subaudioargname: ats # 订阅音频轨道参数名 - subvideoargname: vts # 订阅视频轨道参数名 - subdataargname: dts # 订阅数据轨道参数名 - subaudiotracks: [] # 订阅音频轨道名称列表 - subvideotracks: [] # 订阅视频轨道名称列表 - submode: 0 # 订阅模式,0为跳帧追赶模式,1为不追赶(多用于录制),2为时光回溯模式 - iframeonly: false # 只订阅关键帧 - waittimeout: 10s # 等待发布者的超时时间,用于订阅尚未发布的流 - pull: - repull: 0 - pullonstart: {} - pullonsub: {} + http: # 格式参考全局配置 + publish: # 格式参考全局配置 + subscribe: # 格式参考全局配置 + pull: # 格式 https://m7s.live/guide/config.html#%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE ``` ## 插件功能 diff --git a/pull.go b/pull.go index ca15ea0..0e60033 100644 --- a/pull.go +++ b/pull.go @@ -3,6 +3,7 @@ package hdl import ( "io" "net/http" + "net/url" "os" "strings" @@ -31,7 +32,16 @@ func (puller *HDLPuller) Connect() (err error) { HDLPlugin.Info("connect", zap.String("remoteURL", puller.RemoteURL)) if strings.HasPrefix(puller.RemoteURL, "http") { var res *http.Response - if res, err = http.Get(puller.RemoteURL); err == nil { + client := http.DefaultClient + if puller.Puller.Config.Proxy != "" { + proxy, err := url.Parse(puller.Puller.Config.Proxy) + if err != nil { + return err + } + transport := &http.Transport{Proxy: http.ProxyURL(proxy)} + client = &http.Client{Transport: transport} + } + if res, err = client.Get(puller.RemoteURL); err == nil { if res.StatusCode != http.StatusOK { return io.EOF } @@ -87,6 +97,9 @@ func (puller *HDLPuller) Pull() (err error) { puller.WriteAVCCAudio(puller.absTS, &frame, puller.pool) case codec.FLV_TAG_TYPE_VIDEO: puller.WriteAVCCVideo(puller.absTS, &frame, puller.pool) + case codec.FLV_TAG_TYPE_SCRIPT: + puller.Info("script", zap.ByteString("data", mem.Value)) + frame.Recycle() } } return