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 <ssilkin@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41768}
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
index d2646e8..cea5507 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 @@
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<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
// Skip the single NALU header (payload header), aggregated packet case will
@@ -122,6 +128,10 @@
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 @@
return parsed_payload;
}
+// Fragmentation Unit (FU) structure:
+// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3
absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
if (rtp_payload.size() < kH265FuHeaderSizeBytes + kH265NalHeaderSizeBytes) {
@@ -204,6 +216,8 @@
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;