Fix clang errors in non-GYP_DEFINES=clang=1 build

BUG=1623
R=stefan@webrtc.org, tina.legrand@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1368004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3968 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-05-07 12:36:21 +00:00
parent d3a1959678
commit 3004c79c6a
21 changed files with 295 additions and 295 deletions

View File

@ -21,7 +21,7 @@ extern "C" {
namespace { namespace {
enum { kNumValidFrameLengths = 3 }; const int kNumValidFrameLengths = 3;
TEST_F(VadTest, vad_filterbank) { TEST_F(VadTest, vad_filterbank) {
VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT)));

View File

@ -19,9 +19,9 @@ struct WebRtcOpusDecInst;
namespace webrtc { namespace webrtc {
// Number of samples in a 60 ms stereo frame, sampled at 48 kHz. // Number of samples in a 60 ms stereo frame, sampled at 48 kHz.
enum { kOpusNumberOfSamples = 480 * 6 * 2 }; const int kOpusNumberOfSamples = 480 * 6 * 2;
// Maximum number of bytes in output bitstream. // Maximum number of bytes in output bitstream.
enum { kMaxBytes = 1000 }; const size_t kMaxBytes = 1000;
class OpusTest : public ::testing::Test { class OpusTest : public ::testing::Test {
protected: protected:

View File

@ -27,14 +27,15 @@ namespace webrtc {
// tests for AudioVector already covers a number of different type parameters, // tests for AudioVector already covers a number of different type parameters,
// this test focuses on testing different number of channels, and keeping the // this test focuses on testing different number of channels, and keeping the
// value type constant. // value type constant.
class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> { class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
protected: protected:
typedef int16_t T; // Use this value type for all tests. typedef int16_t T; // Use this value type for all tests.
AudioMultiVectorTest() AudioMultiVectorTest()
: num_channels_(GetParam()), // Get the test parameter. : num_channels_(GetParam()), // Get the test parameter.
interleaved_length_(num_channels_ * kLength) { interleaved_length_(num_channels_ * array_length()) {
array_interleaved_ = new T[num_channels_ * kLength]; array_interleaved_ = new T[num_channels_ * array_length()];
} }
~AudioMultiVectorTest() { ~AudioMultiVectorTest() {
@ -43,14 +44,14 @@ class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
virtual void SetUp() { virtual void SetUp() {
// Populate test arrays. // Populate test arrays.
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
array_[i] = static_cast<T>(i); array_[i] = static_cast<T>(i);
} }
T* ptr = array_interleaved_; T* ptr = array_interleaved_;
// Write 100, 101, 102, ... for first channel. // Write 100, 101, 102, ... for first channel.
// Write 200, 201, 202, ... for second channel. // Write 200, 201, 202, ... for second channel.
// And so on. // And so on.
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
for (size_t j = 1; j <= num_channels_; ++j) { for (size_t j = 1; j <= num_channels_; ++j) {
*ptr = j * 100 + i; *ptr = j * 100 + i;
++ptr; ++ptr;
@ -58,13 +59,13 @@ class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
} }
} }
enum { size_t array_length() const {
kLength = 10 return sizeof(array_) / sizeof(array_[0]);
}; }
const size_t num_channels_; const size_t num_channels_;
size_t interleaved_length_; size_t interleaved_length_;
T array_[kLength]; T array_[10];
T* array_interleaved_; T* array_interleaved_;
}; };
@ -85,9 +86,9 @@ TEST_P(AudioMultiVectorTest, CreateAndDestroy) {
// Test the subscript operator [] for getting and setting. // Test the subscript operator [] for getting and setting.
TEST_P(AudioMultiVectorTest, SubscriptOperator) { TEST_P(AudioMultiVectorTest, SubscriptOperator) {
AudioMultiVector<T> vec(num_channels_, kLength); AudioMultiVector<T> vec(num_channels_, array_length());
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
vec[channel][i] = static_cast<T>(i); vec[channel][i] = static_cast<T>(i);
// Make sure to use the const version. // Make sure to use the const version.
const AudioVector<T>& audio_vec = vec[channel]; const AudioVector<T>& audio_vec = vec[channel];
@ -104,11 +105,11 @@ TEST_P(AudioMultiVectorTest, PushBackInterleavedAndCopy) {
AudioMultiVector<T> vec_copy(num_channels_); AudioMultiVector<T> vec_copy(num_channels_);
vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|. vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|.
ASSERT_EQ(num_channels_, vec.Channels()); ASSERT_EQ(num_channels_, vec.Channels());
ASSERT_EQ(kLength, vec.Size()); ASSERT_EQ(array_length(), vec.Size());
ASSERT_EQ(num_channels_, vec_copy.Channels()); ASSERT_EQ(num_channels_, vec_copy.Channels());
ASSERT_EQ(kLength, vec_copy.Size()); ASSERT_EQ(array_length(), vec_copy.Size());
for (size_t channel = 0; channel < vec.Channels(); ++channel) { for (size_t channel = 0; channel < vec.Channels(); ++channel) {
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
EXPECT_EQ(static_cast<T>((channel + 1) * 100 + i), vec[channel][i]); EXPECT_EQ(static_cast<T>((channel + 1) * 100 + i), vec[channel][i]);
EXPECT_EQ(vec[channel][i], vec_copy[channel][i]); EXPECT_EQ(vec[channel][i], vec_copy[channel][i]);
} }
@ -133,22 +134,23 @@ TEST_P(AudioMultiVectorTest, CopyToNull) {
// Test the PushBack method with another AudioMultiVector as input argument. // Test the PushBack method with another AudioMultiVector as input argument.
TEST_P(AudioMultiVectorTest, PushBackVector) { TEST_P(AudioMultiVectorTest, PushBackVector) {
AudioMultiVector<T> vec1(num_channels_, kLength); AudioMultiVector<T> vec1(num_channels_, array_length());
AudioMultiVector<T> vec2(num_channels_, kLength); AudioMultiVector<T> vec2(num_channels_, array_length());
// Set the first vector to [0, 1, ..., kLength - 1] + 100 * channel_number. // Set the first vector to [0, 1, ..., array_length() - 1] +
// Set the second vector to [kLength, kLength + 1, ..., 2 * kLength - 1] + // 100 * channel_number.
// 100 * channel_number. // Set the second vector to [array_length(), array_length() + 1, ...,
// 2 * array_length() - 1] + 100 * channel_number.
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
vec1[channel][i] = static_cast<T>(i + 100 * channel); vec1[channel][i] = static_cast<T>(i + 100 * channel);
vec2[channel][i] = static_cast<T>(i + 100 * channel + kLength); vec2[channel][i] = static_cast<T>(i + 100 * channel + array_length());
} }
} }
// Append vec2 to the back of vec1. // Append vec2 to the back of vec1.
vec1.PushBack(vec2); vec1.PushBack(vec2);
ASSERT_EQ(2u * kLength, vec1.Size()); ASSERT_EQ(2u * array_length(), vec1.Size());
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < 2 * kLength; ++i) { for (size_t i = 0; i < 2 * array_length(); ++i) {
EXPECT_EQ(static_cast<T>(i + 100 * channel), vec1[channel][i]); EXPECT_EQ(static_cast<T>(i + 100 * channel), vec1[channel][i]);
} }
} }
@ -162,12 +164,12 @@ TEST_P(AudioMultiVectorTest, PushBackFromIndex) {
// Append vec1 to the back of vec2 (which is empty). Read vec1 from the second // Append vec1 to the back of vec2 (which is empty). Read vec1 from the second
// last element. // last element.
vec2.PushBackFromIndex(vec1, kLength - 2); vec2.PushBackFromIndex(vec1, array_length() - 2);
ASSERT_EQ(2u, vec2.Size()); ASSERT_EQ(2u, vec2.Size());
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < 2; ++i) { for (size_t i = 0; i < 2; ++i) {
EXPECT_EQ(array_interleaved_[channel + num_channels_ * (kLength - 2 + i)], EXPECT_EQ(array_interleaved_[channel + num_channels_ *
vec2[channel][i]); (array_length() - 2 + i)], vec2[channel][i]);
} }
} }
} }
@ -176,11 +178,11 @@ TEST_P(AudioMultiVectorTest, PushBackFromIndex) {
TEST_P(AudioMultiVectorTest, Zeros) { TEST_P(AudioMultiVectorTest, Zeros) {
AudioMultiVector<T> vec(num_channels_); AudioMultiVector<T> vec(num_channels_);
vec.PushBackInterleaved(array_interleaved_, interleaved_length_); vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
vec.Zeros(2 * kLength); vec.Zeros(2 * array_length());
ASSERT_EQ(num_channels_, vec.Channels()); ASSERT_EQ(num_channels_, vec.Channels());
ASSERT_EQ(2u * kLength, vec.Size()); ASSERT_EQ(2u * array_length(), vec.Size());
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < 2 * kLength; ++i) { for (size_t i = 0; i < 2 * array_length(); ++i) {
EXPECT_EQ(0, vec[channel][i]); EXPECT_EQ(0, vec[channel][i]);
} }
} }
@ -199,7 +201,7 @@ TEST_P(AudioMultiVectorTest, ReadInterleaved) {
// Read too many samples. Expect to get all samples from the vector. // Read too many samples. Expect to get all samples from the vector.
EXPECT_EQ(interleaved_length_, EXPECT_EQ(interleaved_length_,
vec.ReadInterleaved(kLength + 1, output)); vec.ReadInterleaved(array_length() + 1, output));
EXPECT_EQ(0, memcmp(array_interleaved_, output, read_samples * sizeof(T))); EXPECT_EQ(0, memcmp(array_interleaved_, output, read_samples * sizeof(T)));
delete [] output; delete [] output;
@ -220,17 +222,17 @@ TEST_P(AudioMultiVectorTest, PopFront) {
AudioMultiVector<T> vec(num_channels_); AudioMultiVector<T> vec(num_channels_);
vec.PushBackInterleaved(array_interleaved_, interleaved_length_); vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
vec.PopFront(1); // Remove one element from each channel. vec.PopFront(1); // Remove one element from each channel.
ASSERT_EQ(kLength - 1u, vec.Size()); ASSERT_EQ(array_length() - 1u, vec.Size());
// Let |ptr| point to the second element of the first channel in the // Let |ptr| point to the second element of the first channel in the
// interleaved array. // interleaved array.
T* ptr = &array_interleaved_[num_channels_]; T* ptr = &array_interleaved_[num_channels_];
for (size_t i = 0; i < kLength - 1; ++i) { for (size_t i = 0; i < array_length() - 1; ++i) {
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
EXPECT_EQ(*ptr, vec[channel][i]); EXPECT_EQ(*ptr, vec[channel][i]);
++ptr; ++ptr;
} }
} }
vec.PopFront(kLength); // Remove more elements than vector size. vec.PopFront(array_length()); // Remove more elements than vector size.
EXPECT_EQ(0u, vec.Size()); EXPECT_EQ(0u, vec.Size());
} }
@ -239,36 +241,36 @@ TEST_P(AudioMultiVectorTest, PopBack) {
AudioMultiVector<T> vec(num_channels_); AudioMultiVector<T> vec(num_channels_);
vec.PushBackInterleaved(array_interleaved_, interleaved_length_); vec.PushBackInterleaved(array_interleaved_, interleaved_length_);
vec.PopBack(1); // Remove one element from each channel. vec.PopBack(1); // Remove one element from each channel.
ASSERT_EQ(kLength - 1u, vec.Size()); ASSERT_EQ(array_length() - 1u, vec.Size());
// Let |ptr| point to the first element of the first channel in the // Let |ptr| point to the first element of the first channel in the
// interleaved array. // interleaved array.
T* ptr = array_interleaved_; T* ptr = array_interleaved_;
for (size_t i = 0; i < kLength - 1; ++i) { for (size_t i = 0; i < array_length() - 1; ++i) {
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
EXPECT_EQ(*ptr, vec[channel][i]); EXPECT_EQ(*ptr, vec[channel][i]);
++ptr; ++ptr;
} }
} }
vec.PopBack(kLength); // Remove more elements than vector size. vec.PopBack(array_length()); // Remove more elements than vector size.
EXPECT_EQ(0u, vec.Size()); EXPECT_EQ(0u, vec.Size());
} }
// Test the AssertSize method. // Test the AssertSize method.
TEST_P(AudioMultiVectorTest, AssertSize) { TEST_P(AudioMultiVectorTest, AssertSize) {
AudioMultiVector<T> vec(num_channels_, kLength); AudioMultiVector<T> vec(num_channels_, array_length());
EXPECT_EQ(kLength, vec.Size()); EXPECT_EQ(array_length(), vec.Size());
// Start with asserting with smaller sizes than already allocated. // Start with asserting with smaller sizes than already allocated.
vec.AssertSize(0); vec.AssertSize(0);
vec.AssertSize(kLength - 1); vec.AssertSize(array_length() - 1);
// Nothing should have changed. // Nothing should have changed.
EXPECT_EQ(kLength, vec.Size()); EXPECT_EQ(array_length(), vec.Size());
// Assert with one element longer than already allocated. // Assert with one element longer than already allocated.
vec.AssertSize(kLength + 1); vec.AssertSize(array_length() + 1);
// Expect vector to have grown. // Expect vector to have grown.
EXPECT_EQ(kLength + 1u, vec.Size()); EXPECT_EQ(array_length() + 1, vec.Size());
// Also check the individual AudioVectors. // Also check the individual AudioVectors.
for (size_t channel = 0; channel < vec.Channels(); ++channel) { for (size_t channel = 0; channel < vec.Channels(); ++channel) {
EXPECT_EQ(kLength + 1u, vec[channel].Size()); EXPECT_EQ(array_length() + 1u, vec[channel].Size());
} }
} }
@ -281,9 +283,10 @@ TEST_P(AudioMultiVectorTest, OverwriteAt) {
// Overwrite vec2 at position 5. // Overwrite vec2 at position 5.
vec1.OverwriteAt(vec2, 3, 5); vec1.OverwriteAt(vec2, 3, 5);
// Verify result. // Verify result.
ASSERT_EQ(kLength, vec1.Size()); // Length remains the same. // Length remains the same.
ASSERT_EQ(array_length(), vec1.Size());
T* ptr = array_interleaved_; T* ptr = array_interleaved_;
for (size_t i = 0; i < kLength - 1; ++i) { for (size_t i = 0; i < array_length() - 1; ++i) {
for (size_t channel = 0; channel < num_channels_; ++channel) { for (size_t channel = 0; channel < num_channels_; ++channel) {
if (i >= 5 && i <= 7) { if (i >= 5 && i <= 7) {
// Elements 5, 6, 7 should have been replaced with zeros. // Elements 5, 6, 7 should have been replaced with zeros.

View File

@ -27,23 +27,23 @@ namespace webrtc {
// int32_t and double in this case. Each test is then run once for each of these // int32_t and double in this case. Each test is then run once for each of these
// types. // types.
// A few special tricks are needed. For instance, the member variable |array_| // A few special tricks are needed. For instance, the member variable |array_|
// in the test fixture must be accessed using this->array_ in the tests. Also, // in the test fixture must be accessed using this->array_ in the tests.
// the enumerator value kLength must be accessed with TestFixture::kLength.
template<typename T> template<typename T>
class AudioVectorTest : public ::testing::Test { class AudioVectorTest : public ::testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
// Populate test array. // Populate test array.
for (size_t i = 0; i < kLength; ++i) { for (size_t i = 0; i < array_length(); ++i) {
array_[i] = static_cast<T>(i); array_[i] = static_cast<T>(i);
} }
} }
enum { size_t array_length() const {
kLength = 10 return sizeof(array_) / sizeof(array_[0]);
}; }
T array_[kLength]; T array_[10];
}; };
// Instantiate typed tests with int16_t, int32_t, and double. // Instantiate typed tests with int16_t, int32_t, and double.
@ -65,8 +65,8 @@ TYPED_TEST(AudioVectorTest, CreateAndDestroy) {
// Test the subscript operator [] for getting and setting. // Test the subscript operator [] for getting and setting.
TYPED_TEST(AudioVectorTest, SubscriptOperator) { TYPED_TEST(AudioVectorTest, SubscriptOperator) {
AudioVector<TypeParam> vec(TestFixture::kLength); AudioVector<TypeParam> vec(this->array_length());
for (size_t i = 0; i < TestFixture::kLength; ++i) { for (size_t i = 0; i < this->array_length(); ++i) {
vec[i] = static_cast<TypeParam>(i); vec[i] = static_cast<TypeParam>(i);
const TypeParam& value = vec[i]; // Make sure to use the const version. const TypeParam& value = vec[i]; // Make sure to use the const version.
EXPECT_EQ(static_cast<TypeParam>(i), value); EXPECT_EQ(static_cast<TypeParam>(i), value);
@ -78,11 +78,11 @@ TYPED_TEST(AudioVectorTest, SubscriptOperator) {
TYPED_TEST(AudioVectorTest, PushBackAndCopy) { TYPED_TEST(AudioVectorTest, PushBackAndCopy) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
AudioVector<TypeParam> vec_copy; AudioVector<TypeParam> vec_copy;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|. vec.CopyFrom(&vec_copy); // Copy from |vec| to |vec_copy|.
ASSERT_EQ(TestFixture::kLength, vec.Size()); ASSERT_EQ(this->array_length(), vec.Size());
ASSERT_EQ(TestFixture::kLength, vec_copy.Size()); ASSERT_EQ(this->array_length(), vec_copy.Size());
for (size_t i = 0; i < TestFixture::kLength; ++i) { for (size_t i = 0; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[i]); EXPECT_EQ(this->array_[i], vec[i]);
EXPECT_EQ(this->array_[i], vec_copy[i]); EXPECT_EQ(this->array_[i], vec_copy[i]);
} }
@ -100,7 +100,7 @@ TYPED_TEST(AudioVectorTest, PushBackAndCopy) {
TYPED_TEST(AudioVectorTest, CopyToNull) { TYPED_TEST(AudioVectorTest, CopyToNull) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
AudioVector<TypeParam>* vec_copy = NULL; AudioVector<TypeParam>* vec_copy = NULL;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec.CopyFrom(vec_copy); vec.CopyFrom(vec_copy);
} }
@ -126,9 +126,9 @@ TYPED_TEST(AudioVectorTest, PushBackVector) {
// Test the PushFront method. // Test the PushFront method.
TYPED_TEST(AudioVectorTest, PushFront) { TYPED_TEST(AudioVectorTest, PushFront) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushFront(this->array_, TestFixture::kLength); vec.PushFront(this->array_, this->array_length());
ASSERT_EQ(TestFixture::kLength, vec.Size()); ASSERT_EQ(this->array_length(), vec.Size());
for (size_t i = 0; i < TestFixture::kLength; ++i) { for (size_t i = 0; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[i]); EXPECT_EQ(this->array_[i], vec[i]);
} }
} }
@ -155,37 +155,37 @@ TYPED_TEST(AudioVectorTest, PushFrontVector) {
// Test the PopFront method. // Test the PopFront method.
TYPED_TEST(AudioVectorTest, PopFront) { TYPED_TEST(AudioVectorTest, PopFront) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec.PopFront(1); // Remove one element. vec.PopFront(1); // Remove one element.
EXPECT_EQ(TestFixture::kLength - 1u, vec.Size()); EXPECT_EQ(this->array_length() - 1u, vec.Size());
for (size_t i = 0; i < TestFixture::kLength - 1; ++i) { for (size_t i = 0; i < this->array_length() - 1; ++i) {
EXPECT_EQ(static_cast<TypeParam>(i + 1), vec[i]); EXPECT_EQ(static_cast<TypeParam>(i + 1), vec[i]);
} }
vec.PopFront(TestFixture::kLength); // Remove more elements than vector size. vec.PopFront(this->array_length()); // Remove more elements than vector size.
EXPECT_EQ(0u, vec.Size()); EXPECT_EQ(0u, vec.Size());
} }
// Test the PopBack method. // Test the PopBack method.
TYPED_TEST(AudioVectorTest, PopBack) { TYPED_TEST(AudioVectorTest, PopBack) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec.PopBack(1); // Remove one element. vec.PopBack(1); // Remove one element.
EXPECT_EQ(TestFixture::kLength - 1u, vec.Size()); EXPECT_EQ(this->array_length() - 1u, vec.Size());
for (size_t i = 0; i < TestFixture::kLength - 1; ++i) { for (size_t i = 0; i < this->array_length() - 1; ++i) {
EXPECT_EQ(static_cast<TypeParam>(i), vec[i]); EXPECT_EQ(static_cast<TypeParam>(i), vec[i]);
} }
vec.PopBack(TestFixture::kLength); // Remove more elements than vector size. vec.PopBack(this->array_length()); // Remove more elements than vector size.
EXPECT_EQ(0u, vec.Size()); EXPECT_EQ(0u, vec.Size());
} }
// Test the Extend method. // Test the Extend method.
TYPED_TEST(AudioVectorTest, Extend) { TYPED_TEST(AudioVectorTest, Extend) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec.Extend(5); // Extend with 5 elements, which should all be zeros. vec.Extend(5); // Extend with 5 elements, which should all be zeros.
ASSERT_EQ(TestFixture::kLength + 5u, vec.Size()); ASSERT_EQ(this->array_length() + 5u, vec.Size());
// Verify that all are zero. // Verify that all are zero.
for (int i = TestFixture::kLength; i < TestFixture::kLength + 5; ++i) { for (size_t i = this->array_length(); i < this->array_length() + 5; ++i) {
EXPECT_EQ(0, vec[i]); EXPECT_EQ(0, vec[i]);
} }
} }
@ -193,7 +193,7 @@ TYPED_TEST(AudioVectorTest, Extend) {
// Test the InsertAt method with an insert position in the middle of the vector. // Test the InsertAt method with an insert position in the middle of the vector.
TYPED_TEST(AudioVectorTest, InsertAt) { TYPED_TEST(AudioVectorTest, InsertAt) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
@ -205,7 +205,7 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {0, 1, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1, // {0, 1, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
// |insert_position|, |insert_position| + 1, ..., kLength - 1}. // |insert_position|, |insert_position| + 1, ..., kLength - 1}.
int pos = 0; size_t pos = 0;
for (int i = 0; i < insert_position; ++i) { for (int i = 0; i < insert_position; ++i) {
EXPECT_EQ(this->array_[i], vec[pos]); EXPECT_EQ(this->array_[i], vec[pos]);
++pos; ++pos;
@ -214,7 +214,7 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
EXPECT_EQ(new_array[i], vec[pos]); EXPECT_EQ(new_array[i], vec[pos]);
++pos; ++pos;
} }
for (int i = insert_position; i < TestFixture::kLength; ++i) { for (size_t i = insert_position; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[pos]); EXPECT_EQ(this->array_[i], vec[pos]);
++pos; ++pos;
} }
@ -225,8 +225,8 @@ TYPED_TEST(AudioVectorTest, InsertAt) {
TYPED_TEST(AudioVectorTest, InsertZerosAt) { TYPED_TEST(AudioVectorTest, InsertZerosAt) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
AudioVector<TypeParam> vec_ref; AudioVector<TypeParam> vec_ref;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
vec_ref.PushBack(this->array_, TestFixture::kLength); vec_ref.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
int insert_position = 5; int insert_position = 5;
vec.InsertZerosAt(kNewLength, insert_position); vec.InsertZerosAt(kNewLength, insert_position);
@ -242,7 +242,7 @@ TYPED_TEST(AudioVectorTest, InsertZerosAt) {
// Test the InsertAt method with an insert position at the start of the vector. // Test the InsertAt method with an insert position at the start of the vector.
TYPED_TEST(AudioVectorTest, InsertAtBeginning) { TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
@ -254,12 +254,12 @@ TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {100, 101, ..., 100 + kNewLength - 1, // {100, 101, ..., 100 + kNewLength - 1,
// 0, 1, ..., kLength - 1}. // 0, 1, ..., kLength - 1}.
int pos = 0; size_t pos = 0;
for (int i = 0; i < kNewLength; ++i) { for (int i = 0; i < kNewLength; ++i) {
EXPECT_EQ(new_array[i], vec[pos]); EXPECT_EQ(new_array[i], vec[pos]);
++pos; ++pos;
} }
for (int i = insert_position; i < TestFixture::kLength; ++i) { for (size_t i = insert_position; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[pos]); EXPECT_EQ(this->array_[i], vec[pos]);
++pos; ++pos;
} }
@ -268,19 +268,19 @@ TYPED_TEST(AudioVectorTest, InsertAtBeginning) {
// Test the InsertAt method with an insert position at the end of the vector. // Test the InsertAt method with an insert position at the end of the vector.
TYPED_TEST(AudioVectorTest, InsertAtEnd) { TYPED_TEST(AudioVectorTest, InsertAtEnd) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
for (int i = 0; i < kNewLength; ++i) { for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i; new_array[i] = 100 + i;
} }
int insert_position = TestFixture::kLength; int insert_position = this->array_length();
vec.InsertAt(new_array, kNewLength, insert_position); vec.InsertAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }. // {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
int pos = 0; size_t pos = 0;
for (int i = 0; i < TestFixture::kLength; ++i) { for (size_t i = 0; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[pos]); EXPECT_EQ(this->array_[i], vec[pos]);
++pos; ++pos;
} }
@ -297,19 +297,19 @@ TYPED_TEST(AudioVectorTest, InsertAtEnd) {
// allowed value. // allowed value.
TYPED_TEST(AudioVectorTest, InsertBeyondEnd) { TYPED_TEST(AudioVectorTest, InsertBeyondEnd) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
for (int i = 0; i < kNewLength; ++i) { for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i; new_array[i] = 100 + i;
} }
int insert_position = TestFixture::kLength + 10; // Too large. int insert_position = this->array_length() + 10; // Too large.
vec.InsertAt(new_array, kNewLength, insert_position); vec.InsertAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }. // {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
int pos = 0; size_t pos = 0;
for (int i = 0; i < TestFixture::kLength; ++i) { for (size_t i = 0; i < this->array_length(); ++i) {
EXPECT_EQ(this->array_[i], vec[pos]); EXPECT_EQ(this->array_[i], vec[pos]);
++pos; ++pos;
} }
@ -323,19 +323,19 @@ TYPED_TEST(AudioVectorTest, InsertBeyondEnd) {
// fit within the old vector. // fit within the old vector.
TYPED_TEST(AudioVectorTest, OverwriteAt) { TYPED_TEST(AudioVectorTest, OverwriteAt) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
for (int i = 0; i < kNewLength; ++i) { for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i; new_array[i] = 100 + i;
} }
int insert_position = 2; size_t insert_position = 2;
vec.OverwriteAt(new_array, kNewLength, insert_position); vec.OverwriteAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1, // {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
// |insert_position|, |insert_position| + 1, ..., kLength - 1}. // |insert_position|, |insert_position| + 1, ..., kLength - 1}.
int pos = 0; size_t pos = 0;
for (pos = 0; pos < insert_position; ++pos) { for (pos = 0; pos < insert_position; ++pos) {
EXPECT_EQ(this->array_[pos], vec[pos]); EXPECT_EQ(this->array_[pos], vec[pos]);
} }
@ -343,7 +343,7 @@ TYPED_TEST(AudioVectorTest, OverwriteAt) {
EXPECT_EQ(new_array[i], vec[pos]); EXPECT_EQ(new_array[i], vec[pos]);
++pos; ++pos;
} }
for (; pos < TestFixture::kLength; ++pos) { for (; pos < this->array_length(); ++pos) {
EXPECT_EQ(this->array_[pos], vec[pos]); EXPECT_EQ(this->array_[pos], vec[pos]);
} }
} }
@ -353,16 +353,16 @@ TYPED_TEST(AudioVectorTest, OverwriteAt) {
// expected to expand to accommodate the new values. // expected to expand to accommodate the new values.
TYPED_TEST(AudioVectorTest, OverwriteBeyondEnd) { TYPED_TEST(AudioVectorTest, OverwriteBeyondEnd) {
AudioVector<TypeParam> vec; AudioVector<TypeParam> vec;
vec.PushBack(this->array_, TestFixture::kLength); vec.PushBack(this->array_, this->array_length());
static const int kNewLength = 5; static const int kNewLength = 5;
TypeParam new_array[kNewLength]; TypeParam new_array[kNewLength];
// Set array elements to {100, 101, 102, ... }. // Set array elements to {100, 101, 102, ... }.
for (int i = 0; i < kNewLength; ++i) { for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i; new_array[i] = 100 + i;
} }
int insert_position = TestFixture::kLength - 2; int insert_position = this->array_length() - 2;
vec.OverwriteAt(new_array, kNewLength, insert_position); vec.OverwriteAt(new_array, kNewLength, insert_position);
ASSERT_EQ(TestFixture::kLength - 2u + kNewLength, vec.Size()); ASSERT_EQ(this->array_length() - 2u + kNewLength, vec.Size());
// Verify that the vector looks as follows: // Verify that the vector looks as follows:
// {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1, // {0, ..., |insert_position| - 1, 100, 101, ..., 100 + kNewLength - 1,
// |insert_position|, |insert_position| + 1, ..., kLength - 1}. // |insert_position|, |insert_position| + 1, ..., kLength - 1}.

View File

@ -215,6 +215,8 @@ void RemoteBitrateEstimatorTest::AddDefaultStream() {
0)); // RTCP receive time. 0)); // RTCP receive time.
} }
const unsigned int RemoteBitrateEstimatorTest::kDefaultSsrc = 1;
// Generates a frame of packets belonging to a stream at a given bitrate and // Generates a frame of packets belonging to a stream at a given bitrate and
// with a given ssrc. The stream is pushed through a very simple simulated // with a given ssrc. The stream is pushed through a very simple simulated
// network, and is then given to the receive-side bandwidth estimator. // network, and is then given to the receive-side bandwidth estimator.

View File

@ -186,7 +186,7 @@ class RemoteBitrateEstimatorTest : public ::testing::Test {
unsigned int max_bitrate, unsigned int max_bitrate,
unsigned int target_bitrate); unsigned int target_bitrate);
enum { kDefaultSsrc = 1 }; static const unsigned int kDefaultSsrc;
SimulatedClock clock_; // Time at the receiver. SimulatedClock clock_; // Time at the receiver.
OverUseDetectorOptions overuse_detector_options_; OverUseDetectorOptions overuse_detector_options_;

View File

@ -125,11 +125,10 @@ TEST_F(RtcpFormatRembTest, TestCompund) {
EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 2, SSRCs)); EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 2, SSRCs));
EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRemb)); EXPECT_EQ(0, rtcp_sender_->SendRTCP(kRtcpRemb));
} }
} // namespace
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
} // namespace

