use crate::ffi;
use cxx::UniquePtr;
pub struct SpoutSender(UniquePtr<ffi::SpoutSender>);
unsafe impl Send for SpoutSender {}
impl SpoutSender {
pub fn new(name: &str) -> Self {
let mut inner = ffi::new_spout_sender();
inner.pin_mut().set_sender_name(name);
Self(inner)
}
pub fn send_texture(
&mut self,
tex_id: u32,
target: u32,
width: u32,
height: u32,
invert: bool,
) -> bool {
self.0
.pin_mut()
.send_texture(tex_id, target, width, height, invert, 0)
}
pub fn send_image(
&mut self,
pixels: &[u8],
width: u32,
height: u32,
gl_format: u32,
invert: bool,
) -> bool {
self.0
.pin_mut()
.send_image(pixels, width, height, gl_format, invert, 0)
}
pub fn is_initialized(&mut self) -> bool {
self.0.pin_mut().is_initialized()
}
pub fn name(&mut self) -> String {
self.0.pin_mut().get_name()
}
pub fn size(&mut self) -> (u32, u32) {
let w = self.0.pin_mut().get_width();
let h = self.0.pin_mut().get_height();
(w, h)
}
pub fn hold_fps(&mut self, fps: i32) {
self.0.pin_mut().hold_fps(fps);
}
pub fn send_image_rgba(&mut self, pixels: &[u8], width: u32, height: u32) -> bool {
const GL_RGBA: u32 = 0x1908;
self.send_image(pixels, width, height, GL_RGBA, false)
}
}
impl Drop for SpoutSender {
fn drop(&mut self) {
self.0.pin_mut().release_sender();
}
}