stream_processor_encoder_factory/
encoders.rsuse fidl::endpoints::*;
use fidl_fuchsia_media::*;
use fidl_fuchsia_mediacodec::*;
use fuchsia_component::client;
use futures::future::{self, BoxFuture};
use futures::FutureExt;
use stream_processor_test::*;
pub struct EncoderFactory;
impl StreamProcessorFactory for EncoderFactory {
fn connect_to_stream_processor(
&self,
stream: &dyn ElementaryStream,
format_details_version_ordinal: u64,
) -> BoxFuture<'_, Result<StreamProcessorProxy>> {
let get_encoder = || {
let factory = client::connect_to_protocol::<CodecFactoryMarker>()?;
let (encoder_client_end, encoder_request) = create_endpoints();
let encoder = encoder_client_end.into_proxy();
factory.create_encoder(
&CreateEncoderParams {
input_details: Some(stream.format_details(format_details_version_ordinal)),
require_hw: Some(false),
..Default::default()
},
encoder_request,
)?;
Ok(encoder)
};
future::ready(get_encoder()).boxed()
}
}