cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / video / capture / fake_video_capture_device.h
blob4804c2885a946ce1a9f3ea87fc0866e52b0b2638
1 // Copyright (c) 2012 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 // Implementation of a fake VideoCaptureDevice class. Used for testing other
6 // video capture classes when no real hardware is available.
8 #ifndef MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
9 #define MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
11 #include <string>
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h"
15 #include "media/video/capture/video_capture_device.h"
17 namespace media {
19 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
20 public:
21 static VideoCaptureDevice* Create(const Name& device_name);
22 virtual ~FakeVideoCaptureDevice();
23 // Used for testing. This will make sure the next call to Create will
24 // return NULL;
25 static void SetFailNextCreate();
27 static void GetDeviceNames(Names* device_names);
29 // VideoCaptureDevice implementation.
30 virtual void Allocate(const VideoCaptureCapability& capture_format,
31 VideoCaptureDevice::EventHandler* observer) OVERRIDE;
32 virtual void Start() OVERRIDE;
33 virtual void Stop() OVERRIDE;
34 virtual void DeAllocate() OVERRIDE;
35 virtual const Name& device_name() OVERRIDE;
37 private:
38 // Flag indicating the internal state.
39 enum InternalState {
40 kIdle,
41 kAllocated,
42 kCapturing,
43 kError
45 explicit FakeVideoCaptureDevice(const Name& device_name);
47 // Called on the capture_thread_.
48 void OnCaptureTask();
50 // EXPERIMENTAL, similar to allocate, but changes resolution and calls
51 // observer->OnFrameInfoChanged(VideoCaptureCapability&)
52 void Reallocate();
53 void PopulateCapabilitiesRoster();
55 Name device_name_;
56 VideoCaptureDevice::EventHandler* observer_;
57 InternalState state_;
58 base::Thread capture_thread_;
59 scoped_ptr<uint8[]> fake_frame_;
60 int frame_count_;
61 VideoCaptureCapability capture_format_;
63 // When the device is configured as mutating video captures, this vector
64 // holds the available ones which are used in sequence, restarting at the end.
65 std::vector<VideoCaptureCapability> capabilities_roster_;
66 int capabilities_roster_index_;
68 static bool fail_next_create_;
70 DISALLOW_IMPLICIT_CONSTRUCTORS(FakeVideoCaptureDevice);
73 } // namespace media
75 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_