gstreamer/parse_context.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ffi;
4use glib::translate::*;
5
6glib::wrapper! {
7 /// Opaque structure.
8 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9 #[doc(alias = "GstParseContext")]
10 pub struct ParseContext(Boxed<ffi::GstParseContext>);
11
12 match fn {
13 copy => |ptr| ffi::gst_parse_context_copy(ptr),
14 free => |ptr| ffi::gst_parse_context_free(ptr),
15 type_ => || ffi::gst_parse_context_get_type(),
16 }
17}
18
19unsafe impl Send for ParseContext {}
20unsafe impl Sync for ParseContext {}
21
22impl ParseContext {
23 /// Allocates a parse context for use with `gst_parse_launch_full()` or
24 /// `gst_parse_launchv_full()`.
25 ///
26 /// Free-function: gst_parse_context_free
27 ///
28 /// # Returns
29 ///
30 /// a newly-allocated parse context. Free
31 /// with `gst_parse_context_free()` when no longer needed.
32 #[doc(alias = "gst_parse_context_new")]
33 pub fn new() -> Self {
34 unsafe { from_glib_full(ffi::gst_parse_context_new()) }
35 }
36
37 /// Retrieve missing elements from a previous run of `gst_parse_launch_full()`
38 /// or `gst_parse_launchv_full()`. Will only return results if an error code
39 /// of [`ParseError::NoSuchElement`][crate::ParseError::NoSuchElement] was returned.
40 ///
41 /// # Returns
42 ///
43 /// a
44 /// [`None`]-terminated array of element factory name strings of missing
45 /// elements. Free with `g_strfreev()` when no longer needed.
46 #[doc(alias = "get_missing_elements")]
47 #[doc(alias = "gst_parse_context_get_missing_elements")]
48 pub fn missing_elements(&self) -> Vec<String> {
49 unsafe {
50 FromGlibPtrContainer::from_glib_full(ffi::gst_parse_context_get_missing_elements(
51 mut_override(self.to_glib_none().0),
52 ))
53 }
54 }
55}
56
57impl Default for ParseContext {
58 fn default() -> Self {
59 Self::new()
60 }
61}