Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(recording): wire segment_tx through Windows fragmented muxer and capture pipeline

Richie McIlroya9b7d010feca
diff --git a/crates/recording/src/capture_pipeline.rs b/crates/recording/src/capture_pipeline.rs
index 523dc2855..1b1aa62ee 100644
--- a/crates/recording/src/capture_pipeline.rs
+++ b/crates/recording/src/capture_pipeline.rs
@@ -161,6 +161,7 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {
output_size,
shared_pause_state,
disk_space_callback: None,
+ segment_tx: None,
})
.await
} else {
@@ -192,12 +193,6 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {
start_time: Timestamps,
segment_tx: Option<std::sync::mpsc::Sender<SegmentCompletedEvent>>,
) -> anyhow::Result<OutputPipeline> {
- if segment_tx.is_some() {
- tracing::info!(
- "Segment upload channel not yet supported on Windows, using fragmented muxer fallback"
- );
- }
- drop(segment_tx);
OutputPipeline::builder(segments_dir)
.with_video::<screen_capture::VideoSource>(screen_capture)
.with_timestamps(start_time)
@@ -208,6 +203,7 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {
output_size: Some(output_size),
shared_pause_state: None,
disk_space_callback: None,
+ segment_tx,
})
.await
}
diff --git a/crates/recording/src/output_pipeline/win_fragmented_m4s.rs b/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
index 4ba9e02a2..229a7d4d4 100644
--- a/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
+++ b/crates/recording/src/output_pipeline/win_fragmented_m4s.rs
@@ -198,6 +198,8 @@ pub struct WindowsFragmentedM4SMuxer {
frame_drops: FrameDropTracker,
started: bool,
disk_space_callback: Option<DiskSpaceCallback>,
+ segment_tx:
+ Option<std::sync::mpsc::Sender<cap_enc_ffmpeg::segmented_stream::SegmentCompletedEvent>>,
}
pub struct WindowsFragmentedM4SMuxerConfig {
@@ -207,6 +209,8 @@ pub struct WindowsFragmentedM4SMuxerConfig {
pub output_size: Option<(u32, u32)>,
pub shared_pause_state: Option<SharedPauseState>,
pub disk_space_callback: Option<DiskSpaceCallback>,
+ pub segment_tx:
+ Option<std::sync::mpsc::Sender<cap_enc_ffmpeg::segmented_stream::SegmentCompletedEvent>>,
}
impl Default for WindowsFragmentedM4SMuxerConfig {
@@ -218,6 +222,7 @@ impl Default for WindowsFragmentedM4SMuxerConfig {
output_size: None,
shared_pause_state: None,
disk_space_callback: None,
+ segment_tx: None,
}
}
}
@@ -258,6 +263,7 @@ impl Muxer for WindowsFragmentedM4SMuxer {
frame_drops: FrameDropTracker::new(),
started: false,
disk_space_callback: config.disk_space_callback,
+ segment_tx: config.segment_tx,
};
muxer.start_encoder()?;
@@ -313,6 +319,9 @@ impl WindowsFragmentedM4SMuxer {
if let Some(callback) = &self.disk_space_callback {
encoder.set_disk_space_callback(callback.clone());
}
+ if let Some(tx) = self.segment_tx.take() {
+ encoder.set_segment_callback(tx);
+ }
let encoder = Arc::new(Mutex::new(encoder));
let encoder_clone = encoder.clone();