blob: 5448756c7c511e13472f9804ac0120240b7a874e [file] [log] [blame]
// Copyright 2014 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 "gpu/ipc/common/mailbox_holder.mojom";
import "mojo/common/time.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
// See media/base/buffering_state.h for descriptions.
enum BufferingState;
// See media/base/decode_status.h for descriptions.
enum DecodeStatus;
// See media/base/audio_codecs.h for descriptions.
enum AudioCodec;
// See media/base/channel_layout.h for descriptions.
enum ChannelLayout;
// See media/base/output_device_info.h for descriptions.
enum OutputDeviceStatus;
// See media/base/sample_format.h for descriptions.
enum SampleFormat;
// See media/base/video_types.h for descriptions.
enum VideoPixelFormat;
// See media/base/video_types.h for descriptions.
enum ColorSpace;
// See media/base/video_codecs.h for descriptions.
enum VideoCodec;
// See media/base/video_codecs.h for descriptions.
enum VideoCodecProfile;
// This defines a mojo transport format for media::EncryptionScheme::Pattern
// See media/base/encryption_scheme.h for description.
struct Pattern {
uint32 encrypt_blocks;
uint32 skip_blocks;
// This defines a mojo transport format for media::EncryptionScheme.
// See media/base/encryption_scheme.h for description.
struct EncryptionScheme {
enum CipherMode;
CipherMode mode;
Pattern pattern;
// This defines a mojo transport format for media::VideoColorSpace.
// See media/base/video_color_space.h for description.
struct VideoColorSpace {
enum PrimaryID;
enum TransferID;
enum MatrixID;
enum RangeID;
PrimaryID primaries;
TransferID transfer;
MatrixID matrix;
RangeID range;
// This defines a mojo transport format for media::HDRMetadata.
// See media/base/hdr_metadata.h for description.
struct MasteringMetadata {
gfx.mojom.PointF primary_r;
gfx.mojom.PointF primary_g;
gfx.mojom.PointF primary_b;
gfx.mojom.PointF white_point;
float luminance_max;
float luminance_min;
struct HDRMetadata {
MasteringMetadata mastering_metadata;
uint32 max_content_light_level;
uint32 max_frame_average_light_level;
// This defines a mojo transport format for media::AudioDecoderConfig.
// See media/base/audio_decoder_config.h for descriptions.
struct AudioDecoderConfig {
AudioCodec codec;
SampleFormat sample_format;
ChannelLayout channel_layout;
int32 samples_per_second;
array<uint8> extra_data;
mojo.common.mojom.TimeDelta seek_preroll;
int32 codec_delay;
EncryptionScheme encryption_scheme;
// This defines a mojo transport format for media::VideoDecoderConfig.
// See media/base/video_decoder_config.h for descriptions.
struct VideoDecoderConfig {
VideoCodec codec;
VideoCodecProfile profile;
VideoPixelFormat format;
ColorSpace color_space;
gfx.mojom.Size coded_size;
gfx.mojom.Rect visible_rect;
gfx.mojom.Size natural_size;
array<uint8> extra_data;
EncryptionScheme encryption_scheme;
VideoColorSpace color_space_info;
HDRMetadata? hdr_metadata;
// Native struct media::SubsampleEntry;
struct SubsampleEntry;
// This defines a mojo transport format for media::DecryptConfig.
// See media/base/decrypt_config.h for descriptions.
struct DecryptConfig {
string key_id;
string iv;
array<SubsampleEntry> subsamples;
// This defines a mojo transport format for media::DecoderBuffer.
struct DecoderBuffer {
mojo.common.mojom.TimeDelta timestamp;
mojo.common.mojom.TimeDelta duration;
// Whether the buffer is an end-of-stream (EOS) buffer.
bool is_end_of_stream;
// The number of bytes present in this buffer. The data is not serialized
// along with this structure and must be read from a separate DataPipe.
// Note that |data_size| could be zero even for a non-EOS buffer (e.g.
// with non-empty |size_data|). See
uint32 data_size;
// Indicates whether or not this buffer is a random access point.
bool is_key_frame;
// Empty when |side_data| doesn't exist.
array<uint8> side_data;
// DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
DecryptConfig? decrypt_config;
// These fields indicate the amount of data to discard after decoding.
mojo.common.mojom.TimeDelta front_discard;
mojo.common.mojom.TimeDelta back_discard;
// This defines a mojo transport format for media::AudioBuffer.
struct AudioBuffer {
// Format of the audio.
SampleFormat sample_format;
// How the channels are laid out.
ChannelLayout channel_layout;
// Number of channels.
int32 channel_count;
// Sample rate of the buffer.
int32 sample_rate;
// Number of frames in the buffer.
int32 frame_count;
// True if end of stream.
bool end_of_stream;
// Timestamp in microseconds of the first frame.
mojo.common.mojom.TimeDelta timestamp;
// Channel data. Will be empty for EOS buffers.
array<uint8> data;
// This defines a mojo transport format for media::VideoFrame.
struct VideoFrame {
// Format of the frame.
VideoPixelFormat format;
// Width and height of the video frame, in pixels.
gfx.mojom.Size coded_size;
// Visible size of the frame.
gfx.mojom.Rect visible_rect;
// Natural size of the frame.
gfx.mojom.Size natural_size;
// Timestamp in microseconds of the associated frame.
mojo.common.mojom.TimeDelta timestamp;
// Contents of the video frame (or EOS marker).
VideoFrameData data;
// Possible choices for storing VideoFrame data.
union VideoFrameData {
EosVideoFrameData eos_data;
SharedBufferVideoFrameData shared_buffer_data;
MailboxVideoFrameData mailbox_data;
// A marker for EOS frames.
struct EosVideoFrameData {
// This defines video frame data stored in a Mojo shared buffer.
struct SharedBufferVideoFrameData {
// Reference to the shared memory containing the frame's data.
handle<shared_buffer> frame_data;
uint64 frame_data_size;
// Stride and offsets for each plane. Offsets are relative to the start
// of |frame_data|.
int32 y_stride;
int32 u_stride;
int32 v_stride;
uint64 y_offset;
uint64 u_offset;
uint64 v_offset;
// This defines video frame data stored in texture mailboxes.
struct MailboxVideoFrameData {
// Size must be kept in sync with media::VideoFrame::kMaxPlanes.
array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
struct PipelineStatistics {
uint64 audio_bytes_decoded;
uint64 video_bytes_decoded;
uint32 video_frames_decoded;
uint32 video_frames_dropped;
int64 audio_memory_usage;
int64 video_memory_usage;