зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0f59a9eb1658 due to bustage.
This commit is contained in:
Родитель
22fec013ea
Коммит
c81918a3f8
|
@ -29,6 +29,45 @@ namespace mozilla {
|
|||
|
||||
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)
|
||||
: mMediaSource(nullptr)
|
||||
{
|
||||
|
@ -45,8 +84,7 @@ MediaSourceDecoder::Clone()
|
|||
MediaDecoderStateMachine*
|
||||
MediaSourceDecoder::CreateStateMachine()
|
||||
{
|
||||
mReader = new MediaSourceReader(this, mMediaSource);
|
||||
return new MediaDecoderStateMachine(this, mReader);
|
||||
return new MediaSourceStateMachine(this, new MediaSourceReader(this, mMediaSource));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -110,7 +148,21 @@ MediaSourceDecoder::DetachMediaSource()
|
|||
already_AddRefed<SubBufferDecoder>
|
||||
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
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace mozilla {
|
|||
|
||||
class MediaResource;
|
||||
class MediaDecoderStateMachine;
|
||||
class MediaSourceReader;
|
||||
class SubBufferDecoder;
|
||||
|
||||
namespace dom {
|
||||
|
@ -45,12 +44,13 @@ public:
|
|||
|
||||
already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType);
|
||||
|
||||
nsresult EnqueueDecoderInitialization();
|
||||
|
||||
private:
|
||||
// The owning MediaSource holds a strong reference to this decoder, and
|
||||
// calls Attach/DetachMediaSource on this decoder to set and clear
|
||||
// mMediaSource.
|
||||
dom::MediaSource* mMediaSource;
|
||||
nsRefPtr<MediaSourceReader> mReader;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "MediaDecoderOwner.h"
|
||||
#include "MediaSource.h"
|
||||
#include "MediaSourceDecoder.h"
|
||||
#include "SharedThreadPool.h"
|
||||
#include "SubBufferDecoder.h"
|
||||
|
||||
#ifdef MOZ_FMP4
|
||||
|
@ -42,7 +41,6 @@ MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder, dom::MediaSou
|
|||
, mActiveAudioDecoder(-1)
|
||||
, mMediaSource(aSource)
|
||||
{
|
||||
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -137,7 +135,6 @@ MediaSourceReader::Shutdown()
|
|||
for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
|
||||
mDecoders[i]->GetReader()->Shutdown();
|
||||
}
|
||||
mTaskQueue->Shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -302,7 +299,8 @@ CreateReaderForType(const nsACString& aType, AbstractMediaDecoder* aDecoder)
|
|||
|
||||
already_AddRefed<SubBufferDecoder>
|
||||
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?!
|
||||
nsRefPtr<SubBufferDecoder> decoder =
|
||||
|
@ -315,18 +313,16 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType,
|
|||
// This reader will then forward them onto the state machine via this
|
||||
// reader's callback.
|
||||
RefPtr<MediaDataDecodedListener<MediaSourceReader>> callback =
|
||||
new MediaDataDecodedListener<MediaSourceReader>(this, mTaskQueue);
|
||||
new MediaDataDecodedListener<MediaSourceReader>(this, aTaskQueue);
|
||||
reader->SetCallback(callback);
|
||||
reader->SetTaskQueue(mTaskQueue);
|
||||
reader->SetTaskQueue(aTaskQueue);
|
||||
reader->Init(nullptr);
|
||||
ReentrantMonitorAutoEnter mon(aParentDecoder->GetReentrantMonitor());
|
||||
MSE_DEBUG("MediaSourceReader(%p)::CreateSubDecoder subdecoder %p subreader %p",
|
||||
this, decoder.get(), reader.get());
|
||||
decoder->SetReader(reader);
|
||||
mPendingDecoders.AppendElement(decoder);
|
||||
RefPtr<nsIRunnable> task =
|
||||
NS_NewRunnableMethod(this, &MediaSourceReader::InitializePendingDecoders);
|
||||
if (NS_FAILED(mTaskQueue->Dispatch(task))) {
|
||||
if (NS_FAILED(static_cast<MediaSourceDecoder*>(mDecoder)->EnqueueDecoderInitialization())) {
|
||||
MSE_DEBUG("MediaSourceReader(%p): Failed to enqueue decoder initialization task", this);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,8 @@ public:
|
|||
nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
|
||||
int64_t aCurrentTime) MOZ_OVERRIDE;
|
||||
already_AddRefed<SubBufferDecoder> CreateSubDecoder(const nsACString& aType,
|
||||
MediaSourceDecoder* aParentDecoder);
|
||||
MediaSourceDecoder* aParentDecoder,
|
||||
MediaTaskQueue* aTaskQueue);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
|
@ -108,8 +109,6 @@ private:
|
|||
nsTArray<nsRefPtr<SubBufferDecoder>> mPendingDecoders;
|
||||
nsTArray<nsRefPtr<SubBufferDecoder>> mDecoders;
|
||||
|
||||
nsRefPtr<MediaTaskQueue> mTaskQueue;
|
||||
|
||||
int32_t mActiveVideoDecoder;
|
||||
int32_t mActiveAudioDecoder;
|
||||
dom::MediaSource* mMediaSource;
|
||||
|
|
Загрузка…
Ссылка в новой задаче