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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;
use glib::GString;
use gst;
use gst_player_sys;
use PlayerAudioInfo;
use PlayerStreamInfo;
use PlayerSubtitleInfo;
use PlayerVideoInfo;

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

    match fn {
        get_type => || gst_player_sys::gst_player_media_info_get_type(),
    }
}

impl PlayerMediaInfo {
    ///
    /// # Returns
    ///
    /// A `glib::List` of
    /// matching `PlayerAudioInfo`.
    pub fn get_audio_streams(&self) -> Vec<PlayerAudioInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                gst_player_sys::gst_player_media_info_get_audio_streams(self.to_glib_none().0),
            )
        }
    }

    ///
    /// # Returns
    ///
    /// the container format.
    pub fn get_container_format(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gst_player_sys::gst_player_media_info_get_container_format(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// duration of the media.
    pub fn get_duration(&self) -> gst::ClockTime {
        unsafe {
            from_glib(gst_player_sys::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.
    pub fn get_image_sample(&self) -> Option<gst::Sample> {
        unsafe {
            from_glib_none(gst_player_sys::gst_player_media_info_get_image_sample(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// number of audio streams.
    pub fn get_number_of_audio_streams(&self) -> u32 {
        unsafe {
            gst_player_sys::gst_player_media_info_get_number_of_audio_streams(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// number of total streams.
    pub fn get_number_of_streams(&self) -> u32 {
        unsafe {
            gst_player_sys::gst_player_media_info_get_number_of_streams(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// number of subtitle streams.
    pub fn get_number_of_subtitle_streams(&self) -> u32 {
        unsafe {
            gst_player_sys::gst_player_media_info_get_number_of_subtitle_streams(
                self.to_glib_none().0,
            )
        }
    }

    ///
    /// # Returns
    ///
    /// number of video streams.
    pub fn get_number_of_video_streams(&self) -> u32 {
        unsafe {
            gst_player_sys::gst_player_media_info_get_number_of_video_streams(self.to_glib_none().0)
        }
    }

    ///
    /// # Returns
    ///
    /// A `glib::List` of
    /// matching `PlayerStreamInfo`.
    pub fn get_stream_list(&self) -> Vec<PlayerStreamInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                gst_player_sys::gst_player_media_info_get_stream_list(self.to_glib_none().0),
            )
        }
    }

    ///
    /// # Returns
    ///
    /// A `glib::List` of
    /// matching `PlayerSubtitleInfo`.
    pub fn get_subtitle_streams(&self) -> Vec<PlayerSubtitleInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                gst_player_sys::gst_player_media_info_get_subtitle_streams(self.to_glib_none().0),
            )
        }
    }

    ///
    /// # Returns
    ///
    /// the tags contained in media info.
    pub fn get_tags(&self) -> Option<gst::TagList> {
        unsafe {
            from_glib_none(gst_player_sys::gst_player_media_info_get_tags(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the media title.
    pub fn get_title(&self) -> Option<GString> {
        unsafe {
            from_glib_none(gst_player_sys::gst_player_media_info_get_title(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// the URI associated with `PlayerMediaInfo`.
    pub fn get_uri(&self) -> GString {
        unsafe {
            from_glib_none(gst_player_sys::gst_player_media_info_get_uri(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// A `glib::List` of
    /// matching `PlayerVideoInfo`.
    pub fn get_video_streams(&self) -> Vec<PlayerVideoInfo> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(
                gst_player_sys::gst_player_media_info_get_video_streams(self.to_glib_none().0),
            )
        }
    }

    ///
    /// # Returns
    ///
    /// `true` if the media is live.
    pub fn is_live(&self) -> bool {
        unsafe {
            from_glib(gst_player_sys::gst_player_media_info_is_live(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// `true` if the media is seekable.
    pub fn is_seekable(&self) -> bool {
        unsafe {
            from_glib(gst_player_sys::gst_player_media_info_is_seekable(
                self.to_glib_none().0,
            ))
        }
    }
}

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