Skip to content

Commit 432af2e

Browse files
committed
separate capture-video task
1 parent 7ff2a96 commit 432af2e

File tree

1 file changed

+15
-6
lines changed
  • crates/recording/src/output_pipeline

1 file changed

+15
-6
lines changed

crates/recording/src/output_pipeline/core.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,26 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
405405
muxer: Arc<Mutex<TMutex>>,
406406
timestamps: Timestamps,
407407
) {
408+
setup_ctx.tasks().spawn("capture-video", {
409+
let stop_token = stop_token.clone();
410+
async move {
411+
video_source.start().await?;
412+
413+
stop_token.cancelled().await;
414+
415+
if let Err(e) = video_source.stop().await {
416+
error!("Video source stop failed: {e:#}");
417+
};
418+
419+
Ok(())
420+
}
421+
});
422+
408423
setup_ctx.tasks().spawn("mux-video", async move {
409424
use futures::StreamExt;
410425

411426
let mut first_tx = Some(first_tx);
412427

413-
video_source.start().await?;
414-
415428
stop_token
416429
.run_until_cancelled(async {
417430
while let Some(frame) = video_rx.next().await {
@@ -432,10 +445,6 @@ fn spawn_video_encoder<TMutex: VideoMuxer<VideoFrame = TVideo::Frame>, TVideo: V
432445
})
433446
.await;
434447

435-
if let Err(e) = video_source.stop().await {
436-
error!("Video source stopped with error: {e:#}");
437-
};
438-
439448
muxer.lock().await.stop();
440449

441450
Ok(())

0 commit comments

Comments
 (0)