--- a/dom/media/Benchmark.cpp
+++ b/dom/media/Benchmark.cpp
@@ -47,20 +47,18 @@ VP9Benchmark::IsVP9DecodeFast()
return false;
#else
bool hasPref = Preferences::HasUserValue(sBenchmarkFpsPref);
uint32_t hadRecentUpdate = Preferences::GetUint(sBenchmarkFpsVersionCheck, 0U);
if (!sHasRunTest && (!hasPref || hadRecentUpdate != sBenchmarkVersionID)) {
sHasRunTest = true;
- RefPtr<WebMDemuxer> demuxer =
- new WebMDemuxer(
- new BufferMediaResource(sWebMSample, sizeof(sWebMSample), nullptr,
- MediaContainerType(MEDIAMIMETYPE("video/webm"))));
+ RefPtr<WebMDemuxer> demuxer = new WebMDemuxer(
+ new BufferMediaResource(sWebMSample, sizeof(sWebMSample), nullptr));
RefPtr<Benchmark> estimiser =
new Benchmark(demuxer,
{
Preferences::GetInt("media.benchmark.frames", 300), // frames to measure
1, // start benchmarking after decoding this frame.
8, // loop after decoding that many frames.
TimeDuration::FromMilliseconds(
Preferences::GetUint("media.benchmark.timeout", 1000))
--- a/dom/media/BufferMediaResource.h
+++ b/dom/media/BufferMediaResource.h
@@ -17,23 +17,21 @@ namespace mozilla {
// the address and the length of the buffer, and simulates a read/seek API
// on top of it. The Read implementation involves copying memory, which is
// unfortunate, but the MediaResource interface mandates that.
class BufferMediaResource : public MediaResource
{
public:
BufferMediaResource(const uint8_t* aBuffer,
uint32_t aLength,
- nsIPrincipal* aPrincipal,
- const MediaContainerType& aContainerType) :
- mBuffer(aBuffer),
- mLength(aLength),
- mOffset(0),
- mPrincipal(aPrincipal),
- mContainerType(aContainerType)
+ nsIPrincipal* aPrincipal)
+ : mBuffer(aBuffer)
+ , mLength(aLength)
+ , mOffset(0)
+ , mPrincipal(aPrincipal)
{
}
protected:
virtual ~BufferMediaResource()
{
}
@@ -100,40 +98,32 @@ private:
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
{
aRanges += MediaByteRange(0, int64_t(mLength));
return NS_OK;
}
bool IsTransportSeekable() override { return true; }
- const MediaContainerType& GetContentType() const override
- {
- return mContainerType;
- }
-
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
// Not owned:
// - mBuffer
// - mPrincipal
size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
- size += mContainerType.SizeOfExcludingThis(aMallocSizeOf);
-
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
private:
const uint8_t * mBuffer;
uint32_t mLength;
uint32_t mOffset;
nsCOMPtr<nsIPrincipal> mPrincipal;
- const MediaContainerType mContainerType;
};
} // namespace mozilla
#endif
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -74,40 +74,37 @@ MediaResource::Destroy()
"MediaResource::Destroy", this, &MediaResource::Destroy));
MOZ_ALWAYS_SUCCEEDS(rv);
}
NS_IMPL_ADDREF(MediaResource)
NS_IMPL_RELEASE_WITH_DESTROY(MediaResource, Destroy())
NS_IMPL_QUERY_INTERFACE0(MediaResource)
-ChannelMediaResource::ChannelMediaResource(
- MediaResourceCallback* aCallback,
- nsIChannel* aChannel,
- nsIURI* aURI,
- const MediaContainerType& aContainerType,
- bool aIsPrivateBrowsing)
- : BaseMediaResource(aCallback, aChannel, aURI, aContainerType)
+ChannelMediaResource::ChannelMediaResource(MediaResourceCallback* aCallback,
+ nsIChannel* aChannel,
+ nsIURI* aURI,
+ bool aIsPrivateBrowsing)
+ : BaseMediaResource(aCallback, aChannel, aURI)
, mOffset(0)
, mReopenOnError(false)
, mIgnoreClose(false)
, mCacheStream(this, aIsPrivateBrowsing)
, mLock("ChannelMediaResource.mLock")
, mIgnoreResume(false)
, mSuspendAgent(mChannel)
{
}
ChannelMediaResource::ChannelMediaResource(
MediaResourceCallback* aCallback,
nsIChannel* aChannel,
nsIURI* aURI,
- const MediaContainerType& aContainerType,
const MediaChannelStatistics& aStatistics)
- : BaseMediaResource(aCallback, aChannel, aURI, aContainerType)
+ : BaseMediaResource(aCallback, aChannel, aURI)
, mOffset(0)
, mReopenOnError(false)
, mIgnoreClose(false)
, mCacheStream(this, /* aIsPrivateBrowsing = */ false)
, mLock("ChannelMediaResource.mLock")
, mChannelStatistics(aStatistics)
, mIgnoreResume(false)
, mSuspendAgent(mChannel)
@@ -654,18 +651,18 @@ bool ChannelMediaResource::CanClone()
return mCacheStream.IsAvailableForSharing();
}
already_AddRefed<MediaResource> ChannelMediaResource::CloneData(MediaResourceCallback* aCallback)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
NS_ASSERTION(mCacheStream.IsAvailableForSharing(), "Stream can't be cloned");
- RefPtr<ChannelMediaResource> resource = new ChannelMediaResource(
- aCallback, nullptr, mURI, GetContentType(), mChannelStatistics);
+ RefPtr<ChannelMediaResource> resource =
+ new ChannelMediaResource(aCallback, nullptr, mURI, mChannelStatistics);
if (resource) {
// Initially the clone is treated as suspended by the cache, because
// we don't have a channel. If the cache needs to read data from the clone
// it will call CacheClientResume (or CacheClientSeek with aResume true)
// which will recreate the channel. This way, if all of the media data
// is already in the cache we don't create an unnecessary HTTP channel
// and perform a useless HTTP transaction.
resource->mSuspendAgent.Suspend();
@@ -853,21 +850,16 @@ ChannelMediaResource::RecreateChannel()
element,
securityFlags,
contentPolicyType,
loadGroup,
nullptr, // aCallbacks
loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
- // We have cached the Content-Type, which should not change. Give a hint to
- // the channel to avoid a sniffing failure, which would be expected because we
- // are probably seeking in the middle of the bitstream, and sniffing relies
- // on the presence of a magic number at the beginning of the stream.
- mChannel->SetContentType(GetContentType().OriginalString());
mSuspendAgent.NotifyChannelOpened(mChannel);
// Tell the cache to reset the download status when the channel is reopened.
mCacheStream.NotifyChannelRecreated();
return rv;
}
@@ -1112,22 +1104,21 @@ ChannelSuspendAgent::IsSuspended()
// FileMediaResource
class FileMediaResource : public BaseMediaResource
{
public:
FileMediaResource(MediaResourceCallback* aCallback,
nsIChannel* aChannel,
- nsIURI* aURI,
- const MediaContainerType& aContainerType) :
- BaseMediaResource(aCallback, aChannel, aURI, aContainerType),
- mSize(-1),
- mLock("FileMediaResource.mLock"),
- mSizeInitialized(false)
+ nsIURI* aURI)
+ : BaseMediaResource(aCallback, aChannel, aURI)
+ , mSize(-1)
+ , mLock("FileMediaResource.mLock")
+ , mSizeInitialized(false)
{
}
~FileMediaResource()
{
}
// Main thread
nsresult Open(nsIStreamListener** aStreamListener) override;
@@ -1451,46 +1442,44 @@ MediaResource::Create(MediaResourceCallb
if (!containerType) {
return nullptr;
}
RefPtr<MediaResource> resource;
#ifdef MOZ_ANDROID_HLS_SUPPORT
if (DecoderTraits::IsHttpLiveStreamingType(containerType.value())) {
- resource = new HLSResource(aCallback, aChannel, uri, *containerType);
+ resource = new HLSResource(aCallback, aChannel, uri);
return resource.forget();
}
#endif
// Let's try to create a FileMediaResource in case the channel is a nsIFile
nsCOMPtr<nsIFileChannel> fc = do_QueryInterface(aChannel);
if (fc) {
- resource = new FileMediaResource(aCallback, aChannel, uri, *containerType);
+ resource = new FileMediaResource(aCallback, aChannel, uri);
}
// If the URL is blobURL with a seekable inputStream, we can still use a
// FileMediaResource. This basically means that the blobURL and its Blob have
// been created in the current process.
if (!resource) {
nsCOMPtr<nsIInputStream> stream;
nsCOMPtr<nsISeekableStream> seekableStream;
if (IsBlobURI(uri) &&
NS_SUCCEEDED(NS_GetStreamForBlobURI(uri, getter_AddRefs(stream))) &&
(seekableStream = do_QueryInterface(stream))) {
- resource =
- new FileMediaResource(aCallback, aChannel, uri, *containerType);
+ resource = new FileMediaResource(aCallback, aChannel, uri);
}
}
if (!resource) {
resource =
- new ChannelMediaResource(aCallback, aChannel, uri, *containerType,
- aIsPrivateBrowsing);
+ new ChannelMediaResource(aCallback, aChannel, uri, aIsPrivateBrowsing);
}
return resource.forget();
}
void BaseMediaResource::SetLoadInBackground(bool aLoadInBackground) {
if (aLoadInBackground == mLoadInBackground) {
return;
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -310,21 +310,16 @@ public:
/**
* Fills aRanges with MediaByteRanges representing the data which is cached
* in the media cache. Stream should be pinned during call and while
* aRanges is being used.
*/
virtual nsresult GetCachedRanges(MediaByteRangeSet& aRanges) = 0;
- // Returns the container content type of the resource. This is copied from the
- // nsIChannel when the MediaResource is created. Safe to call from
- // any thread.
- virtual const MediaContainerType& GetContentType() const = 0;
-
// Returns true if the resource is a live stream.
virtual bool IsLiveStream()
{
return GetLength() == -1;
}
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
return 0;
@@ -348,47 +343,38 @@ public:
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
// Might be useful to track in the future:
// - mChannel
// - mURI (possibly owned, looks like just a ref from mChannel)
// Not owned:
// - mCallback
size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
- size += mContainerType.SizeOfExcludingThis(aMallocSizeOf);
-
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
protected:
BaseMediaResource(MediaResourceCallback* aCallback,
nsIChannel* aChannel,
- nsIURI* aURI,
- const MediaContainerType& aContainerType) :
- mCallback(aCallback),
- mChannel(aChannel),
- mURI(aURI),
- mContainerType(aContainerType),
- mLoadInBackground(false)
+ nsIURI* aURI)
+ : mCallback(aCallback)
+ , mChannel(aChannel)
+ , mURI(aURI)
+ , mLoadInBackground(false)
{
}
virtual ~BaseMediaResource()
{
}
- const MediaContainerType& GetContentType() const override
- {
- return mContainerType;
- }
-
// Set the request's load flags to aFlags. If the request is part of a
// load group, the request is removed from the group, the flags are set, and
// then the request is added back to the load group.
void ModifyLoadFlags(nsLoadFlags aFlags);
// Dispatches an event to call MediaDecoder::NotifyBytesConsumed(aNumBytes, aOffset)
// on the main thread. This is called automatically after every read.
void DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset);
@@ -398,21 +384,16 @@ protected:
// Channel used to download the media data. Must be accessed
// from the main thread only.
nsCOMPtr<nsIChannel> mChannel;
// URI in case the stream needs to be re-opened. Access from
// main thread only.
nsCOMPtr<nsIURI> mURI;
- // Content-Type of the channel. This is copied from the nsIChannel when the
- // MediaResource is created. This is constant, so accessing from any thread
- // is safe.
- const MediaContainerType mContainerType;
-
// True if SetLoadInBackground() has been called with
// aLoadInBackground = true, i.e. when the document load event is not
// blocked by this resource, and all channel loads will be in the
// background.
bool mLoadInBackground;
};
@@ -465,22 +446,20 @@ private:
* thread operations are delegated directly to that object.
*/
class ChannelMediaResource : public BaseMediaResource
{
public:
ChannelMediaResource(MediaResourceCallback* aDecoder,
nsIChannel* aChannel,
nsIURI* aURI,
- const MediaContainerType& aContainerType,
bool aIsPrivateBrowsing);
ChannelMediaResource(MediaResourceCallback* aDecoder,
nsIChannel* aChannel,
nsIURI* aURI,
- const MediaContainerType& aContainerType,
const MediaChannelStatistics& aStatistics);
~ChannelMediaResource();
// These are called on the main thread by MediaCache. These must
// not block or grab locks, because the media cache is holding its lock.
// Notify that data is available from the cache. This can happen even
// if this stream didn't read any data, since another stream might have
// received data for the same resource.
--- a/dom/media/gtest/MockMediaResource.cpp
+++ b/dom/media/gtest/MockMediaResource.cpp
@@ -5,21 +5,19 @@
#include "MockMediaResource.h"
#include <sys/types.h>
#include <sys/stat.h>
namespace mozilla
{
-MockMediaResource::MockMediaResource(const char* aFileName,
- const MediaContainerType& aContainerType)
+MockMediaResource::MockMediaResource(const char* aFileName)
: mFileHandle(nullptr)
, mFileName(aFileName)
- , mContainerType(aContainerType)
{
}
nsresult
MockMediaResource::Open(nsIStreamListener** aStreamListener)
{
mFileHandle = fopen(mFileName, "rb");
if (mFileHandle == nullptr) {
--- a/dom/media/gtest/MockMediaResource.h
+++ b/dom/media/gtest/MockMediaResource.h
@@ -10,19 +10,17 @@
#include "mozilla/Atomics.h"
namespace mozilla
{
class MockMediaResource : public MediaResource
{
public:
- explicit MockMediaResource(const char* aFileName,
- const MediaContainerType& aMimeType =
- MediaContainerType(MEDIAMIMETYPE("video/mp4")));
+ explicit MockMediaResource(const char* aFileName);
nsresult Close() override { return NS_OK; }
void Suspend(bool aCloseImmediately) override {}
void Resume() override {}
already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override
{
return nullptr;
}
void SetReadMode(MediaCacheStream::ReadMode aMode) override {}
@@ -51,30 +49,25 @@ public:
nsresult rv = ReadAt(aOffset, aBuffer, aCount, &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE;
}
bool IsTransportSeekable() override { return true; }
nsresult Open(nsIStreamListener** aStreamListener) override;
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override;
- const MediaContainerType& GetContentType() const override
- {
- return mContainerType;
- }
void MockClearBufferedRanges();
void MockAddBufferedRange(int64_t aStart, int64_t aEnd);
protected:
virtual ~MockMediaResource();
private:
FILE* mFileHandle;
const char* mFileName;
MediaByteRangeSet mRanges;
Atomic<int> mEntry;
- const MediaContainerType mContainerType;
};
} // namespace mozilla
#endif
--- a/dom/media/gtest/TestMediaDataDecoder.cpp
+++ b/dom/media/gtest/TestMediaDataDecoder.cpp
@@ -45,32 +45,30 @@ private:
TEST(MediaDataDecoder, H264)
{
if (!DecoderTraits::IsMP4SupportedType(
MediaContainerType(MEDIAMIMETYPE("video/mp4")),
/* DecoderDoctorDiagnostics* */ nullptr)) {
EXPECT_TRUE(true);
} else {
- RefPtr<MediaResource> resource =
- new MockMediaResource("gizmo.mp4", MediaContainerType(MEDIAMIMETYPE("video/mp4")));
+ RefPtr<MediaResource> resource = new MockMediaResource("gizmo.mp4");
nsresult rv = resource->Open(nullptr);
EXPECT_TRUE(NS_SUCCEEDED(rv));
BenchmarkRunner runner(new Benchmark(new MP4Demuxer(resource)));
EXPECT_GT(runner.Run(), 0u);
}
}
TEST(MediaDataDecoder, VP9)
{
if (!WebMDecoder::IsSupportedType(MediaContainerType(MEDIAMIMETYPE("video/webm")))) {
EXPECT_TRUE(true);
} else {
- RefPtr<MediaResource> resource =
- new MockMediaResource("vp9cake.webm", MediaContainerType(MEDIAMIMETYPE("video/webm")));
+ RefPtr<MediaResource> resource = new MockMediaResource("vp9cake.webm");
nsresult rv = resource->Open(nullptr);
EXPECT_TRUE(NS_SUCCEEDED(rv));
BenchmarkRunner runner(new Benchmark(new WebMDemuxer(resource)));
EXPECT_GT(runner.Run(), 0u);
}
}
--- a/dom/media/hls/HLSResource.cpp
+++ b/dom/media/hls/HLSResource.cpp
@@ -27,22 +27,20 @@ HLSResourceCallbacksSupport::OnDataArriv
void
HLSResourceCallbacksSupport::OnError(int aErrorCode)
{
MOZ_ASSERT(mResource);
}
HLSResource::HLSResource(MediaResourceCallback* aCallback,
nsIChannel* aChannel,
- nsIURI* aURI,
- const MediaContainerType& aContainerType)
+ nsIURI* aURI)
: mCallback(aCallback)
, mChannel(aChannel)
, mURI(aURI)
- , mContainerType(aContainerType)
{
nsCString spec;
nsresult rv = aURI->GetSpec(spec);
(void)rv;
HLSResourceCallbacksSupport::Init();
mJavaCallbacks = GeckoHLSResourceWrapper::Callbacks::New();
HLSResourceCallbacksSupport::AttachNative(mJavaCallbacks,
mozilla::MakeUnique<HLSResourceCallbacksSupport>(this));
--- a/dom/media/hls/HLSResource.h
+++ b/dom/media/hls/HLSResource.h
@@ -36,18 +36,17 @@ private:
HLSResource* mResource;
};
class HLSResource final : public MediaResource
{
public:
HLSResource(MediaResourceCallback* aCallback,
nsIChannel* aChannel,
- nsIURI* aURI,
- const MediaContainerType& aContainerType);
+ nsIURI* aURI);
~HLSResource();
nsresult Close() override { return NS_OK; }
void Suspend(bool aCloseImmediately) override { UNIMPLEMENTED(); }
void Resume() override { UNIMPLEMENTED(); }
void SetReadMode(MediaCacheStream::ReadMode aMode) override { UNIMPLEMENTED(); }
void SetPlaybackRate(uint32_t aBytesPerSecond) override { UNIMPLEMENTED(); }
nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) override { UNIMPLEMENTED(); return NS_ERROR_FAILURE; }
bool ShouldCacheReads() override { UNIMPLEMENTED(); return false; }
@@ -79,18 +78,16 @@ public:
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
{
UNIMPLEMENTED();
return NS_OK;
}
bool IsTransportSeekable() override { return true; }
- const MediaContainerType& GetContentType() const override { return mContainerType; }
-
bool IsLiveStream() override
{
return false;
}
bool IsExpectingMoreData() override
{
return false;
@@ -103,28 +100,25 @@ public:
private:
friend class HLSResourceCallbacksSupport;
void onDataAvailable();
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
- size += mContainerType.SizeOfExcludingThis(aMallocSizeOf);
-
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
RefPtr<MediaResourceCallback> mCallback;
nsCOMPtr<nsIChannel> mChannel;
nsCOMPtr<nsIURI> mURI;
- const MediaContainerType mContainerType;
java::GeckoHLSResourceWrapper::GlobalRef mHLSResourceWrapper;
java::GeckoHLSResourceWrapper::Callbacks::GlobalRef mJavaCallbacks;
};
} // namespace mozilla
#endif /* HLSResource_h_ */
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -207,18 +207,17 @@ public:
return NS_ERROR_NOT_AVAILABLE;
}
if (initSegment) {
mOffset = 0;
mParser = WebMBufferedParser(0);
mOverlappedMapping.Clear();
mInitData = new MediaByteBuffer();
- mResource = new SourceBufferResource(
- MediaContainerType(MEDIAMIMETYPE("video/webm")));
+ mResource = new SourceBufferResource();
mCompleteInitSegmentRange = MediaByteRange();
mCompleteMediaHeaderRange = MediaByteRange();
mCompleteMediaSegmentRange = MediaByteRange();
mGlobalOffset = mTotalParsed;
}
// XXX if it only adds new mappings, overlapped but not available
// (e.g. overlap < 0) frames are "lost" from the reported mappings here.
@@ -491,18 +490,17 @@ private:
public:
MediaResult ParseStartAndEndTimestamps(MediaByteBuffer* aData,
int64_t& aStart,
int64_t& aEnd) override
{
bool initSegment = NS_SUCCEEDED(IsInitSegmentPresent(aData));
if (initSegment) {
- mResource = new SourceBufferResource(
- MediaContainerType(MEDIAMIMETYPE("video/mp4")));
+ mResource = new SourceBufferResource();
mStream = new MP4Stream(mResource);
// We use a timestampOffset of 0 for ContainerParser, and require
// consumers of ParseStartAndEndTimestamps to add their timestamp offset
// manually. This allows the ContainerParser to be shared across different
// timestampOffsets.
mParser = new mp4_demuxer::MoofParser(mStream, 0, /* aIsAudio = */ false);
mInitData = new MediaByteBuffer();
mCompleteInitSegmentRange = MediaByteRange();
--- a/dom/media/mediasource/MediaSourceResource.h
+++ b/dom/media/mediasource/MediaSourceResource.h
@@ -8,29 +8,31 @@
#define MOZILLA_MEDIASOURCERESOURCE_H_
#include "MediaResource.h"
#include "mozilla/Monitor.h"
#include "mozilla/Logging.h"
extern mozilla::LogModule* GetMediaSourceLog();
-#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("MediaSourceResource(%p:%s)::%s: " arg, this, mType.OriginalString().Data(), __func__, ##__VA_ARGS__))
+#define MSE_DEBUG(arg, ...) \
+ MOZ_LOG( \
+ GetMediaSourceLog(), \
+ mozilla::LogLevel::Debug, \
+ ("MediaSourceResource(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
#define UNIMPLEMENTED() MSE_DEBUG("UNIMPLEMENTED FUNCTION at %s:%d", __FILE__, __LINE__)
namespace mozilla {
class MediaSourceResource final : public MediaResource
{
public:
explicit MediaSourceResource(nsIPrincipal* aPrincipal = nullptr)
: mPrincipal(aPrincipal)
- // Fake-but-valid MIME type, unused but necessary to implement GetContentType().
- , mType(MEDIAMIMETYPE("application/x.mediasource"))
, mMonitor("MediaSourceResource")
, mEnded(false)
{}
nsresult Close() override { return NS_OK; }
void Suspend(bool aCloseImmediately) override { UNIMPLEMENTED(); }
void Resume() override { UNIMPLEMENTED(); }
void SetReadMode(MediaCacheStream::ReadMode aMode) override { UNIMPLEMENTED(); }
@@ -58,17 +60,16 @@ public:
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
{
UNIMPLEMENTED();
aRanges += MediaByteRange(0, GetLength());
return NS_OK;
}
bool IsTransportSeekable() override { return true; }
- const MediaContainerType& GetContentType() const override { return mType; }
bool IsLiveStream() override
{
MonitorAutoLock mon(mMonitor);
return !mEnded;
}
void SetEnded(bool aEnded)
{
@@ -81,28 +82,25 @@ public:
MonitorAutoLock mon(mMonitor);
return !mEnded;
}
private:
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
- size += mType.SizeOfExcludingThis(aMallocSizeOf);
-
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
RefPtr<nsIPrincipal> mPrincipal;
- const MediaContainerType mType;
Monitor mMonitor;
bool mEnded; // protected by mMonitor
};
} // namespace mozilla
#undef MSE_DEBUG
#undef UNIMPLEMENTED
--- a/dom/media/mediasource/SourceBufferResource.cpp
+++ b/dom/media/mediasource/SourceBufferResource.cpp
@@ -16,18 +16,26 @@
#include "MediaData.h"
mozilla::LogModule* GetSourceBufferResourceLog()
{
static mozilla::LazyLogModule sLogModule("SourceBufferResource");
return sLogModule;
}
-#define SBR_DEBUG(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Debug, ("SourceBufferResource(%p:%s)::%s: " arg, this, mType.OriginalString().Data(), __func__, ##__VA_ARGS__))
-#define SBR_DEBUGV(arg, ...) MOZ_LOG(GetSourceBufferResourceLog(), mozilla::LogLevel::Verbose, ("SourceBufferResource(%p:%s)::%s: " arg, this, mType.OriginalString().Data(), __func__, ##__VA_ARGS__))
+#define SBR_DEBUG(arg, ...) \
+ MOZ_LOG( \
+ GetSourceBufferResourceLog(), \
+ mozilla::LogLevel::Debug, \
+ ("SourceBufferResource(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
+#define SBR_DEBUGV(arg, ...) \
+ MOZ_LOG( \
+ GetSourceBufferResourceLog(), \
+ mozilla::LogLevel::Verbose, \
+ ("SourceBufferResource(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
namespace mozilla {
nsresult
SourceBufferResource::Close()
{
MOZ_ASSERT(OnTaskQueue());
SBR_DEBUG("Close");
@@ -149,22 +157,23 @@ SourceBufferResource::Ended()
mEnded = true;
}
SourceBufferResource::~SourceBufferResource()
{
SBR_DEBUG("");
}
-SourceBufferResource::SourceBufferResource(const MediaContainerType& aType)
- : mType(aType)
+SourceBufferResource::SourceBufferResource()
#if defined(DEBUG)
- , mTaskQueue(AbstractThread::GetCurrent()->AsTaskQueue())
+ : mTaskQueue(AbstractThread::GetCurrent()->AsTaskQueue())
+ , mOffset(0)
+#else
+ : mOffset(0)
#endif
- , mOffset(0)
, mClosed(false)
, mEnded(false)
{
SBR_DEBUG("");
}
#if defined(DEBUG)
AbstractThread*
--- a/dom/media/mediasource/SourceBufferResource.h
+++ b/dom/media/mediasource/SourceBufferResource.h
@@ -33,17 +33,17 @@ namespace dom {
class SourceBuffer;
} // namespace dom
// SourceBufferResource is not thread safe.
class SourceBufferResource final : public MediaResource
{
public:
- explicit SourceBufferResource(const MediaContainerType& aType);
+ SourceBufferResource();
nsresult Close() override;
void Suspend(bool aCloseImmediately) override { UNIMPLEMENTED(); }
void Resume() override { UNIMPLEMENTED(); }
already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override
{
UNIMPLEMENTED();
return nullptr;
}
@@ -120,24 +120,21 @@ public:
MOZ_ASSERT(OnTaskQueue());
if (mInputBuffer.GetLength()) {
aRanges += MediaByteRange(mInputBuffer.GetOffset(),
mInputBuffer.GetLength());
}
return NS_OK;
}
- const MediaContainerType& GetContentType() const override { return mType; }
-
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override
{
MOZ_ASSERT(OnTaskQueue());
size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
- size += mType.SizeOfExcludingThis(aMallocSizeOf);
size += mInputBuffer.SizeOfExcludingThis(aMallocSizeOf);
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
@@ -182,17 +179,16 @@ public:
#endif
private:
virtual ~SourceBufferResource();
nsresult ReadAtInternal(int64_t aOffset,
char* aBuffer,
uint32_t aCount,
uint32_t* aBytes);
- const MediaContainerType mType;
#if defined(DEBUG)
const RefPtr<TaskQueue> mTaskQueue;
// TaskQueue methods and objects.
AbstractThread* GetTaskQueue() const;
bool OnTaskQueue() const;
#endif
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -397,17 +397,17 @@ TrackBuffersManager::CompleteResetParser
}
// 7. Remove all bytes from the input buffer.
mInputBuffer = nullptr;
if (mCurrentInputBuffer) {
mCurrentInputBuffer->EvictAll();
// The demuxer will be recreated during the next run of SegmentParserLoop.
// As such we don't need to notify it that data has been removed.
- mCurrentInputBuffer = new SourceBufferResource(mType);
+ mCurrentInputBuffer = new SourceBufferResource();
}
// We could be left with a demuxer in an unusable state. It needs to be
// recreated. We store in the InputBuffer an init segment which will be parsed
// during the next Segment Parser Loop and a new demuxer will be created and
// initialized.
if (mFirstInitializationSegmentReceived) {
MOZ_ASSERT(mInitData && mInitData->Length(), "we must have an init segment");
@@ -844,17 +844,17 @@ TrackBuffersManager::CreateDemuxerforMIM
}
// We reset the demuxer by creating a new one and initializing it.
void
TrackBuffersManager::ResetDemuxingState()
{
MOZ_ASSERT(mParser && mParser->HasInitData());
RecreateParser(true);
- mCurrentInputBuffer = new SourceBufferResource(mType);
+ mCurrentInputBuffer = new SourceBufferResource();
// The demuxer isn't initialized yet ; we don't want to notify it
// that data has been appended yet ; so we simply append the init segment
// to the resource.
mCurrentInputBuffer->AppendData(mParser->InitData());
CreateDemuxerforMIMEType();
if (!mInputDemuxer) {
RejectAppend(NS_ERROR_FAILURE, __func__);
return;
@@ -938,17 +938,17 @@ TrackBuffersManager::InitializationSegme
int64_t(mProcessedInput - mInputBuffer->Length()) > endInit) {
// Something is not quite right with the data appended. Refuse it.
RejectAppend(MediaResult(NS_ERROR_FAILURE,
"Invalid state following initialization segment"),
__func__);
return;
}
- mCurrentInputBuffer = new SourceBufferResource(mType);
+ mCurrentInputBuffer = new SourceBufferResource();
// The demuxer isn't initialized yet ; we don't want to notify it
// that data has been appended yet ; so we simply append the init segment
// to the resource.
mCurrentInputBuffer->AppendData(mParser->InitData());
uint32_t length = endInit - (mProcessedInput - mInputBuffer->Length());
if (mInputBuffer->Length() == length) {
mInputBuffer = nullptr;
} else {
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -178,18 +178,17 @@ MediaDecodeTask::CreateReader()
nsCOMPtr<nsIPrincipal> principal;
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(parent);
if (sop) {
principal = sop->GetPrincipal();
}
RefPtr<BufferMediaResource> resource =
- new BufferMediaResource(static_cast<uint8_t*> (mBuffer),
- mLength, principal, mContainerType);
+ new BufferMediaResource(static_cast<uint8_t*>(mBuffer), mLength, principal);
MOZ_ASSERT(!mBufferDecoder);
mMainThread =
mDecodeJob.mContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other);
mBufferDecoder = new BufferDecoder(resource, mMainThread);
// If you change this list to add support for new decoders, please consider
// updating HTMLMediaElement::CreateDecoder as well.