2017-07-07 11:47:28 +00:00
|
|
|
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2017-07-05 08:09:49 +00:00
|
|
|
use Element;
|
|
|
|
|
|
|
|
use glib;
|
|
|
|
use glib::IsA;
|
2017-07-31 11:16:42 +00:00
|
|
|
use glib::translate::{from_glib, ToGlibPtr};
|
2017-07-29 13:04:34 +00:00
|
|
|
use QueryRef;
|
2017-08-01 12:58:50 +00:00
|
|
|
use Event;
|
2017-07-29 13:04:34 +00:00
|
|
|
use miniobject::MiniObject;
|
2017-07-05 08:09:49 +00:00
|
|
|
|
|
|
|
use ffi;
|
|
|
|
|
|
|
|
impl Element {
|
|
|
|
pub fn link_many<E: IsA<Element>>(elements: &[&E]) -> Result<(), glib::BoolError> {
|
|
|
|
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
|
|
|
|
unsafe {
|
2017-07-10 21:33:24 +00:00
|
|
|
let ret: bool = from_glib(ffi::gst_element_link(
|
|
|
|
e1.to_glib_none().0,
|
|
|
|
e2.to_glib_none().0,
|
|
|
|
));
|
2017-07-05 08:09:49 +00:00
|
|
|
if !ret {
|
|
|
|
return Err(glib::BoolError("Failed to link elements"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-02 16:40:31 +00:00
|
|
|
Ok(())
|
2017-07-05 08:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn unlink_many<E: IsA<Element>>(elements: &[&E]) {
|
|
|
|
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_element_unlink(e1.to_glib_none().0, e2.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 13:04:34 +00:00
|
|
|
|
|
|
|
pub trait ElementExtManual {
|
|
|
|
fn query(&self, query: &mut QueryRef) -> bool;
|
2017-08-01 12:58:50 +00:00
|
|
|
|
|
|
|
fn send_event(&self, event: Event) -> bool;
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<Element>> ElementExtManual for O {
|
|
|
|
fn query(&self, query: &mut QueryRef) -> bool {
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_element_query(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-01 12:58:50 +00:00
|
|
|
|
|
|
|
fn send_event(&self, event: Event) -> bool {
|
|
|
|
unsafe {
|
2017-08-02 16:41:33 +00:00
|
|
|
from_glib(ffi::gst_element_send_event(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
2017-08-01 12:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|