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::Handle {
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 { codecs: Vec<CodecDescription> },
522}
523
524impl CodecFactoryEvent {
525    #[allow(irrefutable_let_patterns)]
526    pub fn into_on_codec_list(self) -> Option<Vec<CodecDescription>> {
527        if let CodecFactoryEvent::OnCodecList { codecs } = self { Some((codecs)) } else { None }
528    }
529
530    /// Decodes a message buffer as a [`CodecFactoryEvent`].
531    fn decode(
532        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
533    ) -> Result<CodecFactoryEvent, fidl::Error> {
534        let (bytes, _handles) = buf.split_mut();
535        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
536        debug_assert_eq!(tx_header.tx_id, 0);
537        match tx_header.ordinal {
538            0x2f93e3d51ff1ace0 => {
539                let mut out = fidl::new_empty!(
540                    CodecFactoryOnCodecListRequest,
541                    fidl::encoding::DefaultFuchsiaResourceDialect
542                );
543                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryOnCodecListRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
544                Ok((CodecFactoryEvent::OnCodecList { codecs: out.codecs }))
545            }
546            _ => Err(fidl::Error::UnknownOrdinal {
547                ordinal: tx_header.ordinal,
548                protocol_name: <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
549            }),
550        }
551    }
552}
553
554/// A Stream of incoming requests for fuchsia.mediacodec/CodecFactory.
555pub struct CodecFactoryRequestStream {
556    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
557    is_terminated: bool,
558}
559
560impl std::marker::Unpin for CodecFactoryRequestStream {}
561
562impl futures::stream::FusedStream for CodecFactoryRequestStream {
563    fn is_terminated(&self) -> bool {
564        self.is_terminated
565    }
566}
567
568impl fidl::endpoints::RequestStream for CodecFactoryRequestStream {
569    type Protocol = CodecFactoryMarker;
570    type ControlHandle = CodecFactoryControlHandle;
571
572    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
573        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
574    }
575
576    fn control_handle(&self) -> Self::ControlHandle {
577        CodecFactoryControlHandle { inner: self.inner.clone() }
578    }
579
580    fn into_inner(
581        self,
582    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
583    {
584        (self.inner, self.is_terminated)
585    }
586
587    fn from_inner(
588        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
589        is_terminated: bool,
590    ) -> Self {
591        Self { inner, is_terminated }
592    }
593}
594
595impl futures::Stream for CodecFactoryRequestStream {
596    type Item = Result<CodecFactoryRequest, fidl::Error>;
597
598    fn poll_next(
599        mut self: std::pin::Pin<&mut Self>,
600        cx: &mut std::task::Context<'_>,
601    ) -> std::task::Poll<Option<Self::Item>> {
602        let this = &mut *self;
603        if this.inner.check_shutdown(cx) {
604            this.is_terminated = true;
605            return std::task::Poll::Ready(None);
606        }
607        if this.is_terminated {
608            panic!("polled CodecFactoryRequestStream after completion");
609        }
610        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
611            |bytes, handles| {
612                match this.inner.channel().read_etc(cx, bytes, handles) {
613                    std::task::Poll::Ready(Ok(())) => {}
614                    std::task::Poll::Pending => return std::task::Poll::Pending,
615                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
616                        this.is_terminated = true;
617                        return std::task::Poll::Ready(None);
618                    }
619                    std::task::Poll::Ready(Err(e)) => {
620                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
621                            e.into(),
622                        ))));
623                    }
624                }
625
626                // A message has been received from the channel
627                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
628
629                std::task::Poll::Ready(Some(match header.ordinal {
630                    0x7a3a1c956352d49a => {
631                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
632                        let mut req = fidl::new_empty!(
633                            fidl::encoding::EmptyPayload,
634                            fidl::encoding::DefaultFuchsiaResourceDialect
635                        );
636                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
637                        let control_handle =
638                            CodecFactoryControlHandle { inner: this.inner.clone() };
639                        Ok(CodecFactoryRequest::GetDetailedCodecDescriptions {
640                            responder: CodecFactoryGetDetailedCodecDescriptionsResponder {
641                                control_handle: std::mem::ManuallyDrop::new(control_handle),
642                                tx_id: header.tx_id,
643                            },
644                        })
645                    }
646                    0x72a3c2035a1e94f0 => {
647                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
648                        let mut req = fidl::new_empty!(
649                            CodecFactoryCreateDecoderRequest,
650                            fidl::encoding::DefaultFuchsiaResourceDialect
651                        );
652                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryCreateDecoderRequest>(&header, _body_bytes, handles, &mut req)?;
653                        let control_handle =
654                            CodecFactoryControlHandle { inner: this.inner.clone() };
655                        Ok(CodecFactoryRequest::CreateDecoder {
656                            decoder_params: req.decoder_params,
657                            decoder: req.decoder,
658
659                            control_handle,
660                        })
661                    }
662                    0x20c3a235602eed0f => {
663                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
664                        let mut req = fidl::new_empty!(
665                            CodecFactoryCreateEncoderRequest,
666                            fidl::encoding::DefaultFuchsiaResourceDialect
667                        );
668                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryCreateEncoderRequest>(&header, _body_bytes, handles, &mut req)?;
669                        let control_handle =
670                            CodecFactoryControlHandle { inner: this.inner.clone() };
671                        Ok(CodecFactoryRequest::CreateEncoder {
672                            encoder_params: req.encoder_params,
673                            encoder: req.encoder,
674
675                            control_handle,
676                        })
677                    }
678                    0x1086674ad2568498 => {
679                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
680                        let mut req = fidl::new_empty!(
681                            CodecFactoryAttachLifetimeTrackingRequest,
682                            fidl::encoding::DefaultFuchsiaResourceDialect
683                        );
684                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecFactoryAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
685                        let control_handle =
686                            CodecFactoryControlHandle { inner: this.inner.clone() };
687                        Ok(CodecFactoryRequest::AttachLifetimeTracking {
688                            codec_end: req.codec_end,
689
690                            control_handle,
691                        })
692                    }
693                    _ => Err(fidl::Error::UnknownOrdinal {
694                        ordinal: header.ordinal,
695                        protocol_name:
696                            <CodecFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
697                    }),
698                }))
699            },
700        )
701    }
702}
703
704/// The purpose of the media::CodecFactory interface is to create
705/// media::StreamProcessor instances for decoders and encoders.
706///
707/// The interface methods don't attempt to homogenize all codec types,
708/// preferring to have a separate dedicated message for decoders.
709#[derive(Debug)]
710pub enum CodecFactoryRequest {
711    /// A client should call |GetDetailedCodecDescriptions()| to get a list of
712    /// codecs supported either by software implementations or by underlying hardware.
713    GetDetailedCodecDescriptions { responder: CodecFactoryGetDetailedCodecDescriptionsResponder },
714    /// CreateDecoder:
715    ///
716    /// decoder_params - See CreateDecoder_Params comments for required
717    /// and optional parameters for creating a decoder.
718    ///
719    /// decoder - a Codec.NewRequest() which will hopefully be connected to
720    /// a Codec server, or the Codec channel will get closed if no suitable
721    /// codec can be found.  We don't return any additional Codec-specific
722    /// status here because finding the Codec is allowed to be fully async, so
723    /// we don't necessarily yet know on return from this method which Codec
724    /// will be selected, if any.
725    ///
726    /// Rough sequence to create a decoder:
727    ///
728    /// factory = ConnectToEnvironmentService(CodecFactory);
729    /// CreateDecoder_Params params;
730    /// [fill out params]
731    /// CreateDecoder(params, decoder_request);
732    ///
733    /// See use_media_decoder code for more detail.
734    CreateDecoder {
735        decoder_params: CreateDecoderParams,
736        decoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
737        control_handle: CodecFactoryControlHandle,
738    },
739    /// CreateEncoder:
740    ///
741    /// encoder_params - See CreateEncoder_Params comments for required
742    /// and optional parameters for creating a decoder.
743    ///
744    /// encoder - a Codec.NewRequest() which will hopefully be connected to
745    /// a Codec server, or the Codec channel will get closed if no suitable
746    /// codec can be found.  We don't return any additional Codec-specific
747    /// status here because finding the Codec is allowed to be fully async, so
748    /// we don't necessarily yet know on return from this method which Codec
749    /// will be selected, if any.
750    CreateEncoder {
751        encoder_params: CreateEncoderParams,
752        encoder: fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
753        control_handle: CodecFactoryControlHandle,
754    },
755    /// AttachLifetimeTracking:
756    ///
757    /// Attach an eventpair endpoint to the next Create{X}(), so that the
758    /// codec_end will be closed when the number of buffers allocated reaches
759    /// 'buffers_remaining'.  Multiple eventpair endpoints can be attached per
760    /// create, with an enforced limit of
761    /// CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX.
762    ///
763    /// The lifetime signalled by this event is intended to track all resources
764    /// used by the codec, including sysmem-allocated buffers created internally
765    /// by the codec.  The sysmem buffer collections visible to the client, for
766    /// input and output buffers, are not included in the resources tracked
767    /// here, because those can be tracked separately via
768    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().  It is
769    /// permitted to send a duplicate of codec_end to both this
770    /// AttachLifetimeTracking() and also to
771    /// fuchsia.sysmem.BufferCollection.AttachLifetimeTracking().
772    /// The ZX_EVENTPAIR_PEER_CLOSED will happen when both/all lifetimes are
773    /// fully over.  This conveniently avoids needing multiple separate async
774    /// waits by the client.
775    ///
776    /// In the case of server process crashes, or failure of a codec to plumb
777    /// codec_end to sysmem, ZX_EVENTPAIR_PEER_CLOSED signalled on the peer of
778    /// codec_end may occur shortly before all resources are freed.
779    ///
780    /// A maximum of CODEC_FACTORY_LIFETIME_TRACKING_EVENTPAIR_PER_CREATE_MAX
781    /// calls to AttachLifetimeTracking() are allowed
782    /// before any Create{X}().  There is no way to cancel an attach short of
783    /// closing the CodecFactory channel.  Closing the client end of the
784    /// eventpair doesn't subtract from the number of pending attach(es).  For
785    /// this reason, it can be good to only send attach message(s) immediately
786    /// before the relevant Create{X}(), when it's known by the client that both
787    /// the attach message(s) and the Create{X}() messages will be sent.
788    ///
789    /// Closing the client's end doesn't result in any action by the server.
790    /// If the server listens to events from the client end at all, it is for
791    /// debug logging only.
792    ///
793    /// The server intentionally doesn't "trust" any bits signalled by the
794    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
795    /// which can't be triggered early, and is only triggered when all handles
796    /// to codec_end are closed.  No meaning is associated with any of the other
797    /// signal bits, and clients should functionally ignore any other signal
798    /// bits on either end of the eventpair or its peer.
799    ///
800    /// The codec_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but must
801    /// have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to transfer
802    /// without causing CodecFactory channel failure).
803    AttachLifetimeTracking { codec_end: fidl::EventPair, control_handle: CodecFactoryControlHandle },
804}
805
806impl CodecFactoryRequest {
807    #[allow(irrefutable_let_patterns)]
808    pub fn into_get_detailed_codec_descriptions(
809        self,
810    ) -> Option<(CodecFactoryGetDetailedCodecDescriptionsResponder)> {
811        if let CodecFactoryRequest::GetDetailedCodecDescriptions { responder } = self {
812            Some((responder))
813        } else {
814            None
815        }
816    }
817
818    #[allow(irrefutable_let_patterns)]
819    pub fn into_create_decoder(
820        self,
821    ) -> Option<(
822        CreateDecoderParams,
823        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
824        CodecFactoryControlHandle,
825    )> {
826        if let CodecFactoryRequest::CreateDecoder { decoder_params, decoder, control_handle } = self
827        {
828            Some((decoder_params, decoder, control_handle))
829        } else {
830            None
831        }
832    }
833
834    #[allow(irrefutable_let_patterns)]
835    pub fn into_create_encoder(
836        self,
837    ) -> Option<(
838        CreateEncoderParams,
839        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
840        CodecFactoryControlHandle,
841    )> {
842        if let CodecFactoryRequest::CreateEncoder { encoder_params, encoder, control_handle } = self
843        {
844            Some((encoder_params, encoder, control_handle))
845        } else {
846            None
847        }
848    }
849
850    #[allow(irrefutable_let_patterns)]
851    pub fn into_attach_lifetime_tracking(
852        self,
853    ) -> Option<(fidl::EventPair, CodecFactoryControlHandle)> {
854        if let CodecFactoryRequest::AttachLifetimeTracking { codec_end, control_handle } = self {
855            Some((codec_end, control_handle))
856        } else {
857            None
858        }
859    }
860
861    /// Name of the method defined in FIDL
862    pub fn method_name(&self) -> &'static str {
863        match *self {
864            CodecFactoryRequest::GetDetailedCodecDescriptions { .. } => {
865                "get_detailed_codec_descriptions"
866            }
867            CodecFactoryRequest::CreateDecoder { .. } => "create_decoder",
868            CodecFactoryRequest::CreateEncoder { .. } => "create_encoder",
869            CodecFactoryRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
870        }
871    }
872}
873
874#[derive(Debug, Clone)]
875pub struct CodecFactoryControlHandle {
876    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
877}
878
879impl fidl::endpoints::ControlHandle for CodecFactoryControlHandle {
880    fn shutdown(&self) {
881        self.inner.shutdown()
882    }
883    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
884        self.inner.shutdown_with_epitaph(status)
885    }
886
887    fn is_closed(&self) -> bool {
888        self.inner.channel().is_closed()
889    }
890    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
891        self.inner.channel().on_closed()
892    }
893
894    #[cfg(target_os = "fuchsia")]
895    fn signal_peer(
896        &self,
897        clear_mask: zx::Signals,
898        set_mask: zx::Signals,
899    ) -> Result<(), zx_status::Status> {
900        use fidl::Peered;
901        self.inner.channel().signal_peer(clear_mask, set_mask)
902    }
903}
904
905impl CodecFactoryControlHandle {
906    pub fn send_on_codec_list(&self, mut codecs: &[CodecDescription]) -> Result<(), fidl::Error> {
907        self.inner.send::<CodecFactoryOnCodecListRequest>(
908            (codecs,),
909            0,
910            0x2f93e3d51ff1ace0,
911            fidl::encoding::DynamicFlags::empty(),
912        )
913    }
914}
915
916#[must_use = "FIDL methods require a response to be sent"]
917#[derive(Debug)]
918pub struct CodecFactoryGetDetailedCodecDescriptionsResponder {
919    control_handle: std::mem::ManuallyDrop<CodecFactoryControlHandle>,
920    tx_id: u32,
921}
922
923/// Set the the channel to be shutdown (see [`CodecFactoryControlHandle::shutdown`])
924/// if the responder is dropped without sending a response, so that the client
925/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
926impl std::ops::Drop for CodecFactoryGetDetailedCodecDescriptionsResponder {
927    fn drop(&mut self) {
928        self.control_handle.shutdown();
929        // Safety: drops once, never accessed again
930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
931    }
932}
933
934impl fidl::endpoints::Responder for CodecFactoryGetDetailedCodecDescriptionsResponder {
935    type ControlHandle = CodecFactoryControlHandle;
936
937    fn control_handle(&self) -> &CodecFactoryControlHandle {
938        &self.control_handle
939    }
940
941    fn drop_without_shutdown(mut self) {
942        // Safety: drops once, never accessed again due to mem::forget
943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
944        // Prevent Drop from running (which would shut down the channel)
945        std::mem::forget(self);
946    }
947}
948
949impl CodecFactoryGetDetailedCodecDescriptionsResponder {
950    /// Sends a response to the FIDL transaction.
951    ///
952    /// Sets the channel to shutdown if an error occurs.
953    pub fn send(
954        self,
955        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
956    ) -> Result<(), fidl::Error> {
957        let _result = self.send_raw(payload);
958        if _result.is_err() {
959            self.control_handle.shutdown();
960        }
961        self.drop_without_shutdown();
962        _result
963    }
964
965    /// Similar to "send" but does not shutdown the channel if an error occurs.
966    pub fn send_no_shutdown_on_err(
967        self,
968        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
969    ) -> Result<(), fidl::Error> {
970        let _result = self.send_raw(payload);
971        self.drop_without_shutdown();
972        _result
973    }
974
975    fn send_raw(
976        &self,
977        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
978    ) -> Result<(), fidl::Error> {
979        self.control_handle.inner.send::<CodecFactoryGetDetailedCodecDescriptionsResponse>(
980            payload,
981            self.tx_id,
982            0x7a3a1c956352d49a,
983            fidl::encoding::DynamicFlags::empty(),
984        )
985    }
986}
987
988mod internal {
989    use super::*;
990
991    impl fidl::encoding::ResourceTypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
992        type Borrowed<'a> = &'a mut Self;
993        fn take_or_borrow<'a>(
994            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
995        ) -> Self::Borrowed<'a> {
996            value
997        }
998    }
999
1000    unsafe impl fidl::encoding::TypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
1001        type Owned = Self;
1002
1003        #[inline(always)]
1004        fn inline_align(_context: fidl::encoding::Context) -> usize {
1005            4
1006        }
1007
1008        #[inline(always)]
1009        fn inline_size(_context: fidl::encoding::Context) -> usize {
1010            4
1011        }
1012    }
1013
1014    unsafe impl
1015        fidl::encoding::Encode<
1016            CodecFactoryAttachLifetimeTrackingRequest,
1017            fidl::encoding::DefaultFuchsiaResourceDialect,
1018        > for &mut CodecFactoryAttachLifetimeTrackingRequest
1019    {
1020        #[inline]
1021        unsafe fn encode(
1022            self,
1023            encoder: &mut fidl::encoding::Encoder<
1024                '_,
1025                fidl::encoding::DefaultFuchsiaResourceDialect,
1026            >,
1027            offset: usize,
1028            _depth: fidl::encoding::Depth,
1029        ) -> fidl::Result<()> {
1030            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1031            // Delegate to tuple encoding.
1032            fidl::encoding::Encode::<
1033                CodecFactoryAttachLifetimeTrackingRequest,
1034                fidl::encoding::DefaultFuchsiaResourceDialect,
1035            >::encode(
1036                (<fidl::encoding::HandleType<
1037                    fidl::EventPair,
1038                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1039                    2147483648,
1040                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1041                    &mut self.codec_end
1042                ),),
1043                encoder,
1044                offset,
1045                _depth,
1046            )
1047        }
1048    }
1049    unsafe impl<
1050        T0: fidl::encoding::Encode<
1051                fidl::encoding::HandleType<
1052                    fidl::EventPair,
1053                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1054                    2147483648,
1055                >,
1056                fidl::encoding::DefaultFuchsiaResourceDialect,
1057            >,
1058    >
1059        fidl::encoding::Encode<
1060            CodecFactoryAttachLifetimeTrackingRequest,
1061            fidl::encoding::DefaultFuchsiaResourceDialect,
1062        > for (T0,)
1063    {
1064        #[inline]
1065        unsafe fn encode(
1066            self,
1067            encoder: &mut fidl::encoding::Encoder<
1068                '_,
1069                fidl::encoding::DefaultFuchsiaResourceDialect,
1070            >,
1071            offset: usize,
1072            depth: fidl::encoding::Depth,
1073        ) -> fidl::Result<()> {
1074            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1075            // Zero out padding regions. There's no need to apply masks
1076            // because the unmasked parts will be overwritten by fields.
1077            // Write the fields.
1078            self.0.encode(encoder, offset + 0, depth)?;
1079            Ok(())
1080        }
1081    }
1082
1083    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1084        for CodecFactoryAttachLifetimeTrackingRequest
1085    {
1086        #[inline(always)]
1087        fn new_empty() -> Self {
1088            Self {
1089                codec_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1090            }
1091        }
1092
1093        #[inline]
1094        unsafe fn decode(
1095            &mut self,
1096            decoder: &mut fidl::encoding::Decoder<
1097                '_,
1098                fidl::encoding::DefaultFuchsiaResourceDialect,
1099            >,
1100            offset: usize,
1101            _depth: fidl::encoding::Depth,
1102        ) -> fidl::Result<()> {
1103            decoder.debug_check_bounds::<Self>(offset);
1104            // Verify that padding bytes are zero.
1105            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.codec_end, decoder, offset + 0, _depth)?;
1106            Ok(())
1107        }
1108    }
1109
1110    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateDecoderRequest {
1111        type Borrowed<'a> = &'a mut Self;
1112        fn take_or_borrow<'a>(
1113            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1114        ) -> Self::Borrowed<'a> {
1115            value
1116        }
1117    }
1118
1119    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateDecoderRequest {
1120        type Owned = Self;
1121
1122        #[inline(always)]
1123        fn inline_align(_context: fidl::encoding::Context) -> usize {
1124            8
1125        }
1126
1127        #[inline(always)]
1128        fn inline_size(_context: fidl::encoding::Context) -> usize {
1129            24
1130        }
1131    }
1132
1133    unsafe impl
1134        fidl::encoding::Encode<
1135            CodecFactoryCreateDecoderRequest,
1136            fidl::encoding::DefaultFuchsiaResourceDialect,
1137        > for &mut CodecFactoryCreateDecoderRequest
1138    {
1139        #[inline]
1140        unsafe fn encode(
1141            self,
1142            encoder: &mut fidl::encoding::Encoder<
1143                '_,
1144                fidl::encoding::DefaultFuchsiaResourceDialect,
1145            >,
1146            offset: usize,
1147            _depth: fidl::encoding::Depth,
1148        ) -> fidl::Result<()> {
1149            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1150            // Delegate to tuple encoding.
1151            fidl::encoding::Encode::<
1152                CodecFactoryCreateDecoderRequest,
1153                fidl::encoding::DefaultFuchsiaResourceDialect,
1154            >::encode(
1155                (
1156                    <CreateDecoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1157                        &self.decoder_params,
1158                    ),
1159                    <fidl::encoding::Endpoint<
1160                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1161                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1162                        &mut self.decoder
1163                    ),
1164                ),
1165                encoder,
1166                offset,
1167                _depth,
1168            )
1169        }
1170    }
1171    unsafe impl<
1172        T0: fidl::encoding::Encode<CreateDecoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1173        T1: fidl::encoding::Encode<
1174                fidl::encoding::Endpoint<
1175                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1176                >,
1177                fidl::encoding::DefaultFuchsiaResourceDialect,
1178            >,
1179    >
1180        fidl::encoding::Encode<
1181            CodecFactoryCreateDecoderRequest,
1182            fidl::encoding::DefaultFuchsiaResourceDialect,
1183        > for (T0, T1)
1184    {
1185        #[inline]
1186        unsafe fn encode(
1187            self,
1188            encoder: &mut fidl::encoding::Encoder<
1189                '_,
1190                fidl::encoding::DefaultFuchsiaResourceDialect,
1191            >,
1192            offset: usize,
1193            depth: fidl::encoding::Depth,
1194        ) -> fidl::Result<()> {
1195            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1196            // Zero out padding regions. There's no need to apply masks
1197            // because the unmasked parts will be overwritten by fields.
1198            unsafe {
1199                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1200                (ptr as *mut u64).write_unaligned(0);
1201            }
1202            // Write the fields.
1203            self.0.encode(encoder, offset + 0, depth)?;
1204            self.1.encode(encoder, offset + 16, depth)?;
1205            Ok(())
1206        }
1207    }
1208
1209    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1210        for CodecFactoryCreateDecoderRequest
1211    {
1212        #[inline(always)]
1213        fn new_empty() -> Self {
1214            Self {
1215                decoder_params: fidl::new_empty!(
1216                    CreateDecoderParams,
1217                    fidl::encoding::DefaultFuchsiaResourceDialect
1218                ),
1219                decoder: fidl::new_empty!(
1220                    fidl::encoding::Endpoint<
1221                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1222                    >,
1223                    fidl::encoding::DefaultFuchsiaResourceDialect
1224                ),
1225            }
1226        }
1227
1228        #[inline]
1229        unsafe fn decode(
1230            &mut self,
1231            decoder: &mut fidl::encoding::Decoder<
1232                '_,
1233                fidl::encoding::DefaultFuchsiaResourceDialect,
1234            >,
1235            offset: usize,
1236            _depth: fidl::encoding::Depth,
1237        ) -> fidl::Result<()> {
1238            decoder.debug_check_bounds::<Self>(offset);
1239            // Verify that padding bytes are zero.
1240            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1241            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1242            let mask = 0xffffffff00000000u64;
1243            let maskedval = padval & mask;
1244            if maskedval != 0 {
1245                return Err(fidl::Error::NonZeroPadding {
1246                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1247                });
1248            }
1249            fidl::decode!(
1250                CreateDecoderParams,
1251                fidl::encoding::DefaultFuchsiaResourceDialect,
1252                &mut self.decoder_params,
1253                decoder,
1254                offset + 0,
1255                _depth
1256            )?;
1257            fidl::decode!(
1258                fidl::encoding::Endpoint<
1259                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1260                >,
1261                fidl::encoding::DefaultFuchsiaResourceDialect,
1262                &mut self.decoder,
1263                decoder,
1264                offset + 16,
1265                _depth
1266            )?;
1267            Ok(())
1268        }
1269    }
1270
1271    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateEncoderRequest {
1272        type Borrowed<'a> = &'a mut Self;
1273        fn take_or_borrow<'a>(
1274            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1275        ) -> Self::Borrowed<'a> {
1276            value
1277        }
1278    }
1279
1280    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateEncoderRequest {
1281        type Owned = Self;
1282
1283        #[inline(always)]
1284        fn inline_align(_context: fidl::encoding::Context) -> usize {
1285            8
1286        }
1287
1288        #[inline(always)]
1289        fn inline_size(_context: fidl::encoding::Context) -> usize {
1290            24
1291        }
1292    }
1293
1294    unsafe impl
1295        fidl::encoding::Encode<
1296            CodecFactoryCreateEncoderRequest,
1297            fidl::encoding::DefaultFuchsiaResourceDialect,
1298        > for &mut CodecFactoryCreateEncoderRequest
1299    {
1300        #[inline]
1301        unsafe fn encode(
1302            self,
1303            encoder: &mut fidl::encoding::Encoder<
1304                '_,
1305                fidl::encoding::DefaultFuchsiaResourceDialect,
1306            >,
1307            offset: usize,
1308            _depth: fidl::encoding::Depth,
1309        ) -> fidl::Result<()> {
1310            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1311            // Delegate to tuple encoding.
1312            fidl::encoding::Encode::<
1313                CodecFactoryCreateEncoderRequest,
1314                fidl::encoding::DefaultFuchsiaResourceDialect,
1315            >::encode(
1316                (
1317                    <CreateEncoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1318                        &self.encoder_params,
1319                    ),
1320                    <fidl::encoding::Endpoint<
1321                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1322                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1323                        &mut self.encoder
1324                    ),
1325                ),
1326                encoder,
1327                offset,
1328                _depth,
1329            )
1330        }
1331    }
1332    unsafe impl<
1333        T0: fidl::encoding::Encode<CreateEncoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1334        T1: fidl::encoding::Encode<
1335                fidl::encoding::Endpoint<
1336                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1337                >,
1338                fidl::encoding::DefaultFuchsiaResourceDialect,
1339            >,
1340    >
1341        fidl::encoding::Encode<
1342            CodecFactoryCreateEncoderRequest,
1343            fidl::encoding::DefaultFuchsiaResourceDialect,
1344        > for (T0, T1)
1345    {
1346        #[inline]
1347        unsafe fn encode(
1348            self,
1349            encoder: &mut fidl::encoding::Encoder<
1350                '_,
1351                fidl::encoding::DefaultFuchsiaResourceDialect,
1352            >,
1353            offset: usize,
1354            depth: fidl::encoding::Depth,
1355        ) -> fidl::Result<()> {
1356            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1357            // Zero out padding regions. There's no need to apply masks
1358            // because the unmasked parts will be overwritten by fields.
1359            unsafe {
1360                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1361                (ptr as *mut u64).write_unaligned(0);
1362            }
1363            // Write the fields.
1364            self.0.encode(encoder, offset + 0, depth)?;
1365            self.1.encode(encoder, offset + 16, depth)?;
1366            Ok(())
1367        }
1368    }
1369
1370    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1371        for CodecFactoryCreateEncoderRequest
1372    {
1373        #[inline(always)]
1374        fn new_empty() -> Self {
1375            Self {
1376                encoder_params: fidl::new_empty!(
1377                    CreateEncoderParams,
1378                    fidl::encoding::DefaultFuchsiaResourceDialect
1379                ),
1380                encoder: fidl::new_empty!(
1381                    fidl::encoding::Endpoint<
1382                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1383                    >,
1384                    fidl::encoding::DefaultFuchsiaResourceDialect
1385                ),
1386            }
1387        }
1388
1389        #[inline]
1390        unsafe fn decode(
1391            &mut self,
1392            decoder: &mut fidl::encoding::Decoder<
1393                '_,
1394                fidl::encoding::DefaultFuchsiaResourceDialect,
1395            >,
1396            offset: usize,
1397            _depth: fidl::encoding::Depth,
1398        ) -> fidl::Result<()> {
1399            decoder.debug_check_bounds::<Self>(offset);
1400            // Verify that padding bytes are zero.
1401            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1402            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1403            let mask = 0xffffffff00000000u64;
1404            let maskedval = padval & mask;
1405            if maskedval != 0 {
1406                return Err(fidl::Error::NonZeroPadding {
1407                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1408                });
1409            }
1410            fidl::decode!(
1411                CreateEncoderParams,
1412                fidl::encoding::DefaultFuchsiaResourceDialect,
1413                &mut self.encoder_params,
1414                decoder,
1415                offset + 0,
1416                _depth
1417            )?;
1418            fidl::decode!(
1419                fidl::encoding::Endpoint<
1420                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1421                >,
1422                fidl::encoding::DefaultFuchsiaResourceDialect,
1423                &mut self.encoder,
1424                decoder,
1425                offset + 16,
1426                _depth
1427            )?;
1428            Ok(())
1429        }
1430    }
1431}