☠☠ backed out by aa52cfb29acb ☠ ☠ | |
author | Corentin Cos <corentin.cos@gmail.com> |
Tue, 17 Jun 2014 00:32:18 +0200 | |
changeset 189614 | 9fd0316dcd1bd4e7fb8d1aa5fe1a08f5d3a0a2e3 |
parent 189613 | fc071decd42d50366b3b2d19b073976f4450555a |
child 189615 | 3ff9374610b71410b65fc44b01200559953eaca4 |
push id | 26992 |
push user | kwierso@gmail.com |
push date | Fri, 20 Jun 2014 01:07:53 +0000 |
treeherder | mozilla-central@bdac18bd6c74 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | rillian |
bugs | 1016413 |
milestone | 33.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/media/fmp4/MP4Reader.cpp +++ b/content/media/fmp4/MP4Reader.cpp @@ -245,17 +245,17 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo } // We can seek if we get a duration *and* the reader reports that it's // seekable. if (!mDecoder->GetResource()->IsTransportSeekable() || !mDemuxer->CanSeek()) { mDecoder->SetMediaSeekable(false); } *aInfo = mInfo; - *aTags = nullptr; + *aTags = mDemuxer->GetTags(); return NS_OK; } bool MP4Reader::HasAudio() { return mAudio.mActive;
--- a/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h +++ b/media/libstagefright/binding/include/mp4_demuxer/mp4_demuxer.h @@ -3,16 +3,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef MP4_DEMUXER_H_ #define MP4_DEMUXER_H_ #include "nsAutoPtr.h" #include "mozilla/gfx/Rect.h" #include "mp4_demuxer/DecoderData.h" +#include "AbstractMediaDecoder.h" namespace mp4_demuxer { struct StageFrightPrivate; typedef int64_t Microseconds; class Stream @@ -33,16 +34,17 @@ class MP4Demuxer public: MP4Demuxer(Stream* aSource); ~MP4Demuxer(); bool Init(); Microseconds Duration(); bool CanSeek(); + mozilla::MetadataTags* GetTags(); bool HasValidAudio(); bool HasValidVideo(); void SeekAudio(Microseconds aTime); void SeekVideo(Microseconds aTime); // DemuxAudioSample and DemuxVideoSample functions return nullptr on end of // stream or error.
--- a/media/libstagefright/binding/mp4_demuxer.cpp +++ b/media/libstagefright/binding/mp4_demuxer.cpp @@ -3,24 +3,48 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "include/MPEG4Extractor.h" #include "media/stagefright/DataSource.h" #include "media/stagefright/MediaSource.h" #include "media/stagefright/MetaData.h" #include "mp4_demuxer/Adts.h" #include "mp4_demuxer/mp4_demuxer.h" - +#include "mozilla/ArrayUtils.h" #include <stdint.h> using namespace stagefright; namespace mp4_demuxer { +struct tagmap { + const uint32_t key; + const char* name; +}; + +const struct tagmap keys[] = { + { kKeyAlbum, "album" }, + { kKeyArtist, "artist" }, + { kKeyAlbumArtist, "albumArtist" }, + { kKeyComposer, "composer" }, + { kKeyGenre, "genre" }, + { kKeyTitle, "title" }, + { kKeyYear, "year" }, + { kKeyAlbumArt, "albumArt" }, + { kKeyAlbumArtMIME, "albumArtMIME" }, + { kKeyAuthor, "author" }, + { kKeyCDTrackNumber, "cdTrackNumber" }, + { kKeyDiscNumber, "discNumber" }, + { kKeyDate, "date" }, + { kKeyWriter, "writer" }, + { kKeyCompilation, "compilation" }, + { kKeyLocation, "location" }, +}; + struct StageFrightPrivate { sp<MPEG4Extractor> mExtractor; sp<MediaSource> mAudio; MediaSource::ReadOptions mAudioOptions; sp<MediaSource> mVideo; @@ -75,16 +99,38 @@ MP4Demuxer::~MP4Demuxer() if (mPrivate->mAudio.get()) { mPrivate->mAudio->stop(); } if (mPrivate->mVideo.get()) { mPrivate->mVideo->stop(); } } +mozilla::MetadataTags* +MP4Demuxer::GetTags() +{ + mozilla::MetadataTags* tags = new mozilla::MetadataTags; + sp<MetaData> metaData = mPrivate->mExtractor->getMetaData(); + const char* value = nullptr; + nsCString cstringValue; + size_t key_count = mozilla::ArrayLength(keys); + + for (size_t i = 0; i < key_count; i++) { + if (metaData->findCString(keys[i].key, &value)) { + MOZ_ASSERT(value); + cstringValue = nsCString(value); + if (IsUTF8(cstringValue)) { + tags->Put(nsCString(keys[i].name), cstringValue); + } + } + } + + return tags; +} + bool MP4Demuxer::Init() { sp<MediaExtractor> e = mPrivate->mExtractor; for (size_t i = 0; i < e->countTracks(); i++) { sp<MetaData> metaData = e->getTrackMetaData(i); const char* mimeType;