Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / media / video / capture / fake_video_capture_device.h
blobf4a19f9edb9c2c6611aa8d66cc15094f905ead7f
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/atomicops.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread.h"
17 #include "base/threading/thread_checker.h"
18 #include "media/video/capture/video_capture_device.h"
20 namespace media {
22 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
23 public:
24 enum FakeVideoCaptureDeviceType {
25 USING_OWN_BUFFERS,
26 USING_OWN_BUFFERS_TRIPLANAR,
27 USING_CLIENT_BUFFERS_I420,
28 USING_CLIENT_BUFFERS_GPU,
31 static int FakeCapturePeriodMs() { return kFakeCapturePeriodMs; }
33 explicit FakeVideoCaptureDevice(FakeVideoCaptureDeviceType device_type);
34 ~FakeVideoCaptureDevice() override;
36 // VideoCaptureDevice implementation.
37 void AllocateAndStart(const VideoCaptureParams& params,
38 scoped_ptr<Client> client) override;
39 void StopAndDeAllocate() override;
41 private:
42 static const int kFakeCapturePeriodMs = 50;
44 void CaptureUsingOwnBuffers();
45 void CaptureUsingClientBuffers(VideoPixelFormat pixel_format);
46 void BeepAndScheduleNextCapture(const base::Closure& next_capture);
48 // |thread_checker_| is used to check that all methods are called in the
49 // correct thread that owns the object.
50 base::ThreadChecker thread_checker_;
52 const FakeVideoCaptureDeviceType device_type_;
54 scoped_ptr<VideoCaptureDevice::Client> client_;
55 // |fake_frame_| is used for capturing on Own Buffers.
56 scoped_ptr<uint8[]> fake_frame_;
57 int frame_count_;
58 VideoCaptureFormat capture_format_;
60 // FakeVideoCaptureDevice post tasks to itself for frame construction and
61 // needs to deal with asynchronous StopAndDeallocate().
62 base::WeakPtrFactory<FakeVideoCaptureDevice> weak_factory_;
64 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice);
67 } // namespace media
69 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_