From 1dac0b7b194ff64d9dec064ed8215f6f7ea27555 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Wed, 27 Jan 2016 18:36:08 +1300 Subject: [PATCH] Bug 1243234 - Remove now-unnecessary StagefrightPrivate wrapper. r=giles --- media/libstagefright/binding/MP4Metadata.cpp | 48 ++++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/media/libstagefright/binding/MP4Metadata.cpp b/media/libstagefright/binding/MP4Metadata.cpp index bc7d2ace649..69f8e91bf29 100644 --- a/media/libstagefright/binding/MP4Metadata.cpp +++ b/media/libstagefright/binding/MP4Metadata.cpp @@ -27,15 +27,6 @@ using namespace stagefright; namespace mp4_demuxer { -struct StageFrightPrivate -{ - StageFrightPrivate() - : mCanSeek(false) {} - sp mMetadataExtractor; - - bool mCanSeek; -}; - class DataSourceAdapter : public DataSource { public: @@ -97,9 +88,10 @@ private: mozilla::UniquePtr CheckTrack(const char* aMimeType, stagefright::MetaData* aMetaData, int32_t aIndex) const; - nsAutoPtr mPrivate; CryptoFile mCrypto; RefPtr mSource; + sp mMetadataExtractor; + bool mCanSeek; }; #ifdef MOZ_RUST_MP4PARSE @@ -240,14 +232,11 @@ ConvertIndex(FallibleTArray& aDest, } MP4MetadataStagefright::MP4MetadataStagefright(Stream* aSource) - : mPrivate(new StageFrightPrivate) - , mSource(aSource) + : mSource(aSource) + , mMetadataExtractor(new MPEG4Extractor(new DataSourceAdapter(mSource))) + , mCanSeek(mMetadataExtractor->flags() & MediaExtractor::CAN_SEEK) { - mPrivate->mMetadataExtractor = - new MPEG4Extractor(new DataSourceAdapter(mSource)); - mPrivate->mCanSeek = - mPrivate->mMetadataExtractor->flags() & MediaExtractor::CAN_SEEK; - sp metaData = mPrivate->mMetadataExtractor->getMetaData(); + sp metaData = mMetadataExtractor->getMetaData(); if (metaData.get()) { UpdateCrypto(metaData.get()); @@ -261,10 +250,10 @@ MP4MetadataStagefright::~MP4MetadataStagefright() uint32_t MP4MetadataStagefright::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const { - size_t tracks = mPrivate->mMetadataExtractor->countTracks(); + size_t tracks = mMetadataExtractor->countTracks(); uint32_t total = 0; for (size_t i = 0; i < tracks; i++) { - sp metaData = mPrivate->mMetadataExtractor->getTrackMetaData(i); + sp metaData = mMetadataExtractor->getTrackMetaData(i); const char* mimeType; if (metaData == nullptr || !metaData->findCString(kKeyMIMEType, &mimeType)) { @@ -294,7 +283,7 @@ mozilla::UniquePtr MP4MetadataStagefright::GetTrackInfo(mozilla::TrackInfo::TrackType aType, size_t aTrackNumber) const { - size_t tracks = mPrivate->mMetadataExtractor->countTracks(); + size_t tracks = mMetadataExtractor->countTracks(); if (!tracks) { return nullptr; } @@ -304,7 +293,7 @@ MP4MetadataStagefright::GetTrackInfo(mozilla::TrackInfo::TrackType aType, size_t i = 0; while (i < tracks) { - metaData = mPrivate->mMetadataExtractor->getTrackMetaData(i); + metaData = mMetadataExtractor->getTrackMetaData(i); if (metaData == nullptr || !metaData->findCString(kKeyMIMEType, &mimeType)) { continue; @@ -337,7 +326,7 @@ MP4MetadataStagefright::GetTrackInfo(mozilla::TrackInfo::TrackType aType, UniquePtr e = CheckTrack(mimeType, metaData.get(), index); if (e) { - metaData = mPrivate->mMetadataExtractor->getMetaData(); + metaData = mMetadataExtractor->getMetaData(); int64_t movieDuration; if (!e->mDuration && metaData->findInt64(kKeyMovieDuration, &movieDuration)) { @@ -354,7 +343,7 @@ MP4MetadataStagefright::CheckTrack(const char* aMimeType, stagefright::MetaData* aMetaData, int32_t aIndex) const { - sp track = mPrivate->mMetadataExtractor->getTrack(aIndex); + sp track = mMetadataExtractor->getTrack(aIndex); if (!track.get()) { return nullptr; } @@ -380,7 +369,7 @@ MP4MetadataStagefright::CheckTrack(const char* aMimeType, bool MP4MetadataStagefright::CanSeek() const { - return mPrivate->mCanSeek; + return mCanSeek; } const CryptoFile& @@ -407,17 +396,16 @@ MP4MetadataStagefright::UpdateCrypto(const MetaData* aMetaData) bool MP4MetadataStagefright::ReadTrackIndex(FallibleTArray& aDest, mozilla::TrackID aTrackID) { - size_t numTracks = mPrivate->mMetadataExtractor->countTracks(); + size_t numTracks = mMetadataExtractor->countTracks(); int32_t trackNumber = GetTrackNumber(aTrackID); if (trackNumber < 0) { return false; } - sp track = mPrivate->mMetadataExtractor->getTrack(trackNumber); + sp track = mMetadataExtractor->getTrack(trackNumber); if (!track.get()) { return false; } - sp metadata = - mPrivate->mMetadataExtractor->getTrackMetaData(trackNumber); + sp metadata = mMetadataExtractor->getTrackMetaData(trackNumber); int64_t mediaTime; if (!metadata->findInt64(kKeyMediaTime, &mediaTime)) { mediaTime = 0; @@ -430,9 +418,9 @@ MP4MetadataStagefright::ReadTrackIndex(FallibleTArray& aDest, moz int32_t MP4MetadataStagefright::GetTrackNumber(mozilla::TrackID aTrackID) { - size_t numTracks = mPrivate->mMetadataExtractor->countTracks(); + size_t numTracks = mMetadataExtractor->countTracks(); for (size_t i = 0; i < numTracks; i++) { - sp metaData = mPrivate->mMetadataExtractor->getTrackMetaData(i); + sp metaData = mMetadataExtractor->getTrackMetaData(i); if (!metaData.get()) { continue; }