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 853b8fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This file is auto generated, using git to list all individuals contributors.
# see `.github/generate-authors.sh` for the scripting
Aaron Boushley <boushley@pretzelaux.com>
adamroach <adam@nostrum.com>
adwpc <adwpc@hotmail.com>
aler9 <46489434+aler9@users.noreply.github.com>
Antoine Baché <antoine.bache@epitech.eu>
Expand Down
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 853b8fc

Please sign in to comment.