From 09a3422d061642b8b6c7b399bc47247e7f50483f Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 18 Oct 2020 11:06:54 +0200 Subject: [PATCH] Configure and test transcoder --- docs/ghostream.example.yml | 26 +++++++++++++++++--------- internal/config/config.go | 1 + main.go | 2 +- stream/messaging.go | 6 ++++-- stream/srt/handler.go | 2 +- stream/srt/srt.go | 3 +++ transcoder/transcoder_test.go | 1 + 7 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 transcoder/transcoder_test.go diff --git a/docs/ghostream.example.yml b/docs/ghostream.example.yml index aa7624e..0a0ce36 100644 --- a/docs/ghostream.example.yml +++ b/docs/ghostream.example.yml @@ -82,16 +82,24 @@ telnet: # #listenAddress: :8023 - # Size is in characters. It is recommended to keep a 16x9 format. - # - #width: 80 - #height: 45 +## Transcoders configuration ## +transcoder: + text: + # By default the text transcoder is disabled. + # You need to enable it to use telnet output. + # + #enabled: false - # Time in milliseconds between two images. - # By default 50 ms, so 20 FPS. - # Displaying text takes time. - # - #delay: 50 + # Size is in characters. It is recommended to keep a 16x9 format. + # + #width: 80 + #height: 45 + + # Time in milliseconds between two images. + # By default 50 ms, so 20 FPS. + # Displaying text takes time. + # + #delay: 50 ## Web server ## # The web server serves a WebRTC player. diff --git a/internal/config/config.go b/internal/config/config.go index dbefc50..2a94292 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -25,6 +25,7 @@ type Config struct { Monitoring monitoring.Options Srt srt.Options Telnet telnet.Options + Transcoder transcoder.Options Web web.Options WebRTC webrtc.Options } diff --git a/main.go b/main.go index 781b8dc..87d0c41 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ func main() { // Start routines go transcoder.Init(streams, &cfg.Transcoder) - go forwarding.Serve(streams, &cfg.Forwarding) + go forwarding.Serve(streams, cfg.Forwarding) go monitoring.Serve(&cfg.Monitoring) go srt.Serve(streams, authBackend, &cfg.Srt) go telnet.Serve(streams, &cfg.Telnet) diff --git a/stream/messaging.go b/stream/messaging.go index 4876d63..0798d84 100644 --- a/stream/messaging.go +++ b/stream/messaging.go @@ -1,7 +1,9 @@ // Package stream defines a structure to communication between inputs and outputs package stream -import "sync" +import ( + "sync" +) // Stream makes packages able to subscribe to an incoming stream type Stream struct { @@ -21,7 +23,7 @@ type Stream struct { // New creates a new stream. func New() *Stream { s := &Stream{} - broadcast := make(chan []byte, 64) + broadcast := make(chan []byte, 1024) s.Broadcast = broadcast s.outputs = make(map[chan []byte]struct{}) s.nbClients = 0 diff --git a/stream/srt/handler.go b/stream/srt/handler.go index 9d521dc..df0e324 100644 --- a/stream/srt/handler.go +++ b/stream/srt/handler.go @@ -65,7 +65,7 @@ func handleViewer(s *srtgo.SrtSocket, streams map[string]*stream.Stream, name st } // Register new output - c := make(chan []byte, 128) + c := make(chan []byte, 1024) st.Register(c) st.IncrementClientCount() diff --git a/stream/srt/srt.go b/stream/srt/srt.go index 6efe7a2..81e766c 100644 --- a/stream/srt/srt.go +++ b/stream/srt/srt.go @@ -69,6 +69,9 @@ func Serve(streams map[string]*stream.Stream, authBackend auth.Backend, cfg *Opt continue } + // FIXME: Flush socket + // Without this, the SRT buffer might get full before reading it + // streamid can be "name:password" for streamer or "name" for viewer streamID, err := s.GetSockOptString(C.SRTO_STREAMID) if err != nil { diff --git a/transcoder/transcoder_test.go b/transcoder/transcoder_test.go new file mode 100644 index 0000000..5493916 --- /dev/null +++ b/transcoder/transcoder_test.go @@ -0,0 +1 @@ +package transcoder