Initial commit: RustDesk 1.4.7 macOS desktop port
- Filled empty libs/hbb_common/ submodule (cloned from rustdesk/hbb_common) - Patched Flutter 3.44 / Dart 3.12 compatibility: * flutter/lib/generated_bridge.dart: asTypedList with cast<>, DartPort=Int64 * flutter/lib/common.dart: DialogTheme->DialogThemeData, TabBarTheme->TabBarThemeData * flutter/pubspec.yaml: extended_text 14.0.0->15.0.2, google_fonts override 5.0.0 * flutter/macos/Runner/Configs/Release.xcconfig: EXCLUDED_ARCHS=x86_64 - Build verified: cargo check + cargo build --features flutter + cargo build --release --features flutter - Verified flutter build macos --debug and --release both produce working .app - Verified .dmg installer (27MB arm64) created via hdiutil - Build deps: Xcode 26.5, CocoaPods 1.16.2, Flutter 3.44, VCPKG arm64-osx
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
extern crate hbb_common;
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", hbb_common::config::PeerConfig::load("455058072"));
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
extern crate hbb_common;
|
||||
#[cfg(target_os = "linux")]
|
||||
use hbb_common::platform::linux;
|
||||
#[cfg(target_os = "macos")]
|
||||
use hbb_common::platform::macos;
|
||||
|
||||
fn main() {
|
||||
#[cfg(target_os = "linux")]
|
||||
let res = linux::system_message("test title", "test message", true);
|
||||
#[cfg(target_os = "macos")]
|
||||
let res = macos::alert(
|
||||
"System Preferences".to_owned(),
|
||||
"warning".to_owned(),
|
||||
"test title".to_owned(),
|
||||
"test message".to_owned(),
|
||||
["Ok".to_owned()].to_vec(),
|
||||
);
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
println!("result {:?}", &res);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
extern crate hbb_common;
|
||||
|
||||
#[cfg(feature = "webrtc")]
|
||||
use hbb_common::webrtc::WebRTCStream;
|
||||
|
||||
use std::io::Write;
|
||||
use anyhow::Result;
|
||||
use bytes::Bytes;
|
||||
use clap::{Arg, Command};
|
||||
use tokio::time::Duration;
|
||||
|
||||
#[cfg(not(feature = "webrtc"))]
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
println!(
|
||||
"The webrtc feature is not enabled. \
|
||||
Please enable the webrtc feature to run this example."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "webrtc")]
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let app = Command::new("webrtc-stream")
|
||||
.about("An example of webrtc stream using hbb_common and webrtc-rs")
|
||||
.arg(
|
||||
Arg::new("debug")
|
||||
.long("debug")
|
||||
.short('d')
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("Prints debug log information"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("offer")
|
||||
.long("offer")
|
||||
.short('o')
|
||||
.help("set offer from other endpoint"),
|
||||
);
|
||||
|
||||
let matches = app.clone().get_matches();
|
||||
|
||||
let debug = matches.contains_id("debug");
|
||||
if debug {
|
||||
println!("Debug log enabled");
|
||||
env_logger::Builder::new()
|
||||
.format(|buf, record| {
|
||||
writeln!(
|
||||
buf,
|
||||
"{}:{} [{}] {} - {}",
|
||||
record.file().unwrap_or("unknown"),
|
||||
record.line().unwrap_or(0),
|
||||
record.level(),
|
||||
chrono::Local::now().format("%H:%M:%S.%6f"),
|
||||
record.args()
|
||||
)
|
||||
})
|
||||
.filter(Some("hbb_common"), log::LevelFilter::Debug)
|
||||
.init();
|
||||
}
|
||||
|
||||
let remote_endpoint = if let Some(endpoint) = matches.get_one::<String>("offer") {
|
||||
endpoint.to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let webrtc_stream = WebRTCStream::new(&remote_endpoint, false, 30000).await?;
|
||||
// Print the offer to be sent to the other peer
|
||||
let local_endpoint = webrtc_stream.get_local_endpoint().await?;
|
||||
|
||||
if remote_endpoint.is_empty() {
|
||||
println!();
|
||||
// Wait for the answer to be pasted
|
||||
println!(
|
||||
"Start new terminal run: \n{} \ncopy remote endpoint and paste here",
|
||||
format!(
|
||||
"cargo r --features webrtc --example webrtc -- --offer {}",
|
||||
local_endpoint
|
||||
)
|
||||
);
|
||||
// readline blocking
|
||||
let line = std::io::stdin()
|
||||
.lines()
|
||||
.next()
|
||||
.ok_or_else(|| anyhow::anyhow!("No input received"))??;
|
||||
webrtc_stream.set_remote_endpoint(&line).await?;
|
||||
} else {
|
||||
println!(
|
||||
"Copy local endpoint and paste to the other peer: \n{}",
|
||||
local_endpoint
|
||||
);
|
||||
}
|
||||
|
||||
let s1 = webrtc_stream.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = read_loop(s1).await;
|
||||
});
|
||||
|
||||
let s2 = webrtc_stream.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = write_loop(s2).await;
|
||||
});
|
||||
|
||||
println!("Press ctrl-c to stop");
|
||||
tokio::select! {
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
println!();
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// read_loop shows how to read from the datachannel directly
|
||||
#[cfg(feature = "webrtc")]
|
||||
async fn read_loop(mut stream: WebRTCStream) -> Result<()> {
|
||||
loop {
|
||||
let Some(res) = stream.next().await else {
|
||||
println!("WebRTC stream closed; Exit the read_loop");
|
||||
return Ok(());
|
||||
};
|
||||
match res {
|
||||
Err(e) => {
|
||||
println!("WebRTC stream read error: {}; Exit the read_loop", e);
|
||||
return Ok(());
|
||||
}
|
||||
Ok(data) => {
|
||||
println!("Message from stream: {}", String::from_utf8(data.to_vec())?);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write_loop shows how to write to the webrtc stream directly
|
||||
#[cfg(feature = "webrtc")]
|
||||
async fn write_loop(mut stream: WebRTCStream) -> Result<()> {
|
||||
let mut result = Result::<()>::Ok(());
|
||||
while result.is_ok() {
|
||||
let timeout = tokio::time::sleep(Duration::from_secs(5));
|
||||
tokio::pin!(timeout);
|
||||
|
||||
tokio::select! {
|
||||
_ = timeout.as_mut() =>{
|
||||
let message = webrtc::peer_connection::math_rand_alpha(15);
|
||||
result = stream.send_bytes(Bytes::from(message.clone())).await;
|
||||
println!("Sent '{message}' {}", result.is_ok());
|
||||
}
|
||||
};
|
||||
}
|
||||
println!("WebRTC stream write failed; Exit the write_loop");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user