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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 OveruseFrameDetector::OnTargetFramerateUpdated(framerate_fps); | 82 OveruseFrameDetector::OnTargetFramerateUpdated(framerate_fps); |
83 } | 83 } |
84 | 84 |
85 int GetLastTargetFramerate() { | 85 int GetLastTargetFramerate() { |
86 rtc::CritScope cs(&lock_); | 86 rtc::CritScope cs(&lock_); |
87 return last_target_framerate_fps_; | 87 return last_target_framerate_fps_; |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 rtc::CriticalSection lock_; | 91 rtc::CriticalSection lock_; |
92 int last_target_framerate_fps_ GUARDED_BY(lock_); | 92 int last_target_framerate_fps_ RTC_GUARDED_BY(lock_); |
93 }; | 93 }; |
94 | 94 |
95 class VideoStreamEncoderUnderTest : public VideoStreamEncoder { | 95 class VideoStreamEncoderUnderTest : public VideoStreamEncoder { |
96 public: | 96 public: |
97 VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy, | 97 VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy, |
98 const VideoSendStream::Config::EncoderSettings& settings) | 98 const VideoSendStream::Config::EncoderSettings& settings) |
99 : VideoStreamEncoder( | 99 : VideoStreamEncoder( |
100 1 /* number_of_cores */, | 100 1 /* number_of_cores */, |
101 stats_proxy, | 101 stats_proxy, |
102 settings, | 102 settings, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, | 211 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
212 const rtc::VideoSinkWants& wants) override { | 212 const rtc::VideoSinkWants& wants) override { |
213 rtc::CritScope cs(&crit_); | 213 rtc::CritScope cs(&crit_); |
214 last_wants_ = sink_wants(); | 214 last_wants_ = sink_wants(); |
215 adapter_.OnResolutionFramerateRequest(wants.target_pixel_count, | 215 adapter_.OnResolutionFramerateRequest(wants.target_pixel_count, |
216 wants.max_pixel_count, | 216 wants.max_pixel_count, |
217 wants.max_framerate_fps); | 217 wants.max_framerate_fps); |
218 test::FrameForwarder::AddOrUpdateSink(sink, wants); | 218 test::FrameForwarder::AddOrUpdateSink(sink, wants); |
219 } | 219 } |
220 cricket::VideoAdapter adapter_; | 220 cricket::VideoAdapter adapter_; |
221 bool adaptation_enabled_ GUARDED_BY(crit_); | 221 bool adaptation_enabled_ RTC_GUARDED_BY(crit_); |
222 rtc::VideoSinkWants last_wants_ GUARDED_BY(crit_); | 222 rtc::VideoSinkWants last_wants_ RTC_GUARDED_BY(crit_); |
223 }; | 223 }; |
224 | 224 |
225 class MockableSendStatisticsProxy : public SendStatisticsProxy { | 225 class MockableSendStatisticsProxy : public SendStatisticsProxy { |
226 public: | 226 public: |
227 MockableSendStatisticsProxy(Clock* clock, | 227 MockableSendStatisticsProxy(Clock* clock, |
228 const VideoSendStream::Config& config, | 228 const VideoSendStream::Config& config, |
229 VideoEncoderConfig::ContentType content_type) | 229 VideoEncoderConfig::ContentType content_type) |
230 : SendStatisticsProxy(clock, config, content_type) {} | 230 : SendStatisticsProxy(clock, config, content_type) {} |
231 | 231 |
232 VideoSendStream::Stats GetStats() override { | 232 VideoSendStream::Stats GetStats() override { |
233 rtc::CritScope cs(&lock_); | 233 rtc::CritScope cs(&lock_); |
234 if (mock_stats_) | 234 if (mock_stats_) |
235 return *mock_stats_; | 235 return *mock_stats_; |
236 return SendStatisticsProxy::GetStats(); | 236 return SendStatisticsProxy::GetStats(); |
237 } | 237 } |
238 | 238 |
239 void SetMockStats(const VideoSendStream::Stats& stats) { | 239 void SetMockStats(const VideoSendStream::Stats& stats) { |
240 rtc::CritScope cs(&lock_); | 240 rtc::CritScope cs(&lock_); |
241 mock_stats_.emplace(stats); | 241 mock_stats_.emplace(stats); |
242 } | 242 } |
243 | 243 |
244 void ResetMockStats() { | 244 void ResetMockStats() { |
245 rtc::CritScope cs(&lock_); | 245 rtc::CritScope cs(&lock_); |
246 mock_stats_.reset(); | 246 mock_stats_.reset(); |
247 } | 247 } |
248 | 248 |
249 private: | 249 private: |
250 rtc::CriticalSection lock_; | 250 rtc::CriticalSection lock_; |
251 rtc::Optional<VideoSendStream::Stats> mock_stats_ GUARDED_BY(lock_); | 251 rtc::Optional<VideoSendStream::Stats> mock_stats_ RTC_GUARDED_BY(lock_); |
252 }; | 252 }; |
253 | 253 |
254 class MockBitrateObserver : public VideoBitrateAllocationObserver { | 254 class MockBitrateObserver : public VideoBitrateAllocationObserver { |
255 public: | 255 public: |
256 MOCK_METHOD1(OnBitrateAllocationUpdated, void(const BitrateAllocation&)); | 256 MOCK_METHOD1(OnBitrateAllocationUpdated, void(const BitrateAllocation&)); |
257 }; | 257 }; |
258 | 258 |
259 } // namespace | 259 } // namespace |
260 | 260 |
261 class VideoStreamEncoderTest : public ::testing::Test { | 261 class VideoStreamEncoderTest : public ::testing::Test { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 allocated_temporal_layers_.emplace_back( | 544 allocated_temporal_layers_.emplace_back( |
545 config->VP8().tl_factory->Create(i, num_temporal_layers, 42)); | 545 config->VP8().tl_factory->Create(i, num_temporal_layers, 42)); |
546 } | 546 } |
547 } | 547 } |
548 if (force_init_encode_failed_) | 548 if (force_init_encode_failed_) |
549 return -1; | 549 return -1; |
550 return res; | 550 return res; |
551 } | 551 } |
552 | 552 |
553 rtc::CriticalSection local_crit_sect_; | 553 rtc::CriticalSection local_crit_sect_; |
554 bool block_next_encode_ GUARDED_BY(local_crit_sect_) = false; | 554 bool block_next_encode_ RTC_GUARDED_BY(local_crit_sect_) = false; |
555 rtc::Event continue_encode_event_; | 555 rtc::Event continue_encode_event_; |
556 uint32_t timestamp_ GUARDED_BY(local_crit_sect_) = 0; | 556 uint32_t timestamp_ RTC_GUARDED_BY(local_crit_sect_) = 0; |
557 int64_t ntp_time_ms_ GUARDED_BY(local_crit_sect_) = 0; | 557 int64_t ntp_time_ms_ RTC_GUARDED_BY(local_crit_sect_) = 0; |
558 int last_input_width_ GUARDED_BY(local_crit_sect_) = 0; | 558 int last_input_width_ RTC_GUARDED_BY(local_crit_sect_) = 0; |
559 int last_input_height_ GUARDED_BY(local_crit_sect_) = 0; | 559 int last_input_height_ RTC_GUARDED_BY(local_crit_sect_) = 0; |
560 bool quality_scaling_ GUARDED_BY(local_crit_sect_) = true; | 560 bool quality_scaling_ RTC_GUARDED_BY(local_crit_sect_) = true; |
561 std::vector<std::unique_ptr<TemporalLayers>> allocated_temporal_layers_ | 561 std::vector<std::unique_ptr<TemporalLayers>> allocated_temporal_layers_ |
562 GUARDED_BY(local_crit_sect_); | 562 RTC_GUARDED_BY(local_crit_sect_); |
563 bool force_init_encode_failed_ GUARDED_BY(local_crit_sect_) = false; | 563 bool force_init_encode_failed_ RTC_GUARDED_BY(local_crit_sect_) = false; |
564 }; | 564 }; |
565 | 565 |
566 class TestSink : public VideoStreamEncoder::EncoderSink { | 566 class TestSink : public VideoStreamEncoder::EncoderSink { |
567 public: | 567 public: |
568 explicit TestSink(TestEncoder* test_encoder) | 568 explicit TestSink(TestEncoder* test_encoder) |
569 : test_encoder_(test_encoder), encoded_frame_event_(false, false) {} | 569 : test_encoder_(test_encoder), encoded_frame_event_(false, false) {} |
570 | 570 |
571 void WaitForEncodedFrame(int64_t expected_ntp_time) { | 571 void WaitForEncodedFrame(int64_t expected_ntp_time) { |
572 EXPECT_TRUE( | 572 EXPECT_TRUE( |
573 TimedWaitForEncodedFrame(expected_ntp_time, kDefaultTimeoutMs)); | 573 TimedWaitForEncodedFrame(expected_ntp_time, kDefaultTimeoutMs)); |
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 // Bitrate observer should not be called. | 3271 // Bitrate observer should not be called. |
3272 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); | 3272 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); |
3273 video_source_.IncomingCapturedFrame( | 3273 video_source_.IncomingCapturedFrame( |
3274 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); | 3274 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
3275 ExpectDroppedFrame(); | 3275 ExpectDroppedFrame(); |
3276 | 3276 |
3277 video_stream_encoder_->Stop(); | 3277 video_stream_encoder_->Stop(); |
3278 } | 3278 } |
3279 | 3279 |
3280 } // namespace webrtc | 3280 } // namespace webrtc |
OLD | NEW |