forked from mirrors/gstreamer-rs
gstreamer-app: Update manual code to 2018 edition
This commit is contained in:
parent
e7843d68d0
commit
5a70dd1756
4 changed files with 62 additions and 105 deletions
|
@ -11,19 +11,17 @@ homepage = "https://gstreamer.freedesktop.org"
|
||||||
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_app/"
|
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_app/"
|
||||||
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures-core = "0.3"
|
futures-core = "0.3"
|
||||||
futures-sink = "0.3"
|
futures-sink = "0.3"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
ffi = { package = "gstreamer-app-sys", path = "../gstreamer-app/sys", features = ["v1_8"] }
|
||||||
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
|
||||||
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
|
|
||||||
gstreamer-app-sys = { path = "../gstreamer-app/sys", features = ["v1_8"] }
|
|
||||||
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||||
gstreamer = { path = "../gstreamer" }
|
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||||
gstreamer-base = { path = "../gstreamer-base" }
|
gst-base = { package = "gstreamer-base", path = "../gstreamer-base" }
|
||||||
once_cell = "1.0"
|
once_cell = "1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -35,14 +33,14 @@ futures-executor = "0.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-app-sys/v1_10"]
|
v1_10 = ["gst/v1_10", "gst-base/v1_10", "ffi/v1_10"]
|
||||||
v1_12 = ["gstreamer/v1_12", "gstreamer-base/v1_12", "gstreamer-app-sys/v1_12", "v1_10"]
|
v1_12 = ["gst/v1_12", "gst-base/v1_12", "ffi/v1_12", "v1_10"]
|
||||||
v1_14 = ["gstreamer/v1_14", "gstreamer-base/v1_14", "gstreamer-app-sys/v1_14", "v1_12"]
|
v1_14 = ["gst/v1_14", "gst-base/v1_14", "ffi/v1_14", "v1_12"]
|
||||||
v1_16 = ["gstreamer/v1_16", "gstreamer-base/v1_16", "gstreamer-app-sys/v1_16", "v1_14"]
|
v1_16 = ["gst/v1_16", "gst-base/v1_16", "ffi/v1_16", "v1_14"]
|
||||||
v1_18 = ["gstreamer/v1_18", "gstreamer-base/v1_18", "gstreamer-app-sys/v1_18", "v1_16"]
|
v1_18 = ["gst/v1_18", "gst-base/v1_18", "ffi/v1_18", "v1_16"]
|
||||||
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
dox = ["v1_18", "gstreamer-app-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox"]
|
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox", "gst-base/dox"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["dox", "embed-lgpl-docs"]
|
features = ["dox", "embed-lgpl-docs"]
|
||||||
|
|
|
@ -6,22 +6,18 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
use crate::AppSink;
|
||||||
|
use glib::ffi::gpointer;
|
||||||
use glib::object::ObjectType;
|
use glib::object::ObjectType;
|
||||||
use glib::signal::connect_raw;
|
use glib::signal::connect_raw;
|
||||||
use glib::signal::SignalHandlerId;
|
use glib::signal::SignalHandlerId;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib_sys::gpointer;
|
|
||||||
use gst;
|
|
||||||
use gst::gst_element_error;
|
|
||||||
use gst_app_sys;
|
|
||||||
use gst_sys;
|
|
||||||
use std::boxed::Box as Box_;
|
use std::boxed::Box as Box_;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use AppSink;
|
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_10"))]
|
#[cfg(any(feature = "v1_10"))]
|
||||||
use {
|
use {
|
||||||
|
@ -48,7 +44,7 @@ pub struct AppSinkCallbacks {
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
panicked: AtomicBool,
|
panicked: AtomicBool,
|
||||||
callbacks: gst_app_sys::GstAppSinkCallbacks,
|
callbacks: ffi::GstAppSinkCallbacks,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for AppSinkCallbacks {}
|
unsafe impl Send for AppSinkCallbacks {}
|
||||||
|
@ -122,7 +118,7 @@ impl AppSinkCallbacksBuilder {
|
||||||
new_preroll: self.new_preroll,
|
new_preroll: self.new_preroll,
|
||||||
new_sample: self.new_sample,
|
new_sample: self.new_sample,
|
||||||
panicked: AtomicBool::new(false),
|
panicked: AtomicBool::new(false),
|
||||||
callbacks: gst_app_sys::GstAppSinkCallbacks {
|
callbacks: ffi::GstAppSinkCallbacks {
|
||||||
eos: if have_eos { Some(trampoline_eos) } else { None },
|
eos: if have_eos { Some(trampoline_eos) } else { None },
|
||||||
new_preroll: if have_new_preroll {
|
new_preroll: if have_new_preroll {
|
||||||
Some(trampoline_new_preroll)
|
Some(trampoline_new_preroll)
|
||||||
|
@ -148,21 +144,21 @@ impl AppSinkCallbacksBuilder {
|
||||||
fn post_panic_error_message(element: &AppSink, err: &dyn std::any::Any) {
|
fn post_panic_error_message(element: &AppSink, err: &dyn std::any::Any) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
||||||
} else if let Some(cause) = err.downcast_ref::<String>() {
|
} else if let Some(cause) = err.downcast_ref::<String>() {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
||||||
} else {
|
} else {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_eos(appsink: *mut gst_app_sys::GstAppSink, callbacks: gpointer) {
|
unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gpointer) {
|
||||||
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,15 +177,15 @@ unsafe extern "C" fn trampoline_eos(appsink: *mut gst_app_sys::GstAppSink, callb
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_new_preroll(
|
unsafe extern "C" fn trampoline_new_preroll(
|
||||||
appsink: *mut gst_app_sys::GstAppSink,
|
appsink: *mut ffi::GstAppSink,
|
||||||
callbacks: gpointer,
|
callbacks: gpointer,
|
||||||
) -> gst_sys::GstFlowReturn {
|
) -> gst::ffi::GstFlowReturn {
|
||||||
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return gst::FlowReturn::Error.to_glib();
|
return gst::FlowReturn::Error.to_glib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,15 +210,15 @@ unsafe extern "C" fn trampoline_new_preroll(
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_new_sample(
|
unsafe extern "C" fn trampoline_new_sample(
|
||||||
appsink: *mut gst_app_sys::GstAppSink,
|
appsink: *mut ffi::GstAppSink,
|
||||||
callbacks: gpointer,
|
callbacks: gpointer,
|
||||||
) -> gst_sys::GstFlowReturn {
|
) -> gst::ffi::GstFlowReturn {
|
||||||
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
let callbacks = &*(callbacks as *const AppSinkCallbacks);
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
let element: Borrowed<AppSink> = from_glib_borrow(appsink);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return gst::FlowReturn::Error.to_glib();
|
return gst::FlowReturn::Error.to_glib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,20 +258,20 @@ impl AppSink {
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() < (1, 16, 3, 0) {
|
if gst::version() < (1, 16, 3, 0) {
|
||||||
if !gobject_sys::g_object_get_qdata(sink as *mut _, SET_ONCE_QUARK.to_glib())
|
if !glib::gobject_ffi::g_object_get_qdata(sink as *mut _, SET_ONCE_QUARK.to_glib())
|
||||||
.is_null()
|
.is_null()
|
||||||
{
|
{
|
||||||
panic!("AppSink callbacks can only be set once");
|
panic!("AppSink callbacks can only be set once");
|
||||||
}
|
}
|
||||||
|
|
||||||
gobject_sys::g_object_set_qdata(
|
glib::gobject_ffi::g_object_set_qdata(
|
||||||
sink as *mut _,
|
sink as *mut _,
|
||||||
SET_ONCE_QUARK.to_glib(),
|
SET_ONCE_QUARK.to_glib(),
|
||||||
1 as *mut _,
|
1 as *mut _,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_app_sys::gst_app_sink_set_callbacks(
|
ffi::gst_app_sink_set_callbacks(
|
||||||
sink,
|
sink,
|
||||||
mut_override(&callbacks.callbacks),
|
mut_override(&callbacks.callbacks),
|
||||||
Box::into_raw(Box::new(callbacks)) as *mut _,
|
Box::into_raw(Box::new(callbacks)) as *mut _,
|
||||||
|
@ -331,9 +327,9 @@ impl AppSink {
|
||||||
unsafe extern "C" fn new_sample_trampoline<
|
unsafe extern "C" fn new_sample_trampoline<
|
||||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||||
>(
|
>(
|
||||||
this: *mut gst_app_sys::GstAppSink,
|
this: *mut ffi::GstAppSink,
|
||||||
f: glib_sys::gpointer,
|
f: glib::ffi::gpointer,
|
||||||
) -> gst_sys::GstFlowReturn {
|
) -> gst::ffi::GstFlowReturn {
|
||||||
let f: &F = &*(f as *const F);
|
let f: &F = &*(f as *const F);
|
||||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||||
ret.to_glib()
|
ret.to_glib()
|
||||||
|
@ -342,9 +338,9 @@ unsafe extern "C" fn new_sample_trampoline<
|
||||||
unsafe extern "C" fn new_preroll_trampoline<
|
unsafe extern "C" fn new_preroll_trampoline<
|
||||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||||
>(
|
>(
|
||||||
this: *mut gst_app_sys::GstAppSink,
|
this: *mut ffi::GstAppSink,
|
||||||
f: glib_sys::gpointer,
|
f: glib::ffi::gpointer,
|
||||||
) -> gst_sys::GstFlowReturn {
|
) -> gst::ffi::GstFlowReturn {
|
||||||
let f: &F = &*(f as *const F);
|
let f: &F = &*(f as *const F);
|
||||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||||
ret.to_glib()
|
ret.to_glib()
|
||||||
|
|
|
@ -7,13 +7,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use futures_sink::Sink;
|
use futures_sink::Sink;
|
||||||
|
use glib::ffi::{gboolean, gpointer};
|
||||||
use glib::prelude::*;
|
use glib::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib_sys::{gboolean, gpointer};
|
|
||||||
use gst;
|
|
||||||
use gst::gst_element_error;
|
|
||||||
|
|
||||||
use gst_app_sys;
|
use crate::AppSrc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
|
@ -22,7 +20,6 @@ use std::ptr;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::task::{Context, Poll, Waker};
|
use std::task::{Context, Poll, Waker};
|
||||||
use AppSrc;
|
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub struct AppSrcCallbacks {
|
pub struct AppSrcCallbacks {
|
||||||
|
@ -30,7 +27,7 @@ pub struct AppSrcCallbacks {
|
||||||
enough_data: Option<Box<dyn Fn(&AppSrc) + Send + Sync + 'static>>,
|
enough_data: Option<Box<dyn Fn(&AppSrc) + Send + Sync + 'static>>,
|
||||||
seek_data: Option<Box<dyn Fn(&AppSrc, u64) -> bool + Send + Sync + 'static>>,
|
seek_data: Option<Box<dyn Fn(&AppSrc, u64) -> bool + Send + Sync + 'static>>,
|
||||||
panicked: AtomicBool,
|
panicked: AtomicBool,
|
||||||
callbacks: gst_app_sys::GstAppSrcCallbacks,
|
callbacks: ffi::GstAppSrcCallbacks,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for AppSrcCallbacks {}
|
unsafe impl Send for AppSrcCallbacks {}
|
||||||
|
@ -90,7 +87,7 @@ impl AppSrcCallbacksBuilder {
|
||||||
enough_data: self.enough_data,
|
enough_data: self.enough_data,
|
||||||
seek_data: self.seek_data,
|
seek_data: self.seek_data,
|
||||||
panicked: AtomicBool::new(false),
|
panicked: AtomicBool::new(false),
|
||||||
callbacks: gst_app_sys::GstAppSrcCallbacks {
|
callbacks: ffi::GstAppSrcCallbacks {
|
||||||
need_data: if have_need_data {
|
need_data: if have_need_data {
|
||||||
Some(trampoline_need_data)
|
Some(trampoline_need_data)
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,16 +117,16 @@ impl AppSrcCallbacksBuilder {
|
||||||
fn post_panic_error_message(element: &AppSrc, err: &dyn std::any::Any) {
|
fn post_panic_error_message(element: &AppSrc, err: &dyn std::any::Any) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
||||||
} else if let Some(cause) = err.downcast_ref::<String>() {
|
} else if let Some(cause) = err.downcast_ref::<String>() {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked: {}", cause]);
|
||||||
} else {
|
} else {
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_need_data(
|
unsafe extern "C" fn trampoline_need_data(
|
||||||
appsrc: *mut gst_app_sys::GstAppSrc,
|
appsrc: *mut ffi::GstAppSrc,
|
||||||
length: u32,
|
length: u32,
|
||||||
callbacks: gpointer,
|
callbacks: gpointer,
|
||||||
) {
|
) {
|
||||||
|
@ -138,7 +135,7 @@ unsafe extern "C" fn trampoline_need_data(
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,16 +153,13 @@ unsafe extern "C" fn trampoline_need_data(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_enough_data(
|
unsafe extern "C" fn trampoline_enough_data(appsrc: *mut ffi::GstAppSrc, callbacks: gpointer) {
|
||||||
appsrc: *mut gst_app_sys::GstAppSrc,
|
|
||||||
callbacks: gpointer,
|
|
||||||
) {
|
|
||||||
let callbacks = &*(callbacks as *const AppSrcCallbacks);
|
let callbacks = &*(callbacks as *const AppSrcCallbacks);
|
||||||
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +176,7 @@ unsafe extern "C" fn trampoline_enough_data(
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_seek_data(
|
unsafe extern "C" fn trampoline_seek_data(
|
||||||
appsrc: *mut gst_app_sys::GstAppSrc,
|
appsrc: *mut ffi::GstAppSrc,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
callbacks: gpointer,
|
callbacks: gpointer,
|
||||||
) -> gboolean {
|
) -> gboolean {
|
||||||
|
@ -191,7 +185,7 @@ unsafe extern "C" fn trampoline_seek_data(
|
||||||
|
|
||||||
if callbacks.panicked.load(Ordering::Relaxed) {
|
if callbacks.panicked.load(Ordering::Relaxed) {
|
||||||
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
let element: Borrowed<AppSrc> = from_glib_borrow(appsrc);
|
||||||
gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
gst::gst_element_error!(&element, gst::LibraryError::Failed, ["Panicked"]);
|
||||||
return false.to_glib();
|
return false.to_glib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,17 +214,14 @@ unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {
|
||||||
|
|
||||||
impl AppSrc {
|
impl AppSrc {
|
||||||
pub fn end_of_stream(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
pub fn end_of_stream(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
let ret: gst::FlowReturn = unsafe {
|
let ret: gst::FlowReturn =
|
||||||
from_glib(gst_app_sys::gst_app_src_end_of_stream(
|
unsafe { from_glib(ffi::gst_app_src_end_of_stream(self.to_glib_none().0)) };
|
||||||
self.to_glib_none().0,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
ret.into_result()
|
ret.into_result()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
let ret: gst::FlowReturn = unsafe {
|
let ret: gst::FlowReturn = unsafe {
|
||||||
from_glib(gst_app_sys::gst_app_src_push_buffer(
|
from_glib(ffi::gst_app_src_push_buffer(
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
buffer.into_ptr(),
|
buffer.into_ptr(),
|
||||||
))
|
))
|
||||||
|
@ -245,7 +236,7 @@ impl AppSrc {
|
||||||
list: gst::BufferList,
|
list: gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
let ret: gst::FlowReturn = unsafe {
|
let ret: gst::FlowReturn = unsafe {
|
||||||
from_glib(gst_app_sys::gst_app_src_push_buffer_list(
|
from_glib(ffi::gst_app_src_push_buffer_list(
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
list.into_ptr(),
|
list.into_ptr(),
|
||||||
))
|
))
|
||||||
|
@ -255,7 +246,7 @@ impl AppSrc {
|
||||||
|
|
||||||
pub fn push_sample(&self, sample: &gst::Sample) -> Result<gst::FlowSuccess, gst::FlowError> {
|
pub fn push_sample(&self, sample: &gst::Sample) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
let ret: gst::FlowReturn = unsafe {
|
let ret: gst::FlowReturn = unsafe {
|
||||||
from_glib(gst_app_sys::gst_app_src_push_sample(
|
from_glib(ffi::gst_app_src_push_sample(
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
sample.to_glib_none().0,
|
sample.to_glib_none().0,
|
||||||
))
|
))
|
||||||
|
@ -273,20 +264,20 @@ impl AppSrc {
|
||||||
// This is not thread-safe before 1.16.3, see
|
// This is not thread-safe before 1.16.3, see
|
||||||
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
// https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/merge_requests/570
|
||||||
if gst::version() < (1, 16, 3, 0) {
|
if gst::version() < (1, 16, 3, 0) {
|
||||||
if !gobject_sys::g_object_get_qdata(src as *mut _, SET_ONCE_QUARK.to_glib())
|
if !glib::gobject_ffi::g_object_get_qdata(src as *mut _, SET_ONCE_QUARK.to_glib())
|
||||||
.is_null()
|
.is_null()
|
||||||
{
|
{
|
||||||
panic!("AppSrc callbacks can only be set once");
|
panic!("AppSrc callbacks can only be set once");
|
||||||
}
|
}
|
||||||
|
|
||||||
gobject_sys::g_object_set_qdata(
|
glib::gobject_ffi::g_object_set_qdata(
|
||||||
src as *mut _,
|
src as *mut _,
|
||||||
SET_ONCE_QUARK.to_glib(),
|
SET_ONCE_QUARK.to_glib(),
|
||||||
1 as *mut _,
|
1 as *mut _,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_app_sys::gst_app_src_set_callbacks(
|
ffi::gst_app_src_set_callbacks(
|
||||||
src,
|
src,
|
||||||
mut_override(&callbacks.callbacks),
|
mut_override(&callbacks.callbacks),
|
||||||
Box::into_raw(Box::new(callbacks)) as *mut _,
|
Box::into_raw(Box::new(callbacks)) as *mut _,
|
||||||
|
@ -297,11 +288,7 @@ impl AppSrc {
|
||||||
|
|
||||||
pub fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime) {
|
pub fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_app_sys::gst_app_src_set_latency(
|
ffi::gst_app_src_set_latency(self.to_glib_none().0, min.to_glib(), max.to_glib());
|
||||||
self.to_glib_none().0,
|
|
||||||
min.to_glib(),
|
|
||||||
max.to_glib(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,11 +296,7 @@ impl AppSrc {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut min = mem::MaybeUninit::uninit();
|
let mut min = mem::MaybeUninit::uninit();
|
||||||
let mut max = mem::MaybeUninit::uninit();
|
let mut max = mem::MaybeUninit::uninit();
|
||||||
gst_app_sys::gst_app_src_get_latency(
|
ffi::gst_app_src_get_latency(self.to_glib_none().0, min.as_mut_ptr(), max.as_mut_ptr());
|
||||||
self.to_glib_none().0,
|
|
||||||
min.as_mut_ptr(),
|
|
||||||
max.as_mut_ptr(),
|
|
||||||
);
|
|
||||||
(from_glib(min.assume_init()), from_glib(max.assume_init()))
|
(from_glib(min.assume_init()), from_glib(max.assume_init()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,27 +8,7 @@
|
||||||
|
|
||||||
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
||||||
|
|
||||||
extern crate libc;
|
pub use ffi;
|
||||||
|
|
||||||
extern crate futures_core;
|
|
||||||
extern crate futures_sink;
|
|
||||||
extern crate glib_sys;
|
|
||||||
extern crate gobject_sys;
|
|
||||||
extern crate gstreamer as gst;
|
|
||||||
extern crate gstreamer_app_sys as gst_app_sys;
|
|
||||||
extern crate gstreamer_base as gst_base;
|
|
||||||
extern crate gstreamer_sys as gst_sys;
|
|
||||||
|
|
||||||
extern crate once_cell;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate glib;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate futures_util;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate futures_executor;
|
|
||||||
|
|
||||||
macro_rules! skip_assert_initialized {
|
macro_rules! skip_assert_initialized {
|
||||||
() => {};
|
() => {};
|
||||||
|
@ -38,13 +18,13 @@ macro_rules! skip_assert_initialized {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
#[allow(clippy::match_same_arms)]
|
#[allow(clippy::match_same_arms)]
|
||||||
mod auto;
|
mod auto;
|
||||||
pub use auto::*;
|
pub use crate::auto::*;
|
||||||
|
|
||||||
pub mod app_sink;
|
pub mod app_sink;
|
||||||
pub use app_sink::AppSinkCallbacks;
|
pub use crate::app_sink::AppSinkCallbacks;
|
||||||
|
|
||||||
pub mod app_src;
|
pub mod app_src;
|
||||||
pub use app_src::AppSrcCallbacks;
|
pub use crate::app_src::AppSrcCallbacks;
|
||||||
|
|
||||||
// Re-export all the traits in a prelude module, so that applications
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
// can always "use gst::prelude::*" without getting conflicts
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
@ -52,5 +32,5 @@ pub mod prelude {
|
||||||
pub use glib::prelude::*;
|
pub use glib::prelude::*;
|
||||||
pub use gst::prelude::*;
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
pub use auto::traits::*;
|
pub use crate::auto::traits::*;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue