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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.h

Issue 3013023004: Make rtp::Packet's destructor and constructors public (Closed)
Patch Set: Created 3 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_
(...skipping 12 matching lines...) Expand all
23 23
24 namespace rtp { 24 namespace rtp {
25 class Packet { 25 class Packet {
26 public: 26 public:
27 using ExtensionType = RTPExtensionType; 27 using ExtensionType = RTPExtensionType;
28 using ExtensionManager = RtpHeaderExtensionMap; 28 using ExtensionManager = RtpHeaderExtensionMap;
29 static constexpr size_t kMaxExtensionHeaders = 14; 29 static constexpr size_t kMaxExtensionHeaders = 14;
30 static constexpr int kMinExtensionId = 1; 30 static constexpr int kMinExtensionId = 1;
31 static constexpr int kMaxExtensionId = 14; 31 static constexpr int kMaxExtensionId = 14;
32 32
33 // |extensions| required for SetExtension/ReserveExtension functions during
34 // packet creating and used if available in Parse function.
35 // Adding and getting extensions will fail until |extensions| is
36 // provided via constructor or IdentifyExtensions function.
37 Packet();
38 explicit Packet(const ExtensionManager* extensions);
39 Packet(const Packet&);
40 Packet(const ExtensionManager* extensions, size_t capacity);
41 ~Packet();
42
43 Packet& operator=(const Packet&) = default;
44
33 // Parse and copy given buffer into Packet. 45 // Parse and copy given buffer into Packet.
34 bool Parse(const uint8_t* buffer, size_t size); 46 bool Parse(const uint8_t* buffer, size_t size);
35 bool Parse(rtc::ArrayView<const uint8_t> packet); 47 bool Parse(rtc::ArrayView<const uint8_t> packet);
36 48
37 // Parse and move given buffer into Packet. 49 // Parse and move given buffer into Packet.
38 bool Parse(rtc::CopyOnWriteBuffer packet); 50 bool Parse(rtc::CopyOnWriteBuffer packet);
39 51
40 // Maps extensions id to their types. 52 // Maps extensions id to their types.
41 void IdentifyExtensions(const ExtensionManager& extensions); 53 void IdentifyExtensions(const ExtensionManager& extensions);
42 54
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Allocates and returns place to store rtp header extension. 118 // Allocates and returns place to store rtp header extension.
107 // Returns empty arrayview on failure. 119 // Returns empty arrayview on failure.
108 rtc::ArrayView<uint8_t> AllocateRawExtension(int id, size_t length); 120 rtc::ArrayView<uint8_t> AllocateRawExtension(int id, size_t length);
109 121
110 // Reserve size_bytes for payload. Returns nullptr on failure. 122 // Reserve size_bytes for payload. Returns nullptr on failure.
111 uint8_t* SetPayloadSize(size_t size_bytes); 123 uint8_t* SetPayloadSize(size_t size_bytes);
112 // Same as SetPayloadSize but doesn't guarantee to keep current payload. 124 // Same as SetPayloadSize but doesn't guarantee to keep current payload.
113 uint8_t* AllocatePayload(size_t size_bytes); 125 uint8_t* AllocatePayload(size_t size_bytes);
114 bool SetPadding(uint8_t size_bytes, Random* random); 126 bool SetPadding(uint8_t size_bytes, Random* random);
115 127
116 protected:
117 // |extensions| required for SetExtension/ReserveExtension functions during
118 // packet creating and used if available in Parse function.
119 // Adding and getting extensions will fail until |extensions| is
120 // provided via constructor or IdentifyExtensions function.
121 Packet();
122 explicit Packet(const ExtensionManager* extensions);
123 Packet(const Packet&);
124 Packet(const ExtensionManager* extensions, size_t capacity);
125 ~Packet();
126
127 Packet& operator=(const Packet&) = default;
128
129 private: 128 private:
130 struct ExtensionInfo { 129 struct ExtensionInfo {
131 ExtensionType type; 130 ExtensionType type;
132 uint16_t offset; 131 uint16_t offset;
133 uint8_t length; 132 uint8_t length;
134 }; 133 };
135 134
136 // Helper function for Parse. Fill header fields using data in given buffer, 135 // Helper function for Parse. Fill header fields using data in given buffer,
137 // but does not touch packet own buffer, leaving packet in invalid state. 136 // but does not touch packet own buffer, leaving packet in invalid state.
138 bool ParseBuffer(const uint8_t* buffer, size_t size); 137 bool ParseBuffer(const uint8_t* buffer, size_t size);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes); 191 auto buffer = AllocateExtension(Extension::kId, Extension::kValueSizeBytes);
193 if (buffer.empty()) 192 if (buffer.empty())
194 return false; 193 return false;
195 memset(buffer.data(), 0, Extension::kValueSizeBytes); 194 memset(buffer.data(), 0, Extension::kValueSizeBytes);
196 return true; 195 return true;
197 } 196 }
198 } // namespace rtp 197 } // namespace rtp
199 } // namespace webrtc 198 } // namespace webrtc
200 199
201 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ 200 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698