From c4c38fc1ea06086ea3c7ba12f59ecfacd5fa716b Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 4 Mar 2011 10:24:54 -0800 Subject: [PATCH] Added more metadata published by the MediaMetaDataRetriever - presence of audio/video content - video dimensions - avg. bitrate Change-Id: Ie6d478a3c2d0bb6bebaea99ac0a20a4c17808934 related-to-bug: 3506316 --- api/current.xml | 55 +++++++++++++++++++ include/media/mediametadataretriever.h | 6 ++ .../android/media/MediaMetadataRetriever.java | 20 +++++++ .../StagefrightMetadataRetriever.cpp | 49 +++++++++++++++++ 4 files changed, 130 insertions(+) diff --git a/api/current.xml b/api/current.xml index b48260231af38..0f591b295d623 100644 --- a/api/current.xml +++ b/api/current.xml @@ -105768,6 +105768,17 @@ visibility="public" > + + + + + + + + + + findCString(kKeyMIMEType, &mime)) { + if (!hasAudio && !strncasecmp("audio/", mime, 6)) { + hasAudio = true; + + if (!trackMeta->findInt32(kKeyBitRate, &audioBitrate)) { + audioBitrate = -1; + } + } else if (!hasVideo && !strncasecmp("video/", mime, 6)) { + hasVideo = true; + + CHECK(trackMeta->findInt32(kKeyWidth, &videoWidth)); + CHECK(trackMeta->findInt32(kKeyHeight, &videoHeight)); + } + } } // The duration value is a string representing the duration in ms. sprintf(tmp, "%lld", (maxDurationUs + 500) / 1000); mMetaData.add(METADATA_KEY_DURATION, String8(tmp)); + if (hasAudio) { + mMetaData.add(METADATA_KEY_HAS_AUDIO, String8("yes")); + } + + if (hasVideo) { + mMetaData.add(METADATA_KEY_HAS_VIDEO, String8("yes")); + + sprintf(tmp, "%d", videoWidth); + mMetaData.add(METADATA_KEY_VIDEO_WIDTH, String8(tmp)); + + sprintf(tmp, "%d", videoHeight); + mMetaData.add(METADATA_KEY_VIDEO_HEIGHT, String8(tmp)); + } + + if (numTracks == 1 && hasAudio && audioBitrate >= 0) { + sprintf(tmp, "%ld", audioBitrate); + mMetaData.add(METADATA_KEY_BITRATE, String8(tmp)); + } else { + off64_t sourceSize; + if (mSource->getSize(&sourceSize) == OK) { + int64_t avgBitRate = (int64_t)(sourceSize * 8E6 / maxDurationUs); + + sprintf(tmp, "%lld", avgBitRate); + mMetaData.add(METADATA_KEY_BITRATE, String8(tmp)); + } + } + if (numTracks == 1) { const char *fileMIME; CHECK(meta->findCString(kKeyMIMEType, &fileMIME));