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

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

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tommi@s nits Created 6 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/fake_video_capture_device.h
diff --git a/media/video/capture/fake_video_capture_device.h b/media/video/capture/fake_video_capture_device.h
index 399a68268fb53d60ec50ff65bd8e3e843eff8bcf..96264e86aa3183500c1ea1dacbe64c7802d2f9a4 100644
--- a/media/video/capture/fake_video_capture_device.h
+++ b/media/video/capture/fake_video_capture_device.h
@@ -20,34 +20,29 @@ namespace media {
class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
public:
- static VideoCaptureDevice* Create(const Name& device_name);
- virtual ~FakeVideoCaptureDevice();
- // Used for testing. This will make sure the next call to Create will
- // return NULL;
- static void SetFailNextCreate();
- static void SetNumberOfFakeDevices(size_t number_of_devices);
- static size_t NumberOfFakeDevices();
+ static const int kFakeCaptureTimeoutMs = 50;
- static void GetDeviceNames(Names* device_names);
- static void GetDeviceSupportedFormats(const Name& device,
- VideoCaptureFormats* supported_formats);
+ FakeVideoCaptureDevice();
+ virtual ~FakeVideoCaptureDevice();
// VideoCaptureDevice implementation.
- virtual void AllocateAndStart(const VideoCaptureParams& params,
- scoped_ptr<VideoCaptureDevice::Client> client)
- OVERRIDE;
+ virtual void AllocateAndStart(
+ const VideoCaptureParams& params,
+ scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE;
virtual void StopAndDeAllocate() OVERRIDE;
- private:
- FakeVideoCaptureDevice();
+ // Sets the formats to use sequentially when the device is configured as
+ // variable capture resolution. Works only before AllocateAndStart() or
+ // after StopAndDeallocate().
+ void PopulateVariableFormatsRoster(const VideoCaptureFormats& formats);
+ private:
// Called on the |capture_thread_| only.
void OnAllocateAndStart(const VideoCaptureParams& params,
scoped_ptr<Client> client);
void OnStopAndDeAllocate();
void OnCaptureTask();
void Reallocate();
- void PopulateFormatRoster();
// |thread_checker_| is used to check that destructor, AllocateAndStart() and
// StopAndDeAllocate() are called in the correct thread that owns the object.
@@ -61,18 +56,12 @@ class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
VideoCaptureFormat capture_format_;
// When the device is allowed to change resolution, this vector holds the
- // available ones which are used in sequence, restarting at the end. These
- // two members belong to and are only used in |capture_thread_|.
+ // available ones, used sequentially restarting at the end. These two members
+ // are initialised in PopulateFormatRoster() before |capture_thread_| is
+ // running and are subsequently read-only in that thread.
std::vector<VideoCaptureFormat> format_roster_;
int format_roster_index_;
- static bool fail_next_create_;
- // |number_of_devices_| is atomic since tests can call SetNumberOfFakeDevices
- // on the IO thread to set |number_of_devices_|. The variable can be
- // read from a separate thread.
- // TODO(perkj): Make tests independent of global state. crbug/323913
- static base::subtle::Atomic32 number_of_devices_;
-
DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice);
};

Powered by Google App Engine
This is Rietveld 408576698