Fixes to build WebRTC for Fuchsia
1. Added WEBRTC_FUCHSIA define. 2. Added PlatformThreadId typedef for Fuchsia. 3. Updated ifdefs for _strnicmp()/strncasecmd(), so _strnicmp() is used on all platforms 3. Updated ifdefs in clock.cc to avoid invalid assumption that POSIX = LINUX || MAC . Bug: chromium:750940 Change-Id: Id7aa98e017f467bcebb78a0b298ba91655502072 Reviewed-on: https://webrtc-review.googlesource.com/31641 Commit-Queue: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21233}
This commit is contained in:

committed by
Commit Bot

parent
3fe1b15413
commit
6acefdb70a
3
BUILD.gn
3
BUILD.gn
@ -134,6 +134,9 @@ config("common_inherited_config") {
|
||||
if (is_mac) {
|
||||
defines += [ "WEBRTC_MAC" ]
|
||||
}
|
||||
if (is_fuchsia) {
|
||||
defines += [ "WEBRTC_FUCHSIA" ]
|
||||
}
|
||||
if (is_win) {
|
||||
defines += [
|
||||
"WEBRTC_WIN",
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -37,17 +38,10 @@ enum {
|
||||
* Misc utility routines
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
bool StringCompare(const char* str1, const char* str2,
|
||||
const uint32_t length) {
|
||||
return _strnicmp(str1, str2, length) == 0;
|
||||
}
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
bool StringCompare(const char* str1, const char* str2,
|
||||
const uint32_t length) {
|
||||
return strncasecmp(str1, str2, length) == 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t Word32Align(size_t size) {
|
||||
uint32_t remainder = size % 4;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "modules/video_capture/device_info_impl.h"
|
||||
#include "modules/video_capture/video_capture_config.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
|
||||
#ifndef abs
|
||||
#define abs(a) (a >= 0 ? a : -a)
|
||||
@ -21,6 +22,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
namespace videocapturemodule {
|
||||
|
||||
DeviceInfoImpl::DeviceInfoImpl()
|
||||
: _apiLock(*RWLockWrapper::CreateRWLock()),
|
||||
_lastUsedDeviceName(NULL),
|
||||
@ -33,6 +35,7 @@ DeviceInfoImpl::~DeviceInfoImpl(void) {
|
||||
|
||||
delete &_apiLock;
|
||||
}
|
||||
|
||||
int32_t DeviceInfoImpl::NumberOfCapabilities(const char* deviceUniqueIdUTF8) {
|
||||
if (!deviceUniqueIdUTF8)
|
||||
return -1;
|
||||
@ -41,14 +44,8 @@ int32_t DeviceInfoImpl::NumberOfCapabilities(const char* deviceUniqueIdUTF8) {
|
||||
|
||||
if (_lastUsedDeviceNameLength == strlen((char*)deviceUniqueIdUTF8)) {
|
||||
// Is it the same device that is asked for again.
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX)
|
||||
if (strncasecmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) == 0)
|
||||
#else
|
||||
if (_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) == 0)
|
||||
#endif
|
||||
{
|
||||
_lastUsedDeviceNameLength) == 0) {
|
||||
// yes
|
||||
_apiLock.ReleaseLockShared();
|
||||
return static_cast<int32_t>(_captureCapabilities.size());
|
||||
@ -69,16 +66,9 @@ int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
|
||||
|
||||
ReadLockScoped cs(_apiLock);
|
||||
|
||||
if ((_lastUsedDeviceNameLength != strlen((char*)deviceUniqueIdUTF8))
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX)
|
||||
|| (strncasecmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0))
|
||||
#else
|
||||
|| (_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0))
|
||||
#endif
|
||||
|
||||
{
|
||||
if ((_lastUsedDeviceNameLength != strlen((char*)deviceUniqueIdUTF8)) ||
|
||||
(_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0)) {
|
||||
_apiLock.ReleaseLockShared();
|
||||
_apiLock.AcquireLockExclusive();
|
||||
if (-1 == CreateCapabilityMap(deviceUniqueIdUTF8)) {
|
||||
@ -110,15 +100,9 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability(
|
||||
return -1;
|
||||
|
||||
ReadLockScoped cs(_apiLock);
|
||||
if ((_lastUsedDeviceNameLength != strlen((char*)deviceUniqueIdUTF8))
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX)
|
||||
|| (strncasecmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0))
|
||||
#else
|
||||
|| (_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0))
|
||||
#endif
|
||||
{
|
||||
if ((_lastUsedDeviceNameLength != strlen((char*)deviceUniqueIdUTF8)) ||
|
||||
(_strnicmp((char*)_lastUsedDeviceName, (char*)deviceUniqueIdUTF8,
|
||||
_lastUsedDeviceNameLength) != 0)) {
|
||||
_apiLock.ReleaseLockShared();
|
||||
_apiLock.AcquireLockExclusive();
|
||||
if (-1 == CreateCapabilityMap(deviceUniqueIdUTF8)) {
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_FUCHSIA)
|
||||
#include <zircon/process.h>
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
PlatformThreadId CurrentThreadId() {
|
||||
@ -31,6 +35,8 @@ PlatformThreadId CurrentThreadId() {
|
||||
ret = pthread_mach_thread_np(pthread_self());
|
||||
#elif defined(WEBRTC_ANDROID)
|
||||
ret = gettid();
|
||||
#elif defined(WEBRTC_FUCHSIA)
|
||||
ret = zx_thread_self();
|
||||
#elif defined(WEBRTC_LINUX)
|
||||
ret = syscall(__NR_gettid);
|
||||
#else
|
||||
|
@ -14,6 +14,8 @@
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#elif defined(WEBRTC_FUCHSIA)
|
||||
#include <zircon/types.h>
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
@ -23,6 +25,9 @@ namespace rtc {
|
||||
#if defined(WEBRTC_WIN)
|
||||
typedef DWORD PlatformThreadId;
|
||||
typedef DWORD PlatformThreadRef;
|
||||
#elif defined(WEBRTC_FUCHSIA)
|
||||
typedef zx_handle_t PlatformThreadId;
|
||||
typedef pthread_t PlatformThreadRef;
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
typedef pid_t PlatformThreadId;
|
||||
typedef pthread_t PlatformThreadRef;
|
||||
|
@ -10,19 +10,19 @@
|
||||
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(WEBRTC_WIN)
|
||||
|
||||
// Windows needs to be included before mmsystem.h
|
||||
#include "rtc_base/win32.h"
|
||||
|
||||
#include <MMSystem.h>
|
||||
|
||||
#elif ((defined WEBRTC_LINUX) || (defined WEBRTC_MAC))
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#endif
|
||||
#endif // defined(WEBRTC_POSIX)
|
||||
|
||||
#include "rtc_base/criticalsection.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
@ -79,7 +79,7 @@ class RealTimeClock : public Clock {
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(WEBRTC_WIN)
|
||||
// TODO(pbos): Consider modifying the implementation to synchronize itself
|
||||
// against system time (update ref_point_, make it non-const) periodically to
|
||||
// prevent clock drift.
|
||||
@ -181,7 +181,7 @@ class WindowsRealTimeClock : public RealTimeClock {
|
||||
const ReferencePoint ref_point_;
|
||||
};
|
||||
|
||||
#elif ((defined WEBRTC_LINUX) || (defined WEBRTC_MAC))
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
class UnixRealTimeClock : public RealTimeClock {
|
||||
public:
|
||||
UnixRealTimeClock() {}
|
||||
@ -198,13 +198,14 @@ class UnixRealTimeClock : public RealTimeClock {
|
||||
return tv;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif // defined(WEBRTC_POSIX)
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(WEBRTC_WIN)
|
||||
static WindowsRealTimeClock* volatile g_shared_clock = nullptr;
|
||||
#endif
|
||||
#endif // defined(WEBRTC_WIN)
|
||||
|
||||
Clock* Clock::GetRealTimeClock() {
|
||||
#if defined(_WIN32)
|
||||
#if defined(WEBRTC_WIN)
|
||||
// This read relies on volatile read being atomic-load-acquire. This is
|
||||
// true in MSVC since at least 2005:
|
||||
// "A read of a volatile object (volatile read) has Acquire semantics"
|
||||
@ -219,12 +220,12 @@ Clock* Clock::GetRealTimeClock() {
|
||||
delete clock;
|
||||
}
|
||||
return g_shared_clock;
|
||||
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
static UnixRealTimeClock clock;
|
||||
return &clock;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
#else // defined(WEBRTC_POSIX)
|
||||
return nullptr;
|
||||
#endif // !defined(WEBRTC_WIN) || defined(WEBRTC_POSIX)
|
||||
}
|
||||
|
||||
SimulatedClock::SimulatedClock(int64_t initial_time_us)
|
||||
|
Reference in New Issue
Block a user