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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 loss_count_(0), 81 loss_count_(0),
82 packets_(), 82 packets_(),
83 clock_(clock), 83 clock_(clock),
84 rtt_ms_(rtt_ms) { 84 rtt_ms_(rtt_ms) {
85 assert(clock); 85 assert(clock);
86 } 86 }
87 87
88 ~LostPackets() { 88 ~LostPackets() {
89 if (debug_file_) { 89 if (debug_file_) {
90 fclose(debug_file_); 90 fclose(debug_file_);
91 debug_file_ = NULL; 91 debug_file_ = nullptr;
92 } 92 }
93 while (!packets_.empty()) { 93 while (!packets_.empty()) {
94 delete packets_.back(); 94 delete packets_.back();
95 packets_.pop_back(); 95 packets_.pop_back();
96 } 96 }
97 } 97 }
98 98
99 void AddPacket(RawRtpPacket* packet) { 99 void AddPacket(RawRtpPacket* packet) {
100 assert(packet); 100 assert(packet);
101 printf("Throw: %08x:%u\n", packet->ssrc(), packet->seq_num()); 101 printf("Throw: %08x:%u\n", packet->ssrc(), packet->seq_num());
(...skipping 28 matching lines...) Expand all
130 RawRtpPacket* NextPacketToResend(int64_t time_now) { 130 RawRtpPacket* NextPacketToResend(int64_t time_now) {
131 CriticalSectionScoped cs(crit_sect_.get()); 131 CriticalSectionScoped cs(crit_sect_.get());
132 for (RtpPacketIterator it = packets_.begin(); it != packets_.end(); ++it) { 132 for (RtpPacketIterator it = packets_.begin(); it != packets_.end(); ++it) {
133 RawRtpPacket* packet = *it; 133 RawRtpPacket* packet = *it;
134 if (time_now >= packet->resend_time_ms() && 134 if (time_now >= packet->resend_time_ms() &&
135 packet->resend_time_ms() != -1) { 135 packet->resend_time_ms() != -1) {
136 packets_.erase(it); 136 packets_.erase(it);
137 return packet; 137 return packet;
138 } 138 }
139 } 139 }
140 return NULL; 140 return nullptr;
141 } 141 }
142 142
143 int NumberOfPacketsToResend() const { 143 int NumberOfPacketsToResend() const {
144 CriticalSectionScoped cs(crit_sect_.get()); 144 CriticalSectionScoped cs(crit_sect_.get());
145 int count = 0; 145 int count = 0;
146 for (ConstRtpPacketIterator it = packets_.begin(); it != packets_.end(); 146 for (ConstRtpPacketIterator it = packets_.begin(); it != packets_.end();
147 ++it) { 147 ++it) {
148 if ((*it)->resend_time_ms() >= 0) { 148 if ((*it)->resend_time_ms() >= 0) {
149 count++; 149 count++;
150 } 150 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 int RegisterSsrc(uint32_t ssrc, LostPackets* lost_packets, Clock* clock) { 209 int RegisterSsrc(uint32_t ssrc, LostPackets* lost_packets, Clock* clock) {
210 if (handlers_.count(ssrc) > 0) { 210 if (handlers_.count(ssrc) > 0) {
211 return 0; 211 return 0;
212 } 212 }
213 DEBUG_LOG1("Registering handler for ssrc=%08x", ssrc); 213 DEBUG_LOG1("Registering handler for ssrc=%08x", ssrc);
214 214
215 std::unique_ptr<Handler> handler( 215 std::unique_ptr<Handler> handler(
216 new Handler(ssrc, payload_types_, lost_packets)); 216 new Handler(ssrc, payload_types_, lost_packets));
217 handler->payload_sink_.reset(payload_sink_factory_->Create(handler.get())); 217 handler->payload_sink_.reset(payload_sink_factory_->Create(handler.get()));
218 if (handler->payload_sink_.get() == NULL) { 218 if (handler->payload_sink_.get() == nullptr) {
219 return -1; 219 return -1;
220 } 220 }
221 221
222 RtpRtcp::Configuration configuration; 222 RtpRtcp::Configuration configuration;
223 configuration.clock = clock; 223 configuration.clock = clock;
224 configuration.audio = false; 224 configuration.audio = false;
225 handler->rtp_module_.reset(RtpReceiver::CreateVideoReceiver( 225 handler->rtp_module_.reset(RtpReceiver::CreateVideoReceiver(
226 configuration.clock, handler->payload_sink_.get(), NULL, 226 configuration.clock, handler->payload_sink_.get(), nullptr,
227 handler->rtp_payload_registry_.get())); 227 handler->rtp_payload_registry_.get()));
228 if (handler->rtp_module_.get() == NULL) { 228 if (handler->rtp_module_.get() == nullptr) {
229 return -1; 229 return -1;
230 } 230 }
231 231
232 handler->rtp_header_parser_->RegisterRtpHeaderExtension( 232 handler->rtp_header_parser_->RegisterRtpHeaderExtension(
233 kRtpExtensionTransmissionTimeOffset, 233 kRtpExtensionTransmissionTimeOffset,
234 kDefaultTransmissionTimeOffsetExtensionId); 234 kDefaultTransmissionTimeOffsetExtensionId);
235 235
236 for (PayloadTypesIterator it = payload_types_.begin(); 236 for (PayloadTypesIterator it = payload_types_.begin();
237 it != payload_types_.end(); ++it) { 237 it != payload_types_.end(); ++it) {
238 VideoCodec codec; 238 VideoCodec codec;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 assert(packet_source->get()); 342 assert(packet_source->get());
343 packet_source_.swap(*packet_source); 343 packet_source_.swap(*packet_source);
344 std::srand(321); 344 std::srand(321);
345 } 345 }
346 346
347 virtual ~RtpPlayerImpl() {} 347 virtual ~RtpPlayerImpl() {}
348 348
349 virtual int NextPacket(int64_t time_now) { 349 virtual int NextPacket(int64_t time_now) {
350 // Send any packets ready to be resent. 350 // Send any packets ready to be resent.
351 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now); 351 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now);
352 packet != NULL; packet = lost_packets_.NextPacketToResend(time_now)) { 352 packet != nullptr;
353 packet = lost_packets_.NextPacketToResend(time_now)) {
353 int ret = SendPacket(packet->data(), packet->length()); 354 int ret = SendPacket(packet->data(), packet->length());
354 if (ret > 0) { 355 if (ret > 0) {
355 printf("Resend: %08x:%u\n", packet->ssrc(), packet->seq_num()); 356 printf("Resend: %08x:%u\n", packet->ssrc(), packet->seq_num());
356 lost_packets_.LogPacketResent(packet); 357 lost_packets_.LogPacketResent(packet);
357 resend_packet_count_++; 358 resend_packet_count_++;
358 } 359 }
359 delete packet; 360 delete packet;
360 if (ret < 0) { 361 if (ret < 0) {
361 return ret; 362 return ret;
362 } 363 }
363 } 364 }
364 365
365 // Send any packets from packet source. 366 // Send any packets from packet source.
366 if (!end_of_file_ && (TimeUntilNextPacket() == 0 || first_packet_)) { 367 if (!end_of_file_ && (TimeUntilNextPacket() == 0 || first_packet_)) {
367 if (first_packet_) { 368 if (first_packet_) {
368 if (!packet_source_->NextPacket(&next_packet_)) 369 if (!packet_source_->NextPacket(&next_packet_))
369 return 0; 370 return 0;
370 first_packet_rtp_time_ = next_packet_.time_ms; 371 first_packet_rtp_time_ = next_packet_.time_ms;
371 first_packet_time_ms_ = clock_->TimeInMilliseconds(); 372 first_packet_time_ms_ = clock_->TimeInMilliseconds();
372 first_packet_ = false; 373 first_packet_ = false;
373 } 374 }
374 375
375 if (reordering_ && reorder_buffer_.get() == NULL) { 376 if (reordering_ && reorder_buffer_.get() == nullptr) {
376 reorder_buffer_.reset( 377 reorder_buffer_.reset(
377 new RawRtpPacket(next_packet_.data, next_packet_.length, 0, 0)); 378 new RawRtpPacket(next_packet_.data, next_packet_.length, 0, 0));
378 return 0; 379 return 0;
379 } 380 }
380 int ret = SendPacket(next_packet_.data, next_packet_.length); 381 int ret = SendPacket(next_packet_.data, next_packet_.length);
381 if (reorder_buffer_.get()) { 382 if (reorder_buffer_.get()) {
382 SendPacket(reorder_buffer_->data(), reorder_buffer_->length()); 383 SendPacket(reorder_buffer_->data(), reorder_buffer_->length());
383 reorder_buffer_.reset(NULL); 384 reorder_buffer_.reset(nullptr);
384 } 385 }
385 if (ret < 0) { 386 if (ret < 0) {
386 return ret; 387 return ret;
387 } 388 }
388 389
389 if (!packet_source_->NextPacket(&next_packet_)) { 390 if (!packet_source_->NextPacket(&next_packet_)) {
390 end_of_file_ = true; 391 end_of_file_ = true;
391 return 0; 392 return 0;
392 } else if (next_packet_.length == 0) { 393 } else if (next_packet_.length == 0) {
393 return 0; 394 return 0;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 RtpPlayerInterface* Create(const std::string& input_filename, 470 RtpPlayerInterface* Create(const std::string& input_filename,
470 PayloadSinkFactoryInterface* payload_sink_factory, 471 PayloadSinkFactoryInterface* payload_sink_factory,
471 Clock* clock, 472 Clock* clock,
472 const PayloadTypes& payload_types, 473 const PayloadTypes& payload_types,
473 float loss_rate, 474 float loss_rate,
474 int64_t rtt_ms, 475 int64_t rtt_ms,
475 bool reordering) { 476 bool reordering) {
476 std::unique_ptr<test::RtpFileReader> packet_source( 477 std::unique_ptr<test::RtpFileReader> packet_source(
477 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump, 478 test::RtpFileReader::Create(test::RtpFileReader::kRtpDump,
478 input_filename)); 479 input_filename));
479 if (packet_source.get() == NULL) { 480 if (packet_source.get() == nullptr) {
480 packet_source.reset(test::RtpFileReader::Create(test::RtpFileReader::kPcap, 481 packet_source.reset(test::RtpFileReader::Create(test::RtpFileReader::kPcap,
481 input_filename)); 482 input_filename));
482 if (packet_source.get() == NULL) { 483 if (packet_source.get() == nullptr) {
483 return NULL; 484 return nullptr;
484 } 485 }
485 } 486 }
486 487
487 std::unique_ptr<RtpPlayerImpl> impl( 488 std::unique_ptr<RtpPlayerImpl> impl(
488 new RtpPlayerImpl(payload_sink_factory, payload_types, clock, 489 new RtpPlayerImpl(payload_sink_factory, payload_types, clock,
489 &packet_source, loss_rate, rtt_ms, reordering)); 490 &packet_source, loss_rate, rtt_ms, reordering));
490 return impl.release(); 491 return impl.release();
491 } 492 }
492 } // namespace rtpplayer 493 } // namespace rtpplayer
493 } // namespace webrtc 494 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698