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