@@ -8,6 +8,8 @@ use cap_project::{
88 cursor:: CursorEvents ,
99} ;
1010use cap_recording:: PipelineDoneError ;
11+ use cap_recording:: feeds:: camera:: CameraFeedLock ;
12+ use cap_recording:: feeds:: microphone:: MicrophoneFeedLock ;
1113use cap_recording:: {
1214 RecordingError , RecordingMode ,
1315 feeds:: { camera, microphone} ,
@@ -53,20 +55,24 @@ use crate::{
5355 windows:: { CapWindowId , ShowCapWindow } ,
5456} ;
5557
58+ pub struct InProgressRecordingCommon {
59+ pub target_name : String ,
60+ pub inputs : StartRecordingInputs ,
61+ pub recording_dir : PathBuf ,
62+ }
63+
5664pub enum InProgressRecording {
5765 Instant {
58- target_name : String ,
5966 handle : instant_recording:: ActorHandle ,
6067 progressive_upload : InstantMultipartUpload ,
6168 video_upload_info : VideoUploadInfo ,
62- inputs : StartRecordingInputs ,
63- recording_dir : PathBuf ,
69+ common : InProgressRecordingCommon ,
70+ // camera isn't used as part of recording pipeline so we hold lock here
71+ camera_feed : Option < Arc < CameraFeedLock > > ,
6472 } ,
6573 Studio {
66- target_name : String ,
6774 handle : studio_recording:: ActorHandle ,
68- inputs : StartRecordingInputs ,
69- recording_dir : PathBuf ,
75+ common : InProgressRecordingCommon ,
7076 } ,
7177}
7278
@@ -80,8 +86,8 @@ impl InProgressRecording {
8086
8187 pub fn inputs ( & self ) -> & StartRecordingInputs {
8288 match self {
83- Self :: Instant { inputs , .. } => inputs,
84- Self :: Studio { inputs , .. } => inputs,
89+ Self :: Instant { common , .. } => & common . inputs ,
90+ Self :: Studio { common , .. } => & common . inputs ,
8591 }
8692 }
8793
@@ -101,8 +107,8 @@ impl InProgressRecording {
101107
102108 pub fn recording_dir ( & self ) -> & PathBuf {
103109 match self {
104- Self :: Instant { recording_dir , .. } => recording_dir,
105- Self :: Studio { recording_dir , .. } => recording_dir,
110+ Self :: Instant { common , .. } => & common . recording_dir ,
111+ Self :: Studio { common , .. } => & common . recording_dir ,
106112 }
107113 }
108114
@@ -112,21 +118,17 @@ impl InProgressRecording {
112118 handle,
113119 progressive_upload,
114120 video_upload_info,
115- target_name ,
121+ common ,
116122 ..
117123 } => CompletedRecording :: Instant {
118124 recording : handle. stop ( ) . await ?,
119125 progressive_upload,
120126 video_upload_info,
121- target_name,
127+ target_name : common . target_name ,
122128 } ,
123- Self :: Studio {
124- handle,
125- target_name,
126- ..
127- } => CompletedRecording :: Studio {
129+ Self :: Studio { handle, common, .. } => CompletedRecording :: Studio {
128130 recording : handle. stop ( ) . await ?,
129- target_name,
131+ target_name : common . target_name ,
130132 } ,
131133 } )
132134 }
@@ -449,6 +451,12 @@ pub async fn start_recording(
449451 . map_err ( |e| format ! ( "GetShareableContent: {e}" ) ) ?
450452 . ok_or_else ( || format ! ( "GetShareableContent/NotAvailable" ) ) ?;
451453
454+ let common = InProgressRecordingCommon {
455+ target_name,
456+ inputs : inputs. clone ( ) ,
457+ recording_dir : recording_dir. clone ( ) ,
458+ } ;
459+
452460 let actor = match inputs. mode {
453461 RecordingMode :: Studio => {
454462 let mut builder = studio_recording:: Actor :: builder (
@@ -481,12 +489,7 @@ pub async fn start_recording(
481489 e. to_string ( )
482490 } ) ?;
483491
484- InProgressRecording :: Studio {
485- handle,
486- target_name,
487- inputs,
488- recording_dir : recording_dir. clone ( ) ,
489- }
492+ InProgressRecording :: Studio { handle, common }
490493 }
491494 RecordingMode :: Instant => {
492495 let Some ( video_upload_info) = video_upload_info. clone ( ) else {
@@ -526,9 +529,8 @@ pub async fn start_recording(
526529 handle,
527530 progressive_upload,
528531 video_upload_info,
529- target_name,
530- inputs,
531- recording_dir : recording_dir. clone ( ) ,
532+ common,
533+ camera_feed,
532534 }
533535 }
534536 } ;
0 commit comments