1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 11:28:51 +02:00

Try to test serving SRT server

This commit is contained in:
Yohann D'ANELLO
2020-09-30 16:53:15 +02:00
parent 2096643ab4
commit ddd8be155e
3 changed files with 53 additions and 1 deletions

View File

@ -82,6 +82,10 @@ func RegisterStream(name string) error {
// SendPacket forward data to all FFMpeg instances related to the stream name
func SendPacket(name string, data []byte) {
stdin := ffmpegInputStreams[name]
if stdin == nil {
// Don't need to forward stream
return
}
_, err := (*stdin).Write(data)
if err != nil {
log.Printf("Error while sending a packet to external streaming server for key %s: %s", name, err)
@ -91,6 +95,10 @@ func SendPacket(name string, data []byte) {
// CloseConnection When the stream is ended, close FFMPEG instances
func CloseConnection(name string) error {
ffmpeg := ffmpegInstances[name]
if ffmpeg == nil {
// No stream to close
return nil
}
if err := ffmpeg.Process.Kill(); err != nil {
return err
}