summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MP3Extractor.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-08-25 11:09:41 -0700
committerAndreas Huber <andih@google.com>2010-08-25 13:08:38 -0700
commit5a1c3529e4fa2f8a11054181294e0ce79fff8dd3 (patch)
tree06386bceb568bf27c3fff03139ac0745ec1c4eba /media/libstagefright/MP3Extractor.cpp
parentfce49325d807c278229a594c1cc866e21da0e155 (diff)
downloadframeworks_av-5a1c3529e4fa2f8a11054181294e0ce79fff8dd3.zip
frameworks_av-5a1c3529e4fa2f8a11054181294e0ce79fff8dd3.tar.gz
frameworks_av-5a1c3529e4fa2f8a11054181294e0ce79fff8dd3.tar.bz2
Allow sniffers to return a packet of opaque data that the corresponding extractor can take advantage of to not duplicate work already done sniffing. The mp3 extractor takes advantage of this now.
Change-Id: Icb77ae3ee95a69c7da25b4d3b8696c0a2d33028a related-to-bug: 2948754
Diffstat (limited to 'media/libstagefright/MP3Extractor.cpp')
-rw-r--r--media/libstagefright/MP3Extractor.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 4058fbc..2e36968 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -22,6 +22,7 @@
#include "include/ID3.h"
+#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaBufferGroup.h>
@@ -456,15 +457,31 @@ private:
MP3Source &operator=(const MP3Source &);
};
-MP3Extractor::MP3Extractor(const sp<DataSource> &source)
+MP3Extractor::MP3Extractor(
+ const sp<DataSource> &source, const sp<AMessage> &meta)
: mDataSource(source),
mFirstFramePos(-1),
mFixedHeader(0),
mByteNumber(0) {
off_t pos = 0;
uint32_t header;
- bool success = Resync(mDataSource, 0, &pos, &header);
- CHECK(success);
+ bool success;
+
+ int64_t meta_offset;
+ uint32_t meta_header;
+ if (meta != NULL
+ && meta->findInt64("offset", &meta_offset)
+ && meta->findInt32("header", (int32_t *)&meta_header)) {
+ // The sniffer has already done all the hard work for us, simply
+ // accept its judgement.
+ pos = (off_t)meta_offset;
+ header = meta_header;
+
+ success = true;
+ } else {
+ success = Resync(mDataSource, 0, &pos, &header);
+ CHECK(success);
+ }
if (success) {
mFirstFramePos = pos;
@@ -759,15 +776,20 @@ sp<MetaData> MP3Extractor::getMetaData() {
}
bool SniffMP3(
- const sp<DataSource> &source, String8 *mimeType, float *confidence) {
+ const sp<DataSource> &source, String8 *mimeType,
+ float *confidence, sp<AMessage> *meta) {
off_t pos = 0;
uint32_t header;
if (!Resync(source, 0, &pos, &header)) {
return false;
}
+ *meta = new AMessage;
+ (*meta)->setInt64("offset", pos);
+ (*meta)->setInt32("header", header);
+
*mimeType = MEDIA_MIMETYPE_AUDIO_MPEG;
- *confidence = 0.3f;
+ *confidence = 0.2f;
return true;
}