opt: no copy during transmitting the decoded frame

This commit is contained in:
Kingtous
2023-02-11 12:25:13 +08:00
parent f8c78a6bf2
commit f521b1665a
4 changed files with 9 additions and 9 deletions

View File

@@ -1545,7 +1545,7 @@ pub type MediaSender = mpsc::Sender<MediaData>;
/// * `video_callback` - The callback for video frame. Being called when a video frame is ready.
pub fn start_video_audio_threads<F>(video_callback: F) -> (MediaSender, MediaSender)
where
F: 'static + FnMut(&[u8]) + Send,
F: 'static + FnMut(Vec<u8>) + Send,
{
let (video_sender, video_receiver) = mpsc::channel::<MediaData>();
let mut video_callback = video_callback;
@@ -1560,7 +1560,7 @@ where
match data {
MediaData::VideoFrame(vf) => {
if let Ok(true) = video_handler.handle_frame(vf) {
video_callback(&video_handler.rgb);
video_callback(std::mem::replace(&mut video_handler.rgb, vec![]));
}
}
MediaData::Reset => {