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