Compare commits
No commits in common. "1777b5e39f650baecb99134231f19ad552397099" and "94c69b85ccc58c37142ce22749ec8541791218cf" have entirely different histories.
1777b5e39f
...
94c69b85cc
7 changed files with 70 additions and 140 deletions
83
Cargo.lock
generated
83
Cargo.lock
generated
|
@ -198,6 +198,17 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-recursion"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.77",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-stream"
|
||||
version = "0.3.5"
|
||||
|
@ -604,7 +615,7 @@ dependencies = [
|
|||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"cocoa-foundation",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
|
@ -619,7 +630,7 @@ checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
|
|||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation",
|
||||
"core-graphics-types",
|
||||
"libc",
|
||||
"objc",
|
||||
|
@ -759,16 +770,6 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
|
@ -782,7 +783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation",
|
||||
"core-graphics-types",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
|
@ -795,7 +796,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -1610,9 +1611,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gilrs"
|
||||
version = "0.11.0"
|
||||
version = "0.10.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbb2c998745a3c1ac90f64f4f7b3a54219fd3612d7705e7798212935641ed18f"
|
||||
checksum = "a556964c6d62458084356ce9770676f5104bd667e12e9a795691076e8a17c5cf"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"gilrs-core",
|
||||
|
@ -1623,11 +1624,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gilrs-core"
|
||||
version = "0.6.0"
|
||||
version = "0.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "495af945e45efd6386227613cd9fb7bd7c43d3c095040e30c5304c489e6abed5"
|
||||
checksum = "732dadc05170599ddec9a89653f10d7a2af54da9181b3fa6e2bd49907ec8f7e4"
|
||||
dependencies = [
|
||||
"core-foundation 0.10.0",
|
||||
"core-foundation",
|
||||
"inotify",
|
||||
"io-kit-sys",
|
||||
"js-sys",
|
||||
|
@ -2137,11 +2138,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.11.0"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
|
||||
checksum = "fdd168d97690d0b8c412d6b6c10360277f4d7ee495c5d0d5d5fe0854923255cc"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"bitflags 1.3.2",
|
||||
"inotify-sys",
|
||||
"libc",
|
||||
]
|
||||
|
@ -4099,7 +4100,7 @@ dependencies = [
|
|||
"cairo-rs",
|
||||
"cc",
|
||||
"cocoa",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"crossbeam-channel",
|
||||
"dispatch",
|
||||
|
@ -4517,6 +4518,18 @@ dependencies = [
|
|||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"tokio",
|
||||
"tungstenite 0.21.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.23.1"
|
||||
|
@ -4529,18 +4542,6 @@ dependencies = [
|
|||
"tungstenite 0.23.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"tokio",
|
||||
"tungstenite 0.24.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.12"
|
||||
|
@ -4762,9 +4763,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
|||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.23.0"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8"
|
||||
checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"bytes",
|
||||
|
@ -4775,14 +4776,15 @@ dependencies = [
|
|||
"rand 0.8.5",
|
||||
"sha1",
|
||||
"thiserror",
|
||||
"url",
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.24.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a"
|
||||
checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"bytes",
|
||||
|
@ -4932,6 +4934,7 @@ name = "vcs-controller"
|
|||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-recursion",
|
||||
"bincode",
|
||||
"config",
|
||||
"console-subscriber",
|
||||
|
@ -4947,7 +4950,7 @@ dependencies = [
|
|||
"tauri",
|
||||
"tauri-build",
|
||||
"tokio",
|
||||
"tokio-tungstenite 0.24.0",
|
||||
"tokio-tungstenite 0.21.0",
|
||||
"toml 0.8.19",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
|
|
23
Cargo.toml
23
Cargo.toml
|
@ -17,27 +17,28 @@ tokio-logging = []
|
|||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
[dependencies]
|
||||
async-channel = "2.3.1"
|
||||
bincode = "1.3.3"
|
||||
async-channel = "2.2.0"
|
||||
async-recursion = "1.1.1"
|
||||
config = "0.14.0"
|
||||
futures = "0.3.30"
|
||||
futures-core = "0.3.30"
|
||||
futures-util = { version = "0.3.30" }
|
||||
gilrs = "0.11.0"
|
||||
log = "0.4.22"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
gilrs = "0.10.6"
|
||||
log = "0.4.21"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tokio = { version = "1.40", features = ["rt-multi-thread", "time", "sync"] }
|
||||
tokio-tungstenite = "0.24.0"
|
||||
toml = "0.8.19"
|
||||
tokio = { version = "1.37.0", features = ["rt-multi-thread", "time", "sync"] }
|
||||
tokio-tungstenite = "0.21.0"
|
||||
toml = "0.8.12"
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["tracing-log"] }
|
||||
tracing-appender = "0.2.3"
|
||||
snafu = "0.8.4"
|
||||
snafu = "0.8.2"
|
||||
console-subscriber = "0.3.0"
|
||||
tauri = { version = "1.8", features = [] }
|
||||
tauri = { version = "1.6.1", features = [] }
|
||||
lazy_static = "1.5.0"
|
||||
|
||||
vcs-common = { git = "https://git.nickiel.net/VCC/vcs-common.git", branch = "main" }
|
||||
bincode = "1.3.3"
|
||||
futures = "0.3.30"
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ use joystick_source::joystick_loop;
|
|||
use satellite_connection::SatelliteConnection;
|
||||
|
||||
pub enum ApplicationEvent {
|
||||
SupportsWebRTC(bool),
|
||||
WebRTCMessage((String, vcs_common::ApplicationMessage)),
|
||||
JoystickMove(Point),
|
||||
RetryDisconnectedSatellites,
|
||||
|
@ -41,7 +40,6 @@ pub struct AppState {
|
|||
to_mec: Sender<ApplicationEvent>,
|
||||
mec: Receiver<ApplicationEvent>,
|
||||
pub runtime: Handle,
|
||||
pub has_webrtc_support: Option<bool>,
|
||||
|
||||
_config: Arc<tokio::sync::RwLock<AppConfig>>,
|
||||
|
||||
|
@ -72,7 +70,6 @@ impl AppState {
|
|||
to_mec,
|
||||
mec,
|
||||
runtime: rt,
|
||||
has_webrtc_support: None,
|
||||
|
||||
_config: config,
|
||||
|
||||
|
@ -122,28 +119,18 @@ pub async fn run_main_event_loop(
|
|||
Err(TryRecvError::Closed) => break,
|
||||
Ok(msg) => {
|
||||
match msg {
|
||||
ApplicationEvent::SupportsWebRTC(has_support) => {
|
||||
state.has_webrtc_support = Some(has_support);
|
||||
state
|
||||
.camera_satellites
|
||||
.iter_mut()
|
||||
.filter(|x| x.is_connected())
|
||||
.for_each(|x| {
|
||||
x.send_blocking(
|
||||
ApplicationMessage::ConnectionSupportsWebRTC(has_support),
|
||||
state.runtime.clone(),
|
||||
);
|
||||
});
|
||||
}
|
||||
ApplicationEvent::Close => {
|
||||
state.mec.close(); // cleanup is handled on reading from a closed mec
|
||||
}
|
||||
ApplicationEvent::RetryDisconnectedSatellites => {
|
||||
state.camera_satellites.iter_mut().for_each(|x| {
|
||||
info!("Resetting connections");
|
||||
x.try_connecting = true;
|
||||
x.retry_attempts = 0;
|
||||
});
|
||||
state
|
||||
.camera_satellites
|
||||
.iter_mut()
|
||||
.for_each(|x| {
|
||||
info!("Resetting connections");
|
||||
x.try_connecting = true;
|
||||
x.retry_attempts = 0;
|
||||
});
|
||||
}
|
||||
ApplicationEvent::WebRTCMessage((name, msg)) => {
|
||||
info!(
|
||||
|
@ -215,22 +202,14 @@ pub async fn run_main_event_loop(
|
|||
ApplicationMessage::ConnectionSupportsWebRTCRequest => {
|
||||
let does_support_webrtc = true;
|
||||
if let Err(e) = connection
|
||||
.send(ApplicationMessage::ConnectionSupportsWebRTC(
|
||||
does_support_webrtc,
|
||||
))
|
||||
.send(ApplicationMessage::ConnectionSupportsWebRTC(does_support_webrtc))
|
||||
.await
|
||||
{
|
||||
info!(
|
||||
"Was not able to send webrtc support status to remote: {:?}",
|
||||
e
|
||||
);
|
||||
info!("Was not able to send webrtc support status to remote: {:?}", e);
|
||||
}
|
||||
}
|
||||
ApplicationMessage::ConnectionSupportsWebRTC(does_support) => {
|
||||
info!(
|
||||
"Cool, the camera satellite supports webrtc: {}",
|
||||
does_support
|
||||
);
|
||||
info!("Cool, the camera satellite supports webrtc: {}", does_support);
|
||||
}
|
||||
ApplicationMessage::WebRTCIceCandidateInit(pkt) => {
|
||||
send_frontend_message(serde_json::to_string(&pkt).unwrap())
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::{atomic::AtomicBool, Arc};
|
|||
|
||||
use async_channel::TryRecvError;
|
||||
use tokio::runtime::Handle;
|
||||
use tracing::{error, info, instrument, warn};
|
||||
use tracing::{error, instrument, warn, info};
|
||||
|
||||
use crate::config::ConnectionString;
|
||||
|
||||
|
@ -47,13 +47,7 @@ impl SatelliteConnection {
|
|||
#[instrument(skip(self))]
|
||||
pub async fn close(&mut self) {
|
||||
if self.to_socket.is_some() {
|
||||
if let Err(_) = self
|
||||
.to_socket
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.send(ApplicationMessage::CloseConnection)
|
||||
.await
|
||||
{
|
||||
if let Err(_) = self.to_socket.as_ref().unwrap().send(ApplicationMessage::CloseConnection).await {
|
||||
info!("Could not send close connection to active satellite");
|
||||
}
|
||||
}
|
||||
|
@ -112,20 +106,6 @@ impl SatelliteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/// This is not the recommneded method, as it ignores error, but sometimes
|
||||
/// you just really don't want to be async
|
||||
#[instrument(skip(self))]
|
||||
pub fn send_blocking(&mut self, msg: ApplicationMessage, rt: tokio::runtime::Handle) {
|
||||
if self.to_socket.is_some() {
|
||||
let sender = self.to_socket.as_ref().unwrap().clone();
|
||||
rt.spawn(async move {
|
||||
if let Err(e) = sender.send(msg).await {
|
||||
error!("Unhandled send error while in send_blocking! {e}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub async fn send(&mut self, msg: ApplicationMessage) -> Result<(), SatelliteConnectionError> {
|
||||
if self.to_socket.is_some() {
|
||||
|
|
|
@ -74,10 +74,7 @@ fn main() {
|
|||
to_mec: to_mec.clone(),
|
||||
rt: handle2.clone(),
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
tauri_functions::connect_to_camera,
|
||||
tauri_functions::supports_webrtc
|
||||
])
|
||||
.invoke_handler(tauri::generate_handler![tauri_functions::connect_to_camera])
|
||||
.setup(|app| {
|
||||
*APP_HANDLE.lock().unwrap() = Some(app.handle());
|
||||
|
||||
|
|
|
@ -17,11 +17,3 @@ pub fn connect_to_camera(state: State<'_, TauriState>) {
|
|||
let _ = mec.send_blocking(ApplicationEvent::RetryDisconnectedSatellites);
|
||||
});
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all="snake_case")]
|
||||
pub fn supports_webrtc(has_support: bool, state: State<'_, TauriState>) {
|
||||
let mec = state.to_mec.clone();
|
||||
state.rt.spawn(async move {
|
||||
let _ = mec.send_blocking(ApplicationEvent::SupportsWebRTC(has_support));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,29 +16,7 @@ function call_camera_connect() {
|
|||
async function init() {
|
||||
console.log("Setting up");
|
||||
document.getElementById("camera_connect_button").addEventListener("click", call_camera_connect);
|
||||
|
||||
let webrtc_support = supports_webrtc();
|
||||
|
||||
invoke("supports_webrtc", { has_support: webrtc_support });
|
||||
if (webrtc_support) {
|
||||
await rtc_init();
|
||||
}
|
||||
}
|
||||
|
||||
function supports_webrtc() {
|
||||
var isWebRTCSupported = false;
|
||||
|
||||
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
|
||||
if (isWebRTCSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item in window) {
|
||||
isWebRTCSupported = true;
|
||||
}
|
||||
});
|
||||
|
||||
return isWebRTCSupported;
|
||||
await rtc_init();
|
||||
}
|
||||
|
||||
export { init };
|
||||
|
|
Loading…
Reference in a new issue