| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> argb_buffer = | 211 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> argb_buffer = |
| 212 ReserveOutputBuffer(media::VideoFrame::ARGB, frame_format.frame_size); | 212 ReserveOutputBuffer(media::PIXEL_FORMAT_ARGB, frame_format.frame_size); |
| 213 DVLOG_IF(1, !argb_buffer) << "Couldn't allocate ARGB Buffer"; | 213 DVLOG_IF(1, !argb_buffer) << "Couldn't allocate ARGB Buffer"; |
| 214 if (!argb_buffer) | 214 if (!argb_buffer) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 DCHECK(argb_buffer->data()); | 217 DCHECK(argb_buffer->data()); |
| 218 // TODO(mcasas): Take |rotation| into acount. | 218 // TODO(mcasas): Take |rotation| into acount. |
| 219 int ret = libyuv::ConvertToARGB(data, | 219 int ret = libyuv::ConvertToARGB(data, |
| 220 length, | 220 length, |
| 221 reinterpret_cast<uint8*>(argb_buffer->data()), | 221 reinterpret_cast<uint8*>(argb_buffer->data()), |
| 222 frame_format.frame_size.width() * 4, | 222 frame_format.frame_size.width() * 4, |
| 223 0, | 223 0, |
| 224 0, | 224 0, |
| 225 frame_format.frame_size.width(), | 225 frame_format.frame_size.width(), |
| 226 frame_format.frame_size.height(), | 226 frame_format.frame_size.height(), |
| 227 frame_format.frame_size.width(), | 227 frame_format.frame_size.width(), |
| 228 frame_format.frame_size.height(), | 228 frame_format.frame_size.height(), |
| 229 libyuv::kRotate0, | 229 libyuv::kRotate0, |
| 230 VideoPixelFormatToFourCC( | 230 VideoPixelFormatToFourCC( |
| 231 frame_format.pixel_format)); | 231 frame_format.pixel_format)); |
| 232 DLOG_IF(ERROR, ret != 0) << "Error converting incoming frame"; | 232 DLOG_IF(ERROR, ret != 0) << "Error converting incoming frame"; |
| 233 if (ret != 0) | 233 if (ret != 0) |
| 234 return; | 234 return; |
| 235 | 235 |
| 236 // Reserve output buffer for the texture on the IPC borderlands. | 236 // Reserve output buffer for the texture on the IPC borderlands. |
| 237 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> texture_buffer = | 237 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> texture_buffer = |
| 238 ReserveOutputBuffer(media::VideoFrame::NATIVE_TEXTURE, gfx::Size()); | 238 ReserveOutputBuffer(media::PIXEL_FORMAT_TEXTURE, frame_format.frame_size); |
| 239 DVLOG_IF(1, !texture_buffer) << "Couldn't allocate Texture Buffer"; | 239 DVLOG_IF(1, !texture_buffer) << "Couldn't allocate Texture Buffer"; |
| 240 if (!texture_buffer) | 240 if (!texture_buffer) |
| 241 return; | 241 return; |
| 242 | 242 |
| 243 capture_task_runner_->PostTask( | 243 capture_task_runner_->PostTask( |
| 244 FROM_HERE, | 244 FROM_HERE, |
| 245 base::Bind( | 245 base::Bind( |
| 246 &TextureWrapperDelegate::OnIncomingCapturedData, | 246 &TextureWrapperDelegate::OnIncomingCapturedData, |
| 247 wrapper_delegate_, | 247 wrapper_delegate_, |
| 248 texture_buffer, | 248 texture_buffer, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( | 454 void VideoCaptureTextureWrapper::TextureWrapperDelegate::OnError( |
| 455 const std::string& message) { | 455 const std::string& message) { |
| 456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 456 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
| 457 DLOG(ERROR) << message; | 457 DLOG(ERROR) << message; |
| 458 BrowserThread::PostTask( | 458 BrowserThread::PostTask( |
| 459 BrowserThread::IO, FROM_HERE, | 459 BrowserThread::IO, FROM_HERE, |
| 460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 460 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace content | 463 } // namespace content |
| OLD | NEW |