Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h

Issue 1211353002: Integration of VP9 packetization. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: refactor and remove test helper class Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h b/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ed0d4af3607b062e16f4a516118a9386a9b5c0a
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/*
+ * This file contains the declaration of the VP9 packetizer class.
+ * A packetizer object is created for each encoded video frame. The
+ * constructor is called with the payload data and size.
+ *
+ * After creating the packetizer, the method NextPacket is called
+ * repeatedly to get all packets for the frame. The method returns
+ * false as long as there are more packets left to fetch.
+ */
+
+#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_
+#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_
+
+#include <queue>
+#include <string>
+#include <vector>
+
+#include "webrtc/base/constructormagic.h"
+#include "webrtc/modules/interface/module_common_types.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
+#include "webrtc/typedefs.h"
+
+namespace webrtc {
+
+// Packetizer for VP9.
+class RtpPacketizerVp9 : public RtpPacketizer {
+ public:
+ // Initialize without fragmentation info. Mode kEqualSize will be used.
+ // The payload_data must be exactly one encoded VP9 frame.
+ RtpPacketizerVp9(const RTPVideoHeaderVP9& hdr, size_t max_payload_len);
+
+ virtual ~RtpPacketizerVp9();
+
+ void SetPayloadData(const uint8_t* payload_data,
+ size_t payload_size,
+ const RTPFragmentationHeader* fragmentation) override;
+
+ // Get the next payload with VP9 payload header.
+ // |buffer| is a pointer to where the output will be written.
+ // |bytes_to_send| is an output variable that will contain number of bytes
+ // written to buffer. Parameter |last_packet| is true for the last packet of
+ // the frame, false otherwise (i.e. call the function again to get the
+ // next packet).
+ // Returns true on success, false otherwise.
+ bool NextPacket(uint8_t* buffer,
+ size_t* bytes_to_send,
+ bool* last_packet) override;
+
+ ProtectionType GetProtectionType() override;
+
+ StorageType GetStorageType(uint32_t retransmission_settings) override;
+
+ std::string ToString() override;
+
+ typedef struct {
+ size_t payload_start_pos;
+ size_t size;
+ bool layer_begin;
+ bool layer_end;
+ } InfoStruct;
+ typedef std::queue<InfoStruct> InfoQueue;
+
+ private:
+ // Calculate size of next chunk to send. Returns 0 if none can be sent.
+ size_t CalcNextSize(size_t max_payload_len, size_t remaining_bytes) const;
+
+ // Calculate all packet sizes and load to packet info queue.
+ void GeneratePackets();
+
+ // Write the payload header and copy the payload to the |buffer|.
+ // |packet_info| determines which part of the payload to write.
+ // |bytes_to_send| contains the number of written bytes to the buffer.
+ // Returns true on success, false otherwise.
+ bool WriteHeaderAndPayload(const InfoStruct& packet_info,
+ uint8_t* buffer,
+ size_t* bytes_to_send) const;
+
+ // Write payload descriptor to |buffer|.
+ // Returns true on success, false otherwise.
+ bool WriteHeader(const InfoStruct& packet_info,
+ uint8_t* buffer,
+ size_t* extension_length) const;
+
+ const uint8_t* payload_data_;
+ size_t payload_size_;
+ const bool balance_;
+ const RTPVideoHeaderVP9 hdr_;
+ const size_t max_payload_len_;
+ InfoQueue packets_;
+
+ DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9);
+};
+
+// Depacketizer for VP9.
+class RtpDepacketizerVp9 : public RtpDepacketizer {
+ public:
+ virtual ~RtpDepacketizerVp9() {}
+
+ bool Parse(ParsedPayload* parsed_payload,
+ const uint8_t* payload_data,
+ size_t payload_data_length) override;
+};
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP9_H_

Powered by Google App Engine
This is Rietveld 408576698