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

Side by Side Diff: webrtc/media/base/videoengine_unittest.h

Issue 1821083002: Split ByteBuffer into writer/reader objects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 | « webrtc/media/base/testutils.cc ('k') | webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc » ('j') | 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL); 272 ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL);
273 return pt; 273 return pt;
274 } 274 }
275 static bool ParseRtpPacket(const rtc::CopyOnWriteBuffer* p, 275 static bool ParseRtpPacket(const rtc::CopyOnWriteBuffer* p,
276 bool* x, 276 bool* x,
277 int* pt, 277 int* pt,
278 int* seqnum, 278 int* seqnum,
279 uint32_t* tstamp, 279 uint32_t* tstamp,
280 uint32_t* ssrc, 280 uint32_t* ssrc,
281 std::string* payload) { 281 std::string* payload) {
282 // TODO(jbauch): avoid copying the buffer data into the ByteBuffer 282 rtc::ByteBufferReader buf(p->data<char>(), p->size());
283 rtc::ByteBuffer buf(p->data<char>(), p->size());
284 uint8_t u08 = 0; 283 uint8_t u08 = 0;
285 uint16_t u16 = 0; 284 uint16_t u16 = 0;
286 uint32_t u32 = 0; 285 uint32_t u32 = 0;
287 286
288 // Read X and CC fields. 287 // Read X and CC fields.
289 if (!buf.ReadUInt8(&u08)) return false; 288 if (!buf.ReadUInt8(&u08)) return false;
290 bool extension = ((u08 & 0x10) != 0); 289 bool extension = ((u08 & 0x10) != 0);
291 uint8_t cc = (u08 & 0x0F); 290 uint8_t cc = (u08 & 0x0F);
292 if (x) *x = extension; 291 if (x) *x = extension;
293 292
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return true; 332 return true;
334 } 333 }
335 334
336 // Parse all RTCP packet, from start_index to stop_index, and count how many 335 // Parse all RTCP packet, from start_index to stop_index, and count how many
337 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count 336 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count
338 // and return true. 337 // and return true.
339 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) { 338 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) {
340 int count = 0; 339 int count = 0;
341 for (int i = start_index; i < stop_index; ++i) { 340 for (int i = start_index; i < stop_index; ++i) {
342 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtcpPacket(i)); 341 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtcpPacket(i));
343 // TODO(jbauch): avoid copying the buffer data into the ByteBuffer 342 rtc::ByteBufferReader buf(p->data<char>(), p->size());
344 rtc::ByteBuffer buf(p->data<char>(), p->size());
345 size_t total_len = 0; 343 size_t total_len = 0;
346 // The packet may be a compound RTCP packet. 344 // The packet may be a compound RTCP packet.
347 while (total_len < p->size()) { 345 while (total_len < p->size()) {
348 // Read FMT, type and length. 346 // Read FMT, type and length.
349 uint8_t fmt = 0; 347 uint8_t fmt = 0;
350 uint8_t type = 0; 348 uint8_t type = 0;
351 uint16_t length = 0; 349 uint16_t length = 0;
352 if (!buf.ReadUInt8(&fmt)) return false; 350 if (!buf.ReadUInt8(&fmt)) return false;
353 fmt &= 0x1F; 351 fmt &= 0x1F;
354 if (!buf.ReadUInt8(&type)) return false; 352 if (!buf.ReadUInt8(&type)) return false;
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 std::unique_ptr<C> channel_; 1185 std::unique_ptr<C> channel_;
1188 cricket::FakeNetworkInterface network_interface_; 1186 cricket::FakeNetworkInterface network_interface_;
1189 cricket::FakeVideoRenderer renderer_; 1187 cricket::FakeVideoRenderer renderer_;
1190 cricket::VideoMediaChannel::Error media_error_; 1188 cricket::VideoMediaChannel::Error media_error_;
1191 1189
1192 // Used by test cases where 2 streams are run on the same channel. 1190 // Used by test cases where 2 streams are run on the same channel.
1193 cricket::FakeVideoRenderer renderer2_; 1191 cricket::FakeVideoRenderer renderer2_;
1194 }; 1192 };
1195 1193
1196 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT 1194 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT
OLDNEW
« no previous file with comments | « webrtc/media/base/testutils.cc ('k') | webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698