Bug 803471 - Part 4 - Use OmxClient in GonkRecorder. r=mhabicher
authorSotaro Ikeda <sikeda@mozilla.com>
Fri, 08 Mar 2013 14:43:32 -0500
changeset 124260 bc9d903311b72989395e7e8fef44c6d68de880d2
parent 124259 8a29e43d47af22637e254c45633e6c53c4367dfc
child 124261 1e45de4653f32a752b8806a862967bd2e21a664b
push id24316
push userryanvm@gmail.com
push dateFri, 08 Mar 2013 19:43:05 +0000
treeherdermozilla-inbound@a19b312bd4f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhabicher
bugs803471
milestone22.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 803471 - Part 4 - Use OmxClient in GonkRecorder. r=mhabicher
dom/camera/GonkRecorder.cpp
--- a/dom/camera/GonkRecorder.cpp
+++ b/dom/camera/GonkRecorder.cpp
@@ -24,17 +24,17 @@
 
 #include <media/stagefright/AudioSource.h>
 #include <media/stagefright/AMRWriter.h>
 #include <media/stagefright/MPEG2TSWriter.h>
 #include <media/stagefright/MPEG4Writer.h>
 #include <media/stagefright/MediaDebug.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MetaData.h>
-#include <OMX.h>
+#include <media/stagefright/OMXClient.h>
 #include <media/stagefright/OMXCodec.h>
 #include <media/MediaProfiles.h>
 #include <utils/String8.h>
 
 #include <utils/Errors.h>
 #include <sys/types.h>
 #include <ctype.h>
 #include <unistd.h>
@@ -43,24 +43,16 @@
 
 #include "ARTPWriter.h"
 
 #include <cutils/properties.h>
 #include "GonkCameraSource.h"
 
 namespace android {
 
-static sp<IOMX> sOMX = NULL;
-static sp<IOMX> GetOMX() {
-  if(sOMX.get() == NULL) {
-    sOMX = new OMX;
-    }
-  return sOMX;
-}
-
 GonkRecorder::GonkRecorder()
     : mWriter(NULL),
       mOutputFd(-1),
       mAudioSource(AUDIO_SOURCE_CNT),
       mVideoSource(VIDEO_SOURCE_LIST_END),
       mStarted(false),
       mDisableAudio(false) {
 
@@ -760,20 +752,24 @@ sp<MediaSource> GonkRecorder::createAudi
     encMeta->setInt32(kKeyMaxInputSize, maxInputSize);
     encMeta->setInt32(kKeyChannelCount, mAudioChannels);
     encMeta->setInt32(kKeySampleRate, mSampleRate);
     encMeta->setInt32(kKeyBitRate, mAudioBitRate);
     if (mAudioTimeScale > 0) {
         encMeta->setInt32(kKeyTimeScale, mAudioTimeScale);
     }
 
-    // use direct OMX interface instead of connecting to
-    // mediaserver over binder calls
+    // OMXClient::connect() always returns OK and abort's fatally if
+    // it can't connect.
+    OMXClient client;
+    // CHECK_EQ causes an abort if the given condition fails.
+    CHECK_EQ(client.connect(), OK);
+
     sp<MediaSource> audioEncoder =
-        OMXCodec::Create(GetOMX(), encMeta,
+        OMXCodec::Create(client.interface(), encMeta,
                          true /* createEncoder */, audioSource);
     mAudioSourceNode = audioSource;
 
     return audioEncoder;
 }
 
 status_t GonkRecorder::startAMRRecording() {
     CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB ||
@@ -1268,19 +1264,24 @@ status_t GonkRecorder::setupVideoEncoder
     uint32_t encoder_flags = 0;
     if (mIsMetaDataStoredInVideoBuffers) {
         LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
         encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
     }
 
+    // OMXClient::connect() always returns OK and abort's fatally if
+    // it can't connect.
+    OMXClient client;
+    // CHECK_EQ causes an abort if the given condition fails.
+    CHECK_EQ(client.connect(), OK);
+
     sp<MediaSource> encoder = OMXCodec::Create(
-            GetOMX(),
-            enc_meta,
+            client.interface(), enc_meta,
             true /* createEncoder */, cameraSource,
             NULL, encoder_flags);
     if (encoder == NULL) {
         LOGW("Failed to create the encoder");
         // When the encoder fails to be created, we need
         // release the camera source due to the camera's lock
         // and unlock mechanism.
         cameraSource->stop();