gstreamer_player/
config.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::{mem, ops};
4
5use crate::ffi;
6use glib::translate::*;
7
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct PlayerConfig(gst::Structure);
10
11impl ops::Deref for PlayerConfig {
12    type Target = gst::StructureRef;
13
14    #[inline]
15    fn deref(&self) -> &gst::StructureRef {
16        self.0.deref()
17    }
18}
19
20impl ops::DerefMut for PlayerConfig {
21    #[inline]
22    fn deref_mut(&mut self) -> &mut gst::StructureRef {
23        self.0.deref_mut()
24    }
25}
26
27impl AsRef<gst::StructureRef> for PlayerConfig {
28    #[inline]
29    fn as_ref(&self) -> &gst::StructureRef {
30        self.0.as_ref()
31    }
32}
33
34impl AsMut<gst::StructureRef> for PlayerConfig {
35    #[inline]
36    fn as_mut(&mut self) -> &mut gst::StructureRef {
37        self.0.as_mut()
38    }
39}
40
41impl PlayerConfig {
42    #[doc(alias = "get_position_update_interval")]
43    #[doc(alias = "gst_player_config_get_position_update_interval")]
44    pub fn position_update_interval(&self) -> u32 {
45        skip_assert_initialized!();
46        unsafe { ffi::gst_player_config_get_position_update_interval(self.0.to_glib_none().0) }
47    }
48
49    #[doc(alias = "get_seek_accurate")]
50    pub fn is_seek_accurate(&self) -> bool {
51        skip_assert_initialized!();
52        unsafe {
53            from_glib(ffi::gst_player_config_get_seek_accurate(
54                self.0.to_glib_none().0,
55            ))
56        }
57    }
58
59    #[doc(alias = "get_user_agent")]
60    #[doc(alias = "gst_player_config_get_user_agent")]
61    pub fn user_agent(&self) -> Option<String> {
62        skip_assert_initialized!();
63        unsafe {
64            from_glib_full(ffi::gst_player_config_get_user_agent(
65                self.0.to_glib_none().0,
66            ))
67        }
68    }
69
70    #[doc(alias = "gst_player_config_set_position_update_interval")]
71    pub fn set_position_update_interval(&mut self, interval: u32) {
72        skip_assert_initialized!();
73        unsafe {
74            ffi::gst_player_config_set_position_update_interval(
75                self.0.to_glib_none_mut().0,
76                interval,
77            );
78        }
79    }
80
81    pub fn set_seek_accurate(&mut self, accurate: bool) {
82        skip_assert_initialized!();
83        // FIXME: Work-around for
84        // http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=cc58bd6ae071dec4ea7b4be626034accd0372755
85        self.set("accurate-seek", accurate);
86    }
87
88    #[doc(alias = "gst_player_config_set_user_agent")]
89    pub fn set_user_agent(&mut self, agent: &str) {
90        skip_assert_initialized!();
91        unsafe {
92            ffi::gst_player_config_set_user_agent(
93                self.0.to_glib_none_mut().0,
94                agent.to_glib_none().0,
95            );
96        }
97    }
98}
99
100impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayerConfig {
101    #[inline]
102    fn into_glib_ptr(self) -> *mut gst::ffi::GstStructure {
103        let mut s = mem::ManuallyDrop::new(self);
104        s.0.to_glib_none_mut().0
105    }
106}
107
108impl FromGlibPtrFull<*mut gst::ffi::GstStructure> for PlayerConfig {
109    #[inline]
110    unsafe fn from_glib_full(ptr: *mut gst::ffi::GstStructure) -> Self {
111        PlayerConfig(from_glib_full(ptr))
112    }
113}