| Index: webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
|
| index 541f522f8d1e44ce9d148d7d6bf1000b7db1f21f..80f961bd1eb99876c3879e8ed70195830bee9eaf 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
|
| @@ -11,6 +11,7 @@
|
| #include <list>
|
|
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "webrtc/base/random.h"
|
| #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
| #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
|
|
|
| @@ -41,8 +42,12 @@ template <typename T> void ClearList(std::list<T*>* my_list) {
|
| class RtpFecTest : public ::testing::Test {
|
| protected:
|
| RtpFecTest()
|
| - : fec_(new ForwardErrorCorrection()), ssrc_(rand()), fec_seq_num_(0) {}
|
| + : random_(0xfec133700742),
|
| + fec_(new ForwardErrorCorrection()),
|
| + ssrc_(random_.Rand<uint32_t>()),
|
| + fec_seq_num_(0) {}
|
|
|
| + webrtc::Random random_;
|
| ForwardErrorCorrection* fec_;
|
| int ssrc_;
|
| uint16_t fec_seq_num_;
|
| @@ -891,22 +896,20 @@ int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets,
|
| assert(num_media_packets > 0);
|
| ForwardErrorCorrection::Packet* media_packet = NULL;
|
| int sequence_number = start_seq_num;
|
| - int time_stamp = rand();
|
| + int time_stamp = random_.Rand<int>();
|
|
|
| for (int i = 0; i < num_media_packets; ++i) {
|
| media_packet = new ForwardErrorCorrection::Packet;
|
| media_packet_list_.push_back(media_packet);
|
| - media_packet->length = static_cast<size_t>(
|
| - (static_cast<float>(rand()) / RAND_MAX) *
|
| - (IP_PACKET_SIZE - kRtpHeaderSize - kTransportOverhead -
|
| - ForwardErrorCorrection::PacketOverhead()));
|
| + const uint32_t kMinPacketSize = kRtpHeaderSize;
|
| + const uint32_t kMaxPacketSize = IP_PACKET_SIZE - kRtpHeaderSize -
|
| + kTransportOverhead -
|
| + ForwardErrorCorrection::PacketOverhead();
|
| + media_packet->length = random_.Rand(kMinPacketSize, kMaxPacketSize);
|
|
|
| - if (media_packet->length < kRtpHeaderSize) {
|
| - media_packet->length = kRtpHeaderSize;
|
| - }
|
| // Generate random values for the first 2 bytes
|
| - media_packet->data[0] = static_cast<uint8_t>(rand() % 256);
|
| - media_packet->data[1] = static_cast<uint8_t>(rand() % 256);
|
| + media_packet->data[0] = random_.Rand<uint8_t>();
|
| + media_packet->data[1] = random_.Rand<uint8_t>();
|
|
|
| // The first two bits are assumed to be 10 by the FEC encoder.
|
| // In fact the FEC decoder will set the two first bits to 10 regardless of
|
| @@ -929,7 +932,7 @@ int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets,
|
|
|
| // Generate random values for payload.
|
| for (size_t j = 12; j < media_packet->length; ++j) {
|
| - media_packet->data[j] = static_cast<uint8_t>(rand() % 256);
|
| + media_packet->data[j] = random_.Rand<uint8_t>();
|
| }
|
| sequence_number++;
|
| }
|
| @@ -940,5 +943,5 @@ int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets,
|
| }
|
|
|
| int RtpFecTest::ConstructMediaPackets(int num_media_packets) {
|
| - return ConstructMediaPacketsSeqNum(num_media_packets, rand());
|
| + return ConstructMediaPacketsSeqNum(num_media_packets, random_.Rand<int>());
|
| }
|
|
|