Bug 1385155. P2 - move MP4Stream into ContainerParser.cpp which is the only user.
MozReview-Commit-ID: 4IguqbJn1xd
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
@@ -11,19 +11,19 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/SizePrintfMacros.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
@@ -354,16 +354,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)
{
}