mirror of
https://github.com/Monibuca/plugin-hdl.git
synced 2025-10-05 08:47:00 +08:00
修改设置父级Context和IO的方式
This commit is contained in:
4
main.go
4
main.go
@@ -86,8 +86,8 @@ func (*HDLConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "video/x-flv")
|
||||
sub := &HDLSubscriber{}
|
||||
sub.ID = r.RemoteAddr
|
||||
sub.OnEvent(r.Context()) //注入父级Context
|
||||
sub.OnEvent(w) //注入Writer
|
||||
sub.SetParentCtx(r.Context())
|
||||
sub.SetIO(w)
|
||||
if err := plugin.Subscribe(streamPath, sub); err == nil {
|
||||
at, vt := sub.AudioTrack, sub.VideoTrack
|
||||
hasVideo := at != nil
|
||||
|
4
pull.go
4
pull.go
@@ -20,12 +20,12 @@ func (puller *HDLPuller) connect() (err error) {
|
||||
if strings.HasPrefix(puller.RemoteURL, "http") {
|
||||
var res *http.Response
|
||||
if res, err = http.Get(puller.RemoteURL); err == nil {
|
||||
puller.OnEvent(res.Body)
|
||||
puller.SetIO(res.Body)
|
||||
}
|
||||
} else {
|
||||
var res *os.File
|
||||
if res, err = os.Open(puller.RemoteURL); err == nil {
|
||||
puller.OnEvent(res)
|
||||
puller.SetIO(res)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user