Skip to content

Commit

Permalink
ingress & egress api completeness
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Feb 28, 2024
1 parent fca3466 commit a52f239
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
36 changes: 36 additions & 0 deletions livekit-api/src/services/egress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -152,6 +158,36 @@ impl EgressClient {
.map_err(Into::into)
}

pub async fn start_participant_egress(
&self,
room: &str,
participant_identity: &str,
outputs: Vec<EgressOutput>,
options: ParticipantEgressOptions,
) -> ServiceResult<proto::EgressInfo> {
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,
Expand Down
27 changes: 21 additions & 6 deletions livekit-api/src/services/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@ 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,
pub participant_identity: String,
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<bool>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -59,7 +73,7 @@ impl IngressClient {
pub async fn create_ingress(
&self,
input_type: proto::IngressInput,
options: IngressOptions,
options: CreateIngressOptions,
) -> ServiceResult<proto::IngressInfo> {
self.client
.request(
Expand All @@ -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() })?,
)
Expand All @@ -85,7 +100,7 @@ impl IngressClient {
pub async fn update_ingress(
&self,
ingress_id: &str,
options: IngressOptions,
options: UpdateIngressOptions,
) -> ServiceResult<proto::IngressInfo> {
self.client
.request(
Expand All @@ -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() })?,
)
Expand Down

0 comments on commit a52f239

Please sign in to comment.