Add method to get quality

This commit is contained in:
Alexandre Iooss 2020-10-19 19:28:04 +02:00
parent f825d3d513
commit bb589a71ce
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
package messaging package messaging
import ( import (
"errors"
"sync" "sync"
) )
@ -33,7 +34,7 @@ func (s *Stream) CreateQuality(name string) (quality *Quality) {
return quality return quality
} }
// DeleteQuality removes a quality. // DeleteQuality removes a stream quality.
func (s *Stream) DeleteQuality(name string) { func (s *Stream) DeleteQuality(name string) {
// Make sure we did not already close this output // Make sure we did not already close this output
s.lockQualities.Lock() s.lockQualities.Lock()
@ -44,6 +45,17 @@ func (s *Stream) DeleteQuality(name string) {
s.lockQualities.Unlock() 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. // ClientCount returns the number of clients.
func (s *Stream) ClientCount() int { func (s *Stream) ClientCount() int {
return s.nbClients return s.nbClients