stream_processor_decoder_factory/
decoders.rs
1use fidl::endpoints::*;
6use fidl_fuchsia_media::*;
7use fidl_fuchsia_mediacodec::*;
8use fuchsia_component::client;
9use futures::future::{self, BoxFuture};
10use futures::FutureExt;
11use stream_processor_test::*;
12
13pub struct DecoderFactory;
14
15impl StreamProcessorFactory for DecoderFactory {
16 fn connect_to_stream_processor(
17 &self,
18 stream: &dyn ElementaryStream,
19 format_details_version_ordinal: u64,
20 ) -> BoxFuture<'_, Result<StreamProcessorProxy>> {
21 let get_decoder = || {
22 let factory = client::connect_to_protocol::<CodecFactoryMarker>()?;
23 let (decoder_client_end, decoder_request) = create_endpoints();
24 let decoder = decoder_client_end.into_proxy();
25 factory.create_decoder(
28 &CreateDecoderParams {
29 input_details: Some(stream.format_details(format_details_version_ordinal)),
30 promise_separate_access_units_on_input: Some(stream.is_access_units()),
31 permit_lack_of_split_header_handling: Some(true),
32 ..Default::default()
33 },
34 decoder_request,
35 )?;
36 Ok(decoder)
37 };
38 future::ready(get_decoder()).boxed()
39 }
40}