Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add WebRTC features to Linux #277

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mundy = { version = "0.1.2", features = ["accent-color", "callback"] }
tauri-plugin-notification = "2.0"

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
webkit2gtk = { version = "2.0", features = ["v2_4"] }
webkit2gtk = "*"
wgpu = { version = "23.0", default-features = false }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
36 changes: 35 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use crate::{
util::logger,
};

use webkit2gtk::{SettingsExt, WebViewExt};

mod config;
mod functionality;
mod gpu;
Expand All @@ -50,6 +52,28 @@ fn should_disable_plugins() -> bool {
std::env::args().any(|arg| arg == "--disable-plugins")
}

fn enable_web_features(settings: &webkit2gtk::Settings) {
settings.set_enable_webrtc(true);
settings.set_enable_media(true);
settings.set_enable_mediasource(true);
settings.set_enable_media_capabilities(true);
settings.set_enable_encrypted_media(true);
settings.set_enable_media_stream(true);
settings.set_media_playback_requires_user_gesture(false);
settings.set_media_playback_allows_inline(true);
settings.set_media_content_types_requiring_hardware_support(None);
}

#[cfg(target_os = "linux")]
fn allow_all_permissions(webview: &webkit2gtk::WebView) {
use webkit2gtk::{PermissionRequestExt, WebViewExt};
// Allow all permission requests for debugging
let _ = webview.connect_permission_request(move |_, request| {
request.allow();
true
});
}

fn main() {
// Ensure config is created
Config::init();
Expand Down Expand Up @@ -269,7 +293,17 @@ fn main() {
}

let win = win.build()?;

app.webview_windows().values().for_each(|webview_window| {
if let Err(e) = webview_window.with_webview(|webview| {
if let Some(settings) = webview.inner().settings() {
enable_web_features(&settings);
#[cfg(target_os = "linux")]
allow_all_permissions(&webview.inner());
}
}) {
eprintln!("Error configuring webview: {:?}", e);
}
});
configure(&win);
setup_autostart(app);

Expand Down