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

Side by Side Diff: content/browser/renderer_host/media/video_capture_texture_wrapper.cc

Issue 1064703002: VideoCaptureBufferPool: Refactor to allow support of non-ShMem backed buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/browser/renderer_host/media/video_capture_texture_wrapper.h" 5 #include "content/browser/renderer_host/media/video_capture_texture_wrapper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/compositor/image_transport_factory.h" 8 #include "content/browser/compositor/image_transport_factory.h"
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 10 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 void VideoCaptureTextureWrapper::OnIncomingCapturedData( 203 void VideoCaptureTextureWrapper::OnIncomingCapturedData(
204 const uint8* data, 204 const uint8* data,
205 int length, 205 int length,
206 const media::VideoCaptureFormat& frame_format, 206 const media::VideoCaptureFormat& frame_format,
207 int clockwise_rotation, 207 int clockwise_rotation,
208 const base::TimeTicks& timestamp) { 208 const base::TimeTicks& timestamp) {
209 209
210 // Reserve a temporary Buffer for conversion to ARGB. 210 // Reserve a temporary Buffer for conversion to ARGB.
211 const media::VideoCaptureFormat format(frame_format.frame_size,
212 frame_format.frame_rate,
213 media::PIXEL_FORMAT_ARGB);
211 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> argb_buffer = 214 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> argb_buffer =
212 ReserveOutputBuffer(media::VideoFrame::ARGB, frame_format.frame_size); 215 ReserveOutputBuffer(format);
213 DVLOG_IF(1, !argb_buffer) << "Couldn't allocate ARGB Buffer"; 216 DVLOG_IF(1, !argb_buffer) << "Couldn't allocate ARGB Buffer";
214 if (!argb_buffer) 217 if (!argb_buffer)
215 return; 218 return;
216 219
217 DCHECK(argb_buffer->data()); 220 DCHECK(argb_buffer->data());
218 // TODO(mcasas): Take |rotation| into acount. 221 // TODO(mcasas): Take |rotation| into acount.
219 int ret = libyuv::ConvertToARGB(data, 222 int ret = libyuv::ConvertToARGB(data,
220 length, 223 length,
221 reinterpret_cast<uint8*>(argb_buffer->data()), 224 reinterpret_cast<uint8*>(argb_buffer->data()),
222 frame_format.frame_size.width() * 4, 225 frame_format.frame_size.width() * 4,
223 0, 226 0,
224 0, 227 0,
225 frame_format.frame_size.width(), 228 frame_format.frame_size.width(),
226 frame_format.frame_size.height(), 229 frame_format.frame_size.height(),
227 frame_format.frame_size.width(), 230 frame_format.frame_size.width(),
228 frame_format.frame_size.height(), 231 frame_format.frame_size.height(),
229 libyuv::kRotate0, 232 libyuv::kRotate0,
230 VideoPixelFormatToFourCC( 233 VideoPixelFormatToFourCC(
231 frame_format.pixel_format)); 234 frame_format.pixel_format));
232 DLOG_IF(ERROR, ret != 0) << "Error converting incoming frame"; 235 DLOG_IF(ERROR, ret != 0) << "Error converting incoming frame";
233 if (ret != 0) 236 if (ret != 0)
234 return; 237 return;
235 238
236 // Reserve output buffer for the texture on the IPC borderlands. 239 // Reserve output buffer for the texture on the IPC borderlands.
240 const media::VideoCaptureFormat format2(gfx::Size(),
miu 2015/04/08 01:20:00 Here, an empty size is being passed. If the textu
mcasas 2015/04/08 22:07:06 Yes, down the line it will. Changed this line to
241 frame_format.frame_rate,
242 media::PIXEL_FORMAT_TEXTURE);
237 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> texture_buffer = 243 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> texture_buffer =
238 ReserveOutputBuffer(media::VideoFrame::NATIVE_TEXTURE, gfx::Size()); 244 ReserveOutputBuffer(format2);
239 DVLOG_IF(1, !texture_buffer) << "Couldn't allocate Texture Buffer"; 245 DVLOG_IF(1, !texture_buffer) << "Couldn't allocate Texture Buffer";
240 if (!texture_buffer) 246 if (!texture_buffer)
241 return; 247 return;
242 248
243 capture_task_runner_->PostTask( 249 capture_task_runner_->PostTask(
244 FROM_HERE, 250 FROM_HERE,
245 base::Bind( 251 base::Bind(
246 &TextureWrapperDelegate::OnIncomingCapturedData, 252 &TextureWrapperDelegate::OnIncomingCapturedData,
247 wrapper_delegate_, 253 wrapper_delegate_,
248 texture_buffer, 254 texture_buffer,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( 460 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError(
455 const std::string& message) { 461 const std::string& message) {
456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 462 DCHECK(capture_task_runner_->BelongsToCurrentThread());
457 DLOG(ERROR) << message; 463 DLOG(ERROR) << message;
458 BrowserThread::PostTask( 464 BrowserThread::PostTask(
459 BrowserThread::IO, FROM_HERE, 465 BrowserThread::IO, FROM_HERE,
460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); 466 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_));
461 } 467 }
462 468
463 } // namespace content 469 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698