From 41c44cde417e82efb1fd9162e11c068d643537af Mon Sep 17 00:00:00 2001 From: Jianjun Zhu Date: Tue, 20 Feb 2024 10:05:34 +0800 Subject: [PATCH] Add some comments for H265 RTP depacketizer. This CL helps readers to understand which part of the spec VideoRtpDepacketizerH265 implements. Bug: webrtc:13485 Change-Id: Ie78a6ce781e6af559d59b1b07ce2854115368a86 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340008 Reviewed-by: Sergey Silkin Reviewed-by: Danil Chapovalov Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#41768} --- .../rtp_rtcp/source/video_rtp_depacketizer_h265.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc index d2646e82da..cea55078e5 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc @@ -29,6 +29,8 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" +// RTP Payload Format for HEVC: https://datatracker.ietf.org/doc/html/rfc7798 + namespace webrtc { namespace { @@ -55,6 +57,10 @@ bool ParseApStartOffsets(const uint8_t* nalu_ptr, return true; } +// Single NALU packet structure +// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.1 +// Aggregation Packet (AP) strcture +// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2 absl::optional ProcessApOrSingleNalu( rtc::CopyOnWriteBuffer rtp_payload) { // Skip the single NALU header (payload header), aggregated packet case will @@ -122,6 +128,10 @@ absl::optional ProcessApOrSingleNalu( case H265::NaluType::kIdrNLp: case H265::NaluType::kCra: case H265::NaluType::kRsvIrapVcl23: + // Mark IRAP(Intra Random Access Point) frames as key frames. Their NALU + // types are in the range of BLA_W_LP (16) to RSV_IRAP_VCL23 (23), + // inclusive. + // https://datatracker.ietf.org/doc/html/rfc7798#section-3.1.1 parsed_payload->video_header.frame_type = VideoFrameType::kVideoFrameKey; ABSL_FALLTHROUGH_INTENDED; @@ -170,6 +180,8 @@ absl::optional ProcessApOrSingleNalu( return parsed_payload; } +// Fragmentation Unit (FU) structure: +// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3 absl::optional ParseFuNalu( rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() < kH265FuHeaderSizeBytes + kH265NalHeaderSizeBytes) { @@ -204,6 +216,8 @@ absl::optional ParseFuNalu( if (original_nal_type >= H265::NaluType::kBlaWLp && original_nal_type <= H265::NaluType::kRsvIrapVcl23) { + // IRAP picture. + // https://datatracker.ietf.org/doc/html/rfc7798#section-3.1.1 parsed_payload->video_header.frame_type = VideoFrameType::kVideoFrameKey; } else { parsed_payload->video_header.frame_type = VideoFrameType::kVideoFrameDelta;