mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-27 05:28:44 +02:00
Update package srt with Quality structure
This commit is contained in:
@ -25,13 +25,25 @@ func newStream() (s *Stream) {
|
||||
return s
|
||||
}
|
||||
|
||||
// Close stream.
|
||||
func (s *Stream) Close() {
|
||||
for quality := range s.qualities {
|
||||
s.DeleteQuality(quality)
|
||||
}
|
||||
}
|
||||
|
||||
// CreateQuality creates a new quality associated with this stream.
|
||||
func (s *Stream) CreateQuality(name string) (quality *Quality) {
|
||||
func (s *Stream) CreateQuality(name string) (quality *Quality, err error) {
|
||||
// If quality already exist, fail
|
||||
if _, ok := s.qualities[name]; ok {
|
||||
return nil, errors.New("quality already exists")
|
||||
}
|
||||
|
||||
s.lockQualities.Lock()
|
||||
quality = newQuality()
|
||||
s.qualities[name] = quality
|
||||
s.lockQualities.Unlock()
|
||||
return quality
|
||||
return quality, nil
|
||||
}
|
||||
|
||||
// DeleteQuality removes a stream quality.
|
||||
|
@ -91,6 +91,7 @@ func (l *Streams) Delete(name string) {
|
||||
// Make sure we did not already delete this stream
|
||||
l.lockStreams.Lock()
|
||||
if _, ok := l.streams[name]; ok {
|
||||
l.streams[name].Close()
|
||||
delete(l.streams, name)
|
||||
}
|
||||
l.lockStreams.Unlock()
|
||||
|
@ -22,7 +22,10 @@ func TestWithOneStream(t *testing.T) {
|
||||
}
|
||||
|
||||
// Create a quality
|
||||
quality := stream.CreateQuality("source")
|
||||
quality, err := stream.CreateQuality("source")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create quality")
|
||||
}
|
||||
|
||||
// Register one output
|
||||
output := make(chan []byte, 64)
|
||||
|
Reference in New Issue
Block a user