1 | // This file was generated by gir (https://github.com/gtk-rs/gir) |
2 | // from gir-files (https://github.com/gtk-rs/gir-files) |
3 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{Caps, Object, StreamFlags, StreamType, TagList}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem::transmute}; |
13 | |
14 | glib::wrapper! { |
15 | #[doc (alias = "GstStream" )] |
16 | pub struct Stream(Object<ffi::GstStream, ffi::GstStreamClass>) @extends Object; |
17 | |
18 | match fn { |
19 | type_ => || ffi::gst_stream_get_type(), |
20 | } |
21 | } |
22 | |
23 | impl Stream { |
24 | #[doc (alias = "gst_stream_new" )] |
25 | pub fn new( |
26 | stream_id: Option<&str>, |
27 | caps: Option<&Caps>, |
28 | type_: StreamType, |
29 | flags: StreamFlags, |
30 | ) -> Stream { |
31 | assert_initialized_main_thread!(); |
32 | unsafe { |
33 | from_glib_full(ffi::gst_stream_new( |
34 | stream_id.to_glib_none().0, |
35 | caps.to_glib_none().0, |
36 | type_.into_glib(), |
37 | flags.into_glib(), |
38 | )) |
39 | } |
40 | } |
41 | |
42 | #[doc (alias = "gst_stream_get_caps" )] |
43 | #[doc (alias = "get_caps" )] |
44 | pub fn caps(&self) -> Option<Caps> { |
45 | unsafe { from_glib_full(ffi::gst_stream_get_caps(self.to_glib_none().0)) } |
46 | } |
47 | |
48 | #[doc (alias = "gst_stream_get_stream_flags" )] |
49 | #[doc (alias = "get_stream_flags" )] |
50 | pub fn stream_flags(&self) -> StreamFlags { |
51 | unsafe { from_glib(ffi::gst_stream_get_stream_flags(self.to_glib_none().0)) } |
52 | } |
53 | |
54 | #[doc (alias = "gst_stream_get_stream_id" )] |
55 | #[doc (alias = "get_stream_id" )] |
56 | pub fn stream_id(&self) -> Option<glib::GString> { |
57 | unsafe { from_glib_none(ffi::gst_stream_get_stream_id(self.to_glib_none().0)) } |
58 | } |
59 | |
60 | #[doc (alias = "gst_stream_get_stream_type" )] |
61 | #[doc (alias = "get_stream_type" )] |
62 | pub fn stream_type(&self) -> StreamType { |
63 | unsafe { from_glib(ffi::gst_stream_get_stream_type(self.to_glib_none().0)) } |
64 | } |
65 | |
66 | #[doc (alias = "gst_stream_get_tags" )] |
67 | #[doc (alias = "get_tags" )] |
68 | pub fn tags(&self) -> Option<TagList> { |
69 | unsafe { from_glib_full(ffi::gst_stream_get_tags(self.to_glib_none().0)) } |
70 | } |
71 | |
72 | #[doc (alias = "gst_stream_set_caps" )] |
73 | pub fn set_caps(&self, caps: Option<&Caps>) { |
74 | unsafe { |
75 | ffi::gst_stream_set_caps(self.to_glib_none().0, caps.to_glib_none().0); |
76 | } |
77 | } |
78 | |
79 | #[doc (alias = "gst_stream_set_stream_flags" )] |
80 | pub fn set_stream_flags(&self, flags: StreamFlags) { |
81 | unsafe { |
82 | ffi::gst_stream_set_stream_flags(self.to_glib_none().0, flags.into_glib()); |
83 | } |
84 | } |
85 | |
86 | #[doc (alias = "gst_stream_set_stream_type" )] |
87 | pub fn set_stream_type(&self, stream_type: StreamType) { |
88 | unsafe { |
89 | ffi::gst_stream_set_stream_type(self.to_glib_none().0, stream_type.into_glib()); |
90 | } |
91 | } |
92 | |
93 | #[doc (alias = "gst_stream_set_tags" )] |
94 | pub fn set_tags(&self, tags: Option<&TagList>) { |
95 | unsafe { |
96 | ffi::gst_stream_set_tags(self.to_glib_none().0, tags.to_glib_none().0); |
97 | } |
98 | } |
99 | |
100 | #[doc (alias = "caps" )] |
101 | pub fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>( |
102 | &self, |
103 | f: F, |
104 | ) -> SignalHandlerId { |
105 | unsafe extern "C" fn notify_caps_trampoline<F: Fn(&Stream) + Send + Sync + 'static>( |
106 | this: *mut ffi::GstStream, |
107 | _param_spec: glib::ffi::gpointer, |
108 | f: glib::ffi::gpointer, |
109 | ) { |
110 | let f: &F = &*(f as *const F); |
111 | f(&from_glib_borrow(this)) |
112 | } |
113 | unsafe { |
114 | let f: Box_<F> = Box_::new(f); |
115 | connect_raw( |
116 | self.as_ptr() as *mut _, |
117 | b"notify::caps \0" .as_ptr() as *const _, |
118 | Some(transmute::<_, unsafe extern "C" fn()>( |
119 | notify_caps_trampoline::<F> as *const (), |
120 | )), |
121 | Box_::into_raw(f), |
122 | ) |
123 | } |
124 | } |
125 | |
126 | #[doc (alias = "stream-flags" )] |
127 | pub fn connect_stream_flags_notify<F: Fn(&Self) + Send + Sync + 'static>( |
128 | &self, |
129 | f: F, |
130 | ) -> SignalHandlerId { |
131 | unsafe extern "C" fn notify_stream_flags_trampoline< |
132 | F: Fn(&Stream) + Send + Sync + 'static, |
133 | >( |
134 | this: *mut ffi::GstStream, |
135 | _param_spec: glib::ffi::gpointer, |
136 | f: glib::ffi::gpointer, |
137 | ) { |
138 | let f: &F = &*(f as *const F); |
139 | f(&from_glib_borrow(this)) |
140 | } |
141 | unsafe { |
142 | let f: Box_<F> = Box_::new(f); |
143 | connect_raw( |
144 | self.as_ptr() as *mut _, |
145 | b"notify::stream-flags \0" .as_ptr() as *const _, |
146 | Some(transmute::<_, unsafe extern "C" fn()>( |
147 | notify_stream_flags_trampoline::<F> as *const (), |
148 | )), |
149 | Box_::into_raw(f), |
150 | ) |
151 | } |
152 | } |
153 | |
154 | #[doc (alias = "stream-type" )] |
155 | pub fn connect_stream_type_notify<F: Fn(&Self) + Send + Sync + 'static>( |
156 | &self, |
157 | f: F, |
158 | ) -> SignalHandlerId { |
159 | unsafe extern "C" fn notify_stream_type_trampoline< |
160 | F: Fn(&Stream) + Send + Sync + 'static, |
161 | >( |
162 | this: *mut ffi::GstStream, |
163 | _param_spec: glib::ffi::gpointer, |
164 | f: glib::ffi::gpointer, |
165 | ) { |
166 | let f: &F = &*(f as *const F); |
167 | f(&from_glib_borrow(this)) |
168 | } |
169 | unsafe { |
170 | let f: Box_<F> = Box_::new(f); |
171 | connect_raw( |
172 | self.as_ptr() as *mut _, |
173 | b"notify::stream-type \0" .as_ptr() as *const _, |
174 | Some(transmute::<_, unsafe extern "C" fn()>( |
175 | notify_stream_type_trampoline::<F> as *const (), |
176 | )), |
177 | Box_::into_raw(f), |
178 | ) |
179 | } |
180 | } |
181 | |
182 | #[doc (alias = "tags" )] |
183 | pub fn connect_tags_notify<F: Fn(&Self) + Send + Sync + 'static>( |
184 | &self, |
185 | f: F, |
186 | ) -> SignalHandlerId { |
187 | unsafe extern "C" fn notify_tags_trampoline<F: Fn(&Stream) + Send + Sync + 'static>( |
188 | this: *mut ffi::GstStream, |
189 | _param_spec: glib::ffi::gpointer, |
190 | f: glib::ffi::gpointer, |
191 | ) { |
192 | let f: &F = &*(f as *const F); |
193 | f(&from_glib_borrow(this)) |
194 | } |
195 | unsafe { |
196 | let f: Box_<F> = Box_::new(f); |
197 | connect_raw( |
198 | self.as_ptr() as *mut _, |
199 | b"notify::tags \0" .as_ptr() as *const _, |
200 | Some(transmute::<_, unsafe extern "C" fn()>( |
201 | notify_tags_trampoline::<F> as *const (), |
202 | )), |
203 | Box_::into_raw(f), |
204 | ) |
205 | } |
206 | } |
207 | } |
208 | |
209 | unsafe impl Send for Stream {} |
210 | unsafe impl Sync for Stream {} |
211 | |