| OLD | NEW |
| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 TraceContext::tracer()->PrintString("Capture Started"); | 212 TraceContext::tracer()->PrintString("Capture Started"); |
| 213 | 213 |
| 214 // At this point we are going to perform one capture so save the current time. | 214 // At this point we are going to perform one capture so save the current time. |
| 215 ++recordings_; | 215 ++recordings_; |
| 216 DCHECK_LE(recordings_, kMaxRecordings); | 216 DCHECK_LE(recordings_, kMaxRecordings); |
| 217 | 217 |
| 218 // And finally perform one capture. | 218 // And finally perform one capture. |
| 219 capture_start_time_ = base::Time::Now(); | 219 capture_start_time_ = base::Time::Now(); |
| 220 capturer()->CaptureInvalidRects( | 220 capturer()->CaptureInvalidRegion( |
| 221 NewCallback(this, &ScreenRecorder::CaptureDoneCallback)); | 221 NewCallback(this, &ScreenRecorder::CaptureDoneCallback)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ScreenRecorder::CaptureDoneCallback( | 224 void ScreenRecorder::CaptureDoneCallback( |
| 225 scoped_refptr<CaptureData> capture_data) { | 225 scoped_refptr<CaptureData> capture_data) { |
| 226 DCHECK_EQ(capture_loop_, MessageLoop::current()); | 226 DCHECK_EQ(capture_loop_, MessageLoop::current()); |
| 227 | 227 |
| 228 if (!is_recording_) | 228 if (!is_recording_) |
| 229 return; | 229 return; |
| 230 | 230 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Encoder thread -------------------------------------------------------------- | 359 // Encoder thread -------------------------------------------------------------- |
| 360 | 360 |
| 361 void ScreenRecorder::DoEncode( | 361 void ScreenRecorder::DoEncode( |
| 362 scoped_refptr<CaptureData> capture_data) { | 362 scoped_refptr<CaptureData> capture_data) { |
| 363 DCHECK_EQ(encode_loop_, MessageLoop::current()); | 363 DCHECK_EQ(encode_loop_, MessageLoop::current()); |
| 364 TraceContext::tracer()->PrintString("DoEncode called"); | 364 TraceContext::tracer()->PrintString("DoEncode called"); |
| 365 | 365 |
| 366 // Early out if there's nothing to encode. | 366 // Early out if there's nothing to encode. |
| 367 if (!capture_data || !capture_data->dirty_rects().size()) { | 367 if (!capture_data || capture_data->dirty_region().isEmpty()) { |
| 368 // Send an empty video packet to keep network active. | 368 // Send an empty video packet to keep network active. |
| 369 VideoPacket* packet = new VideoPacket(); | 369 VideoPacket* packet = new VideoPacket(); |
| 370 packet->set_flags(VideoPacket::LAST_PARTITION); | 370 packet->set_flags(VideoPacket::LAST_PARTITION); |
| 371 network_loop_->PostTask( | 371 network_loop_->PostTask( |
| 372 FROM_HERE, | 372 FROM_HERE, |
| 373 NewTracedMethod(this, | 373 NewTracedMethod(this, |
| 374 &ScreenRecorder::DoSendVideoPacket, | 374 &ScreenRecorder::DoSendVideoPacket, |
| 375 packet)); | 375 packet)); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 403 (base::Time::Now() - encode_start_time_).InMilliseconds()); | 403 (base::Time::Now() - encode_start_time_).InMilliseconds()); |
| 404 packet->set_encode_time_ms(encode_time); | 404 packet->set_encode_time_ms(encode_time); |
| 405 } | 405 } |
| 406 | 406 |
| 407 network_loop_->PostTask( | 407 network_loop_->PostTask( |
| 408 FROM_HERE, | 408 FROM_HERE, |
| 409 NewTracedMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); | 409 NewTracedMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace remoting | 412 } // namespace remoting |
| OLD | NEW |