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

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

Issue 1751583002: Remove unused libudev on Linux. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 9 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/v4llookup.h ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2009 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 /*
12 * Author: lexnikitin@google.com (Alexey Nikitin)
13 *
14 * V4LLookup provides basic functionality to work with V2L2 devices in Linux
15 * The functionality is implemented as a class with virtual methods for
16 * the purpose of unit testing.
17 */
18 #include "webrtc/media/devices/v4llookup.h"
19
20 #include <errno.h>
21 #include <fcntl.h>
22 #include <linux/types.h>
23 #include <linux/videodev2.h>
24 #include <string.h>
25 #include <sys/ioctl.h>
26 #include <sys/stat.h>
27 #include <sys/types.h>
28 #include <unistd.h>
29
30 #include "webrtc/base/logging.h"
31
32 namespace cricket {
33
34 V4LLookup *V4LLookup::v4l_lookup_ = NULL;
35
36 bool V4LLookup::CheckIsV4L2Device(const std::string& device_path) {
37 // check device major/minor numbers are in the range for video devices.
38 struct stat s;
39
40 if (lstat(device_path.c_str(), &s) != 0 || !S_ISCHR(s.st_mode)) return false;
41
42 int video_fd = -1;
43 bool is_v4l2 = false;
44
45 // check major/minur device numbers are in range for video device
46 if (major(s.st_rdev) == 81) {
47 dev_t num = minor(s.st_rdev);
48 if (num <= 63) {
49 video_fd = ::open(device_path.c_str(), O_RDONLY | O_NONBLOCK);
50 if ((video_fd >= 0) || (errno == EBUSY)) {
51 ::v4l2_capability video_caps;
52 memset(&video_caps, 0, sizeof(video_caps));
53
54 if ((errno == EBUSY) ||
55 (::ioctl(video_fd, VIDIOC_QUERYCAP, &video_caps) >= 0 &&
56 (video_caps.capabilities & V4L2_CAP_VIDEO_CAPTURE))) {
57 LOG(LS_INFO) << "Found V4L2 capture device " << device_path;
58
59 is_v4l2 = true;
60 } else {
61 LOG_ERRNO(LS_ERROR) << "VIDIOC_QUERYCAP failed for " << device_path;
62 }
63 } else {
64 LOG_ERRNO(LS_ERROR) << "Failed to open " << device_path;
65 }
66 }
67 }
68
69 if (video_fd >= 0)
70 ::close(video_fd);
71
72 return is_v4l2;
73 }
74
75 }; // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/devices/v4llookup.h ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698