| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/video_scheduler.h" | 5 #include "remoting/host/video_scheduler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 webrtc::DesktopCapturer::Callback* capturer_callback_; | 162 webrtc::DesktopCapturer::Callback* capturer_callback_; |
| 163 | 163 |
| 164 // Points to the callback passed to webrtc::MouseCursor::Init(). | 164 // Points to the callback passed to webrtc::MouseCursor::Init(). |
| 165 webrtc::MouseCursorMonitor::Callback* mouse_monitor_callback_; | 165 webrtc::MouseCursorMonitor::Callback* mouse_monitor_callback_; |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 DISALLOW_COPY_AND_ASSIGN(VideoSchedulerTest); | 168 DISALLOW_COPY_AND_ASSIGN(VideoSchedulerTest); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 VideoSchedulerTest::VideoSchedulerTest() | 171 VideoSchedulerTest::VideoSchedulerTest() |
| 172 : capturer_callback_(NULL), | 172 : capturer_callback_(nullptr), |
| 173 mouse_monitor_callback_(NULL) { | 173 mouse_monitor_callback_(nullptr) { |
| 174 } | 174 } |
| 175 | 175 |
| 176 void VideoSchedulerTest::SetUp() { | 176 void VideoSchedulerTest::SetUp() { |
| 177 main_task_runner_ = new AutoThreadTaskRunner( | 177 main_task_runner_ = new AutoThreadTaskRunner( |
| 178 message_loop_.message_loop_proxy(), run_loop_.QuitClosure()); | 178 message_loop_.message_loop_proxy(), run_loop_.QuitClosure()); |
| 179 capture_task_runner_ = main_task_runner_; | 179 capture_task_runner_ = main_task_runner_; |
| 180 encode_task_runner_ = main_task_runner_; | 180 encode_task_runner_ = main_task_runner_; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void VideoSchedulerTest::TearDown() { | 183 void VideoSchedulerTest::TearDown() { |
| 184 // Release the task runners, so that the test can quit. | 184 // Release the task runners, so that the test can quit. |
| 185 capture_task_runner_ = NULL; | 185 capture_task_runner_ = nullptr; |
| 186 encode_task_runner_ = NULL; | 186 encode_task_runner_ = nullptr; |
| 187 main_task_runner_ = NULL; | 187 main_task_runner_ = nullptr; |
| 188 | 188 |
| 189 // Run the MessageLoop until everything has torn down. | 189 // Run the MessageLoop until everything has torn down. |
| 190 run_loop_.Run(); | 190 run_loop_.Run(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void VideoSchedulerTest::StartVideoScheduler( | 193 void VideoSchedulerTest::StartVideoScheduler( |
| 194 scoped_ptr<webrtc::DesktopCapturer> capturer, | 194 scoped_ptr<webrtc::DesktopCapturer> capturer, |
| 195 scoped_ptr<VideoEncoder> encoder, | 195 scoped_ptr<VideoEncoder> encoder, |
| 196 scoped_ptr<webrtc::MouseCursorMonitor> mouse_monitor) { | 196 scoped_ptr<webrtc::MouseCursorMonitor> mouse_monitor) { |
| 197 scheduler_ = new VideoScheduler( | 197 scheduler_ = new VideoScheduler( |
| 198 capture_task_runner_, | 198 capture_task_runner_, |
| 199 encode_task_runner_, | 199 encode_task_runner_, |
| 200 main_task_runner_, | 200 main_task_runner_, |
| 201 capturer.Pass(), | 201 capturer.Pass(), |
| 202 mouse_monitor.Pass(), | 202 mouse_monitor.Pass(), |
| 203 encoder.Pass(), | 203 encoder.Pass(), |
| 204 &client_stub_, | 204 &client_stub_, |
| 205 &video_stub_); | 205 &video_stub_); |
| 206 scheduler_->Start(); | 206 scheduler_->Start(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void VideoSchedulerTest::StopVideoScheduler() { | 209 void VideoSchedulerTest::StopVideoScheduler() { |
| 210 scheduler_->Stop(); | 210 scheduler_->Stop(); |
| 211 scheduler_ = NULL; | 211 scheduler_ = nullptr; |
| 212 } | 212 } |
| 213 | 213 |
| 214 void VideoSchedulerTest::OnCapturerStart( | 214 void VideoSchedulerTest::OnCapturerStart( |
| 215 webrtc::DesktopCapturer::Callback* callback) { | 215 webrtc::DesktopCapturer::Callback* callback) { |
| 216 EXPECT_FALSE(capturer_callback_); | 216 EXPECT_FALSE(capturer_callback_); |
| 217 EXPECT_TRUE(callback); | 217 EXPECT_TRUE(callback); |
| 218 | 218 |
| 219 capturer_callback_ = callback; | 219 capturer_callback_ = callback; |
| 220 } | 220 } |
| 221 | 221 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 new ThreadCheckMouseCursorMonitor(capture_task_runner_)); | 338 new ThreadCheckMouseCursorMonitor(capture_task_runner_)); |
| 339 | 339 |
| 340 // Start and stop the scheduler, so it will tear down the screen capturer, | 340 // Start and stop the scheduler, so it will tear down the screen capturer, |
| 341 // video encoder and mouse monitor. | 341 // video encoder and mouse monitor. |
| 342 StartVideoScheduler(capturer.Pass(), encoder.Pass(), | 342 StartVideoScheduler(capturer.Pass(), encoder.Pass(), |
| 343 mouse_cursor_monitor.Pass()); | 343 mouse_cursor_monitor.Pass()); |
| 344 StopVideoScheduler(); | 344 StopVideoScheduler(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace remoting | 347 } // namespace remoting |
| OLD | NEW |