Skip to content

Commit

Permalink
Advance Timestamp when empty payload is packetized
Browse files Browse the repository at this point in the history
Curently, the `Packetize` method has a sanity check that the payload
being packetized is not of zero length; if is, then the function returns
without doing anything. This interacts poorly with pion's binding to
OpenH264, which simply returns payloads of zero length when `encode()`
is called but a frame must be skipped for bandwidth limitation reasons.

The most straightforward use of these two APIs with each other leads to
a situation where an application reads an empty payload from OpenH264
and writes it into the Payloader directly. When this happens, the count
of samples is not advanced, leading to incorrect timestamps in the
generated RTP packets (which can cause A/V sync issues).  This change
simply ensures that the Packetizer Timestamp gets updated under such
circumstances.
  • Loading branch information
adamroach committed Jun 24, 2022
1 parent 9a6e1d0 commit 81d731a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packetizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (p *packetizer) EnableAbsSendTime(value int) {
func (p *packetizer) Packetize(payload []byte, samples uint32) []*Packet {
// Guard against an empty payload
if len(payload) == 0 {
p.SkipSamples(samples)
return nil
}

Expand Down

0 comments on commit 81d731a

Please sign in to comment.