Backed out changeset 0f59a9eb1658 due to bustage.

This commit is contained in:
Matthew Gregan 2014-08-18 17:02:26 +12:00
Родитель 22fec013ea
Коммит c81918a3f8
4 изменённых файлов: 64 добавлений и 17 удалений

Просмотреть файл

@ -29,6 +29,45 @@ namespace mozilla {
class SubBufferDecoder; class SubBufferDecoder;
class MediaSourceStateMachine : public MediaDecoderStateMachine
{
public:
MediaSourceStateMachine(MediaDecoder* aDecoder,
MediaDecoderReader* aReader,
bool aRealTime = false)
: MediaDecoderStateMachine(aDecoder, aReader, aRealTime)
{
}
already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType,
MediaSourceDecoder* aParentDecoder) {
if (!mReader) {
return nullptr;
}
MediaSourceReader* reader = static_cast<MediaSourceReader*>(mReader.get());
return reader->CreateSubDecoder(aType, aParentDecoder, mDecodeTaskQueue);
}
nsresult EnqueueDecoderInitialization() {
AssertCurrentThreadInMonitor();
if (!mReader) {
return NS_ERROR_FAILURE;
}
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(this, &MediaSourceStateMachine::InitializePendingDecoders);
return mDecodeTaskQueue->Dispatch(task);
}
private:
void InitializePendingDecoders() {
if (!mReader) {
return;
}
MediaSourceReader* reader = static_cast<MediaSourceReader*>(mReader.get());
reader->InitializePendingDecoders();
}
};
MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement) MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement)
: mMediaSource(nullptr) : mMediaSource(nullptr)
{ {
@ -45,8 +84,7 @@ MediaSourceDecoder::Clone()
MediaDecoderStateMachine* MediaDecoderStateMachine*
MediaSourceDecoder::CreateStateMachine() MediaSourceDecoder::CreateStateMachine()
{ {
mReader = new MediaSourceReader(this, mMediaSource); return new MediaSourceStateMachine(this, new MediaSourceReader(this, mMediaSource));
return new MediaDecoderStateMachine(this, mReader);
} }
nsresult nsresult
@ -110,7 +148,21 @@ MediaSourceDecoder::DetachMediaSource()
already_AddRefed<SubBufferDecoder> already_AddRefed<SubBufferDecoder>
MediaSourceDecoder::CreateSubDecoder(const nsACString& aType) MediaSourceDecoder::CreateSubDecoder(const nsACString& aType)
{ {
return mReader->CreateSubDecoder(aType, this); if (!mDecoderStateMachine) {
return nullptr;
}
MediaSourceStateMachine* sm = static_cast<MediaSourceStateMachine*>(mDecoderStateMachine.get());
return sm->CreateSubDecoder(aType, this);
}
nsresult
MediaSourceDecoder::EnqueueDecoderInitialization()
{
if (!mDecoderStateMachine) {
return NS_ERROR_FAILURE;
}
MediaSourceStateMachine* sm = static_cast<MediaSourceStateMachine*>(mDecoderStateMachine.get());
return sm->EnqueueDecoderInitialization();
} }
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -18,7 +18,6 @@ namespace mozilla {
class MediaResource; class MediaResource;
class MediaDecoderStateMachine; class MediaDecoderStateMachine;
class MediaSourceReader;
class SubBufferDecoder; class SubBufferDecoder;
namespace dom { namespace dom {
@ -45,12 +44,13 @@ public:
already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType); already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType);
nsresult EnqueueDecoderInitialization();
private: private:
// The owning MediaSource holds a strong reference to this decoder, and // The owning MediaSource holds a strong reference to this decoder, and
// calls Attach/DetachMediaSource on this decoder to set and clear // calls Attach/DetachMediaSource on this decoder to set and clear
// mMediaSource. // mMediaSource.
dom::MediaSource* mMediaSource; dom::MediaSource* mMediaSource;
nsRefPtr<MediaSourceReader> mReader;
}; };
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -11,7 +11,6 @@
#include "MediaDecoderOwner.h" #include "MediaDecoderOwner.h"
#include "MediaSource.h" #include "MediaSource.h"
#include "MediaSourceDecoder.h" #include "MediaSourceDecoder.h"
#include "SharedThreadPool.h"
#include "SubBufferDecoder.h" #include "SubBufferDecoder.h"
#ifdef MOZ_FMP4 #ifdef MOZ_FMP4
@ -42,7 +41,6 @@ MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder, dom::MediaSou
, mActiveAudioDecoder(-1) , mActiveAudioDecoder(-1)
, mMediaSource(aSource) , mMediaSource(aSource)
{ {
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
} }
bool bool
@ -137,7 +135,6 @@ MediaSourceReader::Shutdown()
for (uint32_t i = 0; i < mDecoders.Length(); ++i) { for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
mDecoders[i]->GetReader()->Shutdown(); mDecoders[i]->GetReader()->Shutdown();
} }
mTaskQueue->Shutdown();
} }
void void
@ -302,7 +299,8 @@ CreateReaderForType(const nsACString& aType, AbstractMediaDecoder* aDecoder)
already_AddRefed<SubBufferDecoder> already_AddRefed<SubBufferDecoder>
MediaSourceReader::CreateSubDecoder(const nsACString& aType, MediaSourceReader::CreateSubDecoder(const nsACString& aType,
MediaSourceDecoder* aParentDecoder) MediaSourceDecoder* aParentDecoder,
MediaTaskQueue* aTaskQueue)
{ {
// XXX: Why/when is mDecoder null here, since it should be equal to aParentDecoder?! // XXX: Why/when is mDecoder null here, since it should be equal to aParentDecoder?!
nsRefPtr<SubBufferDecoder> decoder = nsRefPtr<SubBufferDecoder> decoder =
@ -315,18 +313,16 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType,
// This reader will then forward them onto the state machine via this // This reader will then forward them onto the state machine via this
// reader's callback. // reader's callback.
RefPtr<MediaDataDecodedListener<MediaSourceReader>> callback = RefPtr<MediaDataDecodedListener<MediaSourceReader>> callback =
new MediaDataDecodedListener<MediaSourceReader>(this, mTaskQueue); new MediaDataDecodedListener<MediaSourceReader>(this, aTaskQueue);
reader->SetCallback(callback); reader->SetCallback(callback);
reader->SetTaskQueue(mTaskQueue); reader->SetTaskQueue(aTaskQueue);
reader->Init(nullptr); reader->Init(nullptr);
ReentrantMonitorAutoEnter mon(aParentDecoder->GetReentrantMonitor()); ReentrantMonitorAutoEnter mon(aParentDecoder->GetReentrantMonitor());
MSE_DEBUG("MediaSourceReader(%p)::CreateSubDecoder subdecoder %p subreader %p", MSE_DEBUG("MediaSourceReader(%p)::CreateSubDecoder subdecoder %p subreader %p",
this, decoder.get(), reader.get()); this, decoder.get(), reader.get());
decoder->SetReader(reader); decoder->SetReader(reader);
mPendingDecoders.AppendElement(decoder); mPendingDecoders.AppendElement(decoder);
RefPtr<nsIRunnable> task = if (NS_FAILED(static_cast<MediaSourceDecoder*>(mDecoder)->EnqueueDecoderInitialization())) {
NS_NewRunnableMethod(this, &MediaSourceReader::InitializePendingDecoders);
if (NS_FAILED(mTaskQueue->Dispatch(task))) {
MSE_DEBUG("MediaSourceReader(%p): Failed to enqueue decoder initialization task", this); MSE_DEBUG("MediaSourceReader(%p): Failed to enqueue decoder initialization task", this);
return nullptr; return nullptr;
} }

Просмотреть файл

@ -71,7 +71,8 @@ public:
nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
int64_t aCurrentTime) MOZ_OVERRIDE; int64_t aCurrentTime) MOZ_OVERRIDE;
already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType, already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType,
MediaSourceDecoder* aParentDecoder); MediaSourceDecoder* aParentDecoder,
MediaTaskQueue* aTaskQueue);
void Shutdown(); void Shutdown();
@ -108,8 +109,6 @@ private:
nsTArray<nsRefPtr<SubBufferDecoder>> mPendingDecoders; nsTArray<nsRefPtr<SubBufferDecoder>> mPendingDecoders;
nsTArray<nsRefPtr<SubBufferDecoder>> mDecoders; nsTArray<nsRefPtr<SubBufferDecoder>> mDecoders;
nsRefPtr<MediaTaskQueue> mTaskQueue;
int32_t mActiveVideoDecoder; int32_t mActiveVideoDecoder;
int32_t mActiveAudioDecoder; int32_t mActiveAudioDecoder;
dom::MediaSource* mMediaSource; dom::MediaSource* mMediaSource;