summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h')
-rw-r--r--chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h b/chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h
index 58522f721af..bc186b60c84 100644
--- a/chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h
+++ b/chromium/third_party/blink/renderer/modules/webcodecs/decoder_template.h
@@ -22,6 +22,7 @@
#include "third_party/blink/renderer/modules/webcodecs/codec_logger.h"
#include "third_party/blink/renderer/modules/webcodecs/codec_trace_names.h"
#include "third_party/blink/renderer/modules/webcodecs/hardware_preference.h"
+#include "third_party/blink/renderer/modules/webcodecs/reclaimable_codec.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
@@ -39,6 +40,7 @@ template <typename Traits>
class MODULES_EXPORT DecoderTemplate
: public ScriptWrappable,
public ActiveScriptWrappable<DecoderTemplate<Traits>>,
+ public ReclaimableCodec,
public ExecutionContextLifecycleObserver {
public:
typedef typename Traits::ConfigType ConfigType;
@@ -99,8 +101,12 @@ class MODULES_EXPORT DecoderTemplate
// |chunk|. If there is an error in the conversion process, the resulting
// DecoderBuffer will be null, and |out_status| will contain a description of
// the error.
+ //
+ // When |verify_key_frame| is true, clients are expected to verify and set the
+ // DecoderBuffer::is_key_frame() value. I.e., they must process the encoded
+ // data to ensure the value is actually what the chunk says it is.
virtual media::StatusOr<scoped_refptr<media::DecoderBuffer>>
- MakeDecoderBuffer(const InputType& chunk) = 0;
+ MakeDecoderBuffer(const InputType& chunk, bool verify_key_frame) = 0;
private:
struct Request final : public GarbageCollected<Request> {
@@ -154,6 +160,9 @@ class MODULES_EXPORT DecoderTemplate
void ProcessRequests();
bool ProcessConfigureRequest(Request* request);
+ void ContinueConfigureWithGpuFactories(
+ Request* request,
+ media::GpuVideoAcceleratorFactories* factories);
bool ProcessDecodeRequest(Request* request);
bool ProcessFlushRequest(Request* request);
bool ProcessResetRequest(Request* request);
@@ -170,6 +179,9 @@ class MODULES_EXPORT DecoderTemplate
// Helper function making it easier to check |state_|.
bool IsClosed();
+ // ReclaimableCodec implementation.
+ void OnCodecReclaimed(DOMException*) override;
+
void TraceQueueSizes() const;
Member<ScriptState> script_state_;
@@ -191,7 +203,9 @@ class MODULES_EXPORT DecoderTemplate
std::unique_ptr<CodecLogger> logger_;
- media::GpuVideoAcceleratorFactories* gpu_factories_ = nullptr;
+ // Empty - GPU factories haven't been retrieved yet.
+ // nullptr - We tried to get GPU factories, but acceleration is unavailable.
+ absl::optional<media::GpuVideoAcceleratorFactories*> gpu_factories_;
// Cached config from the last kConfigure request which successfully completed
// initialization.
@@ -210,6 +224,9 @@ class MODULES_EXPORT DecoderTemplate
int trace_counter_id_;
HeapHashMap<uint32_t, Member<Request>> pending_decodes_;
+
+ // Keyframes are required after configure(), flush(), and reset().
+ bool require_key_frame_ = true;
};
} // namespace blink