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

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: done 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
« no previous file with comments | « remoting/host/screen_recorder.h ('k') | remoting/proto/internal.proto » ('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 #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 // Sequence number is used and written only on the capture thread.
108 if (MessageLoop::current() != capture_loop_) {
109 capture_loop_->PostTask(
110 FROM_HERE,
111 NewRunnableMethod(this, &ScreenRecorder::UpdateSequenceNumber,
112 sequence_number));
113 return;
114 }
115
116 sequence_number_ = sequence_number;
117 }
118
105 // Private accessors ----------------------------------------------------------- 119 // Private accessors -----------------------------------------------------------
106 120
107 Capturer* ScreenRecorder::capturer() { 121 Capturer* ScreenRecorder::capturer() {
108 DCHECK_EQ(capture_loop_, MessageLoop::current()); 122 DCHECK_EQ(capture_loop_, MessageLoop::current());
109 DCHECK(capturer_); 123 DCHECK(capturer_);
110 return capturer_; 124 return capturer_;
111 } 125 }
112 126
113 Encoder* ScreenRecorder::encoder() { 127 Encoder* ScreenRecorder::encoder() {
114 DCHECK_EQ(encode_loop_, MessageLoop::current()); 128 DCHECK_EQ(encode_loop_, MessageLoop::current());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 scoped_refptr<CaptureData> capture_data) { 235 scoped_refptr<CaptureData> capture_data) {
222 DCHECK_EQ(capture_loop_, MessageLoop::current()); 236 DCHECK_EQ(capture_loop_, MessageLoop::current());
223 237
224 if (!is_recording_) 238 if (!is_recording_)
225 return; 239 return;
226 240
227 TraceContext::tracer()->PrintString("Capture Done"); 241 TraceContext::tracer()->PrintString("Capture Done");
228 int capture_time = static_cast<int>( 242 int capture_time = static_cast<int>(
229 (base::Time::Now() - capture_start_time_).InMilliseconds()); 243 (base::Time::Now() - capture_start_time_).InMilliseconds());
230 capture_data->set_capture_time_ms(capture_time); 244 capture_data->set_capture_time_ms(capture_time);
245
246 // The best way to get this value is by binding the sequence number to
247 // the callback when calling CaptureInvalidRects(). However the callback
248 // system doesn't allow this. Reading from the member variable is
249 // accurate as long as capture is synchronous as the following statement
250 // will obtain the most recent sequence number received.
251 capture_data->set_client_sequence_number(sequence_number_);
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
« no previous file with comments | « remoting/host/screen_recorder.h ('k') | remoting/proto/internal.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698