From e5ed8d89f61e11be3b45e61ddb8557c55573df31 Mon Sep 17 00:00:00 2001 From: Jasper Hugo Date: Thu, 19 Aug 2021 17:20:42 +0700 Subject: [PATCH] added support for some colibri signalling via gst-meet tool --- gst-meet/src/main.rs | 41 +++++++++++++++++++++++++++++++++++-- lib-gst-meet/Cargo.toml | 2 +- lib-gst-meet/src/colibri.rs | 31 +++++++++++++++++----------- lib-gst-meet/src/lib.rs | 2 +- 4 files changed, 60 insertions(+), 16 deletions(-) diff --git a/gst-meet/src/main.rs b/gst-meet/src/main.rs index 1934503..fb6a14c 100644 --- a/gst-meet/src/main.rs +++ b/gst-meet/src/main.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use anyhow::{Context, Result}; +use anyhow::{bail, Context, Result}; #[cfg(target_os = "macos")] use cocoa::appkit::NSApplication; use glib::ObjectExt; @@ -8,7 +8,10 @@ use gstreamer::{ prelude::{ElementExt, GstBinExt}, GhostPad, }; -use lib_gst_meet::{init_tracing, JitsiConferenceConfig, JitsiConnection}; +use lib_gst_meet::{ + init_tracing, JitsiConferenceConfig, JitsiConnection, + colibri::{ColibriMessage, Constraints, VideoType}, +}; use structopt::StructOpt; use tokio::{signal::ctrl_c, task, time::timeout}; use tracing::{info, trace, warn}; @@ -39,6 +42,14 @@ struct Opt { send_pipeline: Option, #[structopt(long)] recv_pipeline_participant_template: Option, + #[structopt(long)] + select_endpoints: Option, + #[structopt(long)] + last_n: Option, + #[structopt(long)] + recv_video_height: Option, + #[structopt(long)] + video_type: Option, #[structopt(short, long, parse(from_occurrences))] verbose: u8, } @@ -139,6 +150,32 @@ async fn main_inner() -> Result<()> { .join_conference(main_loop.context(), config) .await?; + if opt.select_endpoints.is_some() || opt.last_n.is_some() || opt.recv_video_height.is_some() { + conference + .send_colibri_message(ColibriMessage::ReceiverVideoConstraints { + last_n: opt.last_n, + selected_endpoints: opt.select_endpoints.map(|endpoints| endpoints.split(',').map(ToOwned::to_owned).collect()), + on_stage_endpoints: None, + default_constraints: opt.recv_video_height.map(|height| Constraints { + ideal_height: Some(height), + max_height: None, + }), + constraints: None, + }).await?; + } + + if let Some(video_type) = opt.video_type { + conference + .send_colibri_message(ColibriMessage::VideoTypeMessage { + video_type: match video_type.as_str() { + "camera" => VideoType::Camera, + "desktop" => VideoType::Desktop, + other => bail!(format!("invalid video type: {}", other)), + } + }) + .await?; + } + if let Some(bin) = parsed_bin { conference.add_bin(&bin).await?; diff --git a/lib-gst-meet/Cargo.toml b/lib-gst-meet/Cargo.toml index 2a8e543..bd46715 100644 --- a/lib-gst-meet/Cargo.toml +++ b/lib-gst-meet/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lib-gst-meet" description = "Connect GStreamer pipelines to Jitsi Meet conferences" -version = "0.3.0" +version = "0.3.1" edition = "2018" license = "MIT/Apache-2.0" authors = ["Jasper Hugo "] diff --git a/lib-gst-meet/src/colibri.rs b/lib-gst-meet/src/colibri.rs index 08e1b79..f13ad46 100644 --- a/lib-gst-meet/src/colibri.rs +++ b/lib-gst-meet/src/colibri.rs @@ -59,7 +59,7 @@ pub enum ColibriMessage { selected_endpoints: Option>, on_stage_endpoints: Option>, default_constraints: Option, - constraints: HashMap, + constraints: Option>, }, #[serde(rename_all = "camelCase")] SelectedEndpointsChangedEvent { @@ -75,39 +75,46 @@ pub enum ColibriMessage { }, #[serde(rename_all = "camelCase")] VideoTypeMessage { - video_type: String, + video_type: VideoType, }, } +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub enum VideoType { + Camera, + Desktop, +} + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Constraints { - ideal_height: Option, - max_height: Option, + pub ideal_height: Option, + pub max_height: Option, } #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Bitrates { - audio: Bitrate, - video: Bitrate, + pub audio: Bitrate, + pub video: Bitrate, #[serde(flatten)] - total: Bitrate, + pub total: Bitrate, } #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Bitrate { - upload: u32, - download: u32, + pub upload: u32, + pub download: u32, } #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct PacketLoss { - total: u32, - download: u32, - upload: u32, + pub total: u32, + pub download: u32, + pub upload: u32, } pub(crate) struct ColibriChannel { diff --git a/lib-gst-meet/src/lib.rs b/lib-gst-meet/src/lib.rs index b93c900..75b23ad 100644 --- a/lib-gst-meet/src/lib.rs +++ b/lib-gst-meet/src/lib.rs @@ -1,4 +1,4 @@ -mod colibri; +pub mod colibri; mod conference; mod connection; mod jingle;