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

Side by Side Diff: content/renderer/media/video_track_recorder.cc

Issue 2147753002: VideoTrackRecorder: add support for texture backed ARGB VideoFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/video_track_recorder.h" 5 #include "content/renderer/media/video_track_recorder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 base::TimeTicks capture_timestamp) { 178 base::TimeTicks capture_timestamp) {
179 // Cache the thread sending frames on first frame arrival. 179 // Cache the thread sending frames on first frame arrival.
180 if (!origin_task_runner_.get()) 180 if (!origin_task_runner_.get())
181 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 181 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get();
182 DCHECK(origin_task_runner_->BelongsToCurrentThread()); 182 DCHECK(origin_task_runner_->BelongsToCurrentThread());
183 if (paused_) 183 if (paused_)
184 return; 184 return;
185 185
186 if (!(video_frame->format() == media::PIXEL_FORMAT_I420 || 186 if (!(video_frame->format() == media::PIXEL_FORMAT_I420 ||
187 video_frame->format() == media::PIXEL_FORMAT_YV12 || 187 video_frame->format() == media::PIXEL_FORMAT_YV12 ||
188 video_frame->format() == media::PIXEL_FORMAT_ARGB ||
188 video_frame->format() == media::PIXEL_FORMAT_YV12A)) { 189 video_frame->format() == media::PIXEL_FORMAT_YV12A)) {
189 NOTREACHED(); 190 NOTREACHED() << media::VideoPixelFormatToString(video_frame->format());
190 return; 191 return;
191 } 192 }
emircan 2016/07/12 22:57:00 This code looks very similar to CopyFrame() below,
mcasas 2016/07/13 00:45:30 Happy to do that, but I see that CopyFrame() has a
192 scoped_refptr<media::VideoFrame> frame = video_frame; 193 scoped_refptr<media::VideoFrame> frame;
193 // Drop alpha channel since we do not support it yet. 194 if (video_frame->format() == media::PIXEL_FORMAT_ARGB) {
194 if (frame->format() == media::PIXEL_FORMAT_YV12A) 195 // Certain Android (hardware) decoders produce media::PIXEL_FORMAT_ARGB,
196 // (see https://crbug.com/585242) that may or may not be opaque. In the
197 // former case, record black frames (yuv = {0, 0x80, 0x80}) instead.
198 if (!video_frame->IsMappable()) {
199 frame = media::VideoFrame::CreateColorFrame(
200 video_frame->coded_size(), 0u, 0x80, 0x80, video_frame->timestamp());
emircan 2016/07/12 22:57:00 What if the coded_size() is not equal to visible_s
mcasas 2016/07/13 00:45:30 Well, I guess at this point the user is not going
201 } else {
202 frame = media::VideoFrame::CreateFrame(
203 media::PIXEL_FORMAT_I420, video_frame->coded_size(),
204 video_frame->visible_rect(), video_frame->natural_size(),
205 video_frame->timestamp());
206 const int result =
207 libyuv::ARGBToI420(video_frame->data(media::VideoFrame::kARGBPlane),
208 video_frame->stride(media::VideoFrame::kARGBPlane),
209 frame->data(media::VideoFrame::kYPlane),
210 frame->stride(media::VideoFrame::kYPlane),
211 frame->data(media::VideoFrame::kUPlane),
212 frame->stride(media::VideoFrame::kUPlane),
213 frame->data(media::VideoFrame::kVPlane),
214 frame->stride(media::VideoFrame::kVPlane),
215 video_frame->coded_size().width(),
216 video_frame->coded_size().height());
217 DCHECK_EQ(0, result) << "Error converting ARGB input frame to I420";
218 }
219 } else if (video_frame->format() == media::PIXEL_FORMAT_YV12A) {
220 // Drop alpha channel since we do not support it yet.
195 frame = media::WrapAsI420VideoFrame(video_frame); 221 frame = media::WrapAsI420VideoFrame(video_frame);
222 } else {
223 frame = video_frame;
224 }
196 225
197 encoding_task_runner_->PostTask( 226 encoding_task_runner_->PostTask(
198 FROM_HERE, base::Bind(&Encoder::EncodeOnEncodingTaskRunner, this, frame, 227 FROM_HERE, base::Bind(&Encoder::EncodeOnEncodingTaskRunner, this, frame,
199 capture_timestamp)); 228 capture_timestamp));
200 } 229 }
201 230
202 void VideoTrackRecorder::Encoder::SetPaused(bool paused) { 231 void VideoTrackRecorder::Encoder::SetPaused(bool paused) {
203 if (!encoding_task_runner_->BelongsToCurrentThread()) { 232 if (!encoding_task_runner_->BelongsToCurrentThread()) {
204 encoding_task_runner_->PostTask( 233 encoding_task_runner_->PostTask(
205 FROM_HERE, base::Bind(&Encoder::SetPaused, this, paused)); 234 FROM_HERE, base::Bind(&Encoder::SetPaused, this, paused));
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 encoder_->SetPaused(false); 1017 encoder_->SetPaused(false);
989 } 1018 }
990 1019
991 void VideoTrackRecorder::OnVideoFrameForTesting( 1020 void VideoTrackRecorder::OnVideoFrameForTesting(
992 const scoped_refptr<media::VideoFrame>& frame, 1021 const scoped_refptr<media::VideoFrame>& frame,
993 base::TimeTicks timestamp) { 1022 base::TimeTicks timestamp) {
994 encoder_->StartFrameEncode(frame, timestamp); 1023 encoder_->StartFrameEncode(frame, timestamp);
995 } 1024 }
996 1025
997 } // namespace content 1026 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698