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.
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";
20 // See media/base/audio_codecs.h for descriptions.
24 enum AudioCodecProfile;
26 // See media/base/buffering_state.h for descriptions.
30 enum BufferingStateChangeReason;
32 // See media/base/channel_layout.h for descriptions.
36 // See media/base/media_content_type.h for descriptions.
38 enum MediaContentType;
40 // See media/base/media_log_record.h for description.
42 struct MediaLogRecord;
44 // See media/base/output_device_info.h for descriptions.
46 enum OutputDeviceStatus;
48 // See media/base/sample_format.h for descriptions.
52 // See media/base/video_codecs.h for descriptions.
56 // See media/base/video_codecs.h for descriptions.
58 enum VideoCodecProfile;
60 // See media/base/video_types.h for descriptions.
62 enum VideoPixelFormat;
64 // See media/base/decoder.h for descriptions.
66 enum VideoDecoderType;
68 // See media/base/decoder.h for descriptions.
70 enum AudioDecoderType;
72 // See media/base/video_transformation.h for descriptions.
80 // see third_party/blink/public/platform/web_fullscreen_video_status.h for
83 enum FullscreenVideoStatus;
85 // See media/base/video_transformation.h for descriptions.
86 struct VideoTransformation {
87 VideoRotation rotation;
91 // See media/base/waiting.h for descriptions.
95 // See media/base/watch_time_keys.h for descriptions.
99 // See media/base/container_names.h for descriptions.
101 enum MediaContainerName;
103 // See media/base/media_status.h for description.
105 enum MediaStatusState;
107 // See media/base/encryption_scheme.h for description.
109 enum EncryptionScheme;
111 // See media::EncryptionType for descriptions.
112 enum EncryptionType {
116 kEncryptedWithClearLead,
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.
136 // This mojo enum only list hardware codec supported scalability mode.
137 // See media/base/svc_scalability_mode.h for description.
138 enum SVCInterLayerPredMode {
144 // This defines a mojo transport format for media::VideoColorSpace.
145 // See media/base/video_color_space.h for description.
146 struct VideoColorSpace {
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 {
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;
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;
184 // This defines a mojo transport format for media::VideoDecoderConfig.
185 // See media/base/video_decoder_config.h for descriptions.
186 struct VideoDecoderConfig {
188 VideoCodecProfile profile;
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]
201 [EnableIf=is_tizen_tv]
203 [EnableIf=is_tizen_tv]
207 // Native struct media::SubsampleEntry;
209 struct SubsampleEntry;
211 // Important events happened to the CDM. See media/cdm/cdm_document_service.h
215 kSignificantPlayback,
218 kHardwareContextReset,
221 // See media::CdmSessionClosedReason for descriptions.
222 enum CdmSessionClosedReason {
225 kReleaseAcknowledged,
226 kHardwareContextReset,
230 // This defines a mojo transport format for media::SharedImageFormatType.
231 // See media/base/video_frame.h for descriptions.
232 enum SharedImageFormatType {
235 kSharedImageFormatExternalSampler,
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;
244 array<SubsampleEntry> subsamples;
245 EncryptionPattern? encryption_pattern;
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;
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;
260 // Whether the buffer is an end-of-stream (EOS) buffer.
261 bool is_end_of_stream;
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
269 // Indicates whether or not this buffer is a random access point.
272 // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
273 DecryptConfig? decrypt_config;
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;
279 [EnableIf=is_tizen_tv]
281 [EnableIf=is_tizen_tv]
282 uint32 tz_buffer_size;
283 [EnableIf=is_tizen_tv]
284 uint64 decryptor_handle;
286 DecoderBufferSideData? side_data;
289 // This defines a mojo transport format for media::AudioBuffer.
291 // Format of the audio.
292 SampleFormat sample_format;
294 // How the channels are laid out.
295 ChannelLayout channel_layout;
297 // Number of channels.
300 // Sample rate of the buffer.
303 // Number of frames in the buffer.
306 // True if end of stream.
309 // Timestamp in microseconds of the first frame.
310 mojo_base.mojom.TimeDelta timestamp;
312 // Channel data. Will be empty for EOS buffers.
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 {
321 mojo_base.mojom.TimeTicks? capture_begin_time;
322 mojo_base.mojom.TimeTicks? capture_end_time;
324 bool has_capture_counter;
325 int32 capture_counter;
327 gfx.mojom.Rect? capture_update_rect;
329 gfx.mojom.Size? source_size;
331 gfx.mojom.Rect? region_capture_rect;
332 uint32 sub_capture_target_version;
338 mojo_base.mojom.TimeDelta? frame_duration;
343 bool interactive_content;
345 mojo_base.mojom.TimeTicks? reference_time;
347 bool read_lock_fences_enabled;
349 VideoTransformation? transformation;
353 bool wants_promotion_hint;
355 bool protected_video;
359 bool is_webgpu_compatible;
361 mojo_base.mojom.UnguessableToken? overlay_plane_id;
363 bool power_efficient;
365 bool texture_origin_is_top_left;
367 bool has_device_scale_factor;
368 double device_scale_factor;
370 bool has_page_scale_factor;
371 double page_scale_factor;
373 bool has_root_scroll_offset_x;
374 double root_scroll_offset_x;
376 bool has_root_scroll_offset_y;
377 double root_scroll_offset_y;
379 bool has_top_controls_visible_height;
380 double top_controls_visible_height;
382 mojo_base.mojom.TimeTicks? decode_begin_time;
383 mojo_base.mojom.TimeTicks? decode_end_time;
385 mojo_base.mojom.TimeDelta? processing_time;
387 bool has_rtp_timestamp;
388 double rtp_timestamp;
390 mojo_base.mojom.TimeTicks? receive_time;
392 mojo_base.mojom.TimeDelta? wallclock_frame_duration;
395 // This defines a mojo transport format for media::VideoFrame.
397 // Format of the frame.
398 VideoPixelFormat format;
400 // Width and height of the video frame, in pixels.
401 gfx.mojom.Size coded_size;
403 // Visible size of the frame.
404 gfx.mojom.Rect visible_rect;
406 // Natural size of the frame.
407 gfx.mojom.Size natural_size;
409 // Timestamp in microseconds of the associated frame.
410 mojo_base.mojom.TimeDelta timestamp;
412 // Contents of the video frame (or EOS marker).
415 // Extra properties associated with the VideoFrame.
416 VideoFrameMetadata metadata;
418 gfx.mojom.ColorSpace color_space;
419 gfx.mojom.HDRMetadata? hdr_metadata;
421 media.mojom.SharedImageFormatType shared_image_format_type;
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;
432 // A marker for EOS frames.
433 struct EosVideoFrameData {
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;
441 // Stride and offsets for each plane. Offsets are relative to the start
443 array<int32> strides;
444 array<uint32> offsets;
447 struct GpuMemoryBufferVideoFrameData {
448 gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
449 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
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;
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;
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.
480 // Indicates when CDM will use HW secure decoding for EME playbacks.
481 bool use_hw_secure_codecs = false;
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;
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;
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;
508 // See media/base/status.h for descriptions.
513 mojo_base.mojom.ListValue frames;
515 mojo_base.mojom.Value data;
516 uint64 packed_root_cause;
519 struct EncoderStatus {
520 StatusData? internal;
523 struct DecoderStatus {
524 StatusData? internal;
527 struct PipelineStatus {
528 StatusData? internal;
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.
543 // Error codes propagated by Input media streams OnError methods to indicate the
544 // reason for an error.
545 enum InputStreamErrorCode {
547 kSystemPermissions = 1,
551 // See media/base/renderer.h for description.
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