pion / rtp

A Go implementation of RTP
https://pion.ly/
MIT License
363 stars 112 forks source link

Advance Timestamp when empty payload is packetized #192

Open adamroach opened 2 years ago

adamroach commented 2 years ago

Description

Currently, 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.

codecov[bot] commented 2 years ago

Codecov Report

Merging #192 (853b8fc) into master (9a6e1d0) will decrease coverage by 0.04%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
- Coverage   87.36%   87.31%   -0.05%     
==========================================
  Files          18       18              
  Lines        1773     1774       +1     
==========================================
  Hits         1549     1549              
- Misses        195      196       +1     
  Partials       29       29              
Flag Coverage Δ
go 87.31% <0.00%> (-0.05%) :arrow_down:
wasm 86.30% <0.00%> (-0.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packetizer.go 77.35% <0.00%> (-1.49%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9a6e1d0...853b8fc. Read the comment docs.