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

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: Fix TabCaptureApiTest tests. 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 // Allow a copy constructor since this type is used in stl containers
40 // and copied to members.
41 Name(const Name& other)
42 : device_name_(other.device_name_), unique_id_(other.unique_id_) {}
26 43
27 struct Name { 44 ~Name() {}
45
28 // Friendly name of a device 46 // Friendly name of a device
29 std::string device_name; 47 const std::string& name() const { return device_name_; }
30 48
31 // Unique name of a device. Even if there are multiple devices with the same 49 // 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. 50 // friendly name connected to the computer this will be unique.
33 std::string unique_id; 51 const std::string& id() const { return unique_id_; }
52
53 private:
54 std::string device_name_;
55 std::string unique_id_;
34 }; 56 };
35 typedef std::list<Name> Names; 57
58 // Manages a list of Name entries.
59 class Names : public std::list<Name> {
60 public:
61 Names() {}
62
63 // Returns NULL if no entry was found by that ID.
64 Name* FindById(const std::string& id) {
wjia(left Chromium) 2013/06/26 18:16:44 Do you need an inline function here? If not, it's
tommi (sloooow) - chröme 2013/07/01 13:32:30 Sorry, missed this in the last round. Added a new
65 for (iterator it = begin(); it != end(); ++it) {
66 if (it->id() == id)
67 return &(*it);
68 }
69 return NULL;
70 }
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(Names);
74 };
36 75
37 class MEDIA_EXPORT EventHandler { 76 class MEDIA_EXPORT EventHandler {
38 public: 77 public:
39 78
40 // Reserve an output buffer into which a video frame can be captured 79 // Reserve an output buffer into which a video frame can be captured
41 // directly. If all buffers are currently busy, returns NULL. 80 // directly. If all buffers are currently busy, returns NULL.
42 // 81 //
43 // The returned VideoFrames will always be allocated with a YV12 format. The 82 // 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 83 // size will match that specified by an earlier call to OnFrameInfo. It is
45 // the VideoCaptureDevice's responsibility to obey whatever stride and 84 // 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. 172 // not permitted to make any additional calls to its EventHandler.
134 virtual void DeAllocate() = 0; 173 virtual void DeAllocate() = 0;
135 174
136 // Get the name of the capture device. 175 // Get the name of the capture device.
137 virtual const Name& device_name() = 0; 176 virtual const Name& device_name() = 0;
138 }; 177 };
139 178
140 } // namespace media 179 } // namespace media
141 180
142 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 181 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698