mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-03 08:46:39 +00:00
Merge pull request #31 from sdroege/no-vec-from-raw-parts
Use slice::from_raw_parts instead of Vec::from_raw_parts and always free video frames
This commit is contained in:
commit
a355220254
1 changed files with 4 additions and 4 deletions
|
@ -16,7 +16,7 @@ use gst_video;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::{i32, u32};
|
use std::{i32, u32};
|
||||||
|
|
||||||
use std::ptr;
|
use std::{slice, ptr};
|
||||||
|
|
||||||
use connect_ndi;
|
use connect_ndi;
|
||||||
use ndi_struct;
|
use ndi_struct;
|
||||||
|
@ -476,7 +476,6 @@ impl BaseSrcImpl for NdiVideoSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
if time >= (video_frame.timestamp as u64) {
|
if time >= (video_frame.timestamp as u64) {
|
||||||
NDIlib_recv_free_video_v2(pNDI_recv, &video_frame);
|
|
||||||
gst_debug!(self.cat, obj: element, "Frame timestamp ({:?}) is lower than received in the first frame from NDI ({:?}), so skiping...", (video_frame.timestamp as u64), time);
|
gst_debug!(self.cat, obj: element, "Frame timestamp ({:?}) is lower than received in the first frame from NDI ({:?}), so skiping...", (video_frame.timestamp as u64), time);
|
||||||
} else {
|
} else {
|
||||||
skip_frame = false;
|
skip_frame = false;
|
||||||
|
@ -502,7 +501,7 @@ impl BaseSrcImpl for NdiVideoSrc {
|
||||||
let buff_size = (video_frame.yres * video_frame.line_stride_in_bytes) as usize;
|
let buff_size = (video_frame.yres * video_frame.line_stride_in_bytes) as usize;
|
||||||
let mut buffer = gst::Buffer::with_size(buff_size).unwrap();
|
let mut buffer = gst::Buffer::with_size(buff_size).unwrap();
|
||||||
{
|
{
|
||||||
let vec = Vec::from_raw_parts(video_frame.p_data as *mut u8, buff_size, buff_size);
|
let data = slice::from_raw_parts(video_frame.p_data as *mut u8, buff_size);
|
||||||
// Newtek NDI yields times in 100ns intervals since the Unix Time
|
// Newtek NDI yields times in 100ns intervals since the Unix Time
|
||||||
let pts: gst::ClockTime = (pts * 100).into();
|
let pts: gst::ClockTime = (pts * 100).into();
|
||||||
|
|
||||||
|
@ -522,10 +521,11 @@ impl BaseSrcImpl for NdiVideoSrc {
|
||||||
buffer.set_offset(timestamp_data.offset);
|
buffer.set_offset(timestamp_data.offset);
|
||||||
timestamp_data.offset += 1;
|
timestamp_data.offset += 1;
|
||||||
buffer.set_offset_end(timestamp_data.offset);
|
buffer.set_offset_end(timestamp_data.offset);
|
||||||
buffer.copy_from_slice(0, &vec).unwrap();
|
buffer.copy_from_slice(0, data).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_log!(self.cat, obj: element, "Produced buffer {:?}", buffer);
|
gst_log!(self.cat, obj: element, "Produced buffer {:?}", buffer);
|
||||||
|
NDIlib_recv_free_video_v2(pNDI_recv, &video_frame);
|
||||||
|
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue