OLD | NEW |
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> |
15 #include <map> | 16 #include <map> |
16 #include <memory> | 17 #include <memory> |
17 | 18 |
18 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
23 #include "webrtc/modules/video_coding/internal_defines.h" | 24 #include "webrtc/modules/video_coding/internal_defines.h" |
24 #include "webrtc/modules/video_coding/test/test_util.h" | 25 #include "webrtc/modules/video_coding/test/test_util.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 lost_packets_(clock, rtt_ms), | 335 lost_packets_(clock, rtt_ms), |
335 resend_packet_count_(0), | 336 resend_packet_count_(0), |
336 no_loss_startup_(100), | 337 no_loss_startup_(100), |
337 end_of_file_(false), | 338 end_of_file_(false), |
338 reordering_(false), | 339 reordering_(false), |
339 reorder_buffer_() { | 340 reorder_buffer_() { |
340 assert(clock); | 341 assert(clock); |
341 assert(packet_source); | 342 assert(packet_source); |
342 assert(packet_source->get()); | 343 assert(packet_source->get()); |
343 packet_source_.swap(*packet_source); | 344 packet_source_.swap(*packet_source); |
344 srand(321); | 345 std::srand(321); |
345 } | 346 } |
346 | 347 |
347 virtual ~RtpPlayerImpl() {} | 348 virtual ~RtpPlayerImpl() {} |
348 | 349 |
349 virtual int NextPacket(int64_t time_now) { | 350 virtual int NextPacket(int64_t time_now) { |
350 // Send any packets ready to be resent. | 351 // Send any packets ready to be resent. |
351 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now); | 352 for (RawRtpPacket* packet = lost_packets_.NextPacketToResend(time_now); |
352 packet != NULL; packet = lost_packets_.NextPacketToResend(time_now)) { | 353 packet != NULL; 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) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return -1; | 428 return -1; |
428 } | 429 } |
429 uint32_t ssrc = header.ssrc; | 430 uint32_t ssrc = header.ssrc; |
430 if (ssrc_handlers_.RegisterSsrc(ssrc, &lost_packets_, clock_) < 0) { | 431 if (ssrc_handlers_.RegisterSsrc(ssrc, &lost_packets_, clock_) < 0) { |
431 DEBUG_LOG1("Unable to register ssrc: %d", ssrc); | 432 DEBUG_LOG1("Unable to register ssrc: %d", ssrc); |
432 return -1; | 433 return -1; |
433 } | 434 } |
434 | 435 |
435 if (no_loss_startup_ > 0) { | 436 if (no_loss_startup_ > 0) { |
436 no_loss_startup_--; | 437 no_loss_startup_--; |
437 } else if ((rand() + 1.0) / (RAND_MAX + 1.0) < loss_rate_) { // NOLINT | 438 } else if ((std::rand() + 1.0) / (RAND_MAX + 1.0) < |
| 439 loss_rate_) { // NOLINT |
438 uint16_t seq_num = header.sequenceNumber; | 440 uint16_t seq_num = header.sequenceNumber; |
439 lost_packets_.AddPacket(new RawRtpPacket(data, length, ssrc, seq_num)); | 441 lost_packets_.AddPacket(new RawRtpPacket(data, length, ssrc, seq_num)); |
440 DEBUG_LOG1("Dropped packet: %d!", header.header.sequenceNumber); | 442 DEBUG_LOG1("Dropped packet: %d!", header.header.sequenceNumber); |
441 return 0; | 443 return 0; |
442 } | 444 } |
443 } | 445 } |
444 | 446 |
445 ssrc_handlers_.IncomingPacket(data, length); | 447 ssrc_handlers_.IncomingPacket(data, length); |
446 return 1; | 448 return 1; |
447 } | 449 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 485 } |
484 } | 486 } |
485 | 487 |
486 std::unique_ptr<RtpPlayerImpl> impl( | 488 std::unique_ptr<RtpPlayerImpl> impl( |
487 new RtpPlayerImpl(payload_sink_factory, payload_types, clock, | 489 new RtpPlayerImpl(payload_sink_factory, payload_types, clock, |
488 &packet_source, loss_rate, rtt_ms, reordering)); | 490 &packet_source, loss_rate, rtt_ms, reordering)); |
489 return impl.release(); | 491 return impl.release(); |
490 } | 492 } |
491 } // namespace rtpplayer | 493 } // namespace rtpplayer |
492 } // namespace webrtc | 494 } // namespace webrtc |
OLD | NEW |