| OLD | NEW |
| 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 2 * | 2 * |
| 3 * Use of this source code is governed by a BSD-style license | 3 * Use of this source code is governed by a BSD-style license |
| 4 * that can be found in the LICENSE file in the root of the source | 4 * that can be found in the LICENSE file in the root of the source |
| 5 * tree. An additional intellectual property rights grant can be found | 5 * tree. An additional intellectual property rights grant can be found |
| 6 * in the file PATENTS. All contributing project authors may | 6 * in the file PATENTS. All contributing project authors may |
| 7 * be found in the AUTHORS file in the root of the source tree. | 7 * be found in the AUTHORS file in the root of the source tree. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 std::unique_ptr<SimulatedClock> clock_; | 88 std::unique_ptr<SimulatedClock> clock_; |
| 89 VCMTiming timing_; | 89 VCMTiming timing_; |
| 90 NullEventFactory event_factory_; | 90 NullEventFactory event_factory_; |
| 91 VCMReceiver receiver_; | 91 VCMReceiver receiver_; |
| 92 std::unique_ptr<StreamGenerator> stream_generator_; | 92 std::unique_ptr<StreamGenerator> stream_generator_; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 TEST_F(TestVCMReceiver, RenderBufferSize_AllComplete) { | |
| 96 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); | |
| 97 EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); | |
| 98 int num_of_frames = 10; | |
| 99 for (int i = 0; i < num_of_frames; ++i) { | |
| 100 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 101 } | |
| 102 EXPECT_EQ(num_of_frames * kDefaultFramePeriodMs, | |
| 103 receiver_.RenderBufferSizeMs()); | |
| 104 } | |
| 105 | |
| 106 TEST_F(TestVCMReceiver, RenderBufferSize_SkipToKeyFrame) { | |
| 107 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); | |
| 108 const int kNumOfNonDecodableFrames = 2; | |
| 109 for (int i = 0; i < kNumOfNonDecodableFrames; ++i) { | |
| 110 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 111 } | |
| 112 const int kNumOfFrames = 10; | |
| 113 EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); | |
| 114 for (int i = 0; i < kNumOfFrames - 1; ++i) { | |
| 115 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 116 } | |
| 117 EXPECT_EQ((kNumOfFrames - 1) * kDefaultFramePeriodMs, | |
| 118 receiver_.RenderBufferSizeMs()); | |
| 119 } | |
| 120 | |
| 121 TEST_F(TestVCMReceiver, RenderBufferSize_NotAllComplete) { | |
| 122 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); | |
| 123 EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); | |
| 124 int num_of_frames = 10; | |
| 125 for (int i = 0; i < num_of_frames; ++i) { | |
| 126 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 127 } | |
| 128 num_of_frames++; | |
| 129 EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError); | |
| 130 for (int i = 0; i < num_of_frames; ++i) { | |
| 131 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 132 } | |
| 133 EXPECT_EQ((num_of_frames - 1) * kDefaultFramePeriodMs, | |
| 134 receiver_.RenderBufferSizeMs()); | |
| 135 } | |
| 136 | |
| 137 TEST_F(TestVCMReceiver, RenderBufferSize_NoKeyFrame) { | |
| 138 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); | |
| 139 int num_of_frames = 10; | |
| 140 for (int i = 0; i < num_of_frames; ++i) { | |
| 141 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 142 } | |
| 143 int64_t next_render_time_ms = 0; | |
| 144 VCMEncodedFrame* frame = | |
| 145 receiver_.FrameForDecoding(10, &next_render_time_ms, false); | |
| 146 EXPECT_TRUE(frame == NULL); | |
| 147 receiver_.ReleaseFrame(frame); | |
| 148 EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError); | |
| 149 for (int i = 0; i < num_of_frames; ++i) { | |
| 150 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); | |
| 151 } | |
| 152 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); | |
| 153 } | |
| 154 | |
| 155 TEST_F(TestVCMReceiver, NonDecodableDuration_Empty) { | 95 TEST_F(TestVCMReceiver, NonDecodableDuration_Empty) { |
| 156 // Enable NACK and with no RTT thresholds for disabling retransmission delay. | 96 // Enable NACK and with no RTT thresholds for disabling retransmission delay. |
| 157 receiver_.SetNackMode(kNack, -1, -1); | 97 receiver_.SetNackMode(kNack, -1, -1); |
| 158 const size_t kMaxNackListSize = 1000; | 98 const size_t kMaxNackListSize = 1000; |
| 159 const int kMaxPacketAgeToNack = 1000; | 99 const int kMaxPacketAgeToNack = 1000; |
| 160 const int kMaxNonDecodableDuration = 500; | 100 const int kMaxNonDecodableDuration = 500; |
| 161 const int kMinDelayMs = 500; | 101 const int kMinDelayMs = 500; |
| 162 receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, | 102 receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, |
| 163 kMaxNonDecodableDuration); | 103 kMaxNonDecodableDuration); |
| 164 EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); | 104 EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 end_time); | 507 end_time); |
| 568 receiver_.ReleaseFrame(frame); | 508 receiver_.ReleaseFrame(frame); |
| 569 ++num_frames_return; | 509 ++num_frames_return; |
| 570 } else { | 510 } else { |
| 571 EXPECT_EQ(kMaxWaitTime, end_time - start_time); | 511 EXPECT_EQ(kMaxWaitTime, end_time - start_time); |
| 572 } | 512 } |
| 573 } | 513 } |
| 574 } | 514 } |
| 575 | 515 |
| 576 } // namespace webrtc | 516 } // namespace webrtc |
| OLD | NEW |