// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{WebRTCDTLSTransport, WebRTCSCTPTransportState};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GstWebRTCSCTPTransport")]
    pub struct WebRTCSCTPTransport(Object<ffi::GstWebRTCSCTPTransport, ffi::GstWebRTCSCTPTransportClass>);

    match fn {
        type_ => || ffi::gst_webrtc_sctp_transport_get_type(),
    }
}

impl WebRTCSCTPTransport {
    #[doc(alias = "max-channels")]
    pub fn max_channels(&self) -> u32 {
        ObjectExt::property(self, "max-channels")
    }

    #[doc(alias = "max-message-size")]
    pub fn max_message_size(&self) -> u64 {
        ObjectExt::property(self, "max-message-size")
    }

    pub fn state(&self) -> WebRTCSCTPTransportState {
        ObjectExt::property(self, "state")
    }

    pub fn transport(&self) -> Option<WebRTCDTLSTransport> {
        ObjectExt::property(self, "transport")
    }

    #[doc(alias = "max-channels")]
    pub fn connect_max_channels_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_channels_trampoline<
            F: Fn(&WebRTCSCTPTransport) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstWebRTCSCTPTransport,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::max-channels\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_max_channels_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "max-message-size")]
    pub fn connect_max_message_size_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_message_size_trampoline<
            F: Fn(&WebRTCSCTPTransport) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstWebRTCSCTPTransport,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::max-message-size\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_max_message_size_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "state")]
    pub fn connect_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_state_trampoline<
            F: Fn(&WebRTCSCTPTransport) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstWebRTCSCTPTransport,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::state\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_state_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "transport")]
    pub fn connect_transport_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_transport_trampoline<
            F: Fn(&WebRTCSCTPTransport) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstWebRTCSCTPTransport,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::transport\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_transport_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

unsafe impl Send for WebRTCSCTPTransport {}
unsafe impl Sync for WebRTCSCTPTransport {}
