|
1 | 1 | use crate::{ |
2 | | - AudioError, AudioRecorder, CombineTracksConfig, EncodedFrame, Frame, H264Writer, |
| 2 | + AudioError, AudioRecorder, CombineTracksConfig, EncodedFrame, Frame, FrameUser, H264Writer, |
3 | 3 | MAX_H264_WRITER_QUEUE_SIZE, ProgressState, RecorderConfig, RecorderError, Resolution, |
4 | | - SpeakerRecorder, StreamingAudioRecorder, VideoEncoder, combine_tracks, |
| 4 | + SpeakerRecorder, StatsUser, StreamingAudioRecorder, VideoEncoder, combine_tracks, |
5 | 5 | }; |
6 | 6 | use capture::{Capture, CaptureIterConfig, capture_output_iter}; |
7 | 7 | use crossbeam::channel::{Receiver, Sender, bounded}; |
@@ -90,8 +90,8 @@ pub struct RecordingSession { |
90 | 90 | frame_receiver: Receiver<Frame>, |
91 | 91 | capture_workers: Vec<JoinHandle<()>>, |
92 | 92 |
|
93 | | - frame_sender_user: Option<Sender<Frame>>, |
94 | | - frame_receiver_user: Option<Arc<Receiver<Frame>>>, |
| 93 | + frame_sender_user: Option<Sender<FrameUser>>, |
| 94 | + frame_receiver_user: Option<Arc<Receiver<FrameUser>>>, |
95 | 95 |
|
96 | 96 | stop_sig: Arc<AtomicBool>, |
97 | 97 | stop_sig_combine: Arc<AtomicBool>, |
@@ -356,10 +356,17 @@ impl RecordingSession { |
356 | 356 | self.total_frame_count += 1; |
357 | 357 | let index = frame.thread_id as usize; |
358 | 358 |
|
359 | | - if let Some(ref sender) = self.frame_sender_user |
360 | | - && let Err(e) = sender.try_send(frame.clone()) |
361 | | - { |
362 | | - log::warn!("try send frame failed: {e}"); |
| 359 | + if let Some(ref sender) = self.frame_sender_user { |
| 360 | + let frame_user = FrameUser { |
| 361 | + stats: StatsUser { |
| 362 | + total_frames: self.total_frame_count, |
| 363 | + loss_frames: self.loss_frame_count.load(Ordering::Relaxed), |
| 364 | + }, |
| 365 | + frame: frame.clone(), |
| 366 | + }; |
| 367 | + if let Err(e) = sender.try_send(frame_user) { |
| 368 | + log::warn!("try send frame failed: {e}"); |
| 369 | + } |
363 | 370 | } |
364 | 371 |
|
365 | 372 | if let Err(e) = resize_sender.try_send((self.total_frame_count, frame)) { |
@@ -1083,7 +1090,7 @@ impl RecordingSession { |
1083 | 1090 | /// } |
1084 | 1091 | /// } |
1085 | 1092 | /// ``` |
1086 | | - pub fn get_frame_receiver_user(&self) -> Option<Arc<Receiver<Frame>>> { |
| 1093 | + pub fn get_frame_receiver_user(&self) -> Option<Arc<Receiver<FrameUser>>> { |
1087 | 1094 | self.frame_receiver_user.clone() |
1088 | 1095 | } |
1089 | 1096 |
|
|
0 commit comments