mirror of
				https://github.com/owncast/owncast.git
				synced 2025-10-31 10:08:10 +08:00 
			
		
		
		
	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:
		| @ -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 { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Gabe Kangas
					Gabe Kangas