1 // Copyright 2014 The Chromium Authors. All rights reserved.
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 "mojo/public/mojom/base/time.mojom";
10 import "mojo/public/mojom/base/values.mojom";
11 import "mojo/public/mojom/base/unguessable_token.mojom";
12 import "ui/gfx/geometry/mojom/geometry.mojom";
13 import "ui/gfx/mojom/buffer_types.mojom";
14 import "ui/gfx/mojom/color_space.mojom";
15 import "ui/gfx/mojom/hdr_metadata.mojom";
17 // See media/base/audio_codecs.h for descriptions.
21 enum AudioCodecProfile;
23 // See media/base/buffering_state.h for descriptions.
27 enum BufferingStateChangeReason;
29 // See media/base/channel_layout.h for descriptions.
33 // See media/base/decode_status.h for descriptions.
37 // See media/base/status_codes.h for descriptions.
41 // See media/base/media_content_type.h for descriptions.
43 enum MediaContentType;
45 // See media/base/media_log_record.h for description.
47 struct MediaLogRecord;
49 // See media/base/output_device_info.h for descriptions.
51 enum OutputDeviceStatus;
53 // See media/base/pipeline_status.h for descriptions.
57 // See media/base/sample_format.h for descriptions.
61 // See media/base/video_codecs.h for descriptions.
65 // See media/base/video_codecs.h for descriptions.
67 enum VideoCodecProfile;
69 // See media/base/video_types.h for descriptions.
71 enum VideoPixelFormat;
73 // See media/base/decoder.h for descriptions.
75 enum VideoDecoderType;
77 // See media/base/decoder.h for descriptions.
79 enum AudioDecoderType;
81 // See media/base/video_transformation.h for descriptions.
89 // see media/base/video_frame_metadata.h for descriptions.
95 // see third_party/blink/public/platform/web_fullscreen_video_status.h for
98 enum FullscreenVideoStatus;
100 // See media/base/video_transformation.h for descriptions.
101 struct VideoTransformation {
102 VideoRotation rotation;
106 // See media/base/waiting.h for descriptions.
110 // See media/base/watch_time_keys.h for descriptions.
114 // See media/base/container_names.h for descriptions.
116 enum MediaContainerName;
118 // See media/base/media_status.h for description.
120 enum MediaStatusState;
122 // This defines a mojo transport format for media::EncryptionPattern
123 // See media/base/encryption_pattern.h for description.
124 struct EncryptionPattern {
125 uint32 crypt_byte_block;
126 uint32 skip_byte_block;
129 // See media/base/encryption_scheme.h for description.
131 enum EncryptionScheme;
133 // See media::EncryptionType for descriptions.
134 enum EncryptionType {
138 kEncryptedWithClearLead,
141 // This defines a mojo transport format for media::VideoColorSpace.
142 // See media/base/video_color_space.h for description.
143 struct VideoColorSpace {
162 // This defines a mojo transport format for media::AudioDecoderConfig.
163 // See media/base/audio_decoder_config.h for descriptions.
164 // TODO(crbug.com/1232205): Support `channels_` set by SetChannelsForDiscrete().
165 struct AudioDecoderConfig {
167 SampleFormat sample_format;
168 ChannelLayout channel_layout;
169 int32 samples_per_second;
170 array<uint8> extra_data;
171 EncryptionScheme encryption_scheme;
172 mojo_base.mojom.TimeDelta seek_preroll;
174 AudioCodecProfile profile;
175 ChannelLayout target_output_channel_layout;
176 bool should_discard_decoder_delay;
179 // This defines a mojo transport format for media::VideoDecoderConfig.
180 // See media/base/video_decoder_config.h for descriptions.
181 struct VideoDecoderConfig {
183 VideoCodecProfile profile;
186 VideoTransformation transformation;
187 gfx.mojom.Size coded_size;
188 gfx.mojom.Rect visible_rect;
189 gfx.mojom.Size natural_size;
190 array<uint8> extra_data;
191 EncryptionScheme encryption_scheme;
192 VideoColorSpace color_space_info;
193 gfx.mojom.HDRMetadata? hdr_metadata;
196 // Native struct media::SubsampleEntry;
198 struct SubsampleEntry;
200 // See media::CdmSessionClosedReason for descriptions.
201 enum CdmSessionClosedReason {
204 kReleaseAcknowledged,
205 kHardwareContextReset,
209 // This defines a mojo transport format for media::DecryptConfig.
210 // See media/base/decrypt_config.h for descriptions.
211 struct DecryptConfig {
212 EncryptionScheme encryption_scheme;
215 array<SubsampleEntry> subsamples;
216 EncryptionPattern? encryption_pattern;
219 // This defines a mojo transport format for media::DecoderBuffer.
220 struct DecoderBuffer {
221 mojo_base.mojom.TimeDelta timestamp;
222 mojo_base.mojom.TimeDelta duration;
224 // Whether the buffer is an end-of-stream (EOS) buffer.
225 bool is_end_of_stream;
227 // The number of bytes present in this buffer. The data is not serialized
228 // along with this structure and must be read from a separate DataPipe.
229 // Note that |data_size| could be zero even for a non-EOS buffer (e.g.
230 // with non-empty |size_data|). See http://crbug.com/663438
233 // Indicates whether or not this buffer is a random access point.
236 // Empty when |side_data| doesn't exist.
237 array<uint8> side_data;
239 // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
240 DecryptConfig? decrypt_config;
242 // These fields indicate the amount of data to discard after decoding.
243 mojo_base.mojom.TimeDelta front_discard;
244 mojo_base.mojom.TimeDelta back_discard;
247 // This defines a mojo transport format for media::AudioBuffer.
249 // Format of the audio.
250 SampleFormat sample_format;
252 // How the channels are laid out.
253 ChannelLayout channel_layout;
255 // Number of channels.
258 // Sample rate of the buffer.
261 // Number of frames in the buffer.
264 // True if end of stream.
267 // Timestamp in microseconds of the first frame.
268 mojo_base.mojom.TimeDelta timestamp;
270 // Channel data. Will be empty for EOS buffers.
274 // This defines a mojo transport format for an interleaved, signed
275 // 16-bit audio buffer.
276 struct AudioDataS16 {
277 // Number of channels.
280 // Sample rate of the buffer.
283 // Number of frames in the buffer.
290 // See media/base/video_frame_metadata.h for a description of fields.
291 // TODO(crbug.com/657632): Remove |has_*| values and use nullable types.
292 struct VideoFrameMetadata {
295 mojo_base.mojom.TimeTicks? capture_begin_time;
296 mojo_base.mojom.TimeTicks? capture_end_time;
298 bool has_capture_counter;
299 int32 capture_counter;
301 gfx.mojom.Rect? capture_update_rect;
308 mojo_base.mojom.TimeDelta? frame_duration;
313 bool interactive_content;
315 mojo_base.mojom.TimeTicks? reference_time;
317 bool read_lock_fences_enabled;
319 VideoTransformation? transformation;
323 bool wants_promotion_hint;
325 bool protected_video;
329 mojo_base.mojom.UnguessableToken? overlay_plane_id;
331 bool power_efficient;
333 bool texture_origin_is_top_left;
335 bool has_device_scale_factor;
336 double device_scale_factor;
338 bool has_page_scale_factor;
339 double page_scale_factor;
341 bool has_root_scroll_offset_x;
342 double root_scroll_offset_x;
344 bool has_root_scroll_offset_y;
345 double root_scroll_offset_y;
347 bool has_top_controls_visible_height;
348 double top_controls_visible_height;
350 mojo_base.mojom.TimeTicks? decode_begin_time;
351 mojo_base.mojom.TimeTicks? decode_end_time;
353 mojo_base.mojom.TimeDelta? processing_time;
355 bool has_rtp_timestamp;
356 double rtp_timestamp;
358 mojo_base.mojom.TimeTicks? receive_time;
360 mojo_base.mojom.TimeDelta? wallclock_frame_duration;
362 uint32 hw_protected_validation_id;
365 // This defines a mojo transport format for media::VideoFrame.
367 // Format of the frame.
368 VideoPixelFormat format;
370 // Width and height of the video frame, in pixels.
371 gfx.mojom.Size coded_size;
373 // Visible size of the frame.
374 gfx.mojom.Rect visible_rect;
376 // Natural size of the frame.
377 gfx.mojom.Size natural_size;
379 // Timestamp in microseconds of the associated frame.
380 mojo_base.mojom.TimeDelta timestamp;
382 // Contents of the video frame (or EOS marker).
385 // Extra properties associated with the VideoFrame.
386 VideoFrameMetadata metadata;
388 gfx.mojom.ColorSpace color_space;
389 gfx.mojom.HDRMetadata? hdr_metadata;
392 // Possible choices for storing VideoFrame data.
393 union VideoFrameData {
394 EosVideoFrameData eos_data;
395 SharedBufferVideoFrameData shared_buffer_data;
396 GpuMemoryBufferVideoFrameData gpu_memory_buffer_data;
397 MailboxVideoFrameData mailbox_data;
400 // A marker for EOS frames.
401 struct EosVideoFrameData {
404 // This defines video frame data stored in a Mojo shared buffer.
405 struct SharedBufferVideoFrameData {
406 // Reference to the shared memory containing the frame's data.
407 handle<shared_buffer> frame_data;
408 uint64 frame_data_size;
410 // Stride and offsets for each plane. Offsets are relative to the start
412 array<int32> strides;
413 array<uint32> offsets;
416 struct GpuMemoryBufferVideoFrameData {
417 gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
418 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
421 // This defines video frame data stored in texture mailboxes.
422 struct MailboxVideoFrameData {
423 // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
424 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
425 gpu.mojom.VulkanYCbCrInfo? ycbcr_data;
428 struct PipelineStatistics {
429 uint64 audio_bytes_decoded;
430 uint64 video_bytes_decoded;
431 uint32 video_frames_decoded;
432 uint32 video_frames_dropped;
433 int64 audio_memory_usage;
434 int64 video_memory_usage;
437 // Set of features for MediaCapabilities prediction.
438 // TODO(liberato): consider generalizing this.
439 struct PredictionFeatures {
440 // It would be nice to initialize this to VIDEO_CODEC_PROFILE_UNKNOWN (-1),
441 // but we can't do that with native enums.
442 VideoCodecProfile profile;
443 gfx.mojom.Size video_size;
444 // Frames per second may ultimately be a bucketed as an integer, but we want
445 // to do that as late as possible. Using a double avoids early truncation.
446 double frames_per_sec = 0;
447 // Name of the key system used for EME playbacks.
449 // Indicates when CDM will use HW secure decoding for EME playbacks.
450 bool use_hw_secure_codecs = false;
453 // Target values for MediaCapabilities predictions.
454 // TODO(liberato): consider generalizing this.
455 struct PredictionTargets {
456 uint32 frames_decoded = 0;
457 uint32 frames_dropped = 0;
458 uint32 frames_power_efficient = 0;
461 // See media/base/pipeline_status.h for descriptions.
462 struct AudioPipelineInfo {
463 AudioDecoderType decoder_type;
464 bool is_platform_decoder = false;
465 bool has_decrypting_demuxer_stream = false;
466 EncryptionType encryption_type;
469 // See media/base/pipeline_status.h for descriptions.
470 struct VideoPipelineInfo {
471 VideoDecoderType decoder_type;
472 bool is_platform_decoder = false;
473 bool has_decrypting_demuxer_stream = false;
474 EncryptionType encryption_type;
477 // See media/base/status.h for descriptions.
481 array<mojo_base.mojom.Value> frames;
482 array<media.mojom.Status> causes;
483 mojo_base.mojom.Value? data;
486 // Types of media stream, categorised by the media stream's source.
487 // The enum values are emitted to metrics. Do not reorder.
488 enum MediaStreamType {
489 kLocalElementCapture = 0, // The source is a local capture from element.
490 kLocalDeviceCapture = 1, // The source is a local device capture, e.g. webcam.
491 kLocalTabCapture = 2, // The source is a local tab capture.
492 kLocalDesktopCapture = 3, // The source is a local desktop capture.
493 kLocalDisplayCapture = 4, // The source is a local display capture.
494 kRemote = 5, // The source is a remote peer connection.
495 kNone = 6, // Not a media stream.
498 // Error codes propagated by Input media streams OnError methods to indicate the
499 // reason for an error.
500 enum InputStreamErrorCode {
502 kSystemPermissions = 1,
506 // See media/base/renderer_factory_selector.h for description.
508 kDefault = 0, // DefaultRendererFactory
509 kMojo = 1, // MojoRendererFactory
510 kMediaPlayer = 2, // MediaPlayerRendererClientFactory
511 kCourier = 3, // CourierRendererFactory
512 kFlinging = 4, // FlingingRendererClientFactory
513 kCast = 5, // CastRendererClientFactory
514 kMediaFoundation = 6, // MediaFoundationRendererClientFactory
515 kFuchsia = 7, // FuchsiaRendererFactory
516 kRemoting = 8, // RemotingRendererFactory for remoting::Receiver
517 kCastStreaming = 9, // CastStreamingRendererFactory