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

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

Issue 6792038: Chromoting to report roundtrip latency (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add scriptable interface Created 9 years, 8 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
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 #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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Encoder* encoder) 42 Encoder* encoder)
43 : capture_loop_(capture_loop), 43 : capture_loop_(capture_loop),
44 encode_loop_(encode_loop), 44 encode_loop_(encode_loop),
45 network_loop_(network_loop), 45 network_loop_(network_loop),
46 capturer_(capturer), 46 capturer_(capturer),
47 encoder_(encoder), 47 encoder_(encoder),
48 is_recording_(false), 48 is_recording_(false),
49 network_stopped_(false), 49 network_stopped_(false),
50 recordings_(0), 50 recordings_(0),
51 frame_skipped_(false), 51 frame_skipped_(false),
52 max_rate_(kDefaultCaptureRate) { 52 max_rate_(kDefaultCaptureRate),
53 sequence_number_(0) {
53 DCHECK(capture_loop_); 54 DCHECK(capture_loop_);
54 DCHECK(encode_loop_); 55 DCHECK(encode_loop_);
55 DCHECK(network_loop_); 56 DCHECK(network_loop_);
56 } 57 }
57 58
58 ScreenRecorder::~ScreenRecorder() { 59 ScreenRecorder::~ScreenRecorder() {
59 } 60 }
60 61
61 // Public methods -------------------------------------------------------------- 62 // Public methods --------------------------------------------------------------
62 63
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 FROM_HERE, 96 FROM_HERE,
96 NewTracedMethod(this, &ScreenRecorder::DoRemoveClient, connection)); 97 NewTracedMethod(this, &ScreenRecorder::DoRemoveClient, connection));
97 } 98 }
98 99
99 void ScreenRecorder::RemoveAllConnections() { 100 void ScreenRecorder::RemoveAllConnections() {
100 network_loop_->PostTask( 101 network_loop_->PostTask(
101 FROM_HERE, 102 FROM_HERE,
102 NewTracedMethod(this, &ScreenRecorder::DoRemoveAllClients)); 103 NewTracedMethod(this, &ScreenRecorder::DoRemoveAllClients));
103 } 104 }
104 105
106 void ScreenRecorder::UpdateSequenceNumber(int64 sequence_number) {
107 if (MessageLoop::current() != capture_loop_) {
simonmorris 2011/04/05 10:47:06 Maybe a comment to explain why this should be run
Alpha Left Google 2011/04/08 00:07:20 Done.
108 capture_loop_->PostTask(
109 FROM_HERE,
110 NewRunnableMethod(this, &ScreenRecorder::UpdateSequenceNumber,
111 sequence_number));
112 return;
113 }
114
115 sequence_number_ = sequence_number;
116 }
117
105 // Private accessors ----------------------------------------------------------- 118 // Private accessors -----------------------------------------------------------
106 119
107 Capturer* ScreenRecorder::capturer() { 120 Capturer* ScreenRecorder::capturer() {
108 DCHECK_EQ(capture_loop_, MessageLoop::current()); 121 DCHECK_EQ(capture_loop_, MessageLoop::current());
109 DCHECK(capturer_); 122 DCHECK(capturer_);
110 return capturer_; 123 return capturer_;
111 } 124 }
112 125
113 Encoder* ScreenRecorder::encoder() { 126 Encoder* ScreenRecorder::encoder() {
114 DCHECK_EQ(encode_loop_, MessageLoop::current()); 127 DCHECK_EQ(encode_loop_, MessageLoop::current());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 scoped_refptr<CaptureData> capture_data) { 234 scoped_refptr<CaptureData> capture_data) {
222 DCHECK_EQ(capture_loop_, MessageLoop::current()); 235 DCHECK_EQ(capture_loop_, MessageLoop::current());
223 236
224 if (!is_recording_) 237 if (!is_recording_)
225 return; 238 return;
226 239
227 TraceContext::tracer()->PrintString("Capture Done"); 240 TraceContext::tracer()->PrintString("Capture Done");
228 int capture_time = 241 int capture_time =
229 (base::Time::Now() - capture_start_time_).InMilliseconds(); 242 (base::Time::Now() - capture_start_time_).InMilliseconds();
230 capture_data->set_capture_time_ms(capture_time); 243 capture_data->set_capture_time_ms(capture_time);
244
245 // The best way to get this value is by binding the sequence number to
246 // the callback when calling CaptureInvalidRects(). However the callback
247 // system doesn't allow this. Reading from the member variable is
248 // accurate as long as capture is synchronous as the following statement
simonmorris 2011/04/05 10:47:06 Maybe "as long as sequence_number_ is set in the c
Alpha Left Google 2011/04/08 00:07:20 Well that's not true.. capture being synchronous i
simonmorris 2011/04/08 08:18:25 OK.
249 // will obtain the last sequence number received.
Wez 2011/04/05 13:46:20 "last" -> "most recent"
Alpha Left Google 2011/04/08 00:07:20 Done.
250 capture_data->set_client_sequence_number(sequence_number_);
251 sequence_number_ = 0;
252
231 encode_loop_->PostTask( 253 encode_loop_->PostTask(
232 FROM_HERE, 254 FROM_HERE,
233 NewTracedMethod(this, &ScreenRecorder::DoEncode, capture_data)); 255 NewTracedMethod(this, &ScreenRecorder::DoEncode, capture_data));
234 } 256 }
235 257
236 void ScreenRecorder::DoFinishOneRecording() { 258 void ScreenRecorder::DoFinishOneRecording() {
237 DCHECK_EQ(capture_loop_, MessageLoop::current()); 259 DCHECK_EQ(capture_loop_, MessageLoop::current());
238 260
239 if (!is_recording_) 261 if (!is_recording_)
240 return; 262 return;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 (base::Time::Now() - encode_start_time_).InMilliseconds(); 407 (base::Time::Now() - encode_start_time_).InMilliseconds();
386 packet->set_encode_time_ms(encode_time); 408 packet->set_encode_time_ms(encode_time);
387 } 409 }
388 410
389 network_loop_->PostTask( 411 network_loop_->PostTask(
390 FROM_HERE, 412 FROM_HERE,
391 NewTracedMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); 413 NewTracedMethod(this, &ScreenRecorder::DoSendVideoPacket, packet));
392 } 414 }
393 415
394 } // namespace remoting 416 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698