Bug 1385155. P2 - move MP4Stream into ContainerParser.cpp which is the only user. r=gerald
authorJW Wang <jwwang@mozilla.com>
Thu, 27 Jul 2017 17:43:09 +0800
changeset 420248 78d726cefb1275075bae8a9a7c5e67d8d360e6fc
parent 420247 343e5952d6fe4480dfecdd6ab1758d6e5a025283
child 420249 e264858a00d481b5afa785753f29efcaaeca6228
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1385155
milestone56.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 1385155. P2 - move MP4Stream into ContainerParser.cpp which is the only user. r=gerald MozReview-Commit-ID: 4IguqbJn1xd
dom/media/fmp4/MP4Stream.cpp
dom/media/fmp4/MP4Stream.h
dom/media/fmp4/moz.build
dom/media/gtest/TestMP4Demuxer.cpp
dom/media/mediasource/ContainerParser.cpp
deleted file mode 100644
--- a/dom/media/fmp4/MP4Stream.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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/. */
-
-#include "MP4Stream.h"
-
-namespace mozilla {
-
-MP4Stream::MP4Stream(MediaResource* aResource)
-  : mResource(aResource)
-{
-  MOZ_COUNT_CTOR(MP4Stream);
-  MOZ_ASSERT(aResource);
-}
-
-MP4Stream::~MP4Stream()
-{
-  MOZ_COUNT_DTOR(MP4Stream);
-}
-
-bool
-MP4Stream::ReadAt(int64_t aOffset, void* aBuffer, size_t aCount,
-                  size_t* aBytesRead)
-{
-  return CachedReadAt(aOffset, aBuffer, aCount, aBytesRead);
-}
-
-bool
-MP4Stream::CachedReadAt(int64_t aOffset, void* aBuffer, size_t aCount,
-                        size_t* aBytesRead)
-{
-  nsresult rv =
-    mResource.GetResource()->ReadFromCache(reinterpret_cast<char*>(aBuffer),
-                                           aOffset, aCount);
-  if (NS_FAILED(rv)) {
-    *aBytesRead = 0;
-    return false;
-  }
-  *aBytesRead = aCount;
-  return true;
-}
-
-bool
-MP4Stream::Length(int64_t* aSize)
-{
-  if (mResource.GetLength() < 0)
-    return false;
-  *aSize = mResource.GetLength();
-  return true;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/fmp4/MP4Stream.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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 MP4_STREAM_H_
-#define MP4_STREAM_H_
-
-#include "mp4_demuxer/Stream.h"
-
-#include "MediaResource.h"
-
-namespace mozilla {
-
-class MP4Stream : public mp4_demuxer::Stream {
-public:
-  explicit MP4Stream(MediaResource* aResource);
-  virtual ~MP4Stream();
-  bool ReadAt(int64_t aOffset, void* aBuffer, size_t aCount,
-              size_t* aBytesRead) override;
-  bool CachedReadAt(int64_t aOffset, void* aBuffer, size_t aCount,
-                    size_t* aBytesRead) override;
-  bool Length(int64_t* aSize) override;
-
-private:
-  MediaResourceIndex mResource;
-};
-
-} // namespace mozilla
-
-#endif
--- a/dom/media/fmp4/moz.build
+++ b/dom/media/fmp4/moz.build
@@ -2,22 +2,20 @@
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS += [
     'MP4Decoder.h',
     'MP4Demuxer.h',
-    'MP4Stream.h',
 ]
 
 UNIFIED_SOURCES += [
     'MP4Decoder.cpp',
-    'MP4Stream.cpp',
 ]
 
 SOURCES += [
     'MP4Demuxer.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
--- a/dom/media/gtest/TestMP4Demuxer.cpp
+++ b/dom/media/gtest/TestMP4Demuxer.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "gtest/gtest.h"
 #include "MP4Demuxer.h"
-#include "MP4Stream.h"
 #include "mozilla/MozPromise.h"
 #include "MediaDataDemuxer.h"
 #include "mozilla/SharedThreadPool.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/ArrayUtils.h"
 #include "MockMediaResource.h"
 #include "VideoUtils.h"
 
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -10,19 +10,19 @@
 #include "mozilla/EndianUtils.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/ErrorResult.h"
 #include "mp4_demuxer/MoofParser.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Maybe.h"
 #include "MediaData.h"
 #ifdef MOZ_FMP4
-#include "MP4Stream.h"
 #include "mp4_demuxer/AtomType.h"
 #include "mp4_demuxer/ByteReader.h"
+#include "mp4_demuxer/Stream.h"
 #endif
 #include "nsAutoPtr.h"
 #include "SourceBufferResource.h"
 #include <algorithm>
 
 extern mozilla::LogModule* GetMediaSourceSamplesLog();
 
 #define STRINGIFY(x) #x
@@ -353,16 +353,82 @@ public:
 private:
   WebMBufferedParser mParser;
   nsTArray<WebMTimeDataOffset> mOverlappedMapping;
   int64_t mOffset;
   Maybe<WebMTimeDataOffset> mLastMapping;
 };
 
 #ifdef MOZ_FMP4
+
+class MP4Stream : public mp4_demuxer::Stream
+{
+public:
+  explicit MP4Stream(MediaResource* aResource);
+  virtual ~MP4Stream();
+  bool ReadAt(int64_t aOffset,
+              void* aBuffer,
+              size_t aCount,
+              size_t* aBytesRead) override;
+  bool CachedReadAt(int64_t aOffset,
+                    void* aBuffer,
+                    size_t aCount,
+                    size_t* aBytesRead) override;
+  bool Length(int64_t* aSize) override;
+
+private:
+  MediaResourceIndex mResource;
+};
+
+MP4Stream::MP4Stream(MediaResource* aResource)
+  : mResource(aResource)
+{
+  MOZ_COUNT_CTOR(MP4Stream);
+  MOZ_ASSERT(aResource);
+}
+
+MP4Stream::~MP4Stream()
+{
+  MOZ_COUNT_DTOR(MP4Stream);
+}
+
+bool
+MP4Stream::ReadAt(int64_t aOffset,
+                  void* aBuffer,
+                  size_t aCount,
+                  size_t* aBytesRead)
+{
+  return CachedReadAt(aOffset, aBuffer, aCount, aBytesRead);
+}
+
+bool
+MP4Stream::CachedReadAt(int64_t aOffset,
+                        void* aBuffer,
+                        size_t aCount,
+                        size_t* aBytesRead)
+{
+  nsresult rv = mResource.GetResource()->ReadFromCache(
+    reinterpret_cast<char*>(aBuffer), aOffset, aCount);
+  if (NS_FAILED(rv)) {
+    *aBytesRead = 0;
+    return false;
+  }
+  *aBytesRead = aCount;
+  return true;
+}
+
+bool
+MP4Stream::Length(int64_t* aSize)
+{
+  if (mResource.GetLength() < 0)
+    return false;
+  *aSize = mResource.GetLength();
+  return true;
+}
+
 class MP4ContainerParser : public ContainerParser
 {
 public:
   explicit MP4ContainerParser(const MediaContainerType& aType)
     : ContainerParser(aType)
   {
   }