Bug 1287854 - Fix MediaEngineGonk build r=padenot
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Tue, 19 Jul 2016 19:09:16 +0200
changeset 331156 91056939fa77d89ff221df7cc2b524ff6ceee2a7
parent 331155 d93b95e192e9be54084b62c6ef547b4e3cb5b4c2
child 331157 7e53fb50f0afbde895fcc4bd2b413224862546ae
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1287854
milestone50.0a1
Bug 1287854 - Fix MediaEngineGonk build r=padenot MozReview-Commit-ID: 5jmepGcWiIG
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
dom/media/webrtc/MediaEngineGonkVideoSource.h
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -99,17 +99,17 @@ MediaEngineGonkVideoSource::NotifyPull(M
     segment.AppendFrame(image.forget(), delta, size, aPrincipalHandle);
     // This can fail if either a) we haven't added the track yet, or b)
     // we've removed or finished the track.
     aSource->AppendToTrack(aID, &(segment));
   }
 }
 
 size_t
-MediaEngineGonkVideoSource::NumCapabilities()
+MediaEngineGonkVideoSource::NumCapabilities() const
 {
   // TODO: Stop hardcoding. Use GetRecorderProfiles+GetProfileInfo (Bug 1128550)
   //
   // The camera-selecting constraints algorithm needs a set of capabilities to
   // work on. In lieu of something better, here are some generic values based on
   // http://en.wikipedia.org/wiki/Comparison_of_Firefox_OS_devices on Jan 2015.
   // When unknown, better overdo it with choices to not block legitimate asks.
   // TODO: Match with actual hardware or add code to query hardware.
@@ -145,38 +145,45 @@ MediaEngineGonkVideoSource::NumCapabilit
   }
   return mHardcodedCapabilities.Length();
 }
 
 nsresult
 MediaEngineGonkVideoSource::Allocate(const dom::MediaTrackConstraints& aConstraints,
                                      const MediaEnginePrefs& aPrefs,
                                      const nsString& aDeviceId,
-                                     const nsACString& aOrigin)
+                                     const nsACString& aOrigin,
+                                     BaseAllocationHandle** aOutHandle,
+                                     const char** aOutBadConstraint)
 {
   LOG((__FUNCTION__));
 
   ReentrantMonitorAutoEnter sync(mCallbackMonitor);
   if (mState == kReleased && mInitDone) {
-    ChooseCapability(aConstraints, aPrefs, aDeviceId);
+    NormalizedConstraints constraints(aConstraints);
+    ChooseCapability(constraints, aPrefs, aDeviceId);
     NS_DispatchToMainThread(WrapRunnable(RefPtr<MediaEngineGonkVideoSource>(this),
                                          &MediaEngineGonkVideoSource::AllocImpl));
     mCallbackMonitor.Wait();
     if (mState != kAllocated) {
       return NS_ERROR_FAILURE;
     }
   }
 
+  aOutHandle = nullptr;
   return NS_OK;
 }
 
 nsresult
-MediaEngineGonkVideoSource::Deallocate()
+MediaEngineGonkVideoSource::Deallocate(BaseAllocationHandle* aHandle)
 {
   LOG((__FUNCTION__));
+  AssertIsOnOwningThread();
+  MOZ_ASSERT(!aHandle);
+
   bool empty;
   {
     MonitorAutoLock lock(mMonitor);
     empty = mSources.IsEmpty();
   }
   if (empty) {
 
     ReentrantMonitorAutoEnter sync(mCallbackMonitor);
@@ -327,19 +334,21 @@ MediaEngineGonkVideoSource::Stop(SourceM
 
   NS_DispatchToMainThread(WrapRunnable(RefPtr<MediaEngineGonkVideoSource>(this),
                                        &MediaEngineGonkVideoSource::StopImpl));
 
   return NS_OK;
 }
 
 nsresult
-MediaEngineGonkVideoSource::Restart(const dom::MediaTrackConstraints& aConstraints,
+MediaEngineGonkVideoSource::Restart(BaseAllocationHandle* aHandle,
+                                    const dom::MediaTrackConstraints& aConstraints,
                                     const MediaEnginePrefs& aPrefs,
-                                    const nsString& aDeviceId)
+                                    const nsString& aDeviceId,
+                                    const char** aOutBadConstraint)
 {
   return NS_OK;
 }
 
 /**
 * Initialization and Shutdown functions for the video source, called by the
 * constructor and destructor respectively.
 */
@@ -379,17 +388,17 @@ MediaEngineGonkVideoSource::Shutdown()
         source = mSources[0];
       }
       Stop(source, kVideoTrack); // XXX change to support multiple tracks
     }
     MOZ_ASSERT(mState == kStopped);
   }
 
   if (mState == kAllocated || mState == kStopped) {
-    Deallocate();
+    Deallocate(nullptr);
   }
 
   mState = kReleased;
   mInitDone = false;
 }
 
 // All these functions must be run on MainThread!
 void
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.h
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.h
@@ -58,24 +58,28 @@ public:
     , mOrientationChanged(true) // Correct the orientation at first time takePhoto.
     {
       Init();
     }
 
   nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
                     const MediaEnginePrefs &aPrefs,
                     const nsString& aDeviceId,
-                    const nsACString& aOrigin) override;
-  nsresult Deallocate() override;
+                    const nsACString& aOrigin,
+                    BaseAllocationHandle** aOutHandle,
+                    const char** aOutBadConstraint) override;
+  nsresult Deallocate(BaseAllocationHandle* aHandle) override;
   nsresult Start(SourceMediaStream* aStream, TrackID aID,
                  const PrincipalHandle& aPrincipalHandle) override;
   nsresult Stop(SourceMediaStream* aSource, TrackID aID) override;
-  nsresult Restart(const dom::MediaTrackConstraints& aConstraints,
+  nsresult Restart(BaseAllocationHandle* aHandle,
+                   const dom::MediaTrackConstraints& aConstraints,
                    const MediaEnginePrefs &aPrefs,
-                   const nsString& aDeviceId) override;
+                   const nsString& aDeviceId,
+                   const char** aOutBadConstraint) override;
   void NotifyPull(MediaStreamGraph* aGraph,
                   SourceMediaStream* aSource,
                   TrackID aId,
                   StreamTime aDesiredTime,
                   const PrincipalHandle& aPrincipalHandle) override;
   dom::MediaSourceEnum GetMediaSource() const override {
     return dom::MediaSourceEnum::Camera;
   }
@@ -109,17 +113,17 @@ public:
 protected:
   ~MediaEngineGonkVideoSource()
   {
     Shutdown();
   }
   // Initialize the needed Video engine interfaces.
   void Init();
   void Shutdown();
-  size_t NumCapabilities() override;
+  size_t NumCapabilities() const override;
   // Initialize the recording frame (MediaBuffer) callback and Gonk camera.
   // MediaBuffer will transfers to MediaStreamGraph via AppendToTrack.
   nsresult InitDirectMediaBuffer();
 
   mozilla::ReentrantMonitor mCallbackMonitor; // Monitor for camera callback handling
   // This is only modified on MainThread (AllocImpl and DeallocImpl)
   RefPtr<ICameraControl> mCameraControl;
   RefPtr<dom::File> mLastCapture;