Disconnect stream Admin API + HTTP Basic Auth (#204)

* Create http auth middleware

* Add support for ending the inbound stream. Closes #191

* Add a simple success response to API requests
This commit is contained in:
Gabe Kangas
2020-10-01 18:16:58 -07:00
committed by GitHub
parent f8068826ab
commit 7b64fc7c30
6 changed files with 90 additions and 0 deletions

View File

@ -28,6 +28,7 @@ var (
var _transcoder ffmpeg.Transcoder
var _pipe *os.File
var _rtmpConnection net.Conn
//Start starts the rtmp service, listening on port 1935
func Start() {
@ -92,6 +93,7 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) {
_isConnected = true
core.SetStreamAsConnected()
_rtmpConnection = nc
f, err := os.OpenFile(pipePath, os.O_RDWR, os.ModeNamedPipe)
_pipe = f
@ -121,9 +123,20 @@ func handleDisconnect(conn net.Conn) {
_pipe.Close()
_isConnected = false
_transcoder.Stop()
_rtmpConnection = nil
core.SetStreamAsDisconnected()
}
// Disconnect will force disconnect the current inbound RTMP connection.
func Disconnect() {
if _rtmpConnection == nil {
return
}
log.Infoln("Inbound stream disconnect requested.")
handleDisconnect(_rtmpConnection)
}
//IsConnected gets whether there is an rtmp connection or not
//this is only a getter since it is controlled by the rtmp handler
func IsConnected() bool {