mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-06-05 23:18:55 +00:00
Use common start timestamp
This commit is contained in:
parent
8399da4f7c
commit
6ba47cc085
3 changed files with 14 additions and 7 deletions
|
@ -43,12 +43,12 @@ fn plugin_init(plugin: &gst::Plugin) -> bool {
|
||||||
|
|
||||||
struct Ndi{
|
struct Ndi{
|
||||||
recv: Option<NdiInstance>,
|
recv: Option<NdiInstance>,
|
||||||
//start_pts: Option<u64>,
|
start_pts: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut ndi_struct: Ndi = Ndi{
|
static mut ndi_struct: Ndi = Ndi{
|
||||||
recv: None,
|
recv: None,
|
||||||
//start_pts: None,
|
start_pts: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn connect_ndi(cat: gst::DebugCategory , element: &BaseSrc, ip: String, stream_name: String) -> bool{
|
fn connect_ndi(cat: gst::DebugCategory , element: &BaseSrc, ip: String, stream_name: String) -> bool{
|
||||||
|
|
|
@ -294,7 +294,8 @@ impl NdiAudioSrc {
|
||||||
while frame_type != NDIlib_frame_type_e::NDIlib_frame_type_audio{
|
while frame_type != NDIlib_frame_type_e::NDIlib_frame_type_audio{
|
||||||
frame_type = NDIlib_recv_capture_v2(pNDI_recv, ptr::null(), &audio_frame, ptr::null(), 1000);
|
frame_type = NDIlib_recv_capture_v2(pNDI_recv, ptr::null(), &audio_frame, ptr::null(), 1000);
|
||||||
}
|
}
|
||||||
timestamp_data.pts = audio_frame.timecode as u64;
|
ndi_struct.start_pts = audio_frame.timecode as u64;
|
||||||
|
//timestamp_data.pts = audio_frame.timecode as u64;
|
||||||
|
|
||||||
let mut caps = gst::Caps::truncate(caps);
|
let mut caps = gst::Caps::truncate(caps);
|
||||||
{
|
{
|
||||||
|
@ -348,7 +349,8 @@ impl NdiAudioSrc {
|
||||||
|
|
||||||
let audio_frame: NDIlib_audio_frame_v2_t = Default::default();
|
let audio_frame: NDIlib_audio_frame_v2_t = Default::default();
|
||||||
NDIlib_recv_capture_v2(pNDI_recv, ptr::null(), &audio_frame, ptr::null(), 1000,);
|
NDIlib_recv_capture_v2(pNDI_recv, ptr::null(), &audio_frame, ptr::null(), 1000,);
|
||||||
pts = (audio_frame.timecode as u64) - timestamp_data.pts;
|
//pts = (audio_frame.timecode as u64) - timestamp_data.pts;
|
||||||
|
pts = (audio_frame.timecode as u64) - ndi_struct.start_pts;
|
||||||
|
|
||||||
let buff_size = ((audio_frame.channel_stride_in_bytes)) as usize;
|
let buff_size = ((audio_frame.channel_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();
|
||||||
|
|
|
@ -302,7 +302,8 @@ impl NdiVideoSrc {
|
||||||
frame_type = NDIlib_recv_capture_v2(pNDI_recv, &video_frame, ptr::null(), ptr::null(), 1000);
|
frame_type = NDIlib_recv_capture_v2(pNDI_recv, &video_frame, ptr::null(), ptr::null(), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp_data.pts = video_frame.timecode as u64;
|
//timestamp_data.pts = video_frame.timecode as u64;
|
||||||
|
ndi_struct.start_pts = video_frame.timecode as u64;
|
||||||
|
|
||||||
let mut caps = gst::Caps::truncate(caps);
|
let mut caps = gst::Caps::truncate(caps);
|
||||||
{
|
{
|
||||||
|
@ -356,16 +357,20 @@ impl NdiVideoSrc {
|
||||||
let pts: u64;
|
let pts: u64;
|
||||||
let video_frame: NDIlib_video_frame_v2_t = Default::default();
|
let video_frame: NDIlib_video_frame_v2_t = Default::default();
|
||||||
NDIlib_recv_capture_v2(pNDI_recv, &video_frame, ptr::null(), ptr::null(), 1000,);
|
NDIlib_recv_capture_v2(pNDI_recv, &video_frame, ptr::null(), ptr::null(), 1000,);
|
||||||
pts = (video_frame.timecode as u64) - timestamp_data.pts;
|
//pts = (video_frame.timecode as u64) - timestamp_data.pts;
|
||||||
|
|
||||||
|
pts = (video_frame.timecode as u64) - ndi_struct.start_pts;
|
||||||
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;
|
||||||
//println!("{:?}", buff_size);
|
//println!("{:?}", buff_size);
|
||||||
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 vec = Vec::from_raw_parts(video_frame.p_data as *mut u8, buff_size, buff_size);
|
||||||
let pts: gst::ClockTime = (pts * 100).into();
|
let pts: gst::ClockTime = (pts * 100).into();
|
||||||
|
|
||||||
|
// println!("{:?}", video_frame.line_stride_in_bytes);
|
||||||
|
//println!("{:?}", video_frame);
|
||||||
//TODO get duration
|
//TODO get duration
|
||||||
let duration: gst::ClockTime = (40000000).into();
|
let duration: gst::ClockTime = (33333333).into();
|
||||||
let buffer = buffer.get_mut().unwrap();
|
let buffer = buffer.get_mut().unwrap();
|
||||||
buffer.set_pts(pts);
|
buffer.set_pts(pts);
|
||||||
buffer.set_duration(duration);
|
buffer.set_duration(duration);
|
||||||
|
|
Loading…
Reference in a new issue