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]
203 // Native struct media::SubsampleEntry;
205 struct SubsampleEntry;
207 // Important events happened to the CDM. See media/cdm/cdm_document_service.h
211 kSignificantPlayback,
214 kHardwareContextReset,
217 // See media::CdmSessionClosedReason for descriptions.
218 enum CdmSessionClosedReason {
221 kReleaseAcknowledged,
222 kHardwareContextReset,
226 // This defines a mojo transport format for media::SharedImageFormatType.
227 // See media/base/video_frame.h for descriptions.
228 enum SharedImageFormatType {
231 kSharedImageFormatExternalSampler,
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;
240 array<SubsampleEntry> subsamples;
241 EncryptionPattern? encryption_pattern;
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;
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;
256 // Whether the buffer is an end-of-stream (EOS) buffer.
257 bool is_end_of_stream;
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
265 // Indicates whether or not this buffer is a random access point.
268 // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
269 DecryptConfig? decrypt_config;
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;
275 DecoderBufferSideData? side_data;
278 // This defines a mojo transport format for media::AudioBuffer.
280 // Format of the audio.
281 SampleFormat sample_format;
283 // How the channels are laid out.
284 ChannelLayout channel_layout;
286 // Number of channels.
289 // Sample rate of the buffer.
292 // Number of frames in the buffer.
295 // True if end of stream.
298 // Timestamp in microseconds of the first frame.
299 mojo_base.mojom.TimeDelta timestamp;
301 // Channel data. Will be empty for EOS buffers.
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 {
310 mojo_base.mojom.TimeTicks? capture_begin_time;
311 mojo_base.mojom.TimeTicks? capture_end_time;
313 bool has_capture_counter;
314 int32 capture_counter;
316 gfx.mojom.Rect? capture_update_rect;
318 gfx.mojom.Size? source_size;
320 gfx.mojom.Rect? region_capture_rect;
321 uint32 sub_capture_target_version;
327 mojo_base.mojom.TimeDelta? frame_duration;
332 bool interactive_content;
334 mojo_base.mojom.TimeTicks? reference_time;
336 bool read_lock_fences_enabled;
338 VideoTransformation? transformation;
342 bool wants_promotion_hint;
344 bool protected_video;
348 bool is_webgpu_compatible;
350 mojo_base.mojom.UnguessableToken? overlay_plane_id;
352 bool power_efficient;
354 bool texture_origin_is_top_left;
356 bool has_device_scale_factor;
357 double device_scale_factor;
359 bool has_page_scale_factor;
360 double page_scale_factor;
362 bool has_root_scroll_offset_x;
363 double root_scroll_offset_x;
365 bool has_root_scroll_offset_y;
366 double root_scroll_offset_y;
368 bool has_top_controls_visible_height;
369 double top_controls_visible_height;
371 mojo_base.mojom.TimeTicks? decode_begin_time;
372 mojo_base.mojom.TimeTicks? decode_end_time;
374 mojo_base.mojom.TimeDelta? processing_time;
376 bool has_rtp_timestamp;
377 double rtp_timestamp;
379 mojo_base.mojom.TimeTicks? receive_time;
381 mojo_base.mojom.TimeDelta? wallclock_frame_duration;
384 // This defines a mojo transport format for media::VideoFrame.
386 // Format of the frame.
387 VideoPixelFormat format;
389 // Width and height of the video frame, in pixels.
390 gfx.mojom.Size coded_size;
392 // Visible size of the frame.
393 gfx.mojom.Rect visible_rect;
395 // Natural size of the frame.
396 gfx.mojom.Size natural_size;
398 // Timestamp in microseconds of the associated frame.
399 mojo_base.mojom.TimeDelta timestamp;
401 // Contents of the video frame (or EOS marker).
404 // Extra properties associated with the VideoFrame.
405 VideoFrameMetadata metadata;
407 gfx.mojom.ColorSpace color_space;
408 gfx.mojom.HDRMetadata? hdr_metadata;
410 media.mojom.SharedImageFormatType shared_image_format_type;
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;
421 // A marker for EOS frames.
422 struct EosVideoFrameData {
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;
430 // Stride and offsets for each plane. Offsets are relative to the start
432 array<int32> strides;
433 array<uint32> offsets;
436 struct GpuMemoryBufferVideoFrameData {
437 gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
438 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
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;
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;
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.
469 // Indicates when CDM will use HW secure decoding for EME playbacks.
470 bool use_hw_secure_codecs = false;
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;
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;
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;
497 // See media/base/status.h for descriptions.
502 mojo_base.mojom.ListValue frames;
504 mojo_base.mojom.Value data;
505 uint64 packed_root_cause;
508 struct EncoderStatus {
509 StatusData? internal;
512 struct DecoderStatus {
513 StatusData? internal;
516 struct PipelineStatus {
517 StatusData? internal;
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.
532 // Error codes propagated by Input media streams OnError methods to indicate the
533 // reason for an error.
534 enum InputStreamErrorCode {
536 kSystemPermissions = 1,
540 // See media/base/renderer.h for description.
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