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

Side by Side Diff: content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc

Issue 277943002: Add texture support in WebrtcVideoCapturerAdapter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/media/native_handle_impl.h"
10 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
11 #include "third_party/libyuv/include/libyuv/convert.h" 12 #include "third_party/libyuv/include/libyuv/convert.h"
13 #include "third_party/webrtc/system_wrappers/interface/ref_count.h"
12 14
13 namespace content { 15 namespace content {
14 16
15 WebRtcVideoCapturerAdapter::WebRtcVideoCapturerAdapter(bool is_screencast) 17 WebRtcVideoCapturerAdapter::WebRtcVideoCapturerAdapter(bool is_screencast)
16 : is_screencast_(is_screencast), 18 : is_screencast_(is_screencast),
17 running_(false), 19 running_(false),
18 buffer_(NULL), 20 buffer_(NULL),
19 buffer_size_(0) { 21 buffer_size_(0) {
20 } 22 }
21 23
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 best_format->width = desired.width; 73 best_format->width = desired.width;
72 best_format->height = desired.height; 74 best_format->height = desired.height;
73 best_format->fourcc = cricket::FOURCC_I420; 75 best_format->fourcc = cricket::FOURCC_I420;
74 best_format->interval = desired.interval; 76 best_format->interval = desired.interval;
75 return true; 77 return true;
76 } 78 }
77 79
78 void WebRtcVideoCapturerAdapter::OnFrameCaptured( 80 void WebRtcVideoCapturerAdapter::OnFrameCaptured(
79 const scoped_refptr<media::VideoFrame>& frame) { 81 const scoped_refptr<media::VideoFrame>& frame) {
80 DCHECK(media::VideoFrame::I420 == frame->format() || 82 DCHECK(media::VideoFrame::I420 == frame->format() ||
81 media::VideoFrame::YV12 == frame->format()); 83 media::VideoFrame::YV12 == frame->format() ||
84 media::VideoFrame::NATIVE_TEXTURE == frame->format());
82 if (first_frame_timestamp_ == media::kNoTimestamp()) 85 if (first_frame_timestamp_ == media::kNoTimestamp())
83 first_frame_timestamp_ = frame->timestamp(); 86 first_frame_timestamp_ = frame->timestamp();
84 87
85 cricket::CapturedFrame captured_frame; 88 cricket::CapturedFrame captured_frame;
86 captured_frame.width = frame->visible_rect().width(); 89 captured_frame.width = frame->visible_rect().width();
87 captured_frame.height = frame->visible_rect().height(); 90 captured_frame.height = frame->visible_rect().height();
88 // cricket::CapturedFrame time is in nanoseconds. 91 // cricket::CapturedFrame time is in nanoseconds.
89 captured_frame.elapsed_time = 92 captured_frame.elapsed_time =
90 (frame->timestamp() - first_frame_timestamp_).InMicroseconds() * 93 (frame->timestamp() - first_frame_timestamp_).InMicroseconds() *
91 base::Time::kNanosecondsPerMicrosecond; 94 base::Time::kNanosecondsPerMicrosecond;
92 captured_frame.time_stamp = frame->timestamp().InMicroseconds() * 95 captured_frame.time_stamp = frame->timestamp().InMicroseconds() *
93 base::Time::kNanosecondsPerMicrosecond; 96 base::Time::kNanosecondsPerMicrosecond;
94 captured_frame.pixel_height = 1; 97 captured_frame.pixel_height = 1;
95 captured_frame.pixel_width = 1; 98 captured_frame.pixel_width = 1;
96 99
97 // TODO(perkj): 100 // TODO(perkj):
98 // Libjingle expects contiguous layout of image planes as input. 101 // Libjingle expects contiguous layout of image planes as input.
99 // The only format where that is true in Chrome is I420 where the 102 // The only format where that is true in Chrome is I420 where the
100 // coded_size == visible_rect().size(). 103 // coded_size == visible_rect().size().
101 if (frame->format() != media::VideoFrame::I420 || 104 if (frame->format() == media::VideoFrame::NATIVE_TEXTURE) {
105 webrtc::RefCountImpl<NativeHandleImpl>* handle =
106 new webrtc::RefCountImpl<NativeHandleImpl>(frame.get());
perkj_chrome 2014/05/12 08:19:42 nit:indentation
wuchengli 2014/05/12 09:41:29 Done. Ran git cl format.
107 captured_frame.handle = handle;
perkj_chrome 2014/05/12 08:19:42 How does this ensure |frame| is not released while
wuchengli 2014/05/12 09:41:29 NativeHandleImpl keeps a reference to |frame|. htt
108 } else if (frame->format() != media::VideoFrame::I420 ||
102 frame->coded_size() != frame->visible_rect().size()) { 109 frame->coded_size() != frame->visible_rect().size()) {
103 // Cropping and or switching UV planes is needed. 110 // Cropping and or switching UV planes is needed.
104 UpdateI420Buffer(frame); 111 UpdateI420Buffer(frame);
105 captured_frame.data = buffer_; 112 captured_frame.data = buffer_;
106 captured_frame.data_size = buffer_size_; 113 captured_frame.data_size = buffer_size_;
107 captured_frame.fourcc = cricket::FOURCC_I420; 114 captured_frame.fourcc = cricket::FOURCC_I420;
108 } else { 115 } else {
109 captured_frame.fourcc = media::VideoFrame::I420 == frame->format() ? 116 captured_frame.fourcc = media::VideoFrame::I420 == frame->format() ?
110 cricket::FOURCC_I420 : cricket::FOURCC_YV12; 117 cricket::FOURCC_I420 : cricket::FOURCC_YV12;
111 captured_frame.data = frame->data(0); 118 captured_frame.data = frame->data(0);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 dst_stride_y, 173 dst_stride_y,
167 dst_u, 174 dst_u,
168 dst_halfwidth, 175 dst_halfwidth,
169 dst_v, 176 dst_v,
170 dst_halfwidth, 177 dst_halfwidth,
171 dst_width, 178 dst_width,
172 dst_height); 179 dst_height);
173 } 180 }
174 181
175 } // namespace content 182 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698