gstreamer-check: Update manual code to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 10:50:28 +02:00
parent 2bb3385aaf
commit 240285ec0f
4 changed files with 126 additions and 184 deletions

View file

@ -11,29 +11,27 @@ homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_check/"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
edition = "2018"
[dependencies]
bitflags = "1.0"
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
gstreamer-check-sys = { path = "../gstreamer-check/sys", features = ["v1_8"] }
ffi = { package = "gstreamer-check-sys", path = "../gstreamer-check/sys", features = ["v1_8"] }
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { path = "../gstreamer" }
gst = { package = "gstreamer", path = "../gstreamer" }
[build-dependencies]
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
[features]
default = []
v1_10 = ["gstreamer/v1_10", "gstreamer-check-sys/v1_10"]
v1_12 = ["gstreamer/v1_12", "gstreamer-check-sys/v1_12", "v1_10"]
v1_14 = ["gstreamer/v1_14", "gstreamer-check-sys/v1_14", "v1_12"]
v1_16 = ["gstreamer/v1_16", "gstreamer-check-sys/v1_16", "v1_14"]
v1_18 = ["gstreamer/v1_18", "gstreamer-check-sys/v1_18", "v1_16"]
v1_10 = ["gst/v1_10", "ffi/v1_10"]
v1_12 = ["gst/v1_12", "ffi/v1_12", "v1_10"]
v1_14 = ["gst/v1_14", "ffi/v1_14", "v1_12"]
v1_16 = ["gst/v1_16", "ffi/v1_16", "v1_14"]
v1_18 = ["gst/v1_18", "ffi/v1_18", "v1_16"]
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
dox = ["v1_18", "gstreamer-check-sys/dox", "glib/dox", "gstreamer/dox"]
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox"]
[package.metadata.docs.rs]
features = ["dox", "embed-lgpl-docs"]

View file

@ -6,28 +6,23 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib;
use crate::TestClock;
use glib::object::IsA;
use glib::translate::*;
use glib_sys;
use gobject_sys;
use gst;
use gst::prelude::*;
use gst_check_sys;
use std::marker::PhantomData;
use std::mem;
use std::ops;
use std::path;
use std::ptr;
use TestClock;
#[derive(Debug)]
pub struct Harness(ptr::NonNull<gst_check_sys::GstHarness>);
pub struct Harness(ptr::NonNull<ffi::GstHarness>);
impl Drop for Harness {
fn drop(&mut self) {
unsafe {
gst_check_sys::gst_harness_teardown(self.0.as_ptr());
ffi::gst_harness_teardown(self.0.as_ptr());
}
}
}
@ -47,7 +42,7 @@ impl Harness {
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
gst_check_sys::gst_harness_add_element_full(
ffi::gst_harness_add_element_full(
self.0.as_ptr(),
element.as_ref().to_glib_none().0,
hsrc.to_glib_none().0 as *mut _,
@ -60,7 +55,7 @@ impl Harness {
pub fn add_element_sink_pad<P: IsA<gst::Pad>>(&mut self, sinkpad: &P) {
unsafe {
gst_check_sys::gst_harness_add_element_sink_pad(
ffi::gst_harness_add_element_sink_pad(
self.0.as_ptr(),
sinkpad.as_ref().to_glib_none().0,
);
@ -69,16 +64,13 @@ impl Harness {
pub fn add_element_src_pad<P: IsA<gst::Pad>>(&mut self, srcpad: &P) {
unsafe {
gst_check_sys::gst_harness_add_element_src_pad(
self.0.as_ptr(),
srcpad.as_ref().to_glib_none().0,
);
ffi::gst_harness_add_element_src_pad(self.0.as_ptr(), srcpad.as_ref().to_glib_none().0);
}
}
pub fn add_parse(&mut self, launchline: &str) {
unsafe {
gst_check_sys::gst_harness_add_parse(self.0.as_ptr(), launchline.to_glib_none().0);
ffi::gst_harness_add_parse(self.0.as_ptr(), launchline.to_glib_none().0);
}
}
@ -107,39 +99,32 @@ impl Harness {
) {
unsafe {
let params = params.map(|p| p.as_ptr()).unwrap_or(ptr::null_mut());
gst_check_sys::gst_harness_add_propose_allocation_meta(
self.0.as_ptr(),
api.to_glib(),
params,
);
ffi::gst_harness_add_propose_allocation_meta(self.0.as_ptr(), api.to_glib(), params);
}
}
pub fn add_sink(&mut self, sink_element_name: &str) {
unsafe {
gst_check_sys::gst_harness_add_sink(
self.0.as_ptr(),
sink_element_name.to_glib_none().0,
);
ffi::gst_harness_add_sink(self.0.as_ptr(), sink_element_name.to_glib_none().0);
}
}
pub fn add_sink_harness(&mut self, sink_harness: Harness) {
unsafe {
let sink_harness = mem::ManuallyDrop::new(sink_harness);
gst_check_sys::gst_harness_add_sink_harness(self.0.as_ptr(), sink_harness.0.as_ptr());
ffi::gst_harness_add_sink_harness(self.0.as_ptr(), sink_harness.0.as_ptr());
}
}
pub fn add_sink_parse(&mut self, launchline: &str) {
unsafe {
gst_check_sys::gst_harness_add_sink_parse(self.0.as_ptr(), launchline.to_glib_none().0);
ffi::gst_harness_add_sink_parse(self.0.as_ptr(), launchline.to_glib_none().0);
}
}
pub fn add_src(&mut self, src_element_name: &str, has_clock_wait: bool) {
unsafe {
gst_check_sys::gst_harness_add_src(
ffi::gst_harness_add_src(
self.0.as_ptr(),
src_element_name.to_glib_none().0,
has_clock_wait.to_glib(),
@ -150,7 +135,7 @@ impl Harness {
pub fn add_src_harness(&mut self, src_harness: Harness, has_clock_wait: bool) {
unsafe {
let src_harness = mem::ManuallyDrop::new(src_harness);
gst_check_sys::gst_harness_add_src_harness(
ffi::gst_harness_add_src_harness(
self.0.as_ptr(),
src_harness.0.as_ptr(),
has_clock_wait.to_glib(),
@ -160,7 +145,7 @@ impl Harness {
pub fn add_src_parse(&mut self, launchline: &str, has_clock_wait: bool) {
unsafe {
gst_check_sys::gst_harness_add_src_parse(
ffi::gst_harness_add_src_parse(
self.0.as_ptr(),
launchline.to_glib_none().0,
has_clock_wait.to_glib(),
@ -169,17 +154,17 @@ impl Harness {
}
pub fn buffers_in_queue(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_buffers_in_queue(self.0.as_ptr()) }
unsafe { ffi::gst_harness_buffers_in_queue(self.0.as_ptr()) }
}
pub fn buffers_received(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_buffers_received(self.0.as_ptr()) }
unsafe { ffi::gst_harness_buffers_received(self.0.as_ptr()) }
}
pub fn crank_multiple_clock_waits(&mut self, waits: u32) -> Result<(), glib::BoolError> {
unsafe {
glib_result_from_gboolean!(
gst_check_sys::gst_harness_crank_multiple_clock_waits(self.0.as_ptr(), waits),
glib::glib_result_from_gboolean!(
ffi::gst_harness_crank_multiple_clock_waits(self.0.as_ptr(), waits),
"Failed to crank multiple clock waits",
)
}
@ -187,8 +172,8 @@ impl Harness {
pub fn crank_single_clock_wait(&mut self) -> Result<(), glib::BoolError> {
unsafe {
glib_result_from_gboolean!(
gst_check_sys::gst_harness_crank_single_clock_wait(self.0.as_ptr()),
glib::glib_result_from_gboolean!(
ffi::gst_harness_crank_single_clock_wait(self.0.as_ptr()),
"Failed to crank single clock wait",
)
}
@ -196,44 +181,38 @@ impl Harness {
pub fn create_buffer(&mut self, size: usize) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_create_buffer(
self.0.as_ptr(),
size,
))
.ok_or_else(|| glib_bool_error!("Failed to create new buffer"))
Option::<_>::from_glib_full(ffi::gst_harness_create_buffer(self.0.as_ptr(), size))
.ok_or_else(|| glib::glib_bool_error!("Failed to create new buffer"))
}
}
pub fn dump_to_file<P: AsRef<path::Path>>(&mut self, filename: P) {
let filename = filename.as_ref();
unsafe {
gst_check_sys::gst_harness_dump_to_file(self.0.as_ptr(), filename.to_glib_none().0);
ffi::gst_harness_dump_to_file(self.0.as_ptr(), filename.to_glib_none().0);
}
}
pub fn events_in_queue(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_events_in_queue(self.0.as_ptr()) }
unsafe { ffi::gst_harness_events_in_queue(self.0.as_ptr()) }
}
pub fn events_received(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_events_received(self.0.as_ptr()) }
unsafe { ffi::gst_harness_events_received(self.0.as_ptr()) }
}
pub fn find_element(&mut self, element_name: &str) -> Option<gst::Element> {
unsafe {
// Work around https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/31
let ptr = gst_check_sys::gst_harness_find_element(
self.0.as_ptr(),
element_name.to_glib_none().0,
);
let ptr = ffi::gst_harness_find_element(self.0.as_ptr(), element_name.to_glib_none().0);
if ptr.is_null() {
return None;
}
// Clear floating flag if it is set
if gobject_sys::g_object_is_floating(ptr as *mut _) != glib_sys::GFALSE {
gobject_sys::g_object_ref_sink(ptr as *mut _);
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
}
from_glib_full(ptr)
@ -241,77 +220,67 @@ impl Harness {
}
//pub fn get(&mut self, element_name: &str, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call gst_check_sys::gst_harness_get() }
// unsafe { TODO: call ffi::gst_harness_get() }
//}
//pub fn get_allocator(&mut self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
// unsafe { TODO: call gst_check_sys::gst_harness_get_allocator() }
// unsafe { TODO: call ffi::gst_harness_get_allocator() }
//}
pub fn get_last_pushed_timestamp(&self) -> gst::ClockTime {
unsafe {
from_glib(gst_check_sys::gst_harness_get_last_pushed_timestamp(
self.0.as_ptr(),
))
}
unsafe { from_glib(ffi::gst_harness_get_last_pushed_timestamp(self.0.as_ptr())) }
}
pub fn get_testclock(&self) -> Option<TestClock> {
unsafe { from_glib_full(gst_check_sys::gst_harness_get_testclock(self.0.as_ptr())) }
unsafe { from_glib_full(ffi::gst_harness_get_testclock(self.0.as_ptr())) }
}
pub fn play(&mut self) {
unsafe {
gst_check_sys::gst_harness_play(self.0.as_ptr());
ffi::gst_harness_play(self.0.as_ptr());
}
}
pub fn pull(&mut self) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_pull(self.0.as_ptr()))
.ok_or_else(|| glib_bool_error!("Failed to pull buffer"))
Option::<_>::from_glib_full(ffi::gst_harness_pull(self.0.as_ptr()))
.ok_or_else(|| glib::glib_bool_error!("Failed to pull buffer"))
}
}
pub fn pull_event(&mut self) -> Result<gst::Event, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_pull_event(self.0.as_ptr()))
.ok_or_else(|| glib_bool_error!("Failed to pull event"))
Option::<_>::from_glib_full(ffi::gst_harness_pull_event(self.0.as_ptr()))
.ok_or_else(|| glib::glib_bool_error!("Failed to pull event"))
}
}
pub fn pull_upstream_event(&mut self) -> Result<gst::Event, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_pull_upstream_event(
self.0.as_ptr(),
))
.ok_or_else(|| glib_bool_error!("Failed to pull event"))
Option::<_>::from_glib_full(ffi::gst_harness_pull_upstream_event(self.0.as_ptr()))
.ok_or_else(|| glib::glib_bool_error!("Failed to pull event"))
}
}
pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_check_sys::gst_harness_push(
self.0.as_ptr(),
buffer.into_ptr(),
))
};
let ret: gst::FlowReturn =
unsafe { from_glib(ffi::gst_harness_push(self.0.as_ptr(), buffer.into_ptr())) };
ret.into_result()
}
pub fn push_and_pull(&mut self, buffer: gst::Buffer) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_push_and_pull(
Option::<_>::from_glib_full(ffi::gst_harness_push_and_pull(
self.0.as_ptr(),
buffer.into_ptr(),
))
.ok_or_else(|| glib_bool_error!("Failed to push and pull buffer"))
.ok_or_else(|| glib::glib_bool_error!("Failed to push and pull buffer"))
}
}
pub fn push_event(&mut self, event: gst::Event) -> bool {
unsafe {
from_glib(gst_check_sys::gst_harness_push_event(
from_glib(ffi::gst_harness_push_event(
self.0.as_ptr(),
event.into_ptr(),
))
@ -320,19 +289,19 @@ impl Harness {
pub fn push_from_src(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn =
unsafe { from_glib(gst_check_sys::gst_harness_push_from_src(self.0.as_ptr())) };
unsafe { from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) };
ret.into_result()
}
pub fn push_to_sink(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn =
unsafe { from_glib(gst_check_sys::gst_harness_push_to_sink(self.0.as_ptr())) };
unsafe { from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) };
ret.into_result()
}
pub fn push_upstream_event(&mut self, event: gst::Event) -> bool {
unsafe {
from_glib(gst_check_sys::gst_harness_push_upstream_event(
from_glib(ffi::gst_harness_push_upstream_event(
self.0.as_ptr(),
event.into_ptr(),
))
@ -340,28 +309,28 @@ impl Harness {
}
pub fn query_latency(&self) -> gst::ClockTime {
unsafe { from_glib(gst_check_sys::gst_harness_query_latency(self.0.as_ptr())) }
unsafe { from_glib(ffi::gst_harness_query_latency(self.0.as_ptr())) }
}
//pub fn set(&mut self, element_name: &str, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call gst_check_sys::gst_harness_set() }
// unsafe { TODO: call ffi::gst_harness_set() }
//}
pub fn set_blocking_push_mode(&mut self) {
unsafe {
gst_check_sys::gst_harness_set_blocking_push_mode(self.0.as_ptr());
ffi::gst_harness_set_blocking_push_mode(self.0.as_ptr());
}
}
pub fn set_caps(&mut self, in_: gst::Caps, out: gst::Caps) {
unsafe {
gst_check_sys::gst_harness_set_caps(self.0.as_ptr(), in_.into_ptr(), out.into_ptr());
ffi::gst_harness_set_caps(self.0.as_ptr(), in_.into_ptr(), out.into_ptr());
}
}
pub fn set_caps_str(&mut self, in_: &str, out: &str) {
unsafe {
gst_check_sys::gst_harness_set_caps_str(
ffi::gst_harness_set_caps_str(
self.0.as_ptr(),
in_.to_glib_none().0,
out.to_glib_none().0,
@ -371,48 +340,48 @@ impl Harness {
pub fn set_drop_buffers(&mut self, drop_buffers: bool) {
unsafe {
gst_check_sys::gst_harness_set_drop_buffers(self.0.as_ptr(), drop_buffers.to_glib());
ffi::gst_harness_set_drop_buffers(self.0.as_ptr(), drop_buffers.to_glib());
}
}
pub fn set_forwarding(&mut self, forwarding: bool) {
unsafe {
gst_check_sys::gst_harness_set_forwarding(self.0.as_ptr(), forwarding.to_glib());
ffi::gst_harness_set_forwarding(self.0.as_ptr(), forwarding.to_glib());
}
}
//pub fn set_propose_allocator<P: IsA<gst::Allocator>>(&mut self, allocator: Option<&P>, params: Option<&gst::AllocationParams>) {
// unsafe { TODO: call gst_check_sys::gst_harness_set_propose_allocator() }
// unsafe { TODO: call ffi::gst_harness_set_propose_allocator() }
//}
pub fn set_sink_caps(&mut self, caps: gst::Caps) {
unsafe {
gst_check_sys::gst_harness_set_sink_caps(self.0.as_ptr(), caps.into_ptr());
ffi::gst_harness_set_sink_caps(self.0.as_ptr(), caps.into_ptr());
}
}
pub fn set_sink_caps_str(&mut self, str: &str) {
unsafe {
gst_check_sys::gst_harness_set_sink_caps_str(self.0.as_ptr(), str.to_glib_none().0);
ffi::gst_harness_set_sink_caps_str(self.0.as_ptr(), str.to_glib_none().0);
}
}
pub fn set_src_caps(&mut self, caps: gst::Caps) {
unsafe {
gst_check_sys::gst_harness_set_src_caps(self.0.as_ptr(), caps.into_ptr());
ffi::gst_harness_set_src_caps(self.0.as_ptr(), caps.into_ptr());
}
}
pub fn set_src_caps_str(&mut self, str: &str) {
unsafe {
gst_check_sys::gst_harness_set_src_caps_str(self.0.as_ptr(), str.to_glib_none().0);
ffi::gst_harness_set_src_caps_str(self.0.as_ptr(), str.to_glib_none().0);
}
}
pub fn set_time(&mut self, time: gst::ClockTime) -> Result<(), glib::BoolError> {
unsafe {
glib_result_from_gboolean!(
gst_check_sys::gst_harness_set_time(self.0.as_ptr(), time.to_glib()),
glib::glib_result_from_gboolean!(
ffi::gst_harness_set_time(self.0.as_ptr(), time.to_glib()),
"Failed to set time",
)
}
@ -420,13 +389,13 @@ impl Harness {
pub fn set_upstream_latency(&mut self, latency: gst::ClockTime) {
unsafe {
gst_check_sys::gst_harness_set_upstream_latency(self.0.as_ptr(), latency.to_glib());
ffi::gst_harness_set_upstream_latency(self.0.as_ptr(), latency.to_glib());
}
}
pub fn sink_push_many(&mut self, pushes: u32) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_check_sys::gst_harness_sink_push_many(
from_glib(ffi::gst_harness_sink_push_many(
self.0.as_ptr(),
pushes as i32,
))
@ -440,7 +409,7 @@ impl Harness {
pushes: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_check_sys::gst_harness_src_crank_and_push_many(
from_glib(ffi::gst_harness_src_crank_and_push_many(
self.0.as_ptr(),
cranks as i32,
pushes as i32,
@ -450,57 +419,55 @@ impl Harness {
}
pub fn src_push_event(&mut self) -> bool {
unsafe { from_glib(gst_check_sys::gst_harness_src_push_event(self.0.as_ptr())) }
unsafe { from_glib(ffi::gst_harness_src_push_event(self.0.as_ptr())) }
}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_custom_start() }
// unsafe { TODO: call ffi::gst_harness_stress_custom_start() }
//}
//pub fn stress_property_start_full(&mut self, name: &str, value: /*Ignored*/&glib::Value, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_property_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_property_start_full() }
//}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_buffer_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_buffer_start_full() }
//}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_buffer_with_cb_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_buffer_with_cb_start_full() }
//}
//pub fn stress_push_event_start_full(&mut self, event: &mut gst::Event, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_event_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_event_start_full() }
//}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_event_with_cb_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_event_with_cb_start_full() }
//}
//pub fn stress_push_upstream_event_start_full(&mut self, event: &mut gst::Event, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_upstream_event_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_upstream_event_start_full() }
//}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_push_upstream_event_with_cb_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_push_upstream_event_with_cb_start_full() }
//}
//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> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_requestpad_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_requestpad_start_full() }
//}
//pub fn stress_statechange_start_full(&mut self, sleep: libc::c_ulong) -> /*Ignored*/Option<HarnessThread> {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_statechange_start_full() }
// unsafe { TODO: call ffi::gst_harness_stress_statechange_start_full() }
//}
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub fn take_all_data_as_buffer(&mut self) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_take_all_data_as_buffer(
self.0.as_ptr(),
))
.ok_or_else(|| glib_bool_error!("Failed to take all data as buffer"))
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_buffer(self.0.as_ptr()))
.ok_or_else(|| glib::glib_bool_error!("Failed to take all data as buffer"))
}
}
@ -508,46 +475,40 @@ impl Harness {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub fn take_all_data_as_bytes(&mut self) -> Result<glib::Bytes, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(gst_check_sys::gst_harness_take_all_data_as_bytes(
self.0.as_ptr(),
))
.ok_or_else(|| glib_bool_error!("Failed to take all data as bytes"))
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_bytes(self.0.as_ptr()))
.ok_or_else(|| glib::glib_bool_error!("Failed to take all data as bytes"))
}
}
pub fn try_pull(&mut self) -> Option<gst::Buffer> {
unsafe { from_glib_full(gst_check_sys::gst_harness_try_pull(self.0.as_ptr())) }
unsafe { from_glib_full(ffi::gst_harness_try_pull(self.0.as_ptr())) }
}
pub fn try_pull_event(&mut self) -> Option<gst::Event> {
unsafe { from_glib_full(gst_check_sys::gst_harness_try_pull_event(self.0.as_ptr())) }
unsafe { from_glib_full(ffi::gst_harness_try_pull_event(self.0.as_ptr())) }
}
pub fn try_pull_upstream_event(&mut self) -> Option<gst::Event> {
unsafe {
from_glib_full(gst_check_sys::gst_harness_try_pull_upstream_event(
self.0.as_ptr(),
))
}
unsafe { from_glib_full(ffi::gst_harness_try_pull_upstream_event(self.0.as_ptr())) }
}
pub fn upstream_events_in_queue(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_upstream_events_in_queue(self.0.as_ptr()) }
unsafe { ffi::gst_harness_upstream_events_in_queue(self.0.as_ptr()) }
}
pub fn upstream_events_received(&self) -> u32 {
unsafe { gst_check_sys::gst_harness_upstream_events_received(self.0.as_ptr()) }
unsafe { ffi::gst_harness_upstream_events_received(self.0.as_ptr()) }
}
pub fn use_systemclock(&mut self) {
unsafe {
gst_check_sys::gst_harness_use_systemclock(self.0.as_ptr());
ffi::gst_harness_use_systemclock(self.0.as_ptr());
}
}
pub fn use_testclock(&mut self) {
unsafe {
gst_check_sys::gst_harness_use_testclock(self.0.as_ptr());
ffi::gst_harness_use_testclock(self.0.as_ptr());
}
}
@ -557,14 +518,14 @@ impl Harness {
timeout: u32,
) -> Result<(), glib::BoolError> {
unsafe {
glib_result_from_gboolean!(
gst_check_sys::gst_harness_wait_for_clock_id_waits(self.0.as_ptr(), waits, timeout),
glib::glib_result_from_gboolean!(
ffi::gst_harness_wait_for_clock_id_waits(self.0.as_ptr(), waits, timeout),
"Failed to wait for clock id waits",
)
}
}
unsafe fn from_glib_full(ptr: *mut gst_check_sys::GstHarness) -> Harness {
unsafe fn from_glib_full(ptr: *mut ffi::GstHarness) -> Harness {
assert!(!ptr.is_null());
Harness(ptr::NonNull::new_unchecked(ptr))
@ -572,16 +533,12 @@ impl Harness {
pub fn new(element_name: &str) -> Harness {
assert_initialized_main_thread!();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new(
element_name.to_glib_none().0,
))
}
unsafe { Self::from_glib_full(ffi::gst_harness_new(element_name.to_glib_none().0)) }
}
pub fn new_empty() -> Harness {
assert_initialized_main_thread!();
unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_empty()) }
unsafe { Self::from_glib_full(ffi::gst_harness_new_empty()) }
}
pub fn new_full<P: IsA<gst::Element>>(
@ -595,7 +552,7 @@ impl Harness {
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new_full(
Self::from_glib_full(ffi::gst_harness_new_full(
element.as_ref().to_glib_none().0,
hsrc.to_glib_none().0 as *mut _,
element_sinkpad_name.0,
@ -607,11 +564,7 @@ impl Harness {
pub fn new_parse(launchline: &str) -> Harness {
assert_initialized_main_thread!();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new_parse(
launchline.to_glib_none().0,
))
}
unsafe { Self::from_glib_full(ffi::gst_harness_new_parse(launchline.to_glib_none().0)) }
}
pub fn with_element<P: IsA<gst::Element>>(
@ -623,7 +576,7 @@ impl Harness {
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new_with_element(
Self::from_glib_full(ffi::gst_harness_new_with_element(
element.as_ref().to_glib_none().0,
element_sinkpad_name.0,
element_srcpad_name.0,
@ -640,7 +593,7 @@ impl Harness {
let element_sinkpad_name = element_sinkpad_name.to_glib_none();
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new_with_padnames(
Self::from_glib_full(ffi::gst_harness_new_with_padnames(
element_name.to_glib_none().0,
element_sinkpad_name.0,
element_srcpad_name.0,
@ -655,7 +608,7 @@ impl Harness {
) -> Harness {
assert_initialized_main_thread!();
unsafe {
Self::from_glib_full(gst_check_sys::gst_harness_new_with_templates(
Self::from_glib_full(ffi::gst_harness_new_with_templates(
element_name.to_glib_none().0,
hsrc.to_glib_none().0 as *mut _,
hsink.to_glib_none().0 as *mut _,
@ -664,7 +617,7 @@ impl Harness {
}
//pub fn stress_thread_stop(t: /*Ignored*/&mut HarnessThread) -> u32 {
// unsafe { TODO: call gst_check_sys::gst_harness_stress_thread_stop() }
// unsafe { TODO: call ffi::gst_harness_stress_thread_stop() }
//}
pub fn get_element(&self) -> Option<gst::Element> {
@ -677,8 +630,8 @@ impl Harness {
}
// Clear floating flag if it is set
if gobject_sys::g_object_is_floating(ptr as *mut _) != glib_sys::GFALSE {
gobject_sys::g_object_ref_sink(ptr as *mut _);
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
}
from_glib_none(ptr)
@ -695,8 +648,8 @@ impl Harness {
}
// Clear floating flag if it is set
if gobject_sys::g_object_is_floating(ptr as *mut _) != glib_sys::GFALSE {
gobject_sys::g_object_ref_sink(ptr as *mut _);
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
}
from_glib_none(ptr)
@ -713,8 +666,8 @@ impl Harness {
}
// Clear floating flag if it is set
if gobject_sys::g_object_is_floating(ptr as *mut _) != glib_sys::GFALSE {
gobject_sys::g_object_ref_sink(ptr as *mut _);
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
}
from_glib_none(ptr)

View file

@ -8,18 +8,11 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))]
extern crate glib_sys;
extern crate gobject_sys;
extern crate gstreamer as gst;
extern crate gstreamer_check_sys as gst_check_sys;
extern crate gstreamer_sys as gst_sys;
#[macro_use]
extern crate glib;
pub use ffi;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
@ -30,12 +23,12 @@ macro_rules! assert_initialized_main_thread {
#[allow(clippy::match_same_arms)]
#[allow(clippy::type_complexity)]
mod auto;
pub use auto::*;
pub use crate::auto::*;
mod test_clock;
pub mod harness;
pub use harness::Harness;
pub use crate::harness::Harness;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
@ -43,5 +36,5 @@ pub mod prelude {
pub use glib::prelude::*;
pub use gst::prelude::*;
pub use auto::traits::*;
pub use crate::auto::traits::*;
}

View file

@ -6,16 +6,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::TestClock;
use glib::translate::*;
use gst;
use gst_check_sys;
use std::ptr;
use TestClock;
impl TestClock {
pub fn has_id(&self, id: &gst::ClockId) -> bool {
unsafe {
from_glib(gst_check_sys::gst_test_clock_has_id(
from_glib(ffi::gst_test_clock_has_id(
self.to_glib_none().0,
id.to_glib_none().0,
))
@ -25,7 +23,7 @@ impl TestClock {
pub fn peek_next_pending_id(&self) -> Option<gst::ClockId> {
unsafe {
let mut id = ptr::null_mut();
let ret: bool = from_glib(gst_check_sys::gst_test_clock_peek_next_pending_id(
let ret: bool = from_glib(ffi::gst_test_clock_peek_next_pending_id(
self.to_glib_none().0,
&mut id,
));
@ -41,7 +39,7 @@ impl TestClock {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
pub fn process_id(&self, pending_id: &gst::ClockId) -> bool {
unsafe {
from_glib(gst_check_sys::gst_test_clock_process_id(
from_glib(ffi::gst_test_clock_process_id(
self.to_glib_none().0,
pending_id.to_glib_none().0,
))
@ -50,7 +48,7 @@ impl TestClock {
pub fn process_id_list(&self, pending_list: &[&gst::ClockId]) -> u32 {
unsafe {
gst_check_sys::gst_test_clock_process_id_list(
ffi::gst_test_clock_process_id_list(
self.to_glib_none().0,
pending_list.to_glib_none().0,
)
@ -59,7 +57,7 @@ impl TestClock {
pub fn process_next_clock_id(&self) -> Option<gst::ClockId> {
unsafe {
from_glib_full(gst_check_sys::gst_test_clock_process_next_clock_id(
from_glib_full(ffi::gst_test_clock_process_next_clock_id(
self.to_glib_none().0,
))
}
@ -68,7 +66,7 @@ impl TestClock {
pub fn wait_for_multiple_pending_ids(&self, count: u32) -> Vec<gst::ClockId> {
unsafe {
let mut pending_list = ptr::null_mut();
gst_check_sys::gst_test_clock_wait_for_multiple_pending_ids(
ffi::gst_test_clock_wait_for_multiple_pending_ids(
self.to_glib_none().0,
count,
&mut pending_list,
@ -80,7 +78,7 @@ impl TestClock {
pub fn wait_for_next_pending_id(&self) -> gst::ClockId {
unsafe {
let mut id = ptr::null_mut();
gst_check_sys::gst_test_clock_wait_for_next_pending_id(self.to_glib_none().0, &mut id);
ffi::gst_test_clock_wait_for_next_pending_id(self.to_glib_none().0, &mut id);
from_glib_full(id)
}
}
@ -94,7 +92,7 @@ impl TestClock {
) -> (bool, Vec<gst::ClockId>) {
unsafe {
let mut pending_list = ptr::null_mut();
let res = gst_check_sys::gst_test_clock_timed_wait_for_multiple_pending_ids(
let res = ffi::gst_test_clock_timed_wait_for_multiple_pending_ids(
self.to_glib_none().0,
count,
timeout_ms,