element.rs 21.6 KB
Newer Older
1 2
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
Sebastian Dröge's avatar
Sebastian Dröge committed
3 4 5
// DO NOT EDIT

use Bus;
6
use Caps;
Sebastian Dröge's avatar
Sebastian Dröge committed
7 8
use Clock;
use ClockTime;
9
use Context;
10
use ElementClass;
Sebastian Dröge's avatar
Sebastian Dröge committed
11 12
use ElementFactory;
use Error;
13
use Message;
Sebastian Dröge's avatar
Sebastian Dröge committed
14 15
use Object;
use Pad;
Sebastian Dröge's avatar
Sebastian Dröge committed
16
use PadLinkCheck;
Sebastian Dröge's avatar
Sebastian Dröge committed
17
use PadTemplate;
18
use Plugin;
Sebastian Dröge's avatar
Sebastian Dröge committed
19 20 21 22 23 24 25 26
use State;
use StateChange;
use StateChangeReturn;
use URIType;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
27
use glib::signal::SignalHandlerId;
28
use glib::signal::connect_raw;
Sebastian Dröge's avatar
Sebastian Dröge committed
29 30 31 32 33 34 35 36
use glib::translate::*;
use glib_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
37
    pub struct Element(Object<ffi::GstElement, ffi::GstElementClass, ElementClass>): Object;
Sebastian Dröge's avatar
Sebastian Dröge committed
38 39 40 41 42 43 44 45

    match fn {
        get_type => || ffi::gst_element_get_type(),
    }
}

impl Element {
    pub fn make_from_uri<'a, P: Into<Option<&'a str>>>(type_: URIType, uri: &str, elementname: P) -> Result<Element, Error> {
46
        assert_initialized_main_thread!();
Sebastian Dröge's avatar
Sebastian Dröge committed
47 48 49 50 51 52 53 54 55
        let elementname = elementname.into();
        let elementname = elementname.to_glib_none();
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ffi::gst_element_make_from_uri(type_.to_glib(), uri.to_glib_none().0, elementname.0, &mut error);
            if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
        }
    }

