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/screen_recorder.h" | 5 #include "remoting/host/screen_recorder.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/base/capture_data.h" |
| 18 #include "remoting/host/video_frame_capturer.h" |
18 #include "remoting/proto/control.pb.h" | 19 #include "remoting/proto/control.pb.h" |
19 #include "remoting/proto/internal.pb.h" | 20 #include "remoting/proto/internal.pb.h" |
20 #include "remoting/proto/video.pb.h" | 21 #include "remoting/proto/video.pb.h" |
21 #include "remoting/protocol/client_stub.h" | 22 #include "remoting/protocol/client_stub.h" |
22 #include "remoting/protocol/connection_to_client.h" | 23 #include "remoting/protocol/connection_to_client.h" |
23 #include "remoting/protocol/message_decoder.h" | 24 #include "remoting/protocol/message_decoder.h" |
24 #include "remoting/protocol/util.h" | 25 #include "remoting/protocol/util.h" |
25 | 26 |
26 using remoting::protocol::ConnectionToClient; | 27 using remoting::protocol::ConnectionToClient; |
27 | 28 |
28 namespace remoting { | 29 namespace remoting { |
29 | 30 |
30 // Maximum number of frames that can be processed similtaneously. | 31 // Maximum number of frames that can be processed similtaneously. |
31 // TODO(hclam): Move this value to CaptureScheduler. | 32 // TODO(hclam): Move this value to CaptureScheduler. |
32 static const int kMaxRecordings = 2; | 33 static const int kMaxRecordings = 2; |
33 | 34 |
34 ScreenRecorder::ScreenRecorder( | 35 ScreenRecorder::ScreenRecorder( |
35 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
36 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 37 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
37 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 38 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
38 Capturer* capturer, | 39 VideoFrameCapturer* capturer, |
39 Encoder* encoder) | 40 Encoder* encoder) |
40 : capture_task_runner_(capture_task_runner), | 41 : capture_task_runner_(capture_task_runner), |
41 encode_task_runner_(encode_task_runner), | 42 encode_task_runner_(encode_task_runner), |
42 network_task_runner_(network_task_runner), | 43 network_task_runner_(network_task_runner), |
43 capturer_(capturer), | 44 capturer_(capturer), |
44 encoder_(encoder), | 45 encoder_(encoder), |
45 network_stopped_(false), | 46 network_stopped_(false), |
46 encoder_stopped_(false), | 47 encoder_stopped_(false), |
47 max_recordings_(kMaxRecordings), | 48 max_recordings_(kMaxRecordings), |
48 recordings_(0), | 49 recordings_(0), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 110 } |
110 | 111 |
111 sequence_number_ = sequence_number; | 112 sequence_number_ = sequence_number; |
112 } | 113 } |
113 | 114 |
114 // Private methods ----------------------------------------------------------- | 115 // Private methods ----------------------------------------------------------- |
115 | 116 |
116 ScreenRecorder::~ScreenRecorder() { | 117 ScreenRecorder::~ScreenRecorder() { |
117 } | 118 } |
118 | 119 |
119 Capturer* ScreenRecorder::capturer() { | 120 VideoFrameCapturer* ScreenRecorder::capturer() { |
120 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 121 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
121 DCHECK(capturer_); | 122 DCHECK(capturer_); |
122 return capturer_; | 123 return capturer_; |
123 } | 124 } |
124 | 125 |
125 Encoder* ScreenRecorder::encoder() { | 126 Encoder* ScreenRecorder::encoder() { |
126 DCHECK(encode_task_runner_->BelongsToCurrentThread()); | 127 DCHECK(encode_task_runner_->BelongsToCurrentThread()); |
127 DCHECK(encoder_.get()); | 128 DCHECK(encoder_.get()); |
128 return encoder_.get(); | 129 return encoder_.get(); |
129 } | 130 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 packet->set_encode_time_ms(encode_time_ms); | 361 packet->set_encode_time_ms(encode_time_ms); |
361 scheduler_.RecordEncodeTime(encode_time); | 362 scheduler_.RecordEncodeTime(encode_time); |
362 } | 363 } |
363 | 364 |
364 network_task_runner_->PostTask( | 365 network_task_runner_->PostTask( |
365 FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, | 366 FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, |
366 base::Passed(packet.Pass()))); | 367 base::Passed(packet.Pass()))); |
367 } | 368 } |
368 | 369 |
369 } // namespace remoting | 370 } // namespace remoting |
OLD | NEW |