| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "remoting/base/capture_data.h" | 17 #include "remoting/capturer/capture_data.h" |
| 18 #include "remoting/host/video_frame_capturer.h" | 18 #include "remoting/capturer/mouse_cursor_shape.h" |
| 19 #include "remoting/capturer/video_frame_capturer.h" |
| 19 #include "remoting/proto/control.pb.h" | 20 #include "remoting/proto/control.pb.h" |
| 20 #include "remoting/proto/internal.pb.h" | 21 #include "remoting/proto/internal.pb.h" |
| 21 #include "remoting/proto/video.pb.h" | 22 #include "remoting/proto/video.pb.h" |
| 22 #include "remoting/protocol/client_stub.h" | 23 #include "remoting/protocol/client_stub.h" |
| 23 #include "remoting/protocol/message_decoder.h" | 24 #include "remoting/protocol/message_decoder.h" |
| 24 #include "remoting/protocol/video_stub.h" | 25 #include "remoting/protocol/video_stub.h" |
| 25 #include "remoting/protocol/util.h" | 26 #include "remoting/protocol/util.h" |
| 26 | 27 |
| 27 namespace remoting { | 28 namespace remoting { |
| 28 | 29 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // accurate as long as capture is synchronous as the following statement | 71 // accurate as long as capture is synchronous as the following statement |
| 71 // will obtain the most recent sequence number received. | 72 // will obtain the most recent sequence number received. |
| 72 capture_data->set_client_sequence_number(sequence_number_); | 73 capture_data->set_client_sequence_number(sequence_number_); |
| 73 } | 74 } |
| 74 | 75 |
| 75 encode_task_runner_->PostTask( | 76 encode_task_runner_->PostTask( |
| 76 FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this, capture_data)); | 77 FROM_HERE, base::Bind(&VideoScheduler::EncodeFrame, this, capture_data)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void VideoScheduler::OnCursorShapeChanged( | 80 void VideoScheduler::OnCursorShapeChanged( |
| 80 scoped_ptr<protocol::CursorShapeInfo> cursor_shape) { | 81 scoped_ptr<MouseCursorShape> cursor_shape) { |
| 81 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 82 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
| 82 | 83 |
| 84 scoped_ptr<protocol::CursorShapeInfo> cursor_proto( |
| 85 new protocol::CursorShapeInfo()); |
| 86 cursor_proto->set_width(cursor_shape->size.width()); |
| 87 cursor_proto->set_height(cursor_shape->size.height()); |
| 88 cursor_proto->set_hotspot_x(cursor_shape->hotspot.x()); |
| 89 cursor_proto->set_hotspot_y(cursor_shape->hotspot.y()); |
| 90 cursor_proto->set_data(cursor_shape->data); |
| 91 |
| 83 network_task_runner_->PostTask( | 92 network_task_runner_->PostTask( |
| 84 FROM_HERE, base::Bind(&VideoScheduler::SendCursorShape, this, | 93 FROM_HERE, base::Bind(&VideoScheduler::SendCursorShape, this, |
| 85 base::Passed(&cursor_shape))); | 94 base::Passed(&cursor_proto))); |
| 86 } | 95 } |
| 87 | 96 |
| 88 void VideoScheduler::Stop(const base::Closure& done_task) { | 97 void VideoScheduler::Stop(const base::Closure& done_task) { |
| 89 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 98 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 90 DCHECK(!done_task.is_null()); | 99 DCHECK(!done_task.is_null()); |
| 91 | 100 |
| 92 // Clear stubs to prevent further updates reaching the client. | 101 // Clear stubs to prevent further updates reaching the client. |
| 93 cursor_stub_ = NULL; | 102 cursor_stub_ = NULL; |
| 94 video_stub_ = NULL; | 103 video_stub_ = NULL; |
| 95 | 104 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 316 |
| 308 void VideoScheduler::StopOnEncodeThread(const base::Closure& done_task) { | 317 void VideoScheduler::StopOnEncodeThread(const base::Closure& done_task) { |
| 309 DCHECK(encode_task_runner_->BelongsToCurrentThread()); | 318 DCHECK(encode_task_runner_->BelongsToCurrentThread()); |
| 310 | 319 |
| 311 // This is posted by StopOnCaptureThread, so we know that by the time we | 320 // This is posted by StopOnCaptureThread, so we know that by the time we |
| 312 // process it there are no more encode tasks queued. | 321 // process it there are no more encode tasks queued. |
| 313 network_task_runner_->PostTask(FROM_HERE, done_task); | 322 network_task_runner_->PostTask(FROM_HERE, done_task); |
| 314 } | 323 } |
| 315 | 324 |
| 316 } // namespace remoting | 325 } // namespace remoting |
| OLD | NEW |