gstreamer_mse/
source_buffer_interval.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5use crate::ffi;
6
7glib::wrapper! {
8    #[doc(alias = "GstSourceBufferInterval")]
9    pub struct SourceBufferInterval(BoxedInline<ffi::GstSourceBufferInterval>);
10
11    match fn {}
12}
13
14impl SourceBufferInterval {
15    pub fn new(start: gst::ClockTime, end: gst::ClockTime) -> Self {
16        skip_assert_initialized!();
17
18        let inner = ffi::GstSourceBufferInterval {
19            start: start.nseconds(),
20            end: end.nseconds(),
21        };
22
23        Self { inner }
24    }
25
26    pub fn start(&self) -> gst::ClockTime {
27        gst::ClockTime::from_nseconds(self.inner.start)
28    }
29
30    pub fn set_start(&mut self, start: gst::ClockTime) {
31        self.inner.start = start.nseconds();
32    }
33
34    pub fn end(&self) -> gst::ClockTime {
35        gst::ClockTime::from_nseconds(self.inner.end)
36    }
37
38    pub fn set_end(&mut self, end: gst::ClockTime) {
39        self.inner.end = end.nseconds();
40    }
41}
42
43unsafe impl Send for SourceBufferInterval {}
44unsafe impl Sync for SourceBufferInterval {}
45
46impl PartialEq for SourceBufferInterval {
47    fn eq(&self, other: &Self) -> bool {
48        self.inner.start == other.inner.start && self.inner.end == other.inner.end
49    }
50}
51
52impl Eq for SourceBufferInterval {}
53
54impl fmt::Debug for SourceBufferInterval {
55    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
56        f.debug_struct("SourceBufferInterval")
57            .field("start", &self.start())
58            .field("end", &self.end())
59            .finish()
60    }
61}