Bug 1137515 part 2 - Change to media r=jesup
☠☠ backed out by ae42a2adeebd ☠ ☠
authorSotaro Ikeda <sikeda@mozilla.com>
Wed, 11 Mar 2015 07:18:23 -0700
changeset 233037 fad66e8fe87446888a85895d00d290ed7fb51e04
parent 233036 79eab0a3960e3c55a62e1cda21103bdf7bbb6143
child 233038 cd5ec762afa14dcccf43e04c572793626a1d6f1e
push id56721
push usersikeda@mozilla.com
push dateWed, 11 Mar 2015 14:19:07 +0000
treeherdermozilla-inbound@cd5ec762afa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1137515
milestone39.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 1137515 part 2 - Change to media r=jesup
dom/media/omx/OMXCodecWrapper.cpp
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
--- a/dom/media/omx/OMXCodecWrapper.cpp
+++ b/dom/media/omx/OMXCodecWrapper.cpp
@@ -11,16 +11,17 @@
 #include <cutils/properties.h>
 #include <media/ICrypto.h>
 #include <media/IOMX.h>
 #include <OMX_Component.h>
 #include <stagefright/MediaDefs.h>
 #include <stagefright/MediaErrors.h>
 
 #include "AudioChannelFormat.h"
+#include "GrallocImages.h"
 #include <mozilla/Monitor.h>
 #include "mozilla/layers/GrallocTextureClient.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 #define INPUT_BUFFER_TIMEOUT_US (5 * 1000ll)
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -240,19 +240,23 @@ MediaEngineGonkVideoSource::Start(Source
   for (nsTArray<nsString>::index_type i = 0; i < focusModes.Length(); ++i) {
     if (focusModes[i].EqualsASCII("continuous-video")) {
       mCameraControl->Set(CAMERA_PARAM_FOCUSMODE, focusModes[i]);
       mCameraControl->ResumeContinuousFocus();
       break;
     }
   }
 
+  // XXX some devices support recording camera frame only in metadata mode.
+  // But GonkCameraSource requests non-metadata recording mode.
+#if ANDROID_VERSION < 21
   if (NS_FAILED(InitDirectMediaBuffer())) {
     return NS_ERROR_FAILURE;
   }
+#endif
 
   return NS_OK;
 }
 
 nsresult
 MediaEngineGonkVideoSource::InitDirectMediaBuffer()
 {
   // Check available buffer resolution.
@@ -471,18 +475,20 @@ MediaEngineGonkVideoSource::StartImpl(we
 
   hal::RegisterScreenConfigurationObserver(this);
 }
 
 void
 MediaEngineGonkVideoSource::StopImpl() {
   MOZ_ASSERT(NS_IsMainThread());
 
-  mCameraSource->stop();
-  mCameraSource = nullptr;
+  if (mCameraSource.get()) {
+    mCameraSource->stop();
+    mCameraSource = nullptr;
+  }
 
   hal::UnregisterScreenConfigurationObserver(this);
   mCameraControl->Stop();
 }
 
 void
 MediaEngineGonkVideoSource::OnHardwareStateChange(HardwareState aState,
                                                   nsresult aReason)
--- a/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcOMXH264VideoCodec.cpp
@@ -21,17 +21,21 @@
 using namespace android;
 
 // WebRTC
 #include "webrtc/common_video/interface/texture_video_frame.h"
 #include "webrtc/video_engine/include/vie_external_codec.h"
 #include "runnable_utils.h"
 
 // Gecko
+#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
+#include "GonkBufferQueueProducer.h"
+#endif
 #include "GonkNativeWindow.h"
+#include "GrallocImages.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Mutex.h"
 #include "nsThreadUtils.h"
 #include "OMXCodecWrapper.h"
 #include "TextureClient.h"
 #include "mozilla/IntegerPrintfMacros.h"
 
 #define DEQUEUE_BUFFER_TIMEOUT_US (100 * 1000ll) // 100ms.
@@ -311,26 +315,40 @@ public:
     sp<AMessage> config = new AMessage();
     config->setString("mime", MEDIA_MIMETYPE_VIDEO_AVC);
     config->setInt32("width", aWidth);
     config->setInt32("height", aHeight);
     mWidth = aWidth;
     mHeight = aHeight;
 
     sp<Surface> surface = nullptr;
+#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
+    sp<IGraphicBufferProducer> producer;
+    sp<IGonkGraphicBufferConsumer> consumer;
+    GonkBufferQueue::createBufferQueue(&producer, &consumer);
+    mNativeWindow = new GonkNativeWindow(consumer);
+#else
     mNativeWindow = new GonkNativeWindow();
+#endif
     if (mNativeWindow.get()) {
       // listen to buffers queued by MediaCodec::RenderOutputBufferAndRelease().
       mNativeWindow->setNewFrameCallback(this);
       // XXX remove buffer changes after a better solution lands - bug 1009420
+#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
+      static_cast<GonkBufferQueueProducer*>(producer.get())->setSynchronousMode(false);
+      // More spare buffers to avoid OMX decoder waiting for native window
+      consumer->setMaxAcquiredBufferCount(WEBRTC_OMX_H264_MIN_DECODE_BUFFERS);
+      surface = new Surface(producer);
+#else
       sp<GonkBufferQueue> bq = mNativeWindow->getBufferQueue();
       bq->setSynchronousMode(false);
       // More spare buffers to avoid OMX decoder waiting for native window
       bq->setMaxAcquiredBufferCount(WEBRTC_OMX_H264_MIN_DECODE_BUFFERS);
       surface = new Surface(bq);
+#endif
     }
     status_t result = mCodec->configure(config, surface, nullptr, 0);
     if (result == OK) {
       CODEC_LOGD("OMX:%p decoder configured", this);
       result = Start();
     }
     return result;
   }