Define streams in main.go

This commit is contained in:
Alexandre Iooss 2020-10-17 18:22:06 +02:00
parent 88dfc22d81
commit 1469bd8759
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
2 changed files with 10 additions and 9 deletions

16
main.go
View File

@ -10,6 +10,7 @@ import (
"gitlab.crans.org/nounous/ghostream/auth"
"gitlab.crans.org/nounous/ghostream/internal/config"
"gitlab.crans.org/nounous/ghostream/internal/monitoring"
"gitlab.crans.org/nounous/ghostream/stream"
"gitlab.crans.org/nounous/ghostream/stream/forwarding"
"gitlab.crans.org/nounous/ghostream/stream/srt"
"gitlab.crans.org/nounous/ghostream/stream/telnet"
@ -43,17 +44,16 @@ func main() {
})
localSdpChan := make(chan webrtc.SessionDescription)
// SRT channel for forwarding and webrtc
forwardingChannel := make(chan srt.Packet, 64)
webrtcChannel := make(chan srt.Packet, 64)
// Init streams messaging
streams := make(map[string]*stream.Stream)
// Start routines
go forwarding.Serve(forwardingChannel, cfg.Forwarding)
go forwarding.Serve(streams, cfg.Forwarding)
go monitoring.Serve(&cfg.Monitoring)
go srt.Serve(&cfg.Srt, authBackend, forwardingChannel, webrtcChannel)
go telnet.Serve(&cfg.Telnet)
go web.Serve(remoteSdpChan, localSdpChan, &cfg.Web)
go webrtc.Serve(remoteSdpChan, localSdpChan, webrtcChannel, &cfg.WebRTC)
go srt.Serve(streams, authBackend, &cfg.Srt)
go telnet.Serve(streams, &cfg.Telnet)
go web.Serve(streams, remoteSdpChan, localSdpChan, &cfg.Web)
go webrtc.Serve(streams, remoteSdpChan, localSdpChan, &cfg.WebRTC)
// Wait for routines
select {}

View File

@ -59,7 +59,8 @@ func autoStartConversion(streams map[string]*stream.Stream, textStreams map[stri
}
// Start conversion
log.Print("Starting text conversion of %s", name)
log.Printf("Starting text conversion of %s", name)
// FIXME that is not how to use a pointer
textStream = &[]byte{}
textStreams[name] = textStream
go streamToTextStream(stream, textStream, cfg)