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