зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1219142. Part 1 - add AbstractMediaDecoder::DataArrivedEvent() to publish events. r=jya.
This commit is contained in:
Родитель
26b0d282a5
Коммит
fbb85ac25a
|
@ -10,6 +10,7 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/StateMirroring.h"
|
#include "mozilla/StateMirroring.h"
|
||||||
|
|
||||||
|
#include "MediaEventSource.h"
|
||||||
#include "MediaInfo.h"
|
#include "MediaInfo.h"
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
|
@ -68,6 +69,15 @@ public:
|
||||||
|
|
||||||
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
|
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
|
||||||
|
|
||||||
|
// Return an event that will be notified when data arrives in MediaResource.
|
||||||
|
// MediaDecoderReader will register with this event to receive notifications
|
||||||
|
// in order to udpate buffer ranges.
|
||||||
|
// Return null if this decoder doesn't support the event.
|
||||||
|
virtual MediaEventSource<void>* DataArrivedEvent()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) {};
|
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) {};
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1447,10 +1447,13 @@ void
|
||||||
MediaDecoder::NotifyDataArrived() {
|
MediaDecoder::NotifyDataArrived() {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
if (mDecoderStateMachine) {
|
// Don't publish events since task queues might be shutting down.
|
||||||
mDecoderStateMachine->DispatchNotifyDataArrived();
|
if (mShuttingDown) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDataArrivedEvent.Notify();
|
||||||
|
|
||||||
// ReadyState computation depends on MediaDecoder::CanPlayThrough, which
|
// ReadyState computation depends on MediaDecoder::CanPlayThrough, which
|
||||||
// depends on the download rate.
|
// depends on the download rate.
|
||||||
UpdateReadyState();
|
UpdateReadyState();
|
||||||
|
|
|
@ -820,6 +820,11 @@ protected:
|
||||||
RefPtr<MediaResource> mResource;
|
RefPtr<MediaResource> mResource;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MediaEventSource<void>*
|
||||||
|
DataArrivedEvent() override { return &mDataArrivedEvent; }
|
||||||
|
|
||||||
|
MediaEventProducer<void> mDataArrivedEvent;
|
||||||
|
|
||||||
// The state machine object for handling the decoding. It is safe to
|
// The state machine object for handling the decoding. It is safe to
|
||||||
// call methods of this object from other threads. Its internal data
|
// call methods of this object from other threads. Its internal data
|
||||||
// is synchronised on a monitor. The lifetime of this object is
|
// is synchronised on a monitor. The lifetime of this object is
|
||||||
|
|
|
@ -79,6 +79,11 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder)
|
||||||
MOZ_COUNT_CTOR(MediaDecoderReader);
|
MOZ_COUNT_CTOR(MediaDecoderReader);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
if (mDecoder && mDecoder->DataArrivedEvent()) {
|
||||||
|
mDataArrivedListener = mDecoder->DataArrivedEvent()->Connect(
|
||||||
|
mTaskQueue, this, &MediaDecoderReader::NotifyDataArrived);
|
||||||
|
}
|
||||||
|
|
||||||
// Dispatch initialization that needs to happen on that task queue.
|
// Dispatch initialization that needs to happen on that task queue.
|
||||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(this, &MediaDecoderReader::InitializationTask);
|
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(this, &MediaDecoderReader::InitializationTask);
|
||||||
mTaskQueue->Dispatch(r.forget());
|
mTaskQueue->Dispatch(r.forget());
|
||||||
|
@ -360,6 +365,8 @@ MediaDecoderReader::Shutdown()
|
||||||
mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__);
|
mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__);
|
||||||
mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__);
|
mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__);
|
||||||
|
|
||||||
|
mDataArrivedListener.DisconnectIfExists();
|
||||||
|
|
||||||
ReleaseMediaResources();
|
ReleaseMediaResources();
|
||||||
mDuration.DisconnectIfConnected();
|
mDuration.DisconnectIfConnected();
|
||||||
mBuffered.DisconnectAll();
|
mBuffered.DisconnectAll();
|
||||||
|
|
|
@ -428,6 +428,8 @@ private:
|
||||||
// "discontinuity" in the stream. For example after a seek.
|
// "discontinuity" in the stream. For example after a seek.
|
||||||
bool mAudioDiscontinuity;
|
bool mAudioDiscontinuity;
|
||||||
bool mVideoDiscontinuity;
|
bool mVideoDiscontinuity;
|
||||||
|
|
||||||
|
MediaEventListener mDataArrivedListener;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
Загрузка…
Ссылка в новой задаче