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

View File

@ -59,7 +59,8 @@ func autoStartConversion(streams map[string]*stream.Stream, textStreams map[stri
} }
// Start conversion // 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{} textStream = &[]byte{}
textStreams[name] = textStream textStreams[name] = textStream
go streamToTextStream(stream, textStream, cfg) go streamToTextStream(stream, textStream, cfg)