Refactoring for RTMP source

This commit is contained in:
Alexey Khit
2023-08-17 07:59:21 +03:00
parent 42f6441512
commit b016b7dc2a
3 changed files with 51 additions and 85 deletions
+34
View File
@@ -0,0 +1,34 @@
package rtmp
import (
"net"
"net/url"
"strings"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/flv"
)
func Dial(rawURL string) (core.Producer, error) {
u, err := url.Parse(rawURL)
if err != nil {
return nil, err
}
host := u.Host
if strings.IndexByte(host, ':') < 0 {
host += ":1935"
}
conn, err := net.DialTimeout("tcp", host, core.ConnDialTimeout)
if err != nil {
return nil, err
}
rd, err := NewReader(u, conn)
if err != nil {
return nil, err
}
return flv.Open(rd)
}