Bug 987979: Patch 3 - Fix various build issues in webrtc.org/Mozilla integration. r=rjesup
authorRandell Jesup <rjesup@jesup.org>
Thu, 29 May 2014 17:05:14 -0400
changeset 204967 7a835877bc62a4e05c568093dfd5fe66ca7b3984
parent 204966 ad8a86bfd86021b1a92cce6b6847b17d630a602f
child 204968 0dd0c20bea9229728a0f827433cf6e88a5e3838a
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrjesup
bugs987979
milestone32.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 987979: Patch 3 - Fix various build issues in webrtc.org/Mozilla integration. r=rjesup
config/system-headers
content/media/webrtc/MediaEngineWebRTC.cpp
ipc/chromium/src/base/basictypes.h
media/mtransport/third_party/nICEr/src/stun/addrs.c
media/mtransport/third_party/nICEr/src/stun/stun.h
media/webrtc/signaling/signaling.gyp
media/webrtc/signaling/src/callcontrol/CallControlManagerImpl.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/trunk/build/all.gyp
media/webrtc/trunk/build/filename_rules.gypi
media/webrtc/trunk/webrtc/modules/video_capture/include/video_capture.h
media/webrtc/trunk/webrtc/video_engine/include/vie_base.h
media/webrtc/trunk/webrtc/video_engine/vie_impl.cc
mobile/android/base/moz.build
--- a/config/system-headers
+++ b/config/system-headers
@@ -342,17 +342,16 @@ ColorConverter.h
 #endif
 comdef.h
 commctrl.h
 COMMCTRL.H
 commdlg.h
 compat.h
 condapi.h
 ConditionalMacros.h
-config.h
 conio.h
 console.h
 ControlDefinitions.h
 Controls.h
 CoreFoundation/CoreFoundation.h
 CoreServices/CoreServices.h
 CPalmRec.cpp
 Cpalmrec.h
--- a/content/media/webrtc/MediaEngineWebRTC.cpp
+++ b/content/media/webrtc/MediaEngineWebRTC.cpp
@@ -126,22 +126,20 @@ MediaEngineWebRTC::EnumerateVideoDevices
 #else
   ScopedCustomReleasePtr<webrtc::ViEBase> ptrViEBase;
   ScopedCustomReleasePtr<webrtc::ViECapture> ptrViECapture;
 
   // We spawn threads to handle gUM runnables, so we must protect the member vars
   MutexAutoLock lock(mMutex);
 
 #ifdef MOZ_WIDGET_ANDROID
-  jobject context = mozilla::AndroidBridge::Bridge()->GetGlobalContextRef();
-
   // get the JVM
   JavaVM *jvm = mozilla::AndroidBridge::Bridge()->GetVM();
 
-  if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
+  if (webrtc::VideoEngine::SetAndroidObjects(jvm) != 0) {
     LOG(("VieCapture:SetAndroidObjects Failed"));
     return;
   }
 #endif
   if (!mVideoEngine) {
     if (!(mVideoEngine = webrtc::VideoEngine::Create())) {
       return;
     }
--- a/ipc/chromium/src/base/basictypes.h
+++ b/ipc/chromium/src/base/basictypes.h
@@ -164,23 +164,25 @@ inline To implicit_cast(From const &f) {
 // or to make sure a struct is smaller than a certain size:
 //
 //   COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
 //
 // The second argument to the macro is the name of the variable. If
 // the expression is false, most compilers will issue a warning/error
 // containing the name of the variable.
 
+// Avoid multiple definitions for webrtc
+#if !defined(COMPILE_ASSERT)
 template <bool>
 struct CompileAssert {
 };
 
-#undef COMPILE_ASSERT
 #define COMPILE_ASSERT(expr, msg) \
   typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+#endif
 
 // Implementation details of COMPILE_ASSERT:
 //
 // - COMPILE_ASSERT works by defining an array type that has -1
 //   elements (and thus is invalid) when the expression is false.
 //
 // - The simpler definition
 //
--- a/media/mtransport/third_party/nICEr/src/stun/addrs.c
+++ b/media/mtransport/third_party/nICEr/src/stun/addrs.c
@@ -48,18 +48,18 @@ static char *RCSSTRING __UNUSED__="$Id: 
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #else
 #include <syslog.h>
 /* Work around an Android NDK < r8c bug */
 #undef __unused
 #include <linux/sysctl.h>
 #endif
+#ifndef LINUX
 #include <net/if.h>
-#ifndef LINUX
 #if !defined(__OpenBSD__) && !defined(__NetBSD__)
 #include <net/if_var.h>
 #endif
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <sys/sockio.h>
 #else
 #include <linux/sockios.h>
--- a/media/mtransport/third_party/nICEr/src/stun/stun.h
+++ b/media/mtransport/third_party/nICEr/src/stun/stun.h
@@ -34,23 +34,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 #ifndef _STUN_H
 #define _STUN_H
 
 #ifdef WIN32
 #include <winsock2.h>
 #else
 #include <sys/param.h>
 #include <sys/socket.h>
+#ifndef LINUX
 #include <net/if.h>
-#ifndef LINUX
 #if !defined(__OpenBSD__) && !defined(__NetBSD__)
 #include <net/if_var.h>
 #endif
 #include <net/if_dl.h>
 #include <net/if_types.h>
+#else
+#include <linux/if.h>
 #endif
 #ifndef BSD
 #include <net/route.h>
 #endif
 #include <netinet/in.h>
 #ifndef LINUX
 #include <netinet/in_var.h>
 #endif
--- a/media/webrtc/signaling/signaling.gyp
+++ b/media/webrtc/signaling/signaling.gyp
@@ -45,32 +45,28 @@
         './src/media',
         './src/media-conduit',
         './src/mediapipeline',
         './src/softphonewrapper',
         './src/peerconnection',
         './include',
         './src/sipcc/include',
         './src/sipcc/cpr/include',
-        '../../../ipc/chromium/src',
         '../../../ipc/chromium/src/base/third_party/nspr',
         '../../../xpcom/base',
         '../../../dom/base',
         '../../../content/media',
         '../../../media/mtransport',
         '../trunk',
         '../trunk/webrtc',
         '../trunk/webrtc/video_engine/include',
         '../trunk/webrtc/voice_engine/include',
         '../trunk/webrtc/modules/interface',
         '../trunk/webrtc/peerconnection',
         '../../libyuv/include',
-        '../../../netwerk/srtp/src/include',
-        '../../../netwerk/srtp/src/crypto/include',
-        '../../../ipc/chromium/src',
         '../../mtransport/third_party/nrappkit/src/util/libekr',
       ],
 
       #
       # DEPENDENCIES
       #
       'dependencies': [
       ],
@@ -155,18 +151,16 @@
         './src/peerconnection/PeerConnectionMedia.cpp',
         './src/peerconnection/PeerConnectionMedia.h',
 
         # Media pipeline
         './src/mediapipeline/MediaPipeline.h',
         './src/mediapipeline/MediaPipeline.cpp',
         './src/mediapipeline/MediaPipelineFilter.h',
         './src/mediapipeline/MediaPipelineFilter.cpp',
-        './src/mediapipeline/SrtpFlow.h',
-        './src/mediapipeline/SrtpFlow.cpp',
       ],
 
       #
       # DEFINES
       #
 
       'defines' : [
         'LOG4CXX_STATIC',
@@ -189,22 +183,38 @@
         '$(NSS_CFLAGS)',
         '$(MOZ_PIXMAN_CFLAGS)',
       ],
 
       #
       # Conditionals
       #
       'conditions': [
+        # hack so I can change the include flow for SrtpFlow
+        ['build_with_mozilla==1', {
+          'sources': [
+            './src/mediapipeline/SrtpFlow.h',
+            './src/mediapipeline/SrtpFlow.cpp',
+          ],
+          'include_dirs!': [
+            '../trunk/webrtc',
+          ],
+          'include_dirs': [
+            '../../../netwerk/srtp/src/include',
+            '../../../netwerk/srtp/src/crypto/include',
+          ],
+        }],
         ['moz_webrtc_omx==1', {
           'sources': [
             './src/media-conduit/WebrtcOMXH264VideoCodec.cpp',
             './src/media-conduit/OMXVideoCodec.cpp',
           ],
           'include_dirs': [
+            # hack on hack to re-add it after SrtpFlow removes it
+            '../../webrtc/trunk/webrtc',
             '../../../content/media/omx',
             '../../../gfx/layers/client',
           ],
           'cflags_mozilla': [
             '-I$(ANDROID_SOURCE)/frameworks/av/include/media/stagefright',
             '-I$(ANDROID_SOURCE)/frameworks/av/include',
             '-I$(ANDROID_SOURCE)/frameworks/native/include/media/openmax',
             '-I$(ANDROID_SOURCE)/frameworks/native/include',
@@ -233,30 +243,32 @@
             'USE_FAKE_PCOBSERVER'
           ],
         }],
         ['(OS=="linux") or (OS=="android")', {
           'include_dirs': [
           ],
 
           'defines': [
+            'OS_LINUX',
             'SIP_OS_LINUX',
             '_GNU_SOURCE',
             'LINUX',
             'GIPS_VER=3510',
             'SECLIB_OPENSSL',
           ],
 
           'cflags_mozilla': [
           ],
         }],
         ['OS=="win"', {
           'include_dirs': [
           ],
           'defines': [
+            'OS_WIN',
             'SIP_OS_WINDOWS',
             'WIN32',
             'GIPS_VER=3480',
             'SIPCC_BUILD',
             'HAVE_WINSOCK2_H'
           ],
 
           'cflags_mozilla': [
@@ -274,16 +286,17 @@
 
           'cflags_mozilla': [
           ],
         }],
         ['OS=="mac"', {
           'include_dirs': [
           ],
           'defines': [
+            'OS_MACOSX',
             'SIP_OS_OSX',
             'OSX',
             '_FORTIFY_SOURCE=2',
           ],
 
           'cflags_mozilla': [
           ],
         }],
--- a/media/webrtc/signaling/src/callcontrol/CallControlManagerImpl.cpp
+++ b/media/webrtc/signaling/src/callcontrol/CallControlManagerImpl.cpp
@@ -13,16 +13,18 @@
 #include "CC_SIPCCDeviceInfo.h"
 #include "CC_SIPCCFeatureInfo.h"
 #include "CC_SIPCCLine.h"
 #include "CC_SIPCCLineInfo.h"
 #include "CC_SIPCCCallInfo.h"
 #include "CallControlManagerImpl.h"
 #include "csf_common.h"
 
+#include "base/platform_thread.h"
+
 extern "C"
 {
 #include "config_api.h"
 }
 
 
 static const char logTag[] = "CallControlManager";
 
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -240,22 +240,20 @@ MediaConduitErrorCode WebrtcVideoConduit
     mOtherDirection = other;
 
     // only one can call ::Create()/GetVideoEngine()
     MOZ_ASSERT(other->mVideoEngine);
     mVideoEngine = other->mVideoEngine;
   } else {
 
 #ifdef MOZ_WIDGET_ANDROID
-    jobject context = jsjni_GetGlobalContextRef();
-
     // get the JVM
     JavaVM *jvm = jsjni_GetVM();
 
-    if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
+    if (webrtc::VideoEngine::SetAndroidObjects(jvm) != 0) {
       CSFLogError(logTag,  "%s: could not set Android objects", __FUNCTION__);
       return kMediaConduitSessionNotInited;
     }
 #endif
 
     // Per WebRTC APIs below function calls return nullptr on failure
     if( !(mVideoEngine = webrtc::VideoEngine::Create()) )
     {
--- a/media/webrtc/trunk/build/all.gyp
+++ b/media/webrtc/trunk/build/all.gyp
@@ -99,17 +99,17 @@
             }],
             ['chromeos==0', {
               'dependencies': [
                 '../third_party/cros_dbus_cplusplus/cros_dbus_cplusplus.gyp:*',
               ],
             }],
           ],
         }],
