| Index: media/capture/video/linux/v4l2_capture_delegate.cc
|
| diff --git a/media/capture/video/linux/v4l2_capture_delegate.cc b/media/capture/video/linux/v4l2_capture_delegate.cc
|
| index ddc69dc7ba1c91fc4ec5cd8d47851cbd1e382284..d846e416b5153c3b0ffa8d326b8ac83d49b5b0bc 100644
|
| --- a/media/capture/video/linux/v4l2_capture_delegate.cc
|
| +++ b/media/capture/video/linux/v4l2_capture_delegate.cc
|
| @@ -16,10 +16,8 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "build/build_config.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| +#include "media/capture/video/blob_utils.h"
|
| #include "media/capture/video/linux/video_capture_device_linux.h"
|
| -#include "third_party/libyuv/include/libyuv.h"
|
| -#include "third_party/skia/include/core/SkImage.h"
|
| -#include "ui/gfx/codec/png_codec.h"
|
|
|
| namespace media {
|
|
|
| @@ -415,7 +413,8 @@ void V4L2CaptureDelegate::DoCapture() {
|
| std::move(take_photo_callbacks_.front());
|
| take_photo_callbacks_.pop();
|
|
|
| - mojom::BlobPtr blob = GetPhotoBlob(buffer_tracker, buffer.bytesused);
|
| + mojom::BlobPtr blob =
|
| + Blobify(buffer_tracker->start(), buffer.bytesused, capture_format_);
|
| if (blob)
|
| cb.Run(std::move(blob));
|
| }
|
| @@ -430,59 +429,6 @@ void V4L2CaptureDelegate::DoCapture() {
|
| FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this));
|
| }
|
|
|
| -mojom::BlobPtr V4L2CaptureDelegate::GetPhotoBlob(
|
| - const scoped_refptr<BufferTracker>& buffer_tracker,
|
| - const uint32_t bytesused) {
|
| - uint32 src_format;
|
| -
|
| - if (capture_format_.pixel_format == VideoPixelFormat::PIXEL_FORMAT_MJPEG) {
|
| - mojom::BlobPtr blob = mojom::Blob::New();
|
| - blob->data.resize(bytesused);
|
| - memcpy(blob->data.data(), buffer_tracker->start(), bytesused);
|
| - blob->mime_type = "image/jpeg";
|
| - return blob;
|
| - } else if (capture_format_.pixel_format ==
|
| - VideoPixelFormat::PIXEL_FORMAT_UYVY) {
|
| - src_format = libyuv::FOURCC_UYVY;
|
| - } else if (capture_format_.pixel_format ==
|
| - VideoPixelFormat::PIXEL_FORMAT_YUY2) {
|
| - src_format = libyuv::FOURCC_YUY2;
|
| - } else if (capture_format_.pixel_format ==
|
| - VideoPixelFormat::PIXEL_FORMAT_I420) {
|
| - src_format = libyuv::FOURCC_I420;
|
| - } else if (capture_format_.pixel_format ==
|
| - VideoPixelFormat::PIXEL_FORMAT_RGB24) {
|
| - src_format = libyuv::FOURCC_24BG;
|
| - } else {
|
| - return nullptr;
|
| - }
|
| -
|
| - std::unique_ptr<uint8_t[]> dst_argb(new uint8_t[VideoFrame::AllocationSize(
|
| - PIXEL_FORMAT_ARGB, capture_format_.frame_size)]);
|
| - if (ConvertToARGB(buffer_tracker->start(), bytesused, dst_argb.get(),
|
| - capture_format_.frame_size.width() * 4, 0 /* crop_x_pos */,
|
| - 0 /* crop_y_pos */, capture_format_.frame_size.width(),
|
| - capture_format_.frame_size.height(),
|
| - capture_format_.frame_size.width(),
|
| - capture_format_.frame_size.height(),
|
| - libyuv::RotationMode::kRotate0, src_format) != 0) {
|
| - return nullptr;
|
| - }
|
| -
|
| - mojom::BlobPtr blob = mojom::Blob::New();
|
| - const gfx::PNGCodec::ColorFormat codec_color_format =
|
| - (kN32_SkColorType == kRGBA_8888_SkColorType) ? gfx::PNGCodec::FORMAT_RGBA
|
| - : gfx::PNGCodec::FORMAT_BGRA;
|
| - const bool result = gfx::PNGCodec::Encode(
|
| - dst_argb.get(), codec_color_format, capture_format_.frame_size,
|
| - capture_format_.frame_size.width() * 4, true /* discard_transparency */,
|
| - std::vector<gfx::PNGCodec::Comment>(), &blob->data);
|
| - DCHECK(result);
|
| -
|
| - blob->mime_type = "image/png";
|
| - return blob;
|
| -}
|
| -
|
| void V4L2CaptureDelegate::SetErrorState(
|
| const tracked_objects::Location& from_here,
|
| const std::string& reason) {
|
|
|