mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-30 15:31:01 +00:00
Try to add video data to a buffer
This commit is contained in:
parent
ca4e498a0b
commit
d813fa5681
1 changed files with 15 additions and 1 deletions
|
@ -663,6 +663,9 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
let audio_frame: NDIlib_audio_frame_v2_t = Default::default();
|
let audio_frame: NDIlib_audio_frame_v2_t = Default::default();
|
||||||
let metadata_frame: NDIlib_metadata_frame_t = Default::default();
|
let metadata_frame: NDIlib_metadata_frame_t = Default::default();
|
||||||
|
|
||||||
|
//TODO Solo hacemos el buffer cuando tengamos un frame de video
|
||||||
|
let mut frame = false;
|
||||||
|
while !frame{
|
||||||
let frame_type = NDIlib_recv_capture_v2(
|
let frame_type = NDIlib_recv_capture_v2(
|
||||||
pNDI_recv,
|
pNDI_recv,
|
||||||
&video_frame,
|
&video_frame,
|
||||||
|
@ -674,7 +677,7 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
match frame_type {
|
match frame_type {
|
||||||
NDIlib_frame_type_e::NDIlib_frame_type_video => {
|
NDIlib_frame_type_e::NDIlib_frame_type_video => {
|
||||||
println!("Tengo video {:?}", video_frame);
|
println!("Tengo video {:?}", video_frame);
|
||||||
|
frame = true;
|
||||||
}
|
}
|
||||||
NDIlib_frame_type_e::NDIlib_frame_type_audio => {
|
NDIlib_frame_type_e::NDIlib_frame_type_audio => {
|
||||||
println!("Tengo audio {:?}", audio_frame);
|
println!("Tengo audio {:?}", audio_frame);
|
||||||
|
@ -700,6 +703,7 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
}
|
}
|
||||||
_ => println!("Tengo {:?}", frame_type),
|
_ => println!("Tengo {:?}", frame_type),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@ -727,6 +731,16 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
gst::Buffer::with_size(200 * 400).unwrap();
|
gst::Buffer::with_size(200 * 400).unwrap();
|
||||||
{
|
{
|
||||||
let buffer = buffer.get_mut().unwrap();
|
let buffer = buffer.get_mut().unwrap();
|
||||||
|
let pts: gst::ClockTime = (video_frame.timestamp as u64).into();
|
||||||
|
let duration: gst::ClockTime = (334624).into();
|
||||||
|
buffer.set_pts(pts);
|
||||||
|
buffer.set_duration(duration);
|
||||||
|
// Map the buffer writable and create the actual samples
|
||||||
|
let mut map = buffer.map_writable().unwrap();
|
||||||
|
let mut data = map.as_slice();
|
||||||
|
//data = &mut video_frame.p_data;
|
||||||
|
let a = CStr::from_ptr(video_frame.p_data);
|
||||||
|
data = a.to_bytes();
|
||||||
|
|
||||||
// // Calculate the current timestamp (PTS) and the next one,
|
// // Calculate the current timestamp (PTS) and the next one,
|
||||||
// // and calculate the duration from the difference instead of
|
// // and calculate the duration from the difference instead of
|
||||||
|
|
Loading…
Reference in a new issue