[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / media / video / capture / fake_video_capture_device_factory.cc
blob494bcf567ade70ce7141fbc95b88862447faf164
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/video/capture/fake_video_capture_device_factory.h"
7 #include "base/strings/stringprintf.h"
8 #include "media/video/capture/fake_video_capture_device.h"
10 namespace media {
12 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory()
13 : number_of_devices_(1) {
16 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create(
17 const VideoCaptureDevice::Name& device_name) {
18 DCHECK(thread_checker_.CalledOnValidThread());
19 for (int n = 0; n < number_of_devices_; ++n) {
20 std::string possible_id = base::StringPrintf("/dev/video%d", n);
21 if (device_name.id().compare(possible_id) == 0)
22 return scoped_ptr<VideoCaptureDevice>(new FakeVideoCaptureDevice());
24 return scoped_ptr<VideoCaptureDevice>();
27 void FakeVideoCaptureDeviceFactory::GetDeviceNames(
28 VideoCaptureDevice::Names* const device_names) {
29 DCHECK(thread_checker_.CalledOnValidThread());
30 DCHECK(device_names->empty());
31 for (int n = 0; n < number_of_devices_; ++n) {
32 VideoCaptureDevice::Name name(base::StringPrintf("fake_device_%d", n),
33 base::StringPrintf("/dev/video%d", n)
34 #if defined(OS_MACOSX)
35 , VideoCaptureDevice::Name::AVFOUNDATION
36 #elif defined(OS_WIN)
37 , VideoCaptureDevice::Name::DIRECT_SHOW
38 #endif
40 device_names->push_back(name);
44 void FakeVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
45 const VideoCaptureDevice::Name& device,
46 VideoCaptureFormats* supported_formats) {
47 DCHECK(thread_checker_.CalledOnValidThread());
48 const int frame_rate = 1000 / FakeVideoCaptureDevice::kFakeCaptureTimeoutMs;
49 const gfx::Size supported_sizes[] = {gfx::Size(320, 240),
50 gfx::Size(640, 480),
51 gfx::Size(1280, 720),
52 gfx::Size(1920, 1080)};
53 supported_formats->clear();
54 for (size_t i = 0; i < arraysize(supported_sizes); ++i) {
55 supported_formats->push_back(VideoCaptureFormat(supported_sizes[i],
56 frame_rate,
57 media::PIXEL_FORMAT_I420));
61 } // namespace media