feat: update simple_room wgpu (#61)

This commit is contained in:
Théo Monnom
2023-05-09 14:29:29 +02:00
committed by GitHub
parent eb43e02bd1
commit 1beee0e1f7
7 changed files with 395 additions and 536 deletions
+368 -511
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -9,12 +9,12 @@ tracing = "0.1"
tracing-subscriber = "0.3" tracing-subscriber = "0.3"
livekit = { path = "../../livekit", version = "0.1.1" } livekit = { path = "../../livekit", version = "0.1.1" }
futures = "0.3" futures = "0.3"
wgpu = "0.14.0" wgpu = "0.16"
winit = "0.27.5" winit = "0.28"
parking_lot = "0.12.1" parking_lot = "0.12.1"
egui = "0.20.1" egui = { git = "https://github.com/emilk/egui" }
egui-wgpu = { version = "0.20.0", features = ["winit"] } egui-wgpu = { git = "https://github.com/emilk/egui", features = ["winit"] }
egui-winit = "0.20.1" egui-winit = { git = "https://github.com/emilk/egui" }
image = "0.24.5" image = "0.24"
+11 -11
View File
@@ -6,14 +6,14 @@ use crate::{events::AsyncCmd, video_grid::VideoGrid};
use egui::{Rounding, Stroke}; use egui::{Rounding, Stroke};
use egui_wgpu::WgpuConfiguration; use egui_wgpu::WgpuConfiguration;
use futures::StreamExt; use futures::StreamExt;
use image::ImageFormat;
use livekit::options::{TrackPublishOptions, VideoCaptureOptions};
use livekit::prelude::*; use livekit::prelude::*;
use livekit::webrtc::audio_stream::native::NativeAudioStream; use livekit::webrtc::audio_stream::native::NativeAudioStream;
use livekit::webrtc::native::yuv_helper;
use livekit::webrtc::video_frame::native::I420BufferExt; use livekit::webrtc::video_frame::native::I420BufferExt;
use livekit::webrtc::video_frame::{I420Buffer, VideoFrame, VideoRotation};
use livekit::webrtc::video_source::native::NativeVideoSource;
use livekit::SimulateScenario; use livekit::SimulateScenario;
use parking_lot::Mutex; use parking_lot::Mutex;
use std::collections::HashMap; use std::collections::HashMap;
@@ -21,7 +21,7 @@ use std::sync::{
atomic::{AtomicBool, Ordering}, atomic::{AtomicBool, Ordering},
Arc, Arc,
}; };
use std::time::Duration;
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
// Useful default constants for developing // Useful default constants for developing
@@ -77,11 +77,10 @@ pub fn run(rt: tokio::runtime::Runtime) {
let egui_context = egui::Context::default(); let egui_context = egui::Context::default();
let egui_state = egui_winit::State::new(&event_loop); let egui_state = egui_winit::State::new(&event_loop);
let mut egui_painter = egui_wgpu::winit::Painter::new(WgpuConfiguration::default(), 1, 32); let mut egui_painter =
egui_wgpu::winit::Painter::new(WgpuConfiguration::default(), 1, None, false);
unsafe { egui_painter.set_window(Some(&window)).await.unwrap();
egui_painter.set_window(Some(&window));
}
let (async_cmd_tx, mut async_cmd_rx) = mpsc::unbounded_channel::<AsyncCmd>(); let (async_cmd_tx, mut async_cmd_rx) = mpsc::unbounded_channel::<AsyncCmd>();
let (ui_cmd_tx, ui_cmd_rx) = mpsc::unbounded_channel::<UiCmd>(); let (ui_cmd_tx, ui_cmd_rx) = mpsc::unbounded_channel::<UiCmd>();
@@ -497,9 +496,10 @@ impl App {
self.egui_painter.paint_and_update_textures( self.egui_painter.paint_and_update_textures(
egui_winit::native_pixels_per_point(&self.window), egui_winit::native_pixels_per_point(&self.window),
egui::Rgba::BLACK, [0.0, 0.0, 0.0, 0.0],
&clipped_primitives, &clipped_primitives,
&full_output.textures_delta, &full_output.textures_delta,
false,
); );
self.egui_state.handle_platform_output( self.egui_state.handle_platform_output(
+2 -1
View File
@@ -190,7 +190,8 @@ impl LogoTrack {
source.capture_frame(&*video_frame); source.capture_frame(&*video_frame);
} }
}) })
.await; .await
.unwrap();
} }
} }
} }
+1 -1
View File
@@ -88,7 +88,7 @@ impl SineTrack {
} }
async fn track_task( async fn track_task(
mut close_rx: oneshot::Receiver<()>, _close_rx: oneshot::Receiver<()>,
rtc_source: NativeAudioSource, rtc_source: NativeAudioSource,
frame_options: Arc<Mutex<FrameData>>, frame_options: Arc<Mutex<FrameData>>,
) { ) {
+2 -2
View File
@@ -7,11 +7,11 @@ struct State {
impl State { impl State {
pub fn load(ctx: &egui::Context, id: egui::Id) -> Option<Self> { pub fn load(ctx: &egui::Context, id: egui::Id) -> Option<Self> {
ctx.data().get_temp(id) ctx.data(|i| i.get_temp(id))
} }
pub fn store(self, ctx: &egui::Context, id: egui::Id) { pub fn store(self, ctx: &egui::Context, id: egui::Id) {
ctx.data().insert_temp(id, self); ctx.data_mut(|i| i.insert_temp(id, self))
} }
} }
+5 -4
View File
@@ -2,7 +2,7 @@ use futures::StreamExt;
use livekit::webrtc::native::yuv_helper; use livekit::webrtc::native::yuv_helper;
use livekit::webrtc::prelude::*; use livekit::webrtc::prelude::*;
use livekit::webrtc::video_stream::native::NativeVideoStream; use livekit::webrtc::video_stream::native::NativeVideoStream;
use std::num::NonZeroU32;
use std::{ use std::{
ops::DerefMut, ops::DerefMut,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
@@ -49,6 +49,7 @@ impl RendererInternal {
sample_count: 1, sample_count: 1,
mip_level_count: 1, mip_level_count: 1,
format: wgpu::TextureFormat::Rgba8UnormSrgb, format: wgpu::TextureFormat::Rgba8UnormSrgb,
view_formats: &[wgpu::TextureFormat::Rgba8UnormSrgb],
}), }),
); );
@@ -57,8 +58,8 @@ impl RendererInternal {
label: Some("lk-videotexture-view"), label: Some("lk-videotexture-view"),
format: Some(wgpu::TextureFormat::Rgba8UnormSrgb), format: Some(wgpu::TextureFormat::Rgba8UnormSrgb),
dimension: Some(wgpu::TextureViewDimension::D2), dimension: Some(wgpu::TextureViewDimension::D2),
mip_level_count: NonZeroU32::new(1), mip_level_count: Some(1),
array_layer_count: NonZeroU32::new(1), array_layer_count: Some(1),
..Default::default() ..Default::default()
}, },
)); ));
@@ -144,7 +145,7 @@ impl VideoRenderer {
}; };
let copy_layout = wgpu::ImageDataLayout { let copy_layout = wgpu::ImageDataLayout {
bytes_per_row: Some(NonZeroU32::new(width * 4).unwrap()), bytes_per_row: Some(width * 4),
..Default::default() ..Default::default()
}; };