View File

@ -107,7 +107,7 @@ uint16_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const {
} }
// Add RTP extension header length. // Add RTP extension header length.
if (length > 0) { if (length > 0) {
length += RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES; length += kRtpOneByteHeaderLength;
} }
return length; return length;
} }
@ -120,7 +120,7 @@ int32_t RtpHeaderExtensionMap::GetLengthUntilBlockStartInBytes(
return -1; return -1;
} }
// Get length until start of extension block type. // Get length until start of extension block type.
uint16_t length = RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES; uint16_t length = kRtpOneByteHeaderLength;
std::map<uint8_t, HeaderExtension*>::const_iterator it = std::map<uint8_t, HeaderExtension*>::const_iterator it =
extensionMap_.begin(); extensionMap_.begin();

View File

@ -18,19 +18,17 @@
namespace webrtc { namespace webrtc {
enum {RTP_ONE_BYTE_HEADER_EXTENSION = 0xbede}; const uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
enum { const size_t kRtpOneByteHeaderLength = 4;
RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES = 4, const size_t kTransmissionTimeOffsetLength = 4;
TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES = 4
};
struct HeaderExtension { struct HeaderExtension {
HeaderExtension(RTPExtensionType extension_type) HeaderExtension(RTPExtensionType extension_type)
: type(extension_type), : type(extension_type),
length(0) { length(0) {
if (type == kRtpExtensionTransmissionTimeOffset) { if (type == kRtpExtensionTransmissionTimeOffset) {
length = TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES; length = kTransmissionTimeOffsetLength;
} }
} }
@ -69,4 +67,5 @@ class RtpHeaderExtensionMap {
std::map<uint8_t, HeaderExtension*> extensionMap_; std::map<uint8_t, HeaderExtension*> extensionMap_;
}; };
} }
#endif // WEBRTC_MODULES_RTP_RTCP_RTP_HEADER_EXTENSION_H_ #endif // WEBRTC_MODULES_RTP_RTCP_RTP_HEADER_EXTENSION_H_

View File

@ -27,9 +27,11 @@ class RtpHeaderExtensionTest : public ::testing::Test {
~RtpHeaderExtensionTest() {} ~RtpHeaderExtensionTest() {}
RtpHeaderExtensionMap map_; RtpHeaderExtensionMap map_;
enum {kId = 3}; static const uint8_t kId;
}; };
const uint8_t RtpHeaderExtensionTest::kId = 3;
TEST_F(RtpHeaderExtensionTest, Register) { TEST_F(RtpHeaderExtensionTest, Register) {
EXPECT_EQ(0, map_.Size()); EXPECT_EQ(0, map_.Size());
EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
@ -59,8 +61,7 @@ TEST_F(RtpHeaderExtensionTest, NonUniqueId) {
TEST_F(RtpHeaderExtensionTest, GetTotalLength) { TEST_F(RtpHeaderExtensionTest, GetTotalLength) {
EXPECT_EQ(0, map_.GetTotalLengthInBytes()); EXPECT_EQ(0, map_.GetTotalLengthInBytes());
EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
EXPECT_EQ(RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES + EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength,
TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES,
map_.GetTotalLengthInBytes()); map_.GetTotalLengthInBytes());
} }
@ -68,9 +69,9 @@ TEST_F(RtpHeaderExtensionTest, GetLengthUntilBlockStart) {
EXPECT_EQ(-1, map_.GetLengthUntilBlockStartInBytes( EXPECT_EQ(-1, map_.GetLengthUntilBlockStartInBytes(
kRtpExtensionTransmissionTimeOffset)); kRtpExtensionTransmissionTimeOffset));
EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
EXPECT_EQ(RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES, EXPECT_EQ(static_cast<int>(kRtpOneByteHeaderLength),
map_.GetLengthUntilBlockStartInBytes( map_.GetLengthUntilBlockStartInBytes(
kRtpExtensionTransmissionTimeOffset)); kRtpExtensionTransmissionTimeOffset));
} }
TEST_F(RtpHeaderExtensionTest, GetType) { TEST_F(RtpHeaderExtensionTest, GetType) {

View File

@ -849,11 +849,11 @@ uint16_t RTPSender::BuildRTPHeaderExtension(
// | .... | // | .... |
// //
const uint32_t kPosLength = 2; const uint32_t kPosLength = 2;
const uint32_t kHeaderLength = RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES; const uint32_t kHeaderLength = kRtpOneByteHeaderLength;
// Add extension ID (0xBEDE). // Add extension ID (0xBEDE).
ModuleRTPUtility::AssignUWord16ToBuffer(data_buffer, ModuleRTPUtility::AssignUWord16ToBuffer(data_buffer,
RTP_ONE_BYTE_HEADER_EXTENSION); kRtpOneByteHeaderExtensionId);
// Add extensions. // Add extensions.
uint16_t total_block_length = 0; uint16_t total_block_length = 0;
@ -906,14 +906,14 @@ uint8_t RTPSender::BuildTransmissionTimeOffsetExtension(
// Not registered. // Not registered.
return 0; return 0;
} }
int pos = 0; size_t pos = 0;
const uint8_t len = 2; const uint8_t len = 2;
data_buffer[pos++] = (id << 4) + len; data_buffer[pos++] = (id << 4) + len;
ModuleRTPUtility::AssignUWord24ToBuffer(data_buffer + pos, ModuleRTPUtility::AssignUWord24ToBuffer(data_buffer + pos,
transmission_time_offset_); transmission_time_offset_);
pos += 3; pos += 3;
assert(pos == TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES); assert(pos == kTransmissionTimeOffsetLength);
return TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES; return kTransmissionTimeOffsetLength;
} }
bool RTPSender::UpdateTransmissionTimeOffset( bool RTPSender::UpdateTransmissionTimeOffset(

View File

@ -27,7 +27,7 @@ namespace webrtc {
namespace { namespace {
const int kId = 1; const int kId = 1;
const int kTypeLength = TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES; const int kTypeLength = kTransmissionTimeOffsetLength;
const int kPayload = 100; const int kPayload = 100;
const uint32_t kTimestamp = 10; const uint32_t kTimestamp = 10;
const uint16_t kSeqNum = 33; const uint16_t kSeqNum = 33;
@ -92,7 +92,7 @@ class RtpSenderTest : public ::testing::Test {
TEST_F(RtpSenderTest, RegisterRtpHeaderExtension) { TEST_F(RtpSenderTest, RegisterRtpHeaderExtension) {
EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kType, kId)); EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kType, kId));
EXPECT_EQ(RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES + kTypeLength, EXPECT_EQ(kRtpOneByteHeaderLength + kTypeLength,
rtp_sender_->RtpHeaderExtensionTotalLength()); rtp_sender_->RtpHeaderExtensionTotalLength());
EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(kType)); EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(kType));
EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());

View File

@ -382,7 +382,7 @@ bool RTPHeaderParser::Parse(WebRtcRTPHeader& parsedPacket,
if (remain < (4 + XLen)) { if (remain < (4 + XLen)) {
return false; return false;
} }
if (definedByProfile == RTP_ONE_BYTE_HEADER_EXTENSION) { if (definedByProfile == kRtpOneByteHeaderExtensionId) {
const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen; const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen;
ParseOneByteExtensionHeader(parsedPacket, ParseOneByteExtensionHeader(parsedPacket,
ptrExtensionMap, ptrExtensionMap,

View File

@ -56,13 +56,12 @@ class LoopBackTransport : public webrtc::Transport {
class RtpReceiver : public RtpData { class RtpReceiver : public RtpData {
public: public:
enum { kMaxPayloadSize = 1500 };
virtual int32_t OnReceivedPayloadData( virtual int32_t OnReceivedPayloadData(
const uint8_t* payloadData, const uint8_t* payloadData,
const uint16_t payloadSize, const uint16_t payloadSize,
const webrtc::WebRtcRTPHeader* rtpHeader) { const webrtc::WebRtcRTPHeader* rtpHeader) {
EXPECT_LE(payloadSize, kMaxPayloadSize); EXPECT_LE(payloadSize, sizeof(_payloadData));
memcpy(_payloadData, payloadData, payloadSize); memcpy(_payloadData, payloadData, payloadSize);
memcpy(&_rtpHeader, rtpHeader, sizeof(_rtpHeader)); memcpy(&_rtpHeader, rtpHeader, sizeof(_rtpHeader));
_payloadSize = payloadSize; _payloadSize = payloadSize;
@ -82,7 +81,7 @@ class RtpReceiver : public RtpData {
} }
private: private:
uint8_t _payloadData[kMaxPayloadSize]; uint8_t _payloadData[1500];
uint16_t _payloadSize; uint16_t _payloadSize;
webrtc::WebRtcRTPHeader _rtpHeader; webrtc::WebRtcRTPHeader _rtpHeader;
}; };

View File

@ -50,9 +50,15 @@ int main() {
// FEC mask types. // FEC mask types.
const FecMaskType kMaskTypes[] = {kFecMaskRandom, kFecMaskBursty}; const FecMaskType kMaskTypes[] = {kFecMaskRandom, kFecMaskBursty};
const int kNumFecMaskTypes = sizeof(kMaskTypes) / sizeof(*kMaskTypes); const int kNumFecMaskTypes = sizeof(kMaskTypes) / sizeof(*kMaskTypes);
// TODO(pbos): Fix this. Hack to prevent a warning
// ('-Wunneeded-internal-declaration') from clang.
(void) kPacketMaskBurstyTbl;
// Maximum number of media packets allowed for the mask type. // Maximum number of media packets allowed for the mask type.
const uint16_t kMaxMediaPackets[] = {kMaxNumberMediaPackets, const uint16_t kMaxMediaPackets[] = {kMaxNumberMediaPackets,
sizeof(kPacketMaskBurstyTbl) / sizeof(*kPacketMaskBurstyTbl)}; sizeof(kPacketMaskBurstyTbl) / sizeof(*kPacketMaskBurstyTbl)};
if (kMaxMediaPackets[1] != 12) { if (kMaxMediaPackets[1] != 12) {
printf("ERROR: max media packets for bursty mode not equal to 12 \n"); printf("ERROR: max media packets for bursty mode not equal to 12 \n");
return -1; return -1;

View File

@ -17,31 +17,30 @@ using webrtc::ReferencePictureSelection;
// The minimum time between reference frame updates. Should match the values // The minimum time between reference frame updates. Should match the values
// set in reference_picture_selection.h // set in reference_picture_selection.h
enum { kMinUpdateInterval = 10 }; static const uint32_t kMinUpdateInterval = 10;
// The minimum time between decoder refreshes through restricted prediction. // The minimum time between decoder refreshes through restricted prediction.
// Should match the values set in reference_picture_selection.h // Should match the values set in reference_picture_selection.h
enum { kRtt = 10 }; static const int kRtt = 10;
static const int kNoPropagationGolden = VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
static const int kNoPropagationAltRef = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
static const int kPropagateGolden = VP8_EFLAG_FORCE_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_LAST;
static const int kPropagateAltRef = VP8_EFLAG_FORCE_ARF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_REF_LAST;
static const int kRefreshFromGolden = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_REF_ARF;
static const int kRefreshFromAltRef = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_REF_GF;
enum {
kNoPropagationGolden = VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF,
kNoPropagationAltRef = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF,
kPropagateGolden = VP8_EFLAG_FORCE_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_LAST,
kPropagateAltRef = VP8_EFLAG_FORCE_ARF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_REF_LAST,
kRefreshFromGolden = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_REF_ARF,
kRefreshFromAltRef = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_REF_GF
};
class TestRPS : public ::testing::Test { class TestRPS : public ::testing::Test {
protected: protected:

View File

@ -15,11 +15,9 @@
#include "module_common_types.h" #include "module_common_types.h"
#include "jitter_buffer_common.h" #include "jitter_buffer_common.h"
namespace webrtc namespace webrtc {
{
class VCMPacket class VCMPacket {
{
public: public:
VCMPacket(); VCMPacket();
VCMPacket(const uint8_t* ptr, VCMPacket(const uint8_t* ptr,

View File

@ -85,28 +85,28 @@ class TestVCMReceiver : public ::testing::Test {
TEST_F(TestVCMReceiver, RenderBufferSize_AllComplete) { TEST_F(TestVCMReceiver, RenderBufferSize_AllComplete) {
EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); EXPECT_EQ(0, receiver_.RenderBufferSizeMs());
EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError);
int num_of_frames = 10; size_t num_of_frames = 10;
for (int i = 0; i < num_of_frames; ++i) { for (size_t i = 0; i < num_of_frames; ++i) {
EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
} }
EXPECT_EQ(num_of_frames * kDefaultFramePeriodMs, EXPECT_EQ(static_cast<int>(num_of_frames * kDefaultFramePeriodMs),
receiver_.RenderBufferSizeMs()); receiver_.RenderBufferSizeMs());
} }
TEST_F(TestVCMReceiver, RenderBufferSize_NotAllComplete) { TEST_F(TestVCMReceiver, RenderBufferSize_NotAllComplete) {
EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); EXPECT_EQ(0, receiver_.RenderBufferSizeMs());
EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError);
int num_of_frames = 10; size_t num_of_frames = 10;
for (int i = 0; i < num_of_frames; ++i) { for (size_t i = 0; i < num_of_frames; ++i) {
EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
} }
num_of_frames++; num_of_frames++;
EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError); EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError);
for (int i = 0; i < num_of_frames; ++i) { for (size_t i = 0; i < num_of_frames; ++i) {
EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
} }
EXPECT_EQ(num_of_frames * kDefaultFramePeriodMs, EXPECT_EQ(static_cast<int>(num_of_frames * kDefaultFramePeriodMs),
receiver_.RenderBufferSizeMs()); receiver_.RenderBufferSizeMs());
} }
TEST_F(TestVCMReceiver, RenderBufferSize_NoKeyFrame) { TEST_F(TestVCMReceiver, RenderBufferSize_NoKeyFrame) {

View File

@ -19,34 +19,41 @@ namespace webrtc {
class TestSessionInfo : public ::testing::Test { class TestSessionInfo : public ::testing::Test {
protected: protected:
enum { kPacketBufferSize = 10 };
enum { kFrameBufferSize = 10 * kPacketBufferSize };
virtual void SetUp() { virtual void SetUp() {
memset(packet_buffer_, 0, kPacketBufferSize); memset(packet_buffer_, 0, sizeof(packet_buffer_));
memset(frame_buffer_, 0, kFrameBufferSize); memset(frame_buffer_, 0, sizeof(frame_buffer_));
session_.Reset(); session_.Reset();
packet_.Reset(); packet_.Reset();
packet_.frameType = kVideoFrameDelta; packet_.frameType = kVideoFrameDelta;
packet_.sizeBytes = kPacketBufferSize; packet_.sizeBytes = packet_buffer_size();
packet_.dataPtr = packet_buffer_; packet_.dataPtr = packet_buffer_;
packet_.seqNum = 0; packet_.seqNum = 0;
packet_.timestamp = 0; packet_.timestamp = 0;
} }
void FillPacket(uint8_t start_value) { void FillPacket(uint8_t start_value) {
for (int i = 0; i < kPacketBufferSize; ++i) for (int i = 0; i < packet_buffer_size(); ++i)
packet_buffer_[i] = start_value + i; packet_buffer_[i] = start_value + i;
} }
void VerifyPacket(uint8_t* start_ptr, uint8_t start_value) { void VerifyPacket(uint8_t* start_ptr, uint8_t start_value) {
for (int j = 0; j < kPacketBufferSize; ++j) { for (int j = 0; j < packet_buffer_size(); ++j) {
ASSERT_EQ(start_value + j, start_ptr[j]); ASSERT_EQ(start_value + j, start_ptr[j]);
} }
} }
int packet_buffer_size() const {
return sizeof(packet_buffer_) / sizeof(packet_buffer_[0]);
}
int frame_buffer_size() const {
return sizeof(frame_buffer_) / sizeof(frame_buffer_[0]);
}
enum { kPacketBufferSize = 10 };
uint8_t packet_buffer_[kPacketBufferSize]; uint8_t packet_buffer_[kPacketBufferSize];
uint8_t frame_buffer_[kFrameBufferSize]; uint8_t frame_buffer_[10 * kPacketBufferSize];
VCMSessionInfo session_; VCMSessionInfo session_;
VCMPacket packet_; VCMPacket packet_;
}; };
@ -67,12 +74,12 @@ class TestVP8Partitions : public TestSessionInfo {
bool VerifyPartition(int partition_id, bool VerifyPartition(int partition_id,
int packets_expected, int packets_expected,
int start_value) { int start_value) {
EXPECT_EQ(static_cast<uint32_t>(packets_expected * kPacketBufferSize), EXPECT_EQ(static_cast<uint32_t>(packets_expected * packet_buffer_size()),
fragmentation_.fragmentationLength[partition_id]); fragmentation_.fragmentationLength[partition_id]);
for (int i = 0; i < packets_expected; ++i) { for (int i = 0; i < packets_expected; ++i) {
int packet_index = fragmentation_.fragmentationOffset[partition_id] + int packet_index = fragmentation_.fragmentationOffset[partition_id] +
i * kPacketBufferSize; i * packet_buffer_size();
if (packet_index + kPacketBufferSize > kFrameBufferSize) if (packet_index + packet_buffer_size() > frame_buffer_size())
return false; return false;
VerifyPacket(frame_buffer_ + packet_index, start_value + i); VerifyPacket(frame_buffer_ + packet_index, start_value + i);
} }
@ -93,9 +100,9 @@ class TestNalUnits : public TestSessionInfo {
bool VerifyNalu(int offset, int packets_expected, int start_value) { bool VerifyNalu(int offset, int packets_expected, int start_value) {
EXPECT_GE(session_.SessionLength(), EXPECT_GE(session_.SessionLength(),
packets_expected * kPacketBufferSize); packets_expected * packet_buffer_size());
for (int i = 0; i < packets_expected; ++i) { for (int i = 0; i < packets_expected; ++i) {
int packet_index = offset * kPacketBufferSize + i * kPacketBufferSize; int packet_index = (offset + i) * packet_buffer_size();
VerifyPacket(frame_buffer_ + packet_index, start_value + i); VerifyPacket(frame_buffer_ + packet_index, start_value + i);
} }
return true; return true;
@ -104,7 +111,7 @@ class TestNalUnits : public TestSessionInfo {
class TestNackList : public TestSessionInfo { class TestNackList : public TestSessionInfo {
protected: protected:
enum { kMaxSeqNumListLength = 30 }; static const size_t kMaxSeqNumListLength = 30;
virtual void SetUp() { virtual void SetUp() {
TestSessionInfo::SetUp(); TestSessionInfo::SetUp();
@ -114,7 +121,7 @@ class TestNackList : public TestSessionInfo {
void BuildSeqNumList(uint16_t low, void BuildSeqNumList(uint16_t low,
uint16_t high) { uint16_t high) {
int i = 0; size_t i = 0;
while (low != high + 1) { while (low != high + 1) {
EXPECT_LT(i, kMaxSeqNumListLength); EXPECT_LT(i, kMaxSeqNumListLength);
if (i >= kMaxSeqNumListLength) { if (i >= kMaxSeqNumListLength) {
@ -140,10 +147,10 @@ class TestNackList : public TestSessionInfo {
TEST_F(TestSessionInfo, TestSimpleAPIs) { TEST_F(TestSessionInfo, TestSimpleAPIs) {
packet_.isFirstPacket = true; packet_.isFirstPacket = true;
packet_.seqNum = 0xFFFE; packet_.seqNum = 0xFFFE;
packet_.sizeBytes = kPacketBufferSize; packet_.sizeBytes = packet_buffer_size();
packet_.frameType = kVideoFrameKey; packet_.frameType = kVideoFrameKey;
FillPacket(0); FillPacket(0);
ASSERT_EQ(kPacketBufferSize, ASSERT_EQ(packet_buffer_size(),
session_.InsertPacket(packet_, frame_buffer_, false, 0)); session_.InsertPacket(packet_, frame_buffer_, false, 0));
EXPECT_FALSE(session_.HaveLastPacket()); EXPECT_FALSE(session_.HaveLastPacket());
EXPECT_EQ(kVideoFrameKey, session_.FrameType()); EXPECT_EQ(kVideoFrameKey, session_.FrameType());
@ -151,7 +158,7 @@ TEST_F(TestSessionInfo, TestSimpleAPIs) {
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.markerBit = true; packet_.markerBit = true;
packet_.seqNum += 1; packet_.seqNum += 1;
ASSERT_EQ(kPacketBufferSize, ASSERT_EQ(packet_buffer_size(),
session_.InsertPacket(packet_, frame_buffer_, false, 0)); session_.InsertPacket(packet_, frame_buffer_, false, 0));
EXPECT_TRUE(session_.HaveLastPacket()); EXPECT_TRUE(session_.HaveLastPacket());
EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber());
@ -175,27 +182,27 @@ TEST_F(TestSessionInfo, NormalOperation) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(0); FillPacket(0);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
for (int i = 1; i < 9; ++i) { for (int i = 1; i < 9; ++i) {
packet_.seqNum += 1; packet_.seqNum += 1;
FillPacket(i); FillPacket(i);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
} }
packet_.seqNum += 1; packet_.seqNum += 1;
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(9); FillPacket(9);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(0, session_.packets_not_decodable()); EXPECT_EQ(0, session_.packets_not_decodable());
EXPECT_EQ(10 * kPacketBufferSize, session_.SessionLength()); EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength());
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
SCOPED_TRACE("Calling VerifyPacket"); SCOPED_TRACE("Calling VerifyPacket");
VerifyPacket(frame_buffer_ + i * kPacketBufferSize, i); VerifyPacket(frame_buffer_ + i * packet_buffer_size(), i);
} }
} }
@ -208,10 +215,10 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0; packet_header_.header.sequenceNumber = 0;
FillPacket(0); FillPacket(0);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -220,9 +227,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 2; packet_header_.header.sequenceNumber += 2;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -231,16 +238,16 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(3); FillPacket(3);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// One packet should be removed (end of partition 0). // One packet should be removed (end of partition 0).
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
2*kPacketBufferSize); 2 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 1, 0)); EXPECT_TRUE(VerifyPartition(0, 1, 0));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -256,10 +263,10 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1; packet_header_.header.sequenceNumber = 1;
FillPacket(1); FillPacket(1);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0) ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
, kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -268,9 +275,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -279,9 +286,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(3); FillPacket(3);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -290,16 +297,16 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 2; packet_header_.header.sequenceNumber += 2;
FillPacket(5); FillPacket(5);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// One packet should be removed (end of partition 2), 3 left. // One packet should be removed (end of partition 2), 3 left.
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
3*kPacketBufferSize); 3 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1)); EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -316,10 +323,10 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0xfffd; packet_header_.header.sequenceNumber = 0xfffd;
FillPacket(0); FillPacket(0);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -328,9 +335,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(1); FillPacket(1);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -339,9 +346,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -350,16 +357,16 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(3); FillPacket(3);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// No packet should be removed. // No packet should be removed.
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
4*kPacketBufferSize); 4 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 0)); EXPECT_TRUE(VerifyPartition(0, 2, 0));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -376,10 +383,10 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0xfffd; packet_header_.header.sequenceNumber = 0xfffd;
FillPacket(0); FillPacket(0);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -388,9 +395,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(1); FillPacket(1);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -399,9 +406,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -410,16 +417,16 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 2; packet_header_.header.sequenceNumber += 2;
FillPacket(3); FillPacket(3);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// One packet should be removed from the last partition // One packet should be removed from the last partition
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
3*kPacketBufferSize); 3 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 0)); EXPECT_TRUE(VerifyPartition(0, 2, 0));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -437,10 +444,10 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1; packet_header_.header.sequenceNumber = 1;
FillPacket(1); FillPacket(1);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -449,9 +456,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -460,9 +467,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 3; packet_header_.header.sequenceNumber += 3;
FillPacket(5); FillPacket(5);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -471,16 +478,16 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(6); FillPacket(6);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// No packet should be removed. // No packet should be removed.
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
4*kPacketBufferSize); 4 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1)); EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -497,10 +504,10 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1; packet_header_.header.sequenceNumber = 1;
FillPacket(1); FillPacket(1);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -509,9 +516,10 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -520,9 +528,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 2; packet_header_.header.sequenceNumber += 2;
FillPacket(4); FillPacket(4);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -531,9 +539,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(5); FillPacket(5);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -542,9 +550,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(6); FillPacket(6);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -553,16 +561,16 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(7); FillPacket(7);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// 2 partitions left. 2 packets removed from second partition // 2 partitions left. 2 packets removed from second partition
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
4*kPacketBufferSize); 4 * packet_buffer_size());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1)); EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
@ -579,10 +587,10 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0; packet_header_.header.sequenceNumber = 0;
FillPacket(0); FillPacket(0);
VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
packet_header_); packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -591,9 +599,9 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) {
packet_header_.header.markerBit = false; packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(1); FillPacket(1);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
packet_header_.type.Video.isFirstPacket = false; packet_header_.type.Video.isFirstPacket = false;
@ -602,16 +610,16 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) {
packet_header_.header.markerBit = true; packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1; packet_header_.header.sequenceNumber += 1;
FillPacket(2); FillPacket(2);
packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
delete packet; delete packet;
// No packets removed. // No packets removed.
EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
kFrameBufferSize, frame_buffer_size(),
&fragmentation_), &fragmentation_),
3*kPacketBufferSize); 3 * packet_buffer_size());
EXPECT_EQ(0, session_.packets_not_decodable()); EXPECT_EQ(0, session_.packets_not_decodable());
SCOPED_TRACE("Calling VerifyPartition"); SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 0)); EXPECT_TRUE(VerifyPartition(0, 2, 0));
@ -643,7 +651,7 @@ TEST_F(TestNalUnits, OneIsolatedNaluLoss) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(0); FillPacket(0);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.completeNALU = kNaluComplete; packet_.completeNALU = kNaluComplete;
@ -651,10 +659,10 @@ TEST_F(TestNalUnits, OneIsolatedNaluLoss) {
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(2); FillPacket(2);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(0, session_.MakeDecodable()); EXPECT_EQ(0, session_.MakeDecodable());
EXPECT_EQ(2 * kPacketBufferSize, session_.SessionLength()); EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength());
EXPECT_EQ(0, session_.packets_not_decodable()); EXPECT_EQ(0, session_.packets_not_decodable());
SCOPED_TRACE("Calling VerifyNalu"); SCOPED_TRACE("Calling VerifyNalu");
EXPECT_TRUE(VerifyNalu(0, 1, 0)); EXPECT_TRUE(VerifyNalu(0, 1, 0));
@ -669,7 +677,7 @@ TEST_F(TestNalUnits, LossInMiddleOfNalu) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(0); FillPacket(0);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.completeNALU = kNaluEnd; packet_.completeNALU = kNaluEnd;
@ -677,10 +685,10 @@ TEST_F(TestNalUnits, LossInMiddleOfNalu) {
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(2); FillPacket(2);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(kPacketBufferSize, session_.MakeDecodable()); EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable());
EXPECT_EQ(kPacketBufferSize, session_.SessionLength()); EXPECT_EQ(packet_buffer_size(), session_.SessionLength());
EXPECT_EQ(1, session_.packets_not_decodable()); EXPECT_EQ(1, session_.packets_not_decodable());
SCOPED_TRACE("Calling VerifyNalu"); SCOPED_TRACE("Calling VerifyNalu");
EXPECT_TRUE(VerifyNalu(0, 1, 0)); EXPECT_TRUE(VerifyNalu(0, 1, 0));
@ -693,7 +701,7 @@ TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(0); FillPacket(0);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.completeNALU = kNaluIncomplete; packet_.completeNALU = kNaluIncomplete;
@ -701,10 +709,10 @@ TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(1); FillPacket(1);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(kPacketBufferSize, session_.MakeDecodable()); EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable());
EXPECT_EQ(kPacketBufferSize, session_.SessionLength()); EXPECT_EQ(packet_buffer_size(), session_.SessionLength());
EXPECT_EQ(1, session_.packets_not_decodable()); EXPECT_EQ(1, session_.packets_not_decodable());
SCOPED_TRACE("Calling VerifyNalu"); SCOPED_TRACE("Calling VerifyNalu");
EXPECT_TRUE(VerifyNalu(0, 1, 0)); EXPECT_TRUE(VerifyNalu(0, 1, 0));
@ -718,7 +726,7 @@ TEST_F(TestNalUnits, ReorderWrapNoLoss) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(1); FillPacket(1);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = true; packet_.isFirstPacket = true;
packet_.completeNALU = kNaluComplete; packet_.completeNALU = kNaluComplete;
@ -726,7 +734,7 @@ TEST_F(TestNalUnits, ReorderWrapNoLoss) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(0); FillPacket(0);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.completeNALU = kNaluEnd; packet_.completeNALU = kNaluEnd;
@ -734,11 +742,11 @@ TEST_F(TestNalUnits, ReorderWrapNoLoss) {
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(2); FillPacket(2);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(0, session_.MakeDecodable()); EXPECT_EQ(0, session_.MakeDecodable());
EXPECT_EQ(0, session_.packets_not_decodable()); EXPECT_EQ(0, session_.packets_not_decodable());
EXPECT_EQ(3*kPacketBufferSize, session_.SessionLength()); EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength());
SCOPED_TRACE("Calling VerifyNalu"); SCOPED_TRACE("Calling VerifyNalu");
EXPECT_TRUE(VerifyNalu(0, 1, 0)); EXPECT_TRUE(VerifyNalu(0, 1, 0));
} }
@ -750,7 +758,7 @@ TEST_F(TestNalUnits, WrapLosses) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(1); FillPacket(1);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
packet_.completeNALU = kNaluEnd; packet_.completeNALU = kNaluEnd;
@ -758,9 +766,9 @@ TEST_F(TestNalUnits, WrapLosses) {
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(2); FillPacket(2);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(2 * kPacketBufferSize, session_.MakeDecodable()); EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable());
EXPECT_EQ(0, session_.SessionLength()); EXPECT_EQ(0, session_.SessionLength());
EXPECT_EQ(2, session_.packets_not_decodable()); EXPECT_EQ(2, session_.packets_not_decodable());
} }
@ -774,7 +782,7 @@ TEST_F(TestNalUnits, ReorderWrapLosses) {
packet_.markerBit = true; packet_.markerBit = true;
FillPacket(2); FillPacket(2);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
packet_.seqNum -= 2; packet_.seqNum -= 2;
packet_.isFirstPacket = false; packet_.isFirstPacket = false;
@ -782,9 +790,9 @@ TEST_F(TestNalUnits, ReorderWrapLosses) {
packet_.markerBit = false; packet_.markerBit = false;
FillPacket(1); FillPacket(1);
ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0), ASSERT_EQ(session_.InsertPacket(packet_, frame_buffer_, false, 0),
kPacketBufferSize); packet_buffer_size());
EXPECT_EQ(2 * kPacketBufferSize, session_.MakeDecodable()); EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable());
EXPECT_EQ(0, session_.SessionLength()); EXPECT_EQ(0, session_.SessionLength());
EXPECT_EQ(2, session_.packets_not_decodable()); EXPECT_EQ(2, session_.packets_not_decodable());
} }

