mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
rtsp: support reading streams tunneled with HTTP or WebSocket (#4986)
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
This commit is contained in:
parent
558d1c3818
commit
f81c50ee68
6 changed files with 50 additions and 17 deletions
|
|
@ -2,6 +2,8 @@
|
|||
package rtsp
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/bluenviron/gortsplib/v5"
|
||||
|
|
@ -116,14 +118,37 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error {
|
|||
decodeErrors.Start()
|
||||
defer decodeErrors.Stop()
|
||||
|
||||
u, err := base.ParseURL(params.ResolvedSource)
|
||||
u0, err := url.Parse(params.ResolvedSource)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var scheme string
|
||||
if u0.Scheme == "rtsp" || u0.Scheme == "rtsp+http" || u0.Scheme == "rtsp+ws" {
|
||||
scheme = "rtsp"
|
||||
} else {
|
||||
scheme = "rtsps"
|
||||
}
|
||||
|
||||
var tunnel gortsplib.Tunnel
|
||||
switch u0.Scheme {
|
||||
case "rtsp+http", "rtsps+http":
|
||||
tunnel = gortsplib.TunnelHTTP
|
||||
case "rtsp+ws", "rtsps+ws":
|
||||
tunnel = gortsplib.TunnelWebSocket
|
||||
default:
|
||||
tunnel = gortsplib.TunnelNone
|
||||
}
|
||||
|
||||
u, err := base.ParseURL(regexp.MustCompile("^.*?://").ReplaceAllString(params.ResolvedSource, "rtsp://"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := &gortsplib.Client{
|
||||
Scheme: u.Scheme,
|
||||
Scheme: scheme,
|
||||
Host: u.Host,
|
||||
Tunnel: tunnel,
|
||||
Protocol: params.Conf.RTSPTransport.Protocol,
|
||||
TLSConfig: tls.MakeConfig(u.Hostname(), params.Conf.SourceFingerprint),
|
||||
ReadTimeout: time.Duration(s.ReadTimeout),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue