From bb589a71ce8b5fbdb3593a83a333fe753adc10a7 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 19 Oct 2020 19:28:04 +0200 Subject: [PATCH] Add method to get quality --- messaging/stream.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/messaging/stream.go b/messaging/stream.go index 81eed21..73d5e88 100644 --- a/messaging/stream.go +++ b/messaging/stream.go @@ -2,6 +2,7 @@ package messaging import ( + "errors" "sync" ) @@ -33,7 +34,7 @@ func (s *Stream) CreateQuality(name string) (quality *Quality) { return quality } -// DeleteQuality removes a quality. +// DeleteQuality removes a stream quality. func (s *Stream) DeleteQuality(name string) { // Make sure we did not already close this output s.lockQualities.Lock() @@ -44,6 +45,17 @@ func (s *Stream) DeleteQuality(name string) { s.lockQualities.Unlock() } +// GetQuality gets a specific stream quality. +func (s *Stream) GetQuality(name string) (quality *Quality, err error) { + s.lockQualities.Lock() + quality, ok := s.qualities[name] + s.lockQualities.Unlock() + if !ok { + return nil, errors.New("quality does not exist") + } + return quality, nil +} + // ClientCount returns the number of clients. func (s *Stream) ClientCount() int { return s.nbClients