gstreamer_mse/media_source_range.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 = "GstMediaSourceRange")]
9 pub struct MediaSourceRange(BoxedInline<ffi::GstMediaSourceRange>);
10
11 match fn {}
12}
13
14impl MediaSourceRange {
15 pub fn new(start: gst::ClockTime, end: gst::ClockTime) -> Self {
16 skip_assert_initialized!();
17
18 let inner = ffi::GstMediaSourceRange {
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 MediaSourceRange {}
44unsafe impl Sync for MediaSourceRange {}
45
46impl PartialEq for MediaSourceRange {
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 MediaSourceRange {}
53
54impl fmt::Debug for MediaSourceRange {
55 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
56 f.debug_struct("MediaSourceRange")
57 .field("start", &self.start())
58 .field("end", &self.end())
59 .finish()
60 }
61}