Bug 869206 - Make webrtc code build on gonk-JB, r=jesup
authorMichael Wu <mwu@mozilla.com>
Sat, 04 May 2013 11:00:35 -0400
changeset 141944 6240212ff17968b5dcba0d2a6decbf5d4d507414
parent 141943 390c431a2082e6ea9d4adcbe583080d793bcd656
child 141945 cd374ec0bd26020ed1d75565c33e3af052212029
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs869206
milestone23.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 869206 - Make webrtc code build on gonk-JB, r=jesup
content/media/webrtc/MediaEngineWebRTC.cpp
content/media/webrtc/MediaEngineWebRTC.h
content/media/webrtc/MediaEngineWebRTCVideo.cpp
dom/media/MediaManager.cpp
media/webrtc/trunk/webrtc/voice_engine/voice_engine_impl.cc
--- a/content/media/webrtc/MediaEngineWebRTC.cpp
+++ b/content/media/webrtc/MediaEngineWebRTC.cpp
@@ -36,17 +36,17 @@ GetUserMediaLog()
 #undef LOG
 #define LOG(args) PR_LOG(GetUserMediaLog(), PR_LOG_DEBUG, args)
 
 namespace mozilla {
 
 void
 MediaEngineWebRTC::EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources)
 {
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   MutexAutoLock lock(mMutex);
   if (!mCameraManager) {
     return;
   }
 
   /**
    * We still enumerate every time, in case a new device was plugged in since
    * the last call. TODO: Verify that WebRTC actually does deal with hotplugging
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -40,30 +40,30 @@
 #include "voice_engine/include/voe_audio_processing.h"
 
 // Video Engine
 #include "video_engine/include/vie_base.h"
 #include "video_engine/include/vie_codec.h"
 #include "video_engine/include/vie_render.h"
 #include "video_engine/include/vie_capture.h"
 #include "video_engine/include/vie_file.h"
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
 #include "CameraPreviewMediaStream.h"
 #include "DOMCameraManager.h"
 #include "GonkCameraControl.h"
 #include "ImageContainer.h"
 #include "nsGlobalWindow.h"
 #include "prprf.h"
 #endif
 
 #include "NullTransport.h"
 
 namespace mozilla {
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
 class CameraAllocateRunnable;
 class GetCameraNameRunnable;
 #endif
 
 /**
  * The WebRTC implementation of the MediaEngine interface.
  *
  * On B2G platform, member data may accessed from different thread after construction:
@@ -77,29 +77,29 @@ class GetCameraNameRunnable;
  *   mNativeCameraControl, mPreviewStream, mState, mLastCapture, mWidth, mHeight
  *
  * Where mWidth, mHeight, mImage are protected by mMonitor
  *       mState, mLastCapture is protected by mCallbackMonitor
  * Other variable is accessed only from single thread
  */
 class MediaEngineWebRTCVideoSource : public MediaEngineVideoSource
                                    , public nsRunnable
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
                                    , public nsICameraGetCameraCallback
                                    , public nsICameraPreviewStreamCallback
                                    , public nsICameraTakePictureCallback
                                    , public nsICameraReleaseCallback
                                    , public nsICameraErrorCallback
                                    , public CameraPreviewFrameCallback
 #else
                                    , public webrtc::ExternalRenderer
 #endif
 {
 public:
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   MediaEngineWebRTCVideoSource(nsDOMCameraManager* aCameraManager,
     int aIndex, uint64_t aWindowId)
     : mCameraManager(aCameraManager)
     , mNativeCameraControl(nullptr)
     , mPreviewStream(nullptr)
     , mWindowId(aWindowId)
     , mCallbackMonitor("WebRTCCamera.CallbackMonitor")
     , mCaptureIndex(aIndex)
@@ -150,17 +150,17 @@ public:
                           bool aNoiseOn, uint32_t aNoise) { return NS_OK; };
   virtual void NotifyPull(MediaStreamGraph* aGraph,
                           SourceMediaStream *aSource,
                           TrackID aId,
                           StreamTime aDesiredTime,
                           TrackTicks &aLastEndTime);
 
   NS_DECL_ISUPPORTS
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   NS_DECL_NSICAMERAGETCAMERACALLBACK
   NS_DECL_NSICAMERAPREVIEWSTREAMCALLBACK
   NS_DECL_NSICAMERATAKEPICTURECALLBACK
   NS_DECL_NSICAMERARELEASECALLBACK
   NS_DECL_NSICAMERAERRORCALLBACK
 
   void AllocImpl();
   void DeallocImpl();
@@ -195,17 +195,17 @@ private:
   static const unsigned int KMaxDeviceNameLength = 128;
   static const unsigned int KMaxUniqueIdLength = 256;
 
   // Initialize the needed Video engine interfaces.
   void Init();
   void Shutdown();
 
   // Engine variables.
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   // MediaEngine hold this DOM object, and the MediaEngine is hold by Navigator
   // Their life time is always much longer than this object. Use a raw-pointer
   // here should be safe.
   // We need raw pointer here since such DOM-object should not addref/release on
   // any thread other than main thread, but we must use this object for now. To
   // avoid any bad thing do to addref/release DOM-object on other thread, we use
   // raw-pointer for now.
   nsDOMCameraManager* mCameraManager;
@@ -332,17 +332,17 @@ private:
   webrtc::NsModes  mNoiseSuppress;
 
   NullTransport *mNullTransport;
 };
 
 class MediaEngineWebRTC : public MediaEngine
 {
 public:
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   MediaEngineWebRTC(nsDOMCameraManager* aCameraManager, uint64_t aWindowId)
     : mMutex("mozilla::MediaEngineWebRTC")
     , mVideoEngine(nullptr)
     , mVoiceEngine(nullptr)
     , mVideoEngineInit(false)
     , mAudioEngineInit(false)
     , mCameraManager(aCameraManager)
     , mWindowId(aWindowId)
@@ -382,17 +382,17 @@ private:
   bool mVideoEngineInit;
   bool mAudioEngineInit;
 
   // Store devices we've already seen in a hashtable for quick return.
   // Maps UUID to MediaEngineSource (one set for audio, one for video).
   nsRefPtrHashtable<nsStringHashKey, MediaEngineWebRTCVideoSource > mVideoSources;
   nsRefPtrHashtable<nsStringHashKey, MediaEngineWebRTCAudioSource > mAudioSources;
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   // MediaEngine hold this DOM object, and the MediaEngine is hold by Navigator
   // Their life time is always much longer than this object. Use a raw-pointer
   // here should be safe.
   // We need raw pointer here since such DOM-object should not addref/release on
   // any thread other than main thread, but we must use this object for now. To
   // avoid any bad thing do to addref/release DOM-object on other thread, we use
   // raw-pointer for now.
   nsDOMCameraManager* mCameraManager;
--- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp
@@ -20,17 +20,17 @@ extern PRLogModuleInfo* GetMediaManagerL
 #endif
 
 /**
  * Webrtc video source.
  */
 NS_IMPL_THREADSAFE_ISUPPORTS1(MediaEngineWebRTCVideoSource, nsIRunnable)
 
 // ViEExternalRenderer Callback.
-#ifndef MOZ_WIDGET_GONK
+#ifndef MOZ_B2G_CAMERA
 int
 MediaEngineWebRTCVideoSource::FrameSizeChange(
    unsigned int w, unsigned int h, unsigned int streams)
 {
   mWidth = w;
   mHeight = h;
   LOG(("Video FrameSizeChange: %ux%u", w, h));
   return 0;
@@ -151,17 +151,17 @@ MediaEngineWebRTCVideoSource::NotifyPull
       aLastEndTime = target;
     }
   }
 }
 
 void
 MediaEngineWebRTCVideoSource::ChooseCapability(const MediaEnginePrefs &aPrefs)
 {
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   mCapability.width  = aPrefs.mWidth;
   mCapability.height = aPrefs.mHeight;
 #else
   int num = mViECapture->NumberOfCapabilities(mUniqueId, KMaxUniqueIdLength);
 
   LOG(("ChooseCapability: prefs: %dx%d @%d-%dfps", aPrefs.mWidth, aPrefs.mHeight, aPrefs.mFPS, aPrefs.mMinFPS));
 
   if (num <= 0) {
@@ -219,17 +219,17 @@ MediaEngineWebRTCVideoSource::GetUUID(ns
   // mUniqueId is UTF8
   CopyUTF8toUTF16(mUniqueId, aUUID);
 }
 
 nsresult
 MediaEngineWebRTCVideoSource::Allocate(const MediaEnginePrefs &aPrefs)
 {
   LOG((__FUNCTION__));
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
   if (mState == kReleased && mInitDone) {
     ChooseCapability(aPrefs);
     NS_DispatchToMainThread(WrapRunnable(this,
                                          &MediaEngineWebRTCVideoSource::AllocImpl));
     mCallbackMonitor.Wait();
     if (mState != kAllocated) {
       return NS_ERROR_FAILURE;
@@ -257,23 +257,23 @@ MediaEngineWebRTCVideoSource::Allocate(c
   return NS_OK;
 }
 
 nsresult
 MediaEngineWebRTCVideoSource::Deallocate()
 {
   LOG((__FUNCTION__));
   if (mSources.IsEmpty()) {
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
     ReentrantMonitorAutoEnter sync(mCallbackMonitor);
 #endif
     if (mState != kStopped && mState != kAllocated) {
       return NS_ERROR_FAILURE;
     }
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
     // We do not register success callback here
 
     NS_DispatchToMainThread(WrapRunnable(this,
                                          &MediaEngineWebRTCVideoSource::DeallocImpl));
     mCallbackMonitor.Wait();
     if (mState != kReleased) {
       return NS_ERROR_FAILURE;
     }
@@ -314,26 +314,26 @@ MediaEngineWebRTCVideoSource::Start(Sour
     return NS_ERROR_FAILURE;
   }
 
   mSources.AppendElement(aStream);
 
   aStream->AddTrack(aID, USECS_PER_S, 0, new VideoSegment());
   aStream->AdvanceKnownTracksTime(STREAM_TIME_MAX);
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
 #endif
 
   if (mState == kStarted) {
     return NS_OK;
   }
   mImageContainer = layers::LayerManager::CreateImageContainer();
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   NS_DispatchToMainThread(WrapRunnable(this,
                                        &MediaEngineWebRTCVideoSource::StartImpl,
                                        mCapability));
   mCallbackMonitor.Wait();
   if (mState != kStarted) {
     return NS_ERROR_FAILURE;
   }
 #else
@@ -362,32 +362,32 @@ MediaEngineWebRTCVideoSource::Stop(Sourc
   LOG((__FUNCTION__));
   if (!mSources.RemoveElement(aSource)) {
     // Already stopped - this is allowed
     return NS_OK;
   }
   if (!mSources.IsEmpty()) {
     return NS_OK;
   }
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
 #endif
   if (mState != kStarted) {
     return NS_ERROR_FAILURE;
   }
 
   {
     MonitorAutoLock lock(mMonitor);
     mState = kStopped;
     aSource->EndTrack(aID);
     // Drop any cached image so we don't start with a stale image on next
     // usage
     mImage = nullptr;
   }
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   NS_DispatchToMainThread(WrapRunnable(this,
                                        &MediaEngineWebRTCVideoSource::StopImpl));
 #else
   mViERender->StopRender(mCaptureIndex);
   mViERender->RemoveRenderer(mCaptureIndex);
   mViECapture->StopCapture(mCaptureIndex);
 #endif
 
@@ -408,24 +408,24 @@ MediaEngineWebRTCVideoSource::Snapshot(u
    * GetCaptureDeviceSnapshot to work, so we immediately set the condition
    * variable to false and notify this method.
    *
    * This causes the current thread to continue (PR_CondWaitVar will return),
    * at which point we can grab a snapshot, convert it to a file and
    * return from this function after cleaning up the temporary stream object
    * and caling Stop() on the media source.
    */
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
 #endif
   *aFile = nullptr;
   if (!mInitDone || mState != kAllocated) {
     return NS_ERROR_FAILURE;
   }
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   mLastCapture = nullptr;
 
   NS_DispatchToMainThread(WrapRunnable(this,
                                        &MediaEngineWebRTCVideoSource::StartImpl,
                                        mCapability));
   mCallbackMonitor.Wait();
   if (mState != kStarted) {
     return NS_ERROR_FAILURE;
@@ -524,17 +524,17 @@ MediaEngineWebRTCVideoSource::Snapshot(u
  * constructor and destructor respectively.
  */
 
 void
 MediaEngineWebRTCVideoSource::Init()
 {
   mDeviceName[0] = '\0'; // paranoia
   mUniqueId[0] = '\0';
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   nsCString deviceName;
   mCameraManager->GetCameraName(mCaptureIndex, deviceName);
 
   nsString deviceNameUTF16;
   deviceNameUTF16.AssignASCII(deviceName.get());
   char* UTF8Name = ToNewUTF8String(deviceNameUTF16);
   memcpy(mDeviceName, UTF8Name, strlen(UTF8Name));
   memcpy(mUniqueId, UTF8Name, strlen(UTF8Name));
@@ -574,39 +574,39 @@ MediaEngineWebRTCVideoSource::Init()
 
 void
 MediaEngineWebRTCVideoSource::Shutdown()
 {
   LOG((__FUNCTION__));
   if (!mInitDone) {
     return;
   }
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
 #endif
   if (mState == kStarted) {
     while (!mSources.IsEmpty()) {
       Stop(mSources[0], kVideoTrack); // XXX change to support multiple tracks
     }
     MOZ_ASSERT(mState == kStopped);
   }
 
   if (mState == kAllocated || mState == kStopped) {
     Deallocate();
   }
-#ifndef MOZ_WIDGET_GONK
+#ifndef MOZ_B2G_CAMERA
   mViECapture->Release();
   mViERender->Release();
   mViEBase->Release();
 #endif
   mState = kReleased;
   mInitDone = false;
 }
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
 
 // All these functions must be run on MainThread!
 void
 MediaEngineWebRTCVideoSource::AllocImpl() {
   MOZ_ASSERT(NS_IsMainThread());
 
   mDOMCameraControl = new nsDOMCameraControl(mCaptureIndex,
                                              mCameraThread,
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1045,17 +1045,17 @@ MediaManager::GetUserMedia(bool aPrivile
                                            );
   } else {
     // Stream from default device from WebRTC backend.
     gUMRunnable = new GetUserMediaRunnable(
       audio, video, picture, onSuccess.forget(), onError.forget(), windowID, listener, mPrefs
                                            );
   }
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_CAMERA
   if (mCameraManager == nullptr) {
     mCameraManager = nsDOMCameraManager::CheckPermissionAndCreateInstance(aWindow);
     if (!mCameraManager) {
       aPrivileged = false;
     }
   }
 #endif
 
@@ -1141,17 +1141,17 @@ MediaEngine*
 MediaManager::GetBackend(uint64_t aWindowId)
 {
   // Plugin backends as appropriate. The default engine also currently
   // includes picture support for Android.
   // This IS called off main-thread.
   MutexAutoLock lock(mMutex);
   if (!mBackend) {
 #if defined(MOZ_WEBRTC)
-  #ifndef MOZ_WIDGET_GONK
+  #ifndef MOZ_B2G_CAMERA
     mBackend = new MediaEngineWebRTC();
   #else
     mBackend = new MediaEngineWebRTC(mCameraManager, aWindowId);
   #endif
 #else
     mBackend = new MediaEngineDefault();
 #endif
   }
--- a/media/webrtc/trunk/webrtc/voice_engine/voice_engine_impl.cc
+++ b/media/webrtc/trunk/webrtc/voice_engine/voice_engine_impl.cc
@@ -3,17 +3,17 @@
  *
  *  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.
  */
 
-#ifdef ANDROID
+#if defined(ANDROID) && !defined(MOZ_WIDGET_GONK)
 #include "modules/audio_device/android/audio_device_jni_android.h"
 #endif
 
 #include "voice_engine_impl.h"
 #include "trace.h"
 
 namespace webrtc
 {