summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/Utils.cpp')
-rw-r--r--media/libstagefright/Utils.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index 17f0201..6e4a1a4 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -35,6 +35,9 @@
#include <media/stagefright/Utils.h>
#include <media/AudioParameter.h>
+#include <stagefright/AVExtensions.h>
+#include <media/stagefright/FFMPEGSoftCodec.h>
+
namespace android {
uint16_t U16_AT(const uint8_t *ptr) {
@@ -104,7 +107,7 @@ status_t convertMetaDataToMessage(
int avgBitRate;
if (meta->findInt32(kKeyBitRate, &avgBitRate)) {
- msg->setInt32("bit-rate", avgBitRate);
+ msg->setInt32("bitrate", avgBitRate);
}
int32_t isSync;
@@ -203,6 +206,11 @@ status_t convertMetaDataToMessage(
msg->setInt32("frame-rate", fps);
}
+ int32_t bitsPerSample;
+ if (meta->findInt32(kKeyBitsPerSample, &bitsPerSample)) {
+ msg->setInt32("bit-width", bitsPerSample);
+ }
+
uint32_t type;
const void *data;
size_t size;
@@ -453,8 +461,15 @@ status_t convertMetaDataToMessage(
msg->setBuffer("csd-2", buffer);
}
+ AVUtils::get()->convertMetaDataToMessage(meta, &msg);
+
+ FFMPEGSoftCodec::convertMetaDataToMessageFF(meta, &msg);
*format = msg;
+ ALOGI("convertMetaDataToMessage from:");
+ meta->dumpToLog();
+ ALOGI(" to: %s", msg->debugString(0).c_str());
+
return OK;
}
@@ -646,6 +661,11 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
if (msg->findInt32("is-adts", &isADTS)) {
meta->setInt32(kKeyIsADTS, isADTS);
}
+
+ int32_t bitsPerSample;
+ if (msg->findInt32("bit-width", &bitsPerSample)) {
+ meta->setInt32(kKeyBitsPerSample, bitsPerSample);
+ }
}
int32_t maxInputSize;
@@ -685,6 +705,8 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
// for transporting the CSD to muxers.
reassembleESDS(csd0, esds);
meta->setData(kKeyESDS, kKeyESDS, esds, sizeof(esds));
+ } else {
+ AVUtils::get()->HEVCMuxerUtils().reassembleHEVCCSD(mime, csd0, meta);
}
}
@@ -695,10 +717,10 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
// XXX TODO add whatever other keys there are
-#if 0
- ALOGI("converted %s to:", msg->debugString(0).c_str());
+ FFMPEGSoftCodec::convertMessageToMetaDataFF(msg, meta);
+
+ ALOGI("convertMessageToMetaData from %s to:", msg->debugString(0).c_str());
meta->dumpToLog();
-#endif
}
AString MakeUserAgent() {
@@ -744,6 +766,7 @@ status_t sendMetaDataToHal(sp<MediaPlayerBase::AudioSink>& sink,
param.addInt(String8(AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES), paddingSamples);
}
+ AVUtils::get()->sendMetaDataToHal(meta, &param);
ALOGV("sendMetaDataToHal: bitRate %d, sampleRate %d, chanMask %d,"
"delaySample %d, paddingSample %d", bitRate, sampleRate,
channelMask, delaySamples, paddingSamples);
@@ -779,7 +802,7 @@ const struct mime_conv_t* p = &mimeLookup[0];
++p;
}
- return BAD_VALUE;
+ return AVUtils::get()->mapMimeToAudioFormat(format, mime);
}
struct aac_format_conv_t {
@@ -833,18 +856,28 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo,
} else {
ALOGV("Mime type \"%s\" mapped to audio_format %d", mime, info.format);
}
-
+ info.format = AVUtils::get()->updateAudioFormat(info.format, meta);
if (AUDIO_FORMAT_INVALID == info.format) {
// can't offload if we don't know what the source format is
ALOGE("mime type \"%s\" not a known audio format", mime);
return false;
}
+ if (AVUtils::get()->canOffloadAPE(meta) != true) {
+ return false;
+ }
+ ALOGV("Mime type \"%s\" mapped to audio_format %d", mime, info.format);
+
// Redefine aac format according to its profile
// Offloading depends on audio DSP capabilities.
int32_t aacaot = -1;
if (meta->findInt32(kKeyAACAOT, &aacaot)) {
- mapAACProfileToAudioFormat(info.format,(OMX_AUDIO_AACPROFILETYPE) aacaot);
+ bool isADTSSupported = false;
+ isADTSSupported = AVUtils::get()->mapAACProfileToAudioFormat(meta, info.format,
+ (OMX_AUDIO_AACPROFILETYPE) aacaot);
+ if (!isADTSSupported) {
+ mapAACProfileToAudioFormat(info.format,(OMX_AUDIO_AACPROFILETYPE) aacaot);
+ }
}
int32_t srate = -1;