56
    pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> Result<(), glib::error::BoolError> {
57
        assert_initialized_main_thread!();
58 59 60
        let plugin = plugin.into();
        let plugin = plugin.to_glib_none();
        unsafe {
François Laignel's avatar
François Laignel committed
61
            glib_result_from_gboolean!(ffi::gst_element_register(plugin.0, name.to_glib_none().0, rank, type_.to_glib()), "Failed to register element factory")
62 63
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
64 65
}

66 67 68
unsafe impl Send for Element {}
unsafe impl Sync for Element {}

69
pub trait ElementExt: 'static {
Sebastian Dröge's avatar
Sebastian Dröge committed
70 71
    fn abort_state(&self);

72
    fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
73

74
    //#[cfg(any(feature = "v1_10", feature = "dox"))]
75
    //fn call_async(&self, func: /*Unknown conversion*//*Unimplemented*/ElementCallAsyncFunc, destroy_notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify);
Sebastian Dröge's avatar
Sebastian Dröge committed
76 77 78 79 80 81 82

    fn change_state(&self, transition: StateChange) -> StateChangeReturn;

    fn continue_state(&self, ret: StateChangeReturn) -> StateChangeReturn;

    fn create_all_pads(&self);

Sebastian Dröge's avatar
Sebastian Dröge committed
83 84 85 86 87 88 89 90 91
    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool;

    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_sink_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool;

    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_src_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool;

Sebastian Dröge's avatar
Sebastian Dröge committed
92 93 94 95 96 97
    fn get_base_time(&self) -> ClockTime;

    fn get_bus(&self) -> Option<Bus>;

    fn get_clock(&self) -> Option<Clock>;

98
    fn get_compatible_pad<'a, P: IsA<Pad>, Q: Into<Option<&'a Caps>>>(&self, pad: &P, caps: Q) -> Option<Pad>;
Sebastian Dröge's avatar
Sebastian Dröge committed
99 100 101

    fn get_compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate>;

102
    fn get_context(&self, context_type: &str) -> Option<Context>;
Sebastian Dröge's avatar
Sebastian Dröge committed
103

104
    fn get_contexts(&self) -> Vec<Context>;
Sebastian Dröge's avatar
Sebastian Dröge committed
105 106 107 108 109 110 111 112 113 114 115 116 117

    fn get_factory(&self) -> Option<ElementFactory>;

    fn get_request_pad(&self, name: &str) -> Option<Pad>;

    fn get_start_time(&self) -> ClockTime;

    fn get_state(&self, timeout: ClockTime) -> (StateChangeReturn, State, State);

    fn get_static_pad(&self, name: &str) -> Option<Pad>;

    fn is_locked_state(&self) -> bool;

118
    //fn iterate_pads(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
119

120
    //fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
121

122
    //fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
123

124
    fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
125

126
    fn link_filtered<'a, P: IsA<Element>, Q: Into<Option<&'a Caps>>>(&self, dest: &P, filter: Q) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
127 128 129

    //fn link_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool;

130
    fn link_pads<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>>(&self, srcpadname: P, dest: &Q, destpadname: R) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
131

132
    fn link_pads_filtered<'a, 'b, 'c, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>, S: Into<Option<&'c Caps>>>(&self, srcpadname: P, dest: &Q, destpadname: R, filter: S) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
133

134
    fn link_pads_full<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>>(&self, srcpadname: P, dest: &Q, destpadname: R, flags: PadLinkCheck) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
135 136 137

    fn lost_state(&self);

138
    //fn message_full<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32);
Sebastian Dröge's avatar
Sebastian Dröge committed
139

140
    //#[cfg(any(feature = "v1_10", feature = "dox"))]
141
    //fn message_full_with_details<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: &mut Structure);
Sebastian Dröge's avatar
Sebastian Dröge committed
142 143 144

    fn no_more_pads(&self);

145
    fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
146 147 148 149 150

    fn provide_clock(&self) -> Option<Clock>;

    fn release_request_pad<P: IsA<Pad>>(&self, pad: &P);

151
    fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
152

153
    fn request_pad<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b Caps>>>(&self, templ: &PadTemplate, name: P, caps: Q) -> Option<Pad>;
Sebastian Dröge's avatar
Sebastian Dröge committed
154 155 156

    fn set_base_time(&self, time: ClockTime);

157
    fn set_bus<'a, P: Into<Option<&'a Bus>>>(&self, bus: P);
Sebastian Dröge's avatar
Sebastian Dröge committed
158

159
    fn set_clock<'a, P: IsA<Clock> + 'a, Q: Into<Option<&'a P>>>(&self, clock: Q) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
160

161
    fn set_context(&self, context: &Context);
Sebastian Dröge's avatar
Sebastian Dröge committed
162 163 164 165 166 167 168

    fn set_locked_state(&self, locked_state: bool) -> bool;

    fn set_start_time(&self, time: ClockTime);

    fn set_state(&self, state: State) -> StateChangeReturn;

169
    fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
170 171 172 173 174 175 176

    fn unlink<P: IsA<Element>>(&self, dest: &P);

    //fn unlink_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str);

177
    fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
178

179
    fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
180

181
    fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
182 183
}

184
impl<O: IsA<Element>> ElementExt for O {
Sebastian Dröge's avatar
Sebastian Dröge committed
185 186 187 188 189 190
    fn abort_state(&self) {
        unsafe {
            ffi::gst_element_abort_state(self.to_glib_none().0);
        }
    }

191
    fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
192
        unsafe {
François Laignel's avatar
François Laignel committed
193
            glib_result_from_gboolean!(ffi::gst_element_add_pad(self.to_glib_none().0, pad.to_glib_none().0), "Failed to add pad")
Sebastian Dröge's avatar
Sebastian Dröge committed
194 195 196
        }
    }

