[M120 Migration][MM] Framerate calculation
[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   [EnableIf=is_tizen_tv]
202   int32 framerate_num;
203   [EnableIf=is_tizen_tv]
204   int32 framerate_den;
205 };
206
207 // Native struct media::SubsampleEntry;
208 [Native]
209 struct SubsampleEntry;
210
211 // Important events happened to the CDM. See media/cdm/cdm_document_service.h
212 // for descriptions.
213 [EnableIf=is_win]
214 enum CdmEvent {
215   kSignificantPlayback,
216   kPlaybackError,
217   kCdmError,
218   kHardwareContextReset,
219 };
220
221 // See media::CdmSessionClosedReason for descriptions.
222 enum CdmSessionClosedReason {
223   kInternalError,
224   kClose,
225   kReleaseAcknowledged,
226   kHardwareContextReset,
227   kResourceEvicted,
228 };
229
230 // This defines a mojo transport format for media::SharedImageFormatType.
231 // See media/base/video_frame.h for descriptions.
232 enum SharedImageFormatType {
233   kLegacy,
234   kSharedImageFormat,
235   kSharedImageFormatExternalSampler,
236 };
237
238 // This defines a mojo transport format for media::DecryptConfig.
239 // See media/base/decrypt_config.h for descriptions.
240 struct DecryptConfig {
241   EncryptionScheme encryption_scheme;
242   string key_id;
243   string iv;
244   array<SubsampleEntry> subsamples;
245   EncryptionPattern? encryption_pattern;
246 };
247
248 // This defines a mojo transport format for media::DecoderBufferSideData.
249 struct DecoderBufferSideData {
250   array<uint32> spatial_layers;
251   array<uint8> alpha_data;
252   uint64 secure_handle;
253 };
254
255 // This defines a mojo transport format for media::DecoderBuffer.
256 struct DecoderBuffer {
257   mojo_base.mojom.TimeDelta timestamp;
258   mojo_base.mojom.TimeDelta duration;
259
260   // Whether the buffer is an end-of-stream (EOS) buffer.
261   bool is_end_of_stream;
262
263   // The number of bytes present in this buffer. The data is not serialized
264   // along with this structure and must be read from a separate DataPipe.
265   // Note that |data_size| could be zero even for a non-EOS buffer (e.g.
266   // with non-empty |size_data|). See http://crbug.com/663438
267   uint32 data_size;
268
269   // Indicates whether or not this buffer is a random access point.
270   bool is_key_frame;
271
272   // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
273   DecryptConfig? decrypt_config;
274
275   // These fields indicate the amount of data to discard after decoding.
276   mojo_base.mojom.TimeDelta front_discard;
277   mojo_base.mojom.TimeDelta back_discard;
278
279   [EnableIf=is_tizen_tv]
280   uint32 tz_handle;
281   [EnableIf=is_tizen_tv]
282   uint32 tz_buffer_size;
283   [EnableIf=is_tizen_tv]
284   uint64 decryptor_handle;
285
286   DecoderBufferSideData? side_data;
287 };
288
289 // This defines a mojo transport format for media::AudioBuffer.
290 struct AudioBuffer {
291   // Format of the audio.
292   SampleFormat sample_format;
293
294   // How the channels are laid out.
295   ChannelLayout channel_layout;
296
297   // Number of channels.
298   int32 channel_count;
299
300   // Sample rate of the buffer.
301   int32 sample_rate;
302
303   // Number of frames in the buffer.
304   int32 frame_count;
305
306   // True if end of stream.
307   bool end_of_stream;
308
309   // Timestamp in microseconds of the first frame.
310   mojo_base.mojom.TimeDelta timestamp;
311
312   // Channel data. Will be empty for EOS buffers.
313   array<uint8> data;
314 };
315
316 // See media/base/video_frame_metadata.h for a description of fields.
317 // TODO(crbug.com/657632): Remove |has_*| values and use nullable types.
318 struct VideoFrameMetadata {
319   bool allow_overlay;
320
321   mojo_base.mojom.TimeTicks? capture_begin_time;
322   mojo_base.mojom.TimeTicks? capture_end_time;
323
324   bool has_capture_counter;
325   int32 capture_counter;
326
327   gfx.mojom.Rect? capture_update_rect;
328
329   gfx.mojom.Size? source_size;
330
331   gfx.mojom.Rect? region_capture_rect;
332   uint32 sub_capture_target_version;
333
334   bool copy_required;
335
336   bool end_of_stream;
337
338   mojo_base.mojom.TimeDelta? frame_duration;
339
340   bool has_frame_rate;
341   double frame_rate;
342
343   bool interactive_content;
344
345   mojo_base.mojom.TimeTicks? reference_time;
346
347   bool read_lock_fences_enabled;
348
349   VideoTransformation? transformation;
350
351   bool texture_owner;
352
353   bool wants_promotion_hint;
354
355   bool protected_video;
356
357   bool hw_protected;
358
359   bool is_webgpu_compatible;
360
361   mojo_base.mojom.UnguessableToken? overlay_plane_id;
362
363   bool power_efficient;
364
365   bool texture_origin_is_top_left;
366
367   bool has_device_scale_factor;
368   double device_scale_factor;
369
370   bool has_page_scale_factor;
371   double page_scale_factor;
372
373   bool has_root_scroll_offset_x;
374   double root_scroll_offset_x;
375
376   bool has_root_scroll_offset_y;
377   double root_scroll_offset_y;
378
379   bool has_top_controls_visible_height;
380   double top_controls_visible_height;
381
382   mojo_base.mojom.TimeTicks? decode_begin_time;
383   mojo_base.mojom.TimeTicks? decode_end_time;
384
385   mojo_base.mojom.TimeDelta? processing_time;
386
387   bool has_rtp_timestamp;
388   double rtp_timestamp;
389
390   mojo_base.mojom.TimeTicks? receive_time;
391
392   mojo_base.mojom.TimeDelta? wallclock_frame_duration;
393 };
394
395 // This defines a mojo transport format for media::VideoFrame.
396 struct VideoFrame {
397   // Format of the frame.
398   VideoPixelFormat format;
399
400   // Width and height of the video frame, in pixels.
401   gfx.mojom.Size coded_size;
402
403   // Visible size of the frame.
404   gfx.mojom.Rect visible_rect;
405
406   // Natural size of the frame.
407   gfx.mojom.Size natural_size;
408
409   // Timestamp in microseconds of the associated frame.
410   mojo_base.mojom.TimeDelta timestamp;
411
412   // Contents of the video frame (or EOS marker).
413   VideoFrameData data;
414
415   // Extra properties associated with the VideoFrame.
416   VideoFrameMetadata metadata;
417
418   gfx.mojom.ColorSpace color_space;
419   gfx.mojom.HDRMetadata? hdr_metadata;
420
421   media.mojom.SharedImageFormatType shared_image_format_type;
422 };
423
424 // Possible choices for storing VideoFrame data.
425 union VideoFrameData {
426   EosVideoFrameData eos_data;
427   SharedMemoryVideoFrameData shared_memory_data;
428   GpuMemoryBufferVideoFrameData gpu_memory_buffer_data;
429   MailboxVideoFrameData mailbox_data;
430 };
431
432 // A marker for EOS frames.
433 struct EosVideoFrameData {
434 };
435
436 // This defines video frame data for STORAGE_SHMEM VideoFrame.
437 struct SharedMemoryVideoFrameData {
438   // Shared memory region for the frame data.
439   mojo_base.mojom.ReadOnlySharedMemoryRegion frame_data;
440
441   // Stride and offsets for each plane. Offsets are relative to the start
442   // of |frame_data|.
443   array<int32> strides;
444   array<uint32> offsets;
445 };
446
447 struct GpuMemoryBufferVideoFrameData {
448   gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
449   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
450 };
451
452 // This defines video frame data stored in texture mailboxes.
453 struct MailboxVideoFrameData {
454   // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
455   array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
456   gpu.mojom.VulkanYCbCrInfo? ycbcr_data;
457 };
458
459 struct PipelineStatistics {
460   uint64 audio_bytes_decoded;
461   uint64 video_bytes_decoded;
462   uint32 video_frames_decoded;
463   uint32 video_frames_dropped;
464   int64 audio_memory_usage;
465   int64 video_memory_usage;
466 };
467
468 // Set of features for MediaCapabilities prediction.
469 // TODO(liberato): consider generalizing this.
470 struct PredictionFeatures {
471     // It would be nice to initialize this to VIDEO_CODEC_PROFILE_UNKNOWN (-1),
472     // but we can't do that with native enums.
473     VideoCodecProfile profile;
474     gfx.mojom.Size video_size;
475     // Frames per second may ultimately be a bucketed as an integer, but we want
476     // to do that as late as possible. Using a double avoids early truncation.
477     double frames_per_sec = 0;
478     // Name of the key system used for EME playbacks.
479     string key_system;
480     // Indicates when CDM will use HW secure decoding for EME playbacks.
481     bool use_hw_secure_codecs = false;
482 };
483
484 // Target values for MediaCapabilities predictions.
485 // TODO(liberato): consider generalizing this.
486 struct PredictionTargets {
487   uint32 frames_decoded = 0;
488   uint32 frames_dropped = 0;
489   uint32 frames_power_efficient = 0;
490 };
491
492 // See media/base/pipeline_status.h for descriptions.
493 struct AudioPipelineInfo {
494   AudioDecoderType decoder_type;
495   bool is_platform_decoder = false;
496   bool has_decrypting_demuxer_stream = false;
497   EncryptionType encryption_type;
498 };
499
500 // See media/base/pipeline_status.h for descriptions.
501 struct VideoPipelineInfo {
502   VideoDecoderType decoder_type;
503   bool is_platform_decoder = false;
504   bool has_decrypting_demuxer_stream = false;
505   EncryptionType encryption_type;
506 };
507
508 // See media/base/status.h for descriptions.
509 struct StatusData {
510   string group;
511   uint16 code;
512   string message;
513   mojo_base.mojom.ListValue frames;
514   StatusData? cause;
515   mojo_base.mojom.Value data;
516   uint64 packed_root_cause;
517 };
518
519 struct EncoderStatus {
520   StatusData? internal;
521 };
522
523 struct DecoderStatus {
524   StatusData? internal;
525 };
526
527 struct PipelineStatus {
528   StatusData? internal;
529 };
530
531 // Types of media stream, categorised by the media stream's source.
532 // The enum values are emitted to metrics. Do not reorder.
533 enum MediaStreamType {
534   kLocalElementCapture = 0, // The source is a local capture from element.
535   kLocalDeviceCapture = 1, // The source is a local device capture, e.g. webcam.
536   kLocalTabCapture = 2, // The source is a local tab capture.
537   kLocalDesktopCapture = 3, // The source is a local desktop capture.
538   kLocalDisplayCapture = 4, // The source is a local display capture.
539   kRemote = 5, // The source is a remote peer connection.
540   kNone = 6, // Not a media stream.
541 };
542
543 // Error codes propagated by Input media streams OnError methods to indicate the
544 // reason for an error.
545 enum InputStreamErrorCode {
546   kUnknown = 0,
547   kSystemPermissions = 1,
548   kDeviceInUse = 2,
549 };
550
551 // See media/base/renderer.h for description.
552 enum RendererType {
553   kRendererImpl = 0,     // RendererImplFactory
554   kMojo = 1,             // MojoRendererFactory
555   kMediaPlayer = 2,      // MediaPlayerRendererClientFactory
556   kCourier = 3,          // CourierRendererFactory
557   kFlinging = 4,         // FlingingRendererClientFactory
558   kCast = 5,             // CastRendererClientFactory
559   kMediaFoundation = 6,  // MediaFoundationRendererClientFactory
560   // kFuchsia = 7,       // Deprecated
561   kRemoting = 8,         // RemotingRendererFactory for remoting::Receiver
562   kCastStreaming = 9,    // CastStreamingRendererFactory
563   kContentEmbedderDefined = 10,  // Defined by the content embedder
564   kTest= 11,             // Renderer implementations used in tests
565 };