| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/media/devices/deviceinfo.h" | |
| 12 | |
| 13 namespace cricket { | |
| 14 | |
| 15 bool GetUsbId(const Device& device, std::string* usb_id) { | |
| 16 // Both PID and VID are 4 characters. | |
| 17 const int id_size = 4; | |
| 18 const char vid[] = "vid_"; // Also contains '\0'. | |
| 19 const size_t vid_location = device.id.find(vid); | |
| 20 if (vid_location == std::string::npos || | |
| 21 vid_location + sizeof(vid) - 1 + id_size > device.id.size()) { | |
| 22 return false; | |
| 23 } | |
| 24 const char pid[] = "pid_"; | |
| 25 const size_t pid_location = device.id.find(pid); | |
| 26 if (pid_location == std::string::npos || | |
| 27 pid_location + sizeof(pid) - 1 + id_size > device.id.size()) { | |
| 28 return false; | |
| 29 } | |
| 30 std::string id_vendor = device.id.substr(vid_location + sizeof(vid) - 1, | |
| 31 id_size); | |
| 32 std::string id_product = device.id.substr(pid_location + sizeof(pid) -1, | |
| 33 id_size); | |
| 34 usb_id->clear(); | |
| 35 usb_id->append(id_vendor); | |
| 36 usb_id->append(":"); | |
| 37 usb_id->append(id_product); | |
| 38 return true; | |
| 39 } | |
| 40 | |
| 41 bool GetUsbVersion(const Device& device, std::string* usb_version) { | |
| 42 return false; | |
| 43 } | |
| 44 | |
| 45 } // namespace cricket | |
| OLD | NEW |