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

Side by Side Diff: media/video/capture/fake_video_capture_device.h

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make sure devices are not enumerated unless there is a valid security origin. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/atomicops.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "media/video/capture/video_capture_device.h" 16 #include "media/video/capture/video_capture_device.h"
16 17
17 namespace media { 18 namespace media {
18 19
19 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice { 20 class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
20 public: 21 public:
21 static VideoCaptureDevice* Create(const Name& device_name); 22 static VideoCaptureDevice* Create(const Name& device_name);
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();
27 static void SetNumberOfFakeDevices(size_t number_of_devices);
26 28
27 static void GetDeviceNames(Names* device_names); 29 static void GetDeviceNames(Names* device_names);
28 static void GetDeviceSupportedFormats(const Name& device, 30 static void GetDeviceSupportedFormats(const Name& device,
29 VideoCaptureCapabilities* formats); 31 VideoCaptureCapabilities* formats);
30 32
31 // VideoCaptureDevice implementation. 33 // VideoCaptureDevice implementation.
32 virtual void AllocateAndStart(const VideoCaptureParams& params, 34 virtual void AllocateAndStart(const VideoCaptureParams& params,
33 scoped_ptr<VideoCaptureDevice::Client> client) 35 scoped_ptr<VideoCaptureDevice::Client> client)
34 OVERRIDE; 36 OVERRIDE;
35 virtual void StopAndDeAllocate() OVERRIDE; 37 virtual void StopAndDeAllocate() OVERRIDE;
(...skipping 21 matching lines...) Expand all
57 scoped_ptr<uint8[]> fake_frame_; 59 scoped_ptr<uint8[]> fake_frame_;
58 int frame_count_; 60 int frame_count_;
59 VideoCaptureFormat capture_format_; 61 VideoCaptureFormat capture_format_;
60 62
61 // When the device is configured as mutating video captures, this vector 63 // 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. 64 // holds the available ones which are used in sequence, restarting at the end.
63 std::vector<VideoCaptureFormat> format_roster_; 65 std::vector<VideoCaptureFormat> format_roster_;
64 int format_roster_index_; 66 int format_roster_index_;
65 67
66 static bool fail_next_create_; 68 static bool fail_next_create_;
69 static base::subtle::Atomic32 number_of_devices_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice); 71 DISALLOW_COPY_AND_ASSIGN(FakeVideoCaptureDevice);
69 }; 72 };
70 73
71 } // namespace media 74 } // namespace media
72 75
73 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_ 76 #endif // MEDIA_VIDEO_CAPTURE_FAKE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698