@@ -5,7 +5,7 @@ use tokio_util::sync::CancellationToken;
55
66use crate :: {
77 create_editor_instance_impl,
8- frame_ws:: { WSFrame , create_watch_frame_ws} ,
8+ frame_ws:: { WSFrame , WSFrameFormat , create_watch_frame_ws} ,
99} ;
1010
1111pub struct EditorInstance {
@@ -27,16 +27,30 @@ async fn do_prewarm(app: AppHandle, path: PathBuf) -> PendingResult {
2727 let inner = create_editor_instance_impl (
2828 & app,
2929 path,
30- Box :: new ( move |frame| {
31- let _ = frame_tx. send ( Some ( WSFrame {
32- data : frame. data ,
33- width : frame. width ,
34- height : frame. height ,
35- stride : frame. padded_bytes_per_row ,
36- frame_number : frame. frame_number ,
37- target_time_ns : frame. target_time_ns ,
38- created_at : Instant :: now ( ) ,
39- } ) ) ;
30+ Box :: new ( move |output| {
31+ let ws_frame = match output {
32+ cap_editor:: EditorFrameOutput :: Nv12 ( frame) => WSFrame {
33+ data : frame. data ,
34+ width : frame. width ,
35+ height : frame. height ,
36+ stride : frame. y_stride ,
37+ frame_number : frame. frame_number ,
38+ target_time_ns : frame. target_time_ns ,
39+ format : WSFrameFormat :: Nv12 ,
40+ created_at : Instant :: now ( ) ,
41+ } ,
42+ cap_editor:: EditorFrameOutput :: Rgba ( frame) => WSFrame {
43+ data : frame. data ,
44+ width : frame. width ,
45+ height : frame. height ,
46+ stride : frame. padded_bytes_per_row ,
47+ frame_number : frame. frame_number ,
48+ target_time_ns : frame. target_time_ns ,
49+ format : WSFrameFormat :: Rgba ,
50+ created_at : Instant :: now ( ) ,
51+ } ,
52+ } ;
53+ let _ = frame_tx. send ( Some ( std:: sync:: Arc :: new ( ws_frame) ) ) ;
4054 } ) ,
4155 )
4256 . await ?;
@@ -218,16 +232,30 @@ impl EditorInstances {
218232 let inner = create_editor_instance_impl (
219233 window. app_handle ( ) ,
220234 path,
221- Box :: new ( move |frame| {
222- let _ = frame_tx. send ( Some ( WSFrame {
223- data : frame. data ,
224- width : frame. width ,
225- height : frame. height ,
226- stride : frame. padded_bytes_per_row ,
227- frame_number : frame. frame_number ,
228- target_time_ns : frame. target_time_ns ,
229- created_at : Instant :: now ( ) ,
230- } ) ) ;
235+ Box :: new ( move |output| {
236+ let ws_frame = match output {
237+ cap_editor:: EditorFrameOutput :: Nv12 ( frame) => WSFrame {
238+ data : frame. data ,
239+ width : frame. width ,
240+ height : frame. height ,
241+ stride : frame. y_stride ,
242+ frame_number : frame. frame_number ,
243+ target_time_ns : frame. target_time_ns ,
244+ format : WSFrameFormat :: Nv12 ,
245+ created_at : Instant :: now ( ) ,
246+ } ,
247+ cap_editor:: EditorFrameOutput :: Rgba ( frame) => WSFrame {
248+ data : frame. data ,
249+ width : frame. width ,
250+ height : frame. height ,
251+ stride : frame. padded_bytes_per_row ,
252+ frame_number : frame. frame_number ,
253+ target_time_ns : frame. target_time_ns ,
254+ format : WSFrameFormat :: Rgba ,
255+ created_at : Instant :: now ( ) ,
256+ } ,
257+ } ;
258+ let _ = frame_tx. send ( Some ( std:: sync:: Arc :: new ( ws_frame) ) ) ;
231259 } ) ,
232260 )
233261 . await ?;
0 commit comments