-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add H265RtpDepacketizer #1134
Add H265RtpDepacketizer #1134
Conversation
By the way, producing access units rather than NALUs seems to be what FFmpeg's H265 RTP depacketizer does. It's kind of awkward to set up, though! Some open items:
|
aba246f
to
1c13f41
Compare
Agree on NALU API being awkward! do you have bandwidth to update H264 depacketizer I can test + approve? We should make that change ASAP before people depend on it. or maybe this is controlled via constructor |
Yeah, I should be able to take a look later today. |
1c13f41
to
954d962
Compare
I think you are right, it corresponds better to what the user would expect the callback to do. Additionally, it makes the API more symmetrical with packetizers.
This is the most common, but a short start sequence { 0x00, 0x00, 0x01 } also exists. Packetizers have an
Yes it should be, but I can do it in a second time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding, I have only a couple comments and suggestions.
954d962
to
a0e2e06
Compare
a0e2e06
to
ee96c7a
Compare
Re-based on master, added fix for empty RTP packet payloads, made the start sequence configurable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it looks good, feel free to add you name in new files headers.
ee96c7a
to
710023d
Compare
Done. |
@edmonds Sorry, you need to make a couple changes after rebasing as FrameInfo now requires the payload type after #1156 was merged. |
OK, no problem. Should be able to take a look in a couple days. |
This would need a fix similar to #1167 to properly handle multiple NAL units. |
This commit adds an H265 depacketizer which takes incoming H265 RTP packets and emits H265 access units. It is closely based on the `H264RtpDepacketizer` added by @Sean-Der in paullouisageneau#1082. I originally started with a version of this commit that was closer to the `H264RtpDepacketizer` and which emitted individual H265 NALUs in `H265RtpDepacketizer::buildFrames()`. This resulted in calling my `Track::onFrame()` callback for each NALU, which did not work well with the decoder that I'm using which wants to see the VPS/SPS/PPS NALUs as a unit before initializing the decoder (https://intel.github.io/libvpl/v2.10/API_ref/VPL_func_vid_decode.html#mfxvideodecode-decodeheader). So for the `H265RtpDepacketizer` I've tried to make it emit access units rather than NALUs. An "access unit" is (RFC 7798): > A set of NAL units that are associated with each other according to a specified classification rule, that are consecutive in decoding order, *and that contain exactly one coded picture.* "Exactly one coded picture" seems to correspond with what a caller might expect an "onFrame" callback to do. Maybe the `H264RtpDepacketizer` should be revised to similarly emit H264 access units rather than NALUs, too. At least, I could not find a way to receive individual NALUs from the depacketizer and run the VPL decoder without needing to do my own buffering/copying of the NALUs. With this commit I can now do the following: * Generate encoded bitstream output from the Intel VPL encoder. * Pass the output of the encoder one frame at a time to libdatachannel's `Track::send()` on a track with an `H265RtpPacketizer` media handler. * Transport the video track over a WebRTC connection to a libdatachannel peer. * Depacketize it with the `H265RtpDepacketizer` media handler in this commit. * Pass the depacketized output via my `Track::onFrame()` callback to the Intel VPL decoder in "complete frame" mode (https://intel.github.io/libvpl/v2.10/API_ref/VPL_enums.html#_CPPv428MFX_BITSTREAM_COMPLETE_FRAME). Each "onFrame" callback corresponds to a single call to the decoder API to decode a frame.
Similar to the fix for the H.264 RTP depacketizer in https://github.com/ paullouisageneau/pull/1140.
Per PR review feedback, add a parameter to the constructor for configuring the start sequence to use when writing NALUs.
Needed for std::remove_if.
This follows the API change in paullouisageneau#1156 and is based on the very similar change to H264RtpDepacketizer (commit e9060bf).
Based on the fix for H264RtpDepacketizer in paullouisageneau#1167 (commit 4fc4e9b).
710023d
to
3dc1a17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you for the work!
This commit adds an H265 depacketizer which takes incoming H265 RTP packets and emits H265 access units. It is closely based on the
H264RtpDepacketizer
added by @Sean-Der in #1082.I originally started with a version of this commit that was closer to the
H264RtpDepacketizer
and which emitted individual H265 NALUs inH265RtpDepacketizer::buildFrames()
. This resulted in calling myTrack::onFrame()
callback for each NALU, which did not work well with the decoder that I'm using which wants to see the VPS/SPS/PPS NALUs as a unit before initializing the decoder (https://intel.github.io/libvpl/v2.10/API_ref/VPL_func_vid_decode.html#mfxvideodecode-decodeheader).So for the
H265RtpDepacketizer
I've tried to make it emit access units rather than NALUs. An "access unit" is (RFC 7798):"Exactly one coded picture" seems to correspond with what a caller might expect an "onFrame" callback to do. Maybe the
H264RtpDepacketizer
should be revised to similarly emit H264 access units rather than NALUs, too. At least, I could not find a way to receive individual NALUs from the depacketizer and run the VPL decoder without needing to do my own buffering/copying of the NALUs.With this commit I can now do the following:
Track::send()
on a track with anH265RtpPacketizer
media handler.H265RtpDepacketizer
media handler in this commit.Track::onFrame()
callback to the Intel VPL decoder in "complete frame" mode (https://intel.github.io/libvpl/v2.10/API_ref/VPL_enums.html#_CPPv428MFX_BITSTREAM_COMPLETE_FRAME). Each "onFrame" callback corresponds to a single call to the decoder API to decode a frame.