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
use std::ptr;
use ffi;
use glib;
use glib::StaticType;
use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, ToGlibPtr};
use miniobject::*;
use Buffer;
use BufferList;
use Caps;
use FormattedValue;
use Segment;
use FormattedSegment;
use StructureRef;
pub type Sample = GstRc<SampleRef>;
pub struct SampleRef(ffi::GstSample);
unsafe impl MiniObject for SampleRef {
type GstType = ffi::GstSample;
}
impl GstRc<SampleRef> {
pub fn new<F: FormattedValue>(
buffer: Option<&Buffer>,
caps: Option<&Caps>,
segment: Option<&FormattedSegment<F>>,
info: Option<&StructureRef>,
) -> Self {
assert_initialized_main_thread!();
unsafe {
let info = info.map(|i| i.as_ptr()).unwrap_or(ptr::null());
from_glib_full(ffi::gst_sample_new(
buffer.to_glib_none().0,
caps.to_glib_none().0,
mut_override(segment.to_glib_none().0),
mut_override(info),
))
}
}
}
impl SampleRef {
pub fn get_buffer(&self) -> Option<Buffer> {
unsafe { from_glib_none(ffi::gst_sample_get_buffer(self.as_mut_ptr())) }
}
pub fn get_buffer_list(&self) -> Option<BufferList> {
unsafe { from_glib_none(ffi::gst_sample_get_buffer_list(self.as_mut_ptr())) }
}
pub fn get_caps(&self) -> Option<Caps> {
unsafe { from_glib_none(ffi::gst_sample_get_caps(self.as_mut_ptr())) }
}
pub fn get_segment(&self) -> Option<Segment> {
unsafe { from_glib_none(ffi::gst_sample_get_segment(self.as_mut_ptr())) }
}
pub fn get_structure(&self) -> Option<&StructureRef> {
unsafe {
let ptr = ffi::gst_sample_get_info(self.as_mut_ptr());
if ptr.is_null() {
None
} else {
Some(StructureRef::from_glib_borrow(ptr))
}
}
}
}
impl StaticType for SampleRef {
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::gst_sample_get_type()) }
}
}
impl ToOwned for SampleRef {
type Owned = GstRc<SampleRef>;
fn to_owned(&self) -> GstRc<SampleRef> {
unsafe {
from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _)
as *mut _)
}
}
}
unsafe impl Sync for SampleRef {}
unsafe impl Send for SampleRef {}