Remove unused libudev on Linux.

BUG=webrtc:5615

Review URL: https://codereview.webrtc.org/1751583002

Cr-Commit-Position: refs/heads/master@{#12050}
diff --git a/.gitignore b/.gitignore
index 224ff6e..99dab8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,7 +106,6 @@
 /third_party/libsrtp
 /third_party/libvpx
 /third_party/libxml
-/third_party/libudev
 /third_party/libyuv
 /third_party/llvm
 /third_party/llvm-build
diff --git a/setup_links.py b/setup_links.py
index 1bc10d8..8df6171 100755
--- a/setup_links.py
+++ b/setup_links.py
@@ -48,7 +48,6 @@
   'third_party/libjpeg',
   'third_party/libjpeg_turbo',
   'third_party/libsrtp',
-  'third_party/libudev',
   'third_party/libvpx',
   'third_party/libyuv',
   'third_party/llvm-build',
diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi
index cafd612..a349d11 100644
--- a/webrtc/build/common.gypi
+++ b/webrtc/build/common.gypi
@@ -181,9 +181,6 @@
         # Exclude internal ADM since Chromium uses its own IO handling.
         'include_internal_audio_device%': 0,
 
-        # Exclude device management code since Chromium has its own.
-        'include_internal_device_management%': 0,
-
         # Remove tests for Chromium to avoid slowing down GYP generation.
         'include_tests%': 0,
         'restrict_webrtc_logging%': 1,
@@ -196,7 +193,6 @@
 
         'include_pulse_audio%': 1,
         'include_internal_audio_device%': 1,
-        'include_internal_device_management%': 1,
         'include_tests%': 1,
         'restrict_webrtc_logging%': 0,
       }],
