Keep simulcast information tied to receiver. (#3563)

* Keep simulcast information tied to receiver.

`simulcast` flag in `TrackInfo` is at track lavel. With codec simulcast,
the primary codec (in most cases) is SVC and the backup codec is
simulcast. Back up codec publish changing the track info setting to true
meant that the primary receiver was treated as simulcast if a subscriber
for primary codec joined after the backup codec was published.

Keep track of simulcast flag in receiver.

Also, TrackInfo Cids are from signal. So, keep track of SDP cids
separately. The `simulcastTrackIds` map uses SDP cid. Clean up by all
the SDP cids of a track

* clean up

* clean up

* clean up

* clean up

* test

* Store SdpCid and IsSimulcast in Trackinfo

* clean up

* mock
This commit is contained in:
Raja Subramanian
2025-03-31 19:25:57 +05:30
committed by GitHub
parent ad010cfc43
commit ed5e2f16b2
17 changed files with 393 additions and 188 deletions
+7 -6
View File
@@ -223,7 +223,6 @@ type Forwarder struct {
started bool
preStartTime time.Time
isReceiverSimulcast bool
extFirstTS uint64
lastSSRC uint32
lastReferencePayloadType int8
@@ -249,7 +248,6 @@ func NewForwarder(
logger logger.Logger,
skipReferenceTS bool,
rtpStats *rtpstats.RTPStatsSender,
isReceiverSimulcast bool,
) *Forwarder {
f := &Forwarder{
mime: mime.MimeTypeUnknown,
@@ -257,7 +255,6 @@ func NewForwarder(
logger: logger,
skipReferenceTS: skipReferenceTS,
rtpStats: rtpStats,
isReceiverSimulcast: isReceiverSimulcast,
referenceLayerSpatial: buffer.InvalidLayerSpatial,
lastAllocation: VideoAllocationDefault,
lastReferencePayloadType: -1,
@@ -300,7 +297,11 @@ func (f *Forwarder) SetMaxTemporalLayerSeen(maxTemporalLayerSeen int32) bool {
return true
}
func (f *Forwarder) DetermineCodec(codec webrtc.RTPCodecCapability, extensions []webrtc.RTPHeaderExtensionParameter) {
func (f *Forwarder) DetermineCodec(
codec webrtc.RTPCodecCapability,
extensions []webrtc.RTPHeaderExtensionParameter,
isReceiverSimulcast bool,
) {
f.lock.Lock()
defer f.lock.Unlock()
@@ -343,7 +344,7 @@ func (f *Forwarder) DetermineCodec(codec webrtc.RTPCodecCapability, extensions [
}
case mime.MimeTypeVP9:
if f.isReceiverSimulcast {
if isReceiverSimulcast {
f.logger.Debugw("selecting simulcast video layer selector for VP9")
if f.vls != nil {
f.vls = videolayerselector.NewSimulcastFromOther(f.vls)
@@ -372,7 +373,7 @@ func (f *Forwarder) DetermineCodec(codec webrtc.RTPCodecCapability, extensions [
case mime.MimeTypeAV1:
isDDAvailable := ddAvailable(extensions)
if f.isReceiverSimulcast || !isDDAvailable {
if isReceiverSimulcast || !isDDAvailable {
// AV1-SIMULCAST-TODO: Add temporal layer selector for AV1
f.logger.Debugw("selecting simulcast video layer selector for AV1")
if f.vls != nil {