-        ['toolkit_uses_gtk==1', {
+        ['(toolkit_uses_gtk==1) and (build_with_mozilla==0)', {
           'dependencies': [
             '../tools/gtk_clipboard_dump/gtk_clipboard_dump.gyp:*',
             '../tools/xdisplaycheck/xdisplaycheck.gyp:*',
           ],
         }],
         ['OS=="win"', {
           'conditions': [
             ['win_use_allocator_shim==1', {
--- a/media/webrtc/trunk/build/filename_rules.gypi
+++ b/media/webrtc/trunk/build/filename_rules.gypi
@@ -61,17 +61,17 @@
       ],
     }],
     ['<(use_x11)!=1 or >(nacl_untrusted_build)==1', {
       'sources/': [
         ['exclude', '_(x|x11)(_unittest)?\\.(h|cc)$'],
         ['exclude', '(^|/)x11_[^/]*\\.(h|cc)$'],
       ],
     }],
-    ['<(toolkit_uses_gtk)!=1 or >(nacl_untrusted_build)==1', {
+    ['(<(toolkit_uses_gtk)!=1 or >(nacl_untrusted_build)==1) and (build_with_mozilla==0)', {
       'sources/': [
         ['exclude', '_gtk(_browsertest|_unittest)?\\.(h|cc)$'],
         ['exclude', '(^|/)gtk/'],
         ['exclude', '(^|/)gtk_[^/]*\\.(h|cc)$'],
       ],
     }],
     ['<(toolkit_views)==0 or >(nacl_untrusted_build)==1', {
       'sources/': [ ['exclude', '_views\\.(h|cc)$'] ]
--- a/media/webrtc/trunk/webrtc/modules/video_capture/include/video_capture.h
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/include/video_capture.h
@@ -9,23 +9,23 @@
  */
 
 #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
 #define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_
 
 #include "webrtc/modules/interface/module.h"
 #include "webrtc/modules/video_capture/include/video_capture_defines.h"
 
-#ifdef ANDROID
+#if defined(ANDROID) && !defined(WEBRTC_GONK)
 #include <jni.h>
 #endif
 
 namespace webrtc {
 
-#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(WEBRTC_GONK)
 int32_t SetCaptureAndroidVM(JavaVM* javaVM);
 #endif
 
 class VideoCaptureModule: public RefCountedModule {
  public:
   // Interface for receiving information about available camera devices.
   class DeviceInfo {
    public:
--- a/media/webrtc/trunk/webrtc/video_engine/include/vie_base.h
+++ b/media/webrtc/trunk/webrtc/video_engine/include/vie_base.h
@@ -16,17 +16,17 @@
 //    synchronization.
 //  - Start and stop sending and receiving.
 
 #ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_BASE_H_
 #define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_BASE_H_
 
 #include "webrtc/common_types.h"
 
-#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_GONK)
 #include <jni.h>
 #endif
 
 namespace webrtc {
 
 class Config;
 class VoiceEngine;
 
@@ -59,17 +59,17 @@ class WEBRTC_DLLEXPORT VideoEngine {
   // Sets the name of the trace file and enables non‐encrypted trace messages.
   static int SetTraceFile(const char* file_nameUTF8,
                           const bool add_file_counter = false);
 
   // Installs the TraceCallback implementation to ensure that the VideoEngine
   // user receives callbacks for generated trace messages.
   static int SetTraceCallback(TraceCallback* callback);
 
-#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(MOZ_WIDGET_GONK)
   // Android specific.
   static int SetAndroidObjects(JavaVM* java_vm);
 #endif
 
  protected:
   VideoEngine() {}
   virtual ~VideoEngine() {}
 };
--- a/media/webrtc/trunk/webrtc/video_engine/vie_impl.cc
+++ b/media/webrtc/trunk/webrtc/video_engine/vie_impl.cc
@@ -150,17 +150,17 @@ int VideoEngine::SetTraceFilter(const un
 }
 
 int VideoEngine::SetTraceCallback(TraceCallback* callback) {
   WEBRTC_TRACE(kTraceApiCall, kTraceVideo, kModuleId,
                "SetTraceCallback(TraceCallback = 0x%p)", callback);
   return Trace::SetTraceCallback(callback);
 }
 
-#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
+#if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) && !defined(WEBRTC_GONK)
 int VideoEngine::SetAndroidObjects(JavaVM* javaVM) {
   WEBRTC_TRACE(kTraceApiCall, kTraceVideo, kModuleId,
                "SetAndroidObjects()");
 
   if (SetCaptureAndroidVM(javaVM) != 0) {
     WEBRTC_TRACE(kTraceError, kTraceVideo, kModuleId,
                  "Could not set capture Android VM");
     return -1;
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -78,22 +78,25 @@ gujar.extra_jars = [
 gujar.javac_flags += ['-Xlint:all,-deprecation']
 
 stjar = add_java_jar('sync-thirdparty')
 stjar.sources += [ thirdparty_source_dir + f for f in sync_thirdparty_java_files ]
 stjar.javac_flags = ['-Xlint:none']
 
 if CONFIG['MOZ_WEBRTC']:
     video_root = TOPSRCDIR + '/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/'
+    video_render_root = TOPSRCDIR + '/media/webrtc/trunk/webrtc/modules/video_render/android/java/src/org/webrtc/videoengine/'
     audio_root = TOPSRCDIR + '/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/'
     wrjar = add_java_jar('webrtc')
     wrjar.sources += [
         video_root + 'CaptureCapabilityAndroid.java',
         video_root + 'VideoCaptureAndroid.java',
         video_root + 'VideoCaptureDeviceInfoAndroid.java',
+        video_render_root + 'ViEAndroidGLES20.java',
+        video_render_root + 'ViERenderer.java',
     ]
     wrjar.sources += [
         audio_root + 'AudioManagerAndroid.java',
         audio_root + 'WebRTCAudioDevice.java',
     ]
     wrjar.extra_jars = [
         'gecko-R.jar',
         'gecko-browser.jar',