Bug 818843 - Part 2: gyp modifications and add some system call wrappers for B2G. r=ted, r=ethanhugg, r=jesup
authorSteven Lee <slee@mozilla.com>
Tue, 19 Mar 2013 16:02:44 -0400
changeset 125491 b7bd912ce45a49a14dbd2ebec3208a8d866f206a
parent 125490 d8b5d339bb1b22e6fd778d16f75f0755c05655b3
child 125492 3491ce05b207eb43cedb03490597abe65e5c4fa6
push id24459
push useremorley@mozilla.com
push dateWed, 20 Mar 2013 11:46:36 +0000
treeherdermozilla-central@1d6fe70c79c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, ethanhugg, jesup
bugs818843
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 818843 - Part 2: gyp modifications and add some system call wrappers for B2G. r=ted, r=ethanhugg, r=jesup
b2g/confvars.sh
configure.in
media/mtransport/third_party/nICEr/nicer.gyp
media/webrtc/signaling/signaling.gyp
media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_init.c
media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_ipc.c
media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_socket.c
media/webrtc/trunk/webrtc/build/common.gypi
media/webrtc/trunk/webrtc/system_wrappers/source/cpu_info.cc
media/webrtc/trunk/webrtc/system_wrappers/source/system_wrappers.gyp
media/webrtc/trunk/webrtc/system_wrappers/source/thread_posix.cc
media/webrtc/webrtc_config.gypi
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -36,16 +36,18 @@ fi
 MOZ_USE_NATIVE_POPUP_WINDOWS=1
 
 if test "$LIBXUL_SDK"; then
 MOZ_XULRUNNER=1
 else
 MOZ_XULRUNNER=
 fi
 
+MOZ_MEDIA_NAVIGATOR=1
+
 MOZ_APP_ID={3c2e2abc-06d4-11e1-ac3b-374f68613e61}
 MOZ_EXTENSION_MANAGER=1
 
 MOZ_SYS_MSG=1
 MOZ_TIME_MANAGER=1
 
 MOZ_B2G_CERTDATA=1
 MOZ_PAY=1
--- a/configure.in
+++ b/configure.in
@@ -9074,17 +9074,17 @@ fi
 if test -z "$HAVE_TOOLCHAIN_SUPPORT_MSSE4_1"; then
   EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D yuv_disable_asm=1"
 fi
 
 if test -n "$MOZ_WEBRTC"; then
    AC_MSG_RESULT("generating WebRTC Makefiles...")
 
    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
-      EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D build_with_gonk=1"
+      EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D build_with_gonk=1 -D include_internal_audio_device=0"
    fi
 
 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
 dnl so that regeneration via dependencies works correctly
    WEBRTC_CONFIG="-D build_with_mozilla=1 -D build_with_chromium=0 --include ${srcdir}/media/webrtc/webrtc_config.gypi -D FORCED_INCLUDE_FILE=${srcdir}/media/webrtc/webrtc_config.gypi"
 
    if test -n HAVE_CLOCK_MONOTONIC; then
       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=1"
--- a/media/mtransport/third_party/nICEr/nicer.gyp
+++ b/media/mtransport/third_party/nICEr/nicer.gyp
@@ -201,13 +201,19 @@
                  ],
 
 		 'include_dirs': [
 		     '../nrappkit/src/port/linux/include'
 		 ],
 		 
 		 'sources': [
 		 ],
-              }]
-          ]
+              }],
+              ['moz_widget_toolkit_gonk==1', {
+                'defines' : [
+                  'WEBRTC_GONK',
+                  'NO_REG_RPC',
+                ],
+             }],
+          ],
       }]
 }
 
