| Index: media/capture/video/fake_video_capture_device_factory.cc
|
| diff --git a/media/capture/video/fake_video_capture_device_factory.cc b/media/capture/video/fake_video_capture_device_factory.cc
|
| index 49df8e6b962a159f5997396eb98e194e31224032..25fb85a8b47c7e86a4893424c31943798afbb539 100644
|
| --- a/media/capture/video/fake_video_capture_device_factory.cc
|
| +++ b/media/capture/video/fake_video_capture_device_factory.cc
|
| @@ -13,19 +13,9 @@
|
| #include "build/build_config.h"
|
| #include "media/base/media_switches.h"
|
|
|
| -namespace {
|
| +namespace media {
|
|
|
| static const size_t kDepthDeviceIndex = 1;
|
| -static const char kDepthDeviceId[] = "/dev/video1";
|
| -
|
| -media::VideoPixelFormat GetPixelFormatFromDeviceId(
|
| - const std::string& device_id) {
|
| - return (device_id == kDepthDeviceId) ? media::PIXEL_FORMAT_Y16
|
| - : media::PIXEL_FORMAT_I420;
|
| -}
|
| -}
|
| -
|
| -namespace media {
|
|
|
| // Cap the frame rate command line input to reasonable values.
|
| static const float kFakeCaptureMinFrameRate = 5.0f;
|
| @@ -42,6 +32,17 @@ FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory()
|
| USE_DEVICE_INTERNAL_BUFFERS),
|
| frame_rate_(kFakeCaptureDefaultFrameRate) {}
|
|
|
| +// static
|
| +FakeVideoCaptureDeviceMaker::PixelFormat
|
| +FakeVideoCaptureDeviceFactory::GetPixelFormatFromDeviceId(
|
| + const std::string& device_id) {
|
| + if (device_id == "/dev/video1")
|
| + return FakeVideoCaptureDeviceMaker::PixelFormat::Y16;
|
| + if (device_id == "/dev/video2")
|
| + return FakeVideoCaptureDeviceMaker::PixelFormat::MJPEG;
|
| + return FakeVideoCaptureDeviceMaker::PixelFormat::I420;
|
| +}
|
| +
|
| std::unique_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::CreateDevice(
|
| const VideoCaptureDeviceDescriptor& device_descriptor) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| @@ -51,8 +52,19 @@ std::unique_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::CreateDevice(
|
| for (int n = 0; n < number_of_devices_; ++n) {
|
| std::string possible_id = base::StringPrintf("/dev/video%d", n);
|
| if (device_descriptor.device_id.compare(possible_id) == 0) {
|
| + FakeVideoCaptureDeviceMaker::PixelFormat pixel_format =
|
| + GetPixelFormatFromDeviceId(possible_id);
|
| + FakeVideoCaptureDeviceMaker::DeliveryMode delivery_mode = delivery_mode_;
|
| + if (delivery_mode ==
|
| + FakeVideoCaptureDeviceMaker::DeliveryMode::
|
| + USE_CLIENT_PROVIDED_BUFFERS &&
|
| + pixel_format == FakeVideoCaptureDeviceMaker::PixelFormat::MJPEG) {
|
| + // Incompatible options. Fall back to using internal buffers.
|
| + delivery_mode = FakeVideoCaptureDeviceMaker::DeliveryMode::
|
| + USE_DEVICE_INTERNAL_BUFFERS;
|
| + }
|
| return FakeVideoCaptureDeviceMaker::MakeInstance(
|
| - GetPixelFormatFromDeviceId(possible_id), delivery_mode_, frame_rate_);
|
| + pixel_format, delivery_mode, frame_rate_);
|
| }
|
| }
|
| return std::unique_ptr<VideoCaptureDevice>();
|
| @@ -101,7 +113,8 @@ void FakeVideoCaptureDeviceFactory::GetSupportedFormats(
|
| ParseCommandLine();
|
|
|
| const VideoPixelFormat pixel_format =
|
| - GetPixelFormatFromDeviceId(device_descriptor.device_id);
|
| + FakeVideoCaptureDeviceMaker::TranslateToMediaVideoPixelFormat(
|
| + GetPixelFormatFromDeviceId(device_descriptor.device_id));
|
| const VideoPixelStorage pixel_storage = PIXEL_STORAGE_CPU;
|
| std::vector<gfx::Size> supported_sizes;
|
| FakeVideoCaptureDeviceMaker::GetSupportedSizes(&supported_sizes);
|
|
|