| 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 #ifndef REMOTING_HOST_SCREEN_RECORDER_H_ | 5 #ifndef REMOTING_HOST_SCREEN_RECORDER_H_ |
| 6 #define REMOTING_HOST_SCREEN_RECORDER_H_ | 6 #define REMOTING_HOST_SCREEN_RECORDER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | |
| 15 #include "base/time.h" | 14 #include "base/time.h" |
| 16 #include "base/timer.h" | 15 #include "base/timer.h" |
| 17 #include "remoting/base/encoder.h" | 16 #include "remoting/base/encoder.h" |
| 18 #include "remoting/host/capturer.h" | 17 #include "remoting/host/capturer.h" |
| 19 #include "remoting/host/capture_scheduler.h" | 18 #include "remoting/host/capture_scheduler.h" |
| 20 #include "remoting/proto/video.pb.h" | 19 #include "remoting/proto/video.pb.h" |
| 21 | 20 |
| 22 namespace base { | 21 namespace base { |
| 23 class MessageLoopProxy; | 22 class SingleThreadTaskRunner; |
| 24 } // namespace base | 23 } // namespace base |
| 25 | 24 |
| 26 namespace remoting { | 25 namespace remoting { |
| 27 | 26 |
| 28 namespace protocol { | 27 namespace protocol { |
| 29 class ConnectionToClient; | 28 class ConnectionToClient; |
| 30 class CursorShapeInfo; | 29 class CursorShapeInfo; |
| 31 } // namespace protocol | 30 } // namespace protocol |
| 32 | 31 |
| 33 class CaptureData; | 32 class CaptureData; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // This class has the following state variables: | 71 // This class has the following state variables: |
| 73 // |capture_timer_| - If this is set to NULL there should be no activity on | 72 // |capture_timer_| - If this is set to NULL there should be no activity on |
| 74 // the capture thread by this object. | 73 // the capture thread by this object. |
| 75 // |network_stopped_| - This state is to prevent activity on the network thread | 74 // |network_stopped_| - This state is to prevent activity on the network thread |
| 76 // if set to false. | 75 // if set to false. |
| 77 class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> { | 76 class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> { |
| 78 public: | 77 public: |
| 79 | 78 |
| 80 // Construct a ScreenRecorder. Message loops and threads are provided. | 79 // Construct a ScreenRecorder. Message loops and threads are provided. |
| 81 // This object does not own capturer but owns encoder. | 80 // This object does not own capturer but owns encoder. |
| 82 ScreenRecorder(MessageLoop* capture_loop, | 81 ScreenRecorder( |
| 83 MessageLoop* encode_loop, | 82 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 84 base::MessageLoopProxy* network_loop, | 83 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 85 Capturer* capturer, | 84 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 86 Encoder* encoder); | 85 Capturer* capturer, |
| 86 Encoder* encoder); |
| 87 | 87 |
| 88 // Start recording. | 88 // Start recording. |
| 89 void Start(); | 89 void Start(); |
| 90 | 90 |
| 91 // Stop the recording session. |done_task| is executed when recording is fully | 91 // Stop the recording session. |done_task| is executed when recording is fully |
| 92 // stopped. This object cannot be used again after |task| is executed. | 92 // stopped. This object cannot be used again after |task| is executed. |
| 93 void Stop(const base::Closure& done_task); | 93 void Stop(const base::Closure& done_task); |
| 94 | 94 |
| 95 // Add a connection to this recording session. | 95 // Add a connection to this recording session. |
| 96 void AddConnection(protocol::ConnectionToClient* connection); | 96 void AddConnection(protocol::ConnectionToClient* connection); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Encoder thread ----------------------------------------------------------- | 149 // Encoder thread ----------------------------------------------------------- |
| 150 | 150 |
| 151 void DoEncode(scoped_refptr<CaptureData> capture_data); | 151 void DoEncode(scoped_refptr<CaptureData> capture_data); |
| 152 | 152 |
| 153 // Perform stop operations on encode thread. | 153 // Perform stop operations on encode thread. |
| 154 void DoStopOnEncodeThread(const base::Closure& done_task); | 154 void DoStopOnEncodeThread(const base::Closure& done_task); |
| 155 | 155 |
| 156 void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet); | 156 void EncodedDataAvailableCallback(scoped_ptr<VideoPacket> packet); |
| 157 void SendVideoPacket(VideoPacket* packet); | 157 void SendVideoPacket(VideoPacket* packet); |
| 158 | 158 |
| 159 // Message loops used by this class. | 159 // Task runners used by this class. |
| 160 MessageLoop* capture_loop_; | 160 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 161 MessageLoop* encode_loop_; | 161 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 162 scoped_refptr<base::MessageLoopProxy> network_loop_; | 162 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 163 | 163 |
| 164 // Reference to the capturer. This member is always accessed on the capture | 164 // Reference to the capturer. This member is always accessed on the capture |
| 165 // thread. | 165 // thread. |
| 166 Capturer* capturer_; | 166 Capturer* capturer_; |
| 167 | 167 |
| 168 // Reference to the encoder. This member is always accessed on the encode | 168 // Reference to the encoder. This member is always accessed on the encode |
| 169 // thread. | 169 // thread. |
| 170 scoped_ptr<Encoder> encoder_; | 170 scoped_ptr<Encoder> encoder_; |
| 171 | 171 |
| 172 // A list of clients connected to this hosts. | 172 // A list of clients connected to this hosts. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 203 | 203 |
| 204 // An object to schedule capturing. | 204 // An object to schedule capturing. |
| 205 CaptureScheduler scheduler_; | 205 CaptureScheduler scheduler_; |
| 206 | 206 |
| 207 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); | 207 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 } // namespace remoting | 210 } // namespace remoting |
| 211 | 211 |
| 212 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ | 212 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ |
| OLD | NEW |