OLD | NEW |
---|---|
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 #ifndef MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
6 #define MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 6 #define MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
7 | 7 |
8 #include "media/capture/video/fake_video_capture_device.h" | 8 #include "media/capture/video/fake_video_capture_device.h" |
9 #include "media/capture/video/video_capture_device_factory.h" | 9 #include "media/capture/video/video_capture_device_factory.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 // Implementation of VideoCaptureDeviceFactory that creates fake devices | 13 // Implementation of VideoCaptureDeviceFactory that creates fake devices |
14 // that generate test output frames. | 14 // that generate test output frames. |
15 // By default, the factory has one device outputting I420. | 15 // By default, the factory has one device outputting I420. |
16 // When increasing the number of devices using set_number_of_devices(), the | 16 // When increasing the number of devices using set_number_of_devices(), the |
17 // second device will use Y16, and any devices beyond that will use I420. | 17 // second device will use Y16, and any devices beyond that will use I420. |
18 // By default, the delivery mode of all devices is USE_OWN_BUFFERS. | 18 // By default, the delivery mode of all devices is USE_OWN_BUFFERS. |
19 // This, as well as other parameters, can be changed using command-line flags. | 19 // This, as well as other parameters, can be changed using command-line flags. |
20 // See implementation of method ParseCommandLine() for details. | 20 // See implementation of method ParseCommandLine() for details. |
21 class CAPTURE_EXPORT FakeVideoCaptureDeviceFactory | 21 class CAPTURE_EXPORT FakeVideoCaptureDeviceFactory |
22 : public VideoCaptureDeviceFactory { | 22 : public VideoCaptureDeviceFactory { |
23 public: | 23 public: |
24 FakeVideoCaptureDeviceFactory(); | 24 FakeVideoCaptureDeviceFactory(); |
25 ~FakeVideoCaptureDeviceFactory() override {} | 25 ~FakeVideoCaptureDeviceFactory() override {} |
26 | 26 |
27 static media::VideoPixelFormat GetPixelFormatFromDeviceId( | |
mcasas
2017/02/17 18:35:47
Should be private, but better than that just keep
chfremer
2017/02/22 17:28:42
The reason I am exposing this here is because the
mcasas
2017/02/22 20:26:32
Duplication for a test is OK, otherwise we'd be co
chfremer
2017/02/23 01:14:27
Duplication for a test can be problematic. We want
mcasas
2017/02/23 21:46:18
I like this "are you sure" :-) and I'm not the on
| |
28 const std::string& device_id); | |
29 | |
27 std::unique_ptr<VideoCaptureDevice> CreateDevice( | 30 std::unique_ptr<VideoCaptureDevice> CreateDevice( |
28 const VideoCaptureDeviceDescriptor& device_descriptor) override; | 31 const VideoCaptureDeviceDescriptor& device_descriptor) override; |
29 void GetDeviceDescriptors( | 32 void GetDeviceDescriptors( |
30 VideoCaptureDeviceDescriptors* device_descriptors) override; | 33 VideoCaptureDeviceDescriptors* device_descriptors) override; |
31 void GetSupportedFormats( | 34 void GetSupportedFormats( |
32 const VideoCaptureDeviceDescriptor& device_descriptor, | 35 const VideoCaptureDeviceDescriptor& device_descriptor, |
33 VideoCaptureFormats* supported_formats) override; | 36 VideoCaptureFormats* supported_formats) override; |
34 | 37 |
35 void set_number_of_devices(int number_of_devices) { | 38 void set_number_of_devices(int number_of_devices) { |
36 DCHECK(thread_checker_.CalledOnValidThread()); | 39 DCHECK(thread_checker_.CalledOnValidThread()); |
37 number_of_devices_ = number_of_devices; | 40 number_of_devices_ = number_of_devices; |
38 } | 41 } |
39 int number_of_devices() { | 42 int number_of_devices() { |
40 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
41 return number_of_devices_; | 44 return number_of_devices_; |
42 } | 45 } |
43 | 46 |
44 private: | 47 private: |
45 void ParseCommandLine(); | 48 void ParseCommandLine(); |
46 | 49 |
47 int number_of_devices_; | 50 int number_of_devices_; |
48 FakeVideoCaptureDeviceMaker::DeliveryMode delivery_mode_; | 51 FakeVideoCaptureDeviceMaker::DeliveryMode delivery_mode_; |
49 float frame_rate_; | 52 float frame_rate_; |
50 bool command_line_parsed_ = false; | 53 bool command_line_parsed_ = false; |
51 }; | 54 }; |
52 | 55 |
53 } // namespace media | 56 } // namespace media |
54 | 57 |
55 #endif // MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ | 58 #endif // MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ |
OLD | NEW |