blob: fc3410ce46075fb2a0c13a999d407bdbf3dfdfac [file] [log] [blame]
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module media.mojom;
import "media/mojo/mojom/media_types.mojom";
import "media/mojo/mojom/video_decoder.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/color_space.mojom";
[Native]
struct VideoDecodeAcceleratorConfig;
// Used by media clients to acquire new VideoDecoder instances from the GPU
// process.
interface GpuAcceleratedVideoDecoderProvider {
// Creates and initializes a new hardware video decoder instance.
[Sync]
CreateAcceleratedVideoDecoder(
VideoDecodeAcceleratorConfig config,
pending_associated_receiver<GpuAcceleratedVideoDecoder> receiver,
pending_associated_remote<GpuAcceleratedVideoDecoderClient> client)
=> (bool success);
};
[Native]
struct BitstreamBuffer;
// Links a set of texture IDs to a given PictureBuffer ID.
struct PictureBufferAssignment {
int32 buffer_id;
array<uint32> texture_ids;
};
// Interface to control a single hardware video decoder instance. This is
// implemented in the GPU process and called by renderer clients.
interface GpuAcceleratedVideoDecoder {
// Sends an input buffer for decoding.
Decode(BitstreamBuffer buffer);
// Give texture IDs for the textures to use for output.
AssignPictureBuffers(array<PictureBufferAssignment> assignments);
// Indicates that the given picture buffer can be recycled for subsequent
// decode operations.
ReusePictureBuffer(int32 picture_buffer_id);
// Flushes the decoder.
Flush() => ();
// Resets the decoder.
Reset() => ();
// Sends overlay info to the decoder.
SetOverlayInfo(OverlayInfo overlay_info);
};
// Client interface corresponding with a single AcceleratedVideoDecoder
// instance. This is implemented by renderer clients and called from by the GPU
// process.
interface GpuAcceleratedVideoDecoderClient {
// Notifies the client that deferred initialization has completed.
OnInitializationComplete(bool success);
// Notifies the client that an input buffer has been consumed.
OnBitstreamBufferProcessed(int32 buffer_id);
// Allocates video frames for decoder output.
OnProvidePictureBuffers(
uint32 num_frames, VideoPixelFormat format, uint32 num_textures_per_frame,
gfx.mojom.Size buffer_size, uint32 texture_target);
// Notifies the client that a picture is ready.
OnPictureReady(PictureReadyParams params);
// Notifies the client that a picture is ready and the buffer does not need to
// be passed back to the decoder.
OnDismissPictureBuffer(int32 buffer_id);
// Notifies the client of an error encountered by the decoder.
OnError(uint32 error_id);
};
// Parameters passed to AcceleratedVideoDecoderClient.OnPictureReady from the
// GPU process to the client renderer.
struct PictureReadyParams {
int32 picture_buffer_id;
int32 bitstream_buffer_id;
gfx.mojom.Rect visible_rect;
gfx.mojom.ColorSpace color_space;
bool allow_overlay;
bool read_lock_fences_enabled;
bool size_changed;
bool surface_texture;
bool wants_promotion_hint;
};