mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Rework selection of simulcast tracks.
We used to hard-wire the rid identifiers. We now assume that the simulcast streams are ordered in decreasing order of quality.
This commit is contained in:
parent
ea7142ca9a
commit
c501b76d2b
2 changed files with 34 additions and 42 deletions
|
@ -232,9 +232,11 @@ a JSEP session description). Galène will interpret the `nack`,
|
||||||
accordingly.
|
accordingly.
|
||||||
|
|
||||||
The sender may either send a single stream per media section in the SDP,
|
The sender may either send a single stream per media section in the SDP,
|
||||||
or use rid-based simulcasting. In the latter case, it should send two
|
or use rid-based simulcasting with the streams ordered in decreasing order
|
||||||
video streams, one with rid 'h' and high throughput, and one with rid 'l'
|
of throughput. In that case, it should send two video streams, the
|
||||||
and throughput limited to roughly 100kbit/s.
|
first one with high throughput, and the second one with throughput limited
|
||||||
|
to roughly 100kbit/s. If more than two streams are sent, then only the
|
||||||
|
first and the last one will be considered.
|
||||||
|
|
||||||
The receiver may either abort the stream immediately (see below), or send
|
The receiver may either abort the stream immediately (see below), or send
|
||||||
an answer.
|
an answer.
|
||||||
|
|
|
@ -743,21 +743,12 @@ func requestConns(target group.Client, g *group.Group, id string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestedTracks(c *webClient, override []string, up conn.Up, tracks []conn.UpTrack) ([]conn.UpTrack, bool) {
|
func requestedTracks(c *webClient, requested []string, tracks []conn.UpTrack) ([]conn.UpTrack, bool) {
|
||||||
r := override
|
if len(requested) == 0 {
|
||||||
if r == nil {
|
|
||||||
var ok bool
|
|
||||||
r, ok = c.requested[up.Label()]
|
|
||||||
if !ok {
|
|
||||||
r, ok = c.requested[""]
|
|
||||||
}
|
|
||||||
if !ok || len(r) == 0 {
|
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var audio, video, videoLow bool
|
var audio, video, videoLow bool
|
||||||
for _, s := range r {
|
for _, s := range requested {
|
||||||
switch s {
|
switch s {
|
||||||
case "audio":
|
case "audio":
|
||||||
audio = true
|
audio = true
|
||||||
|
@ -770,50 +761,42 @@ func requestedTracks(c *webClient, override []string, up conn.Up, tracks []conn.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
find := func(kind webrtc.RTPCodecType, labels ...string) conn.UpTrack {
|
find := func(kind webrtc.RTPCodecType, last bool) (conn.UpTrack, int) {
|
||||||
for _, l := range labels {
|
var track conn.UpTrack
|
||||||
|
count := 0
|
||||||
for _, t := range tracks {
|
for _, t := range tracks {
|
||||||
if t.Kind() != kind {
|
if t.Kind() != kind {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if t.Label() == l {
|
track = t
|
||||||
return t
|
count++
|
||||||
|
if !last {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return track, count
|
||||||
for _, t := range tracks {
|
|
||||||
if t.Kind() != kind {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ts []conn.UpTrack
|
var ts []conn.UpTrack
|
||||||
limitSid := false
|
limitSid := false
|
||||||
if audio {
|
if audio {
|
||||||
t := find(webrtc.RTPCodecTypeAudio)
|
t, _ := find(webrtc.RTPCodecTypeAudio, false)
|
||||||
if t != nil {
|
if t != nil {
|
||||||
ts = append(ts, t)
|
ts = append(ts, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if video {
|
if video {
|
||||||
t := find(
|
t, _ := find(webrtc.RTPCodecTypeVideo, false)
|
||||||
webrtc.RTPCodecTypeVideo, "h", "m", "video",
|
|
||||||
)
|
|
||||||
if t != nil {
|
if t != nil {
|
||||||
ts = append(ts, t)
|
ts = append(ts, t)
|
||||||
}
|
}
|
||||||
} else if videoLow {
|
} else if videoLow {
|
||||||
t := find(
|
t, count := find(webrtc.RTPCodecTypeVideo, true)
|
||||||
webrtc.RTPCodecTypeVideo, "l", "m", "video",
|
|
||||||
)
|
|
||||||
if t != nil {
|
if t != nil {
|
||||||
ts = append(ts, t)
|
ts = append(ts, t)
|
||||||
if t.Label() != "l" {
|
|
||||||
limitSid = true
|
|
||||||
}
|
}
|
||||||
|
if count < 2 {
|
||||||
|
limitSid = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,11 +1036,18 @@ func pushDownConn(c *webClient, id string, up conn.Up, tracks []conn.UpTrack, re
|
||||||
} else {
|
} else {
|
||||||
old = getDownConn(c, up.Id())
|
old = getDownConn(c, up.Id())
|
||||||
}
|
}
|
||||||
var override []string
|
var req []string
|
||||||
if old != nil {
|
if old != nil {
|
||||||
override = old.requested
|
req = old.requested
|
||||||
}
|
}
|
||||||
requested, limitSid = requestedTracks(c, override, up, tracks)
|
if req == nil {
|
||||||
|
var ok bool
|
||||||
|
req, ok = c.requested[up.Label()]
|
||||||
|
if !ok {
|
||||||
|
req = c.requested[""]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requested, limitSid = requestedTracks(c, req, tracks)
|
||||||
}
|
}
|
||||||
|
|
||||||
if replace != "" {
|
if replace != "" {
|
||||||
|
|
Loading…
Reference in a new issue