Bug 1417795 - remove mp4_demuxer namespace part4. r=kinetik
authorAlfredo.Yang <ayang@mozilla.com>
Fri, 17 Nov 2017 09:42:02 +0800
changeset 392665 e6490ebdab8f7d67c3cf775c579dfbea74e93808
parent 392664 877b83d87d826dc86b21e2dd5d6916a83ff3f421
child 392666 a86b16d24bce1bf8ce003dd429e7d49ffa4d1d12
push id32939
push usercsabou@mozilla.com
push dateMon, 20 Nov 2017 21:59:19 +0000
treeherdermozilla-central@0bbed2e6a4cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1417795
milestone59.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
Bug 1417795 - remove mp4_demuxer namespace part4. r=kinetik MozReview-Commit-ID: FvYub3hRkXr
dom/media/gtest/mp4_demuxer/TestParser.cpp
dom/media/mp4/Atom.h
dom/media/mp4/DecoderData.cpp
dom/media/mp4/DecoderData.h
dom/media/mp4/Index.h
dom/media/mp4/MP4Demuxer.cpp
dom/media/mp4/MP4Metadata.cpp
dom/media/mp4/MP4Metadata.h
--- a/dom/media/gtest/mp4_demuxer/TestParser.cpp
+++ b/dom/media/gtest/mp4_demuxer/TestParser.cpp
@@ -10,17 +10,17 @@
 #include "mozilla/Preferences.h"
 #include "BufferStream.h"
 #include "MP4Metadata.h"
 #include "MoofParser.h"
 
 using namespace mozilla;
 using namespace mp4_demuxer;
 
