| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cast_video_capturer_adapter.h" | 5 #include "remoting/host/cast_video_capturer_adapter.h" |
| 6 | 6 |
| 7 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 7 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 if (!owned_frame || owned_frame->updated_region().is_empty()) { | 38 if (!owned_frame || owned_frame->updated_region().is_empty()) { |
| 39 owned_frame.reset(); | 39 owned_frame.reset(); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Convert the webrtc::DesktopFrame to a cricket::CapturedFrame. | 43 // Convert the webrtc::DesktopFrame to a cricket::CapturedFrame. |
| 44 cricket::CapturedFrame captured_frame; | 44 cricket::CapturedFrame captured_frame; |
| 45 captured_frame.width = owned_frame->size().width(); | 45 captured_frame.width = owned_frame->size().width(); |
| 46 captured_frame.height = owned_frame->size().height(); | 46 captured_frame.height = owned_frame->size().height(); |
| 47 base::TimeTicks current_time = base::TimeTicks::Now(); | 47 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 48 captured_frame.elapsed_time = (current_time - start_time_).InMicroseconds() * | |
| 49 base::Time::kNanosecondsPerMicrosecond; | |
| 50 captured_frame.time_stamp = | 48 captured_frame.time_stamp = |
| 51 current_time.ToInternalValue() * base::Time::kNanosecondsPerMicrosecond; | 49 current_time.ToInternalValue() * base::Time::kNanosecondsPerMicrosecond; |
| 52 captured_frame.data = owned_frame->data(); | 50 captured_frame.data = owned_frame->data(); |
| 53 | 51 |
| 54 // The data_size attribute must be set. If multiple formats are supported, | 52 // The data_size attribute must be set. If multiple formats are supported, |
| 55 // this should be set appropriately for each one. | 53 // this should be set appropriately for each one. |
| 56 captured_frame.data_size = | 54 captured_frame.data_size = |
| 57 (captured_frame.width * webrtc::DesktopFrame::kBytesPerPixel * 8 + 7) / | 55 (captured_frame.width * webrtc::DesktopFrame::kBytesPerPixel * 8 + 7) / |
| 58 8 * captured_frame.height; | 56 8 * captured_frame.height; |
| 59 captured_frame.fourcc = cricket::FOURCC_ARGB; | 57 captured_frame.fourcc = cricket::FOURCC_ARGB; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 VLOG(1) << "CastVideoCapturerAdapter failed to start."; | 82 VLOG(1) << "CastVideoCapturerAdapter failed to start."; |
| 85 return cricket::CS_FAILED; | 83 return cricket::CS_FAILED; |
| 86 } | 84 } |
| 87 | 85 |
| 88 // This is required to tell the cricket::VideoCapturer base class what the | 86 // This is required to tell the cricket::VideoCapturer base class what the |
| 89 // capture format will be. | 87 // capture format will be. |
| 90 SetCaptureFormat(&capture_format); | 88 SetCaptureFormat(&capture_format); |
| 91 | 89 |
| 92 desktop_capturer_->Start(this); | 90 desktop_capturer_->Start(this); |
| 93 | 91 |
| 94 // Save the Start() time of |desktop_capturer_|. This will be used | |
| 95 // to estimate the creation time of the frame source, to set the elapsed_time | |
| 96 // of future CapturedFrames in OnCaptureCompleted(). | |
| 97 start_time_ = base::TimeTicks::Now(); | |
| 98 capture_timer_.reset(new base::RepeatingTimer()); | 92 capture_timer_.reset(new base::RepeatingTimer()); |
| 99 capture_timer_->Start(FROM_HERE, | 93 capture_timer_->Start(FROM_HERE, |
| 100 base::TimeDelta::FromMicroseconds( | 94 base::TimeDelta::FromMicroseconds( |
| 101 GetCaptureFormat()->interval / | 95 GetCaptureFormat()->interval / |
| 102 (base::Time::kNanosecondsPerMicrosecond)), | 96 (base::Time::kNanosecondsPerMicrosecond)), |
| 103 this, | 97 this, |
| 104 &CastVideoCapturerAdapter::CaptureNextFrame); | 98 &CastVideoCapturerAdapter::CaptureNextFrame); |
| 105 | 99 |
| 106 return cricket::CS_RUNNING; | 100 return cricket::CS_RUNNING; |
| 107 } | 101 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void CastVideoCapturerAdapter::CaptureNextFrame() { | 186 void CastVideoCapturerAdapter::CaptureNextFrame() { |
| 193 // If we are paused, then don't capture. | 187 // If we are paused, then don't capture. |
| 194 if (!IsRunning()) | 188 if (!IsRunning()) |
| 195 return; | 189 return; |
| 196 | 190 |
| 197 desktop_capturer_->Capture(webrtc::DesktopRegion()); | 191 desktop_capturer_->Capture(webrtc::DesktopRegion()); |
| 198 } | 192 } |
| 199 | 193 |
| 200 } // namespace remoting | 194 } // namespace remoting |
| 201 | 195 |
| OLD | NEW |