View File

@ -20,11 +20,11 @@
namespace webrtc { namespace webrtc {
const unsigned int kDefaultBitrateKbps = 1000; const unsigned int kDefaultBitrateKbps = 1000;
enum { kDefaultFrameRate = 25u }; const unsigned int kDefaultFrameRate = 25;
const unsigned int kMaxPacketSize = 1500; const unsigned int kMaxPacketSize = 1500;
const unsigned int kFrameSize = (kDefaultBitrateKbps + kDefaultFrameRate * 4) / const unsigned int kFrameSize = (kDefaultBitrateKbps + kDefaultFrameRate * 4) /
(kDefaultFrameRate * 8); (kDefaultFrameRate * 8);
enum { kDefaultFramePeriodMs = 1000u / kDefaultFrameRate }; const unsigned int kDefaultFramePeriodMs = 1000 / kDefaultFrameRate;

View File

@ -23,6 +23,7 @@
#include "engine_configurations.h" #include "engine_configurations.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "webrtc/system_wrappers/interface/sleep.h"
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
@ -189,21 +190,6 @@ private:
static char* log_str_; static char* log_str_;
}; };
// milliseconds #define AutoTestSleep webrtc::SleepMs
#if defined(_WIN32)
#define AutoTestSleep ::Sleep
#elif defined(WEBRTC_MAC)
#define AutoTestSleep(x) usleep(x * 1000)
#elif defined(WEBRTC_LINUX)
namespace {
void Sleep(unsigned long x) {
timespec t;
t.tv_sec = x/1000;
t.tv_nsec = (x-(x/1000)*1000)*1000000;
nanosleep(&t,NULL);
}
}
#define AutoTestSleep ::Sleep
#endif
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_ #endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_