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

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

Issue 17846002: Refactor the VideoCaptureDevice::Name struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 | 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 // 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/time.h" 18 #include "base/time.h"
19 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
20 #include "media/video/capture/video_capture_types.h" 20 #include "media/video/capture/video_capture_types.h"
21 21
22 namespace media { 22 namespace media {
23 23
24 class MEDIA_EXPORT VideoCaptureDevice { 24 class MEDIA_EXPORT VideoCaptureDevice {
25 public: 25 public:
26 // Represents a capture device name and ID.
27 // You should not create an instance of this class directly by e.g. setting
28 // various properties directly. Instead use
29 // 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 // 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 // VideoCaptureDevice::Create.
34 class Name {
35 public:
36 Name() {}
37 Name(const std::string& name, const std::string& id)
38 : device_name_(name), unique_id_(id) {}
39 ~Name() {}
26 40
27 struct Name {
28 // Friendly name of a device 41 // Friendly name of a device
29 std::string device_name; 42 const std::string& name() const { return device_name_; }
30 43
31 // Unique name of a device. Even if there are multiple devices with the same 44 // Unique name of a device. Even if there are multiple devices with the same
32 // friendly name connected to the computer this will be unique. 45 // friendly name connected to the computer this will be unique.
33 std::string unique_id; 46 const std::string& id() const { return unique_id_; }
47
48 // 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
50 // so even though they're not used, they're still depended upon.
51 bool operator==(const Name& other) const {
52 return other.id() == unique_id_ && other.name() == device_name_;
53 }
54 bool operator<(const Name& other) const {
55 return unique_id_ < other.id();
56 }
57
58 private:
59 std::string device_name_;
60 std::string unique_id_;
61 // Allow generated copy constructor and assignment.
34 }; 62 };
35 typedef std::list<Name> Names; 63
64 // Manages a list of Name entries.
65 class MEDIA_EXPORT Names
66 : public NON_EXPORTED_BASE(std::list<Name>) {
67 public:
68 // Returns NULL if no entry was found by that ID.
69 Name* FindById(const std::string& id);
70
71 // Allow generated copy constructor and assignment.
72 };
36 73
37 class MEDIA_EXPORT EventHandler { 74 class MEDIA_EXPORT EventHandler {
38 public: 75 public:
39 76
40 // Reserve an output buffer into which a video frame can be captured 77 // Reserve an output buffer into which a video frame can be captured
41 // directly. If all buffers are currently busy, returns NULL. 78 // directly. If all buffers are currently busy, returns NULL.
42 // 79 //
43 // The returned VideoFrames will always be allocated with a YV12 format. The 80 // The returned VideoFrames will always be allocated with a YV12 format. The
44 // size will match that specified by an earlier call to OnFrameInfo. It is 81 // size will match that specified by an earlier call to OnFrameInfo. It is
45 // the VideoCaptureDevice's responsibility to obey whatever stride and 82 // the VideoCaptureDevice's responsibility to obey whatever stride and
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // not permitted to make any additional calls to its EventHandler. 170 // not permitted to make any additional calls to its EventHandler.
134 virtual void DeAllocate() = 0; 171 virtual void DeAllocate() = 0;
135 172
136 // Get the name of the capture device. 173 // Get the name of the capture device.
137 virtual const Name& device_name() = 0; 174 virtual const Name& device_name() = 0;
138 }; 175 };
139 176
140 } // namespace media 177 } // namespace media
141 178
142 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 179 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « media/video/capture/mac/video_capture_device_mac.mm ('k') | media/video/capture/video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698