Source code

Revision control

Copy as Markdown

Other Tools

From: Jan Beich <jbeich@FreeBSD.org>
Date: Fri, 12 Oct 2018 12:56:00 -0400
Subject: Bug 1376873 - Unbreak WebRTC 64 build on BSDs. r=dminor f=gaston
Also includes:
Bug 1554949 - Fix WebRTC build failure with newer linux kernel. r=dminor
---
modules/video_capture/linux/device_info_linux.cc | 6 ++++++
modules/video_capture/linux/device_info_v4l2.cc | 8 +++++++-
modules/video_capture/linux/video_capture_linux.cc | 9 ++++++++-
rtc_base/byte_order.h | 2 ++
rtc_base/physical_socket_server.cc | 7 +++++--
system_wrappers/source/cpu_info.cc | 4 ++--
6 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/modules/video_capture/linux/device_info_linux.cc b/modules/video_capture/linux/device_info_linux.cc
index 4f8b7c059b..56da475bf3 100644
--- a/modules/video_capture/linux/device_info_linux.cc
+++ b/modules/video_capture/linux/device_info_linux.cc
@@ -16,7 +16,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
#include <vector>
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 7397a10625..19b32f16b9 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -18,7 +18,13 @@
#include <sys/ioctl.h>
#include <unistd.h>
// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
#include <linux/videodev2.h>
+#endif
#include <vector>
@@ -209,8 +215,8 @@ DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
{
_inotifyEventThread->Start();
}
-}
#endif
+}
int32_t DeviceInfoV4l2::Init() {
return 0;
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index a2ea218a8b..23a8f4f3f3 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -10,7 +10,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <linux/videodev2.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -18,6 +17,14 @@
#include <sys/select.h>
#include <time.h>
#include <unistd.h>
+// v4l includes
+#if defined(__NetBSD__) || defined(__OpenBSD__) // WEBRTC_BSD
+#include <sys/videoio.h>
+#elif defined(__sun)
+#include <sys/videodev2.h>
+#else
+#include <linux/videodev2.h>
+#endif
#include <new>
#include <string>
diff --git a/rtc_base/byte_order.h b/rtc_base/byte_order.h
index b8f8ae9f7a..382511daeb 100644
--- a/rtc_base/byte_order.h
+++ b/rtc_base/byte_order.h
@@ -90,6 +90,8 @@
#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined.
#endif // defined(WEBRTC_ARCH_LITTLE_ENDIAN)
+#elif defined(WEBRTC_BSD) && !defined(__OpenBSD__)
+#include <sys/endian.h>
#elif defined(WEBRTC_POSIX)
#include <endian.h>
#else
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 71da31ecec..9b8584e74f 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -74,7 +74,10 @@ typedef void* SockOptArg;
#endif // WEBRTC_POSIX
-#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(__native_client__)
+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) && !defined(WEBRTC_BSD) && !defined(__native_client__)
+#if defined(WEBRTC_LINUX)
+#include <linux/sockios.h>
+#endif
int64_t GetSocketRecvTimestamp(int socket) {
struct timeval tv_ioctl;
@@ -697,7 +700,7 @@ int PhysicalSocket::TranslateOption(Option opt, int* slevel, int* sopt) {
*slevel = IPPROTO_IP;
*sopt = IP_DONTFRAGMENT;
break;
-#elif defined(WEBRTC_MAC) || defined(BSD) || defined(__native_client__)
+#elif defined(WEBRTC_MAC) || defined(WEBRTC_BSD) || defined(__native_client__)
RTC_LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported.";
return -1;
#elif defined(WEBRTC_POSIX)
diff --git a/system_wrappers/source/cpu_info.cc b/system_wrappers/source/cpu_info.cc
index eff720371a..94aed09c48 100644
--- a/system_wrappers/source/cpu_info.cc
+++ b/system_wrappers/source/cpu_info.cc
@@ -12,7 +12,7 @@
#if defined(WEBRTC_WIN)
#include <windows.h>
-#elif defined(WEBRTC_LINUX)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
#include <unistd.h>
#elif defined(WEBRTC_MAC)
#include <sys/sysctl.h>
@@ -30,7 +30,7 @@ static int DetectNumberOfCores() {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
number_of_cores = static_cast<int>(si.dwNumberOfProcessors);
-#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) || defined(WEBRTC_BSD)
number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
if (number_of_cores <= 0) {
RTC_LOG(LS_ERROR) << "Failed to get number of cores";