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" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // if set to false. | 75 // if set to false. |
76 class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> { | 76 class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> { |
77 public: | 77 public: |
78 // Construct a ScreenRecorder. Message loops and threads are provided. | 78 // Construct a ScreenRecorder. Message loops and threads are provided. |
79 // This object does not own capturer but owns encoder. | 79 // This object does not own capturer but owns encoder. |
80 ScreenRecorder( | 80 ScreenRecorder( |
81 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 81 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
82 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, | 82 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
83 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 83 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
84 VideoFrameCapturer* capturer, | 84 VideoFrameCapturer* capturer, |
85 Encoder* encoder); | 85 VideoEncoder* encoder); |
86 | 86 |
87 // Start recording. | 87 // Start recording. |
88 void Start(); | 88 void Start(); |
89 | 89 |
90 // Stop the recording session. |done_task| is executed when recording is fully | 90 // Stop the recording session. |done_task| is executed when recording is fully |
91 // stopped. This object cannot be used again after |task| is executed. | 91 // stopped. This object cannot be used again after |task| is executed. |
92 void Stop(const base::Closure& done_task); | 92 void Stop(const base::Closure& done_task); |
93 | 93 |
94 // Add a connection to this recording session. | 94 // Add a connection to this recording session. |
95 void AddConnection(protocol::ConnectionToClient* connection); | 95 void AddConnection(protocol::ConnectionToClient* connection); |
96 | 96 |
97 // Remove a connection from receiving screen updates. | 97 // Remove a connection from receiving screen updates. |
98 void RemoveConnection(protocol::ConnectionToClient* connection); | 98 void RemoveConnection(protocol::ConnectionToClient* connection); |
99 | 99 |
100 // Remove all connections. | 100 // Remove all connections. |
101 void RemoveAllConnections(); | 101 void RemoveAllConnections(); |
102 | 102 |
103 // Update the sequence number for tracing performance. | 103 // Update the sequence number for tracing performance. |
104 void UpdateSequenceNumber(int64 sequence_number); | 104 void UpdateSequenceNumber(int64 sequence_number); |
105 | 105 |
106 private: | 106 private: |
107 friend class base::RefCountedThreadSafe<ScreenRecorder>; | 107 friend class base::RefCountedThreadSafe<ScreenRecorder>; |
108 virtual ~ScreenRecorder(); | 108 virtual ~ScreenRecorder(); |
109 | 109 |
110 // Getters for capturer and encoder. | 110 // Getters for capturer and encoder. |
111 VideoFrameCapturer* capturer(); | 111 VideoFrameCapturer* capturer(); |
112 Encoder* encoder(); | 112 VideoEncoder* encoder(); |
113 | 113 |
114 bool is_recording(); | 114 bool is_recording(); |
115 | 115 |
116 // Capturer thread ---------------------------------------------------------- | 116 // Capturer thread ---------------------------------------------------------- |
117 | 117 |
118 void DoStart(); | 118 void DoStart(); |
119 void DoSetMaxRate(double max_rate); | 119 void DoSetMaxRate(double max_rate); |
120 | 120 |
121 // Hepler method to schedule next capture using the current rate. | 121 // Hepler method to schedule next capture using the current rate. |
122 void StartCaptureTimer(); | 122 void StartCaptureTimer(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; | 159 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
160 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 160 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
161 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 161 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
162 | 162 |
163 // Reference to the capturer. This member is always accessed on the capture | 163 // Reference to the capturer. This member is always accessed on the capture |
164 // thread. | 164 // thread. |
165 VideoFrameCapturer* capturer_; | 165 VideoFrameCapturer* capturer_; |
166 | 166 |
167 // Reference to the encoder. This member is always accessed on the encode | 167 // Reference to the encoder. This member is always accessed on the encode |
168 // thread. | 168 // thread. |
169 scoped_ptr<Encoder> encoder_; | 169 scoped_ptr<VideoEncoder> encoder_; |
170 | 170 |
171 // A list of clients connected to this hosts. | 171 // A list of clients connected to this hosts. |
172 // This member is always accessed on the network thread. | 172 // This member is always accessed on the network thread. |
173 typedef std::vector<protocol::ConnectionToClient*> ConnectionToClientList; | 173 typedef std::vector<protocol::ConnectionToClient*> ConnectionToClientList; |
174 ConnectionToClientList connections_; | 174 ConnectionToClientList connections_; |
175 | 175 |
176 // Timer that calls DoCapture. Set to NULL when not recording. | 176 // Timer that calls DoCapture. Set to NULL when not recording. |
177 scoped_ptr<base::OneShotTimer<ScreenRecorder> > capture_timer_; | 177 scoped_ptr<base::OneShotTimer<ScreenRecorder> > capture_timer_; |
178 | 178 |
179 // Per-thread flags that are set when the ScreenRecorder is | 179 // Per-thread flags that are set when the ScreenRecorder is |
(...skipping 22 matching lines...) Expand all Loading... |
202 | 202 |
203 // An object to schedule capturing. | 203 // An object to schedule capturing. |
204 CaptureScheduler scheduler_; | 204 CaptureScheduler scheduler_; |
205 | 205 |
206 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); | 206 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); |
207 }; | 207 }; |
208 | 208 |
209 } // namespace remoting | 209 } // namespace remoting |
210 | 210 |
211 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ | 211 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ |
OLD | NEW |