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

Unified Diff: media/capture/video/fake_video_capture_device_factory.h

Issue 2715513008: Make FakeVideoCaptureDeviceFactory configurable to arbitrary fake device configurations (Closed)
Patch Set: emircan@ suggestions Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/fake_video_capture_device_factory.h
diff --git a/media/capture/video/fake_video_capture_device_factory.h b/media/capture/video/fake_video_capture_device_factory.h
index 7fb0597fe7e99f61ae5def6f4ce500a1b4b738a3..06ed42ed1ee1c2a05f787df27b8c1ae4a6688c0f 100644
--- a/media/capture/video/fake_video_capture_device_factory.h
+++ b/media/capture/video/fake_video_capture_device_factory.h
@@ -10,20 +10,56 @@
namespace media {
+struct CAPTURE_EXPORT FakeVideoCaptureDeviceSettings {
+ FakeVideoCaptureDeviceSettings();
+ ~FakeVideoCaptureDeviceSettings();
+ FakeVideoCaptureDeviceSettings(const FakeVideoCaptureDeviceSettings& other);
+
+ std::string device_id;
+ FakeVideoCaptureDevice::DeliveryMode delivery_mode;
+ VideoCaptureFormats supported_formats;
+};
+
// Implementation of VideoCaptureDeviceFactory that creates fake devices
// that generate test output frames.
-// By default, the factory has one device outputting I420.
-// When increasing the number of devices using set_number_of_devices(), the
-// second device will use Y16, and any devices beyond that will use I420.
-// By default, the delivery mode of all devices is USE_OWN_BUFFERS.
-// This, as well as other parameters, can be changed using command-line flags.
-// See implementation of method ParseCommandLine() for details.
+// By default, the factory has one device outputting I420 with
+// USE_DEVICE_INTERNAL_BUFFERS. It supports a default set of resolutions.
+// When a resolution is requested that is not part of the default set, it snaps
+// to the resolution with the next larger width. It supports all frame rates
+// within a default allowed range.
class CAPTURE_EXPORT FakeVideoCaptureDeviceFactory
: public VideoCaptureDeviceFactory {
public:
FakeVideoCaptureDeviceFactory();
- ~FakeVideoCaptureDeviceFactory() override {}
+ ~FakeVideoCaptureDeviceFactory() override;
+
+ static std::unique_ptr<VideoCaptureDevice> CreateDeviceWithSupportedFormats(
+ FakeVideoCaptureDevice::DeliveryMode delivery_mode,
+ const VideoCaptureFormats& formats);
+
+ static std::unique_ptr<VideoCaptureDevice> CreateDeviceWithDefaultResolutions(
+ VideoPixelFormat pixel_format,
+ FakeVideoCaptureDevice::DeliveryMode delivery_mode,
+ float frame_rate);
+
+ // Creates a device that reports OnError() when AllocateAndStart() is called.
+ static std::unique_ptr<VideoCaptureDevice> CreateErrorDevice();
+ static void ParseFakeDevicesConfigFromOptionsString(
+ const std::string options_string,
+ std::vector<FakeVideoCaptureDeviceSettings>* config);
+
+ // All devices use the default set of resolution, the default range for
+ // allowed frame rates, as well as USE_DEVICE_INTERNAL_BUFFERS.
+ // Device 0 outputs I420.
+ // Device 1 outputs Y16.
+ // Device 2 outputs MJPEG.
+ // All additional devices output I420.
+ void SetToDefaultDevicesConfig(int device_count);
+ void SetToCustomDevicesConfig(
+ const std::vector<FakeVideoCaptureDeviceSettings>& config);
+
+ // VideoCaptureDeviceFactory implementation:
std::unique_ptr<VideoCaptureDevice> CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) override;
void GetDeviceDescriptors(
@@ -32,22 +68,13 @@ class CAPTURE_EXPORT FakeVideoCaptureDeviceFactory
const VideoCaptureDeviceDescriptor& device_descriptor,
VideoCaptureFormats* supported_formats) override;
- void set_number_of_devices(int number_of_devices) {
- DCHECK(thread_checker_.CalledOnValidThread());
- number_of_devices_ = number_of_devices;
- }
int number_of_devices() {
DCHECK(thread_checker_.CalledOnValidThread());
- return number_of_devices_;
+ return static_cast<int>(devices_config_.size());
}
private:
- void ParseCommandLine();
-
- int number_of_devices_;
- FakeVideoCaptureDeviceMaker::DeliveryMode delivery_mode_;
- float frame_rate_;
- bool command_line_parsed_ = false;
+ std::vector<FakeVideoCaptureDeviceSettings> devices_config_;
};
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698