From a52f2397ff030db8980c1c9ae479099429cfefad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Wed, 28 Feb 2024 18:49:33 +0100 Subject: [PATCH] ingress & egress api completeness --- livekit-api/src/services/egress.rs | 36 +++++++++++++++++++++++++++++ livekit-api/src/services/ingress.rs | 27 +++++++++++++++++----- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/livekit-api/src/services/egress.rs b/livekit-api/src/services/egress.rs index 4c557be9..cfc66131 100644 --- a/livekit-api/src/services/egress.rs +++ b/livekit-api/src/services/egress.rs @@ -34,6 +34,12 @@ pub struct WebOptions { pub await_start_signal: bool, } +#[derive(Default, Clone, Debug)] +pub struct ParticipantEgressOptions { + pub screenshare: bool, + pub encoding: encoding::EncodingOptions, +} + #[derive(Default, Clone, Debug)] pub struct TrackCompositeOptions { pub encoding: encoding::EncodingOptions, @@ -152,6 +158,36 @@ impl EgressClient { .map_err(Into::into) } + pub async fn start_participant_egress( + &self, + room: &str, + participant_identity: &str, + outputs: Vec, + options: ParticipantEgressOptions, + ) -> ServiceResult { + let (file_outputs, stream_outputs, segment_outputs, image_outputs) = get_outputs(outputs); + self.client + .request( + SVC, + "StartParticipantEgress", + proto::ParticipantEgressRequest { + room_name: room.to_string(), + identity: participant_identity.to_string(), + options: Some(proto::participant_egress_request::Options::Advanced( + options.encoding.into(), + )), + screen_share: options.screenshare, + file_outputs, + stream_outputs, + segment_outputs, + image_outputs, + }, + self.base.auth_header(VideoGrants { room_record: true, ..Default::default() })?, + ) + .await + .map_err(Into::into) + } + pub async fn start_track_composite_egress( &self, room: &str, diff --git a/livekit-api/src/services/ingress.rs b/livekit-api/src/services/ingress.rs index e3e7e570..4cc91f97 100644 --- a/livekit-api/src/services/ingress.rs +++ b/livekit-api/src/services/ingress.rs @@ -18,7 +18,7 @@ use super::{ServiceBase, ServiceResult, LIVEKIT_PACKAGE}; use crate::{access_token::VideoGrants, get_env_keys, services::twirp_client::TwirpClient}; #[derive(Default, Clone, Debug)] -pub struct IngressOptions { +pub struct CreateIngressOptions { pub name: String, pub room_name: String, pub participant_metadata: String, @@ -26,6 +26,20 @@ pub struct IngressOptions { pub participant_name: String, pub audio: proto::IngressAudioOptions, pub video: proto::IngressVideoOptions, + pub bypass_transcoding: bool, + pub url: String, +} + +#[derive(Default, Clone, Debug)] +pub struct UpdateIngressOptions { + pub name: String, + pub room_name: String, + pub participant_metadata: String, + pub participant_identity: String, + pub participant_name: String, + pub audio: proto::IngressAudioOptions, + pub video: proto::IngressVideoOptions, + pub bypass_transcoding: Option, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -59,7 +73,7 @@ impl IngressClient { pub async fn create_ingress( &self, input_type: proto::IngressInput, - options: IngressOptions, + options: CreateIngressOptions, ) -> ServiceResult { self.client .request( @@ -69,12 +83,13 @@ impl IngressClient { input_type: input_type as i32, name: options.name, room_name: options.room_name, + participant_metadata: options.participant_metadata, participant_identity: options.participant_identity, participant_name: options.participant_name, audio: Some(options.audio), video: Some(options.video), - bypass_transcoding: false, // TODO Expose - ..Default::default() + bypass_transcoding: options.bypass_transcoding, + url: options.url, }, self.base.auth_header(VideoGrants { ingress_admin: true, ..Default::default() })?, ) @@ -85,7 +100,7 @@ impl IngressClient { pub async fn update_ingress( &self, ingress_id: &str, - options: IngressOptions, + options: UpdateIngressOptions, ) -> ServiceResult { self.client .request( @@ -100,7 +115,7 @@ impl IngressClient { participant_name: options.participant_name, audio: Some(options.audio), video: Some(options.video), - bypass_transcoding: None, // TODO Expose + bypass_transcoding: options.bypass_transcoding, }, self.base.auth_header(VideoGrants { ingress_admin: true, ..Default::default() })?, )