examples: Fix build

This commit is contained in:
Sebastian Dröge 2020-11-22 12:55:32 +02:00
parent 8dd288f2b9
commit 1b288add4c
4 changed files with 23 additions and 28 deletions

View file

@ -19,7 +19,6 @@ ges = { package = "gstreamer-editing-services", path = "../gstreamer-editing-ser
gst-sdp = { package = "gstreamer-sdp", path = "../gstreamer-sdp", optional = true } gst-sdp = { package = "gstreamer-sdp", path = "../gstreamer-sdp", optional = true }
gst-rtsp = { package = "gstreamer-rtsp", path = "../gstreamer-rtsp", optional = true } gst-rtsp = { package = "gstreamer-rtsp", path = "../gstreamer-rtsp", optional = true }
gst-rtsp-server = { package = "gstreamer-rtsp-server", path = "../gstreamer-rtsp-server", optional = true } gst-rtsp-server = { package = "gstreamer-rtsp-server", path = "../gstreamer-rtsp-server", optional = true }
gst-rtsp-server-sys = { package = "gstreamer-rtsp-server-sys", path = "../gstreamer-rtsp-server/sys", features = ["v1_8"], optional = true }
gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gdk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } gdk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gio = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } gio = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
@ -28,7 +27,6 @@ derive_more = "0.99.5"
futures = "0.3" futures = "0.3"
byte-slice-cast = "1" byte-slice-cast = "1"
cairo-rs = { git = "https://github.com/gtk-rs/gtk-rs", features=["use_glib"], optional = true } cairo-rs = { git = "https://github.com/gtk-rs/gtk-rs", features=["use_glib"], optional = true }
cairo-sys-rs = { git = "https://github.com/gtk-rs/gtk-rs", features=["use_glib"], optional = true }
pango = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } pango = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
pangocairo = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } pangocairo = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
glutin = { version = "0.21", optional = true } glutin = { version = "0.21", optional = true }
@ -46,11 +44,11 @@ gtkvideooverlay = ["gtk", "gdk", "gio"]
gtkvideooverlay-x11 = ["gtkvideooverlay"] gtkvideooverlay-x11 = ["gtkvideooverlay"]
gtkvideooverlay-quartz = ["gtkvideooverlay"] gtkvideooverlay-quartz = ["gtkvideooverlay"]
rtsp-server = ["gst-rtsp-server", "gst-rtsp", "gst-sdp"] rtsp-server = ["gst-rtsp-server", "gst-rtsp", "gst-sdp"]
rtsp-server-record = ["gst-rtsp-server-sys", "gst-rtsp-server", "gst-rtsp", "gio"] rtsp-server-record = ["gst-rtsp-server", "gst-rtsp", "gio"]
v1_10 = ["gst/v1_10"] v1_10 = ["gst/v1_10"]
v1_14 = ["gst/v1_14"] v1_14 = ["gst/v1_14"]
pango-cairo = ["pango", "pangocairo", "cairo-rs"] pango-cairo = ["pango", "pangocairo", "cairo-rs"]
overlay-composition = ["pango", "pangocairo", "cairo-rs", "cairo-sys-rs" ] overlay-composition = ["pango", "pangocairo", "cairo-rs"]
gl = ["gst-gl", "gl_generator", "glutin"] gl = ["gst-gl", "gl_generator", "glutin"]
gl-egl = ["gst-gl/egl"] gl-egl = ["gst-gl/egl"]
gl-x11 = ["gst-gl/x11"] gl-x11 = ["gst-gl/x11"]

View file

