| Index: media/capture/video/fake_video_capture_device.cc
|
| diff --git a/media/capture/video/fake_video_capture_device.cc b/media/capture/video/fake_video_capture_device.cc
|
| index fef7de5aeef1669dd887f42a1f1fd9c704cacdb8..2c8a1c881eed057ba0f522de880e542b4253c2fa 100644
|
| --- a/media/capture/video/fake_video_capture_device.cc
|
| +++ b/media/capture/video/fake_video_capture_device.cc
|
| @@ -12,6 +12,7 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "media/audio/fake_audio_input_stream.h"
|
| #include "media/base/video_frame.h"
|
| +#include "mojo/public/cpp/bindings/string.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| @@ -75,25 +76,26 @@ void DrawPacman(bool use_argb,
|
|
|
| // Creates a PNG-encoded frame and sends it back to |callback|. The other
|
| // parameters are used to replicate the PacMan rendering.
|
| -void DoTakeFakePhoto(const VideoCaptureDevice::TakePhotoCallback& callback,
|
| - const VideoCaptureFormat& capture_format,
|
| - base::TimeDelta elapsed_time,
|
| - float fake_capture_rate) {
|
| +void DoTakeFakePhoto(
|
| + ScopedResultCallback<VideoCaptureDevice::TakePhotoCallback> callback,
|
| + const VideoCaptureFormat& capture_format,
|
| + base::TimeDelta elapsed_time,
|
| + float fake_capture_rate) {
|
| std::unique_ptr<uint8_t[]> buffer(new uint8_t[VideoFrame::AllocationSize(
|
| PIXEL_FORMAT_ARGB, capture_format.frame_size)]);
|
|
|
| DrawPacman(true /* use_argb */, buffer.get(), elapsed_time, fake_capture_rate,
|
| capture_format.frame_size);
|
|
|
| - std::unique_ptr<std::vector<uint8_t>> encoded_data(
|
| - new std::vector<uint8_t>());
|
| + std::vector<uint8_t> encoded_data;
|
| const bool result = gfx::PNGCodec::Encode(
|
| buffer.get(), gfx::PNGCodec::FORMAT_RGBA, capture_format.frame_size,
|
| capture_format.frame_size.width() * 4, true /* discard_transparency */,
|
| - std::vector<gfx::PNGCodec::Comment>(), encoded_data.get());
|
| + std::vector<gfx::PNGCodec::Comment>(), &encoded_data);
|
| DCHECK(result);
|
|
|
| - callback.Run("image/png", std::move(encoded_data));
|
| + callback.Run(mojo::String::From("image/png"),
|
| + mojo::Array<uint8_t>::From(encoded_data));
|
| }
|
|
|
| FakeVideoCaptureDevice::FakeVideoCaptureDevice(BufferOwnership buffer_ownership,
|
| @@ -161,12 +163,12 @@ void FakeVideoCaptureDevice::StopAndDeAllocate() {
|
| client_.reset();
|
| }
|
|
|
| -bool FakeVideoCaptureDevice::TakePhoto(
|
| - const TakePhotoCallback& photo_callback) {
|
| +void FakeVideoCaptureDevice::TakePhoto(
|
| + ScopedResultCallback<TakePhotoCallback> callback) {
|
| base::MessageLoop::current()->PostTask(
|
| - FROM_HERE, base::Bind(&DoTakeFakePhoto, photo_callback, capture_format_,
|
| - elapsed_time_, fake_capture_rate_));
|
| - return true;
|
| + FROM_HERE,
|
| + base::Bind(&DoTakeFakePhoto, base::Passed(&callback), capture_format_,
|
| + elapsed_time_, fake_capture_rate_));
|
| }
|
|
|
| void FakeVideoCaptureDevice::CaptureUsingOwnBuffers(
|
|
|