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

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

Issue 29423003: Added video capture capabilities retrieval and caching to VideoCaptureManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed mechanics of Caps enumeration to be asynchronous and 2 threaded. UT adapted. Created 7 years, 1 month 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/logging.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "media/base/media_export.h" 20 #include "media/base/media_export.h"
21 #include "media/video/capture/video_capture_types.h" 21 #include "media/video/capture/video_capture_types.h"
22 22
23 namespace media { 23 namespace media {
24 24
25 class MEDIA_EXPORT VideoCaptureDevice { 25 class MEDIA_EXPORT VideoCaptureDevice {
26 public: 26 public:
27 // Represents a capture device name and ID. 27 // Represents a capture device name and ID.
tommi (sloooow) - chröme 2013/10/25 14:15:34 If we decide to add capabilities to the Name class
mcasas 2013/10/28 12:50:08 On second thoughts I think is best to leave this c
28 // 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
29 // various properties directly. Instead use 29 // various properties directly. Instead use
30 // 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
31 // 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.
32 // 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
33 // settings that are relevant only to the platform specific implementation of 33 // settings that are relevant only to the platform specific implementation of
34 // VideoCaptureDevice::Create. 34 // VideoCaptureDevice::Create.
35 class MEDIA_EXPORT Name { 35 class MEDIA_EXPORT Name {
36 public: 36 public:
37 Name() {} 37 Name();
38 Name(const std::string& name, const std::string& id) 38 Name(const std::string& name, const std::string& id);
39 : device_name_(name), unique_id_(id) {}
40 39
41 #if defined(OS_WIN) 40 #if defined(OS_WIN)
42 // Windows targets Capture Api type: it can only be set on construction. 41 // Windows targets Capture Api type: it can only be set on construction.
43 enum CaptureApiType { 42 enum CaptureApiType {
44 MEDIA_FOUNDATION, 43 MEDIA_FOUNDATION,
45 DIRECT_SHOW, 44 DIRECT_SHOW,
46 API_TYPE_UNKNOWN 45 API_TYPE_UNKNOWN
47 }; 46 };
48 47
49 Name(const std::string& name, 48 Name(const std::string& name,
50 const std::string& id, 49 const std::string& id,
51 const CaptureApiType api_type) 50 const CaptureApiType api_type)
52 : device_name_(name), unique_id_(id), capture_api_class_(api_type) {} 51 : device_name_(name), unique_id_(id), capture_api_class_(api_type) {}
53 #endif // if defined(OS_WIN) 52 #endif // if defined(OS_WIN)
54 ~Name() {} 53 ~Name();
55 54
56 // Friendly name of a device 55 // Friendly name of a device
57 const std::string& name() const { return device_name_; } 56 const std::string& name() const { return device_name_; }
58 57
59 // Unique name of a device. Even if there are multiple devices with the same 58 // Unique name of a device. Even if there are multiple devices with the same
60 // friendly name connected to the computer this will be unique. 59 // friendly name connected to the computer this will be unique.
61 const std::string& id() const { return unique_id_; } 60 const std::string& id() const { return unique_id_; }
62 61
63 // The unique hardware model identifier of the capture device. Returns 62 // The unique hardware model identifier of the capture device. Returns
64 // "[vid]:[pid]" when a USB device is detected, otherwise "". 63 // "[vid]:[pid]" when a USB device is detected, otherwise "".
(...skipping 15 matching lines...) Expand all
80 79
81 #if defined(OS_WIN) 80 #if defined(OS_WIN)
82 CaptureApiType capture_api_type() const { 81 CaptureApiType capture_api_type() const {
83 return capture_api_class_.capture_api_type(); 82 return capture_api_class_.capture_api_type();
84 } 83 }
85 #endif // if defined(OS_WIN) 84 #endif // if defined(OS_WIN)
86 85
87 private: 86 private:
88 std::string device_name_; 87 std::string device_name_;
89 std::string unique_id_; 88 std::string unique_id_;
89 VideoCaptureCapabilities capture_formats_;
tommi (sloooow) - chröme 2013/10/25 14:15:34 I haven't made up my mind whether adding capabilit
mcasas 2013/10/28 12:50:08 This should go, is left from an experiment.
90
90 #if defined(OS_WIN) 91 #if defined(OS_WIN)
91 // This class wraps the CaptureApiType, so it has a by default value if not 92 // This class wraps the CaptureApiType, so it has a by default value if not
92 // inititalized, and I (mcasas) do a DCHECK on reading its value. 93 // inititalized, and I (mcasas) do a DCHECK on reading its value.
93 class CaptureApiClass { 94 class CaptureApiClass {
94 public: 95 public:
95 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {} 96 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {}
96 CaptureApiClass(const CaptureApiType api_type) 97 CaptureApiClass(const CaptureApiType api_type)
97 : capture_api_type_(api_type) {} 98 : capture_api_type_(api_type) {}
98 CaptureApiType capture_api_type() const { 99 CaptureApiType capture_api_type() const {
99 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN); 100 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN);
100 return capture_api_type_; 101 return capture_api_type_;
101 } 102 }
102 private: 103 private:
103 CaptureApiType capture_api_type_; 104 CaptureApiType capture_api_type_;
104 }; 105 };
105 106
106 CaptureApiClass capture_api_class_; 107 CaptureApiClass capture_api_class_;
107 #endif // if defined(OS_WIN) 108 #endif // if defined(OS_WIN)
109
108 // Allow generated copy constructor and assignment. 110 // Allow generated copy constructor and assignment.
109 }; 111 };
110 112
111 // Manages a list of Name entries. 113 // Manages a list of Name entries.
112 class MEDIA_EXPORT Names 114 class MEDIA_EXPORT Names
113 : public NON_EXPORTED_BASE(std::list<Name>) { 115 : public NON_EXPORTED_BASE(std::list<Name>) {
114 public: 116 public:
115 // Returns NULL if no entry was found by that ID. 117 // Returns NULL if no entry was found by that ID.
116 Name* FindById(const std::string& id); 118 Name* FindById(const std::string& id);
117 119
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // If deallocation is done asynchronously, then the device implementation must 218 // If deallocation is done asynchronously, then the device implementation must
217 // ensure that a subsequent AllocateAndStart() operation targeting the same ID 219 // ensure that a subsequent AllocateAndStart() operation targeting the same ID
218 // would be sequenced through the same task runner, so that deallocation 220 // would be sequenced through the same task runner, so that deallocation
219 // happens first. 221 // happens first.
220 virtual void StopAndDeAllocate() = 0; 222 virtual void StopAndDeAllocate() = 0;
221 }; 223 };
222 224
223 } // namespace media 225 } // namespace media
224 226
225 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 227 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698