@ -10,7 +10,6 @@ use gst::prelude::*;
mod examples_common; mod examples_common;
mod custom_meta { mod custom_meta {
use gst::gst_sys;
use gst::prelude::*; use gst::prelude::*;
use std::fmt; use std::fmt;
use std::ptr; use std::ptr;
@ -31,7 +30,7 @@ mod custom_meta {
) -> gst::MetaRefMut<Self, gst::meta::Standalone> { ) -> gst::MetaRefMut<Self, gst::meta::Standalone> {
unsafe { unsafe {
// First add it: this will store an empty label via custom_meta_init(). // First add it: this will store an empty label via custom_meta_init().
let meta = gst_sys::gst_buffer_add_meta( let meta = gst::ffi::gst_buffer_add_meta(
buffer.as_mut_ptr(), buffer.as_mut_ptr(),
imp::custom_meta_get_info(), imp::custom_meta_get_info(),
ptr::null_mut(), ptr::null_mut(),
@ -72,9 +71,7 @@ mod custom_meta {
// Actual unsafe implementation of the meta. // Actual unsafe implementation of the meta.
mod imp { mod imp {
use glib::glib_sys;
use glib::translate::*; use glib::translate::*;
use gst::gst_sys;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
@ -82,14 +79,14 @@ mod custom_meta {
// This is the C type that is actually stored as meta inside the buffers. // This is the C type that is actually stored as meta inside the buffers.
#[repr(C)] #[repr(C)]
pub struct CustomMeta { pub struct CustomMeta {
parent: gst_sys::GstMeta, parent: gst::ffi::GstMeta,
pub(super) label: String, pub(super) label: String,
} }
// Function to register the meta API and get a type back. // Function to register the meta API and get a type back.
pub(super) fn custom_meta_api_get_type() -> glib::Type { pub(super) fn custom_meta_api_get_type() -> glib::Type {
static TYPE: Lazy<glib::Type> = Lazy::new(|| unsafe { static TYPE: Lazy<glib::Type> = Lazy::new(|| unsafe {
let t = from_glib(gst_sys::gst_meta_api_type_register( let t = from_glib(gst::ffi::gst_meta_api_type_register(
b"MyCustomMetaAPI\0".as_ptr() as *const _, b"MyCustomMetaAPI\0".as_ptr() as *const _,
// We provide no tags here as our meta is just a label and does // We provide no tags here as our meta is just a label and does
// not refer to any specific aspect of the buffer // not refer to any specific aspect of the buffer
@ -107,10 +104,10 @@ mod custom_meta {
// Initialization function for our meta. This needs to ensure all fields are correctly // Initialization function for our meta. This needs to ensure all fields are correctly
// initialized. They will contain random memory before. // initialized. They will contain random memory before.
unsafe extern "C" fn custom_meta_init( unsafe extern "C" fn custom_meta_init(
meta: *mut gst_sys::GstMeta, meta: *mut gst::ffi::GstMeta,
_params: glib_sys::gpointer, _params: glib::ffi::gpointer,
_buffer: *mut gst_sys::GstBuffer, _buffer: *mut gst::ffi::GstBuffer,
) -> glib_sys::gboolean { ) -> glib::ffi::gboolean {
let meta = &mut *(meta as *mut CustomMeta); let meta = &mut *(meta as *mut CustomMeta);
// Need to initialize all our fields correctly here // Need to initialize all our fields correctly here
@ -121,8 +118,8 @@ mod custom_meta {
// Free function for our meta. This needs to free/drop all memory we allocated. // Free function for our meta. This needs to free/drop all memory we allocated.
unsafe extern "C" fn custom_meta_free( unsafe extern "C" fn custom_meta_free(
meta: *mut gst_sys::GstMeta, meta: *mut gst::ffi::GstMeta,
_buffer: *mut gst_sys::GstBuffer, _buffer: *mut gst::ffi::GstBuffer,
) { ) {
let meta = &mut *(meta as *mut CustomMeta); let meta = &mut *(meta as *mut CustomMeta);
@ -134,12 +131,12 @@ mod custom_meta {
// in a way that is compatible with the transformation type. In this case we just always // in a way that is compatible with the transformation type. In this case we just always
// copy it over. // copy it over.
unsafe extern "C" fn custom_meta_transform( unsafe extern "C" fn custom_meta_transform(
dest: *mut gst_sys::GstBuffer, dest: *mut gst::ffi::GstBuffer,
meta: *mut gst_sys::GstMeta, meta: *mut gst::ffi::GstMeta,
_buffer: *mut gst_sys::GstBuffer, _buffer: *mut gst::ffi::GstBuffer,
_type_: glib_sys::GQuark, _type_: glib::ffi::GQuark,
_data: glib_sys::gpointer, _data: glib::ffi::gpointer,
) -> glib_sys::gboolean { ) -> glib::ffi::gboolean {
let meta = &mut *(meta as *mut CustomMeta); let meta = &mut *(meta as *mut CustomMeta);
// We simply copy over our meta here. Other metas might have to look at the type // We simply copy over our meta here. Other metas might have to look at the type
@ -150,21 +147,21 @@ mod custom_meta {
} }
// Register the meta itself with its functions. // Register the meta itself with its functions.
pub(super) fn custom_meta_get_info() -> *const gst_sys::GstMetaInfo { pub(super) fn custom_meta_get_info() -> *const gst::ffi::GstMetaInfo {
struct MetaInfo(ptr::NonNull<gst_sys::GstMetaInfo>); struct MetaInfo(ptr::NonNull<gst::ffi::GstMetaInfo>);
unsafe impl Send for MetaInfo {} unsafe impl Send for MetaInfo {}
unsafe impl Sync for MetaInfo {} unsafe impl Sync for MetaInfo {}
static META_INFO: Lazy<MetaInfo> = Lazy::new(|| unsafe { static META_INFO: Lazy<MetaInfo> = Lazy::new(|| unsafe {
MetaInfo( MetaInfo(
ptr::NonNull::new(gst_sys::gst_meta_register( ptr::NonNull::new(gst::ffi::gst_meta_register(
custom_meta_api_get_type().to_glib(), custom_meta_api_get_type().to_glib(),
b"MyCustomMeta\0".as_ptr() as *const _, b"MyCustomMeta\0".as_ptr() as *const _,
mem::size_of::<CustomMeta>(), mem::size_of::<CustomMeta>(),
Some(custom_meta_init), Some(custom_meta_init),
Some(custom_meta_free), Some(custom_meta_free),
Some(custom_meta_transform), Some(custom_meta_transform),
) as *mut gst_sys::GstMetaInfo) ) as *mut gst::ffi::GstMetaInfo)
.expect("Failed to register meta API"), .expect("Failed to register meta API"),
) )
}); });

View file

@ -242,7 +242,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
drop(cr); drop(cr);
unsafe { unsafe {
assert_eq!( assert_eq!(
cairo_sys::cairo_surface_get_reference_count(surface.to_raw_none()), cairo::ffi::cairo_surface_get_reference_count(surface.to_raw_none()),
1 1
); );
let buffer = glib::translate::from_glib_none(buffer_ptr); let buffer = glib::translate::from_glib_none(buffer_ptr);

View file

@ -84,7 +84,7 @@ fn main_loop() -> Result<(), Error> {
// This declares that the user "user" (once authenticated) has a role that // This declares that the user "user" (once authenticated) has a role that
// allows them to access and construct media factories. // allows them to access and construct media factories.
unsafe { unsafe {
gst_rtsp_server_sys::gst_rtsp_media_factory_add_role( gst_rtsp_server::ffi::gst_rtsp_media_factory_add_role(
factory.to_glib_none().0, factory.to_glib_none().0,
"user".to_glib_none().0, "user".to_glib_none().0,
gst_rtsp_server::RTSP_PERM_MEDIA_FACTORY_ACCESS gst_rtsp_server::RTSP_PERM_MEDIA_FACTORY_ACCESS