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