1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 19:42:20 +00:00

Unify the forwarding package start with the other, start it in a go routine

This commit is contained in:
Yohann D'ANELLO 2020-10-01 19:26:12 +02:00
parent 98d5c609a3
commit d7e104261f
3 changed files with 6 additions and 8 deletions

View File

@ -93,15 +93,13 @@ func main() {
// SRT channel, to propagate forwarding // SRT channel, to propagate forwarding
forwardingChannel := make(chan srt.Packet) forwardingChannel := make(chan srt.Packet)
// Start stream, web and monitoring server // Start stream, web and monitoring server, and stream forwarding
go forwarding.Serve(cfg.Forwarding, forwardingChannel)
go monitoring.Serve(&cfg.Monitoring) go monitoring.Serve(&cfg.Monitoring)
go srt.Serve(&cfg.Srt, forwardingChannel) go srt.Serve(&cfg.Srt, forwardingChannel)
go web.Serve(remoteSdpChan, localSdpChan, &cfg.Web) go web.Serve(remoteSdpChan, localSdpChan, &cfg.Web)
go webrtc.Serve(remoteSdpChan, localSdpChan, &cfg.WebRTC) go webrtc.Serve(remoteSdpChan, localSdpChan, &cfg.WebRTC)
// Configure stream forwarding
forwarding.New(cfg.Forwarding, forwardingChannel)
// Wait for routines // Wait for routines
select {} select {}
} }

View File

@ -19,12 +19,12 @@ var (
ffmpegInputStreams = make(map[string]*io.WriteCloser) ffmpegInputStreams = make(map[string]*io.WriteCloser)
) )
// New Load configuration and initialize SRT channel // Serve Load configuration and initialize SRT channel
func New(c Options, channel chan srt.Packet) { func Serve(c Options, channel chan srt.Packet) {
cfg = c cfg = c
forwardingChannel = channel forwardingChannel = channel
go waitForPackets()
log.Printf("Stream forwarding initialized") log.Printf("Stream forwarding initialized")
waitForPackets()
} }
func waitForPackets() { func waitForPackets() {

View File

@ -56,7 +56,7 @@ func TestForwardStream(t *testing.T) {
forwardingChannel = make(chan srt.Packet) forwardingChannel = make(chan srt.Packet)
// Register forwarding stream list // Register forwarding stream list
New(forwardingList, forwardingChannel) Serve(forwardingList, forwardingChannel)
// Serve HTTP Server // Serve HTTP Server
go srt.Serve(&srt.Options{ListenAddress: ":9712", MaxClients: 2}, forwardingChannel) go srt.Serve(&srt.Options{ListenAddress: ":9712", MaxClients: 2}, forwardingChannel)