diff --git a/webrtc/media/devices/libudevsymboltable.cc b/webrtc/media/devices/libudevsymboltable.cc
deleted file mode 100644
index 155fe48..0000000
--- a/webrtc/media/devices/libudevsymboltable.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *  Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/media/devices/libudevsymboltable.h"
-
-#include <dlfcn.h>
-
-#include "webrtc/base/logging.h"
-
-namespace cricket {
-
-#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBUDEV_SYMBOLS_CLASS_NAME
-#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBUDEV_SYMBOLS_LIST
-#define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libudev.so.0"
-#include "webrtc/base/latebindingsymboltable.cc.def"
-#undef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME
-#undef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
-#undef LATE_BINDING_SYMBOL_TABLE_DLL_NAME
-
-bool IsWrongLibUDevAbiVersion(rtc::DllHandle libudev_0) {
-  rtc::DllHandle libudev_1 = dlopen("libudev.so.1",
-                                          RTLD_NOW|RTLD_LOCAL|RTLD_NOLOAD);
-  bool unsafe_symlink = (libudev_0 == libudev_1);
-  if (unsafe_symlink) {
-    // .0 and .1 are distinct ABIs, so if they point to the same thing then one
-    // of them must be wrong. Probably the old has been symlinked to the new in
-    // a misguided attempt at backwards compatibility.
-    LOG(LS_ERROR) << "libudev.so.0 and libudev.so.1 unsafely point to the"
-                     " same thing; not using libudev";
-  } else if (libudev_1) {
-    // If libudev.so.1 is resident but distinct from libudev.so.0, then some
-    // system library loaded the new ABI separately. This is not a problem for
-    // LateBindingSymbolTable because its symbol look-ups are restricted to its
-    // DllHandle, but having libudev.so.0 resident may cause problems for that
-    // system library because symbol names are not namespaced by DLL. (Although
-    // our use of RTLD_LOCAL should avoid most problems.)
-    LOG(LS_WARNING)
-        << "libudev.so.1 is resident but distinct from libudev.so.0";
-  }
-  if (libudev_1) {
-    // Release the refcount that we acquired above. (Does not unload the DLL;
-    // whoever loaded it still needs it.)
-    dlclose(libudev_1);
-  }
-  return unsafe_symlink;
-}
-
-}  // namespace cricket
diff --git a/webrtc/media/devices/libudevsymboltable.h b/webrtc/media/devices/libudevsymboltable.h
deleted file mode 100644
index 40fc7b9..0000000
--- a/webrtc/media/devices/libudevsymboltable.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *  Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef WEBRTC_MEDIA_DEVICES_LIBUDEVSYMBOLTABLE_H_
-#define WEBRTC_MEDIA_DEVICES_LIBUDEVSYMBOLTABLE_H_
-
-#include <libudev.h>
-
-#include "webrtc/base/latebindingsymboltable.h"
-
-namespace cricket {
-
-#define LIBUDEV_SYMBOLS_CLASS_NAME LibUDevSymbolTable
-// The libudev symbols we need, as an X-Macro list.
-// This list must contain precisely every libudev function that is used in
-// linuxdevicemanager.cc.
-#define LIBUDEV_SYMBOLS_LIST \
-  X(udev_device_get_devnode) \
-  X(udev_device_get_parent_with_subsystem_devtype) \
-  X(udev_device_get_sysattr_value) \
-  X(udev_device_new_from_syspath) \
-  X(udev_device_unref) \
-  X(udev_enumerate_add_match_subsystem) \
-  X(udev_enumerate_get_list_entry) \
-  X(udev_enumerate_new) \
-  X(udev_enumerate_scan_devices) \
-  X(udev_enumerate_unref) \
-  X(udev_list_entry_get_name) \
-  X(udev_list_entry_get_next) \
-  X(udev_monitor_enable_receiving) \
-  X(udev_monitor_filter_add_match_subsystem_devtype) \
-  X(udev_monitor_get_fd) \
-  X(udev_monitor_new_from_netlink) \
-  X(udev_monitor_receive_device) \
-  X(udev_monitor_unref) \
-  X(udev_new) \
-  X(udev_unref)
-
-#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBUDEV_SYMBOLS_CLASS_NAME
-#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBUDEV_SYMBOLS_LIST
-#include "webrtc/base/latebindingsymboltable.h.def"
-#undef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME
-#undef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST
-
-// libudev has changed ABIs to libudev.so.1 in recent distros and lots of users
-// and/or software (including Google Chrome) are symlinking the old to the new.
-// The entire point of ABI versions is that you can't safely do that, and
-// it has caused crashes in the wild. This function checks if the DllHandle that
-// we got back for libudev.so.0 is actually for libudev.so.1. If so, the library
-// cannot safely be used.
-bool IsWrongLibUDevAbiVersion(rtc::DllHandle libudev_0);
-
-}  // namespace cricket
-
-#endif  // WEBRTC_MEDIA_DEVICES_LIBUDEVSYMBOLTABLE_H_
diff --git a/webrtc/media/devices/v4llookup.cc b/webrtc/media/devices/v4llookup.cc
deleted file mode 100644
index 7c3dc70..0000000
--- a/webrtc/media/devices/v4llookup.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Copyright (c) 2009 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-/*
- * Author: lexnikitin@google.com (Alexey Nikitin)
- *
- * V4LLookup provides basic functionality to work with V2L2 devices in Linux
- * The functionality is implemented as a class with virtual methods for
- * the purpose of unit testing.
- */
-#include "webrtc/media/devices/v4llookup.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/types.h>
-#include <linux/videodev2.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "webrtc/base/logging.h"
-
-namespace cricket {
-
-V4LLookup *V4LLookup::v4l_lookup_ = NULL;
-
-bool V4LLookup::CheckIsV4L2Device(const std::string& device_path) {
-  // check device major/minor numbers are in the range for video devices.
-  struct stat s;
-
-  if (lstat(device_path.c_str(), &s) != 0 || !S_ISCHR(s.st_mode)) return false;
-
-  int video_fd = -1;
-  bool is_v4l2 = false;
-
-  // check major/minur device numbers are in range for video device
-  if (major(s.st_rdev) == 81) {
-    dev_t num = minor(s.st_rdev);
-    if (num <= 63) {
-      video_fd = ::open(device_path.c_str(), O_RDONLY | O_NONBLOCK);
-      if ((video_fd >= 0) || (errno == EBUSY)) {
-        ::v4l2_capability video_caps;
-        memset(&video_caps, 0, sizeof(video_caps));
-
-        if ((errno == EBUSY) ||
-            (::ioctl(video_fd, VIDIOC_QUERYCAP, &video_caps) >= 0 &&
-            (video_caps.capabilities & V4L2_CAP_VIDEO_CAPTURE))) {
-          LOG(LS_INFO) << "Found V4L2 capture device " << device_path;
-
-          is_v4l2 = true;
-        } else {
-          LOG_ERRNO(LS_ERROR) << "VIDIOC_QUERYCAP failed for " << device_path;
-        }
-      } else {
-        LOG_ERRNO(LS_ERROR) << "Failed to open " << device_path;
-      }
-    }
-  }
-
-  if (video_fd >= 0)
-    ::close(video_fd);
-
-  return is_v4l2;
-}
-
-};  // namespace cricket
diff --git a/webrtc/media/devices/v4llookup.h b/webrtc/media/devices/v4llookup.h
deleted file mode 100644
index 330d080..0000000
--- a/webrtc/media/devices/v4llookup.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  Copyright (c) 2009 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-/*
- * Author: lexnikitin@google.com (Alexey Nikitin)
- *
- * V4LLookup provides basic functionality to work with V2L2 devices in Linux
- * The functionality is implemented as a class with virtual methods for
- * the purpose of unit testing.
- */
-#ifndef WEBRTC_MEDIA_DEVICES_V4LLOOKUP_H_
-#define WEBRTC_MEDIA_DEVICES_V4LLOOKUP_H_
-
-#include <string>
-
-#ifdef WEBRTC_LINUX
-namespace cricket {
-class V4LLookup {
- public:
-  virtual ~V4LLookup() {}
-
-  static bool IsV4L2Device(const std::string& device_path) {
-    return GetV4LLookup()->CheckIsV4L2Device(device_path);
-  }
-
-  static void SetV4LLookup(V4LLookup* v4l_lookup) {
-    v4l_lookup_ = v4l_lookup;
-  }
-
-  static V4LLookup* GetV4LLookup() {
-    if (!v4l_lookup_) {
-      v4l_lookup_ = new V4LLookup();
-    }
-    return v4l_lookup_;
-  }
-
- protected:
-  static V4LLookup* v4l_lookup_;
-  // Making virtual so it is easier to mock
-  virtual bool CheckIsV4L2Device(const std::string& device_path);
-};
-
-}  // namespace cricket
-
-#endif  // WEBRTC_LINUX
-#endif  // WEBRTC_MEDIA_DEVICES_V4LLOOKUP_H_
diff --git a/webrtc/media/media.gyp b/webrtc/media/media.gyp
index d9d57e1..a414fcd 100644
--- a/webrtc/media/media.gyp
+++ b/webrtc/media/media.gyp
@@ -155,20 +155,6 @@
             '<(webrtc_root)/modules/modules.gyp:video_render_module_internal_impl',
           ],
         }],
-        ['OS=="linux" and include_internal_device_management==1', {
-          'sources': [
-            'devices/libudevsymboltable.cc',
-            'devices/libudevsymboltable.h',
-            'devices/v4llookup.cc',
-            'devices/v4llookup.h',
-          ],
-          'include_dirs': [
-            'third_party/libudev'
-          ],
-          'libraries': [
-            '-lrt',
-          ],
-        }],
         ['OS=="linux" and use_gtk==1', {
           'sources': [
             'devices/gtkvideorenderer.cc',