diff --git a/main.go b/main.go index c0400fb..7f42fd3 100644 --- a/main.go +++ b/main.go @@ -93,15 +93,13 @@ func main() { // SRT channel, to propagate forwarding 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 srt.Serve(&cfg.Srt, forwardingChannel) go web.Serve(remoteSdpChan, localSdpChan, &cfg.Web) go webrtc.Serve(remoteSdpChan, localSdpChan, &cfg.WebRTC) - // Configure stream forwarding - forwarding.New(cfg.Forwarding, forwardingChannel) - // Wait for routines select {} } diff --git a/stream/forwarding/forwarding.go b/stream/forwarding/forwarding.go index e4225dd..31611f2 100644 --- a/stream/forwarding/forwarding.go +++ b/stream/forwarding/forwarding.go @@ -19,12 +19,12 @@ var ( ffmpegInputStreams = make(map[string]*io.WriteCloser) ) -// New Load configuration and initialize SRT channel -func New(c Options, channel chan srt.Packet) { +// Serve Load configuration and initialize SRT channel +func Serve(c Options, channel chan srt.Packet) { cfg = c forwardingChannel = channel - go waitForPackets() log.Printf("Stream forwarding initialized") + waitForPackets() } func waitForPackets() { diff --git a/stream/forwarding/forwarding_test.go b/stream/forwarding/forwarding_test.go index 1d40def..95d5f7a 100644 --- a/stream/forwarding/forwarding_test.go +++ b/stream/forwarding/forwarding_test.go @@ -56,7 +56,7 @@ func TestForwardStream(t *testing.T) { forwardingChannel = make(chan srt.Packet) // Register forwarding stream list - New(forwardingList, forwardingChannel) + Serve(forwardingList, forwardingChannel) // Serve HTTP Server go srt.Serve(&srt.Options{ListenAddress: ":9712", MaxClients: 2}, forwardingChannel)