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

Unified Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 17846002: Refactor the VideoCaptureDevice::Name struct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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/linux/video_capture_device_linux.cc
diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc
index 66f0ed7f8da097123be0cffbb386cb883efc389f..9477e482d035ef5f9dd3108690597ecfbf24b7b3 100644
--- a/media/video/capture/linux/video_capture_device_linux.cc
+++ b/media/video/capture/linux/video_capture_device_linux.cc
@@ -109,9 +109,8 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
while (!enumerator.Next().empty()) {
base::FileEnumerator::FileInfo info = enumerator.GetInfo();
- Name name;
- name.unique_id = path.value() + info.GetName().value();
- if ((fd = open(name.unique_id.c_str() , O_RDONLY)) < 0) {
+ std::string unique_id = path.value() + info.GetName().value();
+ if ((fd = open(unique_id.c_str() , O_RDONLY)) < 0) {
// Failed to open this device.
continue;
}
@@ -122,8 +121,8 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) {
// This is a V4L2 video capture device
if (HasUsableFormats(fd)) {
- name.device_name = base::StringPrintf("%s", cap.card);
- device_names->push_back(name);
+ Name device_name(base::StringPrintf("%s", cap.card), unique_id);
+ device_names->push_back(device_name);
} else {
DVLOG(1) << "No usable formats reported by " << info.GetName().value();
}
@@ -139,7 +138,7 @@ VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
// Test opening the device driver. This is to make sure it is available.
// We will reopen it again in our worker thread when someone
// allocates the camera.
- int fd = open(device_name.unique_id.c_str(), O_RDONLY);
+ int fd = open(device_name.id().c_str(), O_RDONLY);
if (fd < 0) {
DVLOG(1) << "Cannot open device";
delete self;
@@ -234,7 +233,7 @@ void VideoCaptureDeviceLinux::OnAllocate(int width,
observer_ = observer;
// Need to open camera with O_RDWR after Linux kernel 3.3.
- if ((device_fd_ = open(device_name_.unique_id.c_str(), O_RDWR)) < 0) {
+ if ((device_fd_ = open(device_name_.id().c_str(), O_RDWR)) < 0) {
SetErrorState("Failed to open V4L2 device driver.");
return;
}
« no previous file with comments | « media/video/capture/fake_video_capture_device.cc ('k') | media/video/capture/mac/video_capture_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698