Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: media/video/capture/fake_video_capture_device_factory.cc

Issue 1064963002: VideoCapture: add support for GpuMemoryBuffer allocation and lifetime mgmt in VideoCaptureBufferPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/video/capture/fake_video_capture_device_factory.h" 5 #include "media/video/capture/fake_video_capture_device_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "media/base/media_switches.h" 10 #include "media/base/media_switches.h"
11 #include "media/video/capture/fake_video_capture_device.h" 11 #include "media/video/capture/fake_video_capture_device.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() 15 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory()
16 : number_of_devices_(1) { 16 : number_of_devices_(1) {
17 } 17 }
18 18
19 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create( 19 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create(
20 const VideoCaptureDevice::Name& device_name) { 20 const VideoCaptureDevice::Name& device_name) {
21 DCHECK(thread_checker_.CalledOnValidThread()); 21 DCHECK(thread_checker_.CalledOnValidThread());
22 22
23 const std::string option = base::CommandLine::ForCurrentProcess()-> 23 const std::string option = base::CommandLine::ForCurrentProcess()->
24 GetSwitchValueASCII(switches::kUseFakeDeviceForMediaStream); 24 GetSwitchValueASCII(switches::kUseFakeDeviceForMediaStream);
25 25
26 FakeVideoCaptureDevice::FakeVideoCaptureDeviceType fake_vcd_type; 26 FakeVideoCaptureDevice::FakeVideoCaptureDeviceType fake_vcd_type;
27 if (option.empty()) 27 if (option.empty())
28 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS; 28 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS;
29 else if (base:: strcasecmp(option.c_str(), "triplanar") == 0)
30 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS_TRIPLANAR;
29 else if (base:: strcasecmp(option.c_str(), "gpu") == 0) 31 else if (base:: strcasecmp(option.c_str(), "gpu") == 0)
30 fake_vcd_type = FakeVideoCaptureDevice::USING_GPU_MEMORY_BUFFERS; 32 fake_vcd_type = FakeVideoCaptureDevice::USING_GPU_MEMORY_BUFFERS;
31 else 33 else
32 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS; 34 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS;
33 35
34 for (int n = 0; n < number_of_devices_; ++n) { 36 for (int n = 0; n < number_of_devices_; ++n) {
35 std::string possible_id = base::StringPrintf("/dev/video%d", n); 37 std::string possible_id = base::StringPrintf("/dev/video%d", n);
36 if (device_name.id().compare(possible_id) == 0) { 38 if (device_name.id().compare(possible_id) == 0) {
37 return scoped_ptr<VideoCaptureDevice>( 39 return scoped_ptr<VideoCaptureDevice>(
38 new FakeVideoCaptureDevice(fake_vcd_type)); 40 new FakeVideoCaptureDevice(fake_vcd_type));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 gfx::Size(1920, 1080)}; 75 gfx::Size(1920, 1080)};
74 supported_formats->clear(); 76 supported_formats->clear();
75 for (const auto& size : supported_sizes) { 77 for (const auto& size : supported_sizes) {
76 supported_formats->push_back(VideoCaptureFormat(size, 78 supported_formats->push_back(VideoCaptureFormat(size,
77 frame_rate, 79 frame_rate,
78 media::PIXEL_FORMAT_I420)); 80 media::PIXEL_FORMAT_I420));
79 } 81 }
80 } 82 }
81 83
82 } // namespace media 84 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698