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 { 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
884    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
885        self.inner.shutdown_with_epitaph(status)
886    }
887
888    fn is_closed(&self) -> bool {
889        self.inner.channel().is_closed()
890    }
891    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
892        self.inner.channel().on_closed()
893    }
894
895    #[cfg(target_os = "fuchsia")]
896    fn signal_peer(
897        &self,
898        clear_mask: zx::Signals,
899        set_mask: zx::Signals,
900    ) -> Result<(), zx_status::Status> {
901        use fidl::Peered;
902        self.inner.channel().signal_peer(clear_mask, set_mask)
903    }
904}
905
906impl CodecFactoryControlHandle {
907    pub fn send_on_codec_list(&self, mut codecs: &[CodecDescription]) -> Result<(), fidl::Error> {
908        self.inner.send::<CodecFactoryOnCodecListRequest>(
909            (codecs,),
910            0,
911            0x2f93e3d51ff1ace0,
912            fidl::encoding::DynamicFlags::empty(),
913        )
914    }
915}
916
917#[must_use = "FIDL methods require a response to be sent"]
918#[derive(Debug)]
919pub struct CodecFactoryGetDetailedCodecDescriptionsResponder {
920    control_handle: std::mem::ManuallyDrop<CodecFactoryControlHandle>,
921    tx_id: u32,
922}
923
924/// Set the the channel to be shutdown (see [`CodecFactoryControlHandle::shutdown`])
925/// if the responder is dropped without sending a response, so that the client
926/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
927impl std::ops::Drop for CodecFactoryGetDetailedCodecDescriptionsResponder {
928    fn drop(&mut self) {
929        self.control_handle.shutdown();
930        // Safety: drops once, never accessed again
931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
932    }
933}
934
935impl fidl::endpoints::Responder for CodecFactoryGetDetailedCodecDescriptionsResponder {
936    type ControlHandle = CodecFactoryControlHandle;
937
938    fn control_handle(&self) -> &CodecFactoryControlHandle {
939        &self.control_handle
940    }
941
942    fn drop_without_shutdown(mut self) {
943        // Safety: drops once, never accessed again due to mem::forget
944        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
945        // Prevent Drop from running (which would shut down the channel)
946        std::mem::forget(self);
947    }
948}
949
950impl CodecFactoryGetDetailedCodecDescriptionsResponder {
951    /// Sends a response to the FIDL transaction.
952    ///
953    /// Sets the channel to shutdown if an error occurs.
954    pub fn send(
955        self,
956        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
957    ) -> Result<(), fidl::Error> {
958        let _result = self.send_raw(payload);
959        if _result.is_err() {
960            self.control_handle.shutdown();
961        }
962        self.drop_without_shutdown();
963        _result
964    }
965
966    /// Similar to "send" but does not shutdown the channel if an error occurs.
967    pub fn send_no_shutdown_on_err(
968        self,
969        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
970    ) -> Result<(), fidl::Error> {
971        let _result = self.send_raw(payload);
972        self.drop_without_shutdown();
973        _result
974    }
975
976    fn send_raw(
977        &self,
978        mut payload: &CodecFactoryGetDetailedCodecDescriptionsResponse,
979    ) -> Result<(), fidl::Error> {
980        self.control_handle.inner.send::<CodecFactoryGetDetailedCodecDescriptionsResponse>(
981            payload,
982            self.tx_id,
983            0x7a3a1c956352d49a,
984            fidl::encoding::DynamicFlags::empty(),
985        )
986    }
987}
988
989mod internal {
990    use super::*;
991
992    impl fidl::encoding::ResourceTypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
993        type Borrowed<'a> = &'a mut Self;
994        fn take_or_borrow<'a>(
995            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
996        ) -> Self::Borrowed<'a> {
997            value
998        }
999    }
1000
1001    unsafe impl fidl::encoding::TypeMarker for CodecFactoryAttachLifetimeTrackingRequest {
1002        type Owned = Self;
1003
1004        #[inline(always)]
1005        fn inline_align(_context: fidl::encoding::Context) -> usize {
1006            4
1007        }
1008
1009        #[inline(always)]
1010        fn inline_size(_context: fidl::encoding::Context) -> usize {
1011            4
1012        }
1013    }
1014
1015    unsafe impl
1016        fidl::encoding::Encode<
1017            CodecFactoryAttachLifetimeTrackingRequest,
1018            fidl::encoding::DefaultFuchsiaResourceDialect,
1019        > for &mut CodecFactoryAttachLifetimeTrackingRequest
1020    {
1021        #[inline]
1022        unsafe fn encode(
1023            self,
1024            encoder: &mut fidl::encoding::Encoder<
1025                '_,
1026                fidl::encoding::DefaultFuchsiaResourceDialect,
1027            >,
1028            offset: usize,
1029            _depth: fidl::encoding::Depth,
1030        ) -> fidl::Result<()> {
1031            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1032            // Delegate to tuple encoding.
1033            fidl::encoding::Encode::<
1034                CodecFactoryAttachLifetimeTrackingRequest,
1035                fidl::encoding::DefaultFuchsiaResourceDialect,
1036            >::encode(
1037                (<fidl::encoding::HandleType<
1038                    fidl::EventPair,
1039                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1040                    2147483648,
1041                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1042                    &mut self.codec_end
1043                ),),
1044                encoder,
1045                offset,
1046                _depth,
1047            )
1048        }
1049    }
1050    unsafe impl<
1051        T0: fidl::encoding::Encode<
1052                fidl::encoding::HandleType<
1053                    fidl::EventPair,
1054                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1055                    2147483648,
1056                >,
1057                fidl::encoding::DefaultFuchsiaResourceDialect,
1058            >,
1059    >
1060        fidl::encoding::Encode<
1061            CodecFactoryAttachLifetimeTrackingRequest,
1062            fidl::encoding::DefaultFuchsiaResourceDialect,
1063        > for (T0,)
1064    {
1065        #[inline]
1066        unsafe fn encode(
1067            self,
1068            encoder: &mut fidl::encoding::Encoder<
1069                '_,
1070                fidl::encoding::DefaultFuchsiaResourceDialect,
1071            >,
1072            offset: usize,
1073            depth: fidl::encoding::Depth,
1074        ) -> fidl::Result<()> {
1075            encoder.debug_check_bounds::<CodecFactoryAttachLifetimeTrackingRequest>(offset);
1076            // Zero out padding regions. There's no need to apply masks
1077            // because the unmasked parts will be overwritten by fields.
1078            // Write the fields.
1079            self.0.encode(encoder, offset + 0, depth)?;
1080            Ok(())
1081        }
1082    }
1083
1084    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1085        for CodecFactoryAttachLifetimeTrackingRequest
1086    {
1087        #[inline(always)]
1088        fn new_empty() -> Self {
1089            Self {
1090                codec_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1091            }
1092        }
1093
1094        #[inline]
1095        unsafe fn decode(
1096            &mut self,
1097            decoder: &mut fidl::encoding::Decoder<
1098                '_,
1099                fidl::encoding::DefaultFuchsiaResourceDialect,
1100            >,
1101            offset: usize,
1102            _depth: fidl::encoding::Depth,
1103        ) -> fidl::Result<()> {
1104            decoder.debug_check_bounds::<Self>(offset);
1105            // Verify that padding bytes are zero.
1106            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.codec_end, decoder, offset + 0, _depth)?;
1107            Ok(())
1108        }
1109    }
1110
1111    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateDecoderRequest {
1112        type Borrowed<'a> = &'a mut Self;
1113        fn take_or_borrow<'a>(
1114            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1115        ) -> Self::Borrowed<'a> {
1116            value
1117        }
1118    }
1119
1120    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateDecoderRequest {
1121        type Owned = Self;
1122
1123        #[inline(always)]
1124        fn inline_align(_context: fidl::encoding::Context) -> usize {
1125            8
1126        }
1127
1128        #[inline(always)]
1129        fn inline_size(_context: fidl::encoding::Context) -> usize {
1130            24
1131        }
1132    }
1133
1134    unsafe impl
1135        fidl::encoding::Encode<
1136            CodecFactoryCreateDecoderRequest,
1137            fidl::encoding::DefaultFuchsiaResourceDialect,
1138        > for &mut CodecFactoryCreateDecoderRequest
1139    {
1140        #[inline]
1141        unsafe fn encode(
1142            self,
1143            encoder: &mut fidl::encoding::Encoder<
1144                '_,
1145                fidl::encoding::DefaultFuchsiaResourceDialect,
1146            >,
1147            offset: usize,
1148            _depth: fidl::encoding::Depth,
1149        ) -> fidl::Result<()> {
1150            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1151            // Delegate to tuple encoding.
1152            fidl::encoding::Encode::<
1153                CodecFactoryCreateDecoderRequest,
1154                fidl::encoding::DefaultFuchsiaResourceDialect,
1155            >::encode(
1156                (
1157                    <CreateDecoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1158                        &self.decoder_params,
1159                    ),
1160                    <fidl::encoding::Endpoint<
1161                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1162                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1163                        &mut self.decoder
1164                    ),
1165                ),
1166                encoder,
1167                offset,
1168                _depth,
1169            )
1170        }
1171    }
1172    unsafe impl<
1173        T0: fidl::encoding::Encode<CreateDecoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1174        T1: fidl::encoding::Encode<
1175                fidl::encoding::Endpoint<
1176                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1177                >,
1178                fidl::encoding::DefaultFuchsiaResourceDialect,
1179            >,
1180    >
1181        fidl::encoding::Encode<
1182            CodecFactoryCreateDecoderRequest,
1183            fidl::encoding::DefaultFuchsiaResourceDialect,
1184        > for (T0, T1)
1185    {
1186        #[inline]
1187        unsafe fn encode(
1188            self,
1189            encoder: &mut fidl::encoding::Encoder<
1190                '_,
1191                fidl::encoding::DefaultFuchsiaResourceDialect,
1192            >,
1193            offset: usize,
1194            depth: fidl::encoding::Depth,
1195        ) -> fidl::Result<()> {
1196            encoder.debug_check_bounds::<CodecFactoryCreateDecoderRequest>(offset);
1197            // Zero out padding regions. There's no need to apply masks
1198            // because the unmasked parts will be overwritten by fields.
1199            unsafe {
1200                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1201                (ptr as *mut u64).write_unaligned(0);
1202            }
1203            // Write the fields.
1204            self.0.encode(encoder, offset + 0, depth)?;
1205            self.1.encode(encoder, offset + 16, depth)?;
1206            Ok(())
1207        }
1208    }
1209
1210    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1211        for CodecFactoryCreateDecoderRequest
1212    {
1213        #[inline(always)]
1214        fn new_empty() -> Self {
1215            Self {
1216                decoder_params: fidl::new_empty!(
1217                    CreateDecoderParams,
1218                    fidl::encoding::DefaultFuchsiaResourceDialect
1219                ),
1220                decoder: fidl::new_empty!(
1221                    fidl::encoding::Endpoint<
1222                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1223                    >,
1224                    fidl::encoding::DefaultFuchsiaResourceDialect
1225                ),
1226            }
1227        }
1228
1229        #[inline]
1230        unsafe fn decode(
1231            &mut self,
1232            decoder: &mut fidl::encoding::Decoder<
1233                '_,
1234                fidl::encoding::DefaultFuchsiaResourceDialect,
1235            >,
1236            offset: usize,
1237            _depth: fidl::encoding::Depth,
1238        ) -> fidl::Result<()> {
1239            decoder.debug_check_bounds::<Self>(offset);
1240            // Verify that padding bytes are zero.
1241            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1242            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1243            let mask = 0xffffffff00000000u64;
1244            let maskedval = padval & mask;
1245            if maskedval != 0 {
1246                return Err(fidl::Error::NonZeroPadding {
1247                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1248                });
1249            }
1250            fidl::decode!(
1251                CreateDecoderParams,
1252                fidl::encoding::DefaultFuchsiaResourceDialect,
1253                &mut self.decoder_params,
1254                decoder,
1255                offset + 0,
1256                _depth
1257            )?;
1258            fidl::decode!(
1259                fidl::encoding::Endpoint<
1260                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1261                >,
1262                fidl::encoding::DefaultFuchsiaResourceDialect,
1263                &mut self.decoder,
1264                decoder,
1265                offset + 16,
1266                _depth
1267            )?;
1268            Ok(())
1269        }
1270    }
1271
1272    impl fidl::encoding::ResourceTypeMarker for CodecFactoryCreateEncoderRequest {
1273        type Borrowed<'a> = &'a mut Self;
1274        fn take_or_borrow<'a>(
1275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1276        ) -> Self::Borrowed<'a> {
1277            value
1278        }
1279    }
1280
1281    unsafe impl fidl::encoding::TypeMarker for CodecFactoryCreateEncoderRequest {
1282        type Owned = Self;
1283
1284        #[inline(always)]
1285        fn inline_align(_context: fidl::encoding::Context) -> usize {
1286            8
1287        }
1288
1289        #[inline(always)]
1290        fn inline_size(_context: fidl::encoding::Context) -> usize {
1291            24
1292        }
1293    }
1294
1295    unsafe impl
1296        fidl::encoding::Encode<
1297            CodecFactoryCreateEncoderRequest,
1298            fidl::encoding::DefaultFuchsiaResourceDialect,
1299        > for &mut CodecFactoryCreateEncoderRequest
1300    {
1301        #[inline]
1302        unsafe fn encode(
1303            self,
1304            encoder: &mut fidl::encoding::Encoder<
1305                '_,
1306                fidl::encoding::DefaultFuchsiaResourceDialect,
1307            >,
1308            offset: usize,
1309            _depth: fidl::encoding::Depth,
1310        ) -> fidl::Result<()> {
1311            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1312            // Delegate to tuple encoding.
1313            fidl::encoding::Encode::<
1314                CodecFactoryCreateEncoderRequest,
1315                fidl::encoding::DefaultFuchsiaResourceDialect,
1316            >::encode(
1317                (
1318                    <CreateEncoderParams as fidl::encoding::ValueTypeMarker>::borrow(
1319                        &self.encoder_params,
1320                    ),
1321                    <fidl::encoding::Endpoint<
1322                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1323                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1324                        &mut self.encoder
1325                    ),
1326                ),
1327                encoder,
1328                offset,
1329                _depth,
1330            )
1331        }
1332    }
1333    unsafe impl<
1334        T0: fidl::encoding::Encode<CreateEncoderParams, fidl::encoding::DefaultFuchsiaResourceDialect>,
1335        T1: fidl::encoding::Encode<
1336                fidl::encoding::Endpoint<
1337                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1338                >,
1339                fidl::encoding::DefaultFuchsiaResourceDialect,
1340            >,
1341    >
1342        fidl::encoding::Encode<
1343            CodecFactoryCreateEncoderRequest,
1344            fidl::encoding::DefaultFuchsiaResourceDialect,
1345        > for (T0, T1)
1346    {
1347        #[inline]
1348        unsafe fn encode(
1349            self,
1350            encoder: &mut fidl::encoding::Encoder<
1351                '_,
1352                fidl::encoding::DefaultFuchsiaResourceDialect,
1353            >,
1354            offset: usize,
1355            depth: fidl::encoding::Depth,
1356        ) -> fidl::Result<()> {
1357            encoder.debug_check_bounds::<CodecFactoryCreateEncoderRequest>(offset);
1358            // Zero out padding regions. There's no need to apply masks
1359            // because the unmasked parts will be overwritten by fields.
1360            unsafe {
1361                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1362                (ptr as *mut u64).write_unaligned(0);
1363            }
1364            // Write the fields.
1365            self.0.encode(encoder, offset + 0, depth)?;
1366            self.1.encode(encoder, offset + 16, depth)?;
1367            Ok(())
1368        }
1369    }
1370
1371    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1372        for CodecFactoryCreateEncoderRequest
1373    {
1374        #[inline(always)]
1375        fn new_empty() -> Self {
1376            Self {
1377                encoder_params: fidl::new_empty!(
1378                    CreateEncoderParams,
1379                    fidl::encoding::DefaultFuchsiaResourceDialect
1380                ),
1381                encoder: fidl::new_empty!(
1382                    fidl::encoding::Endpoint<
1383                        fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1384                    >,
1385                    fidl::encoding::DefaultFuchsiaResourceDialect
1386                ),
1387            }
1388        }
1389
1390        #[inline]
1391        unsafe fn decode(
1392            &mut self,
1393            decoder: &mut fidl::encoding::Decoder<
1394                '_,
1395                fidl::encoding::DefaultFuchsiaResourceDialect,
1396            >,
1397            offset: usize,
1398            _depth: fidl::encoding::Depth,
1399        ) -> fidl::Result<()> {
1400            decoder.debug_check_bounds::<Self>(offset);
1401            // Verify that padding bytes are zero.
1402            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1403            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1404            let mask = 0xffffffff00000000u64;
1405            let maskedval = padval & mask;
1406            if maskedval != 0 {
1407                return Err(fidl::Error::NonZeroPadding {
1408                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1409                });
1410            }
1411            fidl::decode!(
1412                CreateEncoderParams,
1413                fidl::encoding::DefaultFuchsiaResourceDialect,
1414                &mut self.encoder_params,
1415                decoder,
1416                offset + 0,
1417                _depth
1418            )?;
1419            fidl::decode!(
1420                fidl::encoding::Endpoint<
1421                    fidl::endpoints::ServerEnd<fidl_fuchsia_media::StreamProcessorMarker>,
1422                >,
1423                fidl::encoding::DefaultFuchsiaResourceDialect,
1424                &mut self.encoder,
1425                decoder,
1426                offset + 16,
1427                _depth
1428            )?;
1429            Ok(())
1430        }
1431    }
1432}