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

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

Issue 17402002: Reconnect support for DirectShow video capture devices in parallel to MediaFoundation ones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CaptureApiType wrapped into a CaptureApiClass for default value. Created 7 years, 5 months 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
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 // VideoCaptureDevice is the abstract base class for realizing video capture 5 // VideoCaptureDevice is the abstract base class for realizing video capture
6 // device support in Chromium. It provides the interface for OS dependent 6 // device support in Chromium. It provides the interface for OS dependent
7 // implementations. 7 // implementations.
8 // The class is created and functions are invoked on a thread owned by 8 // The class is created and functions are invoked on a thread owned by
9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS
10 // specific implementation. 10 // specific implementation.
11 11
12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
14 14
15 #include <list> 15 #include <list>
16 #include <string> 16 #include <string>
17 17
18 #include "base/logging.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "media/base/media_export.h" 20 #include "media/base/media_export.h"
20 #include "media/video/capture/video_capture_types.h" 21 #include "media/video/capture/video_capture_types.h"
21 22
22 namespace media { 23 namespace media {
23 24
24 class MEDIA_EXPORT VideoCaptureDevice { 25 class MEDIA_EXPORT VideoCaptureDevice {
25 public: 26 public:
26 // Represents a capture device name and ID. 27 // Represents a capture device name and ID.
27 // You should not create an instance of this class directly by e.g. setting 28 // You should not create an instance of this class directly by e.g. setting
28 // various properties directly. Instead use 29 // various properties directly. Instead use
29 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to 30 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to
30 // cache your own copy of a name, you can do so via the copy constructor. 31 // cache your own copy of a name, you can do so via the copy constructor.
31 // The reason for this is that a device name might contain platform specific 32 // The reason for this is that a device name might contain platform specific
32 // settings that are relevant only to the platform specific implementation of 33 // settings that are relevant only to the platform specific implementation of
33 // VideoCaptureDevice::Create. 34 // VideoCaptureDevice::Create.
34 class Name { 35 class Name {
35 public: 36 public:
36 Name() {} 37 Name() {}
37 Name(const std::string& name, const std::string& id) 38 Name(const std::string& name, const std::string& id)
38 : device_name_(name), unique_id_(id) {} 39 : device_name_(name), unique_id_(id) {}
40
41 #if defined(OS_WIN)
42 // Windows targets Capture Api type: it can only be set on construction.
43 enum CaptureApiType {
44 MEDIA_FOUNDATION,
45 DIRECT_SHOW,
46 API_TYPE_UNKNOWN
47 };
48
49 Name(const std::string& name,
50 const std::string& id,
51 const CaptureApiType api_type)
52 : device_name_(name), unique_id_(id), capture_api_class_(api_type) {}
53 #endif // if defined(OS_WIN)
39 ~Name() {} 54 ~Name() {}
40 55
41 // Friendly name of a device 56 // Friendly name of a device
42 const std::string& name() const { return device_name_; } 57 const std::string& name() const { return device_name_; }
43 58
44 // Unique name of a device. Even if there are multiple devices with the same 59 // Unique name of a device. Even if there are multiple devices with the same
45 // friendly name connected to the computer this will be unique. 60 // friendly name connected to the computer this will be unique.
46 const std::string& id() const { return unique_id_; } 61 const std::string& id() const { return unique_id_; }
47 62
48 // These operators are needed due to storing the name in an STL container. 63 // These operators are needed due to storing the name in an STL container.
49 // In the shared build, all methods from the STL container will be exported 64 // In the shared build, all methods from the STL container will be exported
50 // so even though they're not used, they're still depended upon. 65 // so even though they're not used, they're still depended upon.
51 bool operator==(const Name& other) const { 66 bool operator==(const Name& other) const {
52 return other.id() == unique_id_ && other.name() == device_name_; 67 return other.id() == unique_id_ && other.name() == device_name_;
53 } 68 }
54 bool operator<(const Name& other) const { 69 bool operator<(const Name& other) const {
55 return unique_id_ < other.id(); 70 return unique_id_ < other.id();
56 } 71 }
57 72
73 #if defined(OS_WIN)
74 CaptureApiType capture_api_type() const {
75 return capture_api_class_.capture_api_type();
76 }
77 #endif // if defined(OS_WIN)
78
58 private: 79 private:
59 std::string device_name_; 80 std::string device_name_;
60 std::string unique_id_; 81 std::string unique_id_;
82 #if defined(OS_WIN)
83 // This class wraps the CaptureApiType, so it has a by default value if not
84 // inititalized, and I (mcasas) do a DCHECK on reading its value.
85 class CaptureApiClass{
86 public:
87 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {}
88 CaptureApiClass(const CaptureApiType api_type)
89 : capture_api_type_(api_type) {}
90 CaptureApiType capture_api_type() const {
91 DCHECK(capture_api_type_ != API_TYPE_UNKNOWN);
tommi (sloooow) - chröme 2013/07/03 15:27:26 nit: DCHECK_NE
mcasas 2013/07/04 10:40:42 Done.
92 return capture_api_type_;
93 }
94 private:
95 CaptureApiType capture_api_type_;
96 };
97
98 CaptureApiClass capture_api_class_;
99 #endif // if defined(OS_WIN)
61 // Allow generated copy constructor and assignment. 100 // Allow generated copy constructor and assignment.
62 }; 101 };
63 102
64 // Manages a list of Name entries. 103 // Manages a list of Name entries.
65 class MEDIA_EXPORT Names 104 class MEDIA_EXPORT Names
66 : public NON_EXPORTED_BASE(std::list<Name>) { 105 : public NON_EXPORTED_BASE(std::list<Name>) {
67 public: 106 public:
68 // Returns NULL if no entry was found by that ID. 107 // Returns NULL if no entry was found by that ID.
69 Name* FindById(const std::string& id); 108 Name* FindById(const std::string& id);
70 109
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // not permitted to make any additional calls to its EventHandler. 209 // not permitted to make any additional calls to its EventHandler.
171 virtual void DeAllocate() = 0; 210 virtual void DeAllocate() = 0;
172 211
173 // Get the name of the capture device. 212 // Get the name of the capture device.
174 virtual const Name& device_name() = 0; 213 virtual const Name& device_name() = 0;
175 }; 214 };
176 215
177 } // namespace media 216 } // namespace media
178 217
179 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 218 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698