use new colibri crate & vendored xmpp-parsers

This commit is contained in:
Jasper Hugo 2021-10-06 12:06:27 +07:00
parent a6089293a6
commit 2b2ceca515
9 changed files with 57 additions and 128 deletions

52
Cargo.lock generated
View File

@ -184,6 +184,17 @@ dependencies = [
"objc",
]
[[package]]
name = "colibri"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e90829b3ef30aafd6f707b32665623656cae1c3fd5dfdf090f41bb8855f336d5"
dependencies = [
"serde",
"serde_json",
"serde_with",
]
[[package]]
name = "core-foundation"
version = "0.9.1"
@ -512,6 +523,7 @@ version = "0.2.2"
dependencies = [
"anyhow",
"cocoa",
"colibri",
"futures",
"glib",
"gstreamer",
@ -694,6 +706,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e0935b518d535e6de070bdcfc9ab8970cefc57b94ef13b26baf6967cf65a73"
dependencies = [
"minidom-gst-meet",
"serde",
]
[[package]]
@ -719,12 +732,13 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lib-gst-meet"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"anyhow",
"async-stream",
"async-trait",
"bytes",
"colibri",
"futures",
"glib",
"gstreamer",
@ -885,9 +899,9 @@ dependencies = [
[[package]]
name = "nix"
version = "0.22.1"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7555d6c7164cc913be1ce7f95cbecdabda61eb2ccd89008524af306fb7f5031"
checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba"
dependencies = [
"bitflags",
"cc",
@ -1118,9 +1132,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [
"proc-macro2",
]
@ -1389,9 +1403,9 @@ checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590"
[[package]]
name = "smallvec"
version = "1.6.1"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]]
name = "spin"
@ -1455,9 +1469,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "syn"
version = "1.0.77"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0"
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"
dependencies = [
"proc-macro2",
"quote",
@ -1570,9 +1584,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "1.3.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110"
checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb"
dependencies = [
"proc-macro2",
"quote",
@ -1629,9 +1643,9 @@ dependencies = [
[[package]]
name = "tracing"
version = "0.1.28"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
@ -1641,9 +1655,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.16"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
@ -1652,9 +1666,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.20"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
@ -1672,9 +1686,9 @@ dependencies = [
[[package]]
name = "tracing-subscriber"
version = "0.2.24"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdd0568dbfe3baf7048b7908d2b32bca0d81cd56bec6d2a8f894b01d74f86be3"
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
dependencies = [
"chrono",
"parking_lot",

View File

@ -8,10 +8,11 @@ authors = ["Jasper Hugo <jasper@avstack.io>"]
[dependencies]
anyhow = { version = "1", default-features = false, features = ["std"] }
colibri = { version = "0.1", default-features = false }
futures = { version = "0.3", default-features = false }
glib = { version = "0.14", default-features = false, features = ["log"] }
gstreamer = { version = "0.17", default-features = false, features = ["v1_16"] }
lib-gst-meet = { version = "0.3", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] }
lib-gst-meet = { version = "0.4", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] }
structopt = { version = "0.3", default-features = false }
tokio = { version = "1", default-features = false, features = ["macros", "rt-multi-thread", "signal", "sync", "time"] }
tokio-stream = { version = "0.1", default-features = false }

View File

@ -3,13 +3,13 @@ use std::time::Duration;
use anyhow::{bail, Context, Result};
#[cfg(target_os = "macos")]
use cocoa::appkit::NSApplication;
use colibri::{ColibriMessage, Constraints, VideoType};
use glib::ObjectExt;
use gstreamer::{
prelude::{ElementExt, GstBinExt},
GhostPad,
};
use lib_gst_meet::{
colibri::{ColibriMessage, Constraints, VideoType},
Authentication, init_tracing, JitsiConference, JitsiConferenceConfig, Connection,
};
use structopt::StructOpt;

View File

@ -10,7 +10,7 @@ authors = ["Jasper Hugo <jasper@avstack.io>"]
anyhow = { version = "1", default-features = false }
glib = { version = "0.14", default-features = false }
gstreamer = { version = "0.17", default-features = false }
lib-gst-meet = { version = "0.3", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] }
lib-gst-meet = { version = "0.4", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] }
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
tracing = { version = "0.1", default-features = false }

View File

@ -14,7 +14,7 @@ use glib::{
translate::{from_glib, from_glib_full, ToGlibPtr},
};
use lib_gst_meet::JitsiConferenceConfig;
pub use lib_gst_meet::{init_tracing, JitsiConference, JitsiConnection, MediaType};
pub use lib_gst_meet::{init_tracing, Authentication, Connection, JitsiConference, MediaType};
use tokio::runtime::Runtime;
pub struct Context {
@ -80,14 +80,15 @@ pub unsafe extern "C" fn gstmeet_connection_new(
context: *mut Context,
websocket_url: *const c_char,
xmpp_domain: *const c_char,
) -> *mut JitsiConnection {
) -> *mut Connection {
let websocket_url = CStr::from_ptr(websocket_url);
let xmpp_domain = CStr::from_ptr(xmpp_domain);
(*context)
.runtime
.block_on(JitsiConnection::new(
.block_on(Connection::new(
&websocket_url.to_string_lossy(),
&xmpp_domain.to_string_lossy(),
Authentication::Anonymous,
))
.map(|(connection, background)| {
(*context).runtime.spawn(background);
@ -97,14 +98,14 @@ pub unsafe extern "C" fn gstmeet_connection_new(
}
#[no_mangle]
pub unsafe extern "C" fn gstmeet_connection_free(connection: *mut JitsiConnection) {
pub unsafe extern "C" fn gstmeet_connection_free(connection: *mut Connection) {
Box::from_raw(connection);
}
#[no_mangle]
pub unsafe extern "C" fn gstmeet_connection_connect(
context: *mut Context,
connection: *mut JitsiConnection,
connection: *mut Connection,
) -> bool {
(*context)
.runtime
@ -116,7 +117,7 @@ pub unsafe extern "C" fn gstmeet_connection_connect(
#[no_mangle]
pub unsafe extern "C" fn gstmeet_connection_join_conference(
context: *mut Context,
connection: *mut JitsiConnection,
connection: *mut Connection,
glib_main_context: *mut GMainContext,
config: *const ConferenceConfig,
) -> *mut JitsiConference {
@ -144,10 +145,11 @@ pub unsafe extern "C" fn gstmeet_connection_join_conference(
video_codec: CStr::from_ptr((*config).video_codec)
.to_string_lossy()
.to_string(),
extra_muc_features: vec![],
};
(*context)
.runtime
.block_on((*connection).join_conference(from_glib_full(glib_main_context), config))
.block_on(JitsiConference::join((*connection).clone(), from_glib_full(glib_main_context), config))
.ok_raw_or_log()
}
@ -233,7 +235,11 @@ pub unsafe extern "C" fn gstmeet_conference_on_participant(
let ctx = ctx.clone();
Box::pin(async move {
let participant = Participant {
jid: CString::new(participant.jid.to_string())?.into_raw() as *const _,
jid: participant
.jid
.map(|jid| Ok::<_, anyhow::Error>(CString::new(jid.to_string())?.into_raw() as *const _))
.transpose()?
.unwrap_or_else(ptr::null),
muc_jid: CString::new(participant.muc_jid.to_string())?.into_raw() as *const _,
nick: participant
.nick

View File

@ -1,7 +1,7 @@
[package]
name = "lib-gst-meet"
description = "Connect GStreamer pipelines to Jitsi Meet conferences"
version = "0.3.1"
version = "0.4.0"
edition = "2018"
license = "MIT/Apache-2.0"
authors = ["Jasper Hugo <jasper@avstack.io>"]
@ -11,6 +11,7 @@ anyhow = { version = "1", default-features = false, features = ["std"] }
async-stream = { version = "0.3", default-features = false }
async-trait = { version = "0.1", default-features = false }
bytes = { version = "1", default-features = false, features = ["std"] }
colibri = { version = "0.1", default-features = false }
futures = { version = "0.3", default-features = false }
glib = { version = "0.14", default-features = false }
gstreamer = { version = "0.17", default-features = false, features = ["v1_20"] }
@ -40,7 +41,7 @@ tracing-subscriber = { version = "0.2", optional = true, default-features = fals
"tracing-log",
] }
uuid = { version = "0.8", default-features = false, features = ["v4"] }
xmpp-parsers = { path = "../../xmpp-rs/xmpp-parsers", package = "xmpp-parsers-gst-meet", version = "0.18", default-features = false }
xmpp-parsers = { path = "../xmpp-parsers", package = "xmpp-parsers-gst-meet", version = "0.18", default-features = false }
[features]
default = []

View File

@ -1,6 +1,7 @@
use std::{collections::HashMap, sync::Arc};
use anyhow::Result;
use colibri::ColibriMessage;
use futures::{
sink::SinkExt,
stream::{StreamExt, TryStreamExt},
@ -12,100 +13,6 @@ use tokio_stream::wrappers::ReceiverStream;
use tokio_tungstenite::tungstenite::{http::Request, Message};
use tracing::{debug, error, info, warn};
#[serde_as]
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "colibriClass")]
pub enum ColibriMessage {
#[serde(rename_all = "camelCase")]
DominantSpeakerEndpointChangeEvent {
dominant_speaker_endpoint: String,
previous_speakers: Vec<String>,
},
#[serde(rename_all = "camelCase")]
EndpointConnectivityStatusChangeEvent {
endpoint: String,
#[serde_as(as = "DisplayFromStr")]
active: bool,
},
#[serde(rename_all = "camelCase")]
EndpointMessage {
from: String,
to: Option<String>,
msg_payload: serde_json::Value,
},
#[serde(rename_all = "camelCase")]
EndpointStats {
from: String,
bitrate: Bitrates,
packet_loss: PacketLoss,
connection_quality: f32,
#[serde(rename = "jvbRTT")]
jvb_rtt: Option<u16>,
server_region: String,
max_enabled_resolution: u16,
},
#[serde(rename_all = "camelCase")]
LastNChangedEvent { last_n: u16 },
#[serde(rename_all = "camelCase")]
LastNEndpointsChangeEvent { last_n_endpoints: Vec<String> },
#[serde(rename_all = "camelCase")]
ReceiverVideoConstraint { max_frame_height: u16 },
#[serde(rename_all = "camelCase")]
ReceiverVideoConstraints {
last_n: Option<u16>,
selected_endpoints: Option<Vec<String>>,
on_stage_endpoints: Option<Vec<String>>,
default_constraints: Option<Constraints>,
constraints: Option<HashMap<String, Constraints>>,
},
#[serde(rename_all = "camelCase")]
SelectedEndpointsChangedEvent { selected_endpoints: Vec<String> },
#[serde(rename_all = "camelCase")]
SenderVideoConstraints { video_constraints: Constraints },
#[serde(rename_all = "camelCase")]
ServerHello { version: Option<String> },
#[serde(rename_all = "camelCase")]
VideoTypeMessage { 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 {
pub ideal_height: Option<u16>,
pub max_height: Option<u16>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Bitrates {
pub audio: Bitrate,
pub video: Bitrate,
#[serde(flatten)]
pub total: Bitrate,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Bitrate {
pub upload: u32,
pub download: u32,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PacketLoss {
pub total: u32,
pub download: u32,
pub upload: u32,
}
pub(crate) struct ColibriChannel {
send_tx: mpsc::Sender<ColibriMessage>,
recv_tx: Arc<Mutex<Vec<mpsc::Sender<ColibriMessage>>>>,

View File

@ -2,6 +2,7 @@ use std::{collections::HashMap, convert::TryFrom, fmt, future::Future, pin::Pin,
use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait;
use colibri::ColibriMessage;
use futures::stream::StreamExt;
use gstreamer::prelude::{ElementExt, ElementExtManual, GstBinExt};
use maplit::hashmap;
@ -27,7 +28,7 @@ use xmpp_parsers::{
};
use crate::{
colibri::{ColibriChannel, ColibriMessage},
colibri::ColibriChannel,
jingle::JingleSession,
source::MediaType,
stanza_filter::StanzaFilter,

View File

@ -8,7 +8,6 @@ mod util;
mod xmpp;
pub use crate::{
colibri::ColibriMessage,
conference::{Feature, JitsiConference, JitsiConferenceConfig, Participant},
source::MediaType,
stanza_filter::StanzaFilter,