--- a/media/webrtc/signaling/signaling.gyp
+++ b/media/webrtc/signaling/signaling.gyp
@@ -8,16 +8,26 @@
 # sip.gyp - a library for SIP
 #
 
 {
   'variables': {
     'chromium_code': 1,
   },
 
+  'target_defaults': {
+    'conditions': [
+      ['moz_widget_toolkit_gonk==1', {
+        'defines' : [
+          'WEBRTC_GONK',
+       ],
+      }],
+    ],
+  },
+
   'targets': [
 
     #
     # ECC
     #
     {
       'target_name': 'ecc',
       'type': 'static_library',
--- a/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_init.c
+++ b/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_init.c
@@ -112,18 +112,23 @@
 #include "cpr.h"
 #include "cpr_stdlib.h"
 #include "cpr_stdio.h"
 #include "cpr_timers.h"
 #include "cpr_linux_locks.h"
 #include "cpr_linux_timers.h"
 #include "plat_api.h"
 #include <errno.h>
+#if defined(WEBRTC_GONK)
+#include <linux/msg.h>
+#include <linux/ipc.h>
+#else
 #include <sys/msg.h>
 #include <sys/ipc.h>
+#endif
 #include "plat_debug.h"
 
 /**
   * Mutex to manage message queue list.
   */
 extern pthread_mutex_t msgQueueListMutex;
 
 /**
--- a/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_ipc.c
+++ b/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_ipc.c
@@ -31,25 +31,54 @@
  * @{
  *
  *
  */
 #include "cpr.h"
 #include "cpr_stdlib.h"
 #include <cpr_stdio.h>
 #include <errno.h>
+#if defined(WEBRTC_GONK)
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <linux/msg.h>
+#include <linux/ipc.h>
+#else
 #include <sys/msg.h>
 #include <sys/ipc.h>
+#endif
 #include "plat_api.h"
 #include "CSFLog.h"
 
 static const char *logTag = "cpr_linux_ipc";
 
 #define STATIC static
 
+#if defined(WEBRTC_GONK)
+int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
+{
+  return syscall(__NR_msgsnd, msqid, msgp, msgsz, msgflg);
+}
+
+ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
+{
+  return syscall(__NR_msgrcv, msqid, msgp, msgsz, msgtyp, msgflg);
+}
+
+int msgctl(int msqid, int cmd, struct msqid_ds *buf)
+{
+  return syscall(__NR_msgctl, msqid, cmd, buf);
+}
+
+int msgget(key_t key, int msgflg)
+{
+  return syscall(__NR_msgget, key, msgflg);
+}
+#endif
+
 /* @def The Message Queue depth */
 #define OS_MSGTQL 31
 
 /*
  * Internal CPR API
  */
 extern pthread_t cprGetThreadId(cprThread_t thread);
 
--- a/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_socket.c
+++ b/media/webrtc/signaling/src/sipcc/cpr/linux/cpr_linux_socket.c
@@ -7,18 +7,23 @@
 #include "cpr_assert.h"
 #include "cpr_socket.h"
 #include "cpr_debug.h"
 #include "cpr_rand.h"
 #include "cpr_timers.h"
 #include "cpr_errno.h"
 #include "cpr_stdlib.h"
 #include "cpr_string.h"
+#if defined(WEBRTC_GONK)
+#include <syslog.h>
+#include <linux/fcntl.h>
+#else
 #include <sys/syslog.h>
 #include <sys/fcntl.h>
+#endif
 #include <ctype.h>
 
 
 //const cpr_in6_addr_t in6addr_any = IN6ADDR_ANY_INIT;
 const cpr_ip_addr_t ip_addr_invalid = {0};
 
 #define IN6ADDRSZ   16
 #define INT16SZ     2
--- a/media/webrtc/trunk/webrtc/build/common.gypi
+++ b/media/webrtc/trunk/webrtc/build/common.gypi
@@ -145,16 +145,21 @@
     ],
     'defines': [
       # TODO(leozwang): Run this as a gclient hook rather than at build-time:
       # http://code.google.com/p/webrtc/issues/detail?id=687
       'WEBRTC_SVNREVISION="\\\"Unavailable_issue687\\\""',
       #'WEBRTC_SVNREVISION="<!(python <(webrtc_root)/build/version.py)"',
     ],
     'conditions': [
+      ['moz_widget_toolkit_gonk==1', {
+        'defines' : [
+          'WEBRTC_GONK',
+        ],
+      }],
       ['enable_tracing==1', {
         'defines': ['WEBRTC_LOGGING',],
       }],
       ['build_with_mozilla==1', {
         'defines': [
           # Changes settings for Mozilla build.
           'WEBRTC_MOZILLA_BUILD',
          ],
@@ -214,16 +219,23 @@
         'defines': [
           'WEBRTC_MAC',
           'WEBRTC_IOS',
           'WEBRTC_THREAD_RR',
           'WEBRTC_CLOCK_TYPE_REALTIME',
         ],
       }],
       ['OS=="linux"', {
+        'conditions': [
+          ['have_clock_monotonic==1', {
+            'defines': [
+              'WEBRTC_CLOCK_TYPE_REALTIME',
+            ],
+          }],
+        ],
         'defines': [
           'WEBRTC_LINUX',
           'WEBRTC_THREAD_RR',
           # TODO(andrew): can we select this automatically?
           # Define this if the Linux system does not support CLOCK_MONOTONIC.
           #'WEBRTC_CLOCK_TYPE_REALTIME',
         ],
       }],
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/cpu_info.cc
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/cpu_info.cc
@@ -31,17 +31,17 @@ WebRtc_UWord32 CpuInfo::DetectNumberOfCo
   if (!number_of_cores_) {
 #if defined(_WIN32)
     SYSTEM_INFO si;
     GetSystemInfo(&si);
     number_of_cores_ = static_cast<WebRtc_UWord32>(si.dwNumberOfProcessors);
     WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
                  "Available number of cores:%d", number_of_cores_);
 
-#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
+#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) && !defined(WEBRTC_GONK)
     number_of_cores_ = get_nprocs();
     WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
                  "Available number of cores:%d", number_of_cores_);
 
 #elif defined(WEBRTC_MAC)
     int name[] = {CTL_HW, HW_AVAILCPU};
     int ncpu;
     size_t size = sizeof(ncpu);
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/system_wrappers.gyp
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/system_wrappers.gyp
@@ -131,17 +131,17 @@
             'trace_impl.cc',
             'trace_impl.h',
             'trace_posix.cc',
             'trace_posix.h',
             'trace_win.cc',
             'trace_win.h',
           ],
         }],
-        ['OS=="android"', {
+        ['OS=="android" or moz_widget_toolkit_gonk==1', {
           'dependencies': [ 'cpu_features_android', ],
         }],
         ['OS=="linux"', {
           'link_settings': {
             'libraries': [ '-lrt', ],
           },
         }],
         ['OS=="mac"', {
@@ -183,17 +183,17 @@
           'sources!': [
             'atomic32_posix.cc',
           ],
         }],
       ],
     },
   ], # targets
   'conditions': [
-    ['OS=="android"', {
+    ['OS=="android" or moz_widget_toolkit_gonk==1', {
       'targets': [
         {
           'variables': {
             # Treat this as third-party code.
             'chromium_code': 0,
           },
           'target_name': 'cpu_features_android',
           'type': '<(library)',
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/thread_posix.cc
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/thread_posix.cc
@@ -119,41 +119,41 @@ ThreadPosix::ThreadPosix(ThreadRunFuncti
       obj_(obj),
       crit_state_(CriticalSectionWrapper::CreateCriticalSection()),
       alive_(false),
       dead_(true),
       prio_(prio),
       event_(EventWrapper::Create()),
       name_(),
       set_thread_name_(false),
-#if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID))
+#if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) || defined(WEBRTC_GONK))
       pid_(-1),
 #endif
       attr_(),
       thread_(0) {
   if (thread_name != NULL) {
     set_thread_name_ = true;
     strncpy(name_, thread_name, kThreadMaxNameLength);
     name_[kThreadMaxNameLength - 1] = '\0';
   }
 }
 
 uint32_t ThreadWrapper::GetThreadId() {
-#if defined(WEBRTC_ANDROID) || defined(WEBRTC_LINUX)
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_LINUX) || defined(WEBRTC_GONK)
   return static_cast<uint32_t>(syscall(__NR_gettid));
 #elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
   return pthread_mach_thread_np(pthread_self());
 #else
   return reinterpret_cast<uint32_t>(pthread_self());
 #endif
 }
 
 int ThreadPosix::Construct() {
   int result = 0;
-#if !defined(WEBRTC_ANDROID)
+#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_GONK)
   // Enable immediate cancellation if requested, see Shutdown().
   result = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
   if (result != 0) {
     return -1;
   }
   result = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
   if (result != 0) {
     return -1;
@@ -232,31 +232,31 @@ bool ThreadPosix::Start(unsigned int& th
     WEBRTC_TRACE(kTraceError, kTraceUtility, -1,
                  "unable to set thread priority");
   }
   return true;
 }
 
 // CPU_ZERO and CPU_SET are not available in NDK r7, so disable
 // SetAffinity on Android for now.
-#if (defined(WEBRTC_LINUX) && (!defined(WEBRTC_ANDROID)))
+#if (defined(WEBRTC_LINUX) && (!defined(WEBRTC_ANDROID)) && (!defined(WEBRTC_GONK)))
 bool ThreadPosix::SetAffinity(const int* processor_numbers,
                               const unsigned int amount_of_processors) {
   if (!processor_numbers || (amount_of_processors == 0)) {
     return false;
   }
   cpu_set_t mask;
   CPU_ZERO(&mask);
 
   for (unsigned int processor = 0;
        processor < amount_of_processors;
        ++processor) {
     CPU_SET(processor_numbers[processor], &mask);
   }
-#if defined(WEBRTC_ANDROID)
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_GONK)
   // Android.
   const int result = syscall(__NR_sched_setaffinity,
                              pid_,
                              sizeof(mask),
                              &mask);
 #else
   // "Normal" Linux.
   const int result = sched_setaffinity(pid_,
@@ -311,17 +311,17 @@ bool ThreadPosix::Stop() {
 }
 
 void ThreadPosix::Run() {
   {
     CriticalSectionScoped cs(crit_state_);
     alive_ = true;
     dead_  = false;
   }
-#if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID))
+#if (defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) || defined(WEBRTC_GONK))
   pid_ = GetThreadId();
 #endif
   // The event the Start() is waiting for.
   event_->Set();
 
   if (set_thread_name_) {
 #ifdef WEBRTC_LINUX
     prctl(PR_SET_NAME, (unsigned long)name_, 0, 0, 0);
--- a/media/webrtc/webrtc_config.gypi
+++ b/media/webrtc/webrtc_config.gypi
@@ -18,16 +18,26 @@
     'include_tests': 0,
     'enable_android_opensl': 1,
 # use_system_lib* still seems to be in use in trunk/build
     'use_system_libjpeg': 0,
     'use_system_libvpx': 0,
     'build_libjpeg': 0,
     'build_libvpx': 0,
 
+    #if "-D build_with_gonk=1", then set moz_widget_toolkit_gonk to 1
+    'moz_widget_toolkit_gonk': 0,
+    'variables': {
+      'build_with_gonk%': 0,
+    },
+    'conditions': [
+      ['build_with_gonk==1', {
+         'moz_widget_toolkit_gonk': 1,
+      }],
+    ],
 # (for vp8) chromium sets to 0 also
     'use_temporal_layers': 0,
 # Creates AEC internal sample dump files in current directory
 #    'aec_debug_dump': 1,
 
     # codec enable/disables:
     # Note: if you change one here, you must modify shared_libs.mk!
     'include_g711': 1,