| 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 "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/memory/aligned_memory.h" | 9 #include "base/memory/aligned_memory.h" |
| 10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 best_format->fourcc = cricket::FOURCC_I420; | 73 best_format->fourcc = cricket::FOURCC_I420; |
| 74 best_format->interval = desired.interval; | 74 best_format->interval = desired.interval; |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void WebRtcVideoCapturerAdapter::OnFrameCaptured( | 78 void WebRtcVideoCapturerAdapter::OnFrameCaptured( |
| 79 const scoped_refptr<media::VideoFrame>& frame) { | 79 const scoped_refptr<media::VideoFrame>& frame) { |
| 80 DCHECK(media::VideoFrame::I420 == frame->format() || | 80 DCHECK(media::VideoFrame::I420 == frame->format() || |
| 81 media::VideoFrame::YV12 == frame->format()); | 81 media::VideoFrame::YV12 == frame->format()); |
| 82 if (first_frame_timestamp_ == media::kNoTimestamp()) | 82 if (first_frame_timestamp_ == media::kNoTimestamp()) |
| 83 first_frame_timestamp_ = frame->GetTimestamp(); | 83 first_frame_timestamp_ = frame->timestamp(); |
| 84 | 84 |
| 85 cricket::CapturedFrame captured_frame; | 85 cricket::CapturedFrame captured_frame; |
| 86 captured_frame.width = frame->visible_rect().width(); | 86 captured_frame.width = frame->visible_rect().width(); |
| 87 captured_frame.height = frame->visible_rect().height(); | 87 captured_frame.height = frame->visible_rect().height(); |
| 88 // cricket::CapturedFrame time is in nanoseconds. | 88 // cricket::CapturedFrame time is in nanoseconds. |
| 89 captured_frame.elapsed_time = | 89 captured_frame.elapsed_time = |
| 90 (frame->GetTimestamp() - first_frame_timestamp_).InMicroseconds() * | 90 (frame->timestamp() - first_frame_timestamp_).InMicroseconds() * |
| 91 base::Time::kNanosecondsPerMicrosecond; | 91 base::Time::kNanosecondsPerMicrosecond; |
| 92 captured_frame.time_stamp = frame->GetTimestamp().InMicroseconds() * | 92 captured_frame.time_stamp = frame->timestamp().InMicroseconds() * |
| 93 base::Time::kNanosecondsPerMicrosecond; | 93 base::Time::kNanosecondsPerMicrosecond; |
| 94 captured_frame.pixel_height = 1; | 94 captured_frame.pixel_height = 1; |
| 95 captured_frame.pixel_width = 1; | 95 captured_frame.pixel_width = 1; |
| 96 | 96 |
| 97 // TODO(perkj): | 97 // TODO(perkj): |
| 98 // Libjingle expects contiguous layout of image planes as input. | 98 // Libjingle expects contiguous layout of image planes as input. |
| 99 // The only format where that is true in Chrome is I420 where the | 99 // The only format where that is true in Chrome is I420 where the |
| 100 // coded_size == visible_rect().size(). | 100 // coded_size == visible_rect().size(). |
| 101 if (frame->format() != media::VideoFrame::I420 || | 101 if (frame->format() != media::VideoFrame::I420 || |
| 102 frame->coded_size() != frame->visible_rect().size()) { | 102 frame->coded_size() != frame->visible_rect().size()) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 dst_stride_y, | 166 dst_stride_y, |
| 167 dst_u, | 167 dst_u, |
| 168 dst_halfwidth, | 168 dst_halfwidth, |
| 169 dst_v, | 169 dst_v, |
| 170 dst_halfwidth, | 170 dst_halfwidth, |
| 171 dst_width, | 171 dst_width, |
| 172 dst_height); | 172 dst_height); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace content | 175 } // namespace content |
| OLD | NEW |