mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-03 10:13:47 +00:00
Use Default Trait
The default values must be reviewed
This commit is contained in:
parent
8d99d47f81
commit
20b6ae5ff6
2 changed files with 98 additions and 45 deletions
|
@ -18,11 +18,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO valores por defecto
|
//TODO valores por defecto
|
||||||
let NDI_find_create_desc = NDIlib_find_create_t {
|
let NDI_find_create_desc: NDIlib_find_create_t = Default::default();
|
||||||
show_local_sources: false,
|
|
||||||
p_groups: ptr::null(),
|
|
||||||
p_extra_ips: ptr::null()
|
|
||||||
};
|
|
||||||
let pNDI_find = NDIlib_find_create_v2(&NDI_find_create_desc);
|
let pNDI_find = NDIlib_find_create_v2(&NDI_find_create_desc);
|
||||||
if pNDI_find.is_null() {
|
if pNDI_find.is_null() {
|
||||||
println!("Cannot run NDI: NDIlib_find_create_v2 error.");
|
println!("Cannot run NDI: NDIlib_find_create_v2 error.");
|
||||||
|
@ -54,10 +50,8 @@ fn main() {
|
||||||
let p_ndi_name = CString::new("Galicaster NDI Receiver").unwrap();
|
let p_ndi_name = CString::new("Galicaster NDI Receiver").unwrap();
|
||||||
let NDI_recv_create_desc = NDIlib_recv_create_v3_t {
|
let NDI_recv_create_desc = NDIlib_recv_create_v3_t {
|
||||||
source_to_connect_to: *p_sources,
|
source_to_connect_to: *p_sources,
|
||||||
allow_video_fields: true,
|
p_ndi_name: p_ndi_name.as_ptr(),
|
||||||
bandwidth: NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest,
|
..Default::default()
|
||||||
color_format: NDIlib_recv_color_format_e_NDIlib_recv_color_format_BGRX_BGRA,
|
|
||||||
p_ndi_name: p_ndi_name.as_ptr(), //ptr::null(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,10 +65,7 @@ fn main() {
|
||||||
NDIlib_find_destroy(pNDI_find);
|
NDIlib_find_destroy(pNDI_find);
|
||||||
|
|
||||||
// We are now going to mark this source as being on program output for tally purposes (but not on preview)
|
// We are now going to mark this source as being on program output for tally purposes (but not on preview)
|
||||||
let tally_state = NDIlib_tally_t {
|
let tally_state: NDIlib_tally_t = Default::default();
|
||||||
on_program: true,
|
|
||||||
on_preview: true,
|
|
||||||
};
|
|
||||||
NDIlib_recv_set_tally(pNDI_recv, &tally_state);
|
NDIlib_recv_set_tally(pNDI_recv, &tally_state);
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,39 +83,11 @@ fn main() {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
||||||
let video_frame = NDIlib_video_frame_v2_t {
|
let video_frame: NDIlib_video_frame_v2_t = Default::default();
|
||||||
xres: 0,
|
let audio_frame: NDIlib_audio_frame_v2_t = Default::default();
|
||||||
yres: 0,
|
let metadata_frame: NDIlib_metadata_frame_t = Default::default();
|
||||||
FourCC: 0,
|
|
||||||
frame_rate_N: 0,
|
|
||||||
frame_rate_D: 0,
|
|
||||||
picture_aspect_ratio: 0.0,
|
|
||||||
frame_format_type: 0,
|
|
||||||
timecode: 0,
|
|
||||||
p_data: ptr::null(),
|
|
||||||
line_stride_in_bytes: 0,
|
|
||||||
p_metadata: ptr::null(),
|
|
||||||
timestamp: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let audio_frame = NDIlib_audio_frame_v2_t {
|
|
||||||
sample_rate: 0,
|
|
||||||
no_channels: 0,
|
|
||||||
no_samples: 0,
|
|
||||||
timecode: 0,
|
|
||||||
p_data: ptr::null(),
|
|
||||||
channel_stride_in_bytes: 0,
|
|
||||||
p_metadata: ptr::null(),
|
|
||||||
timestamp: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
let metadata_frame = NDIlib_metadata_frame_t {
|
|
||||||
length: 0,
|
|
||||||
timecode: 0,
|
|
||||||
p_data: ptr::null(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let frame_type = NDIlib_recv_capture_v2(pNDI_recv, &video_frame, &audio_frame, &metadata_frame, 1000);
|
let frame_type = NDIlib_recv_capture_v2(pNDI_recv, &video_frame, &audio_frame, &metadata_frame, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#![allow(non_camel_case_types, non_upper_case_globals)]
|
#![allow(non_camel_case_types, non_upper_case_globals)]
|
||||||
|
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
#[link(name = "ndi")]
|
#[link(name = "ndi")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn NDIlib_initialize() -> bool;
|
pub fn NDIlib_initialize() -> bool;
|
||||||
|
@ -43,6 +45,17 @@ pub struct NDIlib_find_create_t {
|
||||||
pub p_extra_ips: *const ::std::os::raw::c_char,
|
pub p_extra_ips: *const ::std::os::raw::c_char,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_find_create_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_find_create_t {
|
||||||
|
show_local_sources: true,
|
||||||
|
p_groups: ptr::null(),
|
||||||
|
p_extra_ips: ptr::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct NDIlib_source_t {
|
pub struct NDIlib_source_t {
|
||||||
|
@ -50,6 +63,15 @@ pub struct NDIlib_source_t {
|
||||||
pub p_ip_address: *const ::std::os::raw::c_char,
|
pub p_ip_address: *const ::std::os::raw::c_char,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_source_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_source_t {
|
||||||
|
p_ndi_name: ptr::null(),
|
||||||
|
p_ip_address: ptr::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO review enum
|
//TODO review enum
|
||||||
pub type NDIlib_frame_type_e = i32;
|
pub type NDIlib_frame_type_e = i32;
|
||||||
|
@ -89,6 +111,18 @@ pub struct NDIlib_recv_create_v3_t {
|
||||||
pub p_ndi_name: *const ::std::os::raw::c_char,
|
pub p_ndi_name: *const ::std::os::raw::c_char,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_recv_create_v3_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_recv_create_v3_t {
|
||||||
|
source_to_connect_to: Default::default(),
|
||||||
|
allow_video_fields: true,
|
||||||
|
bandwidth: NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest,
|
||||||
|
color_format: NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_BGRA,
|
||||||
|
p_ndi_name: ptr::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type NDIlib_recv_instance_t = *mut ::std::os::raw::c_void;
|
pub type NDIlib_recv_instance_t = *mut ::std::os::raw::c_void;
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,14 +133,36 @@ pub struct NDIlib_tally_t {
|
||||||
pub on_preview: bool,
|
pub on_preview: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_tally_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_tally_t {
|
||||||
|
on_program: false,
|
||||||
|
on_preview: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug,Copy,Clone)]
|
||||||
pub struct NDIlib_metadata_frame_t {
|
pub struct NDIlib_metadata_frame_t {
|
||||||
pub length: ::std::os::raw::c_int,
|
pub length: ::std::os::raw::c_int,
|
||||||
pub timecode: i64,
|
pub timecode: i64,
|
||||||
pub p_data: *const ::std::os::raw::c_char,
|
pub p_data: *const ::std::os::raw::c_char,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Default for NDIlib_metadata_frame_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_metadata_frame_t {
|
||||||
|
length: 0,
|
||||||
|
timecode: 0, //NDIlib_send_timecode_synthesize,
|
||||||
|
p_data: ptr::null()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug,Copy,Clone)]
|
||||||
pub struct NDIlib_video_frame_v2_t {
|
pub struct NDIlib_video_frame_v2_t {
|
||||||
|
@ -124,6 +180,25 @@ pub struct NDIlib_video_frame_v2_t {
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_video_frame_v2_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_video_frame_v2_t {
|
||||||
|
xres: 0,
|
||||||
|
yres: 0,
|
||||||
|
FourCC: 0,
|
||||||
|
frame_rate_N: 0,
|
||||||
|
frame_rate_D: 0,
|
||||||
|
picture_aspect_ratio: 0.0,
|
||||||
|
frame_format_type: 0,
|
||||||
|
timecode: 0, //NDIlib_send_timecode_synthesize,
|
||||||
|
p_data: ptr::null(),
|
||||||
|
line_stride_in_bytes: 0,
|
||||||
|
p_metadata: ptr::null(),
|
||||||
|
timestamp: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug,Copy,Clone)]
|
||||||
|
@ -137,3 +212,18 @@ pub struct NDIlib_audio_frame_v2_t {
|
||||||
pub p_metadata: *const ::std::os::raw::c_char,
|
pub p_metadata: *const ::std::os::raw::c_char,
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for NDIlib_audio_frame_v2_t {
|
||||||
|
fn default() -> Self {
|
||||||
|
NDIlib_audio_frame_v2_t {
|
||||||
|
sample_rate: 48000,
|
||||||
|
no_channels: 2,
|
||||||
|
no_samples: 0,
|
||||||
|
timecode: 0, //NDIlib_send_timecode_synthesize,
|
||||||
|
p_data: ptr::null(),
|
||||||
|
channel_stride_in_bytes: 0,
|
||||||
|
p_metadata: ptr::null(),
|
||||||
|
timestamp: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue