use std::mem::MaybeUninit;
use std::os::raw::{c_long, c_void};
include!(concat!(env!("OUT_DIR"), "/tsduck_version.rs"));
pub type LogCallback = unsafe extern "C" fn(severity: i32, message: *const u8, size: usize);
pub type PluginCallback = unsafe extern "C" fn(
event_code: u32,
plugin_name: *const u8,
plugin_name_size: usize,
plugin_index: usize,
plugin_count: usize,
bitrate: usize,
plugin_packets: usize,
total_packets: usize,
data: *const u8,
data_size: usize,
data_max_size: usize,
data_read_only: bool,
event_data: *mut c_void,
) -> bool;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TspyAbiLayout {
pub tsduck_header_version_major: u32,
pub tsduck_header_version_minor: u32,
pub ts_processor_args_size: usize,
pub ts_processor_args_align: usize,
pub ts_processor_args_offsets: [usize; 16],
pub input_switcher_args_size: usize,
pub input_switcher_args_align: usize,
pub input_switcher_args_offsets: [usize; 23],
pub uint32_size: usize,
pub uint32_align: usize,
pub size_t_size: usize,
pub size_t_align: usize,
pub bool_size: usize,
pub bool_align: usize,
pub long_size: usize,
pub long_align: usize,
}
#[must_use]
pub fn tspy_abi_layout() -> TspyAbiLayout {
let mut layout = MaybeUninit::<TspyAbiLayout>::uninit();
unsafe {
rustduck_tspy_query_abi_layout(layout.as_mut_ptr());
layout.assume_init()
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct TSProcessorArgs {
pub ignore_joint_termination: c_long,
pub buffer_size: c_long,
pub max_flushed_packets: c_long,
pub max_input_packets: c_long,
pub max_output_packets: c_long,
pub initial_input_packets: c_long,
pub add_input_stuffing_0: c_long,
pub add_input_stuffing_1: c_long,
pub add_start_stuffing: c_long,
pub add_stop_stuffing: c_long,
pub bitrate: c_long,
pub bitrate_adjust_interval: c_long,
pub receive_timeout: c_long,
pub log_plugin_index: c_long,
pub plugins: *mut u8,
pub plugins_size: usize,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct InputSwitcherArgs {
pub fast_switch: c_long,
pub delayed_switch: c_long,
pub terminate: c_long,
pub reuse_port: c_long,
pub first_input: c_long,
pub primary_input: c_long,
pub cycle_count: c_long,
pub buffered_packets: c_long,
pub max_input_packets: c_long,
pub max_output_packets: c_long,
pub sock_buffer: c_long,
pub remote_server_port: c_long,
pub receive_timeout: c_long,
pub plugins: *mut u8,
pub plugins_size: usize,
pub event_command: *mut u8,
pub event_command_size: usize,
pub event_udp_addr: *mut u8,
pub event_udp_addr_size: usize,
pub event_udp_port: c_long,
pub local_addr: *mut u8,
pub local_addr_size: usize,
pub event_ttl: c_long,
}
unsafe extern "C" {
fn rustduck_tspy_query_abi_layout(layout: *mut TspyAbiLayout);
pub fn tspyVersionInteger() -> u32;
pub fn tspyVersionString(buffer: *mut u8, size: *mut usize);
pub fn tspyNullReport() -> *mut c_void;
pub fn tspyStdErrReport() -> *mut c_void;
pub fn tspyNewAsyncReport(
severity: i32,
sync_log: bool,
timed_log: bool,
log_msg_count: usize,
) -> *mut c_void;
pub fn tspyNewPySyncReport(callback: LogCallback, severity: i32) -> *mut c_void;
pub fn tspyNewPyAsyncReport(
callback: LogCallback,
severity: i32,
sync_log: bool,
log_msg_count: usize,
) -> *mut c_void;
pub fn tspyDeleteReport(report: *mut c_void);
pub fn tspyTerminateAsyncReport(report: *mut c_void);
pub fn tspySetMaxSeverity(report: *mut c_void, severity: i32);
pub fn tspyLogReport(report: *mut c_void, severity: i32, message: *const u8, size: usize);
pub fn tspyReportHeader(severity: i32, buffer: *mut u8, size: *mut usize);
pub fn tspyNewDuckContext(report: *mut c_void) -> *mut c_void;
pub fn tspyDeleteDuckContext(duck: *mut c_void);
pub fn tspyDuckContextSetDefaultCharset(
duck: *mut c_void,
name: *const u8,
size: usize,
) -> bool;
pub fn tspyDuckContextSetDefaultCASId(duck: *mut c_void, cas: u16);
pub fn tspyDuckContextSetDefaultPDS(duck: *mut c_void, pds: u32);
pub fn tspyDuckContextAddStandards(duck: *mut c_void, mask: u32);
pub fn tspyDuckContextStandards(duck: *mut c_void) -> u32;
pub fn tspyDuckContextResetStandards(duck: *mut c_void, mask: u32);
pub fn tspyDuckContextSetTimeReferenceOffset(duck: *mut c_void, offset: i64);
pub fn tspyDuckContextSetTimeReference(duck: *mut c_void, name: *const u8, size: usize)
-> bool;
pub fn tspyNewPyPluginEventHandler(callback: PluginCallback) -> *mut c_void;
pub fn tspyDeletePyPluginEventHandler(handler: *mut c_void);
pub fn tspyPyPluginEventHandlerUpdateData(
event_data: *mut c_void,
data: *mut c_void,
size: usize,
);
pub fn tspyNewSectionFile(duck: *mut c_void) -> *mut c_void;
pub fn tspyDeleteSectionFile(section_file: *mut c_void);
pub fn tspySectionFileClear(section_file: *mut c_void);
pub fn tspySectionFileBinarySize(section_file: *mut c_void) -> usize;
pub fn tspySectionFileSectionsCount(section_file: *mut c_void) -> usize;
pub fn tspySectionFileTablesCount(section_file: *mut c_void) -> usize;
pub fn tspySectionFileSetCRCValidation(section_file: *mut c_void, mode: i32);
pub fn tspySectionLoadBuffer(section_file: *mut c_void, buffer: *const u8, size: usize)
-> bool;
pub fn tspySectionSaveBuffer(section_file: *mut c_void, buffer: *mut u8, size: *mut usize);
pub fn tspySectionFileLoadBinary(
section_file: *mut c_void,
name: *const u8,
size: usize,
) -> bool;
pub fn tspySectionFileSaveBinary(
section_file: *mut c_void,
name: *const u8,
size: usize,
) -> bool;
pub fn tspySectionFileLoadXML(section_file: *mut c_void, name: *const u8, size: usize) -> bool;
pub fn tspySectionFileSaveXML(section_file: *mut c_void, name: *const u8, size: usize) -> bool;
pub fn tspySectionFileSaveJSON(section_file: *mut c_void, name: *const u8, size: usize)
-> bool;
pub fn tspySectionFileToXML(
section_file: *mut c_void,
buffer: *mut u8,
size: *mut usize,
) -> usize;
pub fn tspySectionFileToJSON(
section_file: *mut c_void,
buffer: *mut u8,
size: *mut usize,
) -> usize;
pub fn tspySectionFileReorganizeEITs(
section_file: *mut c_void,
year: i32,
month: i32,
day: i32,
);
pub fn tspyNewSystemMonitor(
report: *mut c_void,
config: *const u8,
config_size: usize,
) -> *mut c_void;
pub fn tspyDeleteSystemMonitor(monitor: *mut c_void);
pub fn tspyStartSystemMonitor(monitor: *mut c_void);
pub fn tspyStopSystemMonitor(monitor: *mut c_void);
pub fn tspyWaitSystemMonitor(monitor: *mut c_void);
pub fn tspyPluginEventHandlerRegister(
registry: *mut c_void,
handler: *mut c_void,
event_code: u32,
);
pub fn tspyPluginEventHandlerRegisterInput(registry: *mut c_void, handler: *mut c_void);
pub fn tspyPluginEventHandlerRegisterOutput(registry: *mut c_void, handler: *mut c_void);
pub fn tspyNewTSProcessor(report: *mut c_void) -> *mut c_void;
pub fn tspyDeleteTSProcessor(processor: *mut c_void);
pub fn tspyStartTSProcessor(processor: *mut c_void, args: *const TSProcessorArgs) -> bool;
pub fn tspyAbortTSProcessor(processor: *mut c_void);
pub fn tspyWaitTSProcessor(processor: *mut c_void);
pub fn tspyNewInputSwitcher(report: *mut c_void) -> *mut c_void;
pub fn tspyDeleteInputSwitcher(switcher: *mut c_void);
pub fn tspyStartInputSwitcher(switcher: *mut c_void, args: *const InputSwitcherArgs) -> bool;
pub fn tspyInputSwitcherSetInput(switcher: *mut c_void, index: usize);
pub fn tspyInputSwitcherNextInput(switcher: *mut c_void);
pub fn tspyInputSwitcherPreviousInput(switcher: *mut c_void);
pub fn tspyInputSwitcherCurrentInput(switcher: *mut c_void) -> usize;
pub fn tspyStopInputSwitcher(switcher: *mut c_void);
pub fn tspyWaitInputSwitcher(switcher: *mut c_void);
}