pub async fn create_consumer(&self, options: ConsumeArgsDto) -> Result<Consumer, String> {
        if let Some(transport) = self.consumer_transports.get(&self.current_ct_id) {
            println!("creating consumer from transport id; {:?}", transport.id());
            let mut consume_options = ConsumerOptions::new(
                options.producer_id,
                self.self_rtp_capabilities.clone().unwrap(),
            );
            consume_options.app_data = AppData::new(MediaAppData {
                user_id: options.user_id,
                service_type: options.service_type,
                router_id: transport.router_id(),
            });
            consume_options.paused = true;
            let consumer = match transport.consume(consume_options).await {
                Ok(consumer) => consumer,
                Err(error) => return Err(error.to_string()),
            };
            let id = consumer.id();
            let user_id = self.id;
            let ws_actor = self.ws_actor_addr.clone();
            consumer
                .on_producer_resume(move || {
                    ws_actor.do_send(ConsumerResumeResponse { user_id, id });
                })
                .detach();
            let ws_actor = self.ws_actor_addr.clone();
            consumer
                .on_producer_pause(move || ws_actor.do_send(ConsumerPauseResponse { user_id, id }))
                .detach();
            return Ok(consumer);
        } else {
            Err("transport_not_found".to_string())
        }
    }
///
/// This function used to create consumer using provided options
///
This function used to create consumer using provided options
This function used to create consumer using provided options
pub async fn create_consumer(&self, options: ConsumeArgsDto) -> Result<Consumer, String> {
        if let Some(transport) = self.consumer_transports.get(&self.current_ct_id) {
            println!("creating consumer from transport id; {:?}", transport.id());
            let mut consume_options = ConsumerOptions::new(
                options.producer_id,
                self.self_rtp_capabilities.clone().unwrap(),
            );
            consume_options.app_data = AppData::new(MediaAppData {
                user_id: options.user_id,
                service_type: options.service_type,
                router_id: transport.router_id(),
            });
            consume_options.paused = true;
            let consumer = match transport.consume(consume_options).await {
                Ok(consumer) => consumer,
                Err(error) => return Err(error.to_string()),
            };
            let id = consumer.id();
            let user_id = self.id;
            let ws_actor = self.ws_actor_addr.clone();
            consumer
                .on_producer_resume(move || {
                    ws_actor.do_send(ConsumerResumeResponse { user_id, id });
                })
                .detach();
            let ws_actor = self.ws_actor_addr.clone();
            consumer
                .on_producer_pause(move || ws_actor.do_send(ConsumerPauseResponse { user_id, id }))
                .detach();
            return Ok(consumer);
        } else {
            Err("transport_not_found".to_string())
        }
    }
pub async fn create_consumer ( & self , options : ConsumeArgsDto ) -> Result < Consumer , String > { if let Some ( transport ) = self . consumer_transports . get ( & self . current_ct_id ) { println ! ( " " transport id ( ) ) ; let mut consume_options = ConsumerOptions :: new ( options . producer_id , self . self_rtp_capabilities . clone ( ) . unwrap ( ) , ) ; consume_options . app_data = AppData :: new ( MediaAppData { user_id : options . user_id , service_type : options . service_type , router_id : transport . router_id ( ) , } ) ; consume_options . paused = true ; let consumer = match transport . consume ( consume_options ) . await { Ok ( consumer ) => consumer , Err ( error ) => return Err ( error . to_string ( ) ) , } ; let id = consumer . id ( ) ; let user_id = self . id ; let ws_actor = self . ws_actor_addr . clone ( ) ; consumer . on_producer_resume ( move | | { ws_actor . do_send ( ConsumerResumeResponse { user_id , id } ) ; } ) . detach ( ) ; let ws_actor = self . ws_actor_addr . clone ( ) ; consumer . on_producer_pause ( move | | ws_actor . do_send ( ConsumerPauseResponse { user_id , id } ) ) . detach ( ) ; return Ok ( consumer ) ; } else { Err ( " " . to_string ( ) ) } }
This function used to create consumer using provided options
This function used to create consumer using provided options
&self
options
ConsumeArgsDto
&self
options
ConsumeArgsDto