Backed out changeset b9e3a9f5d04a (bug 1036849) for build bustage, a=backout

This commit is contained in:
Phil Ringnalda 2014-09-01 19:22:06 -07:00
parent 42dbcf9e73
commit 7306963418
11 changed files with 17 additions and 347 deletions

View File

@ -20,7 +20,6 @@ class TimeRanges;
class RequestSampleCallback; class RequestSampleCallback;
class MediaDecoderReader; class MediaDecoderReader;
class SharedDecoderManager;
// Encapsulates the decoding and reading of media data. Reading can either // Encapsulates the decoding and reading of media data. Reading can either
// synchronous and done on the calling "decode" thread, or asynchronous and // synchronous and done on the calling "decode" thread, or asynchronous and
@ -44,8 +43,7 @@ public:
virtual bool IsDormantNeeded() { return false; } virtual bool IsDormantNeeded() { return false; }
// Release media resources they should be released in dormant state // Release media resources they should be released in dormant state
// The reader can be made usable again by calling ReadMetadata(). // The reader can be made usable again by calling ReadMetadata().
virtual void ReleaseMediaResources() {} virtual void ReleaseMediaResources() {};
virtual void SetSharedDecoderManager(SharedDecoderManager* aManager) {}
// Breaks reference-counted cycles. Called during shutdown. // Breaks reference-counted cycles. Called during shutdown.
// WARNING: If you override this, you must call the base implementation // WARNING: If you override this, you must call the base implementation
// in your override. // in your override.

View File

@ -14,7 +14,6 @@
#include "SharedThreadPool.h" #include "SharedThreadPool.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/dom/TimeRanges.h" #include "mozilla/dom/TimeRanges.h"
#include "SharedDecoderManager.h"
#ifdef MOZ_EME #ifdef MOZ_EME
#include "mozilla/CDMProxy.h" #include "mozilla/CDMProxy.h"
@ -404,21 +403,12 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
const VideoDecoderConfig& video = mDemuxer->VideoConfig(); const VideoDecoderConfig& video = mDemuxer->VideoConfig();
mInfo.mVideo.mDisplay = mInfo.mVideo.mDisplay =
nsIntSize(video.display_width, video.display_height); nsIntSize(video.display_width, video.display_height);
mVideo.mCallback = new DecoderCallback(this, kVideo); mVideo.mCallback = new DecoderCallback(this, kVideo);
if (mSharedDecoderManager) { mVideo.mDecoder = mPlatform->CreateH264Decoder(video,
mVideo.mDecoder = mLayersBackendType,
mSharedDecoderManager->CreateH264Decoder(video, mDecoder->GetImageContainer(),
mLayersBackendType, mVideo.mTaskQueue,
mDecoder->GetImageContainer(), mVideo.mCallback);
mVideo.mTaskQueue,
mVideo.mCallback);
} else {
mVideo.mDecoder = mPlatform->CreateH264Decoder(video,
mLayersBackendType,
mDecoder->GetImageContainer(),
mVideo.mTaskQueue,
mVideo.mCallback);
}
NS_ENSURE_TRUE(mVideo.mDecoder != nullptr, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mVideo.mDecoder != nullptr, NS_ERROR_FAILURE);
nsresult rv = mVideo.mDecoder->Init(); nsresult rv = mVideo.mDecoder->Init();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -466,6 +456,12 @@ MP4Reader::GetDecoderData(TrackType aTrack)
return (aTrack == kAudio) ? mAudio : mVideo; return (aTrack == kAudio) ? mAudio : mVideo;
} }
MediaDataDecoder*
MP4Reader::Decoder(TrackType aTrack)
{
return GetDecoderData(aTrack).mDecoder;
}
MP4Sample* MP4Sample*
MP4Reader::PopSample(TrackType aTrack) MP4Reader::PopSample(TrackType aTrack)
{ {
@ -873,21 +869,4 @@ void MP4Reader::NotifyResourcesStatusChanged()
#endif #endif
} }
void
MP4Reader::SetIdle()
{
if (mSharedDecoderManager && mVideo.mDecoder) {
mSharedDecoderManager->SetIdle(mVideo.mDecoder);
NotifyResourcesStatusChanged();
}
}
void
MP4Reader::SetSharedDecoderManager(SharedDecoderManager* aManager)
{
#ifdef MOZ_GONK_MEDIACODEC
mSharedDecoderManager = aManager;
#endif
}
} // namespace mozilla } // namespace mozilla

View File

@ -61,12 +61,9 @@ public:
int64_t aStartTime) MOZ_OVERRIDE; int64_t aStartTime) MOZ_OVERRIDE;
// For Media Resource Management // For Media Resource Management
virtual void SetIdle() MOZ_OVERRIDE;
virtual bool IsWaitingMediaResources() MOZ_OVERRIDE; virtual bool IsWaitingMediaResources() MOZ_OVERRIDE;
virtual bool IsDormantNeeded() MOZ_OVERRIDE; virtual bool IsDormantNeeded() MOZ_OVERRIDE;
virtual void ReleaseMediaResources() MOZ_OVERRIDE; virtual void ReleaseMediaResources() MOZ_OVERRIDE;
virtual void SetSharedDecoderManager(SharedDecoderManager* aManager)
MOZ_OVERRIDE;
virtual nsresult ResetDecode() MOZ_OVERRIDE; virtual nsresult ResetDecode() MOZ_OVERRIDE;
@ -181,6 +178,7 @@ private:
uint64_t mLastReportedNumDecodedFrames; uint64_t mLastReportedNumDecodedFrames;
DecoderData& GetDecoderData(mp4_demuxer::TrackType aTrack); DecoderData& GetDecoderData(mp4_demuxer::TrackType aTrack);
MediaDataDecoder* Decoder(mp4_demuxer::TrackType aTrack);
layers::LayersBackend mLayersBackendType; layers::LayersBackend mLayersBackendType;
@ -194,7 +192,6 @@ private:
bool mIndexReady; bool mIndexReady;
Monitor mIndexMonitor; Monitor mIndexMonitor;
nsRefPtr<SharedDecoderManager> mSharedDecoderManager;
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -228,8 +228,8 @@ public:
virtual bool IsDormantNeeded() { virtual bool IsDormantNeeded() {
return false; return false;
}; };
virtual void ReleaseMediaResources() {} virtual void ReleaseMediaResources() {};
virtual void ReleaseDecoder() {} virtual void ReleaseDecoder() {};
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -1,211 +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 "SharedDecoderManager.h"
#include "mp4_demuxer/DecoderData.h"
namespace mozilla {
class SharedDecoderCallback : public MediaDataDecoderCallback
{
public:
SharedDecoderCallback(SharedDecoderManager* aManager) : mManager(aManager) {}
virtual void Output(MediaData* aData) MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->mActiveCallback->Output(aData);
}
}
virtual void Error() MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->mActiveCallback->Error();
}
}
virtual void InputExhausted() MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->mActiveCallback->InputExhausted();
}
}
virtual void DrainComplete() MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->DrainComplete();
}
}
virtual void NotifyResourcesStatusChanged() MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->mActiveCallback->NotifyResourcesStatusChanged();
}
}
virtual void ReleaseMediaResources() MOZ_OVERRIDE
{
if (mManager->mActiveCallback) {
mManager->mActiveCallback->ReleaseMediaResources();
}
}
nsRefPtr<SharedDecoderManager> mManager;
};
SharedDecoderManager::SharedDecoderManager()
: mActiveProxy(nullptr)
, mActiveCallback(nullptr)
, mWaitForInternalDrain(false)
, mMonitor("SharedDecoderProxy")
{
mCallback = new SharedDecoderCallback(this);
}
SharedDecoderManager::~SharedDecoderManager() {}
already_AddRefed<MediaDataDecoder>
SharedDecoderManager::CreateH264Decoder(
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend, layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback)
{
if (!mDecoder) {
mConfig = aConfig;
nsAutoPtr<PlatformDecoderModule> platform(PlatformDecoderModule::Create());
mDecoder = platform->CreateH264Decoder(
mConfig, aLayersBackend, aImageContainer, aVideoTaskQueue, mCallback);
if (!mDecoder) {
return nullptr;
}
nsresult rv = mDecoder->Init();
NS_ENSURE_SUCCESS(rv, nullptr);
}
nsRefPtr<SharedDecoderProxy> proxy(
new SharedDecoderProxy(this, aCallback, aConfig));
return proxy.forget();
}
void
SharedDecoderManager::Select(SharedDecoderProxy* aProxy)
{
if (mActiveProxy == aProxy) {
return;
}
SetIdle(mActiveProxy);
mActiveProxy = aProxy;
mActiveCallback = aProxy->mCallback;
mConfig = aProxy->mConfig;
}
void
SharedDecoderManager::SetIdle(MediaDataDecoder* aProxy)
{
if (aProxy && mActiveProxy == aProxy) {
mWaitForInternalDrain = true;
mActiveProxy->Drain();
MonitorAutoLock mon(mMonitor);
while (mWaitForInternalDrain) {
mon.Wait();
}
mActiveProxy->Flush();
mActiveProxy = nullptr;
}
}
void
SharedDecoderManager::DrainComplete()
{
if (mWaitForInternalDrain) {
MonitorAutoLock mon(mMonitor);
mWaitForInternalDrain = false;
mon.NotifyAll();
} else {
mActiveCallback->DrainComplete();
}
}
SharedDecoderProxy::SharedDecoderProxy(
SharedDecoderManager* aManager, MediaDataDecoderCallback* aCallback,
const mp4_demuxer::VideoDecoderConfig& aConfig)
: mManager(aManager), mCallback(aCallback), mConfig(aConfig)
{
}
SharedDecoderProxy::~SharedDecoderProxy() { Shutdown(); }
nsresult
SharedDecoderProxy::Init()
{
return NS_OK;
}
nsresult
SharedDecoderProxy::Input(mp4_demuxer::MP4Sample* aSample)
{
if (mManager->mActiveProxy != this) {
mManager->Select(this);
}
return mManager->mDecoder->Input(aSample);
return NS_OK;
}
nsresult
SharedDecoderProxy::Flush()
{
if (mManager->mActiveProxy == this) {
return mManager->mDecoder->Flush();
}
return NS_OK;
}
nsresult
SharedDecoderProxy::Drain()
{
if (mManager->mActiveProxy == this) {
return mManager->mDecoder->Drain();
}
return NS_OK;
}
nsresult
SharedDecoderProxy::Shutdown()
{
mManager->SetIdle(this);
return NS_OK;
}
bool
SharedDecoderProxy::IsWaitingMediaResources()
{
if (mManager->mActiveProxy == this) {
return mManager->mDecoder->IsWaitingMediaResources();
}
return mManager->mActiveProxy != nullptr;
}
bool
SharedDecoderProxy::IsDormantNeeded()
{
return mManager->mDecoder->IsDormantNeeded();
}
void
SharedDecoderProxy::ReleaseMediaResources()
{
if (mManager->mActiveProxy == this) {
mManager->mDecoder->ReleaseMediaResources();
}
}
void
SharedDecoderProxy::ReleaseDecoder()
{
if (mManager->mActiveProxy == this) {
mManager->mDecoder->ReleaseMediaResources();
}
}
}

