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;