1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::PlayerAudioInfo;
use crate::PlayerStreamInfo;
use crate::PlayerSubtitleInfo;
use crate::PlayerVideoInfo;
use glib::translate::*;

glib::wrapper! {
    /// Structure containing the media information of a URI.
    ///
    /// # Implements
    ///
    /// [`trait@glib::object::ObjectExt`]
    pub struct PlayerMediaInfo(Object<ffi::GstPlayerMediaInfo, ffi::GstPlayerMediaInfoClass>);

    match fn {
        type_ => || ffi::gst_player_media_info_get_type(),
    }
}

impl PlayerMediaInfo {
    ///
    /// # Returns
    ///
    /// A [`crate::glib::List`] of
    /// matching [`crate::PlayerAudioInfo`].
    #[doc(alias = "gst_player_media_info_get_audio_streams")]
    #[doc(alias = "get_audio_streams")]
    pub fn audio_streams(&self) -> Vec<PlayerAudioInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gst_player_media_info_get_audio_streams(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the container format.
    #[doc(alias = "gst_player_media_info_get_container_format")]
    #[doc(alias = "get_container_format")]
    pub fn container_format(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gst_player_media_info_get_container_format(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// duration of the media.
    #[doc(alias = "gst_player_media_info_get_duration")]
    #[doc(alias = "get_duration")]
    pub fn duration(&self) -> gst::ClockTime {
        unsafe {
            from_glib(ffi::gst_player_media_info_get_duration(
                self.to_glib_none().0,
            ))
        }
    }

    /// Function to get the image (or preview-image) stored in taglist.
    /// Application can use `gst_sample_*_()` API's to get caps, buffer etc.
    ///
    /// # Returns
    ///
    /// GstSample or NULL.
    #[doc(alias = "gst_player_media_info_get_image_sample")]
    #[doc(alias = "get_image_sample")]
    pub fn image_sample(&self) -> Option<gst::Sample> {
        unsafe {
            from_glib_none(ffi::gst_player_media_info_get_image_sample(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// number of audio streams.
    #[doc(alias = "gst_player_media_info_get_number_of_audio_streams")]
    #[doc(alias = "get_number_of_audio_streams")]
    pub fn number_of_audio_streams(&self) -> u32 {
        unsafe { ffi::gst_player_media_info_get_number_of_audio_streams(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// number of total streams.
    #[doc(alias = "gst_player_media_info_get_number_of_streams")]
    #[doc(alias = "get_number_of_streams")]
    pub fn number_of_streams(&self) -> u32 {
        unsafe { ffi::gst_player_media_info_get_number_of_streams(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// number of subtitle streams.
    #[doc(alias = "gst_player_media_info_get_number_of_subtitle_streams")]
    #[doc(alias = "get_number_of_subtitle_streams")]
    pub fn number_of_subtitle_streams(&self) -> u32 {
        unsafe { ffi::gst_player_media_info_get_number_of_subtitle_streams(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// number of video streams.
    #[doc(alias = "gst_player_media_info_get_number_of_video_streams")]
    #[doc(alias = "get_number_of_video_streams")]
    pub fn number_of_video_streams(&self) -> u32 {
        unsafe { ffi::gst_player_media_info_get_number_of_video_streams(self.to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// A [`crate::glib::List`] of
    /// matching [`crate::PlayerStreamInfo`].
    #[doc(alias = "gst_player_media_info_get_stream_list")]
    #[doc(alias = "get_stream_list")]
    pub fn stream_list(&self) -> Vec<PlayerStreamInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gst_player_media_info_get_stream_list(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// A [`crate::glib::List`] of
    /// matching [`crate::PlayerSubtitleInfo`].
    #[doc(alias = "gst_player_media_info_get_subtitle_streams")]
    #[doc(alias = "get_subtitle_streams")]
    pub fn subtitle_streams(&self) -> Vec<PlayerSubtitleInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gst_player_media_info_get_subtitle_streams(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the tags contained in media info.
    #[doc(alias = "gst_player_media_info_get_tags")]
    #[doc(alias = "get_tags")]
    pub fn tags(&self) -> Option<gst::TagList> {
        unsafe { from_glib_none(ffi::gst_player_media_info_get_tags(self.to_glib_none().0)) }
    }

    ///
    /// # Returns
    ///
    /// the media title.
    #[doc(alias = "gst_player_media_info_get_title")]
    #[doc(alias = "get_title")]
    pub fn title(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::gst_player_media_info_get_title(self.to_glib_none().0)) }
    }

    ///
    /// # Returns
    ///
    /// the URI associated with [`crate::PlayerMediaInfo`].
    #[doc(alias = "gst_player_media_info_get_uri")]
    #[doc(alias = "get_uri")]
    pub fn uri(&self) -> glib::GString {
        unsafe { from_glib_none(ffi::gst_player_media_info_get_uri(self.to_glib_none().0)) }
    }

    ///
    /// # Returns
    ///
    /// A [`crate::glib::List`] of
    /// matching [`crate::PlayerVideoInfo`].
    #[doc(alias = "gst_player_media_info_get_video_streams")]
    #[doc(alias = "get_video_streams")]
    pub fn video_streams(&self) -> Vec<PlayerVideoInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gst_player_media_info_get_video_streams(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// [`true`] if the media is live.
    #[doc(alias = "gst_player_media_info_is_live")]
    pub fn is_live(&self) -> bool {
        unsafe { from_glib(ffi::gst_player_media_info_is_live(self.to_glib_none().0)) }
    }

    ///
    /// # Returns
    ///
    /// [`true`] if the media is seekable.
    #[doc(alias = "gst_player_media_info_is_seekable")]
    pub fn is_seekable(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_player_media_info_is_seekable(
                self.to_glib_none().0,
            ))
        }
    }
}

unsafe impl Send for PlayerMediaInfo {}
unsafe impl Sync for PlayerMediaInfo {}