| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 <memory> |
| 12 |
| 11 #include "webrtc/media/devices/deviceinfo.h" | 13 #include "webrtc/media/devices/deviceinfo.h" |
| 12 | 14 |
| 13 #include "webrtc/base/common.h" // for ASSERT | 15 #include "webrtc/base/common.h" // for ASSERT |
| 14 #include "webrtc/media/devices/libudevsymboltable.h" | 16 #include "webrtc/media/devices/libudevsymboltable.h" |
| 15 | 17 |
| 16 namespace cricket { | 18 namespace cricket { |
| 17 | 19 |
| 18 class ScopedLibUdev { | 20 class ScopedLibUdev { |
| 19 public: | 21 public: |
| 20 static ScopedLibUdev* Create() { | 22 static ScopedLibUdev* Create() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 72 |
| 71 udev_enumerate* instance() { return enumerate_; } | 73 udev_enumerate* instance() { return enumerate_; } |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 LibUDevSymbolTable* libudev_; | 76 LibUDevSymbolTable* libudev_; |
| 75 udev_enumerate* enumerate_; | 77 udev_enumerate* enumerate_; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 bool GetUsbProperty(const Device& device, const char* property_name, | 80 bool GetUsbProperty(const Device& device, const char* property_name, |
| 79 std::string* property) { | 81 std::string* property) { |
| 80 rtc::scoped_ptr<ScopedLibUdev> libudev_context(ScopedLibUdev::Create()); | 82 std::unique_ptr<ScopedLibUdev> libudev_context(ScopedLibUdev::Create()); |
| 81 if (!libudev_context) { | 83 if (!libudev_context) { |
| 82 return false; | 84 return false; |
| 83 } | 85 } |
| 84 ScopedUdev udev_context(libudev_context->instance()); | 86 ScopedUdev udev_context(libudev_context->instance()); |
| 85 if (!udev_context.instance()) { | 87 if (!udev_context.instance()) { |
| 86 return false; | 88 return false; |
| 87 } | 89 } |
| 88 ScopedUdevEnumerate enumerate_context(libudev_context->instance(), | 90 ScopedUdevEnumerate enumerate_context(libudev_context->instance(), |
| 89 udev_context.instance()); | 91 udev_context.instance()); |
| 90 if (!enumerate_context.instance()) { | 92 if (!enumerate_context.instance()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 usb_id->append(":"); | 150 usb_id->append(":"); |
| 149 usb_id->append(id_product); | 151 usb_id->append(id_product); |
| 150 return true; | 152 return true; |
| 151 } | 153 } |
| 152 | 154 |
| 153 bool GetUsbVersion(const Device& device, std::string* usb_version) { | 155 bool GetUsbVersion(const Device& device, std::string* usb_version) { |
| 154 return GetUsbProperty(device, "version", usb_version); | 156 return GetUsbProperty(device, "version", usb_version); |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace cricket | 159 } // namespace cricket |
| OLD | NEW |