| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 frame->inter_layer_predicted = inter_layer_predicted; | 128 frame->inter_layer_predicted = inter_layer_predicted; |
| 129 for (size_t r = 0; r < references.size(); ++r) | 129 for (size_t r = 0; r < references.size(); ++r) |
| 130 frame->references[r] = references[r]; | 130 frame->references[r] = references[r]; |
| 131 | 131 |
| 132 buffer_.InsertFrame(std::move(frame)); | 132 buffer_.InsertFrame(std::move(frame)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ExtractFrame(int64_t max_wait_time = 0) { | 135 void ExtractFrame(int64_t max_wait_time = 0) { |
| 136 crit_.Enter(); | 136 crit_.Enter(); |
| 137 if (max_wait_time == 0) { | 137 if (max_wait_time == 0) { |
| 138 frames_.emplace_back(buffer_.NextFrame(0)); | 138 auto frame = buffer_.NextFrame(0); |
| 139 if (frame.first != FrameBuffer::ReturnReason::kStopped) |
| 140 frames_.emplace_back(std::move(frame.second)); |
| 139 crit_.Leave(); | 141 crit_.Leave(); |
| 140 } else { | 142 } else { |
| 141 max_wait_time_ = max_wait_time; | 143 max_wait_time_ = max_wait_time; |
| 142 trigger_extract_event_.Set(); | 144 trigger_extract_event_.Set(); |
| 143 crit_.Leave(); | 145 crit_.Leave(); |
| 144 // Make sure |crit_| is aquired by |extract_thread_| before returning. | 146 // Make sure |crit_| is aquired by |extract_thread_| before returning. |
| 145 crit_acquired_event_.Wait(rtc::Event::kForever); | 147 crit_acquired_event_.Wait(rtc::Event::kForever); |
| 146 } | 148 } |
| 147 } | 149 } |
| 148 | 150 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 163 static bool ExtractLoop(void* obj) { | 165 static bool ExtractLoop(void* obj) { |
| 164 TestFrameBuffer2* tfb = static_cast<TestFrameBuffer2*>(obj); | 166 TestFrameBuffer2* tfb = static_cast<TestFrameBuffer2*>(obj); |
| 165 while (true) { | 167 while (true) { |
| 166 tfb->trigger_extract_event_.Wait(rtc::Event::kForever); | 168 tfb->trigger_extract_event_.Wait(rtc::Event::kForever); |
| 167 { | 169 { |
| 168 rtc::CritScope lock(&tfb->crit_); | 170 rtc::CritScope lock(&tfb->crit_); |
| 169 tfb->crit_acquired_event_.Set(); | 171 tfb->crit_acquired_event_.Set(); |
| 170 if (tfb->tear_down_) | 172 if (tfb->tear_down_) |
| 171 return false; | 173 return false; |
| 172 | 174 |
| 173 tfb->frames_.emplace_back(tfb->buffer_.NextFrame(tfb->max_wait_time_)); | 175 auto frame = tfb->buffer_.NextFrame(tfb->max_wait_time_); |
| 176 if (frame.first != FrameBuffer::ReturnReason::kStopped) |
| 177 tfb->frames_.emplace_back(std::move(frame.second)); |
| 174 } | 178 } |
| 175 } | 179 } |
| 176 } | 180 } |
| 177 | 181 |
| 178 uint32_t Rand() { return rand_.Rand<uint32_t>(); } | 182 uint32_t Rand() { return rand_.Rand<uint32_t>(); } |
| 179 | 183 |
| 180 SimulatedClock clock_; | 184 SimulatedClock clock_; |
| 181 VCMTimingFake timing_; | 185 VCMTimingFake timing_; |
| 182 ::testing::NiceMock<VCMJitterEstimatorMock> jitter_estimator_; | 186 ::testing::NiceMock<VCMJitterEstimatorMock> jitter_estimator_; |
| 183 FrameBuffer buffer_; | 187 FrameBuffer buffer_; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ExtractFrame(); | 350 ExtractFrame(); |
| 347 | 351 |
| 348 buffer_.SetProtectionMode(kProtectionNackFEC); | 352 buffer_.SetProtectionMode(kProtectionNackFEC); |
| 349 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0)); | 353 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0)); |
| 350 InsertFrame(pid + 1, 0, ts, false); | 354 InsertFrame(pid + 1, 0, ts, false); |
| 351 ExtractFrame(); | 355 ExtractFrame(); |
| 352 } | 356 } |
| 353 | 357 |
| 354 } // namespace video_coding | 358 } // namespace video_coding |
| 355 } // namespace webrtc | 359 } // namespace webrtc |
| OLD | NEW |