2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2017-12-16 09:18:00 +00:00
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
|
|
|
|
use std::mem;
|
|
|
|
use std::ops;
|
|
|
|
|
2020-01-30 21:10:26 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
2017-12-16 09:18:00 +00:00
|
|
|
pub struct PlayerConfig(gst::Structure);
|
|
|
|
|
|
|
|
impl ops::Deref for PlayerConfig {
|
|
|
|
type Target = gst::StructureRef;
|
|
|
|
|
|
|
|
fn deref(&self) -> &gst::StructureRef {
|
|
|
|
self.0.deref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ops::DerefMut for PlayerConfig {
|
|
|
|
fn deref_mut(&mut self) -> &mut gst::StructureRef {
|
|
|
|
self.0.deref_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsRef<gst::StructureRef> for PlayerConfig {
|
|
|
|
fn as_ref(&self) -> &gst::StructureRef {
|
|
|
|
self.0.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AsMut<gst::StructureRef> for PlayerConfig {
|
|
|
|
fn as_mut(&mut self) -> &mut gst::StructureRef {
|
|
|
|
self.0.as_mut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PlayerConfig {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_position_update_interval")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_player_config_get_position_update_interval")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn position_update_interval(&self) -> u32 {
|
2017-12-16 09:18:00 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-11-22 10:32:04 +00:00
|
|
|
unsafe { ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) }
|
2017-12-16 09:18:00 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_seek_accurate")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn is_seek_accurate(&self) -> bool {
|
2017-12-16 09:18:00 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-22 10:32:04 +00:00
|
|
|
from_glib(ffi::gst_player_config_get_seek_accurate(
|
2017-12-16 09:18:00 +00:00
|
|
|
self.0.to_glib_none().0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_user_agent")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_player_config_get_user_agent")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn user_agent(&self) -> Option<String> {
|
2017-12-16 09:18:00 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-22 10:32:04 +00:00
|
|
|
from_glib_full(ffi::gst_player_config_get_user_agent(
|
2017-12-16 09:18:00 +00:00
|
|
|
self.0.to_glib_none().0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_player_config_set_position_update_interval")]
|
2017-12-16 09:18:00 +00:00
|
|
|
pub fn set_position_update_interval(&mut self, interval: u32) {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-22 10:32:04 +00:00
|
|
|
ffi::gst_player_config_set_position_update_interval(
|
2017-12-16 09:18:00 +00:00
|
|
|
self.0.to_glib_none_mut().0,
|
|
|
|
interval,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_seek_accurate(&mut self, accurate: bool) {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
// FIXME: Work-around for
|
|
|
|
// http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=cc58bd6ae071dec4ea7b4be626034accd0372755
|
|
|
|
self.set("accurate-seek", &accurate);
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_player_config_set_user_agent")]
|
2017-12-16 09:18:00 +00:00
|
|
|
pub fn set_user_agent(&mut self, agent: &str) {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-22 10:32:04 +00:00
|
|
|
ffi::gst_player_config_set_user_agent(
|
2017-12-16 09:18:00 +00:00
|
|
|
self.0.to_glib_none_mut().0,
|
|
|
|
agent.to_glib_none().0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-05-06 19:41:15 +00:00
|
|
|
}
|
2017-12-16 09:18:00 +00:00
|
|
|
|
2022-05-06 19:41:15 +00:00
|
|
|
impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayerConfig {
|
|
|
|
unsafe fn into_glib_ptr(self) -> *mut gst::ffi::GstStructure {
|
2020-04-09 12:59:14 +00:00
|
|
|
let mut s = mem::ManuallyDrop::new(self);
|
2020-04-11 18:18:18 +00:00
|
|
|
s.0.to_glib_none_mut().0
|
2017-12-16 09:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:32:04 +00:00
|
|
|
impl FromGlibPtrFull<*mut gst::ffi::GstStructure> for PlayerConfig {
|
|
|
|
unsafe fn from_glib_full(ptr: *mut gst::ffi::GstStructure) -> Self {
|
2017-12-16 09:18:00 +00:00
|
|
|
PlayerConfig(from_glib_full(ptr))
|
|
|
|
}
|
|
|
|
}
|