Send stream state paused only when it is paused due to bandwidth limitation. (#1391)

* WIP commit

* Send stream state paused only when it is paused due to bandwidth limitation.

When stream is resumed after a stream is paused, an active update is
sent. Note that this means if there are intervening events like
mute/unmute between pause and resume, resume will be sent.
This commit is contained in:
Raja Subramanian
2023-02-08 20:03:32 +05:30
committed by GitHub
parent 95bc5b9849
commit 8a7478fd0e
5 changed files with 194 additions and 206 deletions
+13 -2
View File
@@ -201,6 +201,9 @@ type DownTrack struct {
// max layer change callback
onSubscribedLayersChanged func(dt *DownTrack, layers VideoLayers)
// target layer found callback
onTargetLayerFound func(dt *DownTrack)
// packet sent callback
onPacketSent []func(dt *DownTrack, size int)
@@ -543,7 +546,7 @@ func (d *DownTrack) WriteRTP(extPkt *buffer.ExtPacket, layer int32) error {
d.onMaxLayerChanged(d, layer)
}
if extPkt.KeyFrame || tp.switchingToTargetLayer {
if extPkt.KeyFrame || tp.isSwitchingToTargetLayer {
d.isNACKThrottled.Store(false)
d.rtpStats.UpdateKeyFrame(1)
@@ -552,8 +555,12 @@ func (d *DownTrack) WriteRTP(extPkt *buffer.ExtPacket, layer int32) error {
d.stopKeyFrameRequester()
}
if !tp.switchingToTargetLayer {
if !tp.isSwitchingToTargetLayer {
d.logger.Debugw("forwarding key frame", "layer", layer)
} else {
if d.onTargetLayerFound != nil {
d.onTargetLayerFound(d)
}
}
}
@@ -910,6 +917,10 @@ func (d *DownTrack) OnSubscribedLayersChanged(fn func(dt *DownTrack, layers Vide
d.onSubscribedLayersChanged = fn
}
func (d *DownTrack) OnTargetLayerFound(fn func(dt *DownTrack)) {
d.onTargetLayerFound = fn
}
func (d *DownTrack) OnPacketSent(fn func(dt *DownTrack, size int)) {
d.onPacketSent = append(d.onPacketSent, fn)
}