1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-30 04:21:07 +02:00

WebRTC offers multiple quality

This commit is contained in:
Yohann D'ANELLO
2020-10-29 00:10:25 +01:00
parent 9e7e1ec0b8
commit 86dac0f929
7 changed files with 121 additions and 88 deletions

View File

@ -10,6 +10,12 @@ import (
// Quality holds a specific stream quality.
// It makes packages able to subscribe to an incoming stream.
type Quality struct {
// Type of the quality
Name string
// Source Stream
Stream *Stream
// Incoming data come from this channel
Broadcast chan<- []byte
@ -27,8 +33,9 @@ type Quality struct {
WebRtcRemoteSdp chan webrtc.SessionDescription
}
func newQuality() (q *Quality) {
q = &Quality{}
func newQuality(name string, stream *Stream) (q *Quality) {
q = &Quality{Name: name}
q.Stream = stream
broadcast := make(chan []byte, 1024)
q.Broadcast = broadcast
q.outputs = make(map[chan []byte]struct{})

View File

@ -40,7 +40,7 @@ func (s *Stream) CreateQuality(name string) (quality *Quality, err error) {
}
s.lockQualities.Lock()
quality = newQuality()
quality = newQuality(name, s)
s.qualities[name] = quality
s.lockQualities.Unlock()
return quality, nil