OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // Implementation of a fake VideoCaptureDevice class. Used for testing other | 5 // Implementation of a fake VideoCaptureDevice class. Used for testing other |
6 // video capture classes when no real hardware is available. | 6 // video capture classes when no real hardware is available. |
7 | 7 |
8 #ifndef MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 8 #ifndef MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
9 #define MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 9 #define MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 virtual ~FakeVideoCaptureDevice(); | 22 virtual ~FakeVideoCaptureDevice(); |
23 // Used for testing. This will make sure the next call to Create will | 23 // Used for testing. This will make sure the next call to Create will |
24 // return NULL; | 24 // return NULL; |
25 static void SetFailNextCreate(); | 25 static void SetFailNextCreate(); |
26 | 26 |
27 static void GetDeviceNames(Names* device_names); | 27 static void GetDeviceNames(Names* device_names); |
28 static void GetDeviceSupportedFormats(const Name& device, | 28 static void GetDeviceSupportedFormats(const Name& device, |
29 VideoCaptureCapabilities* formats); | 29 VideoCaptureCapabilities* formats); |
30 | 30 |
31 // VideoCaptureDevice implementation. | 31 // VideoCaptureDevice implementation. |
32 virtual void AllocateAndStart( | 32 virtual void AllocateAndStart(const VideoCaptureParams& params, |
33 const VideoCaptureCapability& capture_format, | 33 scoped_ptr<VideoCaptureDevice::Client> client) |
34 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; | 34 OVERRIDE; |
35 virtual void StopAndDeAllocate() OVERRIDE; | 35 virtual void StopAndDeAllocate() OVERRIDE; |
36 | 36 |
37 private: | 37 private: |
38 // Flag indicating the internal state. | 38 // Flag indicating the internal state. |
39 enum InternalState { | 39 enum InternalState { |
40 kIdle, | 40 kIdle, |
41 kCapturing, | 41 kCapturing, |
42 kError | 42 kError |
43 }; | 43 }; |
44 FakeVideoCaptureDevice(); | 44 FakeVideoCaptureDevice(); |
45 | 45 |
46 // Called on the capture_thread_. | 46 // Called on the capture_thread_. |
47 void OnCaptureTask(); | 47 void OnCaptureTask(); |
48 | 48 |
49 // EXPERIMENTAL, similar to allocate, but changes resolution and calls | 49 // EXPERIMENTAL, similar to allocate, but changes resolution and calls |
50 // client->OnFrameInfoChanged(VideoCaptureCapability&) | 50 // client->OnFrameInfoChanged(VideoCaptureCapability&) |
51 void Reallocate(); | 51 void Reallocate(); |
52 void PopulateCapabilitiesRoster(); | 52 void PopulateFormatRoster(); |
53 | 53 |
54 scoped_ptr<VideoCaptureDevice::Client> client_; | 54 scoped_ptr<VideoCaptureDevice::Client> client_; |
55 InternalState state_; | 55 InternalState state_; |
56 base::Thread capture_thread_; | 56 base::Thread capture_thread_; |
57 scoped_ptr<uint8[]> fake_frame_; | 57 scoped_ptr<uint8[]> fake_frame_; |
58 int frame_count_; | 58 int frame_count_; |
59 VideoCaptureCapability capture_format_; | 59 VideoCaptureFormat capture_format_; |
60 | 60 |
61 // When the device is configured as mutating video captures, this vector | 61 // When the device is configured as mutating video captures, this vector |
62 // holds the available ones which are used in sequence, restarting at the end. | 62 // holds the available ones which are used in sequence, restarting at the end. |
63 std::vector<VideoCaptureCapability> capabilities_roster_; | 63 std::vector<VideoCaptureFormat> format_roster_; |
64 int capabilities_roster_index_; | 64 int format_roster_index_; |
65 | 65 |
66 static bool fail_next_create_; | 66 static bool fail_next_create_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); | 68 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace media | 71 } // namespace media |
72 | 72 |
73 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 73 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |