diff --git a/gstreamer-player/Cargo.toml b/gstreamer-player/Cargo.toml index fd4047030..a7fa64fb3 100644 --- a/gstreamer-player/Cargo.toml +++ b/gstreamer-player/Cargo.toml @@ -11,29 +11,27 @@ homepage = "https://gstreamer.freedesktop.org" documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_player/" keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] build = "build.rs" +edition = "2018" [dependencies] bitflags = "1.0" libc = "0.2" -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_12"] } -gstreamer-player-sys = { path = "../gstreamer-player/sys" } +ffi = { package = "gstreamer-player-sys", path = "../gstreamer-player/sys" } glib = { git = "https://github.com/gtk-rs/gtk-rs" } -gstreamer = { path = "../gstreamer", features = ["v1_12"] } -gstreamer-video = { path = "../gstreamer-video", features = ["v1_12"] } +gst = { package = "gstreamer", path = "../gstreamer", features = ["v1_12"] } +gst-video = { package = "gstreamer-video", path = "../gstreamer-video", features = ["v1_12"] } [build-dependencies] gstreamer-rs-lgpl-docs = { path = "../docs", optional = true } [features] default = [] -v1_14 = ["gstreamer/v1_14", "gstreamer-video/v1_14", "gstreamer-player-sys/v1_14"] -v1_16 = ["gstreamer/v1_16", "gstreamer-video/v1_16", "gstreamer-player-sys/v1_16", "v1_14"] -v1_18 = ["gstreamer/v1_18", "gstreamer-video/v1_18", "gstreamer-player-sys/v1_18", "v1_16"] +v1_14 = ["gst/v1_14", "gst-video/v1_14", "ffi/v1_14"] +v1_16 = ["gst/v1_16", "gst-video/v1_16", "ffi/v1_16", "v1_14"] +v1_18 = ["gst/v1_18", "gst-video/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-player-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-video/dox"] +dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox", "gst-video/dox"] [package.metadata.docs.rs] features = ["dox", "embed-lgpl-docs"] diff --git a/gstreamer-player/src/auto/flags.rs b/gstreamer-player/src/auto/flags.rs index 8690cac26..fc9f2848b 100644 --- a/gstreamer-player/src/auto/flags.rs +++ b/gstreamer-player/src/auto/flags.rs @@ -2,6 +2,6 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use gst_player_sys; +use ffi; use glib::translate::*; diff --git a/gstreamer-player/src/config.rs b/gstreamer-player/src/config.rs index 6e7c2bcdd..12e8c68c2 100644 --- a/gstreamer-player/src/config.rs +++ b/gstreamer-player/src/config.rs @@ -7,9 +7,6 @@ // except according to those terms. use glib::translate::*; -use gst; -use gst_player_sys; -use gst_sys; use std::mem; use std::ops; @@ -46,15 +43,13 @@ impl AsMut for PlayerConfig { impl PlayerConfig { pub fn get_position_update_interval(&self) -> u32 { assert_initialized_main_thread!(); - unsafe { - gst_player_sys::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) - } + unsafe { ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) } } pub fn get_seek_accurate(&self) -> bool { assert_initialized_main_thread!(); unsafe { - from_glib(gst_player_sys::gst_player_config_get_seek_accurate( + from_glib(ffi::gst_player_config_get_seek_accurate( self.0.to_glib_none().0, )) } @@ -63,7 +58,7 @@ impl PlayerConfig { pub fn get_user_agent(&self) -> Option { assert_initialized_main_thread!(); unsafe { - from_glib_full(gst_player_sys::gst_player_config_get_user_agent( + from_glib_full(ffi::gst_player_config_get_user_agent( self.0.to_glib_none().0, )) } @@ -72,7 +67,7 @@ impl PlayerConfig { pub fn set_position_update_interval(&mut self, interval: u32) { assert_initialized_main_thread!(); unsafe { - gst_player_sys::gst_player_config_set_position_update_interval( + ffi::gst_player_config_set_position_update_interval( self.0.to_glib_none_mut().0, interval, ); @@ -89,21 +84,21 @@ impl PlayerConfig { pub fn set_user_agent(&mut self, agent: &str) { assert_initialized_main_thread!(); unsafe { - gst_player_sys::gst_player_config_set_user_agent( + ffi::gst_player_config_set_user_agent( self.0.to_glib_none_mut().0, agent.to_glib_none().0, ); } } - pub unsafe fn into_ptr(self) -> *mut gst_sys::GstStructure { + pub unsafe fn into_ptr(self) -> *mut gst::ffi::GstStructure { let mut s = mem::ManuallyDrop::new(self); s.0.to_glib_none_mut().0 } } -impl FromGlibPtrFull<*mut gst_sys::GstStructure> for PlayerConfig { - unsafe fn from_glib_full(ptr: *mut gst_sys::GstStructure) -> Self { +impl FromGlibPtrFull<*mut gst::ffi::GstStructure> for PlayerConfig { + unsafe fn from_glib_full(ptr: *mut gst::ffi::GstStructure) -> Self { PlayerConfig(from_glib_full(ptr)) } } diff --git a/gstreamer-player/src/lib.rs b/gstreamer-player/src/lib.rs index 1f80c6e9a..af958e146 100644 --- a/gstreamer-player/src/lib.rs +++ b/gstreamer-player/src/lib.rs @@ -8,17 +8,7 @@ #![cfg_attr(feature = "dox", feature(doc_cfg))] -extern crate libc; - -extern crate glib_sys; -extern crate gobject_sys; -extern crate gstreamer as gst; -extern crate gstreamer_player_sys as gst_player_sys; -extern crate gstreamer_sys as gst_sys; -extern crate gstreamer_video as gst_video; - -#[macro_use] -extern crate glib; +pub use ffi; macro_rules! skip_assert_initialized { () => {}; @@ -35,11 +25,11 @@ macro_rules! assert_initialized_main_thread { #[allow(clippy::cast_ptr_alignment)] #[allow(unused_imports)] mod auto; -pub use auto::*; +pub use crate::auto::*; mod config; mod player; -pub use config::*; +pub use crate::config::*; mod player_video_info; @@ -53,5 +43,5 @@ pub mod prelude { pub use glib::prelude::*; pub use gst::prelude::*; - pub use auto::traits::*; + pub use crate::auto::traits::*; } diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index d9ba4f2e0..489c88afe 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -6,19 +6,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use crate::Player; +use crate::PlayerSignalDispatcher; +use crate::PlayerVideoRenderer; use glib::object::ObjectType; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib_sys; -use gst; -use gst_player_sys; use std::boxed::Box as Box_; use std::mem::transmute; -use Player; -use PlayerSignalDispatcher; -use PlayerVideoRenderer; impl Player { pub fn new( @@ -31,32 +27,22 @@ impl Player { let (major, minor, _, _) = gst::version(); if (major, minor) > (1, 12) { - unsafe { - from_glib_full(gst_player_sys::gst_player_new( - video_renderer, - signal_dispatcher, - )) - } + unsafe { from_glib_full(ffi::gst_player_new(video_renderer, signal_dispatcher)) } } else { // Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13 in // https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/gst-libs/gst/player/gstplayer.c?id=634cd87c76f58b5e1383715bafd5614db825c7d1 - unsafe { - from_glib_none(gst_player_sys::gst_player_new( - video_renderer, - signal_dispatcher, - )) - } + unsafe { from_glib_none(ffi::gst_player_new(video_renderer, signal_dispatcher)) } } } - pub fn get_config(&self) -> ::PlayerConfig { - unsafe { from_glib_full(gst_player_sys::gst_player_get_config(self.to_glib_none().0)) } + pub fn get_config(&self) -> crate::PlayerConfig { + unsafe { from_glib_full(ffi::gst_player_get_config(self.to_glib_none().0)) } } - pub fn set_config(&self, config: ::PlayerConfig) -> Result<(), glib::error::BoolError> { + pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> { unsafe { - glib_result_from_gboolean!( - gst_player_sys::gst_player_set_config(self.to_glib_none().0, config.into_ptr()), + glib::glib_result_from_gboolean!( + ffi::gst_player_set_config(self.to_glib_none().0, config.into_ptr()), "Failed to set config", ) } @@ -120,9 +106,9 @@ impl Player { unsafe extern "C" fn duration_changed_trampoline< F: Fn(&Player, gst::ClockTime) + Send + 'static, >( - this: *mut gst_player_sys::GstPlayer, + this: *mut ffi::GstPlayer, object: u64, - f: glib_sys::gpointer, + f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) @@ -131,18 +117,18 @@ unsafe extern "C" fn duration_changed_trampoline< unsafe extern "C" fn position_updated_trampoline< F: Fn(&Player, gst::ClockTime) + Send + 'static, >( - this: *mut gst_player_sys::GstPlayer, + this: *mut ffi::GstPlayer, object: u64, - f: glib_sys::gpointer, + f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) } unsafe extern "C" fn seek_done_trampoline( - this: *mut gst_player_sys::GstPlayer, + this: *mut ffi::GstPlayer, object: u64, - f: glib_sys::gpointer, + f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) diff --git a/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs index 5016fb27e..5e70bc630 100644 --- a/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs +++ b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs @@ -6,10 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib; +use crate::PlayerGMainContextSignalDispatcher; use glib::translate::*; -use gst_player_sys; -use PlayerGMainContextSignalDispatcher; impl PlayerGMainContextSignalDispatcher { pub fn new( @@ -18,11 +16,10 @@ impl PlayerGMainContextSignalDispatcher { assert_initialized_main_thread!(); let application_context = application_context.to_glib_none(); unsafe { - from_glib_full( - gst_player_sys::gst_player_g_main_context_signal_dispatcher_new( - application_context.0, - ) as *mut gst_player_sys::GstPlayerGMainContextSignalDispatcher, + from_glib_full(ffi::gst_player_g_main_context_signal_dispatcher_new( + application_context.0, ) + as *mut ffi::GstPlayerGMainContextSignalDispatcher) } } } diff --git a/gstreamer-player/src/player_video_info.rs b/gstreamer-player/src/player_video_info.rs index 85ff3da51..a4a2fd8bb 100644 --- a/gstreamer-player/src/player_video_info.rs +++ b/gstreamer-player/src/player_video_info.rs @@ -6,18 +6,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::PlayerVideoInfo; use glib::translate::*; -use gst; -use gst_player_sys; use std::mem; -use PlayerVideoInfo; impl PlayerVideoInfo { pub fn get_framerate(&self) -> gst::Fraction { unsafe { let mut fps_n = mem::MaybeUninit::uninit(); let mut fps_d = mem::MaybeUninit::uninit(); - gst_player_sys::gst_player_video_info_get_framerate( + ffi::gst_player_video_info_get_framerate( self.to_glib_none().0, fps_n.as_mut_ptr(), fps_d.as_mut_ptr(), @@ -30,7 +28,7 @@ impl PlayerVideoInfo { unsafe { let mut par_n = mem::MaybeUninit::uninit(); let mut par_d = mem::MaybeUninit::uninit(); - gst_player_sys::gst_player_video_info_get_pixel_aspect_ratio( + ffi::gst_player_video_info_get_pixel_aspect_ratio( self.to_glib_none().0, par_n.as_mut_ptr(), par_d.as_mut_ptr(), diff --git a/gstreamer-player/src/player_video_overlay_video_renderer.rs b/gstreamer-player/src/player_video_overlay_video_renderer.rs index da06dd41d..cd5e4556f 100644 --- a/gstreamer-player/src/player_video_overlay_video_renderer.rs +++ b/gstreamer-player/src/player_video_overlay_video_renderer.rs @@ -6,11 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use crate::PlayerVideoOverlayVideoRenderer; use glib::translate::*; use glib::IsA; -use gst; -use gst_player_sys; -use PlayerVideoOverlayVideoRenderer; use std::ptr; @@ -20,9 +18,9 @@ impl PlayerVideoOverlayVideoRenderer { pub unsafe fn new(window_handle: uintptr_t) -> PlayerVideoOverlayVideoRenderer { assert_initialized_main_thread!(); - from_glib_full(gst_player_sys::gst_player_video_overlay_video_renderer_new( - window_handle as *mut _, - ) as *mut _) + from_glib_full( + ffi::gst_player_video_overlay_video_renderer_new(window_handle as *mut _) as *mut _, + ) } pub unsafe fn with_handle_and_sink>( @@ -31,35 +29,30 @@ impl PlayerVideoOverlayVideoRenderer { ) -> PlayerVideoOverlayVideoRenderer { assert_initialized_main_thread!(); - from_glib_full( - gst_player_sys::gst_player_video_overlay_video_renderer_new_with_sink( - window_handle as *mut _, - video_sink.as_ref().to_glib_none().0, - ) as *mut _, - ) + from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( + window_handle as *mut _, + video_sink.as_ref().to_glib_none().0, + ) as *mut _) } pub fn with_sink>(video_sink: &P) -> PlayerVideoOverlayVideoRenderer { assert_initialized_main_thread!(); unsafe { - from_glib_full( - gst_player_sys::gst_player_video_overlay_video_renderer_new_with_sink( - ptr::null_mut(), - video_sink.as_ref().to_glib_none().0, - ) as *mut _, - ) + from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink( + ptr::null_mut(), + video_sink.as_ref().to_glib_none().0, + ) as *mut _) } } pub unsafe fn get_window_handle(&self) -> uintptr_t { - gst_player_sys::gst_player_video_overlay_video_renderer_get_window_handle( - self.to_glib_none().0, - ) as uintptr_t + ffi::gst_player_video_overlay_video_renderer_get_window_handle(self.to_glib_none().0) + as uintptr_t } pub unsafe fn set_window_handle(&self, window_handle: uintptr_t) { - gst_player_sys::gst_player_video_overlay_video_renderer_set_window_handle( + ffi::gst_player_video_overlay_video_renderer_set_window_handle( self.to_glib_none().0, window_handle as *mut _, ) diff --git a/gstreamer-player/src/player_visualization.rs b/gstreamer-player/src/player_visualization.rs index 548039486..d334563ae 100644 --- a/gstreamer-player/src/player_visualization.rs +++ b/gstreamer-player/src/player_visualization.rs @@ -9,7 +9,7 @@ use glib::translate::*; use std::ffi::CStr; -use PlayerVisualization; +use crate::PlayerVisualization; impl PlayerVisualization { pub fn name(&self) -> &str {