diff options
Diffstat (limited to 'media/libavextensions/mediaplayerservice/AVNuUtils.cpp')
-rw-r--r-- | media/libavextensions/mediaplayerservice/AVNuUtils.cpp | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp index aacf76a..20149b3 100644 --- a/media/libavextensions/mediaplayerservice/AVNuUtils.cpp +++ b/media/libavextensions/mediaplayerservice/AVNuUtils.cpp @@ -33,6 +33,8 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> +#include <media/stagefright/MediaDefs.h> + #include <nuplayer/NuPlayer.h> #include <nuplayer/NuPlayerDecoderBase.h> #include <nuplayer/NuPlayerDecoderPassThrough.h> @@ -52,12 +54,29 @@ bool AVNuUtils::pcmOffloadException(const sp<MetaData> &) { return true; } -bool AVNuUtils::isRAWFormat(const sp<MetaData> &) { - return false; +bool AVNuUtils::isRAWFormat(const sp<MetaData> &meta) { + const char *mime = {0}; + if (meta == NULL) { + return false; + } + CHECK(meta->findCString(kKeyMIMEType, &mime)); + if (!strncasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW, 9)) + return true; + else + return false; } -bool AVNuUtils::isRAWFormat(const sp<AMessage> &) { - return false; +bool AVNuUtils::isRAWFormat(const sp<AMessage> &format) { + AString mime; + if (format == NULL) { + return false; + } + CHECK(format->findString("mime", &mime)); + if (!strncasecmp(mime.c_str(), MEDIA_MIMETYPE_AUDIO_RAW, 9)) + return true; + else + return false; + } bool AVNuUtils::isVorbisFormat(const sp<MetaData> &) { @@ -69,20 +88,39 @@ int AVNuUtils::updateAudioBitWidth(audio_format_t /*audioFormat*/, return 16; } -audio_format_t AVNuUtils::getKeyPCMFormat(const sp<MetaData> &) { - return AUDIO_FORMAT_INVALID; -} +audio_format_t AVNuUtils::getKeyPCMFormat(const sp<MetaData> &meta) { + int32_t pcmFormat = 0; + if (meta->findInt32('pfmt', &pcmFormat)) + return (audio_format_t)pcmFormat; -void AVNuUtils::setKeyPCMFormat(const sp<MetaData> &, audio_format_t /*audioFormat*/) { + return AUDIO_FORMAT_PCM_16_BIT; +} +void AVNuUtils::setKeyPCMFormat(const sp<MetaData> &meta, audio_format_t audioFormat) { + if (audio_is_linear_pcm(audioFormat)) + meta->setInt32('pfmt', audioFormat); } -audio_format_t AVNuUtils::getPCMFormat(const sp<AMessage> &) { +audio_format_t AVNuUtils::getPCMFormat(const sp<AMessage> &format) { + int32_t pcmFormat = 0; + if (format->findInt32("pcm-format", &pcmFormat)) + return (audio_format_t)pcmFormat; + + int32_t bits = 16; + if (format->findInt32("bit-width", &bits)) { + if (bits == 8) + return AUDIO_FORMAT_PCM_8_BIT; + if (bits == 24) + return AUDIO_FORMAT_PCM_32_BIT; + if (bits == 32) + return AUDIO_FORMAT_PCM_FLOAT; + } return AUDIO_FORMAT_PCM_16_BIT; } -void AVNuUtils::setPCMFormat(const sp<AMessage> &, audio_format_t /*audioFormat*/) { - +void AVNuUtils::setPCMFormat(const sp<AMessage> &format, audio_format_t audioFormat) { + if (audio_is_linear_pcm(audioFormat)) + format->setInt32("pcm-format", audioFormat); } void AVNuUtils::setSourcePCMFormat(const sp<MetaData> &) { |