fidl_fuchsia_mediacodec/
fidl_fuchsia_mediacodec.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_mediacodec__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CodecFactoryAttachLifetimeTrackingRequest {
16    pub codec_end: fidl::EventPair,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for CodecFactoryAttachLifetimeTrackingRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct CodecFactoryCreateDecoderRequest {
26    pub decoder_params: CreateDecoderParams,
27    pub decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for CodecFactoryCreateDecoderRequest
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct CodecFactoryCreateEncoderRequest {
37    pub encoder_params: CreateEncoderParams,
38    pub encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for CodecFactoryCreateEncoderRequest
43{
44}
45
46#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
47pub struct CodecFactoryMarker;
48
49impl fidl::endpoints::ProtocolMarker for CodecFactoryMarker {
50    type Proxy = CodecFactoryProxy;
51    type RequestStream = CodecFactoryRequestStream;
52    #[cfg(target_os = "fuchsia")]
53    type SynchronousProxy = CodecFactorySynchronousProxy;
54
55    const DEBUG_NAME: &'static str = "fuchsia.mediacodec.CodecFactory";
56}
57impl fidl::endpoints::DiscoverableProtocolMarker for CodecFactoryMarker {}
58
59pub trait CodecFactoryProxyInterface: Send + Sync {
60    type GetDetailedCodecDescriptionsResponseFut: std::future::Future<
61            Output = Result<CodecFactoryGetDetailedCodecDescriptionsResponse, fidl::Error>,
62        > + Send;
63    fn r#get_detailed_codec_descriptions(&self) -> Self::GetDetailedCodecDescriptionsResponseFut;
64    fn r#create_decoder(
65        &self,
66        decoder_params: &CreateDecoderParams,
67        decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
68    ) -> Result<(), fidl::Error>;
69    fn r#create_encoder(
70        &self,
71        encoder_params: &CreateEncoderParams,
72        encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
73    ) -> Result<(), fidl::Error>;
74    fn r#attach_lifetime_tracking(&self, codec_end: fidl::EventPair) -> Result<(), fidl::Error>;
75}
76#[derive(Debug)]
77#[cfg(target_os = "fuchsia")]
78pub struct CodecFactorySynchronousProxy {
79    client: fidl::client::sync::Client,
80}
81
82#[cfg(target_os = "fuchsia")]
83impl fidl::endpoints::SynchronousProxy for CodecFactorySynchronousProxy {
84    type Proxy = CodecFactoryProxy;
85    type Protocol = CodecFactoryMarker;
86
87    fn from_channel(inner: fidl::Channel) -> Self {
88        Self::new(inner)
89    }
90
91    fn into_channel(self) -> fidl::Channel {
92        self.client.into_channel()
93    }
94
95    fn as_channel(&self) -> &fidl::Channel {
96        self.client.as_channel()
97    }
98}
99
100#[cfg(target_os = "fuchsia")]
101impl CodecFactorySynchronousProxy {
102    pub fn new(channel: fidl::Channel) -> Self {
103        let protocol_name = <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
104        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
105    }
106
107    pub fn into_channel(self) -> fidl::Channel {
108        self.client.into_channel()
109    }
110
111    /// Waits until an event arrives and returns it. It is safe for other
112    /// threads to make concurrent requests while waiting for an event.
113    pub fn wait_for_event(
114        &self,
115        deadline: zx::MonotonicInstant,
116    ) -> Result<CodecFactoryEvent, fidl::Error> {
117        CodecFactoryEvent::decode(self.client.wait_for_event(deadline)?)
118    }
119
120    /// A client should call |GetDetailedCodecDescriptions()| to get a list of
121    /// codecs supported either by software implementations or by underlying hardware.
122    pub fn r#get_detailed_codec_descriptions(
123        &self,
124        ___deadline: zx::MonotonicInstant,
125    ) -> Result<CodecFactoryGetDetailedCodecDescriptionsResponse, fidl::Error> {
126        let _response = self.client.send_query::<
127            fidl::encoding::EmptyPayload,
128            CodecFactoryGetDetailedCodecDescriptionsResponse,
129        >(
130            (),
131            0x7a3a1c956352d49a,
132            fidl::encoding::DynamicFlags::empty(),
133            ___deadline,
134        )?;
135        Ok(_response)
136    }
137
138    /// CreateDecoder:
139    ///
140    /// decoder_params - See CreateDecoder_Params comments for required
141    /// and optional parameters for creating a decoder.
142    ///
143    /// decoder - a Codec.NewRequest() which will hopefully be connected to
144    /// a Codec server, or the Codec channel will get closed if no suitable
145    /// codec can be found.  We don't return any additional Codec-specific
146    /// status here because finding the Codec is allowed to be fully async, so
147    /// we don't necessarily yet know on return from this method which Codec
148    /// will be selected, if any.
149    ///
150    /// Rough sequence to create a decoder:
151    ///
152    /// factory = ConnectToEnvironmentService(CodecFactory);
153    /// CreateDecoder_Params params;
154    /// [fill out params]
155    /// CreateDecoder(params, decoder_request);
156    ///
157    /// See use_media_decoder code for more detail.
158    pub fn r#create_decoder(
159        &self,
160        mut decoder_params: &CreateDecoderParams,
161        mut decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
162    ) -> Result<(), fidl::Error> {
163        self.client.send::<CodecFactoryCreateDecoderRequest>(
164            (decoder_params, decoder),
165            0x72a3c2035a1e94f0,
166            fidl::encoding::DynamicFlags::empty(),
167        )
168    }
169
170    /// CreateEncoder:
171    ///
172    /// encoder_params - See CreateEncoder_Params comments for required
173    /// and optional parameters for creating a decoder.
174    ///
175    /// encoder - a Codec.NewRequest() which will hopefully be connected to
176    /// a Codec server, or the Codec channel will get closed if no suitable
177    /// codec can be found.  We don't return any additional Codec-specific
178    /// status here because finding the Codec is allowed to be fully async, so
179    /// we don't necessarily yet know on return from this method which Codec
180    /// will be selected, if any.
181    pub fn r#create_encoder(
182        &self,
183        mut encoder_params: &CreateEncoderParams,
184        mut encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
185    ) -> Result<(), fidl::Error> {
186        self.client.send::<CodecFactoryCreateEncoderRequest>(
187            (encoder_params, encoder),
188            0x20c3a235602eed0f,
189            fidl::encoding::DynamicFlags::empty(),
190        )
191    }
192
193    /// AttachLifetimeTracking:
194    ///
195    /// Attach an eventpair endpoint to the next Create{X}(), so that the
196    /// codec_end will be closed when the number of buffers allocated reaches
197    /// 'buffers_remaining'.  Multiple eventpair endpoints can be attached per
198    /// create, with an enforced limit of
199    /// CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX.
200    ///
201    /// The lifetime signalled by this event is intended to track all resources
202    /// used by the codec, including sysmem-allocated buffers created internally
203    /// by the codec.  The sysmem buffer collections visible to the client, for
204    /// input and output buffers, are not included in the resources tracked
205    /// here, because those can be tracked separately via
206    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().  It is
207    /// permitted to send a duplicate of codec_end to both this
208    /// AttachLifetimeTracking() and also to
209    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().
210    /// The ZX_EVENTPAIR_PEER_CLOSED will happen when both/all lifetimes are
211    /// fully over.  This conveniently avoids needing multiple separate async
212    /// waits by the client.
213    ///
214    /// In the case of server process crashes, or failure of a codec to plumb
215    /// codec_end to sysmem, ZX_EVENTPAIR_PEER_CLOSED signalled on the peer of
216    /// codec_end may occur shortly before all resources are freed.
217    ///
218    /// A maximum of CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX
219    /// calls to AttachLifetimeTracking() are allowed
220    /// before any Create{X}().  There is no way to cancel an attach short of
221    /// closing the CodecFactory channel.  Closing the client end of the
222    /// eventpair doesn't subtract from the number of pending attach(es).  For
223    /// this reason, it can be good to only send attach message(s) immediately
224    /// before the relevant Create{X}(), when it's known by the client that both
225    /// the attach message(s) and the Create{X}() messages will be sent.
226    ///
227    /// Closing the client's end doesn't result in any action by the server.
228    /// If the server listens to events from the client end at all, it is for
229    /// debug logging only.
230    ///
231    /// The server intentionally doesn't "trust" any bits signalled by the
232    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
233    /// which can't be triggered early, and is only triggered when all handles
234    /// to codec_end are closed.  No meaning is associated with any of the other
235    /// signal bits, and clients should functionally ignore any other signal
236    /// bits on either end of the eventpair or its peer.
237    ///
238    /// The codec_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but must
239    /// have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to transfer
240    /// without causing CodecFactory channel failure).
241    pub fn r#attach_lifetime_tracking(
242        &self,
243        mut codec_end: fidl::EventPair,
244    ) -> Result<(), fidl::Error> {
245        self.client.send::<CodecFactoryAttachLifetimeTrackingRequest>(
246            (codec_end,),
247            0x1086674ad2568498,
248            fidl::encoding::DynamicFlags::empty(),
249        )
250    }
251}
252
253#[cfg(target_os = "fuchsia")]
254impl From<CodecFactorySynchronousProxy> for zx::NullableHandle {
255    fn from(value: CodecFactorySynchronousProxy) -> Self {
256        value.into_channel().into()
257    }
258}
259
260#[cfg(target_os = "fuchsia")]
261impl From<fidl::Channel> for CodecFactorySynchronousProxy {
262    fn from(value: fidl::Channel) -> Self {
263        Self::new(value)
264    }
265}
266
267#[cfg(target_os = "fuchsia")]
268impl fidl::endpoints::FromClient for CodecFactorySynchronousProxy {
269    type Protocol = CodecFactoryMarker;
270
271    fn from_client(value: fidl::endpoints::ClientEnd<CodecFactoryMarker>) -> Self {
272        Self::new(value.into_channel())
273    }
274}
275
276#[derive(Debug, Clone)]
277pub struct CodecFactoryProxy {
278    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
279}
280
281impl fidl::endpoints::Proxy for CodecFactoryProxy {
282    type Protocol = CodecFactoryMarker;
283
284    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
285        Self::new(inner)
286    }
287
288    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
289        self.client.into_channel().map_err(|client| Self { client })
290    }
291
292    fn as_channel(&self) -> &::fidl::AsyncChannel {
293        self.client.as_channel()
294    }
295}
296
297impl CodecFactoryProxy {
298    /// Create a new Proxy for fuchsia.mediacodec/CodecFactory.
299    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
300        let protocol_name = <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
301        Self { client: fidl::client::Client::new(channel, protocol_name) }
302    }
303
304    /// Get a Stream of events from the remote end of the protocol.
305    ///
306    /// # Panics
307    ///
308    /// Panics if the event stream was already taken.
309    pub fn take_event_stream(&self) -> CodecFactoryEventStream {
310        CodecFactoryEventStream { event_receiver: self.client.take_event_receiver() }
311    }
312
313    /// A client should call |GetDetailedCodecDescriptions()| to get a list of
314    /// codecs supported either by software implementations or by underlying hardware.
315    pub fn r#get_detailed_codec_descriptions(
316        &self,
317    ) -> fidl::client::QueryResponseFut<
318        CodecFactoryGetDetailedCodecDescriptionsResponse,
319        fidl::encoding::DefaultFuchsiaResourceDialect,
320    > {
321        CodecFactoryProxyInterface::r#get_detailed_codec_descriptions(self)
322    }
323
324    /// CreateDecoder:
325    ///
326    /// decoder_params - See CreateDecoder_Params comments for required
327    /// and optional parameters for creating a decoder.
328    ///
329    /// decoder - a Codec.NewRequest() which will hopefully be connected to
330    /// a Codec server, or the Codec channel will get closed if no suitable
331    /// codec can be found.  We don't return any additional Codec-specific
332    /// status here because finding the Codec is allowed to be fully async, so
333    /// we don't necessarily yet know on return from this method which Codec
334    /// will be selected, if any.
335    ///
336    /// Rough sequence to create a decoder:
337    ///
338    /// factory = ConnectToEnvironmentService(CodecFactory);
339    /// CreateDecoder_Params params;
340    /// [fill out params]
341    /// CreateDecoder(params, decoder_request);
342    ///
343    /// See use_media_decoder code for more detail.
344    pub fn r#create_decoder(
345        &self,
346        mut decoder_params: &CreateDecoderParams,
347        mut decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
348    ) -> Result<(), fidl::Error> {
349        CodecFactoryProxyInterface::r#create_decoder(self, decoder_params, decoder)
350    }
351
352    /// CreateEncoder:
353    ///
354    /// encoder_params - See CreateEncoder_Params comments for required
355    /// and optional parameters for creating a decoder.
356    ///
357    /// encoder - a Codec.NewRequest() which will hopefully be connected to
358    /// a Codec server, or the Codec channel will get closed if no suitable
359    /// codec can be found.  We don't return any additional Codec-specific
360    /// status here because finding the Codec is allowed to be fully async, so
361    /// we don't necessarily yet know on return from this method which Codec
362    /// will be selected, if any.
363    pub fn r#create_encoder(
364        &self,
365        mut encoder_params: &CreateEncoderParams,
366        mut encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
367    ) -> Result<(), fidl::Error> {
368        CodecFactoryProxyInterface::r#create_encoder(self, encoder_params, encoder)
369    }
370
371    /// AttachLifetimeTracking:
372    ///
373    /// Attach an eventpair endpoint to the next Create{X}(), so that the
374    /// codec_end will be closed when the number of buffers allocated reaches
375    /// 'buffers_remaining'.  Multiple eventpair endpoints can be attached per
376    /// create, with an enforced limit of
377    /// CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX.
378    ///
379    /// The lifetime signalled by this event is intended to track all resources
380    /// used by the codec, including sysmem-allocated buffers created internally
381    /// by the codec.  The sysmem buffer collections visible to the client, for
382    /// input and output buffers, are not included in the resources tracked
383    /// here, because those can be tracked separately via
384    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().  It is
385    /// permitted to send a duplicate of codec_end to both this
386    /// AttachLifetimeTracking() and also to
387    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().
388    /// The ZX_EVENTPAIR_PEER_CLOSED will happen when both/all lifetimes are
389    /// fully over.  This conveniently avoids needing multiple separate async
390    /// waits by the client.
391    ///
392    /// In the case of server process crashes, or failure of a codec to plumb
393    /// codec_end to sysmem, ZX_EVENTPAIR_PEER_CLOSED signalled on the peer of
394    /// codec_end may occur shortly before all resources are freed.
395    ///
396    /// A maximum of CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX
397    /// calls to AttachLifetimeTracking() are allowed
398    /// before any Create{X}().  There is no way to cancel an attach short of
399    /// closing the CodecFactory channel.  Closing the client end of the
400    /// eventpair doesn't subtract from the number of pending attach(es).  For
401    /// this reason, it can be good to only send attach message(s) immediately
402    /// before the relevant Create{X}(), when it's known by the client that both
403    /// the attach message(s) and the Create{X}() messages will be sent.
404    ///
405    /// Closing the client's end doesn't result in any action by the server.
406    /// If the server listens to events from the client end at all, it is for
407    /// debug logging only.
408    ///
409    /// The server intentionally doesn't "trust" any bits signalled by the
410    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
411    /// which can't be triggered early, and is only triggered when all handles
412    /// to codec_end are closed.  No meaning is associated with any of the other
413    /// signal bits, and clients should functionally ignore any other signal
414    /// bits on either end of the eventpair or its peer.
415    ///
416    /// The codec_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but must
417    /// have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to transfer
418    /// without causing CodecFactory channel failure).
419    pub fn r#attach_lifetime_tracking(
420        &self,
421        mut codec_end: fidl::EventPair,
422    ) -> Result<(), fidl::Error> {
423        CodecFactoryProxyInterface::r#attach_lifetime_tracking(self, codec_end)
424    }
425}
426
427impl CodecFactoryProxyInterface for CodecFactoryProxy {
428    type GetDetailedCodecDescriptionsResponseFut = fidl::client::QueryResponseFut<
429        CodecFactoryGetDetailedCodecDescriptionsResponse,
430        fidl::encoding::DefaultFuchsiaResourceDialect,
431    >;
432    fn r#get_detailed_codec_descriptions(&self) -> Self::GetDetailedCodecDescriptionsResponseFut {
433        fn _decode(
434            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
435        ) -> Result<CodecFactoryGetDetailedCodecDescriptionsResponse, fidl::Error> {
436            let _response = fidl::client::decode_transaction_body::<
437                CodecFactoryGetDetailedCodecDescriptionsResponse,
438                fidl::encoding::DefaultFuchsiaResourceDialect,
439                0x7a3a1c956352d49a,
440            >(_buf?)?;
441            Ok(_response)
442        }
443        self.client.send_query_and_decode::<
444            fidl::encoding::EmptyPayload,
445            CodecFactoryGetDetailedCodecDescriptionsResponse,
446        >(
447            (),
448            0x7a3a1c956352d49a,
449            fidl::encoding::DynamicFlags::empty(),
450            _decode,
451        )
452    }
453
454    fn r#create_decoder(
455        &self,
456        mut decoder_params: &CreateDecoderParams,
457        mut decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
458    ) -> Result<(), fidl::Error> {
459        self.client.send::<CodecFactoryCreateDecoderRequest>(
460            (decoder_params, decoder),
461            0x72a3c2035a1e94f0,
462            fidl::encoding::DynamicFlags::empty(),
463        )
464    }
465
466    fn r#create_encoder(
467        &self,
468        mut encoder_params: &CreateEncoderParams,
469        mut encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
470    ) -> Result<(), fidl::Error> {
471        self.client.send::<CodecFactoryCreateEncoderRequest>(
472            (encoder_params, encoder),
473            0x20c3a235602eed0f,
474            fidl::encoding::DynamicFlags::empty(),
475        )
476    }
477
478    fn r#attach_lifetime_tracking(
479        &self,
480        mut codec_end: fidl::EventPair,
481    ) -> Result<(), fidl::Error> {
482        self.client.send::<CodecFactoryAttachLifetimeTrackingRequest>(
483            (codec_end,),
484            0x1086674ad2568498,
485            fidl::encoding::DynamicFlags::empty(),
486        )
487    }
488}
489
490pub struct CodecFactoryEventStream {
491    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
492}
493
494impl std::marker::Unpin for CodecFactoryEventStream {}
495
496impl futures::stream::FusedStream for CodecFactoryEventStream {
497    fn is_terminated(&self) -> bool {
498        self.event_receiver.is_terminated()
499    }
500}
501
502impl futures::Stream for CodecFactoryEventStream {
503    type Item = Result<CodecFactoryEvent, fidl::Error>;
504
505    fn poll_next(
506        mut self: std::pin::Pin<&mut Self>,
507        cx: &mut std::task::Context<'_>,
508    ) -> std::task::Poll<Option<Self::Item>> {
509        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
510            &mut self.event_receiver,
511            cx
512        )?) {
513            Some(buf) => std::task::Poll::Ready(Some(CodecFactoryEvent::decode(buf))),
514            None => std::task::Poll::Ready(None),
515        }
516    }
517}
518
519#[derive(Debug)]
520pub enum CodecFactoryEvent {
521    OnCodecList {
522        codecs: Vec<CodecDescription>,
523    },
524    #[non_exhaustive]
525    _UnknownEvent {
526        /// Ordinal of the event that was sent.
527        ordinal: u64,
528    },
529}
530
531impl CodecFactoryEvent {
532    #[allow(irrefutable_let_patterns)]
533    pub fn into_on_codec_list(self) -> Option<Vec<CodecDescription>> {
534        if let CodecFactoryEvent::OnCodecList { codecs } = self { Some((codecs)) } else { None }
535    }
536
537    /// Decodes a message buffer as a [`CodecFactoryEvent`].
538    fn decode(
539        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
540    ) -> Result<CodecFactoryEvent, fidl::Error> {
541        let (bytes, _handles) = buf.split_mut();
542        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
543        debug_assert_eq!(tx_header.tx_id, 0);
544        match tx_header.ordinal {
545            0x2f93e3d51ff1ace0 => {
546                let mut out = fidl::new_empty!(
547                    CodecFactoryOnCodecListRequest,
548                    fidl::encoding::DefaultFuchsiaResourceDialect
549                );
550                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryOnCodecListRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
551                Ok((CodecFactoryEvent::OnCodecList { codecs: out.codecs }))
552            }
553            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
554                Ok(CodecFactoryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
555            }
556            _ => Err(fidl::Error::UnknownOrdinal {
557                ordinal: tx_header.ordinal,
558                protocol_name: <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
559            }),
560        }
561    }
562}
563
564/// A Stream of incoming requests for fuchsia.mediacodec/CodecFactory.
565pub struct CodecFactoryRequestStream {
566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
567    is_terminated: bool,
568}
569
570impl std::marker::Unpin for CodecFactoryRequestStream {}
571
572impl futures::stream::FusedStream for CodecFactoryRequestStream {
573    fn is_terminated(&self) -> bool {
574        self.is_terminated
575    }
576}
577
578impl fidl::endpoints::RequestStream for CodecFactoryRequestStream {
579    type Protocol = CodecFactoryMarker;
580    type ControlHandle = CodecFactoryControlHandle;
581
582    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
583        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
584    }
585
586    fn control_handle(&self) -> Self::ControlHandle {
587        CodecFactoryControlHandle { inner: self.inner.clone() }
588    }
589
590    fn into_inner(
591        self,
592    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
593    {
594        (self.inner, self.is_terminated)
595    }
596
597    fn from_inner(
598        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
599        is_terminated: bool,
600    ) -> Self {
601        Self { inner, is_terminated }
602    }
603}
604
605impl futures::Stream for CodecFactoryRequestStream {
606    type Item = Result<CodecFactoryRequest, fidl::Error>;
607
608    fn poll_next(
609        mut self: std::pin::Pin<&mut Self>,
610        cx: &mut std::task::Context<'_>,
611    ) -> std::task::Poll<Option<Self::Item>> {
612        let this = &mut *self;
613        if this.inner.check_shutdown(cx) {
614            this.is_terminated = true;
615            return std::task::Poll::Ready(None);
616        }
617        if this.is_terminated {
618            panic!("polled CodecFactoryRequestStream after completion");
619        }
620        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
621            |bytes, handles| {
622                match this.inner.channel().read_etc(cx, bytes, handles) {
623                    std::task::Poll::Ready(Ok(())) => {}
624                    std::task::Poll::Pending => return std::task::Poll::Pending,
625                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
626                        this.is_terminated = true;
627                        return std::task::Poll::Ready(None);
628                    }
629                    std::task::Poll::Ready(Err(e)) => {
630                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
631                            e.into(),
632                        ))));
633                    }
634                }
635
636                // A message has been received from the channel
637                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
638
639                std::task::Poll::Ready(Some(match header.ordinal {
640                    0x7a3a1c956352d49a => {
641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
642                        let mut req = fidl::new_empty!(
643                            fidl::encoding::EmptyPayload,
644                            fidl::encoding::DefaultFuchsiaResourceDialect
645                        );
646                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
647                        let control_handle =
648                            CodecFactoryControlHandle { inner: this.inner.clone() };
649                        Ok(CodecFactoryRequest::GetDetailedCodecDescriptions {
650                            responder: CodecFactoryGetDetailedCodecDescriptionsResponder {
651                                control_handle: std::mem::ManuallyDrop::new(control_handle),
652                                tx_id: header.tx_id,
653                            },
654                        })
655                    }
656                    0x72a3c2035a1e94f0 => {
657                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
658                        let mut req = fidl::new_empty!(
659                            CodecFactoryCreateDecoderRequest,
660                            fidl::encoding::DefaultFuchsiaResourceDialect
661                        );
662                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryCreateDecoderRequest>(&header, _body_bytes, handles, &mut req)?;
663                        let control_handle =
664                            CodecFactoryControlHandle { inner: this.inner.clone() };
665                        Ok(CodecFactoryRequest::CreateDecoder {
666                            decoder_params: req.decoder_params,
667                            decoder: req.decoder,
668
669                            control_handle,
670                        })
671                    }
672                    0x20c3a235602eed0f => {
673                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
674                        let mut req = fidl::new_empty!(
675                            CodecFactoryCreateEncoderRequest,
676                            fidl::encoding::DefaultFuchsiaResourceDialect
677                        );
678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryCreateEncoderRequest>(&header, _body_bytes, handles, &mut req)?;
679                        let control_handle =
680                            CodecFactoryControlHandle { inner: this.inner.clone() };
681                        Ok(CodecFactoryRequest::CreateEncoder {
682                            encoder_params: req.encoder_params,
683                            encoder: req.encoder,
684
685                            control_handle,
686                        })
687                    }
688                    0x1086674ad2568498 => {
689                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
690                        let mut req = fidl::new_empty!(
691                            CodecFactoryAttachLifetimeTrackingRequest,
692                            fidl::encoding::DefaultFuchsiaResourceDialect
693                        );
694                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
695                        let control_handle =
696                            CodecFactoryControlHandle { inner: this.inner.clone() };
697                        Ok(CodecFactoryRequest::AttachLifetimeTracking {
698                            codec_end: req.codec_end,
699
700                            control_handle,
701                        })
702                    }
703                    _ if header.tx_id == 0
704                        && header
705                            .dynamic_flags()
706                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
707                    {
708                        Ok(CodecFactoryRequest::_UnknownMethod {
709                            ordinal: header.ordinal,
710                            control_handle: CodecFactoryControlHandle { inner: this.inner.clone() },
711                            method_type: fidl::MethodType::OneWay,
712                        })
713                    }
714                    _ if header
715                        .dynamic_flags()
716                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
717                    {
718                        this.inner.send_framework_err(
719                            fidl::encoding::FrameworkErr::UnknownMethod,
720                            header.tx_id,
721                            header.ordinal,
722                            header.dynamic_flags(),
723                            (bytes, handles),
724                        )?;
725                        Ok(CodecFactoryRequest::_UnknownMethod {
726                            ordinal: header.ordinal,
727                            control_handle: CodecFactoryControlHandle { inner: this.inner.clone() },
728                            method_type: fidl::MethodType::TwoWay,
729                        })
730                    }
731                    _ => Err(fidl::Error::UnknownOrdinal {
732                        ordinal: header.ordinal,
733                        protocol_name:
734                            <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
735                    }),
736                }))
737            },
738        )
739    }
740}
741
742/// The purpose of the media::CodecFactory interface is to create
743/// media::StreamProcessor instances for decoders and encoders.
744///
745/// The interface methods don't attempt to homogenize all codec types,
746/// preferring to have a separate dedicated message for decoders.
747#[derive(Debug)]
748pub enum CodecFactoryRequest {
749    /// A client should call |GetDetailedCodecDescriptions()| to get a list of
750    /// codecs supported either by software implementations or by underlying hardware.
751    GetDetailedCodecDescriptions { responder: CodecFactoryGetDetailedCodecDescriptionsResponder },
752    /// CreateDecoder:
753    ///
754    /// decoder_params - See CreateDecoder_Params comments for required
755    /// and optional parameters for creating a decoder.
756    ///
757    /// decoder - a Codec.NewRequest() which will hopefully be connected to
758    /// a Codec server, or the Codec channel will get closed if no suitable
759    /// codec can be found.  We don't return any additional Codec-specific
760    /// status here because finding the Codec is allowed to be fully async, so
761    /// we don't necessarily yet know on return from this method which Codec
762    /// will be selected, if any.
763    ///
764    /// Rough sequence to create a decoder:
765    ///
766    /// factory = ConnectToEnvironmentService(CodecFactory);
767    /// CreateDecoder_Params params;
768    /// [fill out params]
769    /// CreateDecoder(params, decoder_request);
770    ///
771    /// See use_media_decoder code for more detail.
772    CreateDecoder {
773        decoder_params: CreateDecoderParams,
774        decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
775        control_handle: CodecFactoryControlHandle,
776    },
777    /// CreateEncoder:
778    ///
779    /// encoder_params - See CreateEncoder_Params comments for required
780    /// and optional parameters for creating a decoder.
781    ///
782    /// encoder - a Codec.NewRequest() which will hopefully be connected to
783    /// a Codec server, or the Codec channel will get closed if no suitable
784    /// codec can be found.  We don't return any additional Codec-specific
785    /// status here because finding the Codec is allowed to be fully async, so
786    /// we don't necessarily yet know on return from this method which Codec
787    /// will be selected, if any.
788    CreateEncoder {
789        encoder_params: CreateEncoderParams,
790        encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
791        control_handle: CodecFactoryControlHandle,
792    },
793    /// AttachLifetimeTracking:
794    ///
795    /// Attach an eventpair endpoint to the next Create{X}(), so that the
796    /// codec_end will be closed when the number of buffers allocated reaches
797    /// 'buffers_remaining'.  Multiple eventpair endpoints can be attached per
798    /// create, with an enforced limit of
799    /// CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX.
800    ///
801    /// The lifetime signalled by this event is intended to track all resources
802    /// used by the codec, including sysmem-allocated buffers created internally
803    /// by the codec.  The sysmem buffer collections visible to the client, for
804    /// input and output buffers, are not included in the resources tracked
805    /// here, because those can be tracked separately via
806    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().  It is
807    /// permitted to send a duplicate of codec_end to both this
808    /// AttachLifetimeTracking() and also to
809    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().
810    /// The ZX_EVENTPAIR_PEER_CLOSED will happen when both/all lifetimes are
811    /// fully over.  This conveniently avoids needing multiple separate async
812    /// waits by the client.
813    ///
814    /// In the case of server process crashes, or failure of a codec to plumb
815    /// codec_end to sysmem, ZX_EVENTPAIR_PEER_CLOSED signalled on the peer of
816    /// codec_end may occur shortly before all resources are freed.
817    ///
818    /// A maximum of CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX
819    /// calls to AttachLifetimeTracking() are allowed
820    /// before any Create{X}().  There is no way to cancel an attach short of
821    /// closing the CodecFactory channel.  Closing the client end of the
822    /// eventpair doesn't subtract from the number of pending attach(es).  For
823    /// this reason, it can be good to only send attach message(s) immediately
824    /// before the relevant Create{X}(), when it's known by the client that both
825    /// the attach message(s) and the Create{X}() messages will be sent.
826    ///
827    /// Closing the client's end doesn't result in any action by the server.
828    /// If the server listens to events from the client end at all, it is for
829    /// debug logging only.
830    ///
831    /// The server intentionally doesn't "trust" any bits signalled by the
832    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
833    /// which can't be triggered early, and is only triggered when all handles
834    /// to codec_end are closed.  No meaning is associated with any of the other
835    /// signal bits, and clients should functionally ignore any other signal
836    /// bits on either end of the eventpair or its peer.
837    ///
838    /// The codec_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but must
839    /// have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to transfer
840    /// without causing CodecFactory channel failure).
841    AttachLifetimeTracking { codec_end: fidl::EventPair, control_handle: CodecFactoryControlHandle },
842    /// An interaction was received which does not match any known method.
843    #[non_exhaustive]
844    _UnknownMethod {
845        /// Ordinal of the method that was called.
846        ordinal: u64,
847        control_handle: CodecFactoryControlHandle,
848        method_type: fidl::MethodType,
849    },
850}
851
852impl CodecFactoryRequest {
853    #[allow(irrefutable_let_patterns)]
854    pub fn into_get_detailed_codec_descriptions(
855        self,
856    ) -> Option<(CodecFactoryGetDetailedCodecDescriptionsResponder)> {
857        if let CodecFactoryRequest::GetDetailedCodecDescriptions { responder } = self {
858            Some((responder))
859        } else {
860            None
861        }
862    }
863
864    #[allow(irrefutable_let_patterns)]
865    pub fn into_create_decoder(
866        self,
867    ) -> Option<(
868        CreateDecoderParams,
869        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
870        CodecFactoryControlHandle,
871    )> {
872        if let CodecFactoryRequest::CreateDecoder { decoder_params, decoder, control_handle } = self
873        {
874            Some((decoder_params, decoder, control_handle))
875        } else {
876            None
877        }
878    }
879
880    #[allow(irrefutable_let_patterns)]
881    pub fn into_create_encoder(
882        self,
883    ) -> Option<(
884        CreateEncoderParams,
885        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
886        CodecFactoryControlHandle,
887    )> {
888        if let CodecFactoryRequest::CreateEncoder { encoder_params, encoder, control_handle } = self
889        {
890            Some((encoder_params, encoder, control_handle))
891        } else {
892            None
893        }
894    }
895
896    #[allow(irrefutable_let_patterns)]
897    pub fn into_attach_lifetime_tracking(
898        self,
899    ) -> Option<(fidl::EventPair, CodecFactoryControlHandle)> {
900        if let CodecFactoryRequest::AttachLifetimeTracking { codec_end, control_handle } = self {
901            Some((codec_end, control_handle))
902        } else {
903            None
904        }
905    }
906
907    /// Name of the method defined in FIDL
908    pub fn method_name(&self) -> &'static str {
909        match *self {
910            CodecFactoryRequest::GetDetailedCodecDescriptions { .. } => {
911                "get_detailed_codec_descriptions"
912            }
913            CodecFactoryRequest::CreateDecoder { .. } => "create_decoder",
914            CodecFactoryRequest::CreateEncoder { .. } => "create_encoder",
915            CodecFactoryRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
916            CodecFactoryRequest::_UnknownMethod {
917                method_type: fidl::MethodType::OneWay, ..
918            } => "unknown one-way method",
919            CodecFactoryRequest::_UnknownMethod {
920                method_type: fidl::MethodType::TwoWay, ..
921            } => "unknown two-way method",
922        }
923    }
924}
925
926#[derive(Debug, Clone)]
927pub struct CodecFactoryControlHandle {
928    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
929}
930
931impl fidl::endpoints::ControlHandle for CodecFactoryControlHandle {
932    fn shutdown(&self) {
933        self.inner.shutdown()
934    }
935
936    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
937        self.inner.shutdown_with_epitaph(status)
938    }
939
940    fn is_closed(&self) -> bool {
941        self.inner.channel().is_closed()
942    }
943    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
944        self.inner.channel().on_closed()
945    }
946
947    #[cfg(target_os = "fuchsia")]
948    fn signal_peer(
949        &self,
950        clear_mask: zx::Signals,
951        set_mask: zx::Signals,
952    ) -> Result<(), zx_status::Status> {
953        use fidl::Peered;
954        self.inner.channel().signal_peer(clear_mask, set_mask)
955    }
956}
957
958impl CodecFactoryControlHandle {
959    pub fn send_on_codec_list(&self, mut codecs: &[CodecDescription]) -> Result<(), fidl::Error> {
960        self.inner.send::<CodecFactoryOnCodecListRequest>(
961            (codecs,),
962            0,
963            0x2f93e3d51ff1ace0,
964            fidl::encoding::DynamicFlags::empty(),
965        )
966    }
967}
968
969#[must_use = "FIDL methods require a response to be sent"]
970#[derive(Debug)]
971pub struct CodecFactoryGetDetailedCodecDescriptionsResponder {
972    control_handle: std::mem::ManuallyDrop<CodecFactoryControlHandle>,
973    tx_id: u32,
974}
975
976/// Set the the channel to be shutdown (see [`CodecFactoryControlHandle::shutdown`])
977/// if the responder is dropped without sending a response, so that the client
978/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
979impl std::ops::Drop for CodecFactoryGetDetailedCodecDescriptionsResponder {
980    fn drop(&mut self) {
981        self.control_handle.shutdown();
982        // Safety: drops once, never accessed again
983        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
984    }
985}
986
987impl fidl::endpoints::Responder for CodecFactoryGetDetailedCodecDescriptionsResponder {
988    type ControlHandle = CodecFactoryControlHandle;
989
990    fn control_handle(&self) -> &CodecFactoryControlHandle {
991        &self.control_handle
992    }
993
994    fn drop_without_shutdown(mut self) {
995        // Safety: drops once, never accessed again due to mem::forget
996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
997        // Prevent Drop from running (which would shut down the channel)
998        std::mem::forget(self);
999    }
1000}
1001
1002impl CodecFactoryGetDetailedCodecDescriptionsResponder {
1003    /// Sends a response to the FIDL transaction.
1004    ///
1005    /// Sets the channel to shutdown if an error occurs.
1006    pub fn send(
1007        self,
1008        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
1009    ) -> Result<(), fidl::Error> {
1010        let _result = self.send_raw(payload);
1011        if _result.is_err() {
1012            self.control_handle.shutdown();
1013        }
1014        self.drop_without_shutdown();
1015        _result
1016    }
1017
1018    /// Similar to "send" but does not shutdown the channel if an error occurs.
1019    pub fn send_no_shutdown_on_err(
1020        self,
1021        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
1022    ) -> Result<(), fidl::Error> {
1023        let _result = self.send_raw(payload);
1024        self.drop_without_shutdown();
1025        _result
1026    }
1027
1028    fn send_raw(
1029        &self,
1030        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
1031    ) -> Result<(), fidl::Error> {
1032        self.control_handle.inner.send::<CodecFactoryGetDetailedCodecDescriptionsResponse>(
1033            payload,
1034            self.tx_id,
1035            0x7a3a1c956352d49a,
1036            fidl::encoding::DynamicFlags::empty(),
1037        )
1038    }
1039}
1040
1041mod internal {
1042    use super::*;
1043
1044    impl fidl::encoding::ResourceTypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
1045        type Borrowed<'a> = &'a mut Self;
1046        fn take_or_borrow<'a>(
1047            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1048        ) -> Self::Borrowed<'a> {
1049            value
1050        }
1051    }
1052
1053    unsafe impl fidl::encoding::TypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
1054        type Owned = Self;
1055
1056        #[inline(always)]
1057        fn inline_align(_context: fidl::encoding::Context) -> usize {
1058            4
1059        }
1060
1061        #[inline(always)]
1062        fn inline_size(_context: fidl::encoding::Context) -> usize {
1063            4
1064        }
1065    }
1066
1067    unsafe impl
1068        fidl::encoding::Encode<
1069            CodecFactoryAttachLifetimeTrackingRequest,
1070            fidl::encoding::DefaultFuchsiaResourceDialect,
1071        > for &mut CodecFactoryAttachLifetimeTrackingRequest
1072    {
1073        #[inline]
1074        unsafe fn encode(
1075            self,
1076            encoder: &mut fidl::encoding::Encoder<
1077                '_,
1078                fidl::encoding::DefaultFuchsiaResourceDialect,
1079            >,
1080            offset: usize,
1081            _depth: fidl::encoding::Depth,
1082        ) -> fidl::Result<()> {
1083            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1084            // Delegate to tuple encoding.
1085            fidl::encoding::Encode::<
1086                CodecFactoryAttachLifetimeTrackingRequest,
1087                fidl::encoding::DefaultFuchsiaResourceDialect,
1088            >::encode(
1089                (<fidl::encoding::HandleType<
1090                    fidl::EventPair,
1091                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1092                    2147483648,
1093                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1094                    &mut self.codec_end
1095                ),),
1096                encoder,
1097                offset,
1098                _depth,
1099            )
1100        }
1101    }
1102    unsafe impl<
1103        T0: fidl::encoding::Encode<
1104                fidl::encoding::HandleType<
1105                    fidl::EventPair,
1106                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1107                    2147483648,
1108                >,
1109                fidl::encoding::DefaultFuchsiaResourceDialect,
1110            >,
1111    >
1112        fidl::encoding::Encode<
1113            CodecFactoryAttachLifetimeTrackingRequest,
1114            fidl::encoding::DefaultFuchsiaResourceDialect,
1115        > for (T0,)
1116    {
1117        #[inline]
1118        unsafe fn encode(
1119            self,
1120            encoder: &mut fidl::encoding::Encoder<
1121                '_,
1122                fidl::encoding::DefaultFuchsiaResourceDialect,
1123            >,
1124            offset: usize,
1125            depth: fidl::encoding::Depth,
1126        ) -> fidl::Result<()> {
1127            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1128            // Zero out padding regions. There's no need to apply masks
1129            // because the unmasked parts will be overwritten by fields.
1130            // Write the fields.
1131            self.0.encode(encoder, offset + 0, depth)?;
1132            Ok(())
1133        }
1134    }
1135
1136    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1137        for CodecFactoryAttachLifetimeTrackingRequest
1138    {
1139        #[inline(always)]
1140        fn new_empty() -> Self {
1141            Self {
1142                codec_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1143            }
1144        }
1145
1146        #[inline]
1147        unsafe fn decode(
1148            &mut self,
1149            decoder: &mut fidl::encoding::Decoder<
1150                '_,
1151                fidl::encoding::DefaultFuchsiaResourceDialect,
1152            >,
1153            offset: usize,
1154            _depth: fidl::encoding::Depth,
1155        ) -> fidl::Result<()> {
1156            decoder.debug_check_bounds::<Self>(offset);
1157            // Verify that padding bytes are zero.
1158            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.codec_end, decoder, offset + 0, _depth)?;
1159            Ok(())
1160        }
1161    }
1162
1163    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateDecoderRequest {
1164        type Borrowed<'a> = &'a mut Self;
1165        fn take_or_borrow<'a>(
1166            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1167        ) -> Self::Borrowed<'a> {
1168            value
1169        }
1170    }
1171
1172    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateDecoderRequest {
1173        type Owned = Self;
1174
1175        #[inline(always)]
1176        fn inline_align(_context: fidl::encoding::Context) -> usize {
1177            8
1178        }
1179
1180        #[inline(always)]
1181        fn inline_size(_context: fidl::encoding::Context) -> usize {
1182            24
1183        }
1184    }
1185
1186    unsafe impl
1187        fidl::encoding::Encode<
1188            CodecFactoryCreateDecoderRequest,
1189            fidl::encoding::DefaultFuchsiaResourceDialect,
1190        > for &mut CodecFactoryCreateDecoderRequest
1191    {
1192        #[inline]
1193        unsafe fn encode(
1194            self,
1195            encoder: &mut fidl::encoding::Encoder<
1196                '_,
1197                fidl::encoding::DefaultFuchsiaResourceDialect,
1198            >,
1199            offset: usize,
1200            _depth: fidl::encoding::Depth,
1201        ) -> fidl::Result<()> {
1202            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1203            // Delegate to tuple encoding.
1204            fidl::encoding::Encode::<
1205                CodecFactoryCreateDecoderRequest,
1206                fidl::encoding::DefaultFuchsiaResourceDialect,
1207            >::encode(
1208                (
1209                    <CreateDecoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1210                        &self.decoder_params,
1211                    ),
1212                    <fidl::encoding::Endpoint<
1213                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1214                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1215                        &mut self.decoder
1216                    ),
1217                ),
1218                encoder,
1219                offset,
1220                _depth,
1221            )
1222        }
1223    }
1224    unsafe impl<
1225        T0: fidl::encoding::Encode<CreateDecoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1226        T1: fidl::encoding::Encode<
1227                fidl::encoding::Endpoint<
1228                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1229                >,
1230                fidl::encoding::DefaultFuchsiaResourceDialect,
1231            >,
1232    >
1233        fidl::encoding::Encode<
1234            CodecFactoryCreateDecoderRequest,
1235            fidl::encoding::DefaultFuchsiaResourceDialect,
1236        > for (T0, T1)
1237    {
1238        #[inline]
1239        unsafe fn encode(
1240            self,
1241            encoder: &mut fidl::encoding::Encoder<
1242                '_,
1243                fidl::encoding::DefaultFuchsiaResourceDialect,
1244            >,
1245            offset: usize,
1246            depth: fidl::encoding::Depth,
1247        ) -> fidl::Result<()> {
1248            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1249            // Zero out padding regions. There's no need to apply masks
1250            // because the unmasked parts will be overwritten by fields.
1251            unsafe {
1252                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1253                (ptr as *mut u64).write_unaligned(0);
1254            }
1255            // Write the fields.
1256            self.0.encode(encoder, offset + 0, depth)?;
1257            self.1.encode(encoder, offset + 16, depth)?;
1258            Ok(())
1259        }
1260    }
1261
1262    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1263        for CodecFactoryCreateDecoderRequest
1264    {
1265        #[inline(always)]
1266        fn new_empty() -> Self {
1267            Self {
1268                decoder_params: fidl::new_empty!(
1269                    CreateDecoderParams,
1270                    fidl::encoding::DefaultFuchsiaResourceDialect
1271                ),
1272                decoder: fidl::new_empty!(
1273                    fidl::encoding::Endpoint<
1274                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1275                    >,
1276                    fidl::encoding::DefaultFuchsiaResourceDialect
1277                ),
1278            }
1279        }
1280
1281        #[inline]
1282        unsafe fn decode(
1283            &mut self,
1284            decoder: &mut fidl::encoding::Decoder<
1285                '_,
1286                fidl::encoding::DefaultFuchsiaResourceDialect,
1287            >,
1288            offset: usize,
1289            _depth: fidl::encoding::Depth,
1290        ) -> fidl::Result<()> {
1291            decoder.debug_check_bounds::<Self>(offset);
1292            // Verify that padding bytes are zero.
1293            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1294            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1295            let mask = 0xffffffff00000000u64;
1296            let maskedval = padval & mask;
1297            if maskedval != 0 {
1298                return Err(fidl::Error::NonZeroPadding {
1299                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1300                });
1301            }
1302            fidl::decode!(
1303                CreateDecoderParams,
1304                fidl::encoding::DefaultFuchsiaResourceDialect,
1305                &mut self.decoder_params,
1306                decoder,
1307                offset + 0,
1308                _depth
1309            )?;
1310            fidl::decode!(
1311                fidl::encoding::Endpoint<
1312                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1313                >,
1314                fidl::encoding::DefaultFuchsiaResourceDialect,
1315                &mut self.decoder,
1316                decoder,
1317                offset + 16,
1318                _depth
1319            )?;
1320            Ok(())
1321        }
1322    }
1323
1324    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateEncoderRequest {
1325        type Borrowed<'a> = &'a mut Self;
1326        fn take_or_borrow<'a>(
1327            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1328        ) -> Self::Borrowed<'a> {
1329            value
1330        }
1331    }
1332
1333    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateEncoderRequest {
1334        type Owned = Self;
1335
1336        #[inline(always)]
1337        fn inline_align(_context: fidl::encoding::Context) -> usize {
1338            8
1339        }
1340
1341        #[inline(always)]
1342        fn inline_size(_context: fidl::encoding::Context) -> usize {
1343            24
1344        }
1345    }
1346
1347    unsafe impl
1348        fidl::encoding::Encode<
1349            CodecFactoryCreateEncoderRequest,
1350            fidl::encoding::DefaultFuchsiaResourceDialect,
1351        > for &mut CodecFactoryCreateEncoderRequest
1352    {
1353        #[inline]
1354        unsafe fn encode(
1355            self,
1356            encoder: &mut fidl::encoding::Encoder<
1357                '_,
1358                fidl::encoding::DefaultFuchsiaResourceDialect,
1359            >,
1360            offset: usize,
1361            _depth: fidl::encoding::Depth,
1362        ) -> fidl::Result<()> {
1363            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1364            // Delegate to tuple encoding.
1365            fidl::encoding::Encode::<
1366                CodecFactoryCreateEncoderRequest,
1367                fidl::encoding::DefaultFuchsiaResourceDialect,
1368            >::encode(
1369                (
1370                    <CreateEncoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1371                        &self.encoder_params,
1372                    ),
1373                    <fidl::encoding::Endpoint<
1374                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1375                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1376                        &mut self.encoder
1377                    ),
1378                ),
1379                encoder,
1380                offset,
1381                _depth,
1382            )
1383        }
1384    }
1385    unsafe impl<
1386        T0: fidl::encoding::Encode<CreateEncoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1387        T1: fidl::encoding::Encode<
1388                fidl::encoding::Endpoint<
1389                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1390                >,
1391                fidl::encoding::DefaultFuchsiaResourceDialect,
1392            >,
1393    >
1394        fidl::encoding::Encode<
1395            CodecFactoryCreateEncoderRequest,
1396            fidl::encoding::DefaultFuchsiaResourceDialect,
1397        > for (T0, T1)
1398    {
1399        #[inline]
1400        unsafe fn encode(
1401            self,
1402            encoder: &mut fidl::encoding::Encoder<
1403                '_,
1404                fidl::encoding::DefaultFuchsiaResourceDialect,
1405            >,
1406            offset: usize,
1407            depth: fidl::encoding::Depth,
1408        ) -> fidl::Result<()> {
1409            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1410            // Zero out padding regions. There's no need to apply masks
1411            // because the unmasked parts will be overwritten by fields.
1412            unsafe {
1413                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1414                (ptr as *mut u64).write_unaligned(0);
1415            }
1416            // Write the fields.
1417            self.0.encode(encoder, offset + 0, depth)?;
1418            self.1.encode(encoder, offset + 16, depth)?;
1419            Ok(())
1420        }
1421    }
1422
1423    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1424        for CodecFactoryCreateEncoderRequest
1425    {
1426        #[inline(always)]
1427        fn new_empty() -> Self {
1428            Self {
1429                encoder_params: fidl::new_empty!(
1430                    CreateEncoderParams,
1431                    fidl::encoding::DefaultFuchsiaResourceDialect
1432                ),
1433                encoder: fidl::new_empty!(
1434                    fidl::encoding::Endpoint<
1435                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1436                    >,
1437                    fidl::encoding::DefaultFuchsiaResourceDialect
1438                ),
1439            }
1440        }
1441
1442        #[inline]
1443        unsafe fn decode(
1444            &mut self,
1445            decoder: &mut fidl::encoding::Decoder<
1446                '_,
1447                fidl::encoding::DefaultFuchsiaResourceDialect,
1448            >,
1449            offset: usize,
1450            _depth: fidl::encoding::Depth,
1451        ) -> fidl::Result<()> {
1452            decoder.debug_check_bounds::<Self>(offset);
1453            // Verify that padding bytes are zero.
1454            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1455            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1456            let mask = 0xffffffff00000000u64;
1457            let maskedval = padval & mask;
1458            if maskedval != 0 {
1459                return Err(fidl::Error::NonZeroPadding {
1460                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1461                });
1462            }
1463            fidl::decode!(
1464                CreateEncoderParams,
1465                fidl::encoding::DefaultFuchsiaResourceDialect,
1466                &mut self.encoder_params,
1467                decoder,
1468                offset + 0,
1469                _depth
1470            )?;
1471            fidl::decode!(
1472                fidl::encoding::Endpoint<
1473                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1474                >,
1475                fidl::encoding::DefaultFuchsiaResourceDialect,
1476                &mut self.encoder,
1477                decoder,
1478                offset + 16,
1479                _depth
1480            )?;
1481            Ok(())
1482        }
1483    }
1484}