Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: remoting/host/screen_recorder.h

Issue 7635005: Properly handle screen recorder shutdown in ChromotingHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/screen_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/timer.h" 16 #include "base/timer.h"
16 #include "remoting/base/encoder.h" 17 #include "remoting/base/encoder.h"
17 #include "remoting/host/capturer.h" 18 #include "remoting/host/capturer.h"
18 #include "remoting/proto/video.pb.h" 19 #include "remoting/proto/video.pb.h"
19 20
20 namespace remoting { 21 namespace remoting {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Capturer* capturer, 79 Capturer* capturer,
79 Encoder* encoder); 80 Encoder* encoder);
80 81
81 virtual ~ScreenRecorder(); 82 virtual ~ScreenRecorder();
82 83
83 // Start recording. 84 // Start recording.
84 void Start(); 85 void Start();
85 86
86 // Stop the recording session. |done_task| is executed when recording is fully 87 // Stop the recording session. |done_task| is executed when recording is fully
87 // stopped. This object cannot be used again after |task| is executed. 88 // stopped. This object cannot be used again after |task| is executed.
88 void Stop(Task* done_task); 89 void Stop(const base::Closure& done_task);
89 90
90 // Set the maximum capture rate. This is denoted by number of updates 91 // Set the maximum capture rate. This is denoted by number of updates
91 // in one second. The actual system may run in a slower rate than the maximum 92 // in one second. The actual system may run in a slower rate than the maximum
92 // rate due to various factors, e.g. capture speed, encode speed and network 93 // rate due to various factors, e.g. capture speed, encode speed and network
93 // conditions. 94 // conditions.
94 // This method should be called before Start() is called. 95 // This method should be called before Start() is called.
95 void SetMaxRate(double rate); 96 void SetMaxRate(double rate);
96 97
97 // Add a connection to this recording session. 98 // Add a connection to this recording session.
98 void AddConnection(scoped_refptr<protocol::ConnectionToClient> connection); 99 void AddConnection(scoped_refptr<protocol::ConnectionToClient> connection);
99 100
100 // Remove a connection from receiving screen updates. 101 // Remove a connection from receiving screen updates.
101 void RemoveConnection(scoped_refptr<protocol::ConnectionToClient> connection); 102 void RemoveConnection(scoped_refptr<protocol::ConnectionToClient> connection);
102 103
103 // Remove all connections. 104 // Remove all connections.
104 void RemoveAllConnections(); 105 void RemoveAllConnections();
105 106
106 // Update the sequence number for tracing performance. 107 // Update the sequence number for tracing performance.
107 void UpdateSequenceNumber(int64 sequence_number); 108 void UpdateSequenceNumber(int64 sequence_number);
108 109
109 private: 110 private:
110 // Getters for capturer and encoder. 111 // Getters for capturer and encoder.
111 Capturer* capturer(); 112 Capturer* capturer();
112 Encoder* encoder(); 113 Encoder* encoder();
113 114
114 // Capturer thread ---------------------------------------------------------- 115 // Capturer thread ----------------------------------------------------------
115 116
116 void DoStart(); 117 void DoStart();
117 void DoStop(Task* done_task);
118
119 void DoSetMaxRate(double max_rate); 118 void DoSetMaxRate(double max_rate);
120 119
121 // Hepler method to schedule next capture using the current rate. 120 // Hepler method to schedule next capture using the current rate.
122 void StartCaptureTimer(); 121 void StartCaptureTimer();
123 122
124 void DoCapture(); 123 void DoCapture();
125 void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data); 124 void CaptureDoneCallback(scoped_refptr<CaptureData> capture_data);
126 void DoFinishOneRecording(); 125 void DoFinishOneRecording();
127 void DoInvalidateFullScreen(); 126 void DoInvalidateFullScreen();
128 127
129 // Network thread ----------------------------------------------------------- 128 // Network thread -----------------------------------------------------------
130 129
131 // DoSendVideoPacket takes ownership of the |packet| and is responsible 130 // DoSendVideoPacket takes ownership of the |packet| and is responsible
132 // for deleting it. 131 // for deleting it.
133 void DoSendVideoPacket(VideoPacket* packet); 132 void DoSendVideoPacket(VideoPacket* packet);
134 133
135 void DoSendInit(scoped_refptr<protocol::ConnectionToClient> connection, 134 void DoSendInit(scoped_refptr<protocol::ConnectionToClient> connection,
136 int width, int height); 135 int width, int height);
137 136
138 void DoAddConnection(scoped_refptr<protocol::ConnectionToClient> connection); 137 void DoAddConnection(scoped_refptr<protocol::ConnectionToClient> connection);
139 void DoRemoveClient(scoped_refptr<protocol::ConnectionToClient> connection); 138 void DoRemoveClient(scoped_refptr<protocol::ConnectionToClient> connection);
140 void DoRemoveAllClients(); 139 void DoRemoveAllClients();
141 140
142 // Signal network thread to cease activities. 141 // Signal network thread to cease activities.
143 void DoStopOnNetworkThread(Task* done_task); 142 void DoStopOnNetworkThread(const base::Closure& done_task);
144 143
145 // Callback for the last packet in one update. Deletes |packet| and 144 // Callback for the last packet in one update. Deletes |packet| and
146 // schedules next screen capture. 145 // schedules next screen capture.
147 void FrameSentCallback(VideoPacket* packet); 146 void FrameSentCallback(VideoPacket* packet);
148 147
149 // Encoder thread ----------------------------------------------------------- 148 // Encoder thread -----------------------------------------------------------
150 149
151 void DoEncode(scoped_refptr<CaptureData> capture_data); 150 void DoEncode(scoped_refptr<CaptureData> capture_data);
152 151
153 // Perform stop operations on encode thread. 152 // Perform stop operations on encode thread.
154 void DoStopOnEncodeThread(Task* done_task); 153 void DoStopOnEncodeThread(const base::Closure& done_task);
155 154
156 // EncodedDataAvailableCallback takes ownership of |packet|. 155 // EncodedDataAvailableCallback takes ownership of |packet|.
157 void EncodedDataAvailableCallback(VideoPacket* packet); 156 void EncodedDataAvailableCallback(VideoPacket* packet);
158 void SendVideoPacket(VideoPacket* packet); 157 void SendVideoPacket(VideoPacket* packet);
159 158
160 // Message loops used by this class. 159 // Message loops used by this class.
161 MessageLoop* capture_loop_; 160 MessageLoop* capture_loop_;
162 MessageLoop* encode_loop_; 161 MessageLoop* encode_loop_;
163 MessageLoop* network_loop_; 162 MessageLoop* network_loop_;
164 163
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 205
207 // This is a number updated by client to trace performance. 206 // This is a number updated by client to trace performance.
208 int64 sequence_number_; 207 int64 sequence_number_;
209 208
210 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder); 209 DISALLOW_COPY_AND_ASSIGN(ScreenRecorder);
211 }; 210 };
212 211
213 } // namespace remoting 212 } // namespace remoting
214 213
215 #endif // REMOTING_HOST_SCREEN_RECORDER_H_ 214 #endif // REMOTING_HOST_SCREEN_RECORDER_H_
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/screen_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698