Close NDI stream when closing gstreamer

This commit is contained in:
Daniel Vilar 2018-06-04 13:44:27 +02:00
parent a89334a500
commit e8ee6fd806
2 changed files with 18 additions and 3 deletions

View file

@ -15,7 +15,8 @@ extern "C" {
pub fn NDIlib_recv_create_v3(
p_create_settings: *const NDIlib_recv_create_v3_t,
) -> NDIlib_recv_instance_t;
pub fn NDIlib_find_destroy(p_instance: NDIlib_find_instance_t);
pub fn NDIlib_find_destroy(p_instance: NDIlib_recv_instance_t);
pub fn NDIlib_recv_destroy(p_instance: NDIlib_recv_instance_t);
pub fn NDIlib_recv_set_tally(
p_instance: NDIlib_recv_instance_t,
p_tally: *const NDIlib_tally_t,

View file

@ -415,9 +415,23 @@ impl NdiSrc {
// Called when shutting down the element so we can release all stream-related state
fn stop(&self, element: &BaseSrc) -> bool {
// Reset state
*self.state.lock().unwrap() = Default::default();
let state = self.state.lock().unwrap();
let recv = match state.recv{
None => {
//println!("pNDI_recv no encontrado");
gst_element_error!(element, gst::CoreError::Negotiation, ["No encontramos ndi recv"]);
return true;
}
Some(ref recv) => recv.clone(),
};
let pNDI_recv = recv.recv;
unsafe{
NDIlib_recv_destroy(pNDI_recv);
//NDIlib_destroy();
}
// Commented because when adding ndi destroy stopped in this line
//*self.state.lock().unwrap() = Default::default();
self.unlock(element);
gst_info!(self.cat, obj: element, "Stopped");
true