Index: webrtc/modules/rtp_rtcp/source/h264/h264_common.h |
diff --git a/webrtc/modules/rtp_rtcp/source/h264/h264_common.h b/webrtc/modules/rtp_rtcp/source/h264/h264_common.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0054db5a44d39acb4baa700d1e41a3a4f64a913e |
--- /dev/null |
+++ b/webrtc/modules/rtp_rtcp/source/h264/h264_common.h |
@@ -0,0 +1,77 @@ |
+/* |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_ |
+#define WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_ |
+ |
+#include <memory> |
+#include <vector> |
+ |
+#include "webrtc/base/common.h" |
+#include "webrtc/base/buffer.h" |
+ |
+namespace webrtc { |
+ |
+class H264Common { |
stefan-webrtc
2016/05/22 23:11:50
Should this be a namespace instead, maybe?
sprang_webrtc
2016/05/25 09:06:02
Done.
|
+ public: |
+ // The size of a full NALU start sequence {0 0 0 1}, used for the first NALU |
+ // of an access unit, and for SPS and PPS blocks. |
+ static const size_t kNaluLongStartSequenceSize; |
+ |
+ // The size of a shortened NALU start sequence {0 0 1}, that may be used if |
+ // not the first NALU of an access unit or an SPS or PPS block. |
+ static const size_t kNaluShortStartSequenceSize; |
+ |
+ // The size of the NALU type byte (1). |
+ static const size_t kNaluTypeSize; |
+ |
+ enum NaluType : uint8_t { |
+ kIdr = 5, |
+ kSei = 6, |
+ kSps = 7, |
+ kPps = 8, |
+ kAud = 9, |
+ kEndOfSequence = 10, |
+ kEndOfStream = 11, |
+ kFiller = 12 |
+ }; |
+ enum SliceType : uint8_t { P = 0, B = 1, I = 2, Sp = 3, Si = 4 }; |
stefan-webrtc
2016/05/22 23:11:50
Empty line above.
You should probably add k befor
sprang_webrtc
2016/05/25 09:06:02
Done.
|
+ |
+ struct NaluIndex { |
+ // Start index of NALU, including start sequence. |
+ size_t start_offset; |
+ // Start index of NALU payload, typically type header. |
+ size_t payload_start_offset; |
+ // Length of NALU payload, in bytes, counting from payload_start_offset. |
+ size_t payload_size; |
+ }; |
+ |
+ // Returns a vector of the NALU indices in the given buffer. |
+ static std::vector<NaluIndex> FindNaluIndices(const uint8_t* buffer, |
+ size_t buffer_size); |
+ |
+ // Get the NAL type from the header byte immediately following start sequence. |
+ static NaluType ParseNaluType(uint8_t data); |
+ |
+ // Parse the given data and remove any emulation byte escaping. |
+ static std::unique_ptr<rtc::Buffer> ParseRbsp(const uint8_t* data, |
+ size_t length); |
+ |
+ // Write the given data to the destination buffer, inserting and emulation |
+ // bytes in order to escape any data the could be interpreted as a start |
+ // sequence. |
+ static void WriteRbsp(const uint8_t* bytes, |
+ size_t length, |
+ rtc::Buffer* destination); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_H264_H264_COMMON_H_ |