better error reporting on connect failure
This commit is contained in:
parent
f414c9db66
commit
9999cd212c
|
@ -9,12 +9,12 @@ use gstreamer::{
|
||||||
GhostPad,
|
GhostPad,
|
||||||
};
|
};
|
||||||
use lib_gst_meet::{
|
use lib_gst_meet::{
|
||||||
init_tracing, JitsiConferenceConfig, JitsiConnection,
|
|
||||||
colibri::{ColibriMessage, Constraints, VideoType},
|
colibri::{ColibriMessage, Constraints, VideoType},
|
||||||
|
init_tracing, JitsiConferenceConfig, JitsiConnection,
|
||||||
};
|
};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use tokio::{signal::ctrl_c, task, time::timeout};
|
use tokio::{signal::ctrl_c, task, time::timeout};
|
||||||
use tracing::{info, trace, warn};
|
use tracing::{error, info, trace, warn};
|
||||||
|
|
||||||
#[derive(Debug, Clone, StructOpt)]
|
#[derive(Debug, Clone, StructOpt)]
|
||||||
#[structopt(
|
#[structopt(
|
||||||
|
@ -71,7 +71,9 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
rt.spawn(async move {
|
rt.spawn(async move {
|
||||||
main_inner().await.unwrap();
|
if let Err(e) = main_inner().await {
|
||||||
|
error!("fatal: {:?}", e);
|
||||||
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
cocoa::appkit::NSApp().stop_(cocoa::base::nil);
|
cocoa::appkit::NSApp().stop_(cocoa::base::nil);
|
||||||
}
|
}
|
||||||
|
@ -83,10 +85,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_gstreamer() {
|
fn init_gstreamer() -> Result<()> {
|
||||||
trace!("starting gstreamer init");
|
trace!("starting gstreamer init");
|
||||||
gstreamer::init().expect("gstreamer init failed");
|
gstreamer::init()?;
|
||||||
trace!("finished gstreamer init");
|
trace!("finished gstreamer init");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn main_inner() -> Result<()> {
|
async fn main_inner() -> Result<()> {
|
||||||
|
@ -98,8 +101,8 @@ async fn main_inner() -> Result<()> {
|
||||||
_ => tracing::Level::TRACE,
|
_ => tracing::Level::TRACE,
|
||||||
});
|
});
|
||||||
glib::log_set_default_handler(glib::rust_log_handler);
|
glib::log_set_default_handler(glib::rust_log_handler);
|
||||||
|
|
||||||
init_gstreamer();
|
init_gstreamer()?;
|
||||||
|
|
||||||
// Parse pipeline early so that we don't bother connecting to the conference if it's invalid.
|
// Parse pipeline early so that we don't bother connecting to the conference if it's invalid.
|
||||||
|
|
||||||
|
@ -107,10 +110,12 @@ async fn main_inner() -> Result<()> {
|
||||||
.send_pipeline
|
.send_pipeline
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|pipeline| gstreamer::parse_bin_from_description(pipeline, false))
|
.map(|pipeline| gstreamer::parse_bin_from_description(pipeline, false))
|
||||||
.transpose()?;
|
.transpose()
|
||||||
|
.context("failed to parse send pipeline")?;
|
||||||
|
|
||||||
let (connection, background) =
|
let (connection, background) = JitsiConnection::new(&opt.web_socket_url, &opt.xmpp_domain)
|
||||||
JitsiConnection::new(&opt.web_socket_url, &opt.xmpp_domain).await?;
|
.await
|
||||||
|
.context("failed to connect")?;
|
||||||
|
|
||||||
tokio::spawn(background);
|
tokio::spawn(background);
|
||||||
|
|
||||||
|
@ -150,20 +155,24 @@ async fn main_inner() -> Result<()> {
|
||||||
|
|
||||||
let conference = connection
|
let conference = connection
|
||||||
.join_conference(main_loop.context(), config)
|
.join_conference(main_loop.context(), config)
|
||||||
.await?;
|
.await
|
||||||
|
.context("failed to join conference")?;
|
||||||
|
|
||||||
if opt.select_endpoints.is_some() || opt.last_n.is_some() || opt.recv_video_height.is_some() {
|
if opt.select_endpoints.is_some() || opt.last_n.is_some() || opt.recv_video_height.is_some() {
|
||||||
conference
|
conference
|
||||||
.send_colibri_message(ColibriMessage::ReceiverVideoConstraints {
|
.send_colibri_message(ColibriMessage::ReceiverVideoConstraints {
|
||||||
last_n: opt.last_n,
|
last_n: opt.last_n,
|
||||||
selected_endpoints: opt.select_endpoints.map(|endpoints| endpoints.split(',').map(ToOwned::to_owned).collect()),
|
selected_endpoints: opt
|
||||||
|
.select_endpoints
|
||||||
|
.map(|endpoints| endpoints.split(',').map(ToOwned::to_owned).collect()),
|
||||||
on_stage_endpoints: None,
|
on_stage_endpoints: None,
|
||||||
default_constraints: opt.recv_video_height.map(|height| Constraints {
|
default_constraints: opt.recv_video_height.map(|height| Constraints {
|
||||||
ideal_height: Some(height),
|
ideal_height: Some(height),
|
||||||
max_height: None,
|
max_height: None,
|
||||||
}),
|
}),
|
||||||
constraints: None,
|
constraints: None,
|
||||||
}).await?;
|
})
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(video_type) = opt.video_type {
|
if let Some(video_type) = opt.video_type {
|
||||||
|
@ -173,7 +182,7 @@ async fn main_inner() -> Result<()> {
|
||||||
"camera" => VideoType::Camera,
|
"camera" => VideoType::Camera,
|
||||||
"desktop" => VideoType::Desktop,
|
"desktop" => VideoType::Desktop,
|
||||||
other => bail!(format!("invalid video type: {}", other)),
|
other => bail!(format!("invalid video type: {}", other)),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
@ -233,18 +242,21 @@ async fn main_inner() -> Result<()> {
|
||||||
info!("No video sink element found in recv pipeline participant template");
|
info!("No video sink element found in recv pipeline participant template");
|
||||||
}
|
}
|
||||||
|
|
||||||
bin.set_property("name", format!("participant_{}", participant.muc_jid.resource))?;
|
bin.set_property(
|
||||||
|
"name",
|
||||||
|
format!("participant_{}", participant.muc_jid.resource),
|
||||||
|
)?;
|
||||||
conference.add_bin(&bin).await?;
|
conference.add_bin(&bin).await?;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
info!("No template for handling new participant");
|
info!("No template for handling new participant");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
conference
|
conference
|
||||||
.on_participant_left(move |_conference, participant| {
|
.on_participant_left(move |_conference, participant| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
|
@ -286,4 +298,4 @@ async fn main_inner() -> Result<()> {
|
||||||
task::spawn_blocking(move || main_loop.run()).await?;
|
task::spawn_blocking(move || main_loop.run()).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,14 +74,17 @@ impl JitsiConnection {
|
||||||
websocket_url: &str,
|
websocket_url: &str,
|
||||||
xmpp_domain: &str,
|
xmpp_domain: &str,
|
||||||
) -> Result<(Self, impl Future<Output = ()>)> {
|
) -> Result<(Self, impl Future<Output = ()>)> {
|
||||||
let websocket_url: Uri = websocket_url.parse()?;
|
let websocket_url: Uri = websocket_url.parse().context("invalid WebSocket URL")?;
|
||||||
let xmpp_domain: BareJid = xmpp_domain.parse()?;
|
let xmpp_domain: BareJid = xmpp_domain.parse().context("invalid XMPP domain")?;
|
||||||
|
|
||||||
info!("Connecting XMPP WebSocket to {}", websocket_url);
|
info!("Connecting XMPP WebSocket to {}", websocket_url);
|
||||||
let request = Request::get(websocket_url)
|
let request = Request::get(websocket_url)
|
||||||
.header("Sec-Websocket-Protocol", "xmpp")
|
.header("Sec-Websocket-Protocol", "xmpp")
|
||||||
.body(())?;
|
.body(())
|
||||||
let (websocket, _response) = tokio_tungstenite::connect_async(request).await?;
|
.context("failed to build WebSocket request")?;
|
||||||
|
let (websocket, _response) = tokio_tungstenite::connect_async(request)
|
||||||
|
.await
|
||||||
|
.context("failed to connect XMPP WebSocket")?;
|
||||||
let (sink, stream) = websocket.split();
|
let (sink, stream) = websocket.split();
|
||||||
let (tx, rx) = mpsc::channel(64);
|
let (tx, rx) = mpsc::channel(64);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue