2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-11-02 09:20:33 +00:00
|
|
|
|
2020-11-22 08:50:28 +00:00
|
|
|
use crate::TestClock;
|
2018-11-02 09:20:33 +00:00
|
|
|
use glib::translate::*;
|
2018-11-02 11:24:39 +00:00
|
|
|
use gst::prelude::*;
|
|
|
|
use std::marker::PhantomData;
|
2018-11-02 09:20:33 +00:00
|
|
|
use std::mem;
|
2018-11-02 12:32:09 +00:00
|
|
|
use std::ops;
|
2018-11-02 14:05:57 +00:00
|
|
|
use std::path;
|
2018-11-03 18:28:58 +00:00
|
|
|
use std::ptr;
|
2018-11-02 09:20:33 +00:00
|
|
|
|
2018-11-02 11:24:39 +00:00
|
|
|
#[derive(Debug)]
|
2021-06-01 13:15:59 +00:00
|
|
|
#[doc(alias = "GstHarness")]
|
2020-11-22 08:50:28 +00:00
|
|
|
pub struct Harness(ptr::NonNull<ffi::GstHarness>);
|
2018-11-02 09:20:33 +00:00
|
|
|
|
2018-11-02 11:24:39 +00:00
|
|
|
impl Drop for Harness {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_teardown(self.0.as_ptr());
|
2018-11-02 11:24:39 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 11:24:39 +00:00
|
|
|
unsafe impl Send for Harness {}
|
2019-12-18 15:04:42 +00:00
|
|
|
unsafe impl Sync for Harness {}
|
2018-11-02 11:24:39 +00:00
|
|
|
|
2018-11-02 09:20:33 +00:00
|
|
|
impl Harness {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_element_full")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn add_element_full<P: IsA<gst::Element>>(
|
2018-11-02 09:20:33 +00:00
|
|
|
&mut self,
|
|
|
|
element: &P,
|
2019-05-23 18:19:24 +00:00
|
|
|
hsrc: Option<&gst::StaticPadTemplate>,
|
|
|
|
element_sinkpad_name: Option<&str>,
|
|
|
|
hsink: Option<&gst::StaticPadTemplate>,
|
|
|
|
element_srcpad_name: Option<&str>,
|
2018-11-02 09:20:33 +00:00
|
|
|
) {
|
|
|
|
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
|
|
|
|
let element_srcpad_name = element_srcpad_name.to_glib_none();
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_element_full(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
2019-01-16 11:32:58 +00:00
|
|
|
element.as_ref().to_glib_none().0,
|
2018-11-02 11:24:39 +00:00
|
|
|
hsrc.to_glib_none().0 as *mut _,
|
2018-11-02 09:20:33 +00:00
|
|
|
element_sinkpad_name.0,
|
2018-11-02 11:24:39 +00:00
|
|
|
hsink.to_glib_none().0 as *mut _,
|
2018-11-02 09:20:33 +00:00
|
|
|
element_srcpad_name.0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_element_sink_pad")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_element_sink_pad<P: IsA<gst::Pad>>(&mut self, sinkpad: &P) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_element_sink_pad(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
sinkpad.as_ref().to_glib_none().0,
|
|
|
|
);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_element_src_pad")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_element_src_pad<P: IsA<gst::Pad>>(&mut self, srcpad: &P) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_element_src_pad(self.0.as_ptr(), srcpad.as_ref().to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_parse")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_parse(&mut self, launchline: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_parse(self.0.as_ptr(), launchline.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn add_probe<F>(
|
|
|
|
&mut self,
|
|
|
|
element_name: &str,
|
|
|
|
pad_name: &str,
|
|
|
|
mask: gst::PadProbeType,
|
|
|
|
func: F,
|
|
|
|
) where
|
|
|
|
F: Fn(&gst::Pad, &mut gst::PadProbeInfo) -> gst::PadProbeReturn + Send + Sync + 'static,
|
|
|
|
{
|
|
|
|
// Reimplementation of the C code so we don't have to duplicate all the callback code
|
|
|
|
|
|
|
|
let element = self.find_element(element_name).expect("Element not found");
|
2021-04-20 10:24:17 +00:00
|
|
|
let pad = element.static_pad(pad_name).expect("Pad not found");
|
2018-11-02 11:24:39 +00:00
|
|
|
pad.add_probe(mask, func);
|
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_propose_allocation_meta")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn add_propose_allocation_meta(
|
2018-11-02 09:20:33 +00:00
|
|
|
&mut self,
|
|
|
|
api: glib::types::Type,
|
2019-05-23 18:19:24 +00:00
|
|
|
params: Option<&gst::StructureRef>,
|
2018-11-02 09:20:33 +00:00
|
|
|
) {
|
|
|
|
unsafe {
|
2018-11-02 11:58:51 +00:00
|
|
|
let params = params.map(|p| p.as_ptr()).unwrap_or(ptr::null_mut());
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_harness_add_propose_allocation_meta(self.0.as_ptr(), api.into_glib(), params);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_sink")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_sink(&mut self, sink_element_name: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_sink(self.0.as_ptr(), sink_element_name.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_sink_harness")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn add_sink_harness(&mut self, sink_harness: Harness) {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-04-09 12:59:14 +00:00
|
|
|
let sink_harness = mem::ManuallyDrop::new(sink_harness);
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_sink_harness(self.0.as_ptr(), sink_harness.0.as_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_sink_parse")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_sink_parse(&mut self, launchline: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_sink_parse(self.0.as_ptr(), launchline.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_src")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_src(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
src_element_name.to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
has_clock_wait.into_glib(),
|
2018-11-02 09:20:33 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_src_harness")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool) {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-04-09 12:59:14 +00:00
|
|
|
let src_harness = mem::ManuallyDrop::new(src_harness);
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_src_harness(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
src_harness.0.as_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
has_clock_wait.into_glib(),
|
2018-11-02 09:20:33 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_add_src_parse")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_add_src_parse(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
launchline.to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
has_clock_wait.into_glib(),
|
2018-11-02 09:20:33 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_buffers_in_queue")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn buffers_in_queue(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_buffers_in_queue(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_buffers_received")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn buffers_received(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_buffers_received(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_crank_multiple_clock_waits")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn crank_multiple_clock_waits(&mut self, waits: u32) -> Result<(), glib::BoolError> {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_crank_multiple_clock_waits(self.0.as_ptr(), waits),
|
2018-11-02 11:24:39 +00:00
|
|
|
"Failed to crank multiple clock waits",
|
|
|
|
)
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_crank_single_clock_wait")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn crank_single_clock_wait(&mut self) -> Result<(), glib::BoolError> {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_crank_single_clock_wait(self.0.as_ptr()),
|
2018-11-02 11:24:39 +00:00
|
|
|
"Failed to crank single clock wait",
|
|
|
|
)
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_create_buffer")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn create_buffer(&mut self, size: usize) -> Result<gst::Buffer, glib::BoolError> {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_create_buffer(self.0.as_ptr(), size))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to create new buffer"))
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_dump_to_file")]
|
2021-09-21 21:49:26 +00:00
|
|
|
pub fn dump_to_file(&mut self, filename: impl AsRef<path::Path>) {
|
2018-11-02 11:24:39 +00:00
|
|
|
let filename = filename.as_ref();
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_dump_to_file(self.0.as_ptr(), filename.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_events_in_queue")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn events_in_queue(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_events_in_queue(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_events_received")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn events_received(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_events_received(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_find_element")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn find_element(&mut self, element_name: &str) -> Option<gst::Element> {
|
|
|
|
unsafe {
|
2018-11-13 12:45:20 +00:00
|
|
|
// Work around https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/31
|
2020-11-22 08:50:28 +00:00
|
|
|
let ptr = ffi::gst_harness_find_element(self.0.as_ptr(), element_name.to_glib_none().0);
|
2018-11-13 12:45:20 +00:00
|
|
|
|
|
|
|
if ptr.is_null() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear floating flag if it is set
|
2020-11-22 08:50:28 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
|
2018-11-13 12:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
from_glib_full(ptr)
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//pub fn get(&mut self, element_name: &str, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_get() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn get_allocator(&mut self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_get_allocator() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_last_pushed_timestamp")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_get_last_pushed_timestamp")]
|
2021-04-28 22:29:13 +00:00
|
|
|
pub fn last_pushed_timestamp(&self) -> Option<gst::ClockTime> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib(ffi::gst_harness_get_last_pushed_timestamp(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_testclock")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_get_testclock")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn testclock(&self) -> Option<TestClock> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_harness_get_testclock(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_play")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn play(&mut self) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_play(self.0.as_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_pull")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn pull(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_pull(self.0.as_ptr()))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to pull buffer"))
|
2019-12-17 19:00:42 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 18:12:51 +00:00
|
|
|
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_pull_until_eos")]
|
2021-03-25 18:12:51 +00:00
|
|
|
pub fn pull_until_eos(&mut self) -> Result<Option<gst::Buffer>, glib::BoolError> {
|
|
|
|
unsafe {
|
|
|
|
let mut buffer = ptr::null_mut();
|
|
|
|
let res = ffi::gst_harness_pull_until_eos(self.0.as_ptr(), &mut buffer);
|
|
|
|
if from_glib(res) {
|
|
|
|
Ok(from_glib_full(buffer))
|
|
|
|
} else {
|
|
|
|
Err(glib::bool_error!("Failed to pull buffer or EOS"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_pull_event")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn pull_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_pull_event(self.0.as_ptr()))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to pull event"))
|
2019-12-17 19:00:42 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_pull_upstream_event")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn pull_upstream_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_pull_upstream_event(self.0.as_ptr()))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to pull event"))
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push")]
|
2019-01-08 16:13:37 +00:00
|
|
|
pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2021-05-13 12:54:41 +00:00
|
|
|
unsafe { try_from_glib(ffi::gst_harness_push(self.0.as_ptr(), buffer.into_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push_and_pull")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn push_and_pull(&mut self, buffer: gst::Buffer) -> Result<gst::Buffer, glib::BoolError> {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_push_and_pull(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
buffer.into_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to push and pull buffer"))
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push_event")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn push_event(&mut self, event: gst::Event) -> bool {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
from_glib(ffi::gst_harness_push_event(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
event.into_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push_from_src")]
|
2019-01-08 16:13:37 +00:00
|
|
|
pub fn push_from_src(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2021-05-13 12:54:41 +00:00
|
|
|
unsafe { try_from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push_to_sink")]
|
2019-01-08 16:13:37 +00:00
|
|
|
pub fn push_to_sink(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2021-05-13 12:54:41 +00:00
|
|
|
unsafe { try_from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_push_upstream_event")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn push_upstream_event(&mut self, event: gst::Event) -> bool {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
from_glib(ffi::gst_harness_push_upstream_event(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
event.into_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_query_latency")]
|
2021-04-28 22:29:13 +00:00
|
|
|
pub fn query_latency(&self) -> Option<gst::ClockTime> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib(ffi::gst_harness_query_latency(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//pub fn set(&mut self, element_name: &str, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_set() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_blocking_push_mode")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_blocking_push_mode(&mut self) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_blocking_push_mode(self.0.as_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_caps")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn set_caps(&mut self, in_: gst::Caps, out: gst::Caps) {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_caps(self.0.as_ptr(), in_.into_ptr(), out.into_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_caps_str")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_caps_str(&mut self, in_: &str, out: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_caps_str(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
2018-11-02 09:20:33 +00:00
|
|
|
in_.to_glib_none().0,
|
|
|
|
out.to_glib_none().0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_drop_buffers")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_drop_buffers(&mut self, drop_buffers: bool) {
|
|
|
|
unsafe {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_harness_set_drop_buffers(self.0.as_ptr(), drop_buffers.into_glib());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_forwarding")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_forwarding(&mut self, forwarding: bool) {
|
|
|
|
unsafe {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_harness_set_forwarding(self.0.as_ptr(), forwarding.into_glib());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-03 15:45:53 +00:00
|
|
|
#[doc(alias = "gst_harness_set_live")]
|
|
|
|
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
|
|
|
pub fn set_live(&mut self, is_live: bool) {
|
|
|
|
unsafe { ffi::gst_harness_set_live(self.0.as_ptr(), is_live.into_glib()) }
|
|
|
|
}
|
|
|
|
|
2019-05-23 18:19:24 +00:00
|
|
|
//pub fn set_propose_allocator<P: IsA<gst::Allocator>>(&mut self, allocator: Option<&P>, params: Option<&gst::AllocationParams>) {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_set_propose_allocator() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_sink_caps")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn set_sink_caps(&mut self, caps: gst::Caps) {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_sink_caps(self.0.as_ptr(), caps.into_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_sink_caps_str")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_sink_caps_str(&mut self, str: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_sink_caps_str(self.0.as_ptr(), str.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_src_caps")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn set_src_caps(&mut self, caps: gst::Caps) {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_src_caps(self.0.as_ptr(), caps.into_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_src_caps_str")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_src_caps_str(&mut self, str: &str) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_set_src_caps_str(self.0.as_ptr(), str.to_glib_none().0);
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_time")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn set_time(&mut self, time: gst::ClockTime) -> Result<(), glib::BoolError> {
|
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_harness_set_time(self.0.as_ptr(), time.into_glib()),
|
2018-11-02 11:24:39 +00:00
|
|
|
"Failed to set time",
|
|
|
|
)
|
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_set_upstream_latency")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn set_upstream_latency(&mut self, latency: gst::ClockTime) {
|
|
|
|
unsafe {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_harness_set_upstream_latency(self.0.as_ptr(), latency.into_glib());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_sink_push_many")]
|
2019-01-08 16:13:37 +00:00
|
|
|
pub fn sink_push_many(&mut self, pushes: u32) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2021-04-28 12:34:56 +00:00
|
|
|
unsafe {
|
2021-05-13 12:54:41 +00:00
|
|
|
try_from_glib(ffi::gst_harness_sink_push_many(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
pushes as i32,
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
2021-04-28 12:34:56 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_src_crank_and_push_many")]
|
2019-01-08 16:13:37 +00:00
|
|
|
pub fn src_crank_and_push_many(
|
|
|
|
&mut self,
|
|
|
|
cranks: u32,
|
|
|
|
pushes: u32,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2021-04-28 12:34:56 +00:00
|
|
|
unsafe {
|
2021-05-13 12:54:41 +00:00
|
|
|
try_from_glib(ffi::gst_harness_src_crank_and_push_many(
|
2018-11-02 11:24:39 +00:00
|
|
|
self.0.as_ptr(),
|
|
|
|
cranks as i32,
|
|
|
|
pushes as i32,
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
2021-04-28 12:34:56 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_src_push_event")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn src_push_event(&mut self) -> bool {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib(ffi::gst_harness_src_push_event(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//pub fn stress_custom_start<'a, P: Into<Option<&'a /*Ignored*/glib::Func>>, Q: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&mut self, init: P, callback: /*Unknown conversion*//*Unimplemented*/Func, data: Q, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_custom_start() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_property_start_full(&mut self, name: &str, value: /*Ignored*/&glib::Value, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_property_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_buffer_start_full(&mut self, caps: &mut gst::Caps, segment: /*Ignored*/&gst::Segment, buf: &mut gst::Buffer, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_buffer_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_buffer_with_cb_start_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&mut self, caps: &mut gst::Caps, segment: /*Ignored*/&gst::Segment, func: /*Unknown conversion*//*Unimplemented*/HarnessPrepareBufferFunc, data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_buffer_with_cb_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_event_start_full(&mut self, event: &mut gst::Event, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_event_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_event_with_cb_start_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&mut self, func: /*Unknown conversion*//*Unimplemented*/HarnessPrepareEventFunc, data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_event_with_cb_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_upstream_event_start_full(&mut self, event: &mut gst::Event, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_upstream_event_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_push_upstream_event_with_cb_start_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&mut self, func: /*Unknown conversion*//*Unimplemented*/HarnessPrepareEventFunc, data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_push_upstream_event_with_cb_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_requestpad_start_full(&mut self, templ: /*Ignored*/&gst::PadTemplate, name: &str, caps: &mut gst::Caps, release: bool, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_requestpad_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
|
|
|
//pub fn stress_statechange_start_full(&mut self, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_statechange_start_full() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_take_all_data_as_buffer")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn take_all_data_as_buffer(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_buffer(self.0.as_ptr()))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to take all data as buffer"))
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_take_all_data_as_bytes")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn take_all_data_as_bytes(&mut self) -> Result<glib::Bytes, glib::BoolError> {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_bytes(self.0.as_ptr()))
|
2020-12-17 22:38:06 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to take all data as bytes"))
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_try_pull")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn try_pull(&mut self) -> Option<gst::Buffer> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_harness_try_pull(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_try_pull_event")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn try_pull_event(&mut self) -> Option<gst::Event> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_harness_try_pull_event(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_try_pull_upstream_event")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn try_pull_upstream_event(&mut self) -> Option<gst::Event> {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_harness_try_pull_upstream_event(self.0.as_ptr())) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_upstream_events_in_queue")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn upstream_events_in_queue(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_upstream_events_in_queue(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_upstream_events_received")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn upstream_events_received(&self) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { ffi::gst_harness_upstream_events_received(self.0.as_ptr()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_use_systemclock")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn use_systemclock(&mut self) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_use_systemclock(self.0.as_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_use_testclock")]
|
2018-11-02 09:20:33 +00:00
|
|
|
pub fn use_testclock(&mut self) {
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_use_testclock(self.0.as_ptr());
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_wait_for_clock_id_waits")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn wait_for_clock_id_waits(
|
|
|
|
&mut self,
|
|
|
|
waits: u32,
|
|
|
|
timeout: u32,
|
|
|
|
) -> Result<(), glib::BoolError> {
|
2018-11-02 09:20:33 +00:00
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-22 08:50:28 +00:00
|
|
|
ffi::gst_harness_wait_for_clock_id_waits(self.0.as_ptr(), waits, timeout),
|
2018-11-02 11:24:39 +00:00
|
|
|
"Failed to wait for clock id waits",
|
|
|
|
)
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe fn from_glib_full(ptr: *mut ffi::GstHarness) -> Harness {
|
2018-11-02 11:24:39 +00:00
|
|
|
assert!(!ptr.is_null());
|
|
|
|
|
2020-10-24 16:56:48 +00:00
|
|
|
Harness(ptr::NonNull::new_unchecked(ptr))
|
2018-11-02 11:24:39 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn new(element_name: &str) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { Self::from_glib_full(ffi::gst_harness_new(element_name.to_glib_none().0)) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_empty")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn new_empty() -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { Self::from_glib_full(ffi::gst_harness_new_empty()) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_full")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn new_full<P: IsA<gst::Element>>(
|
2018-11-02 09:20:33 +00:00
|
|
|
element: &P,
|
2019-05-23 18:19:24 +00:00
|
|
|
hsrc: Option<&gst::StaticPadTemplate>,
|
|
|
|
element_sinkpad_name: Option<&str>,
|
|
|
|
hsink: Option<&gst::StaticPadTemplate>,
|
|
|
|
element_srcpad_name: Option<&str>,
|
2018-11-02 11:24:39 +00:00
|
|
|
) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
|
|
|
|
let element_srcpad_name = element_srcpad_name.to_glib_none();
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Self::from_glib_full(ffi::gst_harness_new_full(
|
2019-01-16 11:32:58 +00:00
|
|
|
element.as_ref().to_glib_none().0,
|
2018-11-02 11:24:39 +00:00
|
|
|
hsrc.to_glib_none().0 as *mut _,
|
2018-11-02 09:20:33 +00:00
|
|
|
element_sinkpad_name.0,
|
2018-11-02 11:24:39 +00:00
|
|
|
hsink.to_glib_none().0 as *mut _,
|
2018-11-02 09:20:33 +00:00
|
|
|
element_srcpad_name.0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_parse")]
|
2018-11-02 11:24:39 +00:00
|
|
|
pub fn new_parse(launchline: &str) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-11-22 08:50:28 +00:00
|
|
|
unsafe { Self::from_glib_full(ffi::gst_harness_new_parse(launchline.to_glib_none().0)) }
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_with_element")]
|
2020-06-11 08:53:35 +00:00
|
|
|
pub fn with_element<P: IsA<gst::Element>>(
|
2018-11-02 09:20:33 +00:00
|
|
|
element: &P,
|
2019-05-23 18:19:24 +00:00
|
|
|
element_sinkpad_name: Option<&str>,
|
|
|
|
element_srcpad_name: Option<&str>,
|
2018-11-02 11:24:39 +00:00
|
|
|
) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
|
|
|
|
let element_srcpad_name = element_srcpad_name.to_glib_none();
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Self::from_glib_full(ffi::gst_harness_new_with_element(
|
2019-01-16 11:32:58 +00:00
|
|
|
element.as_ref().to_glib_none().0,
|
2018-11-02 09:20:33 +00:00
|
|
|
element_sinkpad_name.0,
|
|
|
|
element_srcpad_name.0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_with_padnames")]
|
2020-06-11 08:53:35 +00:00
|
|
|
pub fn with_padnames(
|
2018-11-02 09:20:33 +00:00
|
|
|
element_name: &str,
|
2019-05-23 18:19:24 +00:00
|
|
|
element_sinkpad_name: Option<&str>,
|
|
|
|
element_srcpad_name: Option<&str>,
|
2018-11-02 11:24:39 +00:00
|
|
|
) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
|
|
|
|
let element_srcpad_name = element_srcpad_name.to_glib_none();
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Self::from_glib_full(ffi::gst_harness_new_with_padnames(
|
2018-11-02 09:20:33 +00:00
|
|
|
element_name.to_glib_none().0,
|
|
|
|
element_sinkpad_name.0,
|
|
|
|
element_srcpad_name.0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_harness_new_with_templates")]
|
2020-06-11 08:53:35 +00:00
|
|
|
pub fn with_templates(
|
2018-11-02 09:20:33 +00:00
|
|
|
element_name: &str,
|
2019-05-23 18:19:24 +00:00
|
|
|
hsrc: Option<&gst::StaticPadTemplate>,
|
|
|
|
hsink: Option<&gst::StaticPadTemplate>,
|
2018-11-02 11:24:39 +00:00
|
|
|
) -> Harness {
|
2018-11-02 09:20:33 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-22 08:50:28 +00:00
|
|
|
Self::from_glib_full(ffi::gst_harness_new_with_templates(
|
2018-11-02 09:20:33 +00:00
|
|
|
element_name.to_glib_none().0,
|
2018-11-02 11:24:39 +00:00
|
|
|
hsrc.to_glib_none().0 as *mut _,
|
|
|
|
hsink.to_glib_none().0 as *mut _,
|
2018-11-02 09:20:33 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//pub fn stress_thread_stop(t: /*Ignored*/&mut HarnessThread) -> u32 {
|
2020-11-22 08:50:28 +00:00
|
|
|
// unsafe { TODO: call ffi::gst_harness_stress_thread_stop() }
|
2018-11-02 09:20:33 +00:00
|
|
|
//}
|
2018-11-02 12:32:09 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_element")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn element(&self) -> Option<gst::Element> {
|
2018-11-13 12:45:20 +00:00
|
|
|
unsafe {
|
|
|
|
// Work around https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/31
|
|
|
|
let ptr = (*self.0.as_ptr()).element;
|
|
|
|
|
|
|
|
if ptr.is_null() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear floating flag if it is set
|
2020-11-22 08:50:28 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
|
2018-11-13 12:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
from_glib_none(ptr)
|
|
|
|
}
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_sinkpad")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn sinkpad(&self) -> Option<gst::Pad> {
|
2018-11-13 12:45:20 +00:00
|
|
|
unsafe {
|
|
|
|
// Work around https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/31
|
|
|
|
let ptr = (*self.0.as_ptr()).sinkpad;
|
|
|
|
|
|
|
|
if ptr.is_null() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear floating flag if it is set
|
2020-11-22 08:50:28 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
|
2018-11-13 12:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
from_glib_none(ptr)
|
|
|
|
}
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_srcpad")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn srcpad(&self) -> Option<gst::Pad> {
|
2018-11-13 12:45:20 +00:00
|
|
|
unsafe {
|
|
|
|
// Work around https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/31
|
|
|
|
let ptr = (*self.0.as_ptr()).srcpad;
|
|
|
|
|
|
|
|
if ptr.is_null() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear floating flag if it is set
|
2020-11-22 08:50:28 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
|
2018-11-13 12:45:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
from_glib_none(ptr)
|
|
|
|
}
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_sink_harness")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn sink_harness(&self) -> Option<Ref> {
|
2018-11-02 12:32:09 +00:00
|
|
|
unsafe {
|
|
|
|
let sink_harness = (*self.0.as_ptr()).sink_harness;
|
|
|
|
if sink_harness.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(Ref(
|
2020-10-24 16:56:48 +00:00
|
|
|
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))),
|
2018-11-02 12:32:09 +00:00
|
|
|
PhantomData,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_src_harness")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn src_harness(&self) -> Option<Ref> {
|
2018-11-02 12:32:09 +00:00
|
|
|
unsafe {
|
|
|
|
let src_harness = (*self.0.as_ptr()).src_harness;
|
|
|
|
if src_harness.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(Ref(
|
2020-10-24 16:56:48 +00:00
|
|
|
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))),
|
2018-11-02 12:32:09 +00:00
|
|
|
PhantomData,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_mut_sink_harness")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn sink_harness_mut(&mut self) -> Option<RefMut> {
|
2018-11-02 12:32:09 +00:00
|
|
|
unsafe {
|
|
|
|
let sink_harness = (*self.0.as_ptr()).sink_harness;
|
|
|
|
if sink_harness.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(RefMut(
|
2020-10-24 16:56:48 +00:00
|
|
|
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(sink_harness))),
|
2018-11-02 12:32:09 +00:00
|
|
|
PhantomData,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_mut_src_harness")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn src_harness_mut(&mut self) -> Option<RefMut> {
|
2018-11-02 12:32:09 +00:00
|
|
|
unsafe {
|
|
|
|
let src_harness = (*self.0.as_ptr()).src_harness;
|
|
|
|
if src_harness.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(RefMut(
|
2020-10-24 16:56:48 +00:00
|
|
|
mem::ManuallyDrop::new(Harness(ptr::NonNull::new_unchecked(src_harness))),
|
2018-11-02 12:32:09 +00:00
|
|
|
PhantomData,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2020-03-09 10:55:14 +00:00
|
|
|
pub struct Ref<'a>(mem::ManuallyDrop<Harness>, PhantomData<&'a Harness>);
|
2018-11-02 12:32:09 +00:00
|
|
|
|
|
|
|
impl<'a> ops::Deref for Ref<'a> {
|
|
|
|
type Target = Harness;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Harness {
|
2020-03-09 10:55:14 +00:00
|
|
|
&*self.0
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2020-03-09 10:55:14 +00:00
|
|
|
pub struct RefMut<'a>(mem::ManuallyDrop<Harness>, PhantomData<&'a mut Harness>);
|
2018-11-02 12:32:09 +00:00
|
|
|
|
|
|
|
impl<'a> ops::Deref for RefMut<'a> {
|
|
|
|
type Target = Harness;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Harness {
|
2020-03-09 10:55:14 +00:00
|
|
|
&*self.0
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ops::DerefMut for RefMut<'a> {
|
|
|
|
fn deref_mut(&mut self) -> &mut Harness {
|
2020-03-09 10:55:14 +00:00
|
|
|
&mut *self.0
|
2018-11-02 12:32:09 +00:00
|
|
|
}
|
2018-11-02 09:20:33 +00:00
|
|
|
}
|
2018-11-02 11:24:39 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_identity_push_pull() {
|
|
|
|
gst::init().unwrap();
|
|
|
|
|
|
|
|
let mut h = Harness::new("identity");
|
2019-02-21 13:07:28 +00:00
|
|
|
h.set_src_caps_str("application/test");
|
2018-11-02 11:24:39 +00:00
|
|
|
let buf = gst::Buffer::new();
|
|
|
|
let buf = h.push_and_pull(buf);
|
2019-12-17 19:00:42 +00:00
|
|
|
assert!(buf.is_ok());
|
2018-11-02 11:24:39 +00:00
|
|
|
}
|
|
|
|
}
|