Index: content/browser/renderer_host/media/video_capture_device_client.cc |
diff --git a/content/browser/renderer_host/media/video_capture_device_client.cc b/content/browser/renderer_host/media/video_capture_device_client.cc |
index 3fdbca2279847bcc186e08b42b89eda43bfdd9b8..e6a34cf7f075f6bbe22c1779112af84f7ddd54cc 100644 |
--- a/content/browser/renderer_host/media/video_capture_device_client.cc |
+++ b/content/browser/renderer_host/media/video_capture_device_client.cc |
@@ -11,6 +11,7 @@ |
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
#include "content/browser/gpu/gpu_data_manager_impl.h" |
+#include "content/browser/renderer_host/gpu_jpeg_decoder.h" |
#include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
#include "content/browser/renderer_host/media/video_capture_controller.h" |
#include "content/common/gpu/client/context_provider_command_buffer.h" |
@@ -120,6 +121,9 @@ class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { |
ClientBuffer AsClientBuffer() override { |
return buffer_handle_->AsClientBuffer(); |
} |
+ base::SharedMemoryHandle AsPlatformHandle() override { |
+ return buffer_handle_->AsPlatformHandle(); |
+ } |
private: |
~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } |
@@ -197,9 +201,17 @@ VideoCaptureDeviceClient::VideoCaptureDeviceClient( |
capture_task_runner_(capture_task_runner), |
last_captured_pixel_format_(media::PIXEL_FORMAT_UNKNOWN) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (GpuJpegDecoder::Supported()) { |
+ external_jpeg_decoder_.reset(new GpuJpegDecoder( |
+ this, |
+ base::Bind( |
+ &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, |
+ controller_))); |
+ } |
} |
-VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {} |
+VideoCaptureDeviceClient::~VideoCaptureDeviceClient() { |
+} |
void VideoCaptureDeviceClient::OnIncomingCapturedData( |
const uint8* data, |
@@ -213,11 +225,22 @@ void VideoCaptureDeviceClient::OnIncomingCapturedData( |
OnLog("Pixel format: " + media::VideoCaptureFormat::PixelFormatToString( |
frame_format.pixel_format)); |
last_captured_pixel_format_ = frame_format.pixel_format; |
+ |
+ if (frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG && |
+ external_jpeg_decoder_) |
mcasas
2015/05/07 00:59:03
With this condition, we would be calling
external
wuchengli
2015/05/07 06:23:14
Not every incoming frame. Only when format changes
kcwu
2015/05/08 14:42:42
This only happens when pixel_format becomes from n
kcwu
2015/05/08 14:42:42
Acknowledged.
|
+ ignore_result(external_jpeg_decoder_->Initialize()); |
wuchengli
2015/05/04 14:14:41
Why not set |external_jpeg_decoder_| to NULL if In
wuchengli
2015/05/06 07:59:18
As discussed, if Initialize fails, there will be n
kcwu
2015/05/08 14:42:42
Done.
kcwu
2015/05/08 14:42:42
Done.
|
} |
if (!frame_format.IsValid()) |
return; |
+ if (frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG && |
+ external_jpeg_decoder_) { |
mcasas
2015/05/07 00:59:03
nit: Merge all conditions in lines l.237-238.
kcwu
2015/05/08 14:42:42
Acknowledged.
This is changed to no fallback.
|
+ if (external_jpeg_decoder_->DecodeCapturedData(data, length, frame_format, |
+ rotation, timestamp)) |
+ return; |
+ } |
+ |
// |chopped_{width,height} and |new_unrotated_{width,height}| are the lowest |
// bit decomposition of {width, height}, grabbing the odd and even parts. |
const int chopped_width = frame_format.frame_size.width() & 1; |