mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-24 21:10:05 +00:00
Execute rustfmt
This commit is contained in:
parent
20b6ae5ff6
commit
98db99924e
2 changed files with 142 additions and 140 deletions
|
@ -1,14 +1,12 @@
|
||||||
#![allow(non_upper_case_globals, non_snake_case)]
|
#![allow(non_upper_case_globals, non_snake_case)]
|
||||||
|
|
||||||
|
|
||||||
pub mod ndilib;
|
pub mod ndilib;
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::{CString, CStr};
|
use std::ffi::{CStr, CString};
|
||||||
|
|
||||||
use ndilib::*;
|
use ndilib::*;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !NDIlib_initialize() {
|
if !NDIlib_initialize() {
|
||||||
|
@ -31,17 +29,21 @@ fn main() {
|
||||||
p_sources = NDIlib_find_get_current_sources(pNDI_find, &mut no_sources as *mut u32);
|
p_sources = NDIlib_find_get_current_sources(pNDI_find, &mut no_sources as *mut u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// We need at least one source
|
// We need at least one source
|
||||||
if p_sources.is_null() {
|
if p_sources.is_null() {
|
||||||
println!("Error getting NDIlib_find_get_current_sources.");
|
println!("Error getting NDIlib_find_get_current_sources.");
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("no_source {}: Name '{}' Address '{}'",
|
println!(
|
||||||
|
"no_source {}: Name '{}' Address '{}'",
|
||||||
no_sources,
|
no_sources,
|
||||||
CStr::from_ptr((*p_sources).p_ndi_name).to_string_lossy().into_owned(),
|
CStr::from_ptr((*p_sources).p_ndi_name)
|
||||||
CStr::from_ptr((*p_sources).p_ip_address).to_string_lossy().into_owned()
|
.to_string_lossy()
|
||||||
|
.into_owned(),
|
||||||
|
CStr::from_ptr((*p_sources).p_ip_address)
|
||||||
|
.to_string_lossy()
|
||||||
|
.into_owned()
|
||||||
);
|
);
|
||||||
|
|
||||||
// We now have at least one source, so we create a receiver to look at it.
|
// We now have at least one source, so we create a receiver to look at it.
|
||||||
|
@ -54,7 +56,6 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let pNDI_recv = NDIlib_recv_create_v3(&NDI_recv_create_desc);
|
let pNDI_recv = NDIlib_recv_create_v3(&NDI_recv_create_desc);
|
||||||
if pNDI_recv.is_null() {
|
if pNDI_recv.is_null() {
|
||||||
println!("Cannot run NDI: NDIlib_recv_create_v3 error.");
|
println!("Cannot run NDI: NDIlib_recv_create_v3 error.");
|
||||||
|
@ -68,7 +69,6 @@ fn main() {
|
||||||
let tally_state: NDIlib_tally_t = Default::default();
|
let tally_state: NDIlib_tally_t = Default::default();
|
||||||
NDIlib_recv_set_tally(pNDI_recv, &tally_state);
|
NDIlib_recv_set_tally(pNDI_recv, &tally_state);
|
||||||
|
|
||||||
|
|
||||||
// Enable Hardwqre Decompression support if this support has it. Please read the caveats in the documentation
|
// Enable Hardwqre Decompression support if this support has it. Please read the caveats in the documentation
|
||||||
// regarding this. There are times in which it might reduce the performance although on small stream numbers
|
// regarding this. There are times in which it might reduce the performance although on small stream numbers
|
||||||
// it almost always yields the same or better performance.
|
// it almost always yields the same or better performance.
|
||||||
|
@ -82,44 +82,47 @@ fn main() {
|
||||||
NDIlib_recv_send_metadata(pNDI_recv, &enable_hw_accel);
|
NDIlib_recv_send_metadata(pNDI_recv, &enable_hw_accel);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
||||||
let video_frame: NDIlib_video_frame_v2_t = Default::default();
|
let video_frame: NDIlib_video_frame_v2_t = Default::default();
|
||||||
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();
|
||||||
|
|
||||||
|
let frame_type = NDIlib_recv_capture_v2(
|
||||||
let frame_type = NDIlib_recv_capture_v2(pNDI_recv, &video_frame, &audio_frame, &metadata_frame, 1000);
|
pNDI_recv,
|
||||||
|
&video_frame,
|
||||||
|
&audio_frame,
|
||||||
|
&metadata_frame,
|
||||||
|
1000,
|
||||||
|
);
|
||||||
|
|
||||||
match frame_type {
|
match frame_type {
|
||||||
NDIlib_frame_type_video => {
|
NDIlib_frame_type_video => {
|
||||||
println!("Tengo video {:?}",
|
println!("Tengo video {:?}", video_frame);
|
||||||
video_frame
|
}
|
||||||
);
|
|
||||||
},
|
|
||||||
NDIlib_frame_type_audio => {
|
NDIlib_frame_type_audio => {
|
||||||
println!("Tengo audio {:?}",
|
println!("Tengo audio {:?}", audio_frame);
|
||||||
audio_frame
|
}
|
||||||
);
|
|
||||||
},
|
|
||||||
NDIlib_frame_type_metadata => {
|
NDIlib_frame_type_metadata => {
|
||||||
println!("Tengo metadata {} '{}'",
|
println!(
|
||||||
|
"Tengo metadata {} '{}'",
|
||||||
metadata_frame.length,
|
metadata_frame.length,
|
||||||
CStr::from_ptr(metadata_frame.p_data).to_string_lossy().into_owned(),
|
CStr::from_ptr(metadata_frame.p_data)
|
||||||
|
.to_string_lossy()
|
||||||
|
.into_owned(),
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
NDIlib_frame_type_error => {
|
NDIlib_frame_type_error => {
|
||||||
println!("Tengo error {} '{}'",
|
println!(
|
||||||
|
"Tengo error {} '{}'",
|
||||||
metadata_frame.length,
|
metadata_frame.length,
|
||||||
CStr::from_ptr(metadata_frame.p_data).to_string_lossy().into_owned(),
|
CStr::from_ptr(metadata_frame.p_data)
|
||||||
|
.to_string_lossy()
|
||||||
|
.into_owned(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
},
|
}
|
||||||
_ => println!("Tengo {}", frame_type),
|
_ => println!("Tengo {}", frame_type),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
println!("Exit");
|
println!("Exit");
|
||||||
}
|
}
|
|
@ -15,9 +15,7 @@ extern "C" {
|
||||||
pub fn NDIlib_recv_create_v3(
|
pub fn NDIlib_recv_create_v3(
|
||||||
p_create_settings: *const NDIlib_recv_create_v3_t,
|
p_create_settings: *const NDIlib_recv_create_v3_t,
|
||||||
) -> NDIlib_recv_instance_t;
|
) -> NDIlib_recv_instance_t;
|
||||||
pub fn NDIlib_find_destroy(
|
pub fn NDIlib_find_destroy(p_instance: NDIlib_find_instance_t);
|
||||||
p_instance: NDIlib_find_instance_t,
|
|
||||||
);
|
|
||||||
pub fn NDIlib_recv_set_tally(
|
pub fn NDIlib_recv_set_tally(
|
||||||
p_instance: NDIlib_recv_instance_t,
|
p_instance: NDIlib_recv_instance_t,
|
||||||
p_tally: *const NDIlib_tally_t,
|
p_tally: *const NDIlib_tally_t,
|
||||||
|
@ -50,12 +48,11 @@ impl Default for NDIlib_find_create_t {
|
||||||
NDIlib_find_create_t {
|
NDIlib_find_create_t {
|
||||||
show_local_sources: true,
|
show_local_sources: true,
|
||||||
p_groups: ptr::null(),
|
p_groups: ptr::null(),
|
||||||
p_extra_ips: 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 {
|
||||||
|
@ -67,12 +64,11 @@ impl Default for NDIlib_source_t {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NDIlib_source_t {
|
NDIlib_source_t {
|
||||||
p_ndi_name: ptr::null(),
|
p_ndi_name: ptr::null(),
|
||||||
p_ip_address: 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;
|
||||||
pub const NDIlib_frame_type_none: NDIlib_frame_type_e = 0;
|
pub const NDIlib_frame_type_none: NDIlib_frame_type_e = 0;
|
||||||
|
@ -82,27 +78,35 @@ pub const NDIlib_frame_type_metadata: NDIlib_frame_type_e = 3;
|
||||||
pub const NDIlib_frame_type_error: NDIlib_frame_type_e = 4;
|
pub const NDIlib_frame_type_error: NDIlib_frame_type_e = 4;
|
||||||
pub const NDIlib_frame_type_status_change: NDIlib_frame_type_e = 100;
|
pub const NDIlib_frame_type_status_change: NDIlib_frame_type_e = 100;
|
||||||
|
|
||||||
|
|
||||||
pub type NDIlib_recv_bandwidth_e = i32;
|
pub type NDIlib_recv_bandwidth_e = i32;
|
||||||
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_metadata_only: NDIlib_recv_bandwidth_e = -10;
|
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_metadata_only: NDIlib_recv_bandwidth_e =
|
||||||
|
-10;
|
||||||
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_audio_only: NDIlib_recv_bandwidth_e = 10;
|
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_audio_only: NDIlib_recv_bandwidth_e = 10;
|
||||||
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_lowest: NDIlib_recv_bandwidth_e = 0;
|
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_lowest: NDIlib_recv_bandwidth_e = 0;
|
||||||
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest: NDIlib_recv_bandwidth_e = 100;
|
pub const NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest: NDIlib_recv_bandwidth_e = 100;
|
||||||
|
|
||||||
|
|
||||||
pub type NDIlib_recv_color_format_e = u32;
|
pub type NDIlib_recv_color_format_e = u32;
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_BGRX_BGRA: NDIlib_recv_color_format_e = 0;
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_BGRX_BGRA:
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_BGRA: NDIlib_recv_color_format_e = 1;
|
NDIlib_recv_color_format_e = 0;
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_RGBX_RGBA: NDIlib_recv_color_format_e = 2;
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_BGRA:
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_RGBA: NDIlib_recv_color_format_e = 3;
|
NDIlib_recv_color_format_e = 1;
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_fastest: NDIlib_recv_color_format_e = 100;
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_RGBX_RGBA:
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_BGRX_BGRA: NDIlib_recv_color_format_e = 0;
|
NDIlib_recv_color_format_e = 2;
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_UYVY_BGRA: NDIlib_recv_color_format_e = 1;
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_RGBA:
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_RGBX_RGBA: NDIlib_recv_color_format_e = 2;
|
NDIlib_recv_color_format_e = 3;
|
||||||
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_UYVY_RGBA: NDIlib_recv_color_format_e = 3;
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_fastest: NDIlib_recv_color_format_e =
|
||||||
|
100;
|
||||||
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_BGRX_BGRA:
|
||||||
|
NDIlib_recv_color_format_e = 0;
|
||||||
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_UYVY_BGRA:
|
||||||
|
NDIlib_recv_color_format_e = 1;
|
||||||
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_RGBX_RGBA:
|
||||||
|
NDIlib_recv_color_format_e = 2;
|
||||||
|
pub const NDIlib_recv_color_format_e_NDIlib_recv_color_format_e_UYVY_RGBA:
|
||||||
|
NDIlib_recv_color_format_e = 3;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct NDIlib_recv_create_v3_t {
|
pub struct NDIlib_recv_create_v3_t {
|
||||||
pub source_to_connect_to: NDIlib_source_t,
|
pub source_to_connect_to: NDIlib_source_t,
|
||||||
pub color_format: NDIlib_recv_color_format_e,
|
pub color_format: NDIlib_recv_color_format_e,
|
||||||
|
@ -118,16 +122,15 @@ impl Default for NDIlib_recv_create_v3_t {
|
||||||
allow_video_fields: true,
|
allow_video_fields: true,
|
||||||
bandwidth: NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest,
|
bandwidth: NDIlib_recv_bandwidth_e_NDIlib_recv_bandwidth_highest,
|
||||||
color_format: NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_BGRA,
|
color_format: NDIlib_recv_color_format_e_NDIlib_recv_color_format_UYVY_BGRA,
|
||||||
p_ndi_name: ptr::null()
|
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;
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct NDIlib_tally_t {
|
pub struct NDIlib_tally_t {
|
||||||
pub on_program: bool,
|
pub on_program: bool,
|
||||||
pub on_preview: bool,
|
pub on_preview: bool,
|
||||||
|
@ -137,34 +140,31 @@ impl Default for NDIlib_tally_t {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NDIlib_tally_t {
|
NDIlib_tally_t {
|
||||||
on_program: false,
|
on_program: false,
|
||||||
on_preview: 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 {
|
impl Default for NDIlib_metadata_frame_t {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NDIlib_metadata_frame_t {
|
NDIlib_metadata_frame_t {
|
||||||
length: 0,
|
length: 0,
|
||||||
timecode: 0, //NDIlib_send_timecode_synthesize,
|
timecode: 0, //NDIlib_send_timecode_synthesize,
|
||||||
p_data: ptr::null()
|
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 {
|
||||||
pub xres: ::std::os::raw::c_int,
|
pub xres: ::std::os::raw::c_int,
|
||||||
pub yres: ::std::os::raw::c_int,
|
pub yres: ::std::os::raw::c_int,
|
||||||
|
@ -194,14 +194,13 @@ impl Default for NDIlib_video_frame_v2_t {
|
||||||
p_data: ptr::null(),
|
p_data: ptr::null(),
|
||||||
line_stride_in_bytes: 0,
|
line_stride_in_bytes: 0,
|
||||||
p_metadata: ptr::null(),
|
p_metadata: ptr::null(),
|
||||||
timestamp: 0
|
timestamp: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug,Copy,Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct NDIlib_audio_frame_v2_t {
|
pub struct NDIlib_audio_frame_v2_t {
|
||||||
pub sample_rate: ::std::os::raw::c_int,
|
pub sample_rate: ::std::os::raw::c_int,
|
||||||
pub no_channels: ::std::os::raw::c_int,
|
pub no_channels: ::std::os::raw::c_int,
|
||||||
|
@ -223,7 +222,7 @@ impl Default for NDIlib_audio_frame_v2_t {
|
||||||
p_data: ptr::null(),
|
p_data: ptr::null(),
|
||||||
channel_stride_in_bytes: 0,
|
channel_stride_in_bytes: 0,
|
||||||
p_metadata: ptr::null(),
|
p_metadata: ptr::null(),
|
||||||
timestamp: 0
|
timestamp: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue