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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/video_capture_device.h
diff --git a/media/video/capture/video_capture_device.h b/media/video/capture/video_capture_device.h
index 9177302a92f9528d60da6b6c999c12b5f2b0b4f0..894480fedd9d4e63e99964a51cdb15cb6e988ac3 100644
--- a/media/video/capture/video_capture_device.h
+++ b/media/video/capture/video_capture_device.h
@@ -23,16 +23,55 @@ namespace media {
class MEDIA_EXPORT VideoCaptureDevice {
public:
+ // Represents a capture device name and ID.
+ // You should not create an instance of this class directly by e.g. setting
+ // various properties directly. Instead use
+ // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to
+ // cache your own copy of a name, you can do so via the copy constructor.
+ // The reason for this is that a device name might contain platform specific
+ // settings that are relevant only to the platform specific implementation of
+ // VideoCaptureDevice::Create.
+ class Name {
+ public:
+ Name() {}
+ Name(const std::string& name, const std::string& id)
+ : device_name_(name), unique_id_(id) {}
+ // Allow a copy constructor since this type is used in stl containers
+ // and copied to members.
+ Name(const Name& other)
+ : device_name_(other.device_name_), unique_id_(other.unique_id_) {}
+
+ ~Name() {}
- struct Name {
// Friendly name of a device
- std::string device_name;
+ const std::string& name() const { return device_name_; }
// Unique name of a device. Even if there are multiple devices with the same
// friendly name connected to the computer this will be unique.
- std::string unique_id;
+ const std::string& id() const { return unique_id_; }
+
+ private:
+ std::string device_name_;
+ std::string unique_id_;
+ };
+
+ // Manages a list of Name entries.
+ class Names : public std::list<Name> {
+ public:
+ Names() {}
+
+ // Returns NULL if no entry was found by that ID.
+ 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
+ for (iterator it = begin(); it != end(); ++it) {
+ if (it->id() == id)
+ return &(*it);
+ }
+ return NULL;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Names);
};
- typedef std::list<Name> Names;
class MEDIA_EXPORT EventHandler {
public:

Powered by Google App Engine
This is Rietveld 408576698