Bug 1287854 - Fix MediaEngineGonk build r?padenot draft
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Tue, 19 Jul 2016 19:09:16 +0200
changeset 390587 4ab8fb9b48bd27afcd27f43bb6610c6ca98b2f46
parent 390029 d224fc999cb6accb208af0a105f14433375e2e77
child 390588 8e9e8c23ac5d14bde6225420c572912fcdfc95cb
child 390591 cdc841e672b55a84ef3dc0283f57f609895beb3d
child 390593 b9059e95b2b4386f7b57268e2db5cc3adc706ac8
push id23698
push userbmo:lissyx+mozillians@lissyx.dyndns.org
push dateThu, 21 Jul 2016 13:05:44 +0000
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;