File tree Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,3 @@ livekit-api = { path = "../../livekit-api"}
1111log = " 0.4"
1212clap = { version = " 4.0" , features = [" derive" ] }
1313inquire = " 0.9"
14-
15- [target .'cfg(target_os = "linux")' .dependencies ]
16- glib = " 0.21.1"
Original file line number Diff line number Diff line change @@ -42,18 +42,6 @@ async fn main() {
4242 . init ( ) ;
4343 let args = Args :: parse ( ) ;
4444
45- // On Wayland, libwebrtc communicates with the XDG Desktop Portal over dbus using GDBus
46- // from the gio library. This requires a running glib event loop to work.
47- // If your application already has a glib event loop running for another reason, for
48- // example using the GTK or GStreamer Rust bindings, you do not need to setup another
49- // glib event loop for this.
50- if cfg ! ( target_os = "linux" ) && std:: env:: var ( "WAYLAND_DISPLAY" ) . is_ok ( ) {
51- let main_loop = glib:: MainLoop :: new ( None , false ) ;
52- let _handle = std:: thread:: spawn ( move || {
53- main_loop. run ( ) ;
54- } ) ;
55- }
56-
5745 let url = env:: var ( "LIVEKIT_URL" ) . expect ( "LIVEKIT_URL is not set" ) ;
5846 let api_key = env:: var ( "LIVEKIT_API_KEY" ) . expect ( "LIVEKIT_API_KEY is not set" ) ;
5947 let api_secret = env:: var ( "LIVEKIT_API_SECRET" ) . expect ( "LIVEKIT_API_SECRET is not set" ) ;
Original file line number Diff line number Diff line change @@ -7,13 +7,25 @@ license = "Apache-2.0"
77description = " Livekit safe bindings to libwebrtc"
88repository = " https://github.com/livekit/rust-sdks"
99
10+ [features ]
11+ default = [ " glib-main-loop" ]
12+ # On Wayland, libwebrtc communicates with the XDG Desktop Portal over dbus using GDBus
13+ # from the gio library. This requires a running glib event loop to work.
14+ # If your application already has a glib event loop running for another reason, for
15+ # example using the GTK or GStreamer Rust bindings, it does not need to setup another
16+ # glib event loop for this and can opt out by disabling this default glib-main-loop feature.
17+ glib-main-loop = [ " dep:glib" ]
18+
1019[dependencies ]
1120livekit-protocol = { workspace = true }
1221log = " 0.4"
1322serde = { version = " 1.0" , features = [" derive" ] }
1423serde_json = " 1.0"
1524thiserror = " 1.0"
1625
26+ [target .'cfg(target_os = "linux")' .dependencies ]
27+ glib = { version = " 0.21.3" , optional = true }
28+
1729[target .'cfg(target_os = "android")' .dependencies ]
1830jni = " 0.21"
1931
Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ impl DesktopCapturer {
145145 }
146146
147147 pub fn start ( & mut self ) {
148+ #[ cfg( all( target_os = "linux" , feature = "glib-main-loop" ) ) ]
149+ if std:: env:: var ( "WAYLAND_DISPLAY" ) . is_ok ( ) {
150+ let main_loop = glib:: MainLoop :: new ( None , false ) ;
151+ let _handle = std:: thread:: spawn ( move || {
152+ main_loop. run ( ) ;
153+ } ) ;
154+ }
148155 let pin_handle = self . sys_handle . pin_mut ( ) ;
149156 pin_handle. start ( ) ;
150157 }
You can’t perform that action at this time.
0 commit comments