Add support TCP MPEG-TS source
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
package tcp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/AlexxIT/go2rtc/cmd/streams"
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/mpegts"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
streams.HandleFunc("tcp", handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handle(rawURL string) (core.Producer, error) {
|
||||||
|
u, err := url.Parse(rawURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
conn, err := net.DialTimeout("tcp", u.Host, time.Second*3)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &http.Request{URL: u}
|
||||||
|
res := &http.Response{Body: conn, Request: req}
|
||||||
|
client := mpegts.NewClient(res)
|
||||||
|
if err := client.Handle(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return client, nil
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/AlexxIT/go2rtc/cmd/srtp"
|
"github.com/AlexxIT/go2rtc/cmd/srtp"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/streams"
|
"github.com/AlexxIT/go2rtc/cmd/streams"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/tapo"
|
"github.com/AlexxIT/go2rtc/cmd/tapo"
|
||||||
|
"github.com/AlexxIT/go2rtc/cmd/tcp"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/webrtc"
|
"github.com/AlexxIT/go2rtc/cmd/webrtc"
|
||||||
"github.com/AlexxIT/go2rtc/cmd/webtorrent"
|
"github.com/AlexxIT/go2rtc/cmd/webtorrent"
|
||||||
"os"
|
"os"
|
||||||
@@ -49,6 +50,7 @@ func main() {
|
|||||||
isapi.Init()
|
isapi.Init()
|
||||||
mpegts.Init()
|
mpegts.Init()
|
||||||
roborock.Init()
|
roborock.Init()
|
||||||
|
tcp.Init()
|
||||||
|
|
||||||
srtp.Init()
|
srtp.Init()
|
||||||
homekit.Init()
|
homekit.Init()
|
||||||
|
|||||||
Reference in New Issue
Block a user