Skip to content

Conversation

@jvary
Copy link

@jvary jvary commented Jul 3, 2022

REQUEST FOR COMMENTS:
H264 spreader : reduces the RTP payload size so 3rd parties RTP sources can be properly redirected over SRTP/WebRTC without IP fragmentation.

High level steps:

  • Passes RTP content straight if possible
    • (if not FUA & not too big)
    • might RtpSeq offset if needed
  • Splits StapA in sub-nals
    • (and then sub-nals in FUA if still too big)
  • Splits StandAlone NAL in FUA
  • Spreads FUA in smaller FUA, carrying 'trailing data' to maximize the size of each FUA nal.
    • (flushing the trailing on RtpSequence discontinuity or change of type)

The steps above handle :

  • RtpSeq offset/adjustment of each packet
  • Rtp Marker 'delay'
  • 'Delay' of FUA 'end' bit if needed.

Advantages vs building whole H264 Frame as you initially proposed:

  • many packets just go through after two 'if'
  • less memory footprint
  • more continuous flow / less data burst
  • RTP sequence holes are 'kept', so it is easier to track quality / packet loss

Future improvement: back-buffer to persist between Process(), to avoid making new buffer for each new returned RTP.

[email protected]

@stv0g stv0g changed the title h264 spreader H264 spreader Apr 18, 2023
@jvary
Copy link
Author

jvary commented Oct 26, 2023

Ok, it looks like there is little interest for this PR/feature, so closing it.

@jvary jvary closed this Oct 26, 2023
@Sean-Der
Copy link
Member

Sean-Der commented Oct 26, 2023

Hi @jvary i would like to take this! I am just very overwhelmed with PRs

@Sean-Der Sean-Der reopened this Oct 26, 2023
@Sean-Der
Copy link
Member

I will review and address all issues myself :)

@jvary
Copy link
Author

jvary commented Oct 26, 2023

Oh! Glad there is interest!
We continued development in-house (and fixed 1-2 bugs as well), so I will update this PR.
@Sean-Der : question : would you rather have the 'interface' dealing with raw slices (as right-now), or have rtp.Packet in input/output ?

@Sean-Der
Copy link
Member

Hey @jvary

Sorry it has been over 3 years O_O but I am going to get this merged! I will fix all the lint errors/etc... and would love your take!

I think this is super valuable to have. Even if only one other person uses it I am so happy to have this code Open Source/available for others to read :)

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 78.23834% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.75%. Comparing base (8c22f58) to head (70bf0aa).

Files with missing lines Patch % Lines
codecs/h264/spreader.go 78.23% 32 Missing and 10 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
- Coverage   91.73%   90.75%   -0.99%     
==========================================
  Files          26       27       +1     
  Lines        2445     2638     +193     
==========================================
+ Hits         2243     2394     +151     
- Misses        140      172      +32     
- Partials       62       72      +10     
Flag Coverage Δ
go 90.75% <78.23%> (-0.99%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants