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
// 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::{Element, Object, Toc};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// Element interface that allows setting of the TOC.
    ///
    /// Elements that support some kind of chapters or editions (or tracks like in
    /// the FLAC cue sheet) will implement this interface.
    ///
    /// If you just want to retrieve the TOC in your application then all you
    /// need to do is watch for TOC messages on your pipeline's bus (or you can
    /// perform TOC query). This interface is only for setting TOC data, not for
    /// extracting it. To set TOC from the application, find proper tocsetter element
    /// and set TOC using [`TocSetterExt::set_toc()`][crate::prelude::TocSetterExt::set_toc()].
    ///
    /// Elements implementing the [`TocSetter`][crate::TocSetter] interface can extend existing TOC
    /// by getting extend UID for that (you can use [`Toc::find_entry()`][crate::Toc::find_entry()] to retrieve it)
    /// with any TOC entries received from downstream.
    ///
    /// # Implements
    ///
    /// [`TocSetterExt`][trait@crate::prelude::TocSetterExt], [`ElementExt`][trait@crate::prelude::ElementExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ElementExtManual`][trait@crate::prelude::ElementExtManual]
    #[doc(alias = "GstTocSetter")]
    pub struct TocSetter(Interface<ffi::GstTocSetter, ffi::GstTocSetterInterface>) @requires Element, Object;

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

impl TocSetter {
    pub const NONE: Option<&'static TocSetter> = None;
}

unsafe impl Send for TocSetter {}
unsafe impl Sync for TocSetter {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::TocSetter>> Sealed for T {}
}

/// Trait containing all [`struct@TocSetter`] methods.
///
/// # Implementors
///
/// [`TocSetter`][struct@crate::TocSetter]
pub trait TocSetterExt: IsA<TocSetter> + sealed::Sealed + 'static {
    /// Return current TOC the setter uses. The TOC should not be
    /// modified without making it writable first.
    ///
    /// # Returns
    ///
    /// TOC set, or [`None`]. Unref with
    ///  `gst_toc_unref()` when no longer needed
    #[doc(alias = "gst_toc_setter_get_toc")]
    #[doc(alias = "get_toc")]
    fn toc(&self) -> Option<Toc> {
        unsafe { from_glib_full(ffi::gst_toc_setter_get_toc(self.as_ref().to_glib_none().0)) }
    }

    /// Reset the internal TOC. Elements should call this from within the
    /// state-change handler.
    #[doc(alias = "gst_toc_setter_reset")]
    fn reset(&self) {
        unsafe {
            ffi::gst_toc_setter_reset(self.as_ref().to_glib_none().0);
        }
    }

    /// Set the given TOC on the setter. Previously set TOC will be
    /// unreffed before setting a new one.
    /// ## `toc`
    /// a [`Toc`][crate::Toc] to set.
    #[doc(alias = "gst_toc_setter_set_toc")]
    fn set_toc(&self, toc: Option<&Toc>) {
        unsafe {
            ffi::gst_toc_setter_set_toc(self.as_ref().to_glib_none().0, toc.to_glib_none().0);
        }
    }
}

impl<O: IsA<TocSetter>> TocSetterExt for O {}