Line data Source code
1 : /*
2 : * Copyright (c) 2012 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 :
11 : // This file contains codec dependent definitions that are needed in
12 : // order to compile the WebRTC codebase, even if this codec is not used.
13 :
14 : #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_GLOBALS_H_
15 : #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_GLOBALS_H_
16 :
17 : namespace webrtc {
18 :
19 : // The packetization types that we support: single, aggregated, and fragmented.
20 : enum H264PacketizationTypes {
21 : kH264SingleNalu, // This packet contains a single NAL unit.
22 : kH264StapA, // This packet contains STAP-A (single time
23 : // aggregation) packets. If this packet has an
24 : // associated NAL unit type, it'll be for the
25 : // first such aggregated packet.
26 : kH264FuA, // This packet contains a FU-A (fragmentation
27 : // unit) packet, meaning it is a part of a frame
28 : // that was too large to fit into a single packet.
29 : };
30 :
31 : // Packetization modes are defined in RFC 6184 section 6
32 : // Due to the structure containing this being initialized with zeroes
33 : // in some places, and mode 1 being default, mode 1 needs to have the value
34 : // zero. https://crbug.com/webrtc/6803
35 : enum class H264PacketizationMode {
36 : NonInterleaved = 0, // Mode 1 - STAP-A, FU-A is allowed
37 : SingleNalUnit // Mode 0 - only single NALU allowed
38 : };
39 :
40 : // This function is declared inline because it is not clear which
41 : // .cc file it should belong to.
42 : // TODO(hta): Refactor. https://bugs.webrtc.org/6842
43 0 : inline std::ostream& operator<<(std::ostream& stream,
44 : H264PacketizationMode mode) {
45 0 : switch (mode) {
46 : case H264PacketizationMode::NonInterleaved:
47 0 : stream << "NonInterleaved";
48 0 : break;
49 : case H264PacketizationMode::SingleNalUnit:
50 0 : stream << "SingleNalUnit";
51 0 : break;
52 : }
53 0 : return stream;
54 : }
55 :
56 : struct NaluInfo {
57 : uint8_t type;
58 : int sps_id;
59 : int pps_id;
60 :
61 : // Offset and size are only valid for non-FuA packets.
62 : size_t offset;
63 : size_t size;
64 : };
65 :
66 : const size_t kMaxNalusPerPacket = 10;
67 :
68 : struct RTPVideoHeaderH264 {
69 : // The NAL unit type. If this is a header for a
70 : // fragmented packet, it's the NAL unit type of
71 : // the original data. If this is the header for an
72 : // aggregated packet, it's the NAL unit type of
73 : // the first NAL unit in the packet.
74 : uint8_t nalu_type;
75 : // The packetization type of this buffer - single, aggregated or fragmented.
76 : H264PacketizationTypes packetization_type;
77 : NaluInfo nalus[kMaxNalusPerPacket];
78 : size_t nalus_length;
79 : // The packetization mode of this transport. Packetization mode
80 : // determines which packetization types are allowed when packetizing.
81 : H264PacketizationMode packetization_mode;
82 : };
83 :
84 : } // namespace webrtc
85 :
86 : #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_GLOBALS_H_
|