Upload upstream chromium 94.0.4606.31
[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 import "ui/gfx/mojom/hdr_metadata.mojom";
16
17 // See media/base/audio_codecs.h for descriptions.
18 [Native]
19 enum AudioCodec;
20 [Native]
21 enum AudioCodecProfile;
22
23 // See media/base/buffering_state.h for descriptions.
24 [Native]
25 enum BufferingState;
26 [Native]
27 enum BufferingStateChangeReason;
28
29 // See media/base/channel_layout.h for descriptions.
30 [Native]
31 enum ChannelLayout;
32
33 // See media/base/decode_status.h for descriptions.
34 [Native]
35 enum DecodeStatus;
36
37 // See media/base/status_codes.h for descriptions.
38 [Native]
39 enum StatusCode;
40
41 // See media/base/media_content_type.h for descriptions.
42 [Native]
43 enum MediaContentType;
44
45 // See media/base/media_log_record.h for description.
46 [Native]
47 struct MediaLogRecord;
48
49 // See media/base/output_device_info.h for descriptions.
50 [Native]
51 enum OutputDeviceStatus;
52
53 // See media/base/pipeline_status.h for descriptions.
54 [Native]
55 enum PipelineStatus;
56
57 // See media/base/sample_format.h for descriptions.
58 [Native]
59 enum SampleFormat;
60
61 // See media/base/video_codecs.h for descriptions.
62 [Native]
63 enum VideoCodec;
64
65 // See media/base/video_codecs.h for descriptions.
66 [Native]
67 enum VideoCodecProfile;
68
69 // See media/base/video_types.h for descriptions.
70 [Native]
71 enum VideoPixelFormat;
72
73 // See media/base/decoder.h for descriptions.
74 [Native]
75 enum VideoDecoderType;
76
77 // See media/base/decoder.h for descriptions.
78 [Native]
79 enum AudioDecoderType;
80
81 // See media/base/video_transformation.h for descriptions.
82 enum VideoRotation {
83   kVideoRotation0,
84   kVideoRotation90,
85   kVideoRotation180,
86   kVideoRotation270,
87 };
88
89 // see media/base/video_frame_metadata.h for descriptions.
90 enum CopyMode {
91   kCopyToNewTexture,
92   kCopyMailboxesOnly,
93 };
94
95 // see third_party/blink/public/platform/web_fullscreen_video_status.h for
96 // descriptions.
97 [Native]
98 enum FullscreenVideoStatus;
99
100 // See media/base/video_transformation.h for descriptions.
101 struct VideoTransformation {
102   VideoRotation rotation;
103   bool mirrored;
104 };
105
106 // See media/base/waiting.h for descriptions.
107 [Native]
108 enum WaitingReason;
109
110 // See media/base/watch_time_keys.h for descriptions.
111 [Native]
112 enum WatchTimeKey;
113
114 // See media/base/container_names.h for descriptions.
115 [Native]
116 enum MediaContainerName;
117
118 // See media/base/media_status.h for description.
119 [Native]
120 enum MediaStatusState;
121
122 // This defines a mojo transport format for media::EncryptionPattern
123 // See media/base/encryption_pattern.h for description.
124 struct EncryptionPattern {
125   uint32 crypt_byte_block;
126   uint32 skip_byte_block;
127 };
128
129 // See media/base/encryption_scheme.h for description.
130 [Native]
131 enum EncryptionScheme;
132
133 // See media::EncryptionType for descriptions.
134 enum EncryptionType {
135   kNone,
136   kClear,
137   kEncrypted,
138   kEncryptedWithClearLead,
139 };
140
141 // This defines a mojo transport format for media::VideoColorSpace.
142 // See media/base/video_color_space.h for description.
143 struct VideoColorSpace {
144   [Native]
145   enum PrimaryID;
146
147   [Native]
148   enum TransferID;
149
150   [Native]
151   enum MatrixID;
152
153   [Native]
154   enum RangeID;
155
156   PrimaryID primaries;
157   TransferID transfer;
158   MatrixID matrix;
159   RangeID range;
160 };
161
162 // This defines a mojo transport format for media::AudioDecoderConfig.
163 // See media/base/audio_decoder_config.h for descriptions.
164 // TODO(crbug.com/1232205): Support `channels_` set by SetChannelsForDiscrete().
165 struct AudioDecoderConfig {
166   AudioCodec codec;
167   SampleFormat sample_format;
168   ChannelLayout channel_layout;
169   int32 samples_per_second;
170   array<uint8> extra_data;
171   EncryptionScheme encryption_scheme;
172   mojo_base.mojom.TimeDelta seek_preroll;
173   int32 codec_delay;
174   AudioCodecProfile profile;
175   ChannelLayout target_output_channel_layout;
176   bool should_discard_decoder_delay;
177 };
178
179 // This defines a mojo transport format for media::VideoDecoderConfig.
180 // See media/base/video_decoder_config.h for descriptions.
181 struct VideoDecoderConfig {
182   VideoCodec codec;
183   VideoCodecProfile profile;
184   uint32 level;
185   bool has_alpha;
186   VideoTransformation transformation;
187   gfx.mojom.Size coded_size;
188   gfx.mojom.Rect visible_rect;
189   gfx.mojom.Size natural_size;
190   array<uint8> extra_data;
191   EncryptionScheme encryption_scheme;
192   VideoColorSpace color_space_info;
193   gfx.mojom.HDRMetadata? hdr_metadata;
194 };
195
196 // Native struct media::SubsampleEntry;
197 [Native]
198 struct SubsampleEntry;
199
200 // See media::CdmSessionClosedReason for descriptions.
201 enum CdmSessionClosedReason {
202   kInternalError,
203   kClose,
204   kReleaseAcknowledged,
205   kHardwareContextReset,
206   kResourceEvicted,
207 };
208
209 // This defines a mojo transport format for media::DecryptConfig.
210 // See media/base/decrypt_config.h for descriptions.
211 struct DecryptConfig {
212   EncryptionScheme encryption_scheme;
213   string key_id;
214   string iv;
215   array<SubsampleEntry> subsamples;
216   EncryptionPattern? encryption_pattern;
217 };
218
219 // This defines a mojo transport format for media::DecoderBuffer.
220 struct DecoderBuffer {
221   mojo_base.mojom.TimeDelta timestamp;
222   mojo_base.mojom.TimeDelta duration;
223
224   // Whether the buffer is an end-of-stream (EOS) buffer.
225   bool is_end_of_stream;
226
227   // The number of bytes present in this buffer. The data is not serialized
228   // along with this structure and must be read from a separate DataPipe.
229   // Note that |data_size| could be zero even for a non-EOS buffer (e.g.
230   // with non-empty |size_data|). See http://crbug.com/663438
231   uint32 data_size;
232
233   // Indicates whether or not this buffer is a random access point.
234   bool is_key_frame;
235
236   // Empty when |side_data| doesn't exist.
237   array<uint8> side_data;
238
239   // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
240   DecryptConfig? decrypt_config;
241
242   // These fields indicate the amount of data to discard after decoding.
243   mojo_base.mojom.TimeDelta front_discard;
244   mojo_base.mojom.TimeDelta back_discard;
245 };
246
247 // This defines a mojo transport format for media::AudioBuffer.
248 struct AudioBuffer {
249   // Format of the audio.
250   SampleFormat sample_format;
251
252   // How the channels are laid out.
253   ChannelLayout channel_layout;
254
255   // Number of channels.
256   int32 channel_count;
257
258   // Sample rate of the buffer.
259   int32 sample_rate;
260
261   // Number of frames in the buffer.
262   int32 frame_count;
263
264   // True if end of stream.
265   bool end_of_stream;
266
267   // Timestamp in microseconds of the first frame.
268   mojo_base.mojom.TimeDelta timestamp;
269
270   // Channel data. Will be empty for EOS buffers.
271   array<uint8> data;
272 };
273
274 // This defines a mojo transport format for an interleaved, signed
275 // 16-bit audio buffer.
276 struct AudioDataS16 {
277   // Number of channels.
278   int32 channel_count;
279
280   // Sample rate of the buffer.
281   int32 sample_rate;
282
283   // Number of frames in the buffer.
284   int32 frame_count;
285
286   // Channel data.
287   array<int16> data;
288 };
289
290 // See media/base/video_frame_metadata.h for a description of fields.
291 // TODO(crbug.com/657632): Remove |has_*| values and use nullable types.
292 struct VideoFrameMetadata {
293   bool allow_overlay;
294
295   mojo_base.mojom.TimeTicks? capture_begin_time;
296   mojo_base.mojom.TimeTicks? capture_end_time;
297
298   bool has_capture_counter;
299   int32 capture_counter;
300
301   gfx.mojom.Rect? capture_update_rect;
302
303   bool has_copy_mode;
304   CopyMode copy_mode;
305
306   bool end_of_stream;
307
308   mojo_base.mojom.TimeDelta? frame_duration;
309
310   bool has_frame_rate;
311   double frame_rate;
312
313   bool interactive_content;
314
315   mojo_base.mojom.TimeTicks? reference_time;
316
317   bool read_lock_fences_enabled;
318
319   VideoTransformation? transformation;
320
321   bool texture_owner;
322
323   bool wants_promotion_hint;
324
325   bool protected_video;
326
327   bool hw_protected;
328
329   mojo_base.mojom.UnguessableToken? overlay_plane_id;
330
331   bool power_efficient;
332
333   bool texture_origin_is_top_left;
334
335   bool has_device_scale_factor;
336   double device_scale_factor;
337
338   bool has_page_scale_factor;
339   double page_scale_factor;
340
341   bool has_root_scroll_offset_x;
342   double root_scroll_offset_x;
343
344   bool has_root_scroll_offset_y;
345   double root_scroll_offset_y;
346
347   bool has_top_controls_visible_height;
348   double top_controls_visible_height;
349
350   mojo_base.mojom.TimeTicks? decode_begin_time;
351   mojo_base.mojom.TimeTicks? decode_end_time;
352
353   mojo_base.mojom.TimeDelta? processing_time;
354
355   bool has_rtp_timestamp;
356   double rtp_timestamp;
357
358   mojo_base.mojom.TimeTicks? receive_time;
359
360   mojo_base.mojom.TimeDelta? wallclock_frame_duration;
361
362   uint32 hw_protected_validation_id;
363 };
364
365 // This defines a mojo transport format for media::VideoFrame.
366 struct VideoFrame {
367   // Format of the frame.
368   VideoPixelFormat format;
369
370   // Width and height of the video frame, in pixels.
371   gfx.mojom.Size coded_size;
372
373   // Visible size of the frame.
374   gfx.mojom.Rect visible_rect;
375
376   // Natural size of the frame.
377   gfx.mojom.Size natural_size;
378
379   // Timestamp in microseconds of the associated frame.
380   mojo_base.mojom.TimeDelta timestamp;
381
382   // Contents of the video frame (or EOS marker).
383   VideoFrameData data;
384
385   // Extra properties associated with the VideoFrame.
386   VideoFrameMetadata metadata;
387
388   gfx.mojom.ColorSpace color_space;
389   gfx.mojom.HDRMetadata? hdr_metadata;
390 };
391
392 // Possible choices for storing VideoFrame data.
393 union VideoFrameData {
394   EosVideoFrameData eos_data;
395   SharedBufferVideoFrameData shared_buffer_data;
396   GpuMemoryBufferVideoFrameData gpu_memory_buffer_data;
397   MailboxVideoFrameData mailbox_data;
398 };
399
400 // A marker for EOS frames.
401 struct EosVideoFrameData {
402 };
403
404 // This defines video frame data stored in a Mojo shared buffer.
405 struct SharedBufferVideoFrameData {
406   // Reference to the shared memory containing the frame's data.
407   handle<shared_buffer> frame_data;
408   uint64 frame_data_size;
409
410   // Stride and offsets for each plane. Offsets are relative to the start
411   // of |frame_data|.
412   array<int32> strides;
413   array<uint32> offsets;
414 };
415
416 struct GpuMemoryBufferVideoFrameData {
417   gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
418   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
419 };
420
421 // This defines video frame data stored in texture mailboxes.
422 struct MailboxVideoFrameData {
423   // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
424   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
425   gpu.mojom.VulkanYCbCrInfo? ycbcr_data;
426 };
427
428 struct PipelineStatistics {
429   uint64 audio_bytes_decoded;
430   uint64 video_bytes_decoded;
431   uint32 video_frames_decoded;
432   uint32 video_frames_dropped;
433   int64 audio_memory_usage;
434   int64 video_memory_usage;
435 };
436
437 // Set of features for MediaCapabilities prediction.
438 // TODO(liberato): consider generalizing this.
439 struct PredictionFeatures {
440     // It would be nice to initialize this to VIDEO_CODEC_PROFILE_UNKNOWN (-1),
441     // but we can't do that with native enums.
442     VideoCodecProfile profile;
443     gfx.mojom.Size video_size;
444     // Frames per second may ultimately be a bucketed as an integer, but we want
445     // to do that as late as possible. Using a double avoids early truncation.
446     double frames_per_sec = 0;
447     // Name of the key system used for EME playbacks.
448     string key_system;
449     // Indicates when CDM will use HW secure decoding for EME playbacks.
450     bool use_hw_secure_codecs = false;
451 };
452
453 // Target values for MediaCapabilities predictions.
454 // TODO(liberato): consider generalizing this.
455 struct PredictionTargets {
456   uint32 frames_decoded = 0;
457   uint32 frames_dropped = 0;
458   uint32 frames_power_efficient = 0;
459 };
460
461 // See media/base/pipeline_status.h for descriptions.
462 struct AudioPipelineInfo {
463   AudioDecoderType decoder_type;
464   bool is_platform_decoder = false;
465   bool has_decrypting_demuxer_stream = false;
466   EncryptionType encryption_type;
467 };
468
469 // See media/base/pipeline_status.h for descriptions.
470 struct VideoPipelineInfo {
471   VideoDecoderType decoder_type;
472   bool is_platform_decoder = false;
473   bool has_decrypting_demuxer_stream = false;
474   EncryptionType encryption_type;
475 };
476
477 // See media/base/status.h for descriptions.
478 struct Status {
479   StatusCode code;
480   string? message;
481   array<mojo_base.mojom.Value> frames;
482   array<media.mojom.Status> causes;
483   mojo_base.mojom.Value? data;
484 };
485
486 // Types of media stream, categorised by the media stream's source.
487 // The enum values are emitted to metrics. Do not reorder.
488 enum MediaStreamType {
489   kLocalElementCapture = 0, // The source is a local capture from element.
490   kLocalDeviceCapture = 1, // The source is a local device capture, e.g. webcam.
491   kLocalTabCapture = 2, // The source is a local tab capture.
492   kLocalDesktopCapture = 3, // The source is a local desktop capture.
493   kLocalDisplayCapture = 4, // The source is a local display capture.
494   kRemote = 5, // The source is a remote peer connection.
495   kNone = 6, // Not a media stream.
496 };
497
498 // Error codes propagated by Input media streams OnError methods to indicate the
499 // reason for an error.
500 enum InputStreamErrorCode {
501   kUnknown = 0,
502   kSystemPermissions = 1,
503   kDeviceInUse = 2,
504 };
505
506 // See media/base/renderer_factory_selector.h for description.
507 enum RendererType {
508   kDefault = 0,          // DefaultRendererFactory
509   kMojo = 1,             // MojoRendererFactory
510   kMediaPlayer = 2,      // MediaPlayerRendererClientFactory
511   kCourier = 3,          // CourierRendererFactory
512   kFlinging = 4,         // FlingingRendererClientFactory
513   kCast = 5,             // CastRendererClientFactory
514   kMediaFoundation = 6,  // MediaFoundationRendererClientFactory
515   kFuchsia = 7,          // FuchsiaRendererFactory
516   kRemoting = 8,         // RemotingRendererFactory for remoting::Receiver
517   kCastStreaming = 9,    // CastStreamingRendererFactory
518 };