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

Side by Side Diff: webrtc/media/devices/linuxdevicemanager.cc

Issue 1728503002: Replace scoped_ptr with unique_ptr in webrtc/media/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up1
Patch Set: Created 4 years, 10 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
« no previous file with comments | « webrtc/media/devices/linuxdeviceinfo.cc ('k') | webrtc/media/devices/macdevicemanager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/media/devices/linuxdevicemanager.h" 11 #include "webrtc/media/devices/linuxdevicemanager.h"
12 12
13 #include <unistd.h> 13 #include <unistd.h>
14
15 #include <memory>
16
14 #include "webrtc/base/fileutils.h" 17 #include "webrtc/base/fileutils.h"
15 #include "webrtc/base/linux.h" 18 #include "webrtc/base/linux.h"
16 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
17 #include "webrtc/base/pathutils.h" 20 #include "webrtc/base/pathutils.h"
18 #include "webrtc/base/physicalsocketserver.h" 21 #include "webrtc/base/physicalsocketserver.h"
19 #include "webrtc/base/stream.h" 22 #include "webrtc/base/stream.h"
20 #include "webrtc/base/stringutils.h" 23 #include "webrtc/base/stringutils.h"
21 #include "webrtc/base/thread.h" 24 #include "webrtc/base/thread.h"
22 #include "webrtc/media/base/mediacommon.h" 25 #include "webrtc/media/base/mediacommon.h"
23 #include "webrtc/media/devices/libudevsymboltable.h" 26 #include "webrtc/media/devices/libudevsymboltable.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return FilterDevices(devs, kFilteredAudioDevicesName); 114 return FilterDevices(devs, kFilteredAudioDevicesName);
112 } 115 }
113 116
114 static const std::string kVideoMetaPathK2_4("/proc/video/dev/"); 117 static const std::string kVideoMetaPathK2_4("/proc/video/dev/");
115 static const std::string kVideoMetaPathK2_6("/sys/class/video4linux/"); 118 static const std::string kVideoMetaPathK2_6("/sys/class/video4linux/");
116 119
117 enum MetaType { M2_4, M2_6, NONE }; 120 enum MetaType { M2_4, M2_6, NONE };
118 121
119 static void ScanDeviceDirectory(const std::string& devdir, 122 static void ScanDeviceDirectory(const std::string& devdir,
120 std::vector<Device>* devices) { 123 std::vector<Device>* devices) {
121 rtc::scoped_ptr<rtc::DirectoryIterator> directoryIterator( 124 std::unique_ptr<rtc::DirectoryIterator> directoryIterator(
122 rtc::Filesystem::IterateDirectory()); 125 rtc::Filesystem::IterateDirectory());
123 126
124 if (directoryIterator->Iterate(rtc::Pathname(devdir))) { 127 if (directoryIterator->Iterate(rtc::Pathname(devdir))) {
125 do { 128 do {
126 std::string filename = directoryIterator->Name(); 129 std::string filename = directoryIterator->Name();
127 std::string device_name = devdir + filename; 130 std::string device_name = devdir + filename;
128 if (!directoryIterator->IsDots()) { 131 if (!directoryIterator->IsDots()) {
129 if (filename.find("video") == 0 && 132 if (filename.find("video") == 0 &&
130 V4LLookup::IsV4L2Device(device_name)) { 133 V4LLookup::IsV4L2Device(device_name)) {
131 devices->push_back(Device(device_name, device_name)); 134 devices->push_back(Device(device_name, device_name));
132 } 135 }
133 } 136 }
134 } while (directoryIterator->Next()); 137 } while (directoryIterator->Next());
135 } 138 }
136 } 139 }
137 140
138 static std::string GetVideoDeviceNameK2_6(const std::string& device_meta_path) { 141 static std::string GetVideoDeviceNameK2_6(const std::string& device_meta_path) {
139 std::string device_name; 142 std::string device_name;
140 143
141 rtc::scoped_ptr<rtc::FileStream> device_meta_stream( 144 std::unique_ptr<rtc::FileStream> device_meta_stream(
142 rtc::Filesystem::OpenFile(device_meta_path, "r")); 145 rtc::Filesystem::OpenFile(device_meta_path, "r"));
143 146
144 if (device_meta_stream) { 147 if (device_meta_stream) {
145 if (device_meta_stream->ReadLine(&device_name) != rtc::SR_SUCCESS) { 148 if (device_meta_stream->ReadLine(&device_name) != rtc::SR_SUCCESS) {
146 LOG(LS_ERROR) << "Failed to read V4L2 device meta " << device_meta_path; 149 LOG(LS_ERROR) << "Failed to read V4L2 device meta " << device_meta_path;
147 } 150 }
148 device_meta_stream->Close(); 151 device_meta_stream->Close();
149 } 152 }
150 153
151 return device_name; 154 return device_name;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 223
221 return Trim(device_name); 224 return Trim(device_name);
222 } 225 }
223 226
224 static void ScanV4L2Devices(std::vector<Device>* devices) { 227 static void ScanV4L2Devices(std::vector<Device>* devices) {
225 LOG(LS_INFO) << ("Enumerating V4L2 devices"); 228 LOG(LS_INFO) << ("Enumerating V4L2 devices");
226 229
227 MetaType meta; 230 MetaType meta;
228 std::string metadata_dir; 231 std::string metadata_dir;
229 232
230 rtc::scoped_ptr<rtc::DirectoryIterator> directoryIterator( 233 std::unique_ptr<rtc::DirectoryIterator> directoryIterator(
231 rtc::Filesystem::IterateDirectory()); 234 rtc::Filesystem::IterateDirectory());
232 235
233 // Try and guess kernel version 236 // Try and guess kernel version
234 if (directoryIterator->Iterate(kVideoMetaPathK2_6)) { 237 if (directoryIterator->Iterate(kVideoMetaPathK2_6)) {
235 meta = M2_6; 238 meta = M2_6;
236 metadata_dir = kVideoMetaPathK2_6; 239 metadata_dir = kVideoMetaPathK2_6;
237 } else if (directoryIterator->Iterate(kVideoMetaPathK2_4)) { 240 } else if (directoryIterator->Iterate(kVideoMetaPathK2_4)) {
238 meta = M2_4; 241 meta = M2_4;
239 metadata_dir = kVideoMetaPathK2_4; 242 metadata_dir = kVideoMetaPathK2_4;
240 } else { 243 } else {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 387 }
385 388
386 bool LinuxDeviceWatcher::IsDescriptorClosed() { 389 bool LinuxDeviceWatcher::IsDescriptorClosed() {
387 // If it is closed then we will just get an error in 390 // If it is closed then we will just get an error in
388 // udev_monitor_receive_device and unregister, so we don't need to check for 391 // udev_monitor_receive_device and unregister, so we don't need to check for
389 // it separately. 392 // it separately.
390 return false; 393 return false;
391 } 394 }
392 395
393 }; // namespace cricket 396 }; // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/devices/linuxdeviceinfo.cc ('k') | webrtc/media/devices/macdevicemanager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698