mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-20 14:11:09 +00:00
print log messages when runOnConnect and runOnRead are started or stopped
This commit is contained in:
parent
3149203f36
commit
160966e81b
@ -147,12 +147,17 @@ func (c *rtmpConn) run() {
|
||||
defer c.log(logger.Info, "closed")
|
||||
|
||||
if c.runOnConnect != "" {
|
||||
c.log(logger.Info, "runOnConnect command started")
|
||||
_, port, _ := net.SplitHostPort(c.rtspAddress)
|
||||
onConnectCmd := externalcmd.New(c.runOnConnect, c.runOnConnectRestart, externalcmd.Environment{
|
||||
Path: "",
|
||||
Port: port,
|
||||
})
|
||||
defer onConnectCmd.Close()
|
||||
|
||||
defer func() {
|
||||
onConnectCmd.Close()
|
||||
c.log(logger.Info, "runOnConnect command stopped")
|
||||
}()
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(c.ctx)
|
||||
@ -278,12 +283,16 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
|
||||
})
|
||||
|
||||
if c.path.Conf().RunOnRead != "" {
|
||||
c.log(logger.Info, "runOnRead command started")
|
||||
_, port, _ := net.SplitHostPort(c.rtspAddress)
|
||||
onReadCmd := externalcmd.New(c.path.Conf().RunOnRead, c.path.Conf().RunOnReadRestart, externalcmd.Environment{
|
||||
Path: c.path.Name(),
|
||||
Port: port,
|
||||
})
|
||||
defer onReadCmd.Close()
|
||||
defer func() {
|
||||
onReadCmd.Close()
|
||||
c.log(logger.Info, "runOnRead command stopped")
|
||||
}()
|
||||
}
|
||||
|
||||
// disable read deadline
|
||||
|
@ -75,6 +75,7 @@ func newRTSPConn(
|
||||
c.log(logger.Info, "opened")
|
||||
|
||||
if c.runOnConnect != "" {
|
||||
c.log(logger.Info, "runOnConnect command started")
|
||||
_, port, _ := net.SplitHostPort(c.rtspAddress)
|
||||
c.onConnectCmd = externalcmd.New(c.runOnConnect, c.runOnConnectRestart, externalcmd.Environment{
|
||||
Path: "",
|
||||
@ -173,6 +174,7 @@ func (c *rtspConn) OnClose(err error) {
|
||||
|
||||
if c.onConnectCmd != nil {
|
||||
c.onConnectCmd.Close()
|
||||
c.log(logger.Info, "runOnConnect command stopped")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,8 @@ func (s *rtspSession) OnClose() {
|
||||
if s.ss.State() == gortsplib.ServerSessionStateRead {
|
||||
if s.onReadCmd != nil {
|
||||
s.onReadCmd.Close()
|
||||
s.onReadCmd = nil
|
||||
s.log(logger.Info, "runOnRead command stopped")
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,6 +264,7 @@ func (s *rtspSession) OnPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Respo
|
||||
s.path.OnReaderPlay(pathReaderPlayReq{Author: s})
|
||||
|
||||
if s.path.Conf().RunOnRead != "" {
|
||||
s.log(logger.Info, "runOnRead command started")
|
||||
_, port, _ := net.SplitHostPort(s.rtspAddress)
|
||||
s.onReadCmd = externalcmd.New(s.path.Conf().RunOnRead, s.path.Conf().RunOnReadRestart, externalcmd.Environment{
|
||||
Path: s.path.Name(),
|
||||
@ -308,6 +311,7 @@ func (s *rtspSession) OnPause(ctx *gortsplib.ServerHandlerOnPauseCtx) (*base.Res
|
||||
switch s.ss.State() {
|
||||
case gortsplib.ServerSessionStateRead:
|
||||
if s.onReadCmd != nil {
|
||||
s.log(logger.Info, "runOnRead command stopped")
|
||||
s.onReadCmd.Close()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user