-static const uint32_t E = mp4_demuxer::MP4Metadata::NumberTracksError();
+static const uint32_t E = MP4Metadata::NumberTracksError();
 
 class TestStream : public Stream
 {
 public:
   TestStream(const uint8_t* aBuffer, size_t aSize)
     : mHighestSuccessfulEndOffset(0)
     , mBuffer(aBuffer)
     , mSize(aSize)
--- a/dom/media/mp4/Atom.h
+++ b/dom/media/mp4/Atom.h
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef ATOM_H_
 #define ATOM_H_
 
-namespace mp4_demuxer {
+namespace mozilla {
 
 class Atom
 {
 public:
   Atom()
     : mValid(false)
   {
   }
--- a/dom/media/mp4/DecoderData.cpp
+++ b/dom/media/mp4/DecoderData.cpp
@@ -11,17 +11,17 @@
 #include "VideoUtils.h"
 
 // OpusDecoder header is really needed only by MP4 in rust
 #include "OpusDecoder.h"
 #include "mp4parse.h"
 
 using mozilla::media::TimeUnit;
 
-namespace mp4_demuxer
+namespace mozilla
 {
 
 mozilla::Result<mozilla::Ok, nsresult>
 CryptoFile::DoUpdate(const uint8_t* aData, size_t aLength)
 {
   BufferReader reader(aData, aLength);
   while (reader.Remaining()) {
     PsshInfo psshInfo;
--- a/dom/media/mp4/DecoderData.h
+++ b/dom/media/mp4/DecoderData.h
@@ -15,17 +15,17 @@
 #include "nsString.h"
 
 extern "C" {
 typedef struct mp4parse_track_info mp4parse_track_info;
 typedef struct mp4parse_track_audio_info mp4parse_track_audio_info;
 typedef struct mp4parse_track_video_info mp4parse_track_video_info;
 }
 
-namespace mp4_demuxer
+namespace mozilla
 {
 
 class MP4Demuxer;
 
 struct PsshInfo
 {
   PsshInfo() {}
   PsshInfo(const PsshInfo& aOther) : uuid(aOther.uuid), data(aOther.data) {}
--- a/dom/media/mp4/Index.h
+++ b/dom/media/mp4/Index.h
@@ -10,21 +10,24 @@
 #include "TimeUnits.h"
 #include "MoofParser.h"
 #include "Interval.h"
 #include "Stream.h"
 #include "nsISupportsImpl.h"
 
 template<class T> class nsAutoPtr;
 
+namespace mozilla {
+class IndiceWrapper;
+}
+
 namespace mp4_demuxer
 {
 
 class Index;
-class IndiceWrapper;
 
 typedef int64_t Microseconds;
 
 class SampleIterator
 {
 public:
   explicit SampleIterator(Index* aIndex);
   ~SampleIterator();
@@ -89,17 +92,17 @@ public:
     };
 
     uint32_t mIndex;
     int64_t mStartOffset;
     int64_t mEndOffset;
     Interval<Microseconds> mTime;
   };
 
-  Index(const IndiceWrapper& aIndices,
+  Index(const mozilla::IndiceWrapper& aIndices,
         Stream* aSource,
         uint32_t aTrackId,
         bool aIsAudio);
 
   void UpdateMoofIndex(const mozilla::MediaByteRangeSet& aByteRanges,
                        bool aCanEvict);
   void UpdateMoofIndex(const mozilla::MediaByteRangeSet& aByteRanges);
   Microseconds GetEndCompositionIfBuffered(
--- a/dom/media/mp4/MP4Demuxer.cpp
+++ b/dom/media/mp4/MP4Demuxer.cpp
@@ -33,17 +33,17 @@ mozilla::LogModule* GetDemuxerLog()
 
 namespace mozilla {
 
 class MP4TrackDemuxer : public MediaTrackDemuxer
 {
 public:
   MP4TrackDemuxer(MP4Demuxer* aParent,
                   UniquePtr<TrackInfo>&& aInfo,
-                  const mp4_demuxer::IndiceWrapper& aIndices);
+                  const IndiceWrapper& aIndices);
 
   UniquePtr<TrackInfo> GetInfo() const override;
 
   RefPtr<SeekPromise> Seek(const media::TimeUnit& aTime) override;
 
   RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples = 1) override;
 
   void Reset() override;
@@ -125,53 +125,53 @@ MP4Demuxer::MP4Demuxer(MediaResource* aR
 RefPtr<MP4Demuxer::InitPromise>
 MP4Demuxer::Init()
 {
   AutoPinned<mp4_demuxer::ResourceStream> stream(mStream);
 
   // 'result' will capture the first warning, if any.
   MediaResult result{NS_OK};
 
-  mp4_demuxer::MP4Metadata::ResultAndByteBuffer initData =
-    mp4_demuxer::MP4Metadata::Metadata(stream);
+  MP4Metadata::ResultAndByteBuffer initData =
+    MP4Metadata::Metadata(stream);
   if (!initData.Ref()) {
     return InitPromise::CreateAndReject(
       NS_FAILED(initData.Result())
       ? Move(initData.Result())
       : MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                     RESULT_DETAIL("Invalid MP4 metadata or OOM")),
       __func__);
   } else if (NS_FAILED(initData.Result()) && result == NS_OK) {
     result = Move(initData.Result());
   }
 
   RefPtr<mp4_demuxer::BufferStream> bufferstream =
     new mp4_demuxer::BufferStream(initData.Ref());
 
-  mp4_demuxer::MP4Metadata metadata{bufferstream};
+  MP4Metadata metadata{bufferstream};
   nsresult rv = metadata.Parse();
   if (NS_FAILED(rv)) {
     return InitPromise::CreateAndReject(
       MediaResult(rv, RESULT_DETAIL("Parse MP4 metadata failed")), __func__);
   }
 
   auto audioTrackCount = metadata.GetNumberTracks(TrackInfo::kAudioTrack);
-  if (audioTrackCount.Ref() == mp4_demuxer::MP4Metadata::NumberTracksError()) {
+  if (audioTrackCount.Ref() == MP4Metadata::NumberTracksError()) {
     if (MediaPrefs::MediaWarningsAsErrors()) {
       return InitPromise::CreateAndReject(
         MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                     RESULT_DETAIL("Invalid audio track (%s)",
                                   audioTrackCount.Result().Description().get())),
         __func__);
     }
     audioTrackCount.Ref() = 0;
   }
 
   auto videoTrackCount = metadata.GetNumberTracks(TrackInfo::kVideoTrack);
-  if (videoTrackCount.Ref() == mp4_demuxer::MP4Metadata::NumberTracksError()) {
+  if (videoTrackCount.Ref() == MP4Metadata::NumberTracksError()) {
     if (MediaPrefs::MediaWarningsAsErrors()) {
       return InitPromise::CreateAndReject(
         MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                     RESULT_DETAIL("Invalid video track (%s)",
                                   videoTrackCount.Result().Description().get())),
         __func__);
     }
     videoTrackCount.Ref() = 0;
@@ -190,17 +190,17 @@ MP4Demuxer::Init()
     result = Move(audioTrackCount.Result());
   }
   if (NS_FAILED(videoTrackCount.Result()) && result == NS_OK) {
     result = Move(videoTrackCount.Result());
   }
 
   if (audioTrackCount.Ref() != 0) {
     for (size_t i = 0; i < audioTrackCount.Ref(); i++) {
-      mp4_demuxer::MP4Metadata::ResultAndTrackInfo info =
+      MP4Metadata::ResultAndTrackInfo info =
         metadata.GetTrackInfo(TrackInfo::kAudioTrack, i);
       if (!info.Ref()) {
         if (MediaPrefs::MediaWarningsAsErrors()) {
           return InitPromise::CreateAndReject(
             MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                         RESULT_DETAIL("Invalid MP4 audio track (%s)",
                                       info.Result().Description().get())),
             __func__);
@@ -209,32 +209,32 @@ MP4Demuxer::Init()
           result = MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                                RESULT_DETAIL("Invalid MP4 audio track (%s)",
                                              info.Result().Description().get()));
         }
         continue;
       } else if (NS_FAILED(info.Result()) && result == NS_OK) {
         result = Move(info.Result());
       }
-      mp4_demuxer::MP4Metadata::ResultAndIndice indices =
+      MP4Metadata::ResultAndIndice indices =
         metadata.GetTrackIndice(info.Ref()->mTrackId);
       if (!indices.Ref()) {
         if (NS_FAILED(info.Result()) && result == NS_OK) {
           result = Move(indices.Result());
         }
         continue;
       }
       mAudioDemuxers.AppendElement(
         new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get()));
     }
   }
 
   if (videoTrackCount.Ref() != 0) {
     for (size_t i = 0; i < videoTrackCount.Ref(); i++) {
-      mp4_demuxer::MP4Metadata::ResultAndTrackInfo info =
+      MP4Metadata::ResultAndTrackInfo info =
         metadata.GetTrackInfo(TrackInfo::kVideoTrack, i);
       if (!info.Ref()) {
         if (MediaPrefs::MediaWarningsAsErrors()) {
           return InitPromise::CreateAndReject(
             MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                         RESULT_DETAIL("Invalid MP4 video track (%s)",
                                       info.Result().Description().get())),
             __func__);
@@ -243,37 +243,37 @@ MP4Demuxer::Init()
           result = MediaResult(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
                                RESULT_DETAIL("Invalid MP4 video track (%s)",
                                              info.Result().Description().get()));
         }
         continue;
       } else if (NS_FAILED(info.Result()) && result == NS_OK) {
         result = Move(info.Result());
       }
-      mp4_demuxer::MP4Metadata::ResultAndIndice indices =
+      MP4Metadata::ResultAndIndice indices =
         metadata.GetTrackIndice(info.Ref()->mTrackId);
       if (!indices.Ref()) {
         if (NS_FAILED(info.Result()) && result == NS_OK) {
           result = Move(indices.Result());
         }
         continue;
       }
       mVideoDemuxers.AppendElement(
         new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get()));
     }
   }
 
-  mp4_demuxer::MP4Metadata::ResultAndCryptoFile cryptoFile =
+  MP4Metadata::ResultAndCryptoFile cryptoFile =
     metadata.Crypto();
   if (NS_FAILED(cryptoFile.Result()) && result == NS_OK) {
     result = Move(cryptoFile.Result());
   }
   MOZ_ASSERT(cryptoFile.Ref());
   if (cryptoFile.Ref()->valid) {
-    const nsTArray<mp4_demuxer::PsshInfo>& psshs = cryptoFile.Ref()->pssh;
+    const nsTArray<PsshInfo>& psshs = cryptoFile.Ref()->pssh;
     for (uint32_t i = 0; i < psshs.Length(); i++) {
       mCryptoInitData.AppendElements(psshs[i].data);
     }
   }
 
   mIsSeekable = metadata.CanSeek();
 
   return InitPromise::CreateAndResolve(result, __func__);
@@ -344,17 +344,17 @@ MP4Demuxer::GetCrypto()
     crypto.reset(new EncryptionInfo{});
     crypto->AddInitData(NS_LITERAL_STRING("cenc"), mCryptoInitData);
   }
   return crypto;
 }
 
 MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent,
                                  UniquePtr<TrackInfo>&& aInfo,
-                                 const mp4_demuxer::IndiceWrapper& aIndices)
+                                 const IndiceWrapper& aIndices)
   : mParent(aParent)
   , mStream(new mp4_demuxer::ResourceStream(mParent->mResource))
   , mInfo(Move(aInfo))
   , mIndex(new mp4_demuxer::Index(aIndices,
                                   mStream,
                                   mInfo->mTrackId,
                                   mInfo->IsAudio()))
   , mIterator(MakeUnique<mp4_demuxer::SampleIterator>(mIndex))
--- a/dom/media/mp4/MP4Metadata.cpp
+++ b/dom/media/mp4/MP4Metadata.cpp
@@ -16,23 +16,22 @@
 #include "MediaPrefs.h"
 #include "mp4parse.h"
 
 #include <limits>
 #include <stdint.h>
 #include <vector>
 
 using mozilla::media::TimeUnit;
+using mp4_demuxer::Stream;
+using mp4_demuxer::Index;
+using mp4_demuxer::MoofParser;
 
 namespace mozilla {
 LazyLogModule gMP4MetadataLog("MP4Metadata");
-}
-
-namespace mp4_demuxer
-{
 
 // the owner of mIndice is rust mp4 paser, so lifetime of this class
 // SHOULD NOT longer than rust parser.
 class IndiceWrapperRust : public IndiceWrapper
 {
 public:
   size_t Length() const override;
 
@@ -403,9 +402,9 @@ MP4Metadata::Metadata(Stream* aSource)
   if (!buffer) {
     return {MediaResult(NS_ERROR_DOM_MEDIA_METADATA_ERR,
                         RESULT_DETAIL("Cannot parse metadata")),
             nullptr};
   }
   return {NS_OK, Move(buffer)};
 }
 
-} // namespace mp4_demuxer
+} // namespace mozilla
--- a/dom/media/mp4/MP4Metadata.h
+++ b/dom/media/mp4/MP4Metadata.h
@@ -10,53 +10,53 @@
 #include "DecoderData.h"
 #include "Index.h"
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "MediaResult.h"
 #include "Stream.h"
 #include "mp4parse.h"
 
-namespace mp4_demuxer {
+namespace mozilla {
 
 class IndiceWrapper {
 public:
   virtual size_t Length() const = 0;
 
   // TODO: Index::Indice is from stagefright, we should use another struct once
   //       stagefrigth is removed.
-  virtual bool GetIndice(size_t aIndex, Index::Indice& aIndice) const = 0;
+  virtual bool GetIndice(size_t aIndex, mp4_demuxer::Index::Indice& aIndice) const = 0;
 
   virtual ~IndiceWrapper() {}
 };
 
 struct FreeMP4Parser { void operator()(mp4parse_parser* aPtr) { mp4parse_free(aPtr); } };
 
-// Wrap an mp4_demuxer::Stream to remember the read offset.
+// Wrap an Stream to remember the read offset.
 class StreamAdaptor {
 public:
-  explicit StreamAdaptor(Stream* aSource)
+  explicit StreamAdaptor(mp4_demuxer::Stream* aSource)
     : mSource(aSource)
     , mOffset(0)
   {
   }
 
   ~StreamAdaptor() {}
 
   bool Read(uint8_t* buffer, uintptr_t size, size_t* bytes_read);
 
 private:
-  Stream* mSource;
+  mp4_demuxer::Stream* mSource;
   CheckedInt<size_t> mOffset;
 };
 
 class MP4Metadata
 {
 public:
-  explicit MP4Metadata(Stream* aSource);
+  explicit MP4Metadata(mp4_demuxer::Stream* aSource);
   ~MP4Metadata();
 
   // Simple template class containing a MediaResult and another type.
   template <typename T>
   class ResultAndType
   {
   public:
     template <typename M2, typename T2>
@@ -73,17 +73,17 @@ public:
     T& Ref() { return mT; }
 
   private:
     mozilla::MediaResult mResult;
     typename mozilla::Decay<T>::Type mT;
   };
 
   using ResultAndByteBuffer = ResultAndType<RefPtr<mozilla::MediaByteBuffer>>;
-  static ResultAndByteBuffer Metadata(Stream* aSource);
+  static ResultAndByteBuffer Metadata(mp4_demuxer::Stream* aSource);
 
   static constexpr uint32_t NumberTracksError() { return UINT32_MAX; }
   using ResultAndTrackCount = ResultAndType<uint32_t>;
   ResultAndTrackCount GetNumberTracks(mozilla::TrackInfo::TrackType aType) const;
 
   using ResultAndTrackInfo =
     ResultAndType<mozilla::UniquePtr<mozilla::TrackInfo>>;
   ResultAndTrackInfo GetTrackInfo(mozilla::TrackInfo::TrackType aType,
@@ -99,16 +99,16 @@ public:
 
   nsresult Parse();
 
 private:
   void UpdateCrypto();
   Maybe<uint32_t> TrackTypeToGlobalTrackIndex(mozilla::TrackInfo::TrackType aType, size_t aTrackNumber) const;
 
   CryptoFile mCrypto;
-  RefPtr<Stream> mSource;
+  RefPtr<mp4_demuxer::Stream> mSource;
   StreamAdaptor mSourceAdaptor;
   mozilla::UniquePtr<mp4parse_parser, FreeMP4Parser> mParser;
 };
 
-} // namespace mp4_demuxer
+} // namespace mozilla
 
 #endif // MP4METADATA_H_