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

Side by Side Diff: webrtc/modules/video_coding/test/rtp_player.cc

Issue 1965063003: Revert of Remove webrtc/base/scoped_ptr.h (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
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
11 #include "webrtc/modules/video_coding/test/rtp_player.h" 11 #include "webrtc/modules/video_coding/test/rtp_player.h"
12 12
13 #include <stdio.h> 13 #include <stdio.h>
14 14
15 #include <cstdlib>
16 #include <map> 15 #include <map>
17 #include <memory> 16 #include <memory>
18 17
19 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
24 #include "webrtc/modules/video_coding/internal_defines.h" 23 #include "webrtc/modules/video_coding/internal_defines.h"
25 #include "webrtc/modules/video_coding/test/test_util.h" 24 #include "webrtc/modules/video_coding/test/test_util.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 lost_packets_(clock, rtt_ms), 335 lost_packets_(clock, rtt_ms),
337 resend_packet_count_(0), 336 resend_packet_count_(0),
338 no_loss_startup_(100), 337 no_loss_startup_(100),
339 end_of_file_(false), 338 end_of_file_(false),
340 reordering_(false), 339 reordering_(false),
341 reorder_buffer_() { 340 reorder_buffer_() {
342 assert(clock); 341 assert(clock);
343 assert(packet_source); 342 assert(packet_source);
344 assert(packet_source->get()); 343 assert(packet_source->get());
345 packet_source_.swap(*packet_source); 344 packet_source_.swap(*packet_source);
346 std::srand(321); 345 srand(321);
347 } 346 }
348 347
349 virtual ~RtpPlayerImpl() {} 348 virtual ~RtpPlayerImpl() {}
350 349
351 virtual int NextPacket(int64_t time_now) { 350 virtual int NextPacket(int64_t time_now) {
352 // Send any packets ready to be resent. 351 // Send any packets ready to be resent.
353 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now); 352 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now);
354 packet != NULL; packet = lost_packets_.NextPacketToResend(time_now)) { 353 packet != NULL; packet = lost_packets_.NextPacketToResend(time_now)) {
355 int ret = SendPacket(packet->data(), packet->length()); 354 int ret = SendPacket(packet->data(), packet->length());
356 if (ret > 0) { 355 if (ret > 0) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 return -1; 428 return -1;
430 } 429 }
431 uint32_t ssrc = header.ssrc; 430 uint32_t ssrc = header.ssrc;
432 if (ssrc_handlers_.RegisterSsrc(ssrc, &lost_packets_, clock_) < 0) { 431 if (ssrc_handlers_.RegisterSsrc(ssrc, &lost_packets_, clock_) < 0) {
433 DEBUG_LOG1("Unable to register ssrc: %d", ssrc); 432 DEBUG_LOG1("Unable to register ssrc: %d", ssrc);
434 return -1; 433 return -1;
435 } 434 }
436 435
437 if (no_loss_startup_ > 0) { 436 if (no_loss_startup_ > 0) {
438 no_loss_startup_--; 437 no_loss_startup_--;
439 } else if ((std::rand() + 1.0) / (RAND_MAX + 1.0) < 438 } else if ((rand() + 1.0) / (RAND_MAX + 1.0) < loss_rate_) { // NOLINT
440 loss_rate_) { // NOLINT
441 uint16_t seq_num = header.sequenceNumber; 439 uint16_t seq_num = header.sequenceNumber;
442 lost_packets_.AddPacket(new RawRtpPacket(data, length, ssrc, seq_num)); 440 lost_packets_.AddPacket(new RawRtpPacket(data, length, ssrc, seq_num));
443 DEBUG_LOG1("Dropped packet: %d!", header.header.sequenceNumber); 441 DEBUG_LOG1("Dropped packet: %d!", header.header.sequenceNumber);
444 return 0; 442 return 0;
445 } 443 }
446 } 444 }
447 445
448 ssrc_handlers_.IncomingPacket(data, length); 446 ssrc_handlers_.IncomingPacket(data, length);
449 return 1; 447 return 1;
450 } 448 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 484 }
487 } 485 }
488 486
489 std::unique_ptr<RtpPlayerImpl> impl( 487 std::unique_ptr<RtpPlayerImpl> impl(
490 new RtpPlayerImpl(payload_sink_factory, payload_types, clock, 488 new RtpPlayerImpl(payload_sink_factory, payload_types, clock,
491 &packet_source, loss_rate, rtt_ms, reordering)); 489 &packet_source, loss_rate, rtt_ms, reordering));
492 return impl.release(); 490 return impl.release();
493 } 491 }
494 } // namespace rtpplayer 492 } // namespace rtpplayer
495 } // namespace webrtc 493 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer.h ('k') | webrtc/modules/video_processing/util/noise_estimation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698