Bug 1229360 - Support MP3 audio in OpenMAX PDM. r=alfredo
authorJohn Lin <jolin@mozilla.com>
Fri, 19 Feb 2016 15:57:24 +0800
changeset 321866 e6b2fb0874ab18c7df9c29cc27298ec5503d2d47
parent 321865 9a5f5c32373ce74b29655192a61f7c8fe5523c14
child 321867 12e56cb35dc57123fb43bc38a44e09207cd68414
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalfredo
bugs1229360
milestone47.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 1229360 - Support MP3 audio in OpenMAX PDM. r=alfredo MozReview-Commit-ID: HUp8Z5KQ8ua
dom/media/platforms/omx/OmxPlatformLayer.cpp
--- a/dom/media/platforms/omx/OmxPlatformLayer.cpp
+++ b/dom/media/platforms/omx/OmxPlatformLayer.cpp
@@ -102,25 +102,53 @@ public:
 
     LOG("Config OMX_IndexParamAudioAac, channel %d, sample rate %d, profile %d",
         aacProfile.nChannels, aacProfile.nSampleRate, aacProfile.eAACProfile);
 
     return ConfigAudioOutputPort(aOmx, aInfo);
   }
 };
 
+class OmxMp3Config : public OmxAudioConfig
+{
+public:
+  OMX_ERRORTYPE Apply(OmxPlatformLayer& aOmx, const AudioInfo& aInfo) override
+  {
+    OMX_ERRORTYPE err;
+
+    OMX_AUDIO_PARAM_MP3TYPE mp3Param;
+    InitOmxParameter(&mp3Param);
+    mp3Param.nPortIndex = aOmx.InputPortIndex();
+    err = aOmx.GetParameter(OMX_IndexParamAudioMp3, &mp3Param, sizeof(mp3Param));
+    RETURN_IF_ERR(err);
+
+    mp3Param.nChannels = aInfo.mChannels;
+    mp3Param.nSampleRate = aInfo.mRate;
+    err = aOmx.SetParameter(OMX_IndexParamAudioMp3, &mp3Param, sizeof(mp3Param));
+    RETURN_IF_ERR(err);
+
+    LOG("Config OMX_IndexParamAudioMp3, channel %d, sample rate %d",
+        mp3Param.nChannels, mp3Param.nSampleRate);
+
+    return ConfigAudioOutputPort(aOmx, aInfo);
+  }
+};
+
 template<>
 UniquePtr<OmxAudioConfig>
 ConfigForMime(const nsACString& aMimeType)
 {
   UniquePtr<OmxAudioConfig> conf;
 
   if (OmxPlatformLayer::SupportsMimeType(aMimeType)) {
     if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
       conf.reset(new OmxAacConfig());
+    } else if (aMimeType.EqualsLiteral("audio/mp3") ||
+                aMimeType.EqualsLiteral("audio/mpeg")) {
+      conf.reset(new OmxMp3Config());
     }
   }
   return Move(conf);
 }
 
 // There should be a better way to calculate it.
 #define MIN_VIDEO_INPUT_BUFFER_SIZE 64 * 1024