forked from External/mediamtx
import changes
This commit is contained in:
parent
da5420a788
commit
09ad8e7160
3 changed files with 28 additions and 0 deletions
|
|
@ -180,6 +180,10 @@ type Path struct {
|
||||||
RunOnUnread string `json:"runOnUnread"`
|
RunOnUnread string `json:"runOnUnread"`
|
||||||
RunOnRecordSegmentCreate string `json:"runOnRecordSegmentCreate"`
|
RunOnRecordSegmentCreate string `json:"runOnRecordSegmentCreate"`
|
||||||
RunOnRecordSegmentComplete string `json:"runOnRecordSegmentComplete"`
|
RunOnRecordSegmentComplete string `json:"runOnRecordSegmentComplete"`
|
||||||
|
|
||||||
|
// Custom hooks
|
||||||
|
HTTPOnReady string `json:"httpOnReady"`
|
||||||
|
HTTPOnNotReady string `json:"httpOnNotReady"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pconf *Path) setDefaults() {
|
func (pconf *Path) setDefaults() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package hooks
|
package hooks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"github.com/bluenviron/mediamtx/internal/conf"
|
"github.com/bluenviron/mediamtx/internal/conf"
|
||||||
"github.com/bluenviron/mediamtx/internal/defs"
|
"github.com/bluenviron/mediamtx/internal/defs"
|
||||||
"github.com/bluenviron/mediamtx/internal/externalcmd"
|
"github.com/bluenviron/mediamtx/internal/externalcmd"
|
||||||
"github.com/bluenviron/mediamtx/internal/logger"
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OnReadyParams are the parameters of OnReady.
|
// OnReadyParams are the parameters of OnReady.
|
||||||
|
|
@ -41,6 +44,16 @@ func OnReady(params OnReadyParams) func() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.Conf.HTTPOnReady != "" {
|
||||||
|
obj := map[string]any{
|
||||||
|
"query": params.Query,
|
||||||
|
"desc": params.Desc,
|
||||||
|
"env": params.ExternalCmdEnv,
|
||||||
|
}
|
||||||
|
jsonValue, _ := json.Marshal(obj)
|
||||||
|
http.Post(params.Conf.HTTPOnReady, "application/json", bytes.NewBuffer(jsonValue))
|
||||||
|
}
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
if onReadyCmd != nil {
|
if onReadyCmd != nil {
|
||||||
onReadyCmd.Close()
|
onReadyCmd.Close()
|
||||||
|
|
@ -56,5 +69,15 @@ func OnReady(params OnReadyParams) func() {
|
||||||
env,
|
env,
|
||||||
nil)
|
nil)
|
||||||
}
|
}
|
||||||
|
if params.Conf.HTTPOnNotReady != "" {
|
||||||
|
obj := map[string]any{
|
||||||
|
"query": params.Query,
|
||||||
|
"desc": params.Desc,
|
||||||
|
"env": params.ExternalCmdEnv,
|
||||||
|
}
|
||||||
|
jsonValue, _ := json.Marshal(obj)
|
||||||
|
http.Post(params.Conf.HTTPOnNotReady, "application/json", bytes.NewBuffer(jsonValue))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,7 @@ const sendOffer = (offer) => {
|
||||||
return res.text()
|
return res.text()
|
||||||
.then((sdp) => onRemoteAnswer(sdp));
|
.then((sdp) => onRemoteAnswer(sdp));
|
||||||
})
|
})
|
||||||
|
.then((sdp) => onRemoteAnswer(sdp))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
onError(err.toString());
|
onError(err.toString());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue