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";
16 // See media/base/audio_codecs.h for descriptions.
20 enum AudioCodecProfile;
22 // See media/base/buffering_state.h for descriptions.
26 enum BufferingStateChangeReason;
28 // See media/base/channel_layout.h for descriptions.
32 // See media/base/decode_status.h for descriptions.
36 // See media/base/status_codes.h for descriptions.
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/pipeline_status.h for descriptions.
52 // See media/base/sample_format.h for descriptions.
56 // See media/base/video_codecs.h for descriptions.
60 // See media/base/video_codecs.h for descriptions.
62 enum VideoCodecProfile;
64 // See media/base/video_types.h for descriptions.
66 enum VideoPixelFormat;
68 // See media/base/video_transformation.h for descriptions.
76 // See media/base/video_transformation.h for descriptions.
77 struct VideoTransformation {
78 VideoRotation rotation;
82 // See media/base/waiting.h for descriptions.
86 // See media/base/watch_time_keys.h for descriptions.
90 // See media/base/container_names.h for descriptions.
92 enum MediaContainerName;
94 // See media/base/media_status.h for description.
96 enum MediaStatusState;
98 // This defines a mojo transport format for media::EncryptionPattern
99 // See media/base/encryption_pattern.h for description.
100 struct EncryptionPattern {
101 uint32 crypt_byte_block;
102 uint32 skip_byte_block;
105 // See media/base/encryption_scheme.h for description.
107 enum EncryptionScheme;
109 // This defines a mojo transport format for media::VideoColorSpace.
110 // See media/base/video_color_space.h for description.
111 struct VideoColorSpace {
130 // This defines a mojo transport format for media::HDRMetadata.
131 // See media/base/hdr_metadata.h for description.
132 struct MasteringMetadata {
133 gfx.mojom.PointF primary_r;
134 gfx.mojom.PointF primary_g;
135 gfx.mojom.PointF primary_b;
136 gfx.mojom.PointF white_point;
142 MasteringMetadata mastering_metadata;
143 uint32 max_content_light_level;
144 uint32 max_frame_average_light_level;
147 // This defines a mojo transport format for media::AudioDecoderConfig.
148 // See media/base/audio_decoder_config.h for descriptions.
149 struct AudioDecoderConfig {
151 AudioCodecProfile profile;
152 SampleFormat sample_format;
153 ChannelLayout channel_layout;
154 int32 samples_per_second;
155 array<uint8> extra_data;
156 mojo_base.mojom.TimeDelta seek_preroll;
158 EncryptionScheme encryption_scheme;
161 // This defines a mojo transport format for media::VideoDecoderConfig.
162 // See media/base/video_decoder_config.h for descriptions.
163 struct VideoDecoderConfig {
165 VideoCodecProfile profile;
168 VideoTransformation transformation;
169 gfx.mojom.Size coded_size;
170 gfx.mojom.Rect visible_rect;
171 gfx.mojom.Size natural_size;
172 array<uint8> extra_data;
173 EncryptionScheme encryption_scheme;
174 VideoColorSpace color_space_info;
175 HDRMetadata? hdr_metadata;
178 // Native struct media::SubsampleEntry;
180 struct SubsampleEntry;
182 // This defines a mojo transport format for media::DecryptConfig.
183 // See media/base/decrypt_config.h for descriptions.
184 struct DecryptConfig {
185 EncryptionScheme encryption_scheme;
188 array<SubsampleEntry> subsamples;
189 EncryptionPattern? encryption_pattern;
192 // This defines a mojo transport format for media::DecoderBuffer.
193 struct DecoderBuffer {
194 mojo_base.mojom.TimeDelta timestamp;
195 mojo_base.mojom.TimeDelta duration;
197 // Whether the buffer is an end-of-stream (EOS) buffer.
198 bool is_end_of_stream;
200 // The number of bytes present in this buffer. The data is not serialized
201 // along with this structure and must be read from a separate DataPipe.
202 // Note that |data_size| could be zero even for a non-EOS buffer (e.g.
203 // with non-empty |size_data|). See http://crbug.com/663438
206 // Indicates whether or not this buffer is a random access point.
209 // Empty when |side_data| doesn't exist.
210 array<uint8> side_data;
212 // DecryptConfig for a encrypted buffer. NULL if the buffer is not encrypted.
213 DecryptConfig? decrypt_config;
215 // These fields indicate the amount of data to discard after decoding.
216 mojo_base.mojom.TimeDelta front_discard;
217 mojo_base.mojom.TimeDelta back_discard;
220 // This defines a mojo transport format for media::AudioBuffer.
222 // Format of the audio.
223 SampleFormat sample_format;
225 // How the channels are laid out.
226 ChannelLayout channel_layout;
228 // Number of channels.
231 // Sample rate of the buffer.
234 // Number of frames in the buffer.
237 // True if end of stream.
240 // Timestamp in microseconds of the first frame.
241 mojo_base.mojom.TimeDelta timestamp;
243 // Channel data. Will be empty for EOS buffers.
247 // This defines a mojo transport format for an interleaved, signed
248 // 16-bit audio buffer.
249 struct AudioDataS16 {
250 // Number of channels.
253 // Sample rate of the buffer.
256 // Number of frames in the buffer.
263 // See media/base/video_frame_metadata.h for a description of fields.
264 // TODO(crbug.com/657632): Remove |has_*| values and use nullable types.
265 struct VideoFrameMetadata {
268 mojo_base.mojom.TimeTicks? capture_begin_time;
269 mojo_base.mojom.TimeTicks? capture_end_time;
271 bool has_capture_counter;
272 int32 capture_counter;
274 gfx.mojom.Rect? capture_update_rect;
280 mojo_base.mojom.TimeDelta? frame_duration;
285 bool interactive_content;
287 mojo_base.mojom.TimeTicks? reference_time;
289 bool has_resource_utilization;
290 double resource_utilization;
292 bool read_lock_fences_enabled;
295 VideoRotation rotation;
299 bool wants_promotion_hint;
301 bool protected_video;
305 mojo_base.mojom.UnguessableToken? overlay_plane_id;
307 bool power_efficient;
309 bool has_device_scale_factor;
310 double device_scale_factor;
312 bool has_page_scale_factor;
313 double page_scale_factor;
315 bool has_root_scroll_offset_x;
316 double root_scroll_offset_x;
318 bool has_root_scroll_offset_y;
319 double root_scroll_offset_y;
321 bool has_top_controls_visible_height;
322 double top_controls_visible_height;
324 mojo_base.mojom.TimeTicks? decode_begin_time;
325 mojo_base.mojom.TimeTicks? decode_end_time;
327 mojo_base.mojom.TimeDelta? processing_time;
329 bool has_rtp_timestamp;
330 double rtp_timestamp;
332 mojo_base.mojom.TimeTicks? receive_time;
334 mojo_base.mojom.TimeDelta? wallclock_frame_duration;
337 // This defines a mojo transport format for media::VideoFrame.
339 // Format of the frame.
340 VideoPixelFormat format;
342 // Width and height of the video frame, in pixels.
343 gfx.mojom.Size coded_size;
345 // Visible size of the frame.
346 gfx.mojom.Rect visible_rect;
348 // Natural size of the frame.
349 gfx.mojom.Size natural_size;
351 // Timestamp in microseconds of the associated frame.
352 mojo_base.mojom.TimeDelta timestamp;
354 // Contents of the video frame (or EOS marker).
357 // Extra properties associated with the VideoFrame.
358 VideoFrameMetadata metadata;
360 gfx.mojom.ColorSpace color_space;
361 HDRMetadata? hdr_metadata;
364 // Possible choices for storing VideoFrame data.
365 union VideoFrameData {
366 EosVideoFrameData eos_data;
367 SharedBufferVideoFrameData shared_buffer_data;
368 DmabufVideoFrameData dmabuf_data;
369 GpuMemoryBufferVideoFrameData gpu_memory_buffer_data;
370 MailboxVideoFrameData mailbox_data;
373 // A marker for EOS frames.
374 struct EosVideoFrameData {
377 // This defines video frame data stored in a Mojo shared buffer.
378 struct SharedBufferVideoFrameData {
379 // Reference to the shared memory containing the frame's data.
380 handle<shared_buffer> frame_data;
381 uint64 frame_data_size;
383 // Stride and offsets for each plane. Offsets are relative to the start
385 array<int32> strides;
386 array<uint32> offsets;
389 // This defines video frame data stored in dmabuf.
390 struct DmabufVideoFrameData {
391 // Size depends on media::VideoFrame::NumPlanes with frame format.
392 array<handle<platform>> dmabuf_fds;
395 struct GpuMemoryBufferVideoFrameData {
396 gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
397 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
400 // This defines video frame data stored in texture mailboxes.
401 struct MailboxVideoFrameData {
402 // Size must be kept in sync with media::VideoFrame::kMaxPlanes.
403 array<gpu.mojom.MailboxHolder, 4> mailbox_holder;
404 gpu.mojom.VulkanYCbCrInfo? ycbcr_data;
407 struct PipelineStatistics {
408 uint64 audio_bytes_decoded;
409 uint64 video_bytes_decoded;
410 uint32 video_frames_decoded;
411 uint32 video_frames_dropped;
412 int64 audio_memory_usage;
413 int64 video_memory_usage;
416 // Set of features for MediaCapabilities prediction.
417 // TODO(liberato): consider generalizing this.
418 struct PredictionFeatures {
419 // It would be nice to initialize this to VIDEO_CODEC_PROFILE_UNKNOWN (-1),
420 // but we can't do that with native enums.
421 VideoCodecProfile profile;
422 gfx.mojom.Size video_size;
423 // Frames per second may ultimately be a bucketed as an integer, but we want
424 // to do that as late as possible. Using a double avoids early truncation.
425 double frames_per_sec = 0;
426 // Name of the key system used for EME playbacks.
428 // Indicates when CDM will use HW secure decoding for EME playbacks.
429 bool use_hw_secure_codecs = false;
432 // Target values for MediaCapabilities predictions.
433 // TODO(liberato): consider generalizing this.
434 struct PredictionTargets {
435 uint32 frames_decoded = 0;
436 uint32 frames_dropped = 0;
437 uint32 frames_power_efficient = 0;
440 // See media/base/pipeline/status.h for descriptions.
441 struct PipelineDecoderInfo {
443 bool is_platform_decoder = false;
444 bool has_decrypting_demuxer_stream = false;
447 // See media/base/status.h for descriptions.
451 array<mojo_base.mojom.Value> frames;
452 array<media.mojom.Status> causes;
453 mojo_base.mojom.Value? data;