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 "media/video/capture/screen/mouse_cursor_shape.h" | |
18 #include "media/video/capture/screen/screen_capturer.h" | |
19 #include "remoting/proto/control.pb.h" | 17 #include "remoting/proto/control.pb.h" |
20 #include "remoting/proto/internal.pb.h" | 18 #include "remoting/proto/internal.pb.h" |
21 #include "remoting/proto/video.pb.h" | 19 #include "remoting/proto/video.pb.h" |
22 #include "remoting/protocol/cursor_shape_stub.h" | 20 #include "remoting/protocol/cursor_shape_stub.h" |
23 #include "remoting/protocol/message_decoder.h" | 21 #include "remoting/protocol/message_decoder.h" |
| 22 #include "remoting/protocol/util.h" |
24 #include "remoting/protocol/video_stub.h" | 23 #include "remoting/protocol/video_stub.h" |
25 #include "remoting/protocol/util.h" | |
26 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 24 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 25 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" |
| 26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 | 29 |
30 // Maximum number of frames that can be processed simultaneously. | 30 // Maximum number of frames that can be processed simultaneously. |
31 // TODO(hclam): Move this value to CaptureScheduler. | 31 // TODO(hclam): Move this value to CaptureScheduler. |
32 static const int kMaxPendingFrames = 2; | 32 static const int kMaxPendingFrames = 2; |
33 | 33 |
34 VideoScheduler::VideoScheduler( | 34 VideoScheduler::VideoScheduler( |
35 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 35 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
36 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
38 scoped_ptr<media::ScreenCapturer> capturer, | 38 scoped_ptr<webrtc::ScreenCapturer> capturer, |
39 scoped_ptr<VideoEncoder> encoder, | 39 scoped_ptr<VideoEncoder> encoder, |
40 protocol::CursorShapeStub* cursor_stub, | 40 protocol::CursorShapeStub* cursor_stub, |
41 protocol::VideoStub* video_stub) | 41 protocol::VideoStub* video_stub) |
42 : capture_task_runner_(capture_task_runner), | 42 : capture_task_runner_(capture_task_runner), |
43 encode_task_runner_(encode_task_runner), | 43 encode_task_runner_(encode_task_runner), |
44 network_task_runner_(network_task_runner), | 44 network_task_runner_(network_task_runner), |
45 capturer_(capturer.Pass()), | 45 capturer_(capturer.Pass()), |
46 encoder_(encoder.Pass()), | 46 encoder_(encoder.Pass()), |
47 cursor_stub_(cursor_stub), | 47 cursor_stub_(cursor_stub), |
48 video_stub_(video_stub), | 48 video_stub_(video_stub), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::Passed(&owned_frame), sequence_number_)); | 81 base::Passed(&owned_frame), sequence_number_)); |
82 | 82 |
83 // If a frame was skipped, try to capture it again. | 83 // If a frame was skipped, try to capture it again. |
84 if (did_skip_frame_) { | 84 if (did_skip_frame_) { |
85 capture_task_runner_->PostTask( | 85 capture_task_runner_->PostTask( |
86 FROM_HERE, base::Bind(&VideoScheduler::CaptureNextFrame, this)); | 86 FROM_HERE, base::Bind(&VideoScheduler::CaptureNextFrame, this)); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void VideoScheduler::OnCursorShapeChanged( | 90 void VideoScheduler::OnCursorShapeChanged( |
91 scoped_ptr<media::MouseCursorShape> cursor_shape) { | 91 webrtc::MouseCursorShape* cursor_shape) { |
92 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 92 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
93 | 93 |
| 94 scoped_ptr<webrtc::MouseCursorShape> owned_cursor(cursor_shape); |
| 95 |
94 // Do nothing if the scheduler is being stopped. | 96 // Do nothing if the scheduler is being stopped. |
95 if (!capturer_) | 97 if (!capturer_) |
96 return; | 98 return; |
97 | 99 |
98 scoped_ptr<protocol::CursorShapeInfo> cursor_proto( | 100 scoped_ptr<protocol::CursorShapeInfo> cursor_proto( |
99 new protocol::CursorShapeInfo()); | 101 new protocol::CursorShapeInfo()); |
100 cursor_proto->set_width(cursor_shape->size.width()); | 102 cursor_proto->set_width(cursor_shape->size.width()); |
101 cursor_proto->set_height(cursor_shape->size.height()); | 103 cursor_proto->set_height(cursor_shape->size.height()); |
102 cursor_proto->set_hotspot_x(cursor_shape->hotspot.x()); | 104 cursor_proto->set_hotspot_x(cursor_shape->hotspot.x()); |
103 cursor_proto->set_hotspot_y(cursor_shape->hotspot.y()); | 105 cursor_proto->set_hotspot_y(cursor_shape->hotspot.y()); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 scheduler_.RecordEncodeTime( | 313 scheduler_.RecordEncodeTime( |
312 base::TimeDelta::FromMilliseconds(packet->encode_time_ms())); | 314 base::TimeDelta::FromMilliseconds(packet->encode_time_ms())); |
313 } | 315 } |
314 | 316 |
315 network_task_runner_->PostTask( | 317 network_task_runner_->PostTask( |
316 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this, | 318 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this, |
317 base::Passed(&packet))); | 319 base::Passed(&packet))); |
318 } | 320 } |
319 | 321 |
320 } // namespace remoting | 322 } // namespace remoting |
OLD | NEW |