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 [EnableIf=is_tizen_tv]
277 [EnableIf=is_tizen_tv]
278 uint32 tz_buffer_size;
279 [EnableIf=is_tizen_tv]
280 uint64 decryptor_handle;
282 DecoderBufferSideData? side_data;
285 // This defines a mojo transport format for media::AudioBuffer.
287 // Format of the audio.
288 SampleFormat sample_format;
290 // How the channels are laid out.
291 ChannelLayout channel_layout;
293 // Number of channels.
296 // Sample rate of the buffer.
299 // Number of frames in the buffer.
302 // True if end of stream.
305 // Timestamp in microseconds of the first frame.
306 mojo_base.mojom.TimeDelta timestamp;
308 // Channel data. Will be empty for EOS buffers.
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 {
317 mojo_base.mojom.TimeTicks? capture_begin_time;
318 mojo_base.mojom.TimeTicks? capture_end_time;
320 bool has_capture_counter;
321 int32 capture_counter;
323 gfx.mojom.Rect? capture_update_rect;
325 gfx.mojom.Size? source_size;
327 gfx.mojom.Rect? region_capture_rect;
328 uint32 sub_capture_target_version;
334 mojo_base.mojom.TimeDelta? frame_duration;
339 bool interactive_content;
341 mojo_base.mojom.TimeTicks? reference_time;
343 bool read_lock_fences_enabled;
345 VideoTransformation? transformation;
349 bool wants_promotion_hint;
351 bool protected_video;
355 bool is_webgpu_compatible;
357 mojo_base.mojom.UnguessableToken? overlay_plane_id;
359 bool power_efficient;
361 bool texture_origin_is_top_left;
363 bool has_device_scale_factor;
364 double device_scale_factor;
366 bool has_page_scale_factor;
367 double page_scale_factor;
369 bool has_root_scroll_offset_x;
370 double root_scroll_offset_x;
372 bool has_root_scroll_offset_y;
373 double root_scroll_offset_y;
375 bool has_top_controls_visible_height;
376 double top_controls_visible_height;
378 mojo_base.mojom.TimeTicks? decode_begin_time;
379 mojo_base.mojom.TimeTicks? decode_end_time;
381 mojo_base.mojom.TimeDelta? processing_time;
383 bool has_rtp_timestamp;
384 double rtp_timestamp;
386 mojo_base.mojom.TimeTicks? receive_time;
388 mojo_base.mojom.TimeDelta? wallclock_frame_duration;
391 // This defines a mojo transport format for media::VideoFrame.
393 // Format of the frame.
394 VideoPixelFormat format;
396 // Width and height of the video frame, in pixels.
397 gfx.mojom.Size coded_size;
399 // Visible size of the frame.
400 gfx.mojom.Rect visible_rect;
402 // Natural size of the frame.
403 gfx.mojom.Size natural_size;
405 // Timestamp in microseconds of the associated frame.
406 mojo_base.mojom.TimeDelta timestamp;
408 // Contents of the video frame (or EOS marker).
411 // Extra properties associated with the VideoFrame.
412 VideoFrameMetadata metadata;
414 gfx.mojom.ColorSpace color_space;
415 gfx.mojom.HDRMetadata? hdr_metadata;
417 media.mojom.SharedImageFormatType shared_image_format_type;
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;
428 // A marker for EOS frames.
429 struct EosVideoFrameData {
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;
437 // Stride and offsets for each plane. Offsets are relative to the start
439 array<int32> strides;
440 array<uint32> offsets;
443 struct GpuMemoryBufferVideoFrameData {
444 gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
445 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
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;
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;
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.
476 // Indicates when CDM will use HW secure decoding for EME playbacks.
477 bool use_hw_secure_codecs = false;
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;
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;
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;
504 // See media/base/status.h for descriptions.
509 mojo_base.mojom.ListValue frames;
511 mojo_base.mojom.Value data;
512 uint64 packed_root_cause;
515 struct EncoderStatus {
516 StatusData? internal;
519 struct DecoderStatus {
520 StatusData? internal;
523 struct PipelineStatus {
524 StatusData? internal;
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.
539 // Error codes propagated by Input media streams OnError methods to indicate the
540 // reason for an error.
541 enum InputStreamErrorCode {
543 kSystemPermissions = 1,
547 // See media/base/renderer.h for description.
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