Skip to content

Commit

Permalink
Fix dispatcher example (livekit#484)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Bulatov <[email protected]>
  • Loading branch information
mikayla-maki and SomeoneToIgnore authored Nov 13, 2024
1 parent ee5076b commit 3c70895
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 66 deletions.
85 changes: 64 additions & 21 deletions examples/basic_room_dispatcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/basic_room_dispatcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ livekit = { path = "../../livekit", default-features = false, features = ["nativ
livekit-api = { path = "../../livekit-api" }
log = "0.4"

[workspace]
[workspace]
3 changes: 1 addition & 2 deletions examples/basic_room_dispatcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 22 additions & 41 deletions examples/wgpu_room/src/video_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion livekit-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c70895

Please sign in to comment.