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 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "media/video/capture/video_capture_device.h" | 15 #include "media/video/capture/video_capture_device.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { | 19 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { |
20 public: | 20 public: |
21 static VideoCaptureDevice* Create(const Name& device_name); | 21 static VideoCaptureDevice* Create(const Name& device_name, |
22 bool encoded_capture); | |
Ami GONE FROM CHROMIUM
2013/06/18 18:35:55
indent is off here and elsewhere in the CL. Pleas
sheu
2013/08/22 22:40:31
Not sure what you mean here?
| |
22 virtual ~FakeVideoCaptureDevice(); | 23 virtual ~FakeVideoCaptureDevice(); |
23 // Used for testing. This will make sure the next call to Create will | 24 // Used for testing. This will make sure the next call to Create will |
24 // return NULL; | 25 // return NULL; |
25 static void SetFailNextCreate(); | 26 static void SetFailNextCreate(); |
26 | 27 |
27 static void GetDeviceNames(Names* device_names); | 28 static void GetDeviceNames(Names* device_names, bool encoded_capture); |
Ami GONE FROM CHROMIUM
2013/06/18 18:35:55
Why pass this in if not to inspect it in Create()
sheu
2013/08/22 22:40:31
Not quite following here. GetDeviceNames() constr
| |
28 | 29 |
29 // VideoCaptureDevice implementation. | 30 // VideoCaptureDevice implementation. |
31 virtual VideoEncodingCapabilities GetEncodingCapabilities() OVERRIDE; | |
32 virtual void TryConfigureEncodedBitstream( | |
33 const RuntimeVideoEncodingParameters& params) OVERRIDE; | |
30 virtual void Allocate(int width, | 34 virtual void Allocate(int width, |
31 int height, | 35 int height, |
32 int frame_rate, | 36 int frame_rate, |
33 VideoCaptureDevice::EventHandler* observer) OVERRIDE; | 37 VideoCaptureDevice::EventHandler* observer) OVERRIDE; |
34 virtual void Start() OVERRIDE; | 38 virtual void Start() OVERRIDE; |
35 virtual void Stop() OVERRIDE; | 39 virtual void Stop() OVERRIDE; |
36 virtual void DeAllocate() OVERRIDE; | 40 virtual void DeAllocate() OVERRIDE; |
37 virtual const Name& device_name() OVERRIDE; | 41 virtual const Name& device_name() OVERRIDE; |
38 | 42 |
39 private: | 43 private: |
40 // Flag indicating the internal state. | 44 // Flag indicating the internal state. |
41 enum InternalState { | 45 enum InternalState { |
42 kIdle, | 46 kIdle, |
43 kAllocated, | 47 kAllocated, |
44 kCapturing, | 48 kCapturing, |
45 kError | 49 kError |
46 }; | 50 }; |
47 explicit FakeVideoCaptureDevice(const Name& device_name); | 51 explicit FakeVideoCaptureDevice(const Name& device_name, |
52 bool encoded_capture); | |
48 | 53 |
49 // Called on the capture_thread_. | 54 // Called on the capture_thread_. |
50 void OnCaptureTask(); | 55 void OnCaptureTask(); |
51 | 56 |
52 Name device_name_; | 57 Name device_name_; |
58 bool encoded_capture_; | |
53 VideoCaptureDevice::EventHandler* observer_; | 59 VideoCaptureDevice::EventHandler* observer_; |
54 InternalState state_; | 60 InternalState state_; |
55 base::Thread capture_thread_; | 61 base::Thread capture_thread_; |
56 int frame_size_; | 62 int frame_size_; |
57 scoped_ptr<uint8[]> fake_frame_; | 63 scoped_ptr<uint8[]> fake_frame_; |
64 scoped_refptr<media::EncodedBitstreamBuffer> fake_encoded_bitstream_buffer_; | |
Ami GONE FROM CHROMIUM
2013/06/18 18:35:55
unused
sheu
2013/08/22 22:40:31
Done.
| |
58 int frame_count_; | 65 int frame_count_; |
59 int frame_width_; | 66 int frame_width_; |
60 int frame_height_; | 67 int frame_height_; |
61 | 68 |
62 static bool fail_next_create_; | 69 static bool fail_next_create_; |
63 | 70 |
64 DISALLOW_IMPLICIT_CONSTRUCTORS(FakeVideoCaptureDevice); | 71 DISALLOW_IMPLICIT_CONSTRUCTORS(FakeVideoCaptureDevice); |
65 }; | 72 }; |
66 | 73 |
67 } // namespace media | 74 } // namespace media |
68 | 75 |
69 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ | 76 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |