rtp_packet_h265_common.h (1829B)
1 /* 2 * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H265_COMMON_H_ 11 #define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H265_COMMON_H_ 12 13 #include <cstddef> 14 #include <cstdint> 15 16 namespace webrtc { 17 // The payload header consists of the same 18 // fields (F, Type, LayerId and TID) as the NAL unit header. Refer to 19 // section 4.4 in RFC 7798. 20 constexpr size_t kH265PayloadHeaderSizeBytes = 2; 21 constexpr uint8_t kH265MaxLayerId = 127; 22 constexpr uint8_t kH265MaxTemporalId = 7; 23 // Unlike H.264, H.265 NAL header is 2-bytes. 24 constexpr size_t kH265NalHeaderSizeBytes = 2; 25 // H.265's FU is constructed of 2-byte payload header, 1-byte FU header and FU 26 // payload. 27 constexpr size_t kH265FuHeaderSizeBytes = 1; 28 // The NALU size for H.265 RTP aggregated packet indicates the size of the NAL 29 // unit is 2-bytes. 30 constexpr size_t kH265LengthFieldSizeBytes = 2; 31 constexpr size_t kH265ApHeaderSizeBytes = 32 kH265NalHeaderSizeBytes + kH265LengthFieldSizeBytes; 33 34 // Bit masks for NAL headers. 35 enum NalHdrMasks { 36 kH265FBit = 0x80, 37 kH265TypeMask = 0x7E, 38 kH265LayerIDHMask = 0x1, 39 kH265LayerIDLMask = 0xF8, 40 kH265TIDMask = 0x7, 41 kH265TypeMaskN = 0x81, 42 kH265TypeMaskInFuHeader = 0x3F 43 }; 44 45 // Bit masks for FU headers. 46 enum FuBitmasks { 47 kH265SBitMask = 0x80, 48 kH265EBitMask = 0x40, 49 kH265FuTypeBitMask = 0x3F 50 }; 51 52 constexpr uint8_t kStartCode[] = {0, 0, 0, 1}; 53 54 } // namespace webrtc 55 56 #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H265_COMMON_H_