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

Side by Side Diff: webrtc/modules/include/module_common_types.h

Issue 3002283002: Implement move constructor for RTPFragmentationHeader. (Closed)
Patch Set: Address comments. 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 class RTPFragmentationHeader { 85 class RTPFragmentationHeader {
86 public: 86 public:
87 RTPFragmentationHeader() 87 RTPFragmentationHeader()
88 : fragmentationVectorSize(0), 88 : fragmentationVectorSize(0),
89 fragmentationOffset(NULL), 89 fragmentationOffset(NULL),
90 fragmentationLength(NULL), 90 fragmentationLength(NULL),
91 fragmentationTimeDiff(NULL), 91 fragmentationTimeDiff(NULL),
92 fragmentationPlType(NULL) {} 92 fragmentationPlType(NULL) {}
93 93
94 RTPFragmentationHeader(RTPFragmentationHeader&& other)
95 : RTPFragmentationHeader() {
96 swap(other);
97 }
98
94 ~RTPFragmentationHeader() { 99 ~RTPFragmentationHeader() {
95 delete[] fragmentationOffset; 100 delete[] fragmentationOffset;
96 delete[] fragmentationLength; 101 delete[] fragmentationLength;
97 delete[] fragmentationTimeDiff; 102 delete[] fragmentationTimeDiff;
98 delete[] fragmentationPlType; 103 delete[] fragmentationPlType;
99 } 104 }
100 105
106 void operator=(RTPFragmentationHeader&& other) { swap(other); }
107
101 void CopyFrom(const RTPFragmentationHeader& src) { 108 void CopyFrom(const RTPFragmentationHeader& src) {
102 if (this == &src) { 109 if (this == &src) {
103 return; 110 return;
104 } 111 }
105 112
106 if (src.fragmentationVectorSize != fragmentationVectorSize) { 113 if (src.fragmentationVectorSize != fragmentationVectorSize) {
107 // new size of vectors 114 // new size of vectors
108 115
109 // delete old 116 // delete old
110 delete[] fragmentationOffset; 117 delete[] fragmentationOffset;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 uint16_t fragmentationVectorSize; // Number of fragmentations 216 uint16_t fragmentationVectorSize; // Number of fragmentations
210 size_t* fragmentationOffset; // Offset of pointer to data for each 217 size_t* fragmentationOffset; // Offset of pointer to data for each
211 // fragmentation 218 // fragmentation
212 size_t* fragmentationLength; // Data size for each fragmentation 219 size_t* fragmentationLength; // Data size for each fragmentation
213 uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for 220 uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for
214 // each fragmentation 221 // each fragmentation
215 uint8_t* fragmentationPlType; // Payload type of each fragmentation 222 uint8_t* fragmentationPlType; // Payload type of each fragmentation
216 223
217 private: 224 private:
218 RTC_DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader); 225 RTC_DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader);
226
227 void swap(RTPFragmentationHeader& other) {
228 std::swap(fragmentationVectorSize, other.fragmentationVectorSize);
229 std::swap(fragmentationOffset, other.fragmentationOffset);
230 std::swap(fragmentationLength, other.fragmentationLength);
231 std::swap(fragmentationTimeDiff, other.fragmentationTimeDiff);
232 std::swap(fragmentationPlType, other.fragmentationPlType);
233 }
kwiberg-webrtc 2017/08/28 08:36:20 To make this useful with the standard swapping idi
sakal 2017/08/28 09:29:27 Done.
219 }; 234 };
220 235
221 struct RTCPVoIPMetric { 236 struct RTCPVoIPMetric {
222 // RFC 3611 4.7 237 // RFC 3611 4.7
223 uint8_t lossRate; 238 uint8_t lossRate;
224 uint8_t discardRate; 239 uint8_t discardRate;
225 uint8_t burstDensity; 240 uint8_t burstDensity;
226 uint8_t gapDensity; 241 uint8_t gapDensity;
227 uint16_t burstDuration; 242 uint16_t burstDuration;
228 uint16_t gapDuration; 243 uint16_t gapDuration;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 static constexpr int kNotAProbe = -1; 637 static constexpr int kNotAProbe = -1;
623 int send_bitrate_bps = -1; 638 int send_bitrate_bps = -1;
624 int probe_cluster_id = kNotAProbe; 639 int probe_cluster_id = kNotAProbe;
625 int probe_cluster_min_probes = -1; 640 int probe_cluster_min_probes = -1;
626 int probe_cluster_min_bytes = -1; 641 int probe_cluster_min_bytes = -1;
627 }; 642 };
628 643
629 } // namespace webrtc 644 } // namespace webrtc
630 645
631 #endif // WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ 646 #endif // WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_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