// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module media.stable.mojom;
import "media/mojo/mojom/encryption_pattern.mojom";
import "media/mojo/mojom/stable/native_pixmap_handle.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/values.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
// Maps to |media.mojom.VideoCodec|.
[Stable, Extensible]
enum VideoCodec {
[Default] kUnknown = 0,
kH264,
kVC1,
kMPEG2,
kMPEG4,
kTheora,
kVP8,
kVP9,
kHEVC,
kDolbyVision,
kAV1,
// DO NOT ADD RANDOM VIDEO CODECS!
//
// The only acceptable time to add a new codec is if there is production code
// that uses said codec in the same CL.
};
// Maps to |media.mojom.VideoCodecProfile|.
[Stable, Extensible]
enum VideoCodecProfile {
// Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
// for example), and keep the values for a particular format grouped
// together for clarity.
// Next version: 3
// Next value: 52
[Default] kVideoCodecProfileUnknown = -1,
kH264ProfileMin = 0,
kH264ProfileBaseline = kH264ProfileMin,
kH264ProfileMain = 1,
kH264ProfileExtended = 2,
kH264ProfileHigh = 3,
kH264ProfileHigh10 = 4,
kH264ProfileHigh422 = 5,
kH264ProfileHigh444Predictive = 6,
kH264ProfileScalableBaseline = 7,
kH264ProfileScalableHigh = 8,
kH264ProfileStereoHigh = 9,
kH264ProfileMultiviewHigh = 10,
kH264ProfileMax = kH264ProfileMultiviewHigh,
kVP8ProfileMin = 11,
kVP8ProfileAny = kVP8ProfileMin,
kVP8ProfileMax = kVP8ProfileAny,
kVP9ProfileMin = 12,
kVP9Profile0 = kVP9ProfileMin,
kVP9Profile1 = 13,
kVP9Profile2 = 14,
kVP9Profile3 = 15,
kVP9ProfileMax = kVP9Profile3,
kHEVCProfileMin = 16,
kHEVCProfileMain = kHEVCProfileMin,
kHEVCProfileMain10 = 17,
kHEVCProfileMainStillPicture = 18,
kHEVCProfileMax = kHEVCProfileMainStillPicture,
kDolbyVisionProfile0 = 19,
// DO NOT USE: Deprecated since DV Profile 4 not used anymore (b/292554162).
kDeprecatedDolbyVisionProfile4 = 20,
kDolbyVisionProfile5 = 21,
kDolbyVisionProfile7 = 22,
kTheoraProfileMin = 23,
kTheoraProfileAny = kTheoraProfileMin,
kTheoraProfileMax = kTheoraProfileAny,
kAV1ProfileMin = 24,
kAV1ProfileMain = kAV1ProfileMin,
kAV1ProfileHigh = 25,
kAV1ProfilePro = 26,
kAV1ProfileMax = kAV1ProfilePro,
kDolbyVisionProfile8 = 27,
kDolbyVisionProfile9 = 28,
[MinVersion=1] kHEVCProfileExtMin = 29,
[MinVersion=1] kHEVCProfileRext = kHEVCProfileExtMin,
[MinVersion=1] kHEVCProfileHighThroughput = 30,
[MinVersion=1] kHEVCProfileMultiviewMain = 31,
[MinVersion=1] kHEVCProfileScalableMain = 32,
[MinVersion=1] kHEVCProfile3dMain = 33,
[MinVersion=1] kHEVCProfileScreenExtended = 34,
[MinVersion=1] kHEVCProfileScalableRext = 35,
[MinVersion=1] kHEVCProfileHighThroughputScreenExtended = 36,
[MinVersion=1] kHEVCProfileExtMax = kHEVCProfileHighThroughputScreenExtended,
[MinVersion=2] kVVCProfileMin = 37,
[MinVersion=2] kVVCProfileMain10 = kVVCProfileMin,
[MinVersion=2] kVVCProfileMain12 = 38,
[MinVersion=2] kVVCProfileMain12Intra = 39,
[MinVersion=2] kVVCProfileMultilayerMain10 = 40,
[MinVersion=2] kVVCProfileMain10444 = 41,
[MinVersion=2] kVVCProfileMain12444 = 42,
[MinVersion=2] kVVCProfileMain16444 = 43,
[MinVersion=2] kVVCProfileMain12444Intra = 44,
[MinVersion=2] kVVCProfileMain16444Intra = 45,
[MinVersion=2] kVVCProfileMultilayerMain10444 = 46,
[MinVersion=2] kVVCProfileMain10Still = 47,
[MinVersion=2] kVVCProfileMain12Still = 48,
[MinVersion=2] kVVCProfileMain10444Still = 49,
[MinVersion=2] kVVCProfileMain12444Still = 50,
[MinVersion=2] kVVCProfileMain16444Still = 51,
[MinVersion=2] kVVCProileMax = kVVCProfileMain16444Still,
};
// Based on |media.mojom.SubsampleEntry|.
// Next min field ID: 2
[Stable]
struct SubsampleEntry {
uint32 clear_bytes@0;
uint32 cypher_bytes@1;
};
// Maps to |media.mojom.EncryptionScheme|.
[Stable, Extensible]
enum EncryptionScheme {
[Default] kUnencrypted = 0,
kCenc, // 'cenc' subsample encryption using AES-CTR mode.
kCbcs, // 'cbcs' pattern encryption using AES-CBC mode.
};
// Based on |media.mojom.DecryptConfig| but does not depend on
// |media.mojom.EncryptionScheme| and |media.mojom.SubsampleEntry|.
// Next min field ID: 5
[Stable]
struct DecryptConfig {
EncryptionScheme encryption_scheme@0;
string key_id@1;
string iv@2;
array<SubsampleEntry> subsamples@3;
media.mojom.EncryptionPattern? encryption_pattern@4;
};
// Based on |gfx.mojom.ColorVolumeMetadata|.
// Next min field ID: 6
[Stable]
struct ColorVolumeMetadata {
gfx.mojom.PointF primary_r@0;
gfx.mojom.PointF primary_g@1;
gfx.mojom.PointF primary_b@2;
gfx.mojom.PointF white_point@3;
float luminance_max@4;
float luminance_min@5;
};
// Based on |gfx.mojom.HDRMetadata| but does not depend on
// |gfx.mojom.ColorVolumeMetadata|.
// Next min field ID: 3
[Stable]
struct HDRMetadata {
ColorVolumeMetadata color_volume_metadata@0;
uint32 max_content_light_level@1;
uint32 max_frame_average_light_level@2;
};
// Based on |media.mojom.VideoDecoderConfig| but does not depend on
// |media.mojom.VideoCodec|, |media.mojom.VideoCodecProfile|,
// |media.mojom.VideoTransformation|, |media.mojom.EncryptionScheme|,
// |media.mojom.VideoColorSpace| and |gfx.mojom.HDRMetadata|.
// Next min field ID: 11
[Stable]
struct VideoDecoderConfig {
VideoCodec codec@0;
VideoCodecProfile profile@1;
uint32 level@2;
bool has_alpha@3;
gfx.mojom.Size coded_size@4;
gfx.mojom.Rect visible_rect@5;
gfx.mojom.Size natural_size@6;
array<uint8> extra_data@7;
EncryptionScheme encryption_scheme@8;
ColorSpace color_space_info@9;
HDRMetadata? hdr_metadata@10;
};
// Based on |media.mojom.SupportedVideoDecoderConfig| but does not
// depend on |media.mojom.VideoCodecProfile|
// Next min field ID: 6
[Stable]
struct SupportedVideoDecoderConfig {
// Range of VideoCodecProfiles to match, inclusive.
VideoCodecProfile profile_min@0;
VideoCodecProfile profile_max@1;
// Range of coded sizes to match, inclusive in each dimension.
gfx.mojom.Size coded_size_min@2;
gfx.mojom.Size coded_size_max@3;
// Match configs that have encryption configured.
bool allow_encrypted@4;
// Do not match configs that do not have encryption configured.
bool require_encrypted@5;
};
[Stable, Extensible]
enum StatusCode {
kOk_DEPRECATED,
kAborted,
[Default] kError,
};
// Based on |media.mojom.StatusData|.
// Next min field ID: 6
[Stable]
struct StatusData {
string group@0;
StatusCode code@1;
string message@2;
// This should ideally be a `mojo_base.mojom.ListValue`, but changing the wire
// format here is too twisted.
array<mojo_base.mojom.Value> frames@3;
StatusData? cause@4;
mojo_base.mojom.Value data@5;
};
// Based on |media.mojom.Status|.
// Next min field ID: 1
[Stable]
struct Status {
StatusData? internal@0;
};
// Based on |media.mojom.DecoderBufferSideData|.
// Next min field ID: 3
[Stable]
struct DecoderBufferSideData {
array<uint32> spatial_layers@0;
array<uint8> alpha_data@1;
uint64 secure_handle@2;
};
// Based on |media.mojom.DecoderBuffer| but does not depend on
// |media.mojom.DecryptConfig|.
// Next min field ID: 10
// Next version: 2
[Stable]
struct DecoderBuffer {
mojo_base.mojom.TimeDelta timestamp@0;
mojo_base.mojom.TimeDelta duration@1;
bool is_end_of_stream@2;
uint32 data_size@3;
bool is_key_frame@4;
// TODO(b/269383891): Deprecate |raw_side_data| in M120.
array<uint8> raw_side_data@5;
DecryptConfig? decrypt_config@6;
mojo_base.mojom.TimeDelta front_discard@7;
mojo_base.mojom.TimeDelta back_discard@8;
[MinVersion=1] DecoderBufferSideData? side_data@9;
};
// Maps to |media.mojom.VideoDecoderType|.
[Stable, Extensible]
enum VideoDecoderType {
[Default] kUnknown,
kVaapi,
kVda,
kV4L2,
kTesting,
};
// Maps to |gfx.mojom.ColorSpacePrimaryID|.
[Stable, Extensible]
enum ColorSpacePrimaryID {
[Default] kInvalid,
kBT709,
kBT470M,
kBT470BG,
kSMPTE170M,
kSMPTE240M,
kFilm,
kBT2020,
kSMPTEST428_1,
kSMPTEST431_2,
kSMPTEST432_1,
kXYZ_D50,
kAdobeRGB,
kAppleGenericRGB,
kWideGamutColorSpin,
kCustom,
[MinVersion=1] kEBU_3213_E,
};
// Maps to |gfx.mojom.ColorSpaceTransferID|.
[Stable, Extensible]
enum ColorSpaceTransferID {
[Default] kInvalid,
kBT709,
kBT709Apple,
kGamma18,
kGamma22,
kGamma24,
kGamma28,
kSMPTE170M,
kSMPTE240M,
kLinear,
kLog,
kLogSqrt,
kIEC61966_2_4,
kBT1361_ECG,
kIEC61966_2_1,
kBT2020_10,
kBT2020_12,
kSMPTEST2084,
kSMPTEST428_1,
kARIB_STD_B67,
kIEC61966_2_1_HDR,
kLinearHDR,
kCustom,
kCustomHDR,
kPiecewiseHDR,
[MinVersion=1] kScrgbLinear80Nits,
};
// Maps to |gfx.mojom.ColorSpaceMatrixID|.
[Stable, Extensible]
enum ColorSpaceMatrixID {
[Default] kInvalid,
kRGB,
kBT709,
kFCC,
kBT470BG,
kSMPTE170M,
kSMPTE240M,
kYCOCG,
// DO NOT USE: Deprecated since BT2020_CL not used anymore (b/333906350).
kBT2020_NCL,
kBT2020_CL,
kYDZDX,
kGBR,
};
// Maps to |gfx.mojom.ColorSpaceRangeID|.
[Stable, Extensible]
enum ColorSpaceRangeID {
[Default] kInvalid,
kLimited,
kFull,
kDerived,
};
// Based on |gfx.mojom.ColorSpace| but does not depend on
// |gfx.mojom.ColorSpacePrimaryID|, |gfx.mojom.ColorSpaceTransferID|,
// |gfx.mojom.ColorSpaceMatrixID| and |gfx.mojom.ColorSpaceRangeID|.
// Next min field ID: 6
[Stable]
struct ColorSpace {
ColorSpacePrimaryID primaries@0;
ColorSpaceTransferID transfer@1;
ColorSpaceMatrixID matrix@2;
ColorSpaceRangeID range@3;
array<float, 9> custom_primary_matrix@4;
array<float, 7> transfer_params@5;
};
// Maps to |media.mojom.VideoPixelFormat|.
[Stable, Extensible]
enum VideoPixelFormat {
[Default] kPixelFormatUnknown = 0, // Unknown or unspecified format value.
kPixelFormatI420 =
1, // 12bpp YUV planar 1x1 Y, 2x2 UV samples, a.k.a. YU12.
// Note: Chrome does not actually support YVU compositing, so you probably
// don't actually want to use this. See http://crbug.com/784627.
kPixelFormatYV12 = 2, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
kPixelFormatI422 = 3, // 16bpp YUV planar 1x1 Y, 2x1 UV samples.
kPixelFormatI420A = 4, // 20bpp YUVA planar 1x1 Y, 2x2 UV, 1x1 A samples.
kPixelFormatI444 = 5, // 24bpp YUV planar, no subsampling.
kPixelFormatNV12 =
6, // 12bpp with Y plane followed by a 2x2 interleaved UV plane.
kPixelFormatNV21 =
7, // 12bpp with Y plane followed by a 2x2 interleaved VU plane.
kPixelFormatUYVY =
8, // 16bpp interleaved 2x1 U, 1x1 Y, 2x1 V, 1x1 Y samples.
kPixelFormatYUY2 =
9, // 16bpp interleaved 1x1 Y, 2x1 U, 1x1 Y, 2x1 V samples.
kPixelFormatARGB = 10, // 32bpp BGRA (byte-order), 1 plane.
kPixelFormatXRGB = 11, // 24bpp BGRX (byte-order), 1 plane.
kPixelFormatRGB24 = 12, // 24bpp BGR (byte-order), 1 plane.
kPixelFormatMJPEG = 14, // MJPEG compressed.
// The P* in the formats below designates the number of bits per pixel
// component. I.e. P9 is 9-bits per pixel component, P10 is 10-bits per pixel
// component, etc.
kPixelFormatYUV420P9 = 16,
kPixelFormatYUV420P10 = 17,
kPixelFormatYUV422P9 = 18,
kPixelFormatYUV422P10 = 19,
kPixelFormatYUV444P9 = 20,
kPixelFormatYUV444P10 = 21,
kPixelFormatYUV420P12 = 22,
kPixelFormatYUV422P12 = 23,
kPixelFormatYUV444P12 = 24,
kPixelFormatY16 = 26, // single 16bpp plane.
kPixelFormatABGR = 27, // 32bpp RGBA (byte-order), 1 plane.
kPixelFormatXBGR = 28, // 24bpp RGBX (byte-order), 1 plane.
// 15bpp YUV planar 1x1 Y, 2x2 interleaved UV, 10 bits per channel.
// data in the high bits, zeros in the low bits, little-endian.
kPixelFormatP010LE = 29,
kPixelFormatXR30 =
30, // 32bpp BGRX, 10 bits per channel, 2 bits ignored, 1 plane
kPixelFormatXB30 =
31, // 32bpp RGBX, 10 bits per channel, 2 bits ignored, 1 plane
kPixelFormatBGRA = 32, // 32bpp ARGB (byte-order), 1 plane.
kPixelFormatRGBAF16 = 33, // Half float RGBA, 1 plane.
[MinVersion=1]
kPixelFormatI422A = 34, // 24bpp YUVA planar 1x1 Y, 2x1 UV, 1x1 A samples.
[MinVersion=1]
kPixelFormatI444A = 35, // 32bpp YUVA planar, no subsampling.
// YUVA planar, 10 bits per pixel component.
[MinVersion=1] kPixelFormatYUV420AP10 = 36,
[MinVersion=1] kPixelFormatYUV422AP10 = 37,
[MinVersion=1] kPixelFormatYUV444AP10 = 38,
// 20bpp YUVA planar 1x1 Y, 2x2 interleaved UV, 1x1 A samples.
[MinVersion=2] kPixelFormatNV12A = 39,
// 16bpp YUV planar 1x1 Y, 2x1 interleaved UV, 8 bits per channel.
[MinVersion=3] kPixelFormatNV16 = 40,
// 24bpp YUV planar 1x1 Y, 1x1 interleaved UV, 8 bits per channel.
[MinVersion=3] kPixelFormatNV24 = 41,
// 20bpp YUV planar 1x1 Y, 2x1 interleaved UV, 16 bits per channel.
// data in the high bits, zeros in the low bits, little-endian.
[MinVersion=3] kPixelFormatP210LE = 42,
// 30bpp YUV planar 1x1 Y, 1x1 interleaved UV, 16 bits per channel.
// data in the high bits, zeros in the low bits, little-endian.
[MinVersion=3] kPixelFormatP410LE = 43,
};
// Based on |gfx.mojom.GpuMemoryBufferHandle| but does not depend on
// |gfx.mojom.GpuMemoryBufferPlatformHandle|.
// Next min field ID: 2
[Stable]
struct NativeGpuMemoryBufferHandle {
gfx.mojom.GpuMemoryBufferId id@0;
NativePixmapHandle platform_handle@1;
};
// Based on |media.mojom.VideoFrameMetadata| but does not depend on
// |media.mojom.VideoTransformation|.
// Next min field ID: 3
// Next version: 2
[Stable]
struct VideoFrameMetadata {
bool protected_video@0;
bool hw_protected@1;
[MinVersion=1] bool needs_detiling@2;
};
// Based on |media.mojom.VideoFrame| but does not depend on
// |media.mojom.VideoPixelFormat|, |media.mojom.VideoFrameData|,
// |media.mojom.VideoFrameMetadata|, |gfx.mojom.ColorSpace| or
// or |gfx.mojom.HDRMetadata|.
// Next min field ID: 9
[Stable]
struct VideoFrame {
// Format of the frame.
VideoPixelFormat format@0;
// Width and height of the video frame, in pixels.
gfx.mojom.Size coded_size@1;
// Visible size of the frame.
gfx.mojom.Rect visible_rect@2;
// Natural size of the frame.
gfx.mojom.Size natural_size@3;
// Timestamp in microseconds of the associated frame.
mojo_base.mojom.TimeDelta timestamp@4;
// Contents of the video frame.
NativeGpuMemoryBufferHandle gpu_memory_buffer_handle@5;
// Extra properties associated with the VideoFrame.
VideoFrameMetadata metadata@6;
ColorSpace color_space@7;
HDRMetadata? hdr_metadata@8;
};
// Maps to |media.mojom.WaitingReason|.
[Stable, Extensible]
enum WaitingReason {
// The playback cannot start because "Media Data May Contain Encrypted Blocks"
// and no CDM is available. The playback will start after a CDM is set. See
// https://www.w3.org/TR/encrypted-media/#media-may-contain-encrypted-blocks
[Default] kNoCdm,
// The playback cannot proceed because some decryption key is not available.
// This could happen when the license exchange is delayed or failed. The
// playback will resume after the decryption key becomes available.
// See https://www.w3.org/TR/encrypted-media/#encrypted-block-encountered
kNoDecryptionKey,
// The playback cannot proceed because the decoder has lost its state, e.g.
// information about reference frames. Usually this only happens to hardware
// decoders. To recover from this state, reset the decoder and start decoding
// from a key frame, which can typically be accomplished by a pipeline seek.
kDecoderStateLost,
// The playback cannot proceed because the secure output surface is gone. This
// can happen when user backgrounds the page when it's playing secure content.
[MinVersion=1] kSecureSurfaceLost,
};
// Based on |media.mojom.MediaLogRecord|.
// Next min field ID: 4
[Stable]
struct MediaLogRecord {
[Stable, Extensible]
enum Type {
// See media/base/media_log_message_levels.h for info.
[Default] kMessage,
// See media/base/media_log_properties.h for info.
kMediaPropertyChange,
// See media/base/media_log_events.h for info.
kMediaEventTriggered,
kMediaStatus,
};
int32 id@0;
Type type@1;
mojo_base.mojom.DictionaryValue params@2;
mojo_base.mojom.TimeTicks time@3;
};
[Stable, Extensible]
enum DecryptStatus {
kSuccess,
kNoKey,
[Default] kFailure,
};
[Stable, Extensible]
enum CdmContextEvent {
// We use |kHasAdditionalUsableKey| as the default since this maps to an
// existing enum in Chrome that only has the two values below. Receiving an
// event for |kHasAdditionalUsableKey| is always safe because it is a benign
// indicator that if something was waiting for a key, it should check again.
// It is not an indicator that the key it actually wanted is ready.
[Default] kHasAdditionalUsableKey,
kHardwareContextReset,
};