197
    //#[cfg(any(feature = "v1_10", feature = "dox"))]
198
    //fn call_async(&self, func: /*Unknown conversion*//*Unimplemented*/ElementCallAsyncFunc, destroy_notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) {
Sebastian Dröge's avatar
Sebastian Dröge committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
    //    unsafe { TODO: call ffi::gst_element_call_async() }
    //}

    fn change_state(&self, transition: StateChange) -> StateChangeReturn {
        unsafe {
            from_glib(ffi::gst_element_change_state(self.to_glib_none().0, transition.to_glib()))
        }
    }

    fn continue_state(&self, ret: StateChangeReturn) -> StateChangeReturn {
        unsafe {
            from_glib(ffi::gst_element_continue_state(self.to_glib_none().0, ret.to_glib()))
        }
    }

    fn create_all_pads(&self) {
        unsafe {
            ffi::gst_element_create_all_pads(self.to_glib_none().0);
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool {
    //    unsafe { TODO: call ffi::gst_element_foreach_pad() }
    //}

    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_sink_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool {
    //    unsafe { TODO: call ffi::gst_element_foreach_sink_pad() }
    //}

    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn foreach_src_pad<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, func: /*Unknown conversion*//*Unimplemented*/ElementForeachPadFunc, user_data: P) -> bool {
    //    unsafe { TODO: call ffi::gst_element_foreach_src_pad() }
    //}

Sebastian Dröge's avatar
Sebastian Dröge committed
235 236
    fn get_base_time(&self) -> ClockTime {
        unsafe {
237
            from_glib(ffi::gst_element_get_base_time(self.to_glib_none().0))
Sebastian Dröge's avatar
Sebastian Dröge committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
        }
    }

    fn get_bus(&self) -> Option<Bus> {
        unsafe {
            from_glib_full(ffi::gst_element_get_bus(self.to_glib_none().0))
        }
    }

    fn get_clock(&self) -> Option<Clock> {
        unsafe {
            from_glib_full(ffi::gst_element_get_clock(self.to_glib_none().0))
        }
    }

253 254 255 256 257 258 259
    fn get_compatible_pad<'a, P: IsA<Pad>, Q: Into<Option<&'a Caps>>>(&self, pad: &P, caps: Q) -> Option<Pad> {
        let caps = caps.into();
        let caps = caps.to_glib_none();
        unsafe {
            from_glib_full(ffi::gst_element_get_compatible_pad(self.to_glib_none().0, pad.to_glib_none().0, caps.0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
260 261 262 263 264 265 266

    fn get_compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate> {
        unsafe {
            from_glib_none(ffi::gst_element_get_compatible_pad_template(self.to_glib_none().0, compattempl.to_glib_none().0))
        }
    }

267 268 269 270 271
    fn get_context(&self, context_type: &str) -> Option<Context> {
        unsafe {
            from_glib_full(ffi::gst_element_get_context(self.to_glib_none().0, context_type.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
272

273 274 275 276 277
    fn get_contexts(&self) -> Vec<Context> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::gst_element_get_contexts(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292

    fn get_factory(&self) -> Option<ElementFactory> {
        unsafe {
            from_glib_none(ffi::gst_element_get_factory(self.to_glib_none().0))
        }
    }

    fn get_request_pad(&self, name: &str) -> Option<Pad> {
        unsafe {
            from_glib_full(ffi::gst_element_get_request_pad(self.to_glib_none().0, name.to_glib_none().0))
        }
    }

    fn get_start_time(&self) -> ClockTime {
        unsafe {
293
            from_glib(ffi::gst_element_get_start_time(self.to_glib_none().0))
Sebastian Dröge's avatar
Sebastian Dröge committed
294 295 296 297 298 299 300
        }
    }

    fn get_state(&self, timeout: ClockTime) -> (StateChangeReturn, State, State) {
        unsafe {
            let mut state = mem::uninitialized();
            let mut pending = mem::uninitialized();
301
            let ret = from_glib(ffi::gst_element_get_state(self.to_glib_none().0, &mut state, &mut pending, timeout.to_glib()));
Sebastian Dröge's avatar
Sebastian Dröge committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
            (ret, from_glib(state), from_glib(pending))
        }
    }

    fn get_static_pad(&self, name: &str) -> Option<Pad> {
        unsafe {
            from_glib_full(ffi::gst_element_get_static_pad(self.to_glib_none().0, name.to_glib_none().0))
        }
    }

    fn is_locked_state(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_element_is_locked_state(self.to_glib_none().0))
        }
    }

318 319 320
    //fn iterate_pads(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_element_iterate_pads() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
321

322 323 324
    //fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_element_iterate_sink_pads() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
325

326 327 328
    //fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_element_iterate_src_pads() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
329

330
    fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
331
        unsafe {
François Laignel's avatar
François Laignel committed
332
            glib_result_from_gboolean!(ffi::gst_element_link(self.to_glib_none().0, dest.to_glib_none().0), "Failed to link elements")
Sebastian Dröge's avatar
Sebastian Dröge committed
333 334 335
        }
    }

336 337 338 339
    fn link_filtered<'a, P: IsA<Element>, Q: Into<Option<&'a Caps>>>(&self, dest: &P, filter: Q) -> Result<(), glib::error::BoolError> {
        let filter = filter.into();
        let filter = filter.to_glib_none();
        unsafe {
François Laignel's avatar
François Laignel committed
340
            glib_result_from_gboolean!(ffi::gst_element_link_filtered(self.to_glib_none().0, dest.to_glib_none().0, filter.0), "Failed to link elements")
341 342
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
343 344 345 346 347

    //fn link_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool {
    //    unsafe { TODO: call ffi::gst_element_link_many() }
    //}

348
    fn link_pads<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>>(&self, srcpadname: P, dest: &Q, destpadname: R) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
349 350 351 352 353
        let srcpadname = srcpadname.into();
        let srcpadname = srcpadname.to_glib_none();
        let destpadname = destpadname.into();
        let destpadname = destpadname.to_glib_none();
        unsafe {
François Laignel's avatar
François Laignel committed
354
            glib_result_from_gboolean!(ffi::gst_element_link_pads(self.to_glib_none().0, srcpadname.0, dest.to_glib_none().0, destpadname.0), "Failed to link pads")
Sebastian Dröge's avatar
Sebastian Dröge committed
355 356 357
        }
    }

358 359 360 361 362 363 364 365
    fn link_pads_filtered<'a, 'b, 'c, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>, S: Into<Option<&'c Caps>>>(&self, srcpadname: P, dest: &Q, destpadname: R, filter: S) -> Result<(), glib::error::BoolError> {
        let srcpadname = srcpadname.into();
        let srcpadname = srcpadname.to_glib_none();
        let destpadname = destpadname.into();
        let destpadname = destpadname.to_glib_none();
        let filter = filter.into();
        let filter = filter.to_glib_none();
        unsafe {
François Laignel's avatar
François Laignel committed
366
            glib_result_from_gboolean!(ffi::gst_element_link_pads_filtered(self.to_glib_none().0, srcpadname.0, dest.to_glib_none().0, destpadname.0, filter.0), "Failed to link pads")
367 368
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
369

370
    fn link_pads_full<'a, 'b, P: Into<Option<&'a str>>, Q: IsA<Element>, R: Into<Option<&'b str>>>(&self, srcpadname: P, dest: &Q, destpadname: R, flags: PadLinkCheck) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
371 372 373 374 375
        let srcpadname = srcpadname.into();
        let srcpadname = srcpadname.to_glib_none();
        let destpadname = destpadname.into();
        let destpadname = destpadname.to_glib_none();
        unsafe {
François Laignel's avatar
François Laignel committed
376
            glib_result_from_gboolean!(ffi::gst_element_link_pads_full(self.to_glib_none().0, srcpadname.0, dest.to_glib_none().0, destpadname.0, flags.to_glib()), "Failed to link pads")
Sebastian Dröge's avatar
Sebastian Dröge committed
377 378
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
379 380 381 382 383 384 385

    fn lost_state(&self) {
        unsafe {
            ffi::gst_element_lost_state(self.to_glib_none().0);
        }
    }

386
    //fn message_full<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32) {
Sebastian Dröge's avatar
Sebastian Dröge committed
387 388 389
    //    unsafe { TODO: call ffi::gst_element_message_full() }
    //}

390
    //#[cfg(any(feature = "v1_10", feature = "dox"))]
391
    //fn message_full_with_details<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: &mut Structure) {
Sebastian Dröge's avatar
Sebastian Dröge committed
392 393 394 395 396 397 398 399 400
    //    unsafe { TODO: call ffi::gst_element_message_full_with_details() }
    //}

    fn no_more_pads(&self) {
        unsafe {
            ffi::gst_element_no_more_pads(self.to_glib_none().0);
        }
    }

401
    fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError> {
402
        unsafe {
François Laignel's avatar
François Laignel committed
403
            glib_result_from_gboolean!(ffi::gst_element_post_message(self.to_glib_none().0, message.to_glib_full()), "Failed to post message")
404 405
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
406 407 408 409 410 411 412 413 414 415 416 417 418

    fn provide_clock(&self) -> Option<Clock> {
        unsafe {
            from_glib_full(ffi::gst_element_provide_clock(self.to_glib_none().0))
        }
    }

    fn release_request_pad<P: IsA<Pad>>(&self, pad: &P) {
        unsafe {
            ffi::gst_element_release_request_pad(self.to_glib_none().0, pad.to_glib_none().0);
        }
    }

419
    fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
420
        unsafe {
François Laignel's avatar
François Laignel committed
421
            glib_result_from_gboolean!(ffi::gst_element_remove_pad(self.to_glib_none().0, pad.to_glib_none().0), "Failed to remove pad")
Sebastian Dröge's avatar
Sebastian Dröge committed
422 423 424
        }
    }

425 426 427 428 429 430 431 432 433
    fn request_pad<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b Caps>>>(&self, templ: &PadTemplate, name: P, caps: Q) -> Option<Pad> {
        let name = name.into();
        let name = name.to_glib_none();
        let caps = caps.into();
        let caps = caps.to_glib_none();
        unsafe {
            from_glib_full(ffi::gst_element_request_pad(self.to_glib_none().0, templ.to_glib_none().0, name.0, caps.0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
434 435 436

    fn set_base_time(&self, time: ClockTime) {
        unsafe {
437
            ffi::gst_element_set_base_time(self.to_glib_none().0, time.to_glib());
Sebastian Dröge's avatar
Sebastian Dröge committed
438 439 440
        }
    }

441 442 443
    fn set_bus<'a, P: Into<Option<&'a Bus>>>(&self, bus: P) {
        let bus = bus.into();
        let bus = bus.to_glib_none();
Sebastian Dröge's avatar
Sebastian Dröge committed
444
        unsafe {
445
            ffi::gst_element_set_bus(self.to_glib_none().0, bus.0);
Sebastian Dröge's avatar
Sebastian Dröge committed
446 447 448
        }
    }

449 450 451
    fn set_clock<'a, P: IsA<Clock> + 'a, Q: Into<Option<&'a P>>>(&self, clock: Q) -> Result<(), glib::error::BoolError> {
        let clock = clock.into();
        let clock = clock.to_glib_none();
Sebastian Dröge's avatar
Sebastian Dröge committed
452
        unsafe {
François Laignel's avatar
François Laignel committed
453
            glib_result_from_gboolean!(ffi::gst_element_set_clock(self.to_glib_none().0, clock.0), "Failed to set clock")
Sebastian Dröge's avatar
Sebastian Dröge committed
454 455 456
        }
    }

457 458 459 460 461
    fn set_context(&self, context: &Context) {
        unsafe {
            ffi::gst_element_set_context(self.to_glib_none().0, context.to_glib_none().0);
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
462 463 464 465 466 467 468 469 470

    fn set_locked_state(&self, locked_state: bool) -> bool {
        unsafe {
            from_glib(ffi::gst_element_set_locked_state(self.to_glib_none().0, locked_state.to_glib()))
        }
    }

    fn set_start_time(&self, time: ClockTime) {
        unsafe {
471
            ffi::gst_element_set_start_time(self.to_glib_none().0, time.to_glib());
Sebastian Dröge's avatar
Sebastian Dröge committed
472 473 474 475 476 477 478 479 480
        }
    }

    fn set_state(&self, state: State) -> StateChangeReturn {
        unsafe {
            from_glib(ffi::gst_element_set_state(self.to_glib_none().0, state.to_glib()))
        }
    }

481
    fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
482
        unsafe {
François Laignel's avatar
François Laignel committed
483
            glib_result_from_gboolean!(ffi::gst_element_sync_state_with_parent(self.to_glib_none().0), "Failed to sync state with parent")
Sebastian Dröge's avatar
Sebastian Dröge committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
        }
    }

    fn unlink<P: IsA<Element>>(&self, dest: &P) {
        unsafe {
            ffi::gst_element_unlink(self.to_glib_none().0, dest.to_glib_none().0);
        }
    }

    //fn unlink_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gst_element_unlink_many() }
    //}

    fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str) {
        unsafe {
            ffi::gst_element_unlink_pads(self.to_glib_none().0, srcpadname.to_glib_none().0, dest.to_glib_none().0, destpadname.to_glib_none().0);
        }
    }

503
    fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
504
        unsafe {
505
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
506
            connect_raw(self.to_glib_none().0 as *mut _, b"no-more-pads\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
507 508 509 510
                transmute(no_more_pads_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

511
    fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
512
        unsafe {
513
            let f: Box_<Box_<Fn(&Self, &Pad) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
514
            connect_raw(self.to_glib_none().0 as *mut _, b"pad-added\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
515 516 517 518
                transmute(pad_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

519
    fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
520
        unsafe {
521
            let f: Box_<Box_<Fn(&Self, &Pad) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
522
            connect_raw(self.to_glib_none().0 as *mut _, b"pad-removed\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
523 524 525 526 527 528 529
                transmute(pad_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn no_more_pads_trampoline<P>(this: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Element> {
530
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
531
    f(&Element::from_glib_borrow(this).downcast_unchecked())
Sebastian Dröge's avatar
Sebastian Dröge committed
532 533 534 535
}

unsafe extern "C" fn pad_added_trampoline<P>(this: *mut ffi::GstElement, new_pad: *mut ffi::GstPad, f: glib_ffi::gpointer)
where P: IsA<Element> {
536
    let f: &&(Fn(&P, &Pad) + Send + Sync + 'static) = transmute(f);
537
    f(&Element::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(new_pad))
Sebastian Dröge's avatar
Sebastian Dröge committed
538 539 540 541
}

unsafe extern "C" fn pad_removed_trampoline<P>(this: *mut ffi::GstElement, old_pad: *mut ffi::GstPad, f: glib_ffi::gpointer)
where P: IsA<Element> {
542
    let f: &&(Fn(&P, &Pad) + Send + Sync + 'static) = transmute(f);
543
    f(&Element::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(old_pad))
Sebastian Dröge's avatar
Sebastian Dröge committed
544
}