|
|
@ -97,14 +97,15 @@ type Parent interface { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Client struct { |
|
|
|
type Client struct { |
|
|
|
wg *sync.WaitGroup |
|
|
|
rtspPort int |
|
|
|
stats *stats.Stats |
|
|
|
|
|
|
|
serverUdpRtp *serverudp.Server |
|
|
|
|
|
|
|
serverUdpRtcp *serverudp.Server |
|
|
|
|
|
|
|
readTimeout time.Duration |
|
|
|
readTimeout time.Duration |
|
|
|
runOnConnect string |
|
|
|
runOnConnect string |
|
|
|
runOnConnectRestart bool |
|
|
|
runOnConnectRestart bool |
|
|
|
protocols map[gortsplib.StreamProtocol]struct{} |
|
|
|
protocols map[gortsplib.StreamProtocol]struct{} |
|
|
|
|
|
|
|
wg *sync.WaitGroup |
|
|
|
|
|
|
|
stats *stats.Stats |
|
|
|
|
|
|
|
serverUdpRtp *serverudp.Server |
|
|
|
|
|
|
|
serverUdpRtcp *serverudp.Server |
|
|
|
conn *gortsplib.ConnServer |
|
|
|
conn *gortsplib.ConnServer |
|
|
|
parent Parent |
|
|
|
parent Parent |
|
|
|
|
|
|
|
|
|
|
@ -128,27 +129,29 @@ type Client struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func New( |
|
|
|
func New( |
|
|
|
wg *sync.WaitGroup, |
|
|
|
rtspPort int, |
|
|
|
stats *stats.Stats, |
|
|
|
|
|
|
|
serverUdpRtp *serverudp.Server, |
|
|
|
|
|
|
|
serverUdpRtcp *serverudp.Server, |
|
|
|
|
|
|
|
readTimeout time.Duration, |
|
|
|
readTimeout time.Duration, |
|
|
|
writeTimeout time.Duration, |
|
|
|
writeTimeout time.Duration, |
|
|
|
runOnConnect string, |
|
|
|
runOnConnect string, |
|
|
|
runOnConnectRestart bool, |
|
|
|
runOnConnectRestart bool, |
|
|
|
protocols map[gortsplib.StreamProtocol]struct{}, |
|
|
|
protocols map[gortsplib.StreamProtocol]struct{}, |
|
|
|
|
|
|
|
wg *sync.WaitGroup, |
|
|
|
|
|
|
|
stats *stats.Stats, |
|
|
|
|
|
|
|
serverUdpRtp *serverudp.Server, |
|
|
|
|
|
|
|
serverUdpRtcp *serverudp.Server, |
|
|
|
nconn net.Conn, |
|
|
|
nconn net.Conn, |
|
|
|
parent Parent) *Client { |
|
|
|
parent Parent) *Client { |
|
|
|
|
|
|
|
|
|
|
|
c := &Client{ |
|
|
|
c := &Client{ |
|
|
|
wg: wg, |
|
|
|
rtspPort: rtspPort, |
|
|
|
stats: stats, |
|
|
|
|
|
|
|
serverUdpRtp: serverUdpRtp, |
|
|
|
|
|
|
|
serverUdpRtcp: serverUdpRtcp, |
|
|
|
|
|
|
|
readTimeout: readTimeout, |
|
|
|
readTimeout: readTimeout, |
|
|
|
runOnConnect: runOnConnect, |
|
|
|
runOnConnect: runOnConnect, |
|
|
|
runOnConnectRestart: runOnConnectRestart, |
|
|
|
runOnConnectRestart: runOnConnectRestart, |
|
|
|
protocols: protocols, |
|
|
|
protocols: protocols, |
|
|
|
|
|
|
|
wg: wg, |
|
|
|
|
|
|
|
stats: stats, |
|
|
|
|
|
|
|
serverUdpRtp: serverUdpRtp, |
|
|
|
|
|
|
|
serverUdpRtcp: serverUdpRtcp, |
|
|
|
conn: gortsplib.NewConnServer(gortsplib.ConnServerConf{ |
|
|
|
conn: gortsplib.NewConnServer(gortsplib.ConnServerConf{ |
|
|
|
Conn: nconn, |
|
|
|
Conn: nconn, |
|
|
|
ReadTimeout: readTimeout, |
|
|
|
ReadTimeout: readTimeout, |
|
|
@ -201,7 +204,10 @@ func (c *Client) run() { |
|
|
|
|
|
|
|
|
|
|
|
var onConnectCmd *externalcmd.ExternalCmd |
|
|
|
var onConnectCmd *externalcmd.ExternalCmd |
|
|
|
if c.runOnConnect != "" { |
|
|
|
if c.runOnConnect != "" { |
|
|
|
onConnectCmd = externalcmd.New(c.runOnConnect, c.runOnConnectRestart, "") |
|
|
|
onConnectCmd = externalcmd.New(c.runOnConnect, c.runOnConnectRestart, externalcmd.Environment{ |
|
|
|
|
|
|
|
Path: "", |
|
|
|
|
|
|
|
Port: strconv.FormatInt(int64(c.rtspPort), 10), |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
for { |
|
|
@ -936,8 +942,10 @@ func (c *Client) runPlay() bool { |
|
|
|
|
|
|
|
|
|
|
|
var onReadCmd *externalcmd.ExternalCmd |
|
|
|
var onReadCmd *externalcmd.ExternalCmd |
|
|
|
if c.path.Conf().RunOnRead != "" { |
|
|
|
if c.path.Conf().RunOnRead != "" { |
|
|
|
onReadCmd = externalcmd.New(c.path.Conf().RunOnRead, |
|
|
|
onReadCmd = externalcmd.New(c.path.Conf().RunOnRead, c.path.Conf().RunOnReadRestart, externalcmd.Environment{ |
|
|
|
c.path.Conf().RunOnReadRestart, c.path.Name()) |
|
|
|
Path: c.path.Name(), |
|
|
|
|
|
|
|
Port: strconv.FormatInt(int64(c.rtspPort), 10), |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if c.streamProtocol == gortsplib.StreamProtocolUDP { |
|
|
|
if c.streamProtocol == gortsplib.StreamProtocolUDP { |
|
|
@ -1111,8 +1119,10 @@ func (c *Client) runRecord() bool { |
|
|
|
|
|
|
|
|
|
|
|
var onPublishCmd *externalcmd.ExternalCmd |
|
|
|
var onPublishCmd *externalcmd.ExternalCmd |
|
|
|
if c.path.Conf().RunOnPublish != "" { |
|
|
|
if c.path.Conf().RunOnPublish != "" { |
|
|
|
onPublishCmd = externalcmd.New(c.path.Conf().RunOnPublish, |
|
|
|
onPublishCmd = externalcmd.New(c.path.Conf().RunOnPublish, c.path.Conf().RunOnPublishRestart, externalcmd.Environment{ |
|
|
|
c.path.Conf().RunOnPublishRestart, c.path.Name()) |
|
|
|
Path: c.path.Name(), |
|
|
|
|
|
|
|
Port: strconv.FormatInt(int64(c.rtspPort), 10), |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if c.streamProtocol == gortsplib.StreamProtocolUDP { |
|
|
|
if c.streamProtocol == gortsplib.StreamProtocolUDP { |
|
|
|