View File

@ -1,80 +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 SHARED_DECODER_MANAGER_H_
#define SHARED_DECODER_MANAGER_H_
#include "PlatformDecoderModule.h"
#include "mozilla/Monitor.h"
namespace mozilla
{
class MediaDataDecoder;
class SharedDecoderProxy;
class SharedDecoderCallback;
class SharedDecoderManager
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedDecoderManager)
SharedDecoderManager();
already_AddRefed<MediaDataDecoder> CreateH264Decoder(
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer, MediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback);
void SetReader(MediaDecoderReader* aReader);
void Select(SharedDecoderProxy* aProxy);
void SetIdle(MediaDataDecoder* aProxy);
friend class SharedDecoderProxy;
friend class SharedDecoderCallback;
private:
virtual ~SharedDecoderManager();
void DrainComplete();
mp4_demuxer::VideoDecoderConfig mConfig;
nsRefPtr<MediaDataDecoder> mDecoder;
SharedDecoderProxy* mActiveProxy;
MediaDataDecoderCallback* mActiveCallback;
nsAutoPtr<MediaDataDecoderCallback> mCallback;
bool mWaitForInternalDrain;
Monitor mMonitor;
};
class SharedDecoderProxy : public MediaDataDecoder
{
public:
SharedDecoderProxy(SharedDecoderManager* aManager,
MediaDataDecoderCallback* aCallback,
const mp4_demuxer::VideoDecoderConfig& aConfig);
virtual ~SharedDecoderProxy();
virtual nsresult Init() MOZ_OVERRIDE;
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE;
virtual nsresult Flush() MOZ_OVERRIDE;
virtual nsresult Drain() MOZ_OVERRIDE;
virtual nsresult Shutdown() MOZ_OVERRIDE;
virtual bool IsWaitingMediaResources() MOZ_OVERRIDE;
virtual bool IsDormantNeeded() MOZ_OVERRIDE;
virtual void ReleaseMediaResources() MOZ_OVERRIDE;
virtual void ReleaseDecoder() MOZ_OVERRIDE;
friend class SharedDecoderManager;
private:
nsRefPtr<SharedDecoderManager> mManager;
MediaDataDecoderCallback* mCallback;
const mp4_demuxer::VideoDecoderConfig& mConfig;
};
}
#endif

View File

@ -59,7 +59,7 @@ GonkVideoDecoderManager::GonkVideoDecoderManager(
mVideoWidth = aConfig.display_width; mVideoWidth = aConfig.display_width;
mVideoHeight = aConfig.display_height; mVideoHeight = aConfig.display_height;
mDisplayWidth = aConfig.display_width; mDisplayWidth = aConfig.display_width;
mDisplayHeight = aConfig.display_height; mDisplayHeight = aConfig.display_width;
mInfo.mVideo.mHasVideo = true; mInfo.mVideo.mHasVideo = true;
nsIntSize displaySize(mDisplayWidth, mDisplayHeight); nsIntSize displaySize(mDisplayWidth, mDisplayHeight);
mInfo.mVideo.mDisplay = displaySize; mInfo.mVideo.mDisplay = displaySize;

View File

@ -8,13 +8,11 @@ EXPORTS += [
'MP4Decoder.h', 'MP4Decoder.h',
'MP4Reader.h', 'MP4Reader.h',
'PlatformDecoderModule.h', 'PlatformDecoderModule.h',
'SharedDecoderManager.h',
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'BlankDecoderModule.cpp', 'BlankDecoderModule.cpp',
'PlatformDecoderModule.cpp', 'PlatformDecoderModule.cpp',
'SharedDecoderManager.cpp',
] ]
SOURCES += [ SOURCES += [

View File

@ -14,7 +14,6 @@
#include "MediaSourceDecoder.h" #include "MediaSourceDecoder.h"
#include "MediaSourceUtils.h" #include "MediaSourceUtils.h"
#include "SourceBufferDecoder.h" #include "SourceBufferDecoder.h"
#include "SharedDecoderManager.h"
#ifdef MOZ_FMP4 #ifdef MOZ_FMP4
#include "MP4Decoder.h" #include "MP4Decoder.h"
@ -42,7 +41,6 @@ MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder)
, mDropAudioBeforeThreshold(false) , mDropAudioBeforeThreshold(false)
, mDropVideoBeforeThreshold(false) , mDropVideoBeforeThreshold(false)
, mEnded(false) , mEnded(false)
, mSharedDecoderManager(new SharedDecoderManager())
{ {
} }
@ -356,7 +354,6 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType)
// reader's callback. // reader's callback.
RefPtr<MediaDataDecodedListener<MediaSourceReader>> callback = RefPtr<MediaDataDecodedListener<MediaSourceReader>> callback =
new MediaDataDecodedListener<MediaSourceReader>(this, GetTaskQueue()); new MediaDataDecodedListener<MediaSourceReader>(this, GetTaskQueue());
reader->SetSharedDecoderManager(mSharedDecoderManager);
reader->SetCallback(callback); reader->SetCallback(callback);
reader->SetTaskQueue(GetTaskQueue()); reader->SetTaskQueue(GetTaskQueue());
reader->Init(nullptr); reader->Init(nullptr);

View File

@ -116,7 +116,6 @@ private:
nsRefPtr<MediaDecoderReader> mVideoReader; nsRefPtr<MediaDecoderReader> mVideoReader;
bool mEnded; bool mEnded;
nsRefPtr<SharedDecoderManager> mSharedDecoderManager;
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -113,13 +113,6 @@ class VideoDecoderConfig : public TrackConfig
{ {
public: public:
VideoDecoderConfig() : display_width(0), display_height(0) {} VideoDecoderConfig() : display_width(0), display_height(0) {}
void operator=(const VideoDecoderConfig& aConfig)
{
display_width = aConfig.display_width;
display_height = aConfig.display_height;
extra_data.appendAll(aConfig.extra_data);
annex_b.appendAll(aConfig.annex_b);
}
int32_t display_width; int32_t display_width;
int32_t display_height; int32_t display_height;