Increment RTP timestamp on padding when using dummy start. (#3989)

* Increment RTP timestamp on padding when using dummy start.

This allows things like egress to have proper sequence to start
the pipeline.

* test
This commit is contained in:
Raja Subramanian
2025-10-07 23:39:51 +05:30
committed by GitHub
parent 4f6ed65d61
commit 158496bca1
4 changed files with 33 additions and 8 deletions
+9 -2
View File
@@ -88,6 +88,7 @@ const (
waitBeforeSendPaddingOnMute = 100 * time.Millisecond
maxPaddingOnMuteDuration = 5 * time.Second
paddingOnMuteInterval = 100 * time.Millisecond
)
// -------------------------------------------------------------------
@@ -1158,7 +1159,14 @@ func (d *DownTrack) WritePaddingRTP(bytesToSend int, paddingOnMute bool, forceMa
return 0
}
snts, err := d.forwarder.GetSnTsForPadding(num, forceMarker)
frameRate := uint32(0)
if paddingOnMute {
// advance timestamps when sending dummy padding packets to start a stream
// to ensure receiver sees proper timestamp and starts the stream
frameRate = uint32(time.Second / paddingOnMuteInterval)
}
snts, err := d.forwarder.GetSnTsForPadding(num, frameRate, forceMarker)
if err != nil {
return 0
}
@@ -2391,7 +2399,6 @@ func (d *DownTrack) sendPaddingOnMute() {
// let uptrack have chance to send packet before we send padding
time.Sleep(waitBeforeSendPaddingOnMute)
paddingOnMuteInterval := 100 * time.Millisecond
numPackets := maxPaddingOnMuteDuration / paddingOnMuteInterval
for i := 0; i < int(numPackets); i++ {
if d.rtpStats.IsActive() || d.IsClosed() {