1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 16:12:19 +00:00

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

View File

@ -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