Upload upstream chromium 85.0.4183.84
[platform/framework/web/chromium-efl.git] / media / mojo / mojom / media_types.mojom
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module media.mojom;
6
7 import "gpu/ipc/common/mailbox_holder.mojom";
8 import "gpu/ipc/common/vulkan_ycbcr_info.mojom";
9 import "mojo/public/mojom/base/time.mojom";
10 import "mojo/public/mojom/base/values.mojom";
11 import "mojo/public/mojom/base/unguessable_token.mojom";
12 import "ui/gfx/geometry/mojom/geometry.mojom";
13 import "ui/gfx/mojom/buffer_types.mojom";
14 import "ui/gfx/mojom/color_space.mojom";
15
16 // See media/base/audio_codecs.h for descriptions.
17 [Native]
18 enum AudioCodec;
19 [Native]
20 enum AudioCodecProfile;
21
22 // See media/base/buffering_state.h for descriptions.
23 [Native]
24 enum BufferingState;
25 [Native]
26 enum BufferingStateChangeReason;
27
28 // See media/base/channel_layout.h for descriptions.
29 [Native]
30 enum ChannelLayout;
31
32 // See media/base/decode_status.h for descriptions.
33 [Native]
34 enum DecodeStatus;
35
36 // See media/base/status_codes.h for descriptions.
37 [Native]
38 enum StatusCode;
39
40 // See media/base/media_log_record.h for description.
41 [Native]
42 struct MediaLogRecord;
43
44 // See media/base/output_device_info.h for descriptions.
45 [Native]
46 enum OutputDeviceStatus;
47
48 // See media/base/pipeline_status.h for descriptions.
49 [Native]
50 enum PipelineStatus;
51
52 // See media/base/sample_format.h for descriptions.
53 [Native]
54 enum SampleFormat;
55
56 // See media/base/video_codecs.h for descriptions.
57 [Native]
58 enum VideoCodec;
59
60 // See media/base/video_codecs.h for descriptions.
61 [Native]
62 enum VideoCodecProfile;
63
64 // See media/base/video_types.h for descriptions.
65 [Native]
66 enum VideoPixelFormat;
67
68 // See media/base/video_transformation.h for descriptions.
69 enum VideoRotation {
70   kVideoRotation0,
71   kVideoRotation90,
72   kVideoRotation180,
73   kVideoRotation270,
74 };
75
76 // See media/base/video_transformation.h for descriptions.
77 struct VideoTransformation {
78   VideoRotation rotation;
79   bool mirrored;
80 };
81
82 // See media/base/waiting.h for descriptions.
83 [Native]
84 enum WaitingReason;
85
86 // See media/base/watch_time_keys.h for descriptions.
87 [Native]
88 enum WatchTimeKey;
89
90 // See media/base/container_names.h for descriptions.
91 [Native]
92 enum MediaContainerName;
93
94 // See media/base/media_status.h for description.
95 [Native]
96 enum MediaStatusState;
97
98 // This defines a mojo transport format for media::EncryptionPattern
99 // See media/base/encryption_pattern.h for description.
100 struct EncryptionPattern {
101   uint32 crypt_byte_block;
102   uint32 skip_byte_block;
103 };
104
105 // See media/base/encryption_scheme.h for description.
106 [Native]
107 enum EncryptionScheme;
108
109 // This defines a mojo transport format for media::VideoColorSpace.
110 // See media/base/video_color_space.h for description.
111 struct VideoColorSpace {
112   [Native]
113   enum PrimaryID;
114
115   [Native]
116   enum TransferID;
117
118   [Native]
119   enum MatrixID;
120
121   [Native]
122   enum RangeID;
123
124   PrimaryID primaries;
125   TransferID transfer;
126   MatrixID matrix;
127   RangeID range;
128 };
129
130 // This defines a mojo transport format for media::HDRMetadata.
131 // See media/base/hdr_metadata.h for description.
132 struct MasteringMetadata {
133   gfx.mojom.PointF primary_r;
134   gfx.mojom.PointF primary_g;
135   gfx.mojom.PointF primary_b;
136   gfx.mojom.PointF white_point;
137   float luminance_max;
138   float luminance_min;
139 };
140
141 struct HDRMetadata {
142   MasteringMetadata mastering_metadata;
143   uint32 max_content_light_level;
144   uint32 max_frame_average_light_level;
145 };
146
147 // This defines a mojo transport format for media::AudioDecoderConfig.
148 // See media/base/audio_decoder_config.h for descriptions.
149 struct AudioDecoderConfig {
150   AudioCodec codec;
151   AudioCodecProfile profile;
152   SampleFormat sample_format;
153   ChannelLayout channel_layout;
154   int32 samples_per_second;
155   array<uint8> extra_data;
156   mojo_base.mojom.TimeDelta seek_preroll;
157   int32 codec_delay;
158   EncryptionScheme encryption_scheme;
159 };
160
161 // This defines a mojo transport format for media::VideoDecoderConfig.
162 // See media/base/video_decoder_config.h for descriptions.
163 struct VideoDecoderConfig {
164   VideoCodec codec;
165   VideoCodecProfile profile;
166   uint32 level;
167   bool has_alpha;
168   VideoTransformation transformation;
169   gfx.mojom.Size coded_size;
170   gfx.mojom.Rect visible_rect;
171   gfx.mojom.Size natural_size;
172   array<uint8> extra_data;
173   EncryptionScheme encryption_scheme;
174   VideoColorSpace color_space_info;
175   HDRMetadata? hdr_metadata;
176 };
177
178 // Native struct media::SubsampleEntry;
179 [Native]
180 struct SubsampleEntry;
181
182 // This defines a mojo transport format for media::DecryptConfig.
183 // See media/base/decrypt_config.h for descriptions.
184 struct DecryptConfig {
185   EncryptionScheme encryption_scheme;
186   string key_id;
187   string iv;
188   array<SubsampleEntry> subsamples;
189   EncryptionPattern? encryption_pattern;
190 };
191
192 // This defines a mojo transport format for media::DecoderBuffer.
193 struct DecoderBuffer {
194   mojo_base.mojom.TimeDelta timestamp;
195   mojo_base.mojom.TimeDelta duration;
196
197   // Whether the buffer is an end-of-stream (EOS) buffer.
198   bool is_end_of_stream;
199
200   // The number of bytes present in this buffer. The data is not serialized
201   // along with this structure and must be read from a separate DataPipe.
202   // Note that |data_size| could be zero even for a non-EOS buffer (e.g.
203   // with non-empty |size_data|). See http://crbug.com/663438
204   uint32 data_size;
205
206   // Indicates whether or not this buffer is a random access point.
207   bool is_key_frame;
208
209   // Empty when |side_data| doesn't exist.
210   array<uint8> side_data;
211
212   // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
213   DecryptConfig? decrypt_config;
214
215   // These fields indicate the amount of data to discard after decoding.
216   mojo_base.mojom.TimeDelta front_discard;
217   mojo_base.mojom.TimeDelta back_discard;
218 };
219
220 // This defines a mojo transport format for media::AudioBuffer.
221 struct AudioBuffer {
222   // Format of the audio.
223   SampleFormat sample_format;
224
225   // How the channels are laid out.
226   ChannelLayout channel_layout;
227
228   // Number of channels.
229   int32 channel_count;
230
231   // Sample rate of the buffer.
232   int32 sample_rate;
233
234   // Number of frames in the buffer.
235   int32 frame_count;
236
237   // True if end of stream.
238   bool end_of_stream;
239
240   // Timestamp in microseconds of the first frame.
241   mojo_base.mojom.TimeDelta timestamp;
242
243   // Channel data. Will be empty for EOS buffers.
244   array<uint8> data;
245 };
246
247 // This defines a mojo transport format for an interleaved, signed
248 // 16-bit audio buffer.
249 struct AudioDataS16 {
250   // Number of channels.
251   int32 channel_count;
252
253   // Sample rate of the buffer.
254   int32 sample_rate;
255
256   // Number of frames in the buffer.
257   int32 frame_count;
258
259   // Channel data.
260   array<int16> data;
261 };
262
263 // See media/base/video_frame_metadata.h for a description of fields.
264 // TODO(crbug.com/657632): Remove |has_*| values and use nullable types.
265 struct VideoFrameMetadata {
266   bool allow_overlay;
267
268   mojo_base.mojom.TimeTicks? capture_begin_time;
269   mojo_base.mojom.TimeTicks? capture_end_time;
270
271   bool has_capture_counter;
272   int32 capture_counter;
273
274   gfx.mojom.Rect? capture_update_rect;
275
276   bool copy_required;
277
278   bool end_of_stream;
279
280   mojo_base.mojom.TimeDelta? frame_duration;
281
282   bool has_frame_rate;
283   double frame_rate;
284
285   bool interactive_content;
286
287   mojo_base.mojom.TimeTicks? reference_time;
288
289   bool has_resource_utilization;
290   double resource_utilization;
291
292   bool read_lock_fences_enabled;
293
294   bool has_rotation;
295   VideoRotation rotation;
296
297   bool texture_owner;
298
299   bool wants_promotion_hint;
300
301   bool protected_video;
302
303   bool hw_protected;
304
305   mojo_base.mojom.UnguessableToken? overlay_plane_id;
306
307   bool power_efficient;
308
309   bool has_device_scale_factor;
310   double device_scale_factor;
311
312   bool has_page_scale_factor;
313   double page_scale_factor;
314
315   bool has_root_scroll_offset_x;
316   double root_scroll_offset_x;
317
318   bool has_root_scroll_offset_y;
319   double root_scroll_offset_y;
320
321   bool has_top_controls_visible_height;
322   double top_controls_visible_height;
323
324   mojo_base.mojom.TimeTicks? decode_begin_time;
325   mojo_base.mojom.TimeTicks? decode_end_time;
326
327   mojo_base.mojom.TimeDelta? processing_time;
328
329   bool has_rtp_timestamp;
330   double rtp_timestamp;
331
332   mojo_base.mojom.TimeTicks? receive_time;
333
334   mojo_base.mojom.TimeDelta? wallclock_frame_duration;
335 };
336
337 // This defines a mojo transport format for media::VideoFrame.
338 struct VideoFrame {
339   // Format of the frame.
340   VideoPixelFormat format;
341
342   // Width and height of the video frame, in pixels.
343   gfx.mojom.Size coded_size;
344
345   // Visible size of the frame.
346   gfx.mojom.Rect visible_rect;
347
348   // Natural size of the frame.
349   gfx.mojom.Size natural_size;
350
351   // Timestamp in microseconds of the associated frame.
352   mojo_base.mojom.TimeDelta timestamp;
353
354   // Contents of the video frame (or EOS marker).
355   VideoFrameData data;
356
357   // Extra properties associated with the VideoFrame.
358   VideoFrameMetadata metadata;
359
360   gfx.mojom.ColorSpace color_space;
361   HDRMetadata? hdr_metadata;
362 };
363
364 // Possible choices for storing VideoFrame data.
365 union VideoFrameData {
366   EosVideoFrameData eos_data;
367   SharedBufferVideoFrameData shared_buffer_data;
368   DmabufVideoFrameData dmabuf_data;
369   GpuMemoryBufferVideoFrameData gpu_memory_buffer_data;
370   MailboxVideoFrameData mailbox_data;
371 };
372
373 // A marker for EOS frames.
374 struct EosVideoFrameData {
375 };
376
377 // This defines video frame data stored in a Mojo shared buffer.
378 struct SharedBufferVideoFrameData {
379   // Reference to the shared memory containing the frame's data.
380   handle<shared_buffer> frame_data;
381   uint64 frame_data_size;
382
383   // Stride and offsets for each plane. Offsets are relative to the start
384   // of |frame_data|.
385   array<int32> strides;
386   array<uint32> offsets;
387 };
388
389 // This defines video frame data stored in dmabuf.
390 struct DmabufVideoFrameData {
391   // Size depends on media::VideoFrame::NumPlanes with frame format.
392   array<handle<platform>> dmabuf_fds;
393 };
394
395 struct GpuMemoryBufferVideoFrameData {
396   gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
397   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
398 };
399
400 // This defines video frame data stored in texture mailboxes.
401 struct MailboxVideoFrameData {
402   // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
403   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
404   gpu.mojom.VulkanYCbCrInfo? ycbcr_data;
405 };
406
407 struct PipelineStatistics {
408   uint64 audio_bytes_decoded;
409   uint64 video_bytes_decoded;
410   uint32 video_frames_decoded;
411   uint32 video_frames_dropped;
412   int64 audio_memory_usage;
413   int64 video_memory_usage;
414 };
415
416 // Set of features for MediaCapabilities prediction.
417 // TODO(liberato): consider generalizing this.
418 struct PredictionFeatures {
419     // It would be nice to initialize this to VIDEO_CODEC_PROFILE_UNKNOWN (-1),
420     // but we can't do that with native enums.
421     VideoCodecProfile profile;
422     gfx.mojom.Size video_size;
423     // Frames per second may ultimately be a bucketed as an integer, but we want
424     // to do that as late as possible. Using a double avoids early truncation.
425     double frames_per_sec = 0;
426     // Name of the key system used for EME playbacks.
427     string key_system;
428     // Indicates when CDM will use HW secure decoding for EME playbacks.
429     bool use_hw_secure_codecs = false;
430 };
431
432 // Target values for MediaCapabilities predictions.
433 // TODO(liberato): consider generalizing this.
434 struct PredictionTargets {
435   uint32 frames_decoded = 0;
436   uint32 frames_dropped = 0;
437   uint32 frames_power_efficient = 0;
438 };
439
440 // See media/base/pipeline/status.h for descriptions.
441 struct PipelineDecoderInfo {
442   string decoder_name;
443   bool is_platform_decoder = false;
444   bool has_decrypting_demuxer_stream = false;
445 };
446
447 // See media/base/status.h for descriptions.
448 struct Status {
449   StatusCode code;
450   string? message;
451   array<mojo_base.mojom.Value> frames;
452   array<media.mojom.Status> causes;
453   mojo_base.mojom.Value? data;
454 };