Bug 1840965 - Move Flush to template r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D189016
This commit is contained in:
Chun-Min Chang 2023-10-02 15:54:01 +00:00
Родитель 6c5416a4a2
Коммит 17a6baba0e
4 изменённых файлов: 30 добавлений и 29 удалений

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

@ -217,6 +217,34 @@ void DecoderTemplate<DecoderType>::Decode(InputType& aInput, ErrorResult& aRv) {
ProcessControlMessageQueue();
}
template <typename DecoderType>
already_AddRefed<Promise> DecoderTemplate<DecoderType>::Flush(
ErrorResult& aRv) {
AssertIsOnOwningThread();
LOG("VideoDecoder %p, Flush", this);
if (mState != CodecState::Configured) {
LOG("VideoDecoder %p, wrong state!", this);
aRv.ThrowInvalidStateError("Decoder must be configured first");
return nullptr;
}
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return p.forget();
}
mKeyChunkRequired = true;
mControlMessageQueue.emplace(UniquePtr<ControlMessage>(
new FlushMessage(++mFlushCounter, mLatestConfigureId, p)));
LOG("VideoDecoder %p enqueues %s", this,
mControlMessageQueue.back()->ToString().get());
ProcessControlMessageQueue();
return p.forget();
}
template <typename DecoderType>
void DecoderTemplate<DecoderType>::Reset(ErrorResult& aRv) {
AssertIsOnOwningThread();

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

@ -157,6 +157,8 @@ class DecoderTemplate : public DOMEventTargetHelper {
virtual void Decode(InputType& aInput, ErrorResult& aRv);
virtual already_AddRefed<Promise> Flush(ErrorResult& aRv);
virtual void Reset(ErrorResult& aRv);
virtual void Close(ErrorResult& aRv);

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

@ -750,33 +750,6 @@ already_AddRefed<VideoDecoder> VideoDecoder::Constructor(
RefPtr<VideoFrameOutputCallback>(aInit.mOutput));
}
// https://w3c.github.io/webcodecs/#dom-videodecoder-flush
already_AddRefed<Promise> VideoDecoder::Flush(ErrorResult& aRv) {
AssertIsOnOwningThread();
LOG("VideoDecoder %p, Flush", this);
if (mState != CodecState::Configured) {
LOG("VideoDecoder %p, wrong state!", this);
aRv.ThrowInvalidStateError("Decoder must be configured first");
return nullptr;
}
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return p.forget();
}
mKeyChunkRequired = true;
mControlMessageQueue.emplace(UniquePtr<ControlMessage>(
new FlushMessage(++mFlushCounter, mLatestConfigureId, p)));
LOG("VideoDecoder %p enqueues %s", this,
mControlMessageQueue.back()->ToString().get());
ProcessControlMessageQueue();
return p.forget();
}
// https://w3c.github.io/webcodecs/#dom-videodecoder-isconfigsupported
/* static */
already_AddRefed<Promise> VideoDecoder::IsConfigSupported(

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

@ -90,8 +90,6 @@ class VideoDecoder final : public DecoderTemplate<VideoDecoderTraits> {
const GlobalObject& aGlobal, const VideoDecoderInit& aInit,
ErrorResult& aRv);
already_AddRefed<Promise> Flush(ErrorResult& aRv);
static already_AddRefed<Promise> IsConfigSupported(
const GlobalObject& aGlobal, const VideoDecoderConfig& aConfig,
ErrorResult& aRv);