summaryrefslogtreecommitdiffstats
path: root/media/mojo/interfaces/media_types.mojom
blob: 91f1619822b6cb04d880909e87f33edf3e812d70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// 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.interfaces;

import "ui/mojo/geometry/geometry.mojom";

// See media/base/buffering_state.h for descriptions.
// Kept in sync with media::BufferingState via static_asserts.
enum BufferingState {
  HAVE_NOTHING,
  HAVE_ENOUGH,
};

// See media/base/audio_decoder_config.h for descriptions.
// Kept in sync with media::AudioCodec via static_asserts.
enum AudioCodec {
  UNKNOWN = 0,
  AAC = 1,
  MP3 = 2,
  PCM = 3,
  Vorbis = 4,
  FLAC = 5,
  AMR_NB = 6,
  AMR_WB = 7,
  PCM_MULAW = 8,
  GSM_MS = 9,
  PCM_S16BE = 10,
  PCM_S24BE = 11,
  Opus = 12,
  EAC3 = 13,
  PCM_ALAW = 14,
  ALAC = 15,
  AC3 = 16,
  MAX = AC3,
};

// See media/base/channel_layout.h for descriptions.
// Kept in sync with media::ChannelLayout via static_asserts.
enum ChannelLayout {
  k_NONE = 0,
  k_UNSUPPORTED = 1,
  k_MONO = 2,
  k_STEREO = 3,
  k_2_1 = 4,
  k_SURROUND = 5,
  k_4_0 = 6,
  k_2_2 = 7,
  k_QUAD = 8,
  k_5_0 = 9,
  k_5_1 = 10,
  k_5_0_BACK = 11,
  k_5_1_BACK = 12,
  k_7_0 = 13,
  k_7_1 = 14,
  k_7_1_WIDE = 15,
  k_STEREO_DOWNMIX = 16,
  k_2POINT1 = 17,
  k_3_1 = 18,
  k_4_1 = 19,
  k_6_0 = 20,
  k_6_0_FRONT = 21,
  k_HEXAGONAL = 22,
  k_6_1 = 23,
  k_6_1_BACK = 24,
  k_6_1_FRONT = 25,
  k_7_0_FRONT = 26,
  k_7_1_WIDE_BACK = 27,
  k_OCTAGONAL = 28,
  k_DISCRETE = 29,
  k_STEREO_AND_KEYBOARD_MIC = 30,
  k_4_1_QUAD_SIDE = 31,
  k_MAX = k_4_1_QUAD_SIDE,
};

// See media/base/sample_format.h for descriptions.
// Kept in sync with media::SampleFormat via static_asserts.
enum SampleFormat {
  UNKNOWN = 0,
  U8,
  S16,
  S32,
  F32,
  PlanarS16,
  PlanarF32,
  PlanarS32,
  S24,
  Max = S24,
};

// See media/base/video_types.h for descriptions.
// Kept in sync with media::VideoPixelFormat via static_asserts.
enum VideoFormat {
  UNKNOWN = 0,
  I420,
  YV12,
  YV16,
  YV12A,
  YV24,
  NV12,
  NV21,
  UYVY,
  YUY2,
  ARGB,
  XRGB,
  RGB24,
  RGB32,
  MJPEG,
  MT21,
  FORMAT_MAX = MT21,
};

// Kept in sync with media::ColorSpace via static_asserts.
enum ColorSpace {
  UNSPECIFIED = 0,
  JPEG = 1,
  HD_REC709 = 2,
  SD_REC601 = 3,
  MAX = SD_REC601,
};

// See media/base/video_decoder_config.h for descriptions.
// Kept in sync with media::VideoCodec via static_asserts.
enum VideoCodec {
  UNKNOWN = 0,
  H264,
  VC1,
  MPEG2,
  MPEG4,
  Theora,
  VP8,
  VP9,
  HEVC,
  Max = HEVC,
};

// See media/base/video_decoder_config.h for descriptions.
// Kept in sync with media::VideoCodecProfile via static_asserts.
enum VideoCodecProfile {
  VIDEO_CODEC_PROFILE_UNKNOWN = -1,
  VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
  H264PROFILE_MIN = 0,
  H264PROFILE_BASELINE = H264PROFILE_MIN,
  H264PROFILE_MAIN = 1,
  H264PROFILE_EXTENDED = 2,
  H264PROFILE_HIGH = 3,
  H264PROFILE_HIGH10PROFILE = 4,
  H264PROFILE_HIGH422PROFILE = 5,
  H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
  H264PROFILE_SCALABLEBASELINE = 7,
  H264PROFILE_SCALABLEHIGH = 8,
  H264PROFILE_STEREOHIGH = 9,
  H264PROFILE_MULTIVIEWHIGH = 10,
  H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
  VP8PROFILE_MIN = 11,
  VP8PROFILE_ANY = VP8PROFILE_MIN,
  VP8PROFILE_MAX = VP8PROFILE_ANY,
  VP9PROFILE_MIN = 12,
  VP9PROFILE_ANY = VP9PROFILE_MIN,
  VP9PROFILE_MAX = VP9PROFILE_ANY,
  VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_MAX,
};

// 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;
  int64 seek_preroll_usec;
  int32 codec_delay;
  bool is_encrypted;
};

// This defines a mojo transport format for media::VideoDecoderConfig.
// See media/base/video_decoder_config.h for descriptions.
struct VideoDecoderConfig {
  VideoCodec codec;
  VideoCodecProfile profile;
  VideoFormat format;
  ColorSpace color_space;
  mojo.Size coded_size;
  mojo.Rect visible_rect;
  mojo.Size natural_size;
  array<uint8>? extra_data;
  bool is_encrypted;
};

// This defines a mojo transport format for media::SubsampleEntry.
// See media/base/decrypt_config.h for descriptions.
struct SubsampleEntry {
  uint32 clear_bytes;
  uint32 cypher_bytes;
};

// 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 {
  int64 timestamp_usec;
  int64 duration_usec;

  // 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.
  uint32 data_size;

  // Indicates whether or not this buffer is a random access point.
  bool is_key_frame;

  // This is backed by an std::vector and results in a few copies.
  // Into the vector, onto and off the MessagePipe, back into a vector.
  array<uint8>? side_data;
  uint32 side_data_size;

  // 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.
  int64 front_discard_usec;
  int64 back_discard_usec;

  // Indicates this buffer is part of a splice around |splice_timestamp_usec|.
  int64 splice_timestamp_usec;
};

// 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.
  int64 timestamp_usec;

  // Channel data. Will be null for EOS buffers.
  array<uint8>? data;
};

// This defines a mojo transport format for media::VideoFrame.
// TODO(jrummell): Support shared memory based VideoFrame to avoid copying
// the data multiple times.
struct VideoFrame {
  // Format of the frame.
  VideoFormat format;

  // Width and height of the video frame, in pixels.
  mojo.Size coded_size;

  // Visible size of the frame.
  mojo.Rect visible_rect;

  // Natural size of the frame.
  mojo.Size natural_size;

  // True if end of stream.
  bool end_of_stream;

  // Timestamp in microseconds of the associated frame.
  int64 timestamp_usec;

  // Frame data for each plane. Will be null for EOS buffers.
  array<uint8>? y_data;
  array<uint8>? u_data;
  array<uint8>? v_data;
};