@@ -21,11 +21,10 @@ use tokio::task::JoinHandle;
21
21
pub async fn start_continuous_recording (
22
22
db : Arc < DatabaseManager > ,
23
23
output_path : Arc < String > ,
24
- fps : f64 ,
24
+ fps : u32 ,
25
25
audio_chunk_duration : Duration ,
26
26
vision_control : Arc < AtomicBool > ,
27
27
audio_devices_control : Arc < SegQueue < ( AudioDevice , DeviceControl ) > > ,
28
- save_text_files : bool ,
29
28
audio_transcription_engine : Arc < AudioTranscriptionEngine > ,
30
29
ocr_engine : Arc < OcrEngine > ,
31
30
friend_wearable_uid : Option < String > ,
@@ -59,7 +58,6 @@ pub async fn start_continuous_recording(
59
58
output_path_video,
60
59
fps,
61
60
is_running_video,
62
- save_text_files,
63
61
ocr_engine,
64
62
friend_wearable_uid_video,
65
63
monitor_id,
@@ -99,9 +97,8 @@ pub async fn start_continuous_recording(
99
97
async fn record_video (
100
98
db : Arc < DatabaseManager > ,
101
99
output_path : Arc < String > ,
102
- fps : f64 ,
100
+ fps : u32 ,
103
101
is_running : Arc < AtomicBool > ,
104
- save_text_files : bool ,
105
102
ocr_engine : Arc < OcrEngine > ,
106
103
_friend_wearable_uid : Option < String > ,
107
104
monitor_id : u32 ,
@@ -125,52 +122,38 @@ async fn record_video(
125
122
& output_path,
126
123
fps,
127
124
new_chunk_callback,
128
- save_text_files,
129
125
Arc :: clone ( & ocr_engine) ,
130
126
monitor_id,
131
127
) ;
132
128
133
129
while is_running. load ( Ordering :: SeqCst ) {
134
130
if let Some ( frame) = video_capture. ocr_frame_queue . pop ( ) {
135
- for window_result in & frame. window_ocr_results {
136
- match db. insert_frame ( ) . await {
137
- Ok ( frame_id) => {
138
- let text_json =
139
- serde_json:: to_string ( & window_result. text_json ) . unwrap_or_default ( ) ;
140
-
141
- let text = if use_pii_removal {
142
- & remove_pii ( & window_result. text )
143
- } else {
144
- & window_result. text
145
- } ;
146
- if let Err ( e) = db
147
- . insert_ocr_text (
148
- frame_id,
149
- text,
150
- & text_json,
151
- & window_result. app_name ,
152
- & window_result. window_name ,
153
- Arc :: clone ( & ocr_engine) ,
154
- window_result. focused , // Add this line
155
- )
156
- . await
157
- {
158
- error ! (
159
- "Failed to insert OCR text: {}, skipping window {} of frame {}" ,
160
- e, window_result. window_name, frame_id
161
- ) ;
162
- continue ;
163
- }
164
- }
165
- Err ( e) => {
166
- warn ! ( "Failed to insert frame: {}" , e) ;
167
- tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
131
+ match db. insert_frame ( ) . await {
132
+ Ok ( frame_id) => {
133
+ let text = if use_pii_removal {
134
+ & remove_pii ( & frame. ocr_results )
135
+ } else {
136
+ & frame. ocr_results
137
+ } ;
138
+ if let Err ( e) = db
139
+ . insert_ocr_text ( frame_id, text, & frame. raw_json , Arc :: clone ( & ocr_engine) )
140
+ . await
141
+ {
142
+ error ! (
143
+ "Failed to insert OCR text: {}, skipping frame {}" ,
144
+ e, frame_id
145
+ ) ;
168
146
continue ;
169
147
}
170
148
}
149
+ Err ( e) => {
150
+ warn ! ( "Failed to insert frame: {}" , e) ;
151
+ tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
152
+ continue ;
153
+ }
171
154
}
172
155
}
173
- tokio:: time:: sleep ( Duration :: from_secs_f64 ( 1.0 / fps ) ) . await ;
156
+ tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
174
157
}
175
158
176
159
Ok ( ( ) )
0 commit comments