fidl_fuchsia_mediacodec__common/
fidl_fuchsia_mediacodec__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Constrain the length of the vector indicated via `OnCodecList`, and constrain the max items in
12/// any vector within the response from `GetDetailedCodecDescriptions`.  The overall enforced limit
13/// for codec caps information is the max channel message size however, since nested vectors each of
14/// max size could otherwise exceed the max channel message size.
15pub const CODEC_FACTORY_CODEC_LIST_SIZE_MAX: u32 = 256;
16
17/// More than this many calls to AttachLifetimeTracking()
18/// without a Create{X}() call will result in CodecFactory channel closing from
19/// the server end.
20pub const CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX: u32 = 16;
21
22/// Constrain the mime_type to a size that won't cause problems.
23pub const CODEC_FACTORY_MAX_MIME_TYPE_LENGTH: u32 = 256;
24
25#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
26#[repr(u32)]
27pub enum CodecType {
28    Decoder = 0,
29    Encoder = 1,
30}
31
32impl CodecType {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            0 => Some(Self::Decoder),
37            1 => Some(Self::Encoder),
38            _ => None,
39        }
40    }
41
42    #[inline]
43    pub const fn into_primitive(self) -> u32 {
44        self as u32
45    }
46}
47
48/// Whether buffers need to be secure.  If not specified, the default is OFF.
49///
50/// This enum may have additional values added later; code handling this type
51/// should be written with this in mind.  For example, in C++, having a
52/// "default" case in any switch statement on this type will avoid compilation
53/// warnings/errors when a new value is added.
54#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
55#[repr(u32)]
56pub enum SecureMemoryMode {
57    Off = 0,
58    On = 1,
59}
60
61impl SecureMemoryMode {
62    #[inline]
63    pub fn from_primitive(prim: u32) -> Option<Self> {
64        match prim {
65            0 => Some(Self::Off),
66            1 => Some(Self::On),
67            _ => None,
68        }
69    }
70
71    #[inline]
72    pub const fn into_primitive(self) -> u32 {
73        self as u32
74    }
75}
76
77/// Deprecated.
78///
79/// Rather than listening for OnCodecList, clients needing codec information prior to just
80/// requesting a codec with CodecFactory.CreateDecoder or CodecFactory.CreateEncoder should instead
81/// use GetDetailedCodecDescriptions to get the DetailedCodecDescription table instead, which has
82/// per-profile-entry equivalents of all these fields.  Clients with no real need for codec
83/// information prior to requesting a codec can call CodecFactory.CreateDecoder or
84/// CodecFactory.CreateEncoder with relevant requirements set in that request, and then
85/// StreamProcessor.Sync to see if a codec was actually created successfully.
86///
87/// In contrast to OnCodecList which uses FIDL structs (due to ordering of historical events),
88/// GetDetailedCodecDescriptions uses FIDL tables so is not expected to need to be deprecated, since
89/// we can add new table fields as needed, and gradually deprecate old table fields if appropriate,
90/// without deprecating the whole thing.
91///
92/// Per-codec servers do not need to fill out this struct or send OnCodecList, as the main
93/// CodecFactory will construct the OnCodecList info from the GetDetailedCodecDescriptions info, so
94/// that each codec can (optionally) stop sending OnCodecList immediately, rather than having to
95/// wait for all clients to stop listening to OnCodecList, which may take a while.  All codecs _do_
96/// need to implement GetDetailedCodecDescriptions however.
97#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
98pub struct CodecDescription {
99    /// Decoder or encoder.
100    pub codec_type: CodecType,
101    /// The mime type of the compressed format.  For decoders this is the mime
102    /// type of the input.  For encoders, this is the mime type of the output.
103    pub mime_type: String,
104    /// For each of these fields, the default is the most-capable setting, but
105    /// if a codec doesn't support the most-capable behavior, then the codec
106    /// must override the default.
107    pub can_stream_bytes_input: bool,
108    pub can_find_start: bool,
109    pub can_re_sync: bool,
110    pub will_report_all_detected_errors: bool,
111    pub is_hw: bool,
112    pub split_header_handling: bool,
113}
114
115impl fidl::Persistable for CodecDescription {}
116
117#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
118pub struct CodecFactoryOnCodecListRequest {
119    pub codecs: Vec<CodecDescription>,
120}
121
122impl fidl::Persistable for CodecFactoryOnCodecListRequest {}
123
124#[derive(Clone, Debug, Default, PartialEq)]
125pub struct CodecFactoryGetDetailedCodecDescriptionsResponse {
126    pub codecs: Option<Vec<DetailedCodecDescription>>,
127    #[doc(hidden)]
128    pub __source_breaking: fidl::marker::SourceBreaking,
129}
130
131impl fidl::Persistable for CodecFactoryGetDetailedCodecDescriptionsResponse {}
132
133#[derive(Clone, Debug, Default, PartialEq)]
134pub struct CreateDecoderParams {
135    /// Input mime type for a decoder.
136    ///
137    /// The recognized mime types for now:
138    /// video/h264
139    /// video/vp9
140    /// audio/aac
141    ///   input_details.oob_bytes must be an AudioSpecificConfig() as defined
142    ///   by AAC spec.
143    /// audio/sbc
144    ///   input_details.oob_bytes must be Codec Specific Information Elements
145    ///   for SBC as defined by the A2DP spec.
146    pub input_details: Option<fidl_fuchsia_media__common::FormatDetails>,
147    /// This must be true in order for the client to be permitted to put a
148    /// timestamp on an input packet, which is in turn required to get any
149    /// timestamps on any output packets.
150    ///
151    /// It is always legal to provide separate Access Units (henceforth AUs) to a
152    /// decoder, but this boolean must be true for a decoder to accept and
153    /// propagate timestamp values.
154    ///
155    /// This must be true when creating a video encoder, or the CodecFactory
156    /// channel will close.
157    ///
158    /// If not set, interpreted as false.
159    pub promise_separate_access_units_on_input: Option<bool>,
160    /// Require that the selected codec be capable of accepting input where
161    /// AUs are not separated into separate packets.
162    ///
163    /// This does not imply that the decoder can find the start of the first AU;
164    /// for that see require_can_find_start.  This does not imply that the decoder
165    /// can re-sync on its own if the stream data is damaged; for that see
166    /// require_can_re_sync.
167    ///
168    /// If both promise_separate_access_units_on_input and
169    /// require_can_stream_bytes_input are true, the CodecFactory channel will
170    /// close.
171    ///
172    /// If this is false, the client must feed separate AUs on the fuchsia.ui.input.  This
173    /// must be false for a video encoder, and if true the CodecFactory channel
174    /// will close.
175    ///
176    /// Unless a client demands a decoder capable of taking concatenated AUs
177    /// (require_can_stream_bytes_input true), the client must feed a decoder
178    /// separate AUs.  This means the client cannot have parts of two separate AUs
179    /// in the same packet, unless require_can_stream_bytes_input is true.
180    ///
181    /// If not set, interpreted as false.
182    pub require_can_stream_bytes_input: Option<bool>,
183    /// A decoder is allowed to be capable of streaming bytes but not capable of
184    /// searching for the start of the first usable AU.  To require both, set both
185    /// require_can_stream_bytes_input and require_can_find_start.  Setting
186    /// require_can_find_start without require_can_stream_bytes_input is invalid.
187    ///
188    /// With require_can_stream_bytes_input true but require_can_find_start false,
189    /// the client must start the first packet with the start of an AU, but can
190    /// send a stream of bytes after that.
191    ///
192    /// If not set, interpreted as false.
193    pub require_can_find_start: Option<bool>,
194    /// On problematic input data, all decoders are expected to at least be able to
195    /// close the channel rather than getting stuck in a failed and/or broken
196    /// state.
197    ///
198    /// A decoder returned from a request with require_can_re_sync is potentially
199    /// able to handle damaged input without closing the Codec channel.  Such a
200    /// Codec is encouraged, but not required, to also satisfy requirements of
201    /// require_report_all_detected_errors.
202    ///
203    /// If not set, interpreted as false.
204    pub require_can_re_sync: Option<bool>,
205    /// Sometimes a client would rather fail an overall use of a decoder than fail
206    /// to notice data corruption.  For such scenarios, the client can specify
207    /// require_report_all_detected_errors.  For any codec returned from a
208    /// request with require_report_all_detected_errors set, on detection of
209    /// any input data corruption the codec will report in one or more of these
210    /// ways:
211    ///   * closing the Codec channel
212    ///   * OnStreamFailed()
213    ///   * error_detected_before
214    ///   * error_detected_during
215    ///
216    /// If false, a codec may silently skip past corrupted input data.
217    ///
218    /// No decoder can detect all corruption, because some corruption can look like
219    /// valid stream data.  This requirement is only to request a codec that
220    /// is written to attempt to detect _and report_ input stream corruption.
221    ///
222    /// This flag is not intended to be 100% bulletproof.  If a client needs robust
223    /// assurance that _all_ detectable stream corruption is _always_ detected,
224    /// this flag is not enough of a guarantee to achieve that.  Since some stream
225    /// corruption is inherently non-detectable in any case, such a client should
226    /// consider using stronger techniques upstream to ensure that corruption can
227    /// be detected with the needed probability very close to 1.
228    ///
229    /// This flag being true doesn't imply anything about whether the codec will
230    /// discard damaged data vs. producing corresponding damaged output.  Only that
231    /// the codec will set error_detected_* bools to true when appropriate.
232    ///
233    /// Regardless of this setting, not all timestamp_ish values provided on input
234    /// are guaranteed to show up on output.
235    ///
236    /// If not set, interpreted as false.
237    pub require_report_all_detected_errors: Option<bool>,
238    /// If true, require that the returned codec is HW-accelerated.  See also
239    /// `require_sw`.
240    ///
241    /// If not set, interpreted as false.
242    pub require_hw: Option<bool>,
243    /// permit_lack_of_split_header_handling
244    ///
245    /// This field is a temporary field that will be going away.
246    ///
247    /// TODO(dustingreen): Remove this field once we're down to zero codecs with
248    /// problems handling split headers.
249    ///
250    /// By default, a Codec instance is required to handle "split headers", meaning
251    /// that a client is allowed to deliver parts of an AU one byte at a time,
252    /// including parts near the beginning of the AU, and the codec is required to
253    /// tolerate and handle that properly.  However, unfortunately not all codecs
254    /// properly support split headers.  If a client is willing to permit such a
255    /// codec to be used, the client can set this to true.  Clients are not
256    /// encouraged to set this, but setting it may be necessary to find a codec for
257    /// some formats _for now_.  If a client sets this to true, the client should
258    /// deliver data of each AU with many contiguous non-split bytes from the start
259    /// of each AU.  The client is not strictly required to deliver one AU at a
260    /// time, only to ensure that either all the AU bytes are in a single packet or
261    /// that many bytes at the start of each AU are in a single packet.
262    ///
263    /// The specification for how a client should use this and how a client should
264    /// behave if setting this to true is intentionally vague, because lack of
265    /// support for header splitting is not ideal, and is expected to be
266    /// temporary, and all codecs should handle split headers in the long run.
267    /// The main intent of this field is to avoid giving an innocent client using
268    /// default value of false here a codec that can't properly handle split
269    /// headers.  This is not an attempt at a mechanism to fully work around a
270    /// codec that doesn't handle split headers.
271    ///
272    /// If not set, interpreted as false.
273    pub permit_lack_of_split_header_handling: Option<bool>,
274    /// If set to ON, the decoder must support secure buffers on output, and
275    /// must reject non-secure buffers on output.
276    ///
277    /// If set to OFF or not set, the created decoder will reject secure buffers
278    /// on output by closing the StreamProcessor channel.
279    ///
280    /// If secure_input_mode ON, secure_output_mode must also be ON.
281    pub secure_output_mode: Option<SecureMemoryMode>,
282    /// If set to ON, the decoder must support secure buffers on input and must
283    /// reject non-secure buffers on input.
284    ///
285    /// If set to OFF or not set, the created decoder will reject secure buffers
286    /// on input by closing the StreamProcessor channel.
287    ///
288    /// If secure_input_mode ON, secure_output_mode must also be ON.
289    pub secure_input_mode: Option<SecureMemoryMode>,
290    /// If true, require that the returned codec is entirely SW-based, not
291    /// HW-accelerated (other than possibly using vector CPU instructions).
292    /// This can be useful for testing purposes or other special scenarios, but
293    /// is not recommended for performance-sensitive scenarios.  Also, some
294    /// builds may lack a SW-based decoder for some formats.  See also
295    /// `require_hw`.
296    ///
297    /// If not set, interpreted as false.
298    pub require_sw: Option<bool>,
299    #[doc(hidden)]
300    pub __source_breaking: fidl::marker::SourceBreaking,
301}
302
303impl fidl::Persistable for CreateDecoderParams {}
304
305/// Parameters used to request an encoder.
306#[derive(Clone, Debug, Default, PartialEq)]
307pub struct CreateEncoderParams {
308    /// The format of the uncompressed input data.
309    ///
310    /// This field should be a raw mime_type (e.g. 'video/raw') and uncompressed
311    /// format details for the encoder to use when reading buffers.
312    ///
313    /// To be elibigible an encoder must support the input format.
314    pub input_details: Option<fidl_fuchsia_media__common::FormatDetails>,
315    /// If true, require that the returned codec is HW-accelerated.
316    ///
317    /// If not set, interpreted as false.
318    pub require_hw: Option<bool>,
319    #[doc(hidden)]
320    pub __source_breaking: fidl::marker::SourceBreaking,
321}
322
323impl fidl::Persistable for CreateEncoderParams {}
324
325/// Specification of the supported parameters of a given video decoder.
326///
327/// Fields in this table with the same name as fields in CodecDescription have the same meaning as
328/// the fields in the CodecDescription struct when the corresponding field in this table is set.
329///
330/// When a corresponding field is un-set, each of these fields is interpreted according to the
331/// corresponding doc comment on the field in this table (doc comments on fields in the
332/// CodecDescription struct re. struct field defaults are not relevant to the interpretation of
333/// un-set fields of this table).
334///
335/// For video decoders, the following is always required:
336///   * Handling split input payload (distinct from split header), when an input frame is too large
337///     for a single input buffer.  The next portion (possibly the remainder) of the timstamped
338///     input chunk is delivered in the next input packet.
339///
340/// For audio decoders, the following is always required:
341///   * Concatenation of multiple compressed audio chunks via the input is always permitted.
342#[derive(Clone, Debug, Default, PartialEq)]
343pub struct DecoderProfileDescription {
344    /// The codec profile that this decoder supports. If the client wants to use this
345    /// profile, the requirements specified in this table must be adhered to.
346    pub profile: Option<fidl_fuchsia_media__common::CodecProfile>,
347    /// The minimum image size this decoder supports for the given |profile|.
348    /// Decoders must set this field, and this field must specify a size that is
349    /// >= the min size defined for the profile in the codec spec.
350    ///
351    /// This size refers to the pixel layout in memory, not the display_rect which can be smaller
352    /// than the fuchsia.Images2.ImageFormat.size / fuchsia.sysmem.ImageFormat2.coded_width/height.
353    pub min_image_size: Option<fidl_fuchsia_math__common::SizeU>,
354    /// The maximum image size this decoder supports for the given |profile|.
355    ///
356    /// Decoders must set this field, and this field must specify a size that is <= the max size
357    /// defined for the profile in the codec spec.
358    ///
359    /// This size refers to the pixel layout in memory, not the display_rect which can be smaller
360    /// than the fuchsia.Images2.ImageFormat.size / fuchsia.sysmem.ImageFormat2.coded_width/height.
361    ///
362    /// By setting this field, a decoder is not required to fail to decode a stream that specifies a
363    /// size that is larger than the profile of the stream would normally allow. The decoder may or
364    /// may not fail to decode a stream which is not a listed profile or not within the size bounds
365    /// of a listed profile.
366    pub max_image_size: Option<fidl_fuchsia_math__common::SizeU>,
367    /// This |profile| entry can apply to encrypted input data. If require_encryption is false or
368    /// unset, this |profile| entry can also apply to unencrypted input data.
369    ///
370    /// This will be un-set (even when allow_input_protection or require_input_protection are true)
371    /// until Fuchsia supports decryption as part of decode (in contrast to it being a separate step
372    /// involving protected memory in between).  When allow_encryption is false/un-set but
373    /// allow_input_protection is true, a client setting up DRM decode should set up decryption as a
374    /// separate step prior to decode with protected memory in between the decrypt and decode.
375    pub allow_encryption: Option<bool>,
376    /// This |profile| entry applies only when input data is encrypted.  This |profile| entry does
377    /// not apply for unencrypted input data.  Un-set is interepted as false.
378    ///
379    /// If this is set to true and there is no profile with require_encryption false in the same
380    /// DetailedCodecDescription, then this decoder only supports encrypted input.
381    ///
382    /// This will be un-set until Fuchsia supports decryption as part of decode (even when
383    /// allow_input_protection or require_input_protection are true).  See also allow_encryption,
384    /// allow_input_protection, require_input_protection.
385    pub require_encryption: Option<bool>,
386    /// This |profile| entry can apply when input data delivered via protected memory.  Whether to
387    /// protect input and which protected "heap" to use (if protecting input) is determined during
388    /// sysmem constraints aggregation and via DRM mechanisms.  See also require_input_protection,
389    /// allow_encryption, require_encryption.
390    pub allow_input_protection: Option<bool>,
391    /// This |profile| entry applies only when input data is delivered via protected memory. Whether
392    /// to protect input and which protected "heap" to use (if protecting input) is determined
393    /// during sysmem constraints aggregation, and by separate DRM mechanisms.
394    ///
395    /// If this is set to true and there is no profile with require_input_protection false in the
396    /// same DetailedCodecDescription, then this decoder only supports protected input.
397    ///
398    /// Output protection is negotiated separately during output buffer constraints aggregation in
399    /// sysmem, and via DRM mechanisms.
400    ///
401    /// See also allow_input_protection, allow_encryption, require_encryption.
402    pub require_input_protection: Option<bool>,
403    /// If set to true, the decoder can handle an input chunk payload (containing compressed data)
404    /// that's split across a packet boundary (between header and payload, or between payload
405    /// bytes), and the decoder can also handle more than one input chunk containing compressed
406    /// input data in a single input packet. See also split_header_handling to determine if the
407    /// decoder can also handle split headers.
408    ///
409    /// Un-set means false.
410    ///
411    /// While this field always indicates whether it's ok to split an input chunk across a packet
412    /// boundary or not, and this field being set always implies it's ok to have a single input
413    /// packet with bytes from more than one input chunk including when the input chunks contain
414    /// compressed input data, there is some additional somewhat-subtle meaning that differs between
415    /// video and audio decoders.
416    ///
417    /// Audio decoders are always required to permit more than one input chunk in a single input
418    /// packet, including mulitple input chunks which each contain compressed input data (not just
419    /// prepended "context" headers), regardless of this field being set or unset.  For audio
420    /// decoders, this field only indicates whether splitting an input chunk across packets is
421    /// allowed.
422    ///
423    /// Audio decoders shouldn't set split_header_handling to true unless they also set
424    /// can_stream_bytes_input to true, since allowing splitting header bytes is meaningless unless
425    /// it's allowed to split an input chunk.
426    ///
427    /// For video decoders, if this field is un-set or false, the decoder may not be able to handle
428    /// bytes of more than one input chunk in a single input packet.  However, for all decoders
429    /// (both video and audio) it's always ok for preceding "context" headers such as the h264 SPS
430    /// and PPS headers to be in the same input packet as the following input chunk containing
431    /// compressed input data such as an h264 slice (for example).  A video decoder is always
432    /// required to permit continuation of an input chunk in the next packet, with the split between
433    /// header byte and compressed input data byte or between two compressed input data bytes (but
434    /// not necessarily between two header bytes; see also split_header_handling).
435    ///
436    /// It's expected to be fairly common for a decoder to set can_stream_bytes_input to true, but
437    /// leave split_header_handling un-set or set split_header_handling to false, due to parsing
438    /// limitations in the HW, FW, or driver.  Decoders which set can_stream_bytes_input false or
439    /// leave can_stream_bytes_input un-set may be forcing input data to be re-packed in some
440    /// scenarios.  Profiles which set allow_encryption are encouraged to also set
441    /// can_stream_bytes_input if feasible, as re-packing input data can be more difficult in some
442    /// scenarios involving encryption.
443    pub can_stream_bytes_input: Option<bool>,
444    /// If set to true, the decoder can scan forward at the start of a stream to find the start of
445    /// the first fully-present input chunk, even if the input data starts at a byte that's in the
446    /// middle of a chunk.
447    ///
448    /// For both video and audio decoders, setting this field to true also indicates the ability to
449    /// handle (skip or only partly use) any input chunks that are not possible to decode (or not
450    /// possible to fully decode) due to lack of referenced prior data.
451    ///
452    /// If un-set or false, the decoder may not be able to scan forward to sync up with the input
453    /// stream unless the input stream starts with the beginning of a suitable chunk.
454    pub can_find_start: Option<bool>,
455    /// If set to true, the decoder can resynchronize with the input stream (eventually) despite a
456    /// missing input chunk, and can handle partial input chunks without failing the stream or the
457    /// StreamProcessor control connection.
458    pub can_re_sync: Option<bool>,
459    /// If set to true, the decoder makes efforts to indicate partial or detected-as-missing or
460    /// detected-as-corrupt input chunks by setting error_detected_before and/or
461    /// error_detected_during as appropriate.  Even when this field is set to true, it is worth
462    /// noting that in general it is not possible for a decoder to detect all possible data
463    /// corruptions, as codecs generally aren't inclined to include error detection bits within the
464    /// stream.  This is not a replacment for a real (as in robust with high probability against
465    /// random bit flips and bit insertion/deletion) data integrity check.
466    pub will_report_all_detected_errors: Option<bool>,
467    /// If set to true, the decoder can handle the bytes of any header being split across packet
468    /// boundaries.  If false or un-set, the decoder requires all header bytes of a header to be
469    /// within the same packet.
470    ///
471    /// Starting a new packet at the spec-defined boundary between two headers that are officially
472    /// in separate input chunks is always permitted.
473    ///
474    /// For purposes of this field, headers like the h264 SPS and PPS headers are considered
475    /// separate input chunks, and so such headers that have their own input chunk can be delivered
476    /// in a separate packet regardless of the setting of this field, and a subsequent h264 slice
477    /// header can be in yet another packet.
478    ///
479    /// It is always permissible regardless of the setting of this field for "context" headers (such
480    /// as h264 SPS and PPS headers) to be delivered in the same packet as the subsequent chunk
481    /// which conveys compressed image data (such as an h264 slice).
482    ///
483    /// Splitting a single header between codec_oob_bytes and the stream data is never supported (as
484    /// in, never to be relied on by clients), not even when this field is set to true.
485    ///
486    /// See also can_stream_bytes_input.
487    ///
488    /// Video decoders with can_stream_bytes_input true but split_header_handling false can handle
489    /// continuing an chunk in the next packet when split between header and payload or between
490    /// payload bytes, and can handle bytes of more than one input chunk in a single input packet,
491    /// but cannot handle splitting a header across packets. Video decoders with
492    /// can_stream_bytes_input false and split_header_handling true cannot tolerate bytes of more
493    /// than one input chunk in a single packet, but can tolerate continuation of an input chunk in
494    /// a following packet regardless of where the split occurs (such as in the middle of an h264
495    /// SPS, PPS, or slice header).
496    ///
497    /// Audio decoders shouldn't set split_header_handling to true unless they also set
498    /// can_stream_bytes_input to true, since for an audio decoder, allowing splitting header bytes
499    /// is meaningless (for audio decoders) unless also allowing splitting an input chunk.
500    pub split_header_handling: Option<bool>,
501    #[doc(hidden)]
502    pub __source_breaking: fidl::marker::SourceBreaking,
503}
504
505impl fidl::Persistable for DecoderProfileDescription {}
506
507/// Clients needing codec information prior to just requesting a codec with
508/// CodecFactory.CreateDecoder or CodecFactory.CreateEncoder should use GetDetailedCodecDescriptions
509/// to get this table, which has details re. the codec and the profile entries supported by the
510/// codec.
511///
512/// Clients with no real need for codec information prior to requesting a codec can simply use
513/// CodecFactory.CreateDecoder or CodecFactory.CreateEncoder with relevant requirements set in that
514/// request, and then call StreamProcessor.Sync (round trip) to see if a codec was created
515/// successfully.
516#[derive(Clone, Debug, Default, PartialEq)]
517pub struct DetailedCodecDescription {
518    /// Decoder or encoder.
519    pub codec_type: Option<CodecType>,
520    /// The mime type of the compressed format.  For decoders this is the mime
521    /// type of the input.  For encoders, this is the mime type of the output.
522    pub mime_type: Option<String>,
523    /// If this decoder/encoder uses underlying hardware to perform its operations.
524    pub is_hw: Option<bool>,
525    /// A list of profile descriptions that describe what codec profiles this
526    /// encoder/decoder supports along with requirements for using each profile.
527    pub profile_descriptions: Option<ProfileDescriptions>,
528    #[doc(hidden)]
529    pub __source_breaking: fidl::marker::SourceBreaking,
530}
531
532impl fidl::Persistable for DetailedCodecDescription {}
533
534#[derive(Clone, Debug, Default, PartialEq)]
535pub struct EncoderProfileDescription {
536    pub profile: Option<fidl_fuchsia_media__common::CodecProfile>,
537    #[doc(hidden)]
538    pub __source_breaking: fidl::marker::SourceBreaking,
539}
540
541impl fidl::Persistable for EncoderProfileDescription {}
542
543#[derive(Clone, Debug, PartialEq)]
544pub enum ProfileDescriptions {
545    /// A list of |DecoderProfileDescription| that describe what codec profiles this
546    /// decoder supports along with requirements that must be adhered to if the client
547    /// is to use the decoder. The CodecFactory guarantees to the client that each
548    /// |DecoderProfileDescription| within |decoder_profile_descriptions| will have an
549    /// unique |profile|.
550    DecoderProfileDescriptions(Vec<DecoderProfileDescription>),
551    EncoderProfileDescriptions(Vec<EncoderProfileDescription>),
552}
553
554impl ProfileDescriptions {
555    #[inline]
556    pub fn ordinal(&self) -> u64 {
557        match *self {
558            Self::DecoderProfileDescriptions(_) => 1,
559            Self::EncoderProfileDescriptions(_) => 2,
560        }
561    }
562}
563
564impl fidl::Persistable for ProfileDescriptions {}
565
566pub mod codec_factory_ordinals {
567    pub const ON_CODEC_LIST: u64 = 0x2f93e3d51ff1ace0;
568    pub const GET_DETAILED_CODEC_DESCRIPTIONS: u64 = 0x7a3a1c956352d49a;
569    pub const CREATE_DECODER: u64 = 0x72a3c2035a1e94f0;
570    pub const CREATE_ENCODER: u64 = 0x20c3a235602eed0f;
571    pub const ATTACH_LIFETIME_TRACKING: u64 = 0x1086674ad2568498;
572}
573
574mod internal {
575    use super::*;
576    unsafe impl fidl::encoding::TypeMarker for CodecType {
577        type Owned = Self;
578
579        #[inline(always)]
580        fn inline_align(_context: fidl::encoding::Context) -> usize {
581            std::mem::align_of::<u32>()
582        }
583
584        #[inline(always)]
585        fn inline_size(_context: fidl::encoding::Context) -> usize {
586            std::mem::size_of::<u32>()
587        }
588
589        #[inline(always)]
590        fn encode_is_copy() -> bool {
591            true
592        }
593
594        #[inline(always)]
595        fn decode_is_copy() -> bool {
596            false
597        }
598    }
599
600    impl fidl::encoding::ValueTypeMarker for CodecType {
601        type Borrowed<'a> = Self;
602        #[inline(always)]
603        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
604            *value
605        }
606    }
607
608    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CodecType {
609        #[inline]
610        unsafe fn encode(
611            self,
612            encoder: &mut fidl::encoding::Encoder<'_, D>,
613            offset: usize,
614            _depth: fidl::encoding::Depth,
615        ) -> fidl::Result<()> {
616            encoder.debug_check_bounds::<Self>(offset);
617            encoder.write_num(self.into_primitive(), offset);
618            Ok(())
619        }
620    }
621
622    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CodecType {
623        #[inline(always)]
624        fn new_empty() -> Self {
625            Self::Decoder
626        }
627
628        #[inline]
629        unsafe fn decode(
630            &mut self,
631            decoder: &mut fidl::encoding::Decoder<'_, D>,
632            offset: usize,
633            _depth: fidl::encoding::Depth,
634        ) -> fidl::Result<()> {
635            decoder.debug_check_bounds::<Self>(offset);
636            let prim = decoder.read_num::<u32>(offset);
637
638            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
639            Ok(())
640        }
641    }
642    unsafe impl fidl::encoding::TypeMarker for SecureMemoryMode {
643        type Owned = Self;
644
645        #[inline(always)]
646        fn inline_align(_context: fidl::encoding::Context) -> usize {
647            std::mem::align_of::<u32>()
648        }
649
650        #[inline(always)]
651        fn inline_size(_context: fidl::encoding::Context) -> usize {
652            std::mem::size_of::<u32>()
653        }
654
655        #[inline(always)]
656        fn encode_is_copy() -> bool {
657            true
658        }
659
660        #[inline(always)]
661        fn decode_is_copy() -> bool {
662            false
663        }
664    }
665
666    impl fidl::encoding::ValueTypeMarker for SecureMemoryMode {
667        type Borrowed<'a> = Self;
668        #[inline(always)]
669        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
670            *value
671        }
672    }
673
674    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
675        for SecureMemoryMode
676    {
677        #[inline]
678        unsafe fn encode(
679            self,
680            encoder: &mut fidl::encoding::Encoder<'_, D>,
681            offset: usize,
682            _depth: fidl::encoding::Depth,
683        ) -> fidl::Result<()> {
684            encoder.debug_check_bounds::<Self>(offset);
685            encoder.write_num(self.into_primitive(), offset);
686            Ok(())
687        }
688    }
689
690    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SecureMemoryMode {
691        #[inline(always)]
692        fn new_empty() -> Self {
693            Self::Off
694        }
695
696        #[inline]
697        unsafe fn decode(
698            &mut self,
699            decoder: &mut fidl::encoding::Decoder<'_, D>,
700            offset: usize,
701            _depth: fidl::encoding::Depth,
702        ) -> fidl::Result<()> {
703            decoder.debug_check_bounds::<Self>(offset);
704            let prim = decoder.read_num::<u32>(offset);
705
706            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
707            Ok(())
708        }
709    }
710
711    impl fidl::encoding::ValueTypeMarker for CodecDescription {
712        type Borrowed<'a> = &'a Self;
713        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
714            value
715        }
716    }
717
718    unsafe impl fidl::encoding::TypeMarker for CodecDescription {
719        type Owned = Self;
720
721        #[inline(always)]
722        fn inline_align(_context: fidl::encoding::Context) -> usize {
723            8
724        }
725
726        #[inline(always)]
727        fn inline_size(_context: fidl::encoding::Context) -> usize {
728            32
729        }
730    }
731
732    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CodecDescription, D>
733        for &CodecDescription
734    {
735        #[inline]
736        unsafe fn encode(
737            self,
738            encoder: &mut fidl::encoding::Encoder<'_, D>,
739            offset: usize,
740            _depth: fidl::encoding::Depth,
741        ) -> fidl::Result<()> {
742            encoder.debug_check_bounds::<CodecDescription>(offset);
743            // Delegate to tuple encoding.
744            fidl::encoding::Encode::<CodecDescription, D>::encode(
745                (
746                    <CodecType as fidl::encoding::ValueTypeMarker>::borrow(&self.codec_type),
747                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
748                        &self.mime_type,
749                    ),
750                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.can_stream_bytes_input),
751                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.can_find_start),
752                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.can_re_sync),
753                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
754                        &self.will_report_all_detected_errors,
755                    ),
756                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_hw),
757                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.split_header_handling),
758                ),
759                encoder,
760                offset,
761                _depth,
762            )
763        }
764    }
765    unsafe impl<
766            D: fidl::encoding::ResourceDialect,
767            T0: fidl::encoding::Encode<CodecType, D>,
768            T1: fidl::encoding::Encode<fidl::encoding::BoundedString<256>, D>,
769            T2: fidl::encoding::Encode<bool, D>,
770            T3: fidl::encoding::Encode<bool, D>,
771            T4: fidl::encoding::Encode<bool, D>,
772            T5: fidl::encoding::Encode<bool, D>,
773            T6: fidl::encoding::Encode<bool, D>,
774            T7: fidl::encoding::Encode<bool, D>,
775        > fidl::encoding::Encode<CodecDescription, D> for (T0, T1, T2, T3, T4, T5, T6, T7)
776    {
777        #[inline]
778        unsafe fn encode(
779            self,
780            encoder: &mut fidl::encoding::Encoder<'_, D>,
781            offset: usize,
782            depth: fidl::encoding::Depth,
783        ) -> fidl::Result<()> {
784            encoder.debug_check_bounds::<CodecDescription>(offset);
785            // Zero out padding regions. There's no need to apply masks
786            // because the unmasked parts will be overwritten by fields.
787            unsafe {
788                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
789                (ptr as *mut u64).write_unaligned(0);
790            }
791            unsafe {
792                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
793                (ptr as *mut u64).write_unaligned(0);
794            }
795            // Write the fields.
796            self.0.encode(encoder, offset + 0, depth)?;
797            self.1.encode(encoder, offset + 8, depth)?;
798            self.2.encode(encoder, offset + 24, depth)?;
799            self.3.encode(encoder, offset + 25, depth)?;
800            self.4.encode(encoder, offset + 26, depth)?;
801            self.5.encode(encoder, offset + 27, depth)?;
802            self.6.encode(encoder, offset + 28, depth)?;
803            self.7.encode(encoder, offset + 29, depth)?;
804            Ok(())
805        }
806    }
807
808    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CodecDescription {
809        #[inline(always)]
810        fn new_empty() -> Self {
811            Self {
812                codec_type: fidl::new_empty!(CodecType, D),
813                mime_type: fidl::new_empty!(fidl::encoding::BoundedString<256>, D),
814                can_stream_bytes_input: fidl::new_empty!(bool, D),
815                can_find_start: fidl::new_empty!(bool, D),
816                can_re_sync: fidl::new_empty!(bool, D),
817                will_report_all_detected_errors: fidl::new_empty!(bool, D),
818                is_hw: fidl::new_empty!(bool, D),
819                split_header_handling: fidl::new_empty!(bool, D),
820            }
821        }
822
823        #[inline]
824        unsafe fn decode(
825            &mut self,
826            decoder: &mut fidl::encoding::Decoder<'_, D>,
827            offset: usize,
828            _depth: fidl::encoding::Depth,
829        ) -> fidl::Result<()> {
830            decoder.debug_check_bounds::<Self>(offset);
831            // Verify that padding bytes are zero.
832            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
833            let padval = unsafe { (ptr as *const u64).read_unaligned() };
834            let mask = 0xffffffff00000000u64;
835            let maskedval = padval & mask;
836            if maskedval != 0 {
837                return Err(fidl::Error::NonZeroPadding {
838                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
839                });
840            }
841            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
842            let padval = unsafe { (ptr as *const u64).read_unaligned() };
843            let mask = 0xffff000000000000u64;
844            let maskedval = padval & mask;
845            if maskedval != 0 {
846                return Err(fidl::Error::NonZeroPadding {
847                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
848                });
849            }
850            fidl::decode!(CodecType, D, &mut self.codec_type, decoder, offset + 0, _depth)?;
851            fidl::decode!(
852                fidl::encoding::BoundedString<256>,
853                D,
854                &mut self.mime_type,
855                decoder,
856                offset + 8,
857                _depth
858            )?;
859            fidl::decode!(bool, D, &mut self.can_stream_bytes_input, decoder, offset + 24, _depth)?;
860            fidl::decode!(bool, D, &mut self.can_find_start, decoder, offset + 25, _depth)?;
861            fidl::decode!(bool, D, &mut self.can_re_sync, decoder, offset + 26, _depth)?;
862            fidl::decode!(
863                bool,
864                D,
865                &mut self.will_report_all_detected_errors,
866                decoder,
867                offset + 27,
868                _depth
869            )?;
870            fidl::decode!(bool, D, &mut self.is_hw, decoder, offset + 28, _depth)?;
871            fidl::decode!(bool, D, &mut self.split_header_handling, decoder, offset + 29, _depth)?;
872            Ok(())
873        }
874    }
875
876    impl fidl::encoding::ValueTypeMarker for CodecFactoryOnCodecListRequest {
877        type Borrowed<'a> = &'a Self;
878        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
879            value
880        }
881    }
882
883    unsafe impl fidl::encoding::TypeMarker for CodecFactoryOnCodecListRequest {
884        type Owned = Self;
885
886        #[inline(always)]
887        fn inline_align(_context: fidl::encoding::Context) -> usize {
888            8
889        }
890
891        #[inline(always)]
892        fn inline_size(_context: fidl::encoding::Context) -> usize {
893            16
894        }
895    }
896
897    unsafe impl<D: fidl::encoding::ResourceDialect>
898        fidl::encoding::Encode<CodecFactoryOnCodecListRequest, D>
899        for &CodecFactoryOnCodecListRequest
900    {
901        #[inline]
902        unsafe fn encode(
903            self,
904            encoder: &mut fidl::encoding::Encoder<'_, D>,
905            offset: usize,
906            _depth: fidl::encoding::Depth,
907        ) -> fidl::Result<()> {
908            encoder.debug_check_bounds::<CodecFactoryOnCodecListRequest>(offset);
909            // Delegate to tuple encoding.
910            fidl::encoding::Encode::<CodecFactoryOnCodecListRequest, D>::encode(
911                (
912                    <fidl::encoding::Vector<CodecDescription, 256> as fidl::encoding::ValueTypeMarker>::borrow(&self.codecs),
913                ),
914                encoder, offset, _depth
915            )
916        }
917    }
918    unsafe impl<
919            D: fidl::encoding::ResourceDialect,
920            T0: fidl::encoding::Encode<fidl::encoding::Vector<CodecDescription, 256>, D>,
921        > fidl::encoding::Encode<CodecFactoryOnCodecListRequest, D> for (T0,)
922    {
923        #[inline]
924        unsafe fn encode(
925            self,
926            encoder: &mut fidl::encoding::Encoder<'_, D>,
927            offset: usize,
928            depth: fidl::encoding::Depth,
929        ) -> fidl::Result<()> {
930            encoder.debug_check_bounds::<CodecFactoryOnCodecListRequest>(offset);
931            // Zero out padding regions. There's no need to apply masks
932            // because the unmasked parts will be overwritten by fields.
933            // Write the fields.
934            self.0.encode(encoder, offset + 0, depth)?;
935            Ok(())
936        }
937    }
938
939    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
940        for CodecFactoryOnCodecListRequest
941    {
942        #[inline(always)]
943        fn new_empty() -> Self {
944            Self { codecs: fidl::new_empty!(fidl::encoding::Vector<CodecDescription, 256>, D) }
945        }
946
947        #[inline]
948        unsafe fn decode(
949            &mut self,
950            decoder: &mut fidl::encoding::Decoder<'_, D>,
951            offset: usize,
952            _depth: fidl::encoding::Depth,
953        ) -> fidl::Result<()> {
954            decoder.debug_check_bounds::<Self>(offset);
955            // Verify that padding bytes are zero.
956            fidl::decode!(fidl::encoding::Vector<CodecDescription, 256>, D, &mut self.codecs, decoder, offset + 0, _depth)?;
957            Ok(())
958        }
959    }
960
961    impl CodecFactoryGetDetailedCodecDescriptionsResponse {
962        #[inline(always)]
963        fn max_ordinal_present(&self) -> u64 {
964            if let Some(_) = self.codecs {
965                return 1;
966            }
967            0
968        }
969    }
970
971    impl fidl::encoding::ValueTypeMarker for CodecFactoryGetDetailedCodecDescriptionsResponse {
972        type Borrowed<'a> = &'a Self;
973        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
974            value
975        }
976    }
977
978    unsafe impl fidl::encoding::TypeMarker for CodecFactoryGetDetailedCodecDescriptionsResponse {
979        type Owned = Self;
980
981        #[inline(always)]
982        fn inline_align(_context: fidl::encoding::Context) -> usize {
983            8
984        }
985
986        #[inline(always)]
987        fn inline_size(_context: fidl::encoding::Context) -> usize {
988            16
989        }
990    }
991
992    unsafe impl<D: fidl::encoding::ResourceDialect>
993        fidl::encoding::Encode<CodecFactoryGetDetailedCodecDescriptionsResponse, D>
994        for &CodecFactoryGetDetailedCodecDescriptionsResponse
995    {
996        unsafe fn encode(
997            self,
998            encoder: &mut fidl::encoding::Encoder<'_, D>,
999            offset: usize,
1000            mut depth: fidl::encoding::Depth,
1001        ) -> fidl::Result<()> {
1002            encoder.debug_check_bounds::<CodecFactoryGetDetailedCodecDescriptionsResponse>(offset);
1003            // Vector header
1004            let max_ordinal: u64 = self.max_ordinal_present();
1005            encoder.write_num(max_ordinal, offset);
1006            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1007            // Calling encoder.out_of_line_offset(0) is not allowed.
1008            if max_ordinal == 0 {
1009                return Ok(());
1010            }
1011            depth.increment()?;
1012            let envelope_size = 8;
1013            let bytes_len = max_ordinal as usize * envelope_size;
1014            #[allow(unused_variables)]
1015            let offset = encoder.out_of_line_offset(bytes_len);
1016            let mut _prev_end_offset: usize = 0;
1017            if 1 > max_ordinal {
1018                return Ok(());
1019            }
1020
1021            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1022            // are envelope_size bytes.
1023            let cur_offset: usize = (1 - 1) * envelope_size;
1024
1025            // Zero reserved fields.
1026            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1027
1028            // Safety:
1029            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1030            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1031            //   envelope_size bytes, there is always sufficient room.
1032            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DetailedCodecDescription, 256>, D>(
1033            self.codecs.as_ref().map(<fidl::encoding::Vector<DetailedCodecDescription, 256> as fidl::encoding::ValueTypeMarker>::borrow),
1034            encoder, offset + cur_offset, depth
1035        )?;
1036
1037            _prev_end_offset = cur_offset + envelope_size;
1038
1039            Ok(())
1040        }
1041    }
1042
1043    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1044        for CodecFactoryGetDetailedCodecDescriptionsResponse
1045    {
1046        #[inline(always)]
1047        fn new_empty() -> Self {
1048            Self::default()
1049        }
1050
1051        unsafe fn decode(
1052            &mut self,
1053            decoder: &mut fidl::encoding::Decoder<'_, D>,
1054            offset: usize,
1055            mut depth: fidl::encoding::Depth,
1056        ) -> fidl::Result<()> {
1057            decoder.debug_check_bounds::<Self>(offset);
1058            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1059                None => return Err(fidl::Error::NotNullable),
1060                Some(len) => len,
1061            };
1062            // Calling decoder.out_of_line_offset(0) is not allowed.
1063            if len == 0 {
1064                return Ok(());
1065            };
1066            depth.increment()?;
1067            let envelope_size = 8;
1068            let bytes_len = len * envelope_size;
1069            let offset = decoder.out_of_line_offset(bytes_len)?;
1070            // Decode the envelope for each type.
1071            let mut _next_ordinal_to_read = 0;
1072            let mut next_offset = offset;
1073            let end_offset = offset + bytes_len;
1074            _next_ordinal_to_read += 1;
1075            if next_offset >= end_offset {
1076                return Ok(());
1077            }
1078
1079            // Decode unknown envelopes for gaps in ordinals.
1080            while _next_ordinal_to_read < 1 {
1081                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1082                _next_ordinal_to_read += 1;
1083                next_offset += envelope_size;
1084            }
1085
1086            let next_out_of_line = decoder.next_out_of_line();
1087            let handles_before = decoder.remaining_handles();
1088            if let Some((inlined, num_bytes, num_handles)) =
1089                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1090            {
1091                let member_inline_size = <fidl::encoding::Vector<DetailedCodecDescription, 256> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1092                if inlined != (member_inline_size <= 4) {
1093                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1094                }
1095                let inner_offset;
1096                let mut inner_depth = depth.clone();
1097                if inlined {
1098                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1099                    inner_offset = next_offset;
1100                } else {
1101                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1102                    inner_depth.increment()?;
1103                }
1104                let val_ref = self.codecs.get_or_insert_with(
1105                    || fidl::new_empty!(fidl::encoding::Vector<DetailedCodecDescription, 256>, D),
1106                );
1107                fidl::decode!(fidl::encoding::Vector<DetailedCodecDescription, 256>, D, val_ref, decoder, inner_offset, inner_depth)?;
1108                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1109                {
1110                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1111                }
1112                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1113                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1114                }
1115            }
1116
1117            next_offset += envelope_size;
1118
1119            // Decode the remaining unknown envelopes.
1120            while next_offset < end_offset {
1121                _next_ordinal_to_read += 1;
1122                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1123                next_offset += envelope_size;
1124            }
1125
1126            Ok(())
1127        }
1128    }
1129
1130    impl CreateDecoderParams {
1131        #[inline(always)]
1132        fn max_ordinal_present(&self) -> u64 {
1133            if let Some(_) = self.require_sw {
1134                return 11;
1135            }
1136            if let Some(_) = self.secure_input_mode {
1137                return 10;
1138            }
1139            if let Some(_) = self.secure_output_mode {
1140                return 9;
1141            }
1142            if let Some(_) = self.permit_lack_of_split_header_handling {
1143                return 8;
1144            }
1145            if let Some(_) = self.require_hw {
1146                return 7;
1147            }
1148            if let Some(_) = self.require_report_all_detected_errors {
1149                return 6;
1150            }
1151            if let Some(_) = self.require_can_re_sync {
1152                return 5;
1153            }
1154            if let Some(_) = self.require_can_find_start {
1155                return 4;
1156            }
1157            if let Some(_) = self.require_can_stream_bytes_input {
1158                return 3;
1159            }
1160            if let Some(_) = self.promise_separate_access_units_on_input {
1161                return 2;
1162            }
1163            if let Some(_) = self.input_details {
1164                return 1;
1165            }
1166            0
1167        }
1168    }
1169
1170    impl fidl::encoding::ValueTypeMarker for CreateDecoderParams {
1171        type Borrowed<'a> = &'a Self;
1172        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1173            value
1174        }
1175    }
1176
1177    unsafe impl fidl::encoding::TypeMarker for CreateDecoderParams {
1178        type Owned = Self;
1179
1180        #[inline(always)]
1181        fn inline_align(_context: fidl::encoding::Context) -> usize {
1182            8
1183        }
1184
1185        #[inline(always)]
1186        fn inline_size(_context: fidl::encoding::Context) -> usize {
1187            16
1188        }
1189    }
1190
1191    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CreateDecoderParams, D>
1192        for &CreateDecoderParams
1193    {
1194        unsafe fn encode(
1195            self,
1196            encoder: &mut fidl::encoding::Encoder<'_, D>,
1197            offset: usize,
1198            mut depth: fidl::encoding::Depth,
1199        ) -> fidl::Result<()> {
1200            encoder.debug_check_bounds::<CreateDecoderParams>(offset);
1201            // Vector header
1202            let max_ordinal: u64 = self.max_ordinal_present();
1203            encoder.write_num(max_ordinal, offset);
1204            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1205            // Calling encoder.out_of_line_offset(0) is not allowed.
1206            if max_ordinal == 0 {
1207                return Ok(());
1208            }
1209            depth.increment()?;
1210            let envelope_size = 8;
1211            let bytes_len = max_ordinal as usize * envelope_size;
1212            #[allow(unused_variables)]
1213            let offset = encoder.out_of_line_offset(bytes_len);
1214            let mut _prev_end_offset: usize = 0;
1215            if 1 > max_ordinal {
1216                return Ok(());
1217            }
1218
1219            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1220            // are envelope_size bytes.
1221            let cur_offset: usize = (1 - 1) * envelope_size;
1222
1223            // Zero reserved fields.
1224            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1225
1226            // Safety:
1227            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1228            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1229            //   envelope_size bytes, there is always sufficient room.
1230            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::FormatDetails, D>(
1231            self.input_details.as_ref().map(<fidl_fuchsia_media__common::FormatDetails as fidl::encoding::ValueTypeMarker>::borrow),
1232            encoder, offset + cur_offset, depth
1233        )?;
1234
1235            _prev_end_offset = cur_offset + envelope_size;
1236            if 2 > max_ordinal {
1237                return Ok(());
1238            }
1239
1240            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1241            // are envelope_size bytes.
1242            let cur_offset: usize = (2 - 1) * envelope_size;
1243
1244            // Zero reserved fields.
1245            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1246
1247            // Safety:
1248            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1249            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1250            //   envelope_size bytes, there is always sufficient room.
1251            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1252                self.promise_separate_access_units_on_input
1253                    .as_ref()
1254                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1255                encoder,
1256                offset + cur_offset,
1257                depth,
1258            )?;
1259
1260            _prev_end_offset = cur_offset + envelope_size;
1261            if 3 > max_ordinal {
1262                return Ok(());
1263            }
1264
1265            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1266            // are envelope_size bytes.
1267            let cur_offset: usize = (3 - 1) * envelope_size;
1268
1269            // Zero reserved fields.
1270            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1271
1272            // Safety:
1273            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1274            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1275            //   envelope_size bytes, there is always sufficient room.
1276            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1277                self.require_can_stream_bytes_input
1278                    .as_ref()
1279                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1280                encoder,
1281                offset + cur_offset,
1282                depth,
1283            )?;
1284
1285            _prev_end_offset = cur_offset + envelope_size;
1286            if 4 > max_ordinal {
1287                return Ok(());
1288            }
1289
1290            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1291            // are envelope_size bytes.
1292            let cur_offset: usize = (4 - 1) * envelope_size;
1293
1294            // Zero reserved fields.
1295            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1296
1297            // Safety:
1298            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1299            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1300            //   envelope_size bytes, there is always sufficient room.
1301            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1302                self.require_can_find_start
1303                    .as_ref()
1304                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1305                encoder,
1306                offset + cur_offset,
1307                depth,
1308            )?;
1309
1310            _prev_end_offset = cur_offset + envelope_size;
1311            if 5 > max_ordinal {
1312                return Ok(());
1313            }
1314
1315            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1316            // are envelope_size bytes.
1317            let cur_offset: usize = (5 - 1) * envelope_size;
1318
1319            // Zero reserved fields.
1320            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1321
1322            // Safety:
1323            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1324            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1325            //   envelope_size bytes, there is always sufficient room.
1326            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1327                self.require_can_re_sync
1328                    .as_ref()
1329                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1330                encoder,
1331                offset + cur_offset,
1332                depth,
1333            )?;
1334
1335            _prev_end_offset = cur_offset + envelope_size;
1336            if 6 > max_ordinal {
1337                return Ok(());
1338            }
1339
1340            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1341            // are envelope_size bytes.
1342            let cur_offset: usize = (6 - 1) * envelope_size;
1343
1344            // Zero reserved fields.
1345            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1346
1347            // Safety:
1348            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1349            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1350            //   envelope_size bytes, there is always sufficient room.
1351            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1352                self.require_report_all_detected_errors
1353                    .as_ref()
1354                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1355                encoder,
1356                offset + cur_offset,
1357                depth,
1358            )?;
1359
1360            _prev_end_offset = cur_offset + envelope_size;
1361            if 7 > max_ordinal {
1362                return Ok(());
1363            }
1364
1365            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1366            // are envelope_size bytes.
1367            let cur_offset: usize = (7 - 1) * envelope_size;
1368
1369            // Zero reserved fields.
1370            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1371
1372            // Safety:
1373            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1374            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1375            //   envelope_size bytes, there is always sufficient room.
1376            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1377                self.require_hw.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1378                encoder,
1379                offset + cur_offset,
1380                depth,
1381            )?;
1382
1383            _prev_end_offset = cur_offset + envelope_size;
1384            if 8 > max_ordinal {
1385                return Ok(());
1386            }
1387
1388            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1389            // are envelope_size bytes.
1390            let cur_offset: usize = (8 - 1) * envelope_size;
1391
1392            // Zero reserved fields.
1393            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1394
1395            // Safety:
1396            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1397            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1398            //   envelope_size bytes, there is always sufficient room.
1399            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1400                self.permit_lack_of_split_header_handling
1401                    .as_ref()
1402                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1403                encoder,
1404                offset + cur_offset,
1405                depth,
1406            )?;
1407
1408            _prev_end_offset = cur_offset + envelope_size;
1409            if 9 > max_ordinal {
1410                return Ok(());
1411            }
1412
1413            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1414            // are envelope_size bytes.
1415            let cur_offset: usize = (9 - 1) * envelope_size;
1416
1417            // Zero reserved fields.
1418            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1419
1420            // Safety:
1421            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1422            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1423            //   envelope_size bytes, there is always sufficient room.
1424            fidl::encoding::encode_in_envelope_optional::<SecureMemoryMode, D>(
1425                self.secure_output_mode
1426                    .as_ref()
1427                    .map(<SecureMemoryMode as fidl::encoding::ValueTypeMarker>::borrow),
1428                encoder,
1429                offset + cur_offset,
1430                depth,
1431            )?;
1432
1433            _prev_end_offset = cur_offset + envelope_size;
1434            if 10 > max_ordinal {
1435                return Ok(());
1436            }
1437
1438            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1439            // are envelope_size bytes.
1440            let cur_offset: usize = (10 - 1) * envelope_size;
1441
1442            // Zero reserved fields.
1443            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1444
1445            // Safety:
1446            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1447            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1448            //   envelope_size bytes, there is always sufficient room.
1449            fidl::encoding::encode_in_envelope_optional::<SecureMemoryMode, D>(
1450                self.secure_input_mode
1451                    .as_ref()
1452                    .map(<SecureMemoryMode as fidl::encoding::ValueTypeMarker>::borrow),
1453                encoder,
1454                offset + cur_offset,
1455                depth,
1456            )?;
1457
1458            _prev_end_offset = cur_offset + envelope_size;
1459            if 11 > max_ordinal {
1460                return Ok(());
1461            }
1462
1463            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1464            // are envelope_size bytes.
1465            let cur_offset: usize = (11 - 1) * envelope_size;
1466
1467            // Zero reserved fields.
1468            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1469
1470            // Safety:
1471            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1472            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1473            //   envelope_size bytes, there is always sufficient room.
1474            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1475                self.require_sw.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1476                encoder,
1477                offset + cur_offset,
1478                depth,
1479            )?;
1480
1481            _prev_end_offset = cur_offset + envelope_size;
1482
1483            Ok(())
1484        }
1485    }
1486
1487    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CreateDecoderParams {
1488        #[inline(always)]
1489        fn new_empty() -> Self {
1490            Self::default()
1491        }
1492
1493        unsafe fn decode(
1494            &mut self,
1495            decoder: &mut fidl::encoding::Decoder<'_, D>,
1496            offset: usize,
1497            mut depth: fidl::encoding::Depth,
1498        ) -> fidl::Result<()> {
1499            decoder.debug_check_bounds::<Self>(offset);
1500            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1501                None => return Err(fidl::Error::NotNullable),
1502                Some(len) => len,
1503            };
1504            // Calling decoder.out_of_line_offset(0) is not allowed.
1505            if len == 0 {
1506                return Ok(());
1507            };
1508            depth.increment()?;
1509            let envelope_size = 8;
1510            let bytes_len = len * envelope_size;
1511            let offset = decoder.out_of_line_offset(bytes_len)?;
1512            // Decode the envelope for each type.
1513            let mut _next_ordinal_to_read = 0;
1514            let mut next_offset = offset;
1515            let end_offset = offset + bytes_len;
1516            _next_ordinal_to_read += 1;
1517            if next_offset >= end_offset {
1518                return Ok(());
1519            }
1520
1521            // Decode unknown envelopes for gaps in ordinals.
1522            while _next_ordinal_to_read < 1 {
1523                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1524                _next_ordinal_to_read += 1;
1525                next_offset += envelope_size;
1526            }
1527
1528            let next_out_of_line = decoder.next_out_of_line();
1529            let handles_before = decoder.remaining_handles();
1530            if let Some((inlined, num_bytes, num_handles)) =
1531                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1532            {
1533                let member_inline_size = <fidl_fuchsia_media__common::FormatDetails as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1534                if inlined != (member_inline_size <= 4) {
1535                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1536                }
1537                let inner_offset;
1538                let mut inner_depth = depth.clone();
1539                if inlined {
1540                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1541                    inner_offset = next_offset;
1542                } else {
1543                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1544                    inner_depth.increment()?;
1545                }
1546                let val_ref = self.input_details.get_or_insert_with(|| {
1547                    fidl::new_empty!(fidl_fuchsia_media__common::FormatDetails, D)
1548                });
1549                fidl::decode!(
1550                    fidl_fuchsia_media__common::FormatDetails,
1551                    D,
1552                    val_ref,
1553                    decoder,
1554                    inner_offset,
1555                    inner_depth
1556                )?;
1557                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1558                {
1559                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1560                }
1561                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1562                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1563                }
1564            }
1565
1566            next_offset += envelope_size;
1567            _next_ordinal_to_read += 1;
1568            if next_offset >= end_offset {
1569                return Ok(());
1570            }
1571
1572            // Decode unknown envelopes for gaps in ordinals.
1573            while _next_ordinal_to_read < 2 {
1574                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1575                _next_ordinal_to_read += 1;
1576                next_offset += envelope_size;
1577            }
1578
1579            let next_out_of_line = decoder.next_out_of_line();
1580            let handles_before = decoder.remaining_handles();
1581            if let Some((inlined, num_bytes, num_handles)) =
1582                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1583            {
1584                let member_inline_size =
1585                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1586                if inlined != (member_inline_size <= 4) {
1587                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1588                }
1589                let inner_offset;
1590                let mut inner_depth = depth.clone();
1591                if inlined {
1592                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1593                    inner_offset = next_offset;
1594                } else {
1595                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1596                    inner_depth.increment()?;
1597                }
1598                let val_ref = self
1599                    .promise_separate_access_units_on_input
1600                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
1601                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1602                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1603                {
1604                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1605                }
1606                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1607                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1608                }
1609            }
1610
1611            next_offset += envelope_size;
1612            _next_ordinal_to_read += 1;
1613            if next_offset >= end_offset {
1614                return Ok(());
1615            }
1616
1617            // Decode unknown envelopes for gaps in ordinals.
1618            while _next_ordinal_to_read < 3 {
1619                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1620                _next_ordinal_to_read += 1;
1621                next_offset += envelope_size;
1622            }
1623
1624            let next_out_of_line = decoder.next_out_of_line();
1625            let handles_before = decoder.remaining_handles();
1626            if let Some((inlined, num_bytes, num_handles)) =
1627                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1628            {
1629                let member_inline_size =
1630                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1631                if inlined != (member_inline_size <= 4) {
1632                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1633                }
1634                let inner_offset;
1635                let mut inner_depth = depth.clone();
1636                if inlined {
1637                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1638                    inner_offset = next_offset;
1639                } else {
1640                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1641                    inner_depth.increment()?;
1642                }
1643                let val_ref = self
1644                    .require_can_stream_bytes_input
1645                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
1646                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1648                {
1649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1650                }
1651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1653                }
1654            }
1655
1656            next_offset += envelope_size;
1657            _next_ordinal_to_read += 1;
1658            if next_offset >= end_offset {
1659                return Ok(());
1660            }
1661
1662            // Decode unknown envelopes for gaps in ordinals.
1663            while _next_ordinal_to_read < 4 {
1664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1665                _next_ordinal_to_read += 1;
1666                next_offset += envelope_size;
1667            }
1668
1669            let next_out_of_line = decoder.next_out_of_line();
1670            let handles_before = decoder.remaining_handles();
1671            if let Some((inlined, num_bytes, num_handles)) =
1672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1673            {
1674                let member_inline_size =
1675                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1676                if inlined != (member_inline_size <= 4) {
1677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1678                }
1679                let inner_offset;
1680                let mut inner_depth = depth.clone();
1681                if inlined {
1682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1683                    inner_offset = next_offset;
1684                } else {
1685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1686                    inner_depth.increment()?;
1687                }
1688                let val_ref =
1689                    self.require_can_find_start.get_or_insert_with(|| fidl::new_empty!(bool, D));
1690                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1691                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1692                {
1693                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1694                }
1695                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1696                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1697                }
1698            }
1699
1700            next_offset += envelope_size;
1701            _next_ordinal_to_read += 1;
1702            if next_offset >= end_offset {
1703                return Ok(());
1704            }
1705
1706            // Decode unknown envelopes for gaps in ordinals.
1707            while _next_ordinal_to_read < 5 {
1708                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1709                _next_ordinal_to_read += 1;
1710                next_offset += envelope_size;
1711            }
1712
1713            let next_out_of_line = decoder.next_out_of_line();
1714            let handles_before = decoder.remaining_handles();
1715            if let Some((inlined, num_bytes, num_handles)) =
1716                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1717            {
1718                let member_inline_size =
1719                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1720                if inlined != (member_inline_size <= 4) {
1721                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1722                }
1723                let inner_offset;
1724                let mut inner_depth = depth.clone();
1725                if inlined {
1726                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1727                    inner_offset = next_offset;
1728                } else {
1729                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1730                    inner_depth.increment()?;
1731                }
1732                let val_ref =
1733                    self.require_can_re_sync.get_or_insert_with(|| fidl::new_empty!(bool, D));
1734                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1735                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1736                {
1737                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1738                }
1739                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1740                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1741                }
1742            }
1743
1744            next_offset += envelope_size;
1745            _next_ordinal_to_read += 1;
1746            if next_offset >= end_offset {
1747                return Ok(());
1748            }
1749
1750            // Decode unknown envelopes for gaps in ordinals.
1751            while _next_ordinal_to_read < 6 {
1752                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1753                _next_ordinal_to_read += 1;
1754                next_offset += envelope_size;
1755            }
1756
1757            let next_out_of_line = decoder.next_out_of_line();
1758            let handles_before = decoder.remaining_handles();
1759            if let Some((inlined, num_bytes, num_handles)) =
1760                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1761            {
1762                let member_inline_size =
1763                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1764                if inlined != (member_inline_size <= 4) {
1765                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1766                }
1767                let inner_offset;
1768                let mut inner_depth = depth.clone();
1769                if inlined {
1770                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1771                    inner_offset = next_offset;
1772                } else {
1773                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1774                    inner_depth.increment()?;
1775                }
1776                let val_ref = self
1777                    .require_report_all_detected_errors
1778                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
1779                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1780                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1781                {
1782                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1783                }
1784                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1785                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1786                }
1787            }
1788
1789            next_offset += envelope_size;
1790            _next_ordinal_to_read += 1;
1791            if next_offset >= end_offset {
1792                return Ok(());
1793            }
1794
1795            // Decode unknown envelopes for gaps in ordinals.
1796            while _next_ordinal_to_read < 7 {
1797                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1798                _next_ordinal_to_read += 1;
1799                next_offset += envelope_size;
1800            }
1801
1802            let next_out_of_line = decoder.next_out_of_line();
1803            let handles_before = decoder.remaining_handles();
1804            if let Some((inlined, num_bytes, num_handles)) =
1805                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1806            {
1807                let member_inline_size =
1808                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1809                if inlined != (member_inline_size <= 4) {
1810                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1811                }
1812                let inner_offset;
1813                let mut inner_depth = depth.clone();
1814                if inlined {
1815                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1816                    inner_offset = next_offset;
1817                } else {
1818                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1819                    inner_depth.increment()?;
1820                }
1821                let val_ref = self.require_hw.get_or_insert_with(|| fidl::new_empty!(bool, D));
1822                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1823                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1824                {
1825                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1826                }
1827                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1828                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1829                }
1830            }
1831
1832            next_offset += envelope_size;
1833            _next_ordinal_to_read += 1;
1834            if next_offset >= end_offset {
1835                return Ok(());
1836            }
1837
1838            // Decode unknown envelopes for gaps in ordinals.
1839            while _next_ordinal_to_read < 8 {
1840                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1841                _next_ordinal_to_read += 1;
1842                next_offset += envelope_size;
1843            }
1844
1845            let next_out_of_line = decoder.next_out_of_line();
1846            let handles_before = decoder.remaining_handles();
1847            if let Some((inlined, num_bytes, num_handles)) =
1848                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1849            {
1850                let member_inline_size =
1851                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1852                if inlined != (member_inline_size <= 4) {
1853                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1854                }
1855                let inner_offset;
1856                let mut inner_depth = depth.clone();
1857                if inlined {
1858                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1859                    inner_offset = next_offset;
1860                } else {
1861                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1862                    inner_depth.increment()?;
1863                }
1864                let val_ref = self
1865                    .permit_lack_of_split_header_handling
1866                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
1867                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1868                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1869                {
1870                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1871                }
1872                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1873                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1874                }
1875            }
1876
1877            next_offset += envelope_size;
1878            _next_ordinal_to_read += 1;
1879            if next_offset >= end_offset {
1880                return Ok(());
1881            }
1882
1883            // Decode unknown envelopes for gaps in ordinals.
1884            while _next_ordinal_to_read < 9 {
1885                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1886                _next_ordinal_to_read += 1;
1887                next_offset += envelope_size;
1888            }
1889
1890            let next_out_of_line = decoder.next_out_of_line();
1891            let handles_before = decoder.remaining_handles();
1892            if let Some((inlined, num_bytes, num_handles)) =
1893                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1894            {
1895                let member_inline_size =
1896                    <SecureMemoryMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1897                if inlined != (member_inline_size <= 4) {
1898                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1899                }
1900                let inner_offset;
1901                let mut inner_depth = depth.clone();
1902                if inlined {
1903                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1904                    inner_offset = next_offset;
1905                } else {
1906                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1907                    inner_depth.increment()?;
1908                }
1909                let val_ref = self
1910                    .secure_output_mode
1911                    .get_or_insert_with(|| fidl::new_empty!(SecureMemoryMode, D));
1912                fidl::decode!(SecureMemoryMode, D, val_ref, decoder, inner_offset, inner_depth)?;
1913                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1914                {
1915                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1916                }
1917                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1918                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1919                }
1920            }
1921
1922            next_offset += envelope_size;
1923            _next_ordinal_to_read += 1;
1924            if next_offset >= end_offset {
1925                return Ok(());
1926            }
1927
1928            // Decode unknown envelopes for gaps in ordinals.
1929            while _next_ordinal_to_read < 10 {
1930                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1931                _next_ordinal_to_read += 1;
1932                next_offset += envelope_size;
1933            }
1934
1935            let next_out_of_line = decoder.next_out_of_line();
1936            let handles_before = decoder.remaining_handles();
1937            if let Some((inlined, num_bytes, num_handles)) =
1938                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1939            {
1940                let member_inline_size =
1941                    <SecureMemoryMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1942                if inlined != (member_inline_size <= 4) {
1943                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1944                }
1945                let inner_offset;
1946                let mut inner_depth = depth.clone();
1947                if inlined {
1948                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1949                    inner_offset = next_offset;
1950                } else {
1951                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1952                    inner_depth.increment()?;
1953                }
1954                let val_ref = self
1955                    .secure_input_mode
1956                    .get_or_insert_with(|| fidl::new_empty!(SecureMemoryMode, D));
1957                fidl::decode!(SecureMemoryMode, D, val_ref, decoder, inner_offset, inner_depth)?;
1958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1959                {
1960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1961                }
1962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1964                }
1965            }
1966
1967            next_offset += envelope_size;
1968            _next_ordinal_to_read += 1;
1969            if next_offset >= end_offset {
1970                return Ok(());
1971            }
1972
1973            // Decode unknown envelopes for gaps in ordinals.
1974            while _next_ordinal_to_read < 11 {
1975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1976                _next_ordinal_to_read += 1;
1977                next_offset += envelope_size;
1978            }
1979
1980            let next_out_of_line = decoder.next_out_of_line();
1981            let handles_before = decoder.remaining_handles();
1982            if let Some((inlined, num_bytes, num_handles)) =
1983                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1984            {
1985                let member_inline_size =
1986                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1987                if inlined != (member_inline_size <= 4) {
1988                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1989                }
1990                let inner_offset;
1991                let mut inner_depth = depth.clone();
1992                if inlined {
1993                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1994                    inner_offset = next_offset;
1995                } else {
1996                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1997                    inner_depth.increment()?;
1998                }
1999                let val_ref = self.require_sw.get_or_insert_with(|| fidl::new_empty!(bool, D));
2000                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2001                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2002                {
2003                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2004                }
2005                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2006                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2007                }
2008            }
2009
2010            next_offset += envelope_size;
2011
2012            // Decode the remaining unknown envelopes.
2013            while next_offset < end_offset {
2014                _next_ordinal_to_read += 1;
2015                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2016                next_offset += envelope_size;
2017            }
2018
2019            Ok(())
2020        }
2021    }
2022
2023    impl CreateEncoderParams {
2024        #[inline(always)]
2025        fn max_ordinal_present(&self) -> u64 {
2026            if let Some(_) = self.require_hw {
2027                return 2;
2028            }
2029            if let Some(_) = self.input_details {
2030                return 1;
2031            }
2032            0
2033        }
2034    }
2035
2036    impl fidl::encoding::ValueTypeMarker for CreateEncoderParams {
2037        type Borrowed<'a> = &'a Self;
2038        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2039            value
2040        }
2041    }
2042
2043    unsafe impl fidl::encoding::TypeMarker for CreateEncoderParams {
2044        type Owned = Self;
2045
2046        #[inline(always)]
2047        fn inline_align(_context: fidl::encoding::Context) -> usize {
2048            8
2049        }
2050
2051        #[inline(always)]
2052        fn inline_size(_context: fidl::encoding::Context) -> usize {
2053            16
2054        }
2055    }
2056
2057    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CreateEncoderParams, D>
2058        for &CreateEncoderParams
2059    {
2060        unsafe fn encode(
2061            self,
2062            encoder: &mut fidl::encoding::Encoder<'_, D>,
2063            offset: usize,
2064            mut depth: fidl::encoding::Depth,
2065        ) -> fidl::Result<()> {
2066            encoder.debug_check_bounds::<CreateEncoderParams>(offset);
2067            // Vector header
2068            let max_ordinal: u64 = self.max_ordinal_present();
2069            encoder.write_num(max_ordinal, offset);
2070            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2071            // Calling encoder.out_of_line_offset(0) is not allowed.
2072            if max_ordinal == 0 {
2073                return Ok(());
2074            }
2075            depth.increment()?;
2076            let envelope_size = 8;
2077            let bytes_len = max_ordinal as usize * envelope_size;
2078            #[allow(unused_variables)]
2079            let offset = encoder.out_of_line_offset(bytes_len);
2080            let mut _prev_end_offset: usize = 0;
2081            if 1 > max_ordinal {
2082                return Ok(());
2083            }
2084
2085            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2086            // are envelope_size bytes.
2087            let cur_offset: usize = (1 - 1) * envelope_size;
2088
2089            // Zero reserved fields.
2090            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2091
2092            // Safety:
2093            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2094            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2095            //   envelope_size bytes, there is always sufficient room.
2096            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::FormatDetails, D>(
2097            self.input_details.as_ref().map(<fidl_fuchsia_media__common::FormatDetails as fidl::encoding::ValueTypeMarker>::borrow),
2098            encoder, offset + cur_offset, depth
2099        )?;
2100
2101            _prev_end_offset = cur_offset + envelope_size;
2102            if 2 > max_ordinal {
2103                return Ok(());
2104            }
2105
2106            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2107            // are envelope_size bytes.
2108            let cur_offset: usize = (2 - 1) * envelope_size;
2109
2110            // Zero reserved fields.
2111            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2112
2113            // Safety:
2114            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2115            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2116            //   envelope_size bytes, there is always sufficient room.
2117            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2118                self.require_hw.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2119                encoder,
2120                offset + cur_offset,
2121                depth,
2122            )?;
2123
2124            _prev_end_offset = cur_offset + envelope_size;
2125
2126            Ok(())
2127        }
2128    }
2129
2130    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CreateEncoderParams {
2131        #[inline(always)]
2132        fn new_empty() -> Self {
2133            Self::default()
2134        }
2135
2136        unsafe fn decode(
2137            &mut self,
2138            decoder: &mut fidl::encoding::Decoder<'_, D>,
2139            offset: usize,
2140            mut depth: fidl::encoding::Depth,
2141        ) -> fidl::Result<()> {
2142            decoder.debug_check_bounds::<Self>(offset);
2143            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2144                None => return Err(fidl::Error::NotNullable),
2145                Some(len) => len,
2146            };
2147            // Calling decoder.out_of_line_offset(0) is not allowed.
2148            if len == 0 {
2149                return Ok(());
2150            };
2151            depth.increment()?;
2152            let envelope_size = 8;
2153            let bytes_len = len * envelope_size;
2154            let offset = decoder.out_of_line_offset(bytes_len)?;
2155            // Decode the envelope for each type.
2156            let mut _next_ordinal_to_read = 0;
2157            let mut next_offset = offset;
2158            let end_offset = offset + bytes_len;
2159            _next_ordinal_to_read += 1;
2160            if next_offset >= end_offset {
2161                return Ok(());
2162            }
2163
2164            // Decode unknown envelopes for gaps in ordinals.
2165            while _next_ordinal_to_read < 1 {
2166                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2167                _next_ordinal_to_read += 1;
2168                next_offset += envelope_size;
2169            }
2170
2171            let next_out_of_line = decoder.next_out_of_line();
2172            let handles_before = decoder.remaining_handles();
2173            if let Some((inlined, num_bytes, num_handles)) =
2174                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2175            {
2176                let member_inline_size = <fidl_fuchsia_media__common::FormatDetails as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2177                if inlined != (member_inline_size <= 4) {
2178                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2179                }
2180                let inner_offset;
2181                let mut inner_depth = depth.clone();
2182                if inlined {
2183                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2184                    inner_offset = next_offset;
2185                } else {
2186                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2187                    inner_depth.increment()?;
2188                }
2189                let val_ref = self.input_details.get_or_insert_with(|| {
2190                    fidl::new_empty!(fidl_fuchsia_media__common::FormatDetails, D)
2191                });
2192                fidl::decode!(
2193                    fidl_fuchsia_media__common::FormatDetails,
2194                    D,
2195                    val_ref,
2196                    decoder,
2197                    inner_offset,
2198                    inner_depth
2199                )?;
2200                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2201                {
2202                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2203                }
2204                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2205                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2206                }
2207            }
2208
2209            next_offset += envelope_size;
2210            _next_ordinal_to_read += 1;
2211            if next_offset >= end_offset {
2212                return Ok(());
2213            }
2214
2215            // Decode unknown envelopes for gaps in ordinals.
2216            while _next_ordinal_to_read < 2 {
2217                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2218                _next_ordinal_to_read += 1;
2219                next_offset += envelope_size;
2220            }
2221
2222            let next_out_of_line = decoder.next_out_of_line();
2223            let handles_before = decoder.remaining_handles();
2224            if let Some((inlined, num_bytes, num_handles)) =
2225                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2226            {
2227                let member_inline_size =
2228                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2229                if inlined != (member_inline_size <= 4) {
2230                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2231                }
2232                let inner_offset;
2233                let mut inner_depth = depth.clone();
2234                if inlined {
2235                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2236                    inner_offset = next_offset;
2237                } else {
2238                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2239                    inner_depth.increment()?;
2240                }
2241                let val_ref = self.require_hw.get_or_insert_with(|| fidl::new_empty!(bool, D));
2242                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2243                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2244                {
2245                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2246                }
2247                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2248                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2249                }
2250            }
2251
2252            next_offset += envelope_size;
2253
2254            // Decode the remaining unknown envelopes.
2255            while next_offset < end_offset {
2256                _next_ordinal_to_read += 1;
2257                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2258                next_offset += envelope_size;
2259            }
2260
2261            Ok(())
2262        }
2263    }
2264
2265    impl DecoderProfileDescription {
2266        #[inline(always)]
2267        fn max_ordinal_present(&self) -> u64 {
2268            if let Some(_) = self.split_header_handling {
2269                return 12;
2270            }
2271            if let Some(_) = self.will_report_all_detected_errors {
2272                return 11;
2273            }
2274            if let Some(_) = self.can_re_sync {
2275                return 10;
2276            }
2277            if let Some(_) = self.can_find_start {
2278                return 9;
2279            }
2280            if let Some(_) = self.can_stream_bytes_input {
2281                return 8;
2282            }
2283            if let Some(_) = self.require_input_protection {
2284                return 7;
2285            }
2286            if let Some(_) = self.allow_input_protection {
2287                return 6;
2288            }
2289            if let Some(_) = self.require_encryption {
2290                return 5;
2291            }
2292            if let Some(_) = self.allow_encryption {
2293                return 4;
2294            }
2295            if let Some(_) = self.max_image_size {
2296                return 3;
2297            }
2298            if let Some(_) = self.min_image_size {
2299                return 2;
2300            }
2301            if let Some(_) = self.profile {
2302                return 1;
2303            }
2304            0
2305        }
2306    }
2307
2308    impl fidl::encoding::ValueTypeMarker for DecoderProfileDescription {
2309        type Borrowed<'a> = &'a Self;
2310        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2311            value
2312        }
2313    }
2314
2315    unsafe impl fidl::encoding::TypeMarker for DecoderProfileDescription {
2316        type Owned = Self;
2317
2318        #[inline(always)]
2319        fn inline_align(_context: fidl::encoding::Context) -> usize {
2320            8
2321        }
2322
2323        #[inline(always)]
2324        fn inline_size(_context: fidl::encoding::Context) -> usize {
2325            16
2326        }
2327    }
2328
2329    unsafe impl<D: fidl::encoding::ResourceDialect>
2330        fidl::encoding::Encode<DecoderProfileDescription, D> for &DecoderProfileDescription
2331    {
2332        unsafe fn encode(
2333            self,
2334            encoder: &mut fidl::encoding::Encoder<'_, D>,
2335            offset: usize,
2336            mut depth: fidl::encoding::Depth,
2337        ) -> fidl::Result<()> {
2338            encoder.debug_check_bounds::<DecoderProfileDescription>(offset);
2339            // Vector header
2340            let max_ordinal: u64 = self.max_ordinal_present();
2341            encoder.write_num(max_ordinal, offset);
2342            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2343            // Calling encoder.out_of_line_offset(0) is not allowed.
2344            if max_ordinal == 0 {
2345                return Ok(());
2346            }
2347            depth.increment()?;
2348            let envelope_size = 8;
2349            let bytes_len = max_ordinal as usize * envelope_size;
2350            #[allow(unused_variables)]
2351            let offset = encoder.out_of_line_offset(bytes_len);
2352            let mut _prev_end_offset: usize = 0;
2353            if 1 > max_ordinal {
2354                return Ok(());
2355            }
2356
2357            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2358            // are envelope_size bytes.
2359            let cur_offset: usize = (1 - 1) * envelope_size;
2360
2361            // Zero reserved fields.
2362            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2363
2364            // Safety:
2365            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2366            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2367            //   envelope_size bytes, there is always sufficient room.
2368            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::CodecProfile, D>(
2369            self.profile.as_ref().map(<fidl_fuchsia_media__common::CodecProfile as fidl::encoding::ValueTypeMarker>::borrow),
2370            encoder, offset + cur_offset, depth
2371        )?;
2372
2373            _prev_end_offset = cur_offset + envelope_size;
2374            if 2 > max_ordinal {
2375                return Ok(());
2376            }
2377
2378            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2379            // are envelope_size bytes.
2380            let cur_offset: usize = (2 - 1) * envelope_size;
2381
2382            // Zero reserved fields.
2383            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2384
2385            // Safety:
2386            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2387            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2388            //   envelope_size bytes, there is always sufficient room.
2389            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
2390                self.min_image_size.as_ref().map(
2391                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
2392                ),
2393                encoder,
2394                offset + cur_offset,
2395                depth,
2396            )?;
2397
2398            _prev_end_offset = cur_offset + envelope_size;
2399            if 3 > max_ordinal {
2400                return Ok(());
2401            }
2402
2403            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2404            // are envelope_size bytes.
2405            let cur_offset: usize = (3 - 1) * envelope_size;
2406
2407            // Zero reserved fields.
2408            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2409
2410            // Safety:
2411            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2412            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2413            //   envelope_size bytes, there is always sufficient room.
2414            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math__common::SizeU, D>(
2415                self.max_image_size.as_ref().map(
2416                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::ValueTypeMarker>::borrow,
2417                ),
2418                encoder,
2419                offset + cur_offset,
2420                depth,
2421            )?;
2422
2423            _prev_end_offset = cur_offset + envelope_size;
2424            if 4 > max_ordinal {
2425                return Ok(());
2426            }
2427
2428            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2429            // are envelope_size bytes.
2430            let cur_offset: usize = (4 - 1) * envelope_size;
2431
2432            // Zero reserved fields.
2433            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2434
2435            // Safety:
2436            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2437            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2438            //   envelope_size bytes, there is always sufficient room.
2439            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2440                self.allow_encryption
2441                    .as_ref()
2442                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2443                encoder,
2444                offset + cur_offset,
2445                depth,
2446            )?;
2447
2448            _prev_end_offset = cur_offset + envelope_size;
2449            if 5 > max_ordinal {
2450                return Ok(());
2451            }
2452
2453            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2454            // are envelope_size bytes.
2455            let cur_offset: usize = (5 - 1) * envelope_size;
2456
2457            // Zero reserved fields.
2458            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2459
2460            // Safety:
2461            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2462            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2463            //   envelope_size bytes, there is always sufficient room.
2464            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2465                self.require_encryption
2466                    .as_ref()
2467                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2468                encoder,
2469                offset + cur_offset,
2470                depth,
2471            )?;
2472
2473            _prev_end_offset = cur_offset + envelope_size;
2474            if 6 > max_ordinal {
2475                return Ok(());
2476            }
2477
2478            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2479            // are envelope_size bytes.
2480            let cur_offset: usize = (6 - 1) * envelope_size;
2481
2482            // Zero reserved fields.
2483            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2484
2485            // Safety:
2486            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2487            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2488            //   envelope_size bytes, there is always sufficient room.
2489            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2490                self.allow_input_protection
2491                    .as_ref()
2492                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2493                encoder,
2494                offset + cur_offset,
2495                depth,
2496            )?;
2497
2498            _prev_end_offset = cur_offset + envelope_size;
2499            if 7 > max_ordinal {
2500                return Ok(());
2501            }
2502
2503            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2504            // are envelope_size bytes.
2505            let cur_offset: usize = (7 - 1) * envelope_size;
2506
2507            // Zero reserved fields.
2508            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2509
2510            // Safety:
2511            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2512            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2513            //   envelope_size bytes, there is always sufficient room.
2514            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2515                self.require_input_protection
2516                    .as_ref()
2517                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2518                encoder,
2519                offset + cur_offset,
2520                depth,
2521            )?;
2522
2523            _prev_end_offset = cur_offset + envelope_size;
2524            if 8 > max_ordinal {
2525                return Ok(());
2526            }
2527
2528            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2529            // are envelope_size bytes.
2530            let cur_offset: usize = (8 - 1) * envelope_size;
2531
2532            // Zero reserved fields.
2533            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2534
2535            // Safety:
2536            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2537            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2538            //   envelope_size bytes, there is always sufficient room.
2539            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2540                self.can_stream_bytes_input
2541                    .as_ref()
2542                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2543                encoder,
2544                offset + cur_offset,
2545                depth,
2546            )?;
2547
2548            _prev_end_offset = cur_offset + envelope_size;
2549            if 9 > max_ordinal {
2550                return Ok(());
2551            }
2552
2553            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2554            // are envelope_size bytes.
2555            let cur_offset: usize = (9 - 1) * envelope_size;
2556
2557            // Zero reserved fields.
2558            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2559
2560            // Safety:
2561            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2562            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2563            //   envelope_size bytes, there is always sufficient room.
2564            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2565                self.can_find_start.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2566                encoder,
2567                offset + cur_offset,
2568                depth,
2569            )?;
2570
2571            _prev_end_offset = cur_offset + envelope_size;
2572            if 10 > max_ordinal {
2573                return Ok(());
2574            }
2575
2576            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2577            // are envelope_size bytes.
2578            let cur_offset: usize = (10 - 1) * envelope_size;
2579
2580            // Zero reserved fields.
2581            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2582
2583            // Safety:
2584            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2585            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2586            //   envelope_size bytes, there is always sufficient room.
2587            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2588                self.can_re_sync.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2589                encoder,
2590                offset + cur_offset,
2591                depth,
2592            )?;
2593
2594            _prev_end_offset = cur_offset + envelope_size;
2595            if 11 > max_ordinal {
2596                return Ok(());
2597            }
2598
2599            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2600            // are envelope_size bytes.
2601            let cur_offset: usize = (11 - 1) * envelope_size;
2602
2603            // Zero reserved fields.
2604            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2605
2606            // Safety:
2607            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2608            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2609            //   envelope_size bytes, there is always sufficient room.
2610            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2611                self.will_report_all_detected_errors
2612                    .as_ref()
2613                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2614                encoder,
2615                offset + cur_offset,
2616                depth,
2617            )?;
2618
2619            _prev_end_offset = cur_offset + envelope_size;
2620            if 12 > max_ordinal {
2621                return Ok(());
2622            }
2623
2624            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2625            // are envelope_size bytes.
2626            let cur_offset: usize = (12 - 1) * envelope_size;
2627
2628            // Zero reserved fields.
2629            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2630
2631            // Safety:
2632            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2633            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2634            //   envelope_size bytes, there is always sufficient room.
2635            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2636                self.split_header_handling
2637                    .as_ref()
2638                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2639                encoder,
2640                offset + cur_offset,
2641                depth,
2642            )?;
2643
2644            _prev_end_offset = cur_offset + envelope_size;
2645
2646            Ok(())
2647        }
2648    }
2649
2650    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2651        for DecoderProfileDescription
2652    {
2653        #[inline(always)]
2654        fn new_empty() -> Self {
2655            Self::default()
2656        }
2657
2658        unsafe fn decode(
2659            &mut self,
2660            decoder: &mut fidl::encoding::Decoder<'_, D>,
2661            offset: usize,
2662            mut depth: fidl::encoding::Depth,
2663        ) -> fidl::Result<()> {
2664            decoder.debug_check_bounds::<Self>(offset);
2665            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2666                None => return Err(fidl::Error::NotNullable),
2667                Some(len) => len,
2668            };
2669            // Calling decoder.out_of_line_offset(0) is not allowed.
2670            if len == 0 {
2671                return Ok(());
2672            };
2673            depth.increment()?;
2674            let envelope_size = 8;
2675            let bytes_len = len * envelope_size;
2676            let offset = decoder.out_of_line_offset(bytes_len)?;
2677            // Decode the envelope for each type.
2678            let mut _next_ordinal_to_read = 0;
2679            let mut next_offset = offset;
2680            let end_offset = offset + bytes_len;
2681            _next_ordinal_to_read += 1;
2682            if next_offset >= end_offset {
2683                return Ok(());
2684            }
2685
2686            // Decode unknown envelopes for gaps in ordinals.
2687            while _next_ordinal_to_read < 1 {
2688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2689                _next_ordinal_to_read += 1;
2690                next_offset += envelope_size;
2691            }
2692
2693            let next_out_of_line = decoder.next_out_of_line();
2694            let handles_before = decoder.remaining_handles();
2695            if let Some((inlined, num_bytes, num_handles)) =
2696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2697            {
2698                let member_inline_size = <fidl_fuchsia_media__common::CodecProfile as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2699                if inlined != (member_inline_size <= 4) {
2700                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2701                }
2702                let inner_offset;
2703                let mut inner_depth = depth.clone();
2704                if inlined {
2705                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2706                    inner_offset = next_offset;
2707                } else {
2708                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2709                    inner_depth.increment()?;
2710                }
2711                let val_ref = self.profile.get_or_insert_with(|| {
2712                    fidl::new_empty!(fidl_fuchsia_media__common::CodecProfile, D)
2713                });
2714                fidl::decode!(
2715                    fidl_fuchsia_media__common::CodecProfile,
2716                    D,
2717                    val_ref,
2718                    decoder,
2719                    inner_offset,
2720                    inner_depth
2721                )?;
2722                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2723                {
2724                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2725                }
2726                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2727                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2728                }
2729            }
2730
2731            next_offset += envelope_size;
2732            _next_ordinal_to_read += 1;
2733            if next_offset >= end_offset {
2734                return Ok(());
2735            }
2736
2737            // Decode unknown envelopes for gaps in ordinals.
2738            while _next_ordinal_to_read < 2 {
2739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2740                _next_ordinal_to_read += 1;
2741                next_offset += envelope_size;
2742            }
2743
2744            let next_out_of_line = decoder.next_out_of_line();
2745            let handles_before = decoder.remaining_handles();
2746            if let Some((inlined, num_bytes, num_handles)) =
2747                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2748            {
2749                let member_inline_size =
2750                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
2751                        decoder.context,
2752                    );
2753                if inlined != (member_inline_size <= 4) {
2754                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2755                }
2756                let inner_offset;
2757                let mut inner_depth = depth.clone();
2758                if inlined {
2759                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2760                    inner_offset = next_offset;
2761                } else {
2762                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2763                    inner_depth.increment()?;
2764                }
2765                let val_ref = self
2766                    .min_image_size
2767                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
2768                fidl::decode!(
2769                    fidl_fuchsia_math__common::SizeU,
2770                    D,
2771                    val_ref,
2772                    decoder,
2773                    inner_offset,
2774                    inner_depth
2775                )?;
2776                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2777                {
2778                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2779                }
2780                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2781                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2782                }
2783            }
2784
2785            next_offset += envelope_size;
2786            _next_ordinal_to_read += 1;
2787            if next_offset >= end_offset {
2788                return Ok(());
2789            }
2790
2791            // Decode unknown envelopes for gaps in ordinals.
2792            while _next_ordinal_to_read < 3 {
2793                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2794                _next_ordinal_to_read += 1;
2795                next_offset += envelope_size;
2796            }
2797
2798            let next_out_of_line = decoder.next_out_of_line();
2799            let handles_before = decoder.remaining_handles();
2800            if let Some((inlined, num_bytes, num_handles)) =
2801                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2802            {
2803                let member_inline_size =
2804                    <fidl_fuchsia_math__common::SizeU as fidl::encoding::TypeMarker>::inline_size(
2805                        decoder.context,
2806                    );
2807                if inlined != (member_inline_size <= 4) {
2808                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2809                }
2810                let inner_offset;
2811                let mut inner_depth = depth.clone();
2812                if inlined {
2813                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2814                    inner_offset = next_offset;
2815                } else {
2816                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2817                    inner_depth.increment()?;
2818                }
2819                let val_ref = self
2820                    .max_image_size
2821                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math__common::SizeU, D));
2822                fidl::decode!(
2823                    fidl_fuchsia_math__common::SizeU,
2824                    D,
2825                    val_ref,
2826                    decoder,
2827                    inner_offset,
2828                    inner_depth
2829                )?;
2830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2831                {
2832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2833                }
2834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2836                }
2837            }
2838
2839            next_offset += envelope_size;
2840            _next_ordinal_to_read += 1;
2841            if next_offset >= end_offset {
2842                return Ok(());
2843            }
2844
2845            // Decode unknown envelopes for gaps in ordinals.
2846            while _next_ordinal_to_read < 4 {
2847                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2848                _next_ordinal_to_read += 1;
2849                next_offset += envelope_size;
2850            }
2851
2852            let next_out_of_line = decoder.next_out_of_line();
2853            let handles_before = decoder.remaining_handles();
2854            if let Some((inlined, num_bytes, num_handles)) =
2855                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2856            {
2857                let member_inline_size =
2858                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2859                if inlined != (member_inline_size <= 4) {
2860                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2861                }
2862                let inner_offset;
2863                let mut inner_depth = depth.clone();
2864                if inlined {
2865                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2866                    inner_offset = next_offset;
2867                } else {
2868                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2869                    inner_depth.increment()?;
2870                }
2871                let val_ref =
2872                    self.allow_encryption.get_or_insert_with(|| fidl::new_empty!(bool, D));
2873                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2874                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2875                {
2876                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2877                }
2878                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2879                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2880                }
2881            }
2882
2883            next_offset += envelope_size;
2884            _next_ordinal_to_read += 1;
2885            if next_offset >= end_offset {
2886                return Ok(());
2887            }
2888
2889            // Decode unknown envelopes for gaps in ordinals.
2890            while _next_ordinal_to_read < 5 {
2891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2892                _next_ordinal_to_read += 1;
2893                next_offset += envelope_size;
2894            }
2895
2896            let next_out_of_line = decoder.next_out_of_line();
2897            let handles_before = decoder.remaining_handles();
2898            if let Some((inlined, num_bytes, num_handles)) =
2899                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2900            {
2901                let member_inline_size =
2902                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2903                if inlined != (member_inline_size <= 4) {
2904                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2905                }
2906                let inner_offset;
2907                let mut inner_depth = depth.clone();
2908                if inlined {
2909                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2910                    inner_offset = next_offset;
2911                } else {
2912                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2913                    inner_depth.increment()?;
2914                }
2915                let val_ref =
2916                    self.require_encryption.get_or_insert_with(|| fidl::new_empty!(bool, D));
2917                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2918                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2919                {
2920                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2921                }
2922                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2923                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2924                }
2925            }
2926
2927            next_offset += envelope_size;
2928            _next_ordinal_to_read += 1;
2929            if next_offset >= end_offset {
2930                return Ok(());
2931            }
2932
2933            // Decode unknown envelopes for gaps in ordinals.
2934            while _next_ordinal_to_read < 6 {
2935                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2936                _next_ordinal_to_read += 1;
2937                next_offset += envelope_size;
2938            }
2939
2940            let next_out_of_line = decoder.next_out_of_line();
2941            let handles_before = decoder.remaining_handles();
2942            if let Some((inlined, num_bytes, num_handles)) =
2943                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2944            {
2945                let member_inline_size =
2946                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2947                if inlined != (member_inline_size <= 4) {
2948                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2949                }
2950                let inner_offset;
2951                let mut inner_depth = depth.clone();
2952                if inlined {
2953                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2954                    inner_offset = next_offset;
2955                } else {
2956                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2957                    inner_depth.increment()?;
2958                }
2959                let val_ref =
2960                    self.allow_input_protection.get_or_insert_with(|| fidl::new_empty!(bool, D));
2961                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2962                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2963                {
2964                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2965                }
2966                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2967                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2968                }
2969            }
2970
2971            next_offset += envelope_size;
2972            _next_ordinal_to_read += 1;
2973            if next_offset >= end_offset {
2974                return Ok(());
2975            }
2976
2977            // Decode unknown envelopes for gaps in ordinals.
2978            while _next_ordinal_to_read < 7 {
2979                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2980                _next_ordinal_to_read += 1;
2981                next_offset += envelope_size;
2982            }
2983
2984            let next_out_of_line = decoder.next_out_of_line();
2985            let handles_before = decoder.remaining_handles();
2986            if let Some((inlined, num_bytes, num_handles)) =
2987                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2988            {
2989                let member_inline_size =
2990                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2991                if inlined != (member_inline_size <= 4) {
2992                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2993                }
2994                let inner_offset;
2995                let mut inner_depth = depth.clone();
2996                if inlined {
2997                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2998                    inner_offset = next_offset;
2999                } else {
3000                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3001                    inner_depth.increment()?;
3002                }
3003                let val_ref =
3004                    self.require_input_protection.get_or_insert_with(|| fidl::new_empty!(bool, D));
3005                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3006                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3007                {
3008                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3009                }
3010                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3011                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3012                }
3013            }
3014
3015            next_offset += envelope_size;
3016            _next_ordinal_to_read += 1;
3017            if next_offset >= end_offset {
3018                return Ok(());
3019            }
3020
3021            // Decode unknown envelopes for gaps in ordinals.
3022            while _next_ordinal_to_read < 8 {
3023                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3024                _next_ordinal_to_read += 1;
3025                next_offset += envelope_size;
3026            }
3027
3028            let next_out_of_line = decoder.next_out_of_line();
3029            let handles_before = decoder.remaining_handles();
3030            if let Some((inlined, num_bytes, num_handles)) =
3031                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3032            {
3033                let member_inline_size =
3034                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3035                if inlined != (member_inline_size <= 4) {
3036                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3037                }
3038                let inner_offset;
3039                let mut inner_depth = depth.clone();
3040                if inlined {
3041                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3042                    inner_offset = next_offset;
3043                } else {
3044                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3045                    inner_depth.increment()?;
3046                }
3047                let val_ref =
3048                    self.can_stream_bytes_input.get_or_insert_with(|| fidl::new_empty!(bool, D));
3049                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3050                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3051                {
3052                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3053                }
3054                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3055                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3056                }
3057            }
3058
3059            next_offset += envelope_size;
3060            _next_ordinal_to_read += 1;
3061            if next_offset >= end_offset {
3062                return Ok(());
3063            }
3064
3065            // Decode unknown envelopes for gaps in ordinals.
3066            while _next_ordinal_to_read < 9 {
3067                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3068                _next_ordinal_to_read += 1;
3069                next_offset += envelope_size;
3070            }
3071
3072            let next_out_of_line = decoder.next_out_of_line();
3073            let handles_before = decoder.remaining_handles();
3074            if let Some((inlined, num_bytes, num_handles)) =
3075                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3076            {
3077                let member_inline_size =
3078                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3079                if inlined != (member_inline_size <= 4) {
3080                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3081                }
3082                let inner_offset;
3083                let mut inner_depth = depth.clone();
3084                if inlined {
3085                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3086                    inner_offset = next_offset;
3087                } else {
3088                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3089                    inner_depth.increment()?;
3090                }
3091                let val_ref = self.can_find_start.get_or_insert_with(|| fidl::new_empty!(bool, D));
3092                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3093                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3094                {
3095                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3096                }
3097                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3098                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3099                }
3100            }
3101
3102            next_offset += envelope_size;
3103            _next_ordinal_to_read += 1;
3104            if next_offset >= end_offset {
3105                return Ok(());
3106            }
3107
3108            // Decode unknown envelopes for gaps in ordinals.
3109            while _next_ordinal_to_read < 10 {
3110                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3111                _next_ordinal_to_read += 1;
3112                next_offset += envelope_size;
3113            }
3114
3115            let next_out_of_line = decoder.next_out_of_line();
3116            let handles_before = decoder.remaining_handles();
3117            if let Some((inlined, num_bytes, num_handles)) =
3118                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3119            {
3120                let member_inline_size =
3121                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3122                if inlined != (member_inline_size <= 4) {
3123                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3124                }
3125                let inner_offset;
3126                let mut inner_depth = depth.clone();
3127                if inlined {
3128                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3129                    inner_offset = next_offset;
3130                } else {
3131                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3132                    inner_depth.increment()?;
3133                }
3134                let val_ref = self.can_re_sync.get_or_insert_with(|| fidl::new_empty!(bool, D));
3135                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3136                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3137                {
3138                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3139                }
3140                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3141                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3142                }
3143            }
3144
3145            next_offset += envelope_size;
3146            _next_ordinal_to_read += 1;
3147            if next_offset >= end_offset {
3148                return Ok(());
3149            }
3150
3151            // Decode unknown envelopes for gaps in ordinals.
3152            while _next_ordinal_to_read < 11 {
3153                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3154                _next_ordinal_to_read += 1;
3155                next_offset += envelope_size;
3156            }
3157
3158            let next_out_of_line = decoder.next_out_of_line();
3159            let handles_before = decoder.remaining_handles();
3160            if let Some((inlined, num_bytes, num_handles)) =
3161                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3162            {
3163                let member_inline_size =
3164                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3165                if inlined != (member_inline_size <= 4) {
3166                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3167                }
3168                let inner_offset;
3169                let mut inner_depth = depth.clone();
3170                if inlined {
3171                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3172                    inner_offset = next_offset;
3173                } else {
3174                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3175                    inner_depth.increment()?;
3176                }
3177                let val_ref = self
3178                    .will_report_all_detected_errors
3179                    .get_or_insert_with(|| fidl::new_empty!(bool, D));
3180                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3181                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3182                {
3183                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3184                }
3185                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3186                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3187                }
3188            }
3189
3190            next_offset += envelope_size;
3191            _next_ordinal_to_read += 1;
3192            if next_offset >= end_offset {
3193                return Ok(());
3194            }
3195
3196            // Decode unknown envelopes for gaps in ordinals.
3197            while _next_ordinal_to_read < 12 {
3198                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3199                _next_ordinal_to_read += 1;
3200                next_offset += envelope_size;
3201            }
3202
3203            let next_out_of_line = decoder.next_out_of_line();
3204            let handles_before = decoder.remaining_handles();
3205            if let Some((inlined, num_bytes, num_handles)) =
3206                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3207            {
3208                let member_inline_size =
3209                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3210                if inlined != (member_inline_size <= 4) {
3211                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3212                }
3213                let inner_offset;
3214                let mut inner_depth = depth.clone();
3215                if inlined {
3216                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3217                    inner_offset = next_offset;
3218                } else {
3219                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3220                    inner_depth.increment()?;
3221                }
3222                let val_ref =
3223                    self.split_header_handling.get_or_insert_with(|| fidl::new_empty!(bool, D));
3224                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3225                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3226                {
3227                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3228                }
3229                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3230                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3231                }
3232            }
3233
3234            next_offset += envelope_size;
3235
3236            // Decode the remaining unknown envelopes.
3237            while next_offset < end_offset {
3238                _next_ordinal_to_read += 1;
3239                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3240                next_offset += envelope_size;
3241            }
3242
3243            Ok(())
3244        }
3245    }
3246
3247    impl DetailedCodecDescription {
3248        #[inline(always)]
3249        fn max_ordinal_present(&self) -> u64 {
3250            if let Some(_) = self.profile_descriptions {
3251                return 4;
3252            }
3253            if let Some(_) = self.is_hw {
3254                return 3;
3255            }
3256            if let Some(_) = self.mime_type {
3257                return 2;
3258            }
3259            if let Some(_) = self.codec_type {
3260                return 1;
3261            }
3262            0
3263        }
3264    }
3265
3266    impl fidl::encoding::ValueTypeMarker for DetailedCodecDescription {
3267        type Borrowed<'a> = &'a Self;
3268        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3269            value
3270        }
3271    }
3272
3273    unsafe impl fidl::encoding::TypeMarker for DetailedCodecDescription {
3274        type Owned = Self;
3275
3276        #[inline(always)]
3277        fn inline_align(_context: fidl::encoding::Context) -> usize {
3278            8
3279        }
3280
3281        #[inline(always)]
3282        fn inline_size(_context: fidl::encoding::Context) -> usize {
3283            16
3284        }
3285    }
3286
3287    unsafe impl<D: fidl::encoding::ResourceDialect>
3288        fidl::encoding::Encode<DetailedCodecDescription, D> for &DetailedCodecDescription
3289    {
3290        unsafe fn encode(
3291            self,
3292            encoder: &mut fidl::encoding::Encoder<'_, D>,
3293            offset: usize,
3294            mut depth: fidl::encoding::Depth,
3295        ) -> fidl::Result<()> {
3296            encoder.debug_check_bounds::<DetailedCodecDescription>(offset);
3297            // Vector header
3298            let max_ordinal: u64 = self.max_ordinal_present();
3299            encoder.write_num(max_ordinal, offset);
3300            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3301            // Calling encoder.out_of_line_offset(0) is not allowed.
3302            if max_ordinal == 0 {
3303                return Ok(());
3304            }
3305            depth.increment()?;
3306            let envelope_size = 8;
3307            let bytes_len = max_ordinal as usize * envelope_size;
3308            #[allow(unused_variables)]
3309            let offset = encoder.out_of_line_offset(bytes_len);
3310            let mut _prev_end_offset: usize = 0;
3311            if 1 > max_ordinal {
3312                return Ok(());
3313            }
3314
3315            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3316            // are envelope_size bytes.
3317            let cur_offset: usize = (1 - 1) * envelope_size;
3318
3319            // Zero reserved fields.
3320            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3321
3322            // Safety:
3323            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3324            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3325            //   envelope_size bytes, there is always sufficient room.
3326            fidl::encoding::encode_in_envelope_optional::<CodecType, D>(
3327                self.codec_type
3328                    .as_ref()
3329                    .map(<CodecType as fidl::encoding::ValueTypeMarker>::borrow),
3330                encoder,
3331                offset + cur_offset,
3332                depth,
3333            )?;
3334
3335            _prev_end_offset = cur_offset + envelope_size;
3336            if 2 > max_ordinal {
3337                return Ok(());
3338            }
3339
3340            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3341            // are envelope_size bytes.
3342            let cur_offset: usize = (2 - 1) * envelope_size;
3343
3344            // Zero reserved fields.
3345            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3346
3347            // Safety:
3348            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3349            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3350            //   envelope_size bytes, there is always sufficient room.
3351            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<256>, D>(
3352                self.mime_type.as_ref().map(
3353                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
3354                ),
3355                encoder,
3356                offset + cur_offset,
3357                depth,
3358            )?;
3359
3360            _prev_end_offset = cur_offset + envelope_size;
3361            if 3 > max_ordinal {
3362                return Ok(());
3363            }
3364
3365            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3366            // are envelope_size bytes.
3367            let cur_offset: usize = (3 - 1) * envelope_size;
3368
3369            // Zero reserved fields.
3370            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3371
3372            // Safety:
3373            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3374            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3375            //   envelope_size bytes, there is always sufficient room.
3376            fidl::encoding::encode_in_envelope_optional::<bool, D>(
3377                self.is_hw.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3378                encoder,
3379                offset + cur_offset,
3380                depth,
3381            )?;
3382
3383            _prev_end_offset = cur_offset + envelope_size;
3384            if 4 > max_ordinal {
3385                return Ok(());
3386            }
3387
3388            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3389            // are envelope_size bytes.
3390            let cur_offset: usize = (4 - 1) * envelope_size;
3391
3392            // Zero reserved fields.
3393            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3394
3395            // Safety:
3396            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3397            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3398            //   envelope_size bytes, there is always sufficient room.
3399            fidl::encoding::encode_in_envelope_optional::<ProfileDescriptions, D>(
3400                self.profile_descriptions
3401                    .as_ref()
3402                    .map(<ProfileDescriptions as fidl::encoding::ValueTypeMarker>::borrow),
3403                encoder,
3404                offset + cur_offset,
3405                depth,
3406            )?;
3407
3408            _prev_end_offset = cur_offset + envelope_size;
3409
3410            Ok(())
3411        }
3412    }
3413
3414    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3415        for DetailedCodecDescription
3416    {
3417        #[inline(always)]
3418        fn new_empty() -> Self {
3419            Self::default()
3420        }
3421
3422        unsafe fn decode(
3423            &mut self,
3424            decoder: &mut fidl::encoding::Decoder<'_, D>,
3425            offset: usize,
3426            mut depth: fidl::encoding::Depth,
3427        ) -> fidl::Result<()> {
3428            decoder.debug_check_bounds::<Self>(offset);
3429            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3430                None => return Err(fidl::Error::NotNullable),
3431                Some(len) => len,
3432            };
3433            // Calling decoder.out_of_line_offset(0) is not allowed.
3434            if len == 0 {
3435                return Ok(());
3436            };
3437            depth.increment()?;
3438            let envelope_size = 8;
3439            let bytes_len = len * envelope_size;
3440            let offset = decoder.out_of_line_offset(bytes_len)?;
3441            // Decode the envelope for each type.
3442            let mut _next_ordinal_to_read = 0;
3443            let mut next_offset = offset;
3444            let end_offset = offset + bytes_len;
3445            _next_ordinal_to_read += 1;
3446            if next_offset >= end_offset {
3447                return Ok(());
3448            }
3449
3450            // Decode unknown envelopes for gaps in ordinals.
3451            while _next_ordinal_to_read < 1 {
3452                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3453                _next_ordinal_to_read += 1;
3454                next_offset += envelope_size;
3455            }
3456
3457            let next_out_of_line = decoder.next_out_of_line();
3458            let handles_before = decoder.remaining_handles();
3459            if let Some((inlined, num_bytes, num_handles)) =
3460                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3461            {
3462                let member_inline_size =
3463                    <CodecType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3464                if inlined != (member_inline_size <= 4) {
3465                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3466                }
3467                let inner_offset;
3468                let mut inner_depth = depth.clone();
3469                if inlined {
3470                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3471                    inner_offset = next_offset;
3472                } else {
3473                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3474                    inner_depth.increment()?;
3475                }
3476                let val_ref = self.codec_type.get_or_insert_with(|| fidl::new_empty!(CodecType, D));
3477                fidl::decode!(CodecType, D, val_ref, decoder, inner_offset, inner_depth)?;
3478                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3479                {
3480                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3481                }
3482                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3483                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3484                }
3485            }
3486
3487            next_offset += envelope_size;
3488            _next_ordinal_to_read += 1;
3489            if next_offset >= end_offset {
3490                return Ok(());
3491            }
3492
3493            // Decode unknown envelopes for gaps in ordinals.
3494            while _next_ordinal_to_read < 2 {
3495                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3496                _next_ordinal_to_read += 1;
3497                next_offset += envelope_size;
3498            }
3499
3500            let next_out_of_line = decoder.next_out_of_line();
3501            let handles_before = decoder.remaining_handles();
3502            if let Some((inlined, num_bytes, num_handles)) =
3503                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3504            {
3505                let member_inline_size =
3506                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
3507                        decoder.context,
3508                    );
3509                if inlined != (member_inline_size <= 4) {
3510                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3511                }
3512                let inner_offset;
3513                let mut inner_depth = depth.clone();
3514                if inlined {
3515                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3516                    inner_offset = next_offset;
3517                } else {
3518                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3519                    inner_depth.increment()?;
3520                }
3521                let val_ref = self
3522                    .mime_type
3523                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<256>, D));
3524                fidl::decode!(
3525                    fidl::encoding::BoundedString<256>,
3526                    D,
3527                    val_ref,
3528                    decoder,
3529                    inner_offset,
3530                    inner_depth
3531                )?;
3532                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3533                {
3534                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3535                }
3536                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3537                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3538                }
3539            }
3540
3541            next_offset += envelope_size;
3542            _next_ordinal_to_read += 1;
3543            if next_offset >= end_offset {
3544                return Ok(());
3545            }
3546
3547            // Decode unknown envelopes for gaps in ordinals.
3548            while _next_ordinal_to_read < 3 {
3549                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3550                _next_ordinal_to_read += 1;
3551                next_offset += envelope_size;
3552            }
3553
3554            let next_out_of_line = decoder.next_out_of_line();
3555            let handles_before = decoder.remaining_handles();
3556            if let Some((inlined, num_bytes, num_handles)) =
3557                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3558            {
3559                let member_inline_size =
3560                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3561                if inlined != (member_inline_size <= 4) {
3562                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3563                }
3564                let inner_offset;
3565                let mut inner_depth = depth.clone();
3566                if inlined {
3567                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3568                    inner_offset = next_offset;
3569                } else {
3570                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3571                    inner_depth.increment()?;
3572                }
3573                let val_ref = self.is_hw.get_or_insert_with(|| fidl::new_empty!(bool, D));
3574                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3575                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3576                {
3577                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3578                }
3579                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3580                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3581                }
3582            }
3583
3584            next_offset += envelope_size;
3585            _next_ordinal_to_read += 1;
3586            if next_offset >= end_offset {
3587                return Ok(());
3588            }
3589
3590            // Decode unknown envelopes for gaps in ordinals.
3591            while _next_ordinal_to_read < 4 {
3592                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3593                _next_ordinal_to_read += 1;
3594                next_offset += envelope_size;
3595            }
3596
3597            let next_out_of_line = decoder.next_out_of_line();
3598            let handles_before = decoder.remaining_handles();
3599            if let Some((inlined, num_bytes, num_handles)) =
3600                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3601            {
3602                let member_inline_size =
3603                    <ProfileDescriptions as fidl::encoding::TypeMarker>::inline_size(
3604                        decoder.context,
3605                    );
3606                if inlined != (member_inline_size <= 4) {
3607                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3608                }
3609                let inner_offset;
3610                let mut inner_depth = depth.clone();
3611                if inlined {
3612                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3613                    inner_offset = next_offset;
3614                } else {
3615                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3616                    inner_depth.increment()?;
3617                }
3618                let val_ref = self
3619                    .profile_descriptions
3620                    .get_or_insert_with(|| fidl::new_empty!(ProfileDescriptions, D));
3621                fidl::decode!(ProfileDescriptions, D, val_ref, decoder, inner_offset, inner_depth)?;
3622                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3623                {
3624                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3625                }
3626                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3627                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3628                }
3629            }
3630
3631            next_offset += envelope_size;
3632
3633            // Decode the remaining unknown envelopes.
3634            while next_offset < end_offset {
3635                _next_ordinal_to_read += 1;
3636                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3637                next_offset += envelope_size;
3638            }
3639
3640            Ok(())
3641        }
3642    }
3643
3644    impl EncoderProfileDescription {
3645        #[inline(always)]
3646        fn max_ordinal_present(&self) -> u64 {
3647            if let Some(_) = self.profile {
3648                return 1;
3649            }
3650            0
3651        }
3652    }
3653
3654    impl fidl::encoding::ValueTypeMarker for EncoderProfileDescription {
3655        type Borrowed<'a> = &'a Self;
3656        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3657            value
3658        }
3659    }
3660
3661    unsafe impl fidl::encoding::TypeMarker for EncoderProfileDescription {
3662        type Owned = Self;
3663
3664        #[inline(always)]
3665        fn inline_align(_context: fidl::encoding::Context) -> usize {
3666            8
3667        }
3668
3669        #[inline(always)]
3670        fn inline_size(_context: fidl::encoding::Context) -> usize {
3671            16
3672        }
3673    }
3674
3675    unsafe impl<D: fidl::encoding::ResourceDialect>
3676        fidl::encoding::Encode<EncoderProfileDescription, D> for &EncoderProfileDescription
3677    {
3678        unsafe fn encode(
3679            self,
3680            encoder: &mut fidl::encoding::Encoder<'_, D>,
3681            offset: usize,
3682            mut depth: fidl::encoding::Depth,
3683        ) -> fidl::Result<()> {
3684            encoder.debug_check_bounds::<EncoderProfileDescription>(offset);
3685            // Vector header
3686            let max_ordinal: u64 = self.max_ordinal_present();
3687            encoder.write_num(max_ordinal, offset);
3688            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3689            // Calling encoder.out_of_line_offset(0) is not allowed.
3690            if max_ordinal == 0 {
3691                return Ok(());
3692            }
3693            depth.increment()?;
3694            let envelope_size = 8;
3695            let bytes_len = max_ordinal as usize * envelope_size;
3696            #[allow(unused_variables)]
3697            let offset = encoder.out_of_line_offset(bytes_len);
3698            let mut _prev_end_offset: usize = 0;
3699            if 1 > max_ordinal {
3700                return Ok(());
3701            }
3702
3703            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3704            // are envelope_size bytes.
3705            let cur_offset: usize = (1 - 1) * envelope_size;
3706
3707            // Zero reserved fields.
3708            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3709
3710            // Safety:
3711            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3712            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3713            //   envelope_size bytes, there is always sufficient room.
3714            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::CodecProfile, D>(
3715            self.profile.as_ref().map(<fidl_fuchsia_media__common::CodecProfile as fidl::encoding::ValueTypeMarker>::borrow),
3716            encoder, offset + cur_offset, depth
3717        )?;
3718
3719            _prev_end_offset = cur_offset + envelope_size;
3720
3721            Ok(())
3722        }
3723    }
3724
3725    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3726        for EncoderProfileDescription
3727    {
3728        #[inline(always)]
3729        fn new_empty() -> Self {
3730            Self::default()
3731        }
3732
3733        unsafe fn decode(
3734            &mut self,
3735            decoder: &mut fidl::encoding::Decoder<'_, D>,
3736            offset: usize,
3737            mut depth: fidl::encoding::Depth,
3738        ) -> fidl::Result<()> {
3739            decoder.debug_check_bounds::<Self>(offset);
3740            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3741                None => return Err(fidl::Error::NotNullable),
3742                Some(len) => len,
3743            };
3744            // Calling decoder.out_of_line_offset(0) is not allowed.
3745            if len == 0 {
3746                return Ok(());
3747            };
3748            depth.increment()?;
3749            let envelope_size = 8;
3750            let bytes_len = len * envelope_size;
3751            let offset = decoder.out_of_line_offset(bytes_len)?;
3752            // Decode the envelope for each type.
3753            let mut _next_ordinal_to_read = 0;
3754            let mut next_offset = offset;
3755            let end_offset = offset + bytes_len;
3756            _next_ordinal_to_read += 1;
3757            if next_offset >= end_offset {
3758                return Ok(());
3759            }
3760
3761            // Decode unknown envelopes for gaps in ordinals.
3762            while _next_ordinal_to_read < 1 {
3763                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3764                _next_ordinal_to_read += 1;
3765                next_offset += envelope_size;
3766            }
3767
3768            let next_out_of_line = decoder.next_out_of_line();
3769            let handles_before = decoder.remaining_handles();
3770            if let Some((inlined, num_bytes, num_handles)) =
3771                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3772            {
3773                let member_inline_size = <fidl_fuchsia_media__common::CodecProfile as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3774                if inlined != (member_inline_size <= 4) {
3775                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3776                }
3777                let inner_offset;
3778                let mut inner_depth = depth.clone();
3779                if inlined {
3780                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3781                    inner_offset = next_offset;
3782                } else {
3783                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3784                    inner_depth.increment()?;
3785                }
3786                let val_ref = self.profile.get_or_insert_with(|| {
3787                    fidl::new_empty!(fidl_fuchsia_media__common::CodecProfile, D)
3788                });
3789                fidl::decode!(
3790                    fidl_fuchsia_media__common::CodecProfile,
3791                    D,
3792                    val_ref,
3793                    decoder,
3794                    inner_offset,
3795                    inner_depth
3796                )?;
3797                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3798                {
3799                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3800                }
3801                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3802                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3803                }
3804            }
3805
3806            next_offset += envelope_size;
3807
3808            // Decode the remaining unknown envelopes.
3809            while next_offset < end_offset {
3810                _next_ordinal_to_read += 1;
3811                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3812                next_offset += envelope_size;
3813            }
3814
3815            Ok(())
3816        }
3817    }
3818
3819    impl fidl::encoding::ValueTypeMarker for ProfileDescriptions {
3820        type Borrowed<'a> = &'a Self;
3821        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3822            value
3823        }
3824    }
3825
3826    unsafe impl fidl::encoding::TypeMarker for ProfileDescriptions {
3827        type Owned = Self;
3828
3829        #[inline(always)]
3830        fn inline_align(_context: fidl::encoding::Context) -> usize {
3831            8
3832        }
3833
3834        #[inline(always)]
3835        fn inline_size(_context: fidl::encoding::Context) -> usize {
3836            16
3837        }
3838    }
3839
3840    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProfileDescriptions, D>
3841        for &ProfileDescriptions
3842    {
3843        #[inline]
3844        unsafe fn encode(
3845            self,
3846            encoder: &mut fidl::encoding::Encoder<'_, D>,
3847            offset: usize,
3848            _depth: fidl::encoding::Depth,
3849        ) -> fidl::Result<()> {
3850            encoder.debug_check_bounds::<ProfileDescriptions>(offset);
3851            encoder.write_num::<u64>(self.ordinal(), offset);
3852            match self {
3853            ProfileDescriptions::DecoderProfileDescriptions(ref val) => {
3854                fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<DecoderProfileDescription, 256>, D>(
3855                    <fidl::encoding::Vector<DecoderProfileDescription, 256> as fidl::encoding::ValueTypeMarker>::borrow(val),
3856                    encoder, offset + 8, _depth
3857                )
3858            }
3859            ProfileDescriptions::EncoderProfileDescriptions(ref val) => {
3860                fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<EncoderProfileDescription, 256>, D>(
3861                    <fidl::encoding::Vector<EncoderProfileDescription, 256> as fidl::encoding::ValueTypeMarker>::borrow(val),
3862                    encoder, offset + 8, _depth
3863                )
3864            }
3865        }
3866        }
3867    }
3868
3869    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProfileDescriptions {
3870        #[inline(always)]
3871        fn new_empty() -> Self {
3872            Self::DecoderProfileDescriptions(
3873                fidl::new_empty!(fidl::encoding::Vector<DecoderProfileDescription, 256>, D),
3874            )
3875        }
3876
3877        #[inline]
3878        unsafe fn decode(
3879            &mut self,
3880            decoder: &mut fidl::encoding::Decoder<'_, D>,
3881            offset: usize,
3882            mut depth: fidl::encoding::Depth,
3883        ) -> fidl::Result<()> {
3884            decoder.debug_check_bounds::<Self>(offset);
3885            #[allow(unused_variables)]
3886            let next_out_of_line = decoder.next_out_of_line();
3887            let handles_before = decoder.remaining_handles();
3888            let (ordinal, inlined, num_bytes, num_handles) =
3889                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3890
3891            let member_inline_size = match ordinal {
3892            1 => <fidl::encoding::Vector<DecoderProfileDescription, 256> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3893            2 => <fidl::encoding::Vector<EncoderProfileDescription, 256> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3894            _ => return Err(fidl::Error::UnknownUnionTag),
3895        };
3896
3897            if inlined != (member_inline_size <= 4) {
3898                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3899            }
3900            let _inner_offset;
3901            if inlined {
3902                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3903                _inner_offset = offset + 8;
3904            } else {
3905                depth.increment()?;
3906                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3907            }
3908            match ordinal {
3909                1 => {
3910                    #[allow(irrefutable_let_patterns)]
3911                    if let ProfileDescriptions::DecoderProfileDescriptions(_) = self {
3912                        // Do nothing, read the value into the object
3913                    } else {
3914                        // Initialize `self` to the right variant
3915                        *self = ProfileDescriptions::DecoderProfileDescriptions(
3916                            fidl::new_empty!(fidl::encoding::Vector<DecoderProfileDescription, 256>, D),
3917                        );
3918                    }
3919                    #[allow(irrefutable_let_patterns)]
3920                    if let ProfileDescriptions::DecoderProfileDescriptions(ref mut val) = self {
3921                        fidl::decode!(fidl::encoding::Vector<DecoderProfileDescription, 256>, D, val, decoder, _inner_offset, depth)?;
3922                    } else {
3923                        unreachable!()
3924                    }
3925                }
3926                2 => {
3927                    #[allow(irrefutable_let_patterns)]
3928                    if let ProfileDescriptions::EncoderProfileDescriptions(_) = self {
3929                        // Do nothing, read the value into the object
3930                    } else {
3931                        // Initialize `self` to the right variant
3932                        *self = ProfileDescriptions::EncoderProfileDescriptions(
3933                            fidl::new_empty!(fidl::encoding::Vector<EncoderProfileDescription, 256>, D),
3934                        );
3935                    }
3936                    #[allow(irrefutable_let_patterns)]
3937                    if let ProfileDescriptions::EncoderProfileDescriptions(ref mut val) = self {
3938                        fidl::decode!(fidl::encoding::Vector<EncoderProfileDescription, 256>, D, val, decoder, _inner_offset, depth)?;
3939                    } else {
3940                        unreachable!()
3941                    }
3942                }
3943                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3944            }
3945            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3946                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3947            }
3948            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3949                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3950            }
3951            Ok(())
3952        }
3953    }
3954}