From 3c70895941d6de6d28adfd69eea4e5f09336e5db Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 12 Nov 2024 18:53:03 -0800 Subject: [PATCH] Fix dispatcher example (#484) Co-authored-by: Kirill Bulatov --- examples/basic_room_dispatcher/Cargo.lock | 85 ++++++++++++++++------ examples/basic_room_dispatcher/Cargo.toml | 2 +- examples/basic_room_dispatcher/src/main.rs | 3 +- examples/wgpu_room/src/video_renderer.rs | 63 ++++++---------- livekit-api/Cargo.toml | 2 +- 5 files changed, 89 insertions(+), 66 deletions(-) diff --git a/examples/basic_room_dispatcher/Cargo.lock b/examples/basic_room_dispatcher/Cargo.lock index f43f54d98..c86a54912 100644 --- a/examples/basic_room_dispatcher/Cargo.lock +++ b/examples/basic_room_dispatcher/Cargo.lock @@ -37,6 +37,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.80" @@ -429,11 +444,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", "num-traits", + "wasm-bindgen", + "windows-targets 0.52.0", ] [[package]] @@ -1115,6 +1135,29 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.5.0" @@ -1301,7 +1344,7 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libwebrtc" -version = "0.3.2" +version = "0.3.7" dependencies = [ "cxx", "jni", @@ -1315,7 +1358,6 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-stream", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -1357,8 +1399,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "livekit" -version = "0.3.2" +version = "0.7.0" dependencies = [ + "chrono", "futures-util", "lazy_static", "libwebrtc", @@ -1368,6 +1411,7 @@ dependencies = [ "log", "parking_lot", "prost", + "semver", "serde", "serde_json", "thiserror", @@ -1376,7 +1420,7 @@ dependencies = [ [[package]] name = "livekit-api" -version = "0.3.2" +version = "0.4.1" dependencies = [ "async-tungstenite", "base64", @@ -1402,7 +1446,7 @@ dependencies = [ [[package]] name = "livekit-protocol" -version = "0.3.2" +version = "0.3.6" dependencies = [ "futures-util", "livekit-runtime", @@ -1418,7 +1462,7 @@ dependencies = [ [[package]] name = "livekit-runtime" -version = "0.3.0" +version = "0.3.1" dependencies = [ "async-io 2.3.1", "async-std", @@ -2415,6 +2459,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", + "signal-hook-registry", "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", @@ -2451,17 +2496,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-tungstenite" version = "0.20.1" @@ -2767,7 +2801,7 @@ dependencies = [ [[package]] name = "webrtc-sys" -version = "0.3.2" +version = "0.3.5" dependencies = [ "cc", "cxx", @@ -2779,7 +2813,7 @@ dependencies = [ [[package]] name = "webrtc-sys-build" -version = "0.3.2" +version = "0.3.5" dependencies = [ "fs2", "regex", @@ -2832,6 +2866,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.45.0" diff --git a/examples/basic_room_dispatcher/Cargo.toml b/examples/basic_room_dispatcher/Cargo.toml index 291bea2f7..eef4d7a8a 100644 --- a/examples/basic_room_dispatcher/Cargo.toml +++ b/examples/basic_room_dispatcher/Cargo.toml @@ -11,4 +11,4 @@ livekit = { path = "../../livekit", default-features = false, features = ["nativ livekit-api = { path = "../../livekit-api" } log = "0.4" -[workspace] \ No newline at end of file +[workspace] diff --git a/examples/basic_room_dispatcher/src/main.rs b/examples/basic_room_dispatcher/src/main.rs index e61c182e6..7f05acbaa 100644 --- a/examples/basic_room_dispatcher/src/main.rs +++ b/examples/basic_room_dispatcher/src/main.rs @@ -47,12 +47,11 @@ fn main() { .unwrap(); let (room, mut rx) = Room::connect(&url, &token, RoomOptions::default()).await.unwrap(); - log::info!("Connected to room: {} - {}", room.name(), room.sid()); + log::info!("Connected to room: {} - {}", room.name(), room.sid().await); room.local_participant() .publish_data(DataPacket { payload: "Hello world".to_owned().into_bytes(), - kind: DataPacketKind::Reliable, ..Default::default() }) .await diff --git a/examples/wgpu_room/src/video_renderer.rs b/examples/wgpu_room/src/video_renderer.rs index 1c052f675..b45e615c7 100644 --- a/examples/wgpu_room/src/video_renderer.rs +++ b/examples/wgpu_room/src/video_renderer.rs @@ -86,20 +86,13 @@ impl VideoRenderer { bytes_per_row: Some(width * 4), ..Default::default() }, - wgpu::Extent3d { - width, - height, - ..Default::default() - }, + wgpu::Extent3d { width, height, ..Default::default() }, ); } } }); - Self { - rtc_track, - internal, - } + Self { rtc_track, internal } } // Returns the last frame resolution @@ -124,47 +117,35 @@ impl RendererInternal { self.height = height; self.rgba_data.resize((width * height * 4) as usize, 0); - self.texture = Some( - self.render_state - .device - .create_texture(&wgpu::TextureDescriptor { - label: Some("lk-videotexture"), - usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, - dimension: wgpu::TextureDimension::D2, - size: wgpu::Extent3d { - width, - height, - ..Default::default() - }, - sample_count: 1, - mip_level_count: 1, - format: wgpu::TextureFormat::Rgba8UnormSrgb, - view_formats: &[wgpu::TextureFormat::Rgba8UnormSrgb], - }), - ); - - self.texture_view = Some(self.texture.as_mut().unwrap().create_view( - &wgpu::TextureViewDescriptor { + self.texture = Some(self.render_state.device.create_texture(&wgpu::TextureDescriptor { + label: Some("lk-videotexture"), + usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, + dimension: wgpu::TextureDimension::D2, + size: wgpu::Extent3d { width, height, ..Default::default() }, + sample_count: 1, + mip_level_count: 1, + format: wgpu::TextureFormat::Rgba8UnormSrgb, + view_formats: &[wgpu::TextureFormat::Rgba8UnormSrgb], + })); + + self.texture_view = + Some(self.texture.as_mut().unwrap().create_view(&wgpu::TextureViewDescriptor { label: Some("lk-videotexture-view"), format: Some(wgpu::TextureFormat::Rgba8UnormSrgb), dimension: Some(wgpu::TextureViewDimension::D2), mip_level_count: Some(1), array_layer_count: Some(1), ..Default::default() - }, - )); + })); if let Some(texture_id) = self.egui_texture { // Update the existing texture - self.render_state - .renderer - .write() - .update_egui_texture_from_wgpu_texture( - &self.render_state.device, - self.texture_view.as_ref().unwrap(), - wgpu::FilterMode::Linear, - texture_id, - ); + self.render_state.renderer.write().update_egui_texture_from_wgpu_texture( + &self.render_state.device, + self.texture_view.as_ref().unwrap(), + wgpu::FilterMode::Linear, + texture_id, + ); } else { self.egui_texture = Some(self.render_state.renderer.write().register_native_texture( &self.render_state.device, diff --git a/livekit-api/Cargo.toml b/livekit-api/Cargo.toml index 0b50257a2..99538ca4a 100644 --- a/livekit-api/Cargo.toml +++ b/livekit-api/Cargo.toml @@ -85,7 +85,7 @@ jsonwebtoken = { version = "9", default-features = false, optional = true } livekit-runtime = { path = "../livekit-runtime", version = "0.3.0", optional = true} tokio-tungstenite = { version = "0.20", optional = true } async-tungstenite = { version = "0.25.0", features = [ "async-std-runtime", "async-native-tls"], optional = true } -tokio = { version = "1", default-features = false, features = ["sync", "macros"], optional = true } +tokio = { version = "1", default-features = false, features = ["sync", "macros", "signal"], optional = true } futures-util = { version = "0.3", default-features = false, features = [ "sink" ], optional = true } # This dependency must be kept in sync with reqwest's version