Loading media/extractors/flac/FLACExtractor.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -366,7 +366,6 @@ void FLACParser::metadataCallback(const FLAC__StreamMetadata *metadata) const FLAC__StreamMetadata_Picture *p = &metadata->data.picture; const FLAC__StreamMetadata_Picture *p = &metadata->data.picture; mFileMetadata->setData(kKeyAlbumArt, mFileMetadata->setData(kKeyAlbumArt, MetaData::TYPE_NONE, p->data, p->data_length); MetaData::TYPE_NONE, p->data, p->data_length); mFileMetadata->setCString(kKeyAlbumArtMIME, p->mime_type); } } break; break; default: default: Loading media/extractors/mp3/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -13,6 +13,7 @@ cc_library_shared { shared_libs: [ shared_libs: [ "liblog", "liblog", "libmediaextractor", "libmediaextractor", "libmediandk", "libstagefright_foundation", "libstagefright_foundation", ], ], Loading media/extractors/mp3/MP3Extractor.cpp +68 −66 Original line number Original line Diff line number Diff line Loading @@ -207,19 +207,19 @@ static bool Resync( return valid; return valid; } } class MP3Source : public MediaTrackHelper { class MP3Source : public MediaTrackHelperV2 { public: public: MP3Source( MP3Source( MetaDataBase &meta, DataSourceHelper *source, AMediaFormat *meta, DataSourceHelper *source, off64_t first_frame_pos, uint32_t fixed_header, off64_t first_frame_pos, uint32_t fixed_header, MP3Seeker *seeker); MP3Seeker *seeker); virtual status_t start(); virtual media_status_t start(); virtual status_t stop(); virtual media_status_t stop(); virtual status_t getFormat(MetaDataBase &meta); virtual media_status_t getFormat(AMediaFormat *meta); virtual status_t read( virtual media_status_t read( MediaBufferBase **buffer, const ReadOptions *options = NULL); MediaBufferBase **buffer, const ReadOptions *options = NULL); protected: protected: Loading @@ -227,7 +227,7 @@ protected: private: private: static const size_t kMaxFrameSize; static const size_t kMaxFrameSize; MetaDataBase &mMeta; AMediaFormat *mMeta; DataSourceHelper *mDataSource; DataSourceHelper *mDataSource; off64_t mFirstFramePos; off64_t mFirstFramePos; uint32_t mFixedHeader; uint32_t mFixedHeader; Loading Loading @@ -283,6 +283,7 @@ MP3Extractor::MP3Extractor( mFixedHeader = header; mFixedHeader = header; XINGSeeker *seeker = XINGSeeker::CreateFromSource(mDataSource, mFirstFramePos); XINGSeeker *seeker = XINGSeeker::CreateFromSource(mDataSource, mFirstFramePos); mMeta = AMediaFormat_new(); if (seeker == NULL) { if (seeker == NULL) { mSeeker = VBRISeeker::CreateFromSource(mDataSource, post_id3_pos); mSeeker = VBRISeeker::CreateFromSource(mDataSource, post_id3_pos); } else { } else { Loading @@ -290,8 +291,8 @@ MP3Extractor::MP3Extractor( int encd = seeker->getEncoderDelay(); int encd = seeker->getEncoderDelay(); int encp = seeker->getEncoderPadding(); int encp = seeker->getEncoderPadding(); if (encd != 0 || encp != 0) { if (encd != 0 || encp != 0) { mMeta.setInt32(kKeyEncoderDelay, encd); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_DELAY, encd); mMeta.setInt32(kKeyEncoderPadding, encp); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_PADDING, encp); } } } } Loading Loading @@ -327,21 +328,23 @@ MP3Extractor::MP3Extractor( switch (layer) { switch (layer) { case 1: case 1: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I); break; break; case 2: case 2: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II); break; break; case 3: case 3: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG); break; break; default: default: TRESPASS(); TRESPASS(); } } mMeta.setInt32(kKeySampleRate, sample_rate); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_SAMPLE_RATE, sample_rate); mMeta.setInt32(kKeyBitRate, bitrate * 1000); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_BIT_RATE, bitrate * 1000); mMeta.setInt32(kKeyChannelCount, num_channels); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_COUNT, num_channels); int64_t durationUs; int64_t durationUs; Loading @@ -361,7 +364,7 @@ MP3Extractor::MP3Extractor( } } if (durationUs >= 0) { if (durationUs >= 0) { mMeta.setInt64(kKeyDuration, durationUs); AMediaFormat_setInt64(mMeta, AMEDIAFORMAT_KEY_DURATION, durationUs); } } mInitCheck = OK; mInitCheck = OK; Loading Loading @@ -389,8 +392,8 @@ MP3Extractor::MP3Extractor( int32_t delay, padding; int32_t delay, padding; if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) { if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) { mMeta.setInt32(kKeyEncoderDelay, delay); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_DELAY, delay); mMeta.setInt32(kKeyEncoderPadding, padding); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_PADDING, padding); } } break; break; } } Loading @@ -404,13 +407,14 @@ MP3Extractor::MP3Extractor( MP3Extractor::~MP3Extractor() { MP3Extractor::~MP3Extractor() { delete mSeeker; delete mSeeker; delete mDataSource; delete mDataSource; AMediaFormat_delete(mMeta); } } size_t MP3Extractor::countTracks() { size_t MP3Extractor::countTracks() { return mInitCheck != OK ? 0 : 1; return mInitCheck != OK ? 0 : 1; } } MediaTrackHelper *MP3Extractor::getTrack(size_t index) { MediaTrackHelperV2 *MP3Extractor::getTrack(size_t index) { if (mInitCheck != OK || index != 0) { if (mInitCheck != OK || index != 0) { return NULL; return NULL; } } Loading @@ -420,14 +424,14 @@ MediaTrackHelper *MP3Extractor::getTrack(size_t index) { mSeeker); mSeeker); } } status_t MP3Extractor::getTrackMetaData( media_status_t MP3Extractor::getTrackMetaData( MetaDataBase &meta, AMediaFormat *meta, size_t index, uint32_t /* flags */) { size_t index, uint32_t /* flags */) { if (mInitCheck != OK || index != 0) { if (mInitCheck != OK || index != 0) { return UNKNOWN_ERROR; return AMEDIA_ERROR_UNKNOWN; } } meta = mMeta; AMediaFormat_copy(meta, mMeta); return OK; return AMEDIA_OK; } } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// Loading @@ -440,7 +444,7 @@ status_t MP3Extractor::getTrackMetaData( // Set our max frame size to the nearest power of 2 above this size (aka, 4kB) // Set our max frame size to the nearest power of 2 above this size (aka, 4kB) const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */ const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */ MP3Source::MP3Source( MP3Source::MP3Source( MetaDataBase &meta, DataSourceHelper *source, AMediaFormat *meta, DataSourceHelper *source, off64_t first_frame_pos, uint32_t fixed_header, off64_t first_frame_pos, uint32_t fixed_header, MP3Seeker *seeker) MP3Seeker *seeker) : mMeta(meta), : mMeta(meta), Loading @@ -462,7 +466,7 @@ MP3Source::~MP3Source() { } } } } status_t MP3Source::start() { media_status_t MP3Source::start() { CHECK(!mStarted); CHECK(!mStarted); mGroup = new MediaBufferGroup; mGroup = new MediaBufferGroup; Loading @@ -477,10 +481,10 @@ status_t MP3Source::start() { mStarted = true; mStarted = true; return OK; return AMEDIA_OK; } } status_t MP3Source::stop() { media_status_t MP3Source::stop() { CHECK(mStarted); CHECK(mStarted); delete mGroup; delete mGroup; Loading @@ -488,15 +492,14 @@ status_t MP3Source::stop() { mStarted = false; mStarted = false; return OK; return AMEDIA_OK; } } status_t MP3Source::getFormat(MetaDataBase &meta) { media_status_t MP3Source::getFormat(AMediaFormat *meta) { meta = mMeta; return AMediaFormat_copy(meta, mMeta); return OK; } } status_t MP3Source::read( media_status_t MP3Source::read( MediaBufferBase **out, const ReadOptions *options) { MediaBufferBase **out, const ReadOptions *options) { *out = NULL; *out = NULL; Loading @@ -509,11 +512,11 @@ status_t MP3Source::read( if (mSeeker == NULL if (mSeeker == NULL || !mSeeker->getOffsetForTime(&actualSeekTimeUs, &mCurrentPos)) { || !mSeeker->getOffsetForTime(&actualSeekTimeUs, &mCurrentPos)) { int32_t bitrate; int32_t bitrate; if (!mMeta.findInt32(kKeyBitRate, &bitrate)) { if (!AMediaFormat_getInt32(mMeta, AMEDIAFORMAT_KEY_BIT_RATE, &bitrate)) { // bitrate is in bits/sec. // bitrate is in bits/sec. ALOGI("no bitrate"); ALOGI("no bitrate"); return ERROR_UNSUPPORTED; return AMEDIA_ERROR_UNSUPPORTED; } } mCurrentTimeUs = seekTimeUs; mCurrentTimeUs = seekTimeUs; Loading @@ -530,7 +533,7 @@ status_t MP3Source::read( MediaBufferBase *buffer; MediaBufferBase *buffer; status_t err = mGroup->acquire_buffer(&buffer); status_t err = mGroup->acquire_buffer(&buffer); if (err != OK) { if (err != OK) { return err; return AMEDIA_ERROR_UNKNOWN; } } size_t frame_size; size_t frame_size; Loading @@ -543,7 +546,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return (n < 0 ? n : ERROR_END_OF_STREAM); return (n < 0 ? AMEDIA_ERROR_UNKNOWN : AMEDIA_ERROR_END_OF_STREAM); } } uint32_t header = U32_AT((const uint8_t *)buffer->data()); uint32_t header = U32_AT((const uint8_t *)buffer->data()); Loading Loading @@ -572,7 +575,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return ERROR_END_OF_STREAM; return AMEDIA_ERROR_END_OF_STREAM; } } mCurrentPos = pos; mCurrentPos = pos; Loading @@ -587,7 +590,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return (n < 0 ? n : ERROR_END_OF_STREAM); return (n < 0 ? AMEDIA_ERROR_UNKNOWN : AMEDIA_ERROR_END_OF_STREAM); } } buffer->set_range(0, frame_size); buffer->set_range(0, frame_size); Loading @@ -602,40 +605,40 @@ status_t MP3Source::read( *out = buffer; *out = buffer; return OK; return AMEDIA_OK; } } status_t MP3Extractor::getMetaData(MetaDataBase &meta) { media_status_t MP3Extractor::getMetaData(AMediaFormat *meta) { meta.clear(); AMediaFormat_clear(meta); if (mInitCheck != OK) { if (mInitCheck != OK) { return UNKNOWN_ERROR; return AMEDIA_ERROR_UNKNOWN; } } meta.setCString(kKeyMIMEType, "audio/mpeg"); AMediaFormat_setString(meta, AMEDIAFORMAT_KEY_MIME, "audio/mpeg"); DataSourceHelper helper(mDataSource); DataSourceHelper helper(mDataSource); ID3 id3(&helper); ID3 id3(&helper); if (!id3.isValid()) { if (!id3.isValid()) { return OK; return AMEDIA_OK; } } struct Map { struct Map { int key; const char *key; const char *tag1; const char *tag1; const char *tag2; const char *tag2; }; }; static const Map kMap[] = { static const Map kMap[] = { { kKeyAlbum, "TALB", "TAL" }, { AMEDIAFORMAT_KEY_ALBUM, "TALB", "TAL" }, { kKeyArtist, "TPE1", "TP1" }, { AMEDIAFORMAT_KEY_ARTIST, "TPE1", "TP1" }, { kKeyAlbumArtist, "TPE2", "TP2" }, { AMEDIAFORMAT_KEY_ALBUMARTIST, "TPE2", "TP2" }, { kKeyComposer, "TCOM", "TCM" }, { AMEDIAFORMAT_KEY_COMPOSER, "TCOM", "TCM" }, { kKeyGenre, "TCON", "TCO" }, { AMEDIAFORMAT_KEY_GENRE, "TCON", "TCO" }, { kKeyTitle, "TIT2", "TT2" }, { AMEDIAFORMAT_KEY_TITLE, "TIT2", "TT2" }, { kKeyYear, "TYE", "TYER" }, { AMEDIAFORMAT_KEY_YEAR, "TYE", "TYER" }, { kKeyAuthor, "TXT", "TEXT" }, { AMEDIAFORMAT_KEY_AUTHOR, "TXT", "TEXT" }, { kKeyCDTrackNumber, "TRK", "TRCK" }, { AMEDIAFORMAT_KEY_CDTRACKNUMBER, "TRK", "TRCK" }, { kKeyDiscNumber, "TPA", "TPOS" }, { AMEDIAFORMAT_KEY_DISCNUMBER, "TPA", "TPOS" }, { kKeyCompilation, "TCP", "TCMP" }, { AMEDIAFORMAT_KEY_COMPILATION, "TCP", "TCMP" }, }; }; static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); Loading @@ -655,7 +658,7 @@ status_t MP3Extractor::getMetaData(MetaDataBase &meta) { it->getString(&s); it->getString(&s); delete it; delete it; meta.setCString(kMap[i].key, s); AMediaFormat_setString(meta, kMap[i].key, s.string()); } } size_t dataSize; size_t dataSize; Loading @@ -663,21 +666,20 @@ status_t MP3Extractor::getMetaData(MetaDataBase &meta) { const void *data = id3.getAlbumArt(&dataSize, &mime); const void *data = id3.getAlbumArt(&dataSize, &mime); if (data) { if (data) { meta.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); AMediaFormat_setBuffer(meta, AMEDIAFORMAT_KEY_ALBUMART, data, dataSize); meta.setCString(kKeyAlbumArtMIME, mime.string()); } } return OK; return AMEDIA_OK; } } static CMediaExtractor* CreateExtractor( static CMediaExtractorV2* CreateExtractor( CDataSource *source, CDataSource *source, void *meta) { void *meta) { Mp3Meta *metaData = static_cast<Mp3Meta *>(meta); Mp3Meta *metaData = static_cast<Mp3Meta *>(meta); return wrap(new MP3Extractor(new DataSourceHelper(source), metaData)); return wrapV2(new MP3Extractor(new DataSourceHelper(source), metaData)); } } static CreatorFunc Sniff( static CreatorFuncV2 Sniff( CDataSource *source, float *confidence, void **meta, CDataSource *source, float *confidence, void **meta, FreeMetaFunc *freeMeta) { FreeMetaFunc *freeMeta) { off64_t pos = 0; off64_t pos = 0; Loading Loading @@ -714,11 +716,11 @@ extern "C" { __attribute__ ((visibility ("default"))) __attribute__ ((visibility ("default"))) ExtractorDef GETEXTRACTORDEF() { ExtractorDef GETEXTRACTORDEF() { return { return { EXTRACTORDEF_VERSION, EXTRACTORDEF_VERSION_CURRENT, UUID("812a3f6c-c8cf-46de-b529-3774b14103d4"), UUID("812a3f6c-c8cf-46de-b529-3774b14103d4"), 1, // version 1, // version "MP3 Extractor", "MP3 Extractor", { Sniff } { .v2 = Sniff } }; }; } } Loading media/extractors/mp3/MP3Extractor.h +6 −6 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ #include <utils/Errors.h> #include <utils/Errors.h> #include <media/MediaExtractorPluginApi.h> #include <media/MediaExtractorPluginApi.h> #include <media/MediaExtractorPluginHelper.h> #include <media/MediaExtractorPluginHelper.h> #include <media/stagefright/MetaDataBase.h> #include <media/NdkMediaFormat.h> namespace android { namespace android { Loading @@ -32,16 +32,16 @@ struct MP3Seeker; class String8; class String8; struct Mp3Meta; struct Mp3Meta; class MP3Extractor : public MediaExtractorPluginHelper { class MP3Extractor : public MediaExtractorPluginHelperV2 { public: public: MP3Extractor(DataSourceHelper *source, Mp3Meta *meta); MP3Extractor(DataSourceHelper *source, Mp3Meta *meta); ~MP3Extractor(); ~MP3Extractor(); virtual size_t countTracks(); virtual size_t countTracks(); virtual MediaTrackHelper *getTrack(size_t index); virtual MediaTrackHelperV2 *getTrack(size_t index); virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags); virtual media_status_t getTrackMetaData(AMediaFormat *meta, size_t index, uint32_t flags); virtual status_t getMetaData(MetaDataBase& meta); virtual media_status_t getMetaData(AMediaFormat *meta); virtual const char * name() { return "MP3Extractor"; } virtual const char * name() { return "MP3Extractor"; } private: private: Loading @@ -49,7 +49,7 @@ private: DataSourceHelper *mDataSource; DataSourceHelper *mDataSource; off64_t mFirstFramePos; off64_t mFirstFramePos; MetaDataBase mMeta; AMediaFormat *mMeta; uint32_t mFixedHeader; uint32_t mFixedHeader; MP3Seeker *mSeeker; MP3Seeker *mSeeker; Loading media/extractors/mp4/MPEG4Extractor.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -3608,7 +3608,6 @@ void MPEG4Extractor::parseID3v2MetaData(off64_t offset) { if (data) { if (data) { mFileMetaData.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); mFileMetaData.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); mFileMetaData.setCString(kKeyAlbumArtMIME, mime.string()); } } } } } } Loading Loading
media/extractors/flac/FLACExtractor.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -366,7 +366,6 @@ void FLACParser::metadataCallback(const FLAC__StreamMetadata *metadata) const FLAC__StreamMetadata_Picture *p = &metadata->data.picture; const FLAC__StreamMetadata_Picture *p = &metadata->data.picture; mFileMetadata->setData(kKeyAlbumArt, mFileMetadata->setData(kKeyAlbumArt, MetaData::TYPE_NONE, p->data, p->data_length); MetaData::TYPE_NONE, p->data, p->data_length); mFileMetadata->setCString(kKeyAlbumArtMIME, p->mime_type); } } break; break; default: default: Loading
media/extractors/mp3/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -13,6 +13,7 @@ cc_library_shared { shared_libs: [ shared_libs: [ "liblog", "liblog", "libmediaextractor", "libmediaextractor", "libmediandk", "libstagefright_foundation", "libstagefright_foundation", ], ], Loading
media/extractors/mp3/MP3Extractor.cpp +68 −66 Original line number Original line Diff line number Diff line Loading @@ -207,19 +207,19 @@ static bool Resync( return valid; return valid; } } class MP3Source : public MediaTrackHelper { class MP3Source : public MediaTrackHelperV2 { public: public: MP3Source( MP3Source( MetaDataBase &meta, DataSourceHelper *source, AMediaFormat *meta, DataSourceHelper *source, off64_t first_frame_pos, uint32_t fixed_header, off64_t first_frame_pos, uint32_t fixed_header, MP3Seeker *seeker); MP3Seeker *seeker); virtual status_t start(); virtual media_status_t start(); virtual status_t stop(); virtual media_status_t stop(); virtual status_t getFormat(MetaDataBase &meta); virtual media_status_t getFormat(AMediaFormat *meta); virtual status_t read( virtual media_status_t read( MediaBufferBase **buffer, const ReadOptions *options = NULL); MediaBufferBase **buffer, const ReadOptions *options = NULL); protected: protected: Loading @@ -227,7 +227,7 @@ protected: private: private: static const size_t kMaxFrameSize; static const size_t kMaxFrameSize; MetaDataBase &mMeta; AMediaFormat *mMeta; DataSourceHelper *mDataSource; DataSourceHelper *mDataSource; off64_t mFirstFramePos; off64_t mFirstFramePos; uint32_t mFixedHeader; uint32_t mFixedHeader; Loading Loading @@ -283,6 +283,7 @@ MP3Extractor::MP3Extractor( mFixedHeader = header; mFixedHeader = header; XINGSeeker *seeker = XINGSeeker::CreateFromSource(mDataSource, mFirstFramePos); XINGSeeker *seeker = XINGSeeker::CreateFromSource(mDataSource, mFirstFramePos); mMeta = AMediaFormat_new(); if (seeker == NULL) { if (seeker == NULL) { mSeeker = VBRISeeker::CreateFromSource(mDataSource, post_id3_pos); mSeeker = VBRISeeker::CreateFromSource(mDataSource, post_id3_pos); } else { } else { Loading @@ -290,8 +291,8 @@ MP3Extractor::MP3Extractor( int encd = seeker->getEncoderDelay(); int encd = seeker->getEncoderDelay(); int encp = seeker->getEncoderPadding(); int encp = seeker->getEncoderPadding(); if (encd != 0 || encp != 0) { if (encd != 0 || encp != 0) { mMeta.setInt32(kKeyEncoderDelay, encd); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_DELAY, encd); mMeta.setInt32(kKeyEncoderPadding, encp); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_PADDING, encp); } } } } Loading Loading @@ -327,21 +328,23 @@ MP3Extractor::MP3Extractor( switch (layer) { switch (layer) { case 1: case 1: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I); break; break; case 2: case 2: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II); break; break; case 3: case 3: mMeta.setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG); AMediaFormat_setString(mMeta, AMEDIAFORMAT_KEY_MIME, MEDIA_MIMETYPE_AUDIO_MPEG); break; break; default: default: TRESPASS(); TRESPASS(); } } mMeta.setInt32(kKeySampleRate, sample_rate); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_SAMPLE_RATE, sample_rate); mMeta.setInt32(kKeyBitRate, bitrate * 1000); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_BIT_RATE, bitrate * 1000); mMeta.setInt32(kKeyChannelCount, num_channels); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_COUNT, num_channels); int64_t durationUs; int64_t durationUs; Loading @@ -361,7 +364,7 @@ MP3Extractor::MP3Extractor( } } if (durationUs >= 0) { if (durationUs >= 0) { mMeta.setInt64(kKeyDuration, durationUs); AMediaFormat_setInt64(mMeta, AMEDIAFORMAT_KEY_DURATION, durationUs); } } mInitCheck = OK; mInitCheck = OK; Loading Loading @@ -389,8 +392,8 @@ MP3Extractor::MP3Extractor( int32_t delay, padding; int32_t delay, padding; if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) { if (sscanf(value, " %*x %x %x %*x", &delay, &padding) == 2) { mMeta.setInt32(kKeyEncoderDelay, delay); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_DELAY, delay); mMeta.setInt32(kKeyEncoderPadding, padding); AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_ENCODER_PADDING, padding); } } break; break; } } Loading @@ -404,13 +407,14 @@ MP3Extractor::MP3Extractor( MP3Extractor::~MP3Extractor() { MP3Extractor::~MP3Extractor() { delete mSeeker; delete mSeeker; delete mDataSource; delete mDataSource; AMediaFormat_delete(mMeta); } } size_t MP3Extractor::countTracks() { size_t MP3Extractor::countTracks() { return mInitCheck != OK ? 0 : 1; return mInitCheck != OK ? 0 : 1; } } MediaTrackHelper *MP3Extractor::getTrack(size_t index) { MediaTrackHelperV2 *MP3Extractor::getTrack(size_t index) { if (mInitCheck != OK || index != 0) { if (mInitCheck != OK || index != 0) { return NULL; return NULL; } } Loading @@ -420,14 +424,14 @@ MediaTrackHelper *MP3Extractor::getTrack(size_t index) { mSeeker); mSeeker); } } status_t MP3Extractor::getTrackMetaData( media_status_t MP3Extractor::getTrackMetaData( MetaDataBase &meta, AMediaFormat *meta, size_t index, uint32_t /* flags */) { size_t index, uint32_t /* flags */) { if (mInitCheck != OK || index != 0) { if (mInitCheck != OK || index != 0) { return UNKNOWN_ERROR; return AMEDIA_ERROR_UNKNOWN; } } meta = mMeta; AMediaFormat_copy(meta, mMeta); return OK; return AMEDIA_OK; } } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// Loading @@ -440,7 +444,7 @@ status_t MP3Extractor::getTrackMetaData( // Set our max frame size to the nearest power of 2 above this size (aka, 4kB) // Set our max frame size to the nearest power of 2 above this size (aka, 4kB) const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */ const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */ MP3Source::MP3Source( MP3Source::MP3Source( MetaDataBase &meta, DataSourceHelper *source, AMediaFormat *meta, DataSourceHelper *source, off64_t first_frame_pos, uint32_t fixed_header, off64_t first_frame_pos, uint32_t fixed_header, MP3Seeker *seeker) MP3Seeker *seeker) : mMeta(meta), : mMeta(meta), Loading @@ -462,7 +466,7 @@ MP3Source::~MP3Source() { } } } } status_t MP3Source::start() { media_status_t MP3Source::start() { CHECK(!mStarted); CHECK(!mStarted); mGroup = new MediaBufferGroup; mGroup = new MediaBufferGroup; Loading @@ -477,10 +481,10 @@ status_t MP3Source::start() { mStarted = true; mStarted = true; return OK; return AMEDIA_OK; } } status_t MP3Source::stop() { media_status_t MP3Source::stop() { CHECK(mStarted); CHECK(mStarted); delete mGroup; delete mGroup; Loading @@ -488,15 +492,14 @@ status_t MP3Source::stop() { mStarted = false; mStarted = false; return OK; return AMEDIA_OK; } } status_t MP3Source::getFormat(MetaDataBase &meta) { media_status_t MP3Source::getFormat(AMediaFormat *meta) { meta = mMeta; return AMediaFormat_copy(meta, mMeta); return OK; } } status_t MP3Source::read( media_status_t MP3Source::read( MediaBufferBase **out, const ReadOptions *options) { MediaBufferBase **out, const ReadOptions *options) { *out = NULL; *out = NULL; Loading @@ -509,11 +512,11 @@ status_t MP3Source::read( if (mSeeker == NULL if (mSeeker == NULL || !mSeeker->getOffsetForTime(&actualSeekTimeUs, &mCurrentPos)) { || !mSeeker->getOffsetForTime(&actualSeekTimeUs, &mCurrentPos)) { int32_t bitrate; int32_t bitrate; if (!mMeta.findInt32(kKeyBitRate, &bitrate)) { if (!AMediaFormat_getInt32(mMeta, AMEDIAFORMAT_KEY_BIT_RATE, &bitrate)) { // bitrate is in bits/sec. // bitrate is in bits/sec. ALOGI("no bitrate"); ALOGI("no bitrate"); return ERROR_UNSUPPORTED; return AMEDIA_ERROR_UNSUPPORTED; } } mCurrentTimeUs = seekTimeUs; mCurrentTimeUs = seekTimeUs; Loading @@ -530,7 +533,7 @@ status_t MP3Source::read( MediaBufferBase *buffer; MediaBufferBase *buffer; status_t err = mGroup->acquire_buffer(&buffer); status_t err = mGroup->acquire_buffer(&buffer); if (err != OK) { if (err != OK) { return err; return AMEDIA_ERROR_UNKNOWN; } } size_t frame_size; size_t frame_size; Loading @@ -543,7 +546,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return (n < 0 ? n : ERROR_END_OF_STREAM); return (n < 0 ? AMEDIA_ERROR_UNKNOWN : AMEDIA_ERROR_END_OF_STREAM); } } uint32_t header = U32_AT((const uint8_t *)buffer->data()); uint32_t header = U32_AT((const uint8_t *)buffer->data()); Loading Loading @@ -572,7 +575,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return ERROR_END_OF_STREAM; return AMEDIA_ERROR_END_OF_STREAM; } } mCurrentPos = pos; mCurrentPos = pos; Loading @@ -587,7 +590,7 @@ status_t MP3Source::read( buffer->release(); buffer->release(); buffer = NULL; buffer = NULL; return (n < 0 ? n : ERROR_END_OF_STREAM); return (n < 0 ? AMEDIA_ERROR_UNKNOWN : AMEDIA_ERROR_END_OF_STREAM); } } buffer->set_range(0, frame_size); buffer->set_range(0, frame_size); Loading @@ -602,40 +605,40 @@ status_t MP3Source::read( *out = buffer; *out = buffer; return OK; return AMEDIA_OK; } } status_t MP3Extractor::getMetaData(MetaDataBase &meta) { media_status_t MP3Extractor::getMetaData(AMediaFormat *meta) { meta.clear(); AMediaFormat_clear(meta); if (mInitCheck != OK) { if (mInitCheck != OK) { return UNKNOWN_ERROR; return AMEDIA_ERROR_UNKNOWN; } } meta.setCString(kKeyMIMEType, "audio/mpeg"); AMediaFormat_setString(meta, AMEDIAFORMAT_KEY_MIME, "audio/mpeg"); DataSourceHelper helper(mDataSource); DataSourceHelper helper(mDataSource); ID3 id3(&helper); ID3 id3(&helper); if (!id3.isValid()) { if (!id3.isValid()) { return OK; return AMEDIA_OK; } } struct Map { struct Map { int key; const char *key; const char *tag1; const char *tag1; const char *tag2; const char *tag2; }; }; static const Map kMap[] = { static const Map kMap[] = { { kKeyAlbum, "TALB", "TAL" }, { AMEDIAFORMAT_KEY_ALBUM, "TALB", "TAL" }, { kKeyArtist, "TPE1", "TP1" }, { AMEDIAFORMAT_KEY_ARTIST, "TPE1", "TP1" }, { kKeyAlbumArtist, "TPE2", "TP2" }, { AMEDIAFORMAT_KEY_ALBUMARTIST, "TPE2", "TP2" }, { kKeyComposer, "TCOM", "TCM" }, { AMEDIAFORMAT_KEY_COMPOSER, "TCOM", "TCM" }, { kKeyGenre, "TCON", "TCO" }, { AMEDIAFORMAT_KEY_GENRE, "TCON", "TCO" }, { kKeyTitle, "TIT2", "TT2" }, { AMEDIAFORMAT_KEY_TITLE, "TIT2", "TT2" }, { kKeyYear, "TYE", "TYER" }, { AMEDIAFORMAT_KEY_YEAR, "TYE", "TYER" }, { kKeyAuthor, "TXT", "TEXT" }, { AMEDIAFORMAT_KEY_AUTHOR, "TXT", "TEXT" }, { kKeyCDTrackNumber, "TRK", "TRCK" }, { AMEDIAFORMAT_KEY_CDTRACKNUMBER, "TRK", "TRCK" }, { kKeyDiscNumber, "TPA", "TPOS" }, { AMEDIAFORMAT_KEY_DISCNUMBER, "TPA", "TPOS" }, { kKeyCompilation, "TCP", "TCMP" }, { AMEDIAFORMAT_KEY_COMPILATION, "TCP", "TCMP" }, }; }; static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); static const size_t kNumMapEntries = sizeof(kMap) / sizeof(kMap[0]); Loading @@ -655,7 +658,7 @@ status_t MP3Extractor::getMetaData(MetaDataBase &meta) { it->getString(&s); it->getString(&s); delete it; delete it; meta.setCString(kMap[i].key, s); AMediaFormat_setString(meta, kMap[i].key, s.string()); } } size_t dataSize; size_t dataSize; Loading @@ -663,21 +666,20 @@ status_t MP3Extractor::getMetaData(MetaDataBase &meta) { const void *data = id3.getAlbumArt(&dataSize, &mime); const void *data = id3.getAlbumArt(&dataSize, &mime); if (data) { if (data) { meta.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); AMediaFormat_setBuffer(meta, AMEDIAFORMAT_KEY_ALBUMART, data, dataSize); meta.setCString(kKeyAlbumArtMIME, mime.string()); } } return OK; return AMEDIA_OK; } } static CMediaExtractor* CreateExtractor( static CMediaExtractorV2* CreateExtractor( CDataSource *source, CDataSource *source, void *meta) { void *meta) { Mp3Meta *metaData = static_cast<Mp3Meta *>(meta); Mp3Meta *metaData = static_cast<Mp3Meta *>(meta); return wrap(new MP3Extractor(new DataSourceHelper(source), metaData)); return wrapV2(new MP3Extractor(new DataSourceHelper(source), metaData)); } } static CreatorFunc Sniff( static CreatorFuncV2 Sniff( CDataSource *source, float *confidence, void **meta, CDataSource *source, float *confidence, void **meta, FreeMetaFunc *freeMeta) { FreeMetaFunc *freeMeta) { off64_t pos = 0; off64_t pos = 0; Loading Loading @@ -714,11 +716,11 @@ extern "C" { __attribute__ ((visibility ("default"))) __attribute__ ((visibility ("default"))) ExtractorDef GETEXTRACTORDEF() { ExtractorDef GETEXTRACTORDEF() { return { return { EXTRACTORDEF_VERSION, EXTRACTORDEF_VERSION_CURRENT, UUID("812a3f6c-c8cf-46de-b529-3774b14103d4"), UUID("812a3f6c-c8cf-46de-b529-3774b14103d4"), 1, // version 1, // version "MP3 Extractor", "MP3 Extractor", { Sniff } { .v2 = Sniff } }; }; } } Loading
media/extractors/mp3/MP3Extractor.h +6 −6 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ #include <utils/Errors.h> #include <utils/Errors.h> #include <media/MediaExtractorPluginApi.h> #include <media/MediaExtractorPluginApi.h> #include <media/MediaExtractorPluginHelper.h> #include <media/MediaExtractorPluginHelper.h> #include <media/stagefright/MetaDataBase.h> #include <media/NdkMediaFormat.h> namespace android { namespace android { Loading @@ -32,16 +32,16 @@ struct MP3Seeker; class String8; class String8; struct Mp3Meta; struct Mp3Meta; class MP3Extractor : public MediaExtractorPluginHelper { class MP3Extractor : public MediaExtractorPluginHelperV2 { public: public: MP3Extractor(DataSourceHelper *source, Mp3Meta *meta); MP3Extractor(DataSourceHelper *source, Mp3Meta *meta); ~MP3Extractor(); ~MP3Extractor(); virtual size_t countTracks(); virtual size_t countTracks(); virtual MediaTrackHelper *getTrack(size_t index); virtual MediaTrackHelperV2 *getTrack(size_t index); virtual status_t getTrackMetaData(MetaDataBase& meta, size_t index, uint32_t flags); virtual media_status_t getTrackMetaData(AMediaFormat *meta, size_t index, uint32_t flags); virtual status_t getMetaData(MetaDataBase& meta); virtual media_status_t getMetaData(AMediaFormat *meta); virtual const char * name() { return "MP3Extractor"; } virtual const char * name() { return "MP3Extractor"; } private: private: Loading @@ -49,7 +49,7 @@ private: DataSourceHelper *mDataSource; DataSourceHelper *mDataSource; off64_t mFirstFramePos; off64_t mFirstFramePos; MetaDataBase mMeta; AMediaFormat *mMeta; uint32_t mFixedHeader; uint32_t mFixedHeader; MP3Seeker *mSeeker; MP3Seeker *mSeeker; Loading
media/extractors/mp4/MPEG4Extractor.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -3608,7 +3608,6 @@ void MPEG4Extractor::parseID3v2MetaData(off64_t offset) { if (data) { if (data) { mFileMetaData.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); mFileMetaData.setData(kKeyAlbumArt, MetaData::TYPE_NONE, data, dataSize); mFileMetaData.setCString(kKeyAlbumArtMIME, mime.string()); } } } } } } Loading