| 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
| 2 | |
| 3 | use crate::ffi; |
| 4 | use glib::{prelude::*, translate::*}; |
| 5 | |
| 6 | glib::wrapper! { |
| 7 | #[derive (Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] |
| 8 | #[doc (alias = "GstFlowCombiner" )] |
| 9 | pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>); |
| 10 | |
| 11 | match fn { |
| 12 | ref => |ptr| ffi::gst_flow_combiner_ref(ptr), |
| 13 | unref => |ptr| ffi::gst_flow_combiner_unref(ptr), |
| 14 | type_ => || ffi::gst_flow_combiner_get_type(), |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | impl FlowCombiner { |
| 19 | #[doc (alias = "gst_flow_combiner_new" )] |
| 20 | pub fn new() -> Self { |
| 21 | assert_initialized_main_thread!(); |
| 22 | unsafe { from_glib_full(ffi::gst_flow_combiner_new()) } |
| 23 | } |
| 24 | |
| 25 | #[doc (alias = "gst_flow_combiner_add_pad" )] |
| 26 | pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) { |
| 27 | unsafe { |
| 28 | ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | #[doc (alias = "gst_flow_combiner_clear" )] |
| 33 | pub fn clear(&self) { |
| 34 | unsafe { |
| 35 | ffi::gst_flow_combiner_clear(self.to_glib_none().0); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | #[doc (alias = "gst_flow_combiner_remove_pad" )] |
| 40 | pub fn remove_pad<P: IsA<gst::Pad>>(&self, pad: &P) { |
| 41 | unsafe { |
| 42 | ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | #[doc (alias = "gst_flow_combiner_reset" )] |
| 47 | pub fn reset(&self) { |
| 48 | unsafe { |
| 49 | ffi::gst_flow_combiner_reset(self.to_glib_none().0); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | #[doc (alias = "gst_flow_combiner_update_flow" )] |
| 54 | pub fn update_flow<FRet: Into<gst::FlowReturn>>( |
| 55 | &self, |
| 56 | fret: FRet, |
| 57 | ) -> Result<gst::FlowSuccess, gst::FlowError> { |
| 58 | let fret: gst::FlowReturn = fret.into(); |
| 59 | unsafe { |
| 60 | try_from_glib(ffi::gst_flow_combiner_update_flow( |
| 61 | self.to_glib_none().0, |
| 62 | fret.into_glib(), |
| 63 | )) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | #[doc (alias = "gst_flow_combiner_update_pad_flow" )] |
| 68 | pub fn update_pad_flow<P: IsA<gst::Pad>, FRet: Into<gst::FlowReturn>>( |
| 69 | &self, |
| 70 | pad: &P, |
| 71 | fret: FRet, |
| 72 | ) -> Result<gst::FlowSuccess, gst::FlowError> { |
| 73 | let fret: gst::FlowReturn = fret.into(); |
| 74 | unsafe { |
| 75 | try_from_glib(ffi::gst_flow_combiner_update_pad_flow( |
| 76 | self.to_glib_none().0, |
| 77 | pad.as_ref().to_glib_none().0, |
| 78 | fret.into_glib(), |
| 79 | )) |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | impl Default for FlowCombiner { |
| 85 | fn default() -> Self { |
| 86 | Self::new() |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | #[derive (Debug)] |
| 91 | pub struct UniqueFlowCombiner(FlowCombiner); |
| 92 | |
| 93 | unsafe impl Sync for UniqueFlowCombiner {} |
| 94 | unsafe impl Send for UniqueFlowCombiner {} |
| 95 | |
| 96 | impl UniqueFlowCombiner { |
| 97 | pub fn new() -> Self { |
| 98 | Self(FlowCombiner::new()) |
| 99 | } |
| 100 | |
| 101 | pub fn add_pad<P: IsA<gst::Pad>>(&mut self, pad: &P) { |
| 102 | self.0.add_pad(pad); |
| 103 | } |
| 104 | |
| 105 | pub fn clear(&mut self) { |
| 106 | self.0.clear(); |
| 107 | } |
| 108 | |
| 109 | pub fn remove_pad<P: IsA<gst::Pad>>(&mut self, pad: &P) { |
| 110 | self.0.remove_pad(pad); |
| 111 | } |
| 112 | |
| 113 | pub fn reset(&mut self) { |
| 114 | self.0.reset(); |
| 115 | } |
| 116 | |
| 117 | pub fn update_flow( |
| 118 | &mut self, |
| 119 | fret: Result<gst::FlowSuccess, gst::FlowError>, |
| 120 | ) -> Result<gst::FlowSuccess, gst::FlowError> { |
| 121 | self.0.update_flow(fret) |
| 122 | } |
| 123 | |
| 124 | pub fn update_pad_flow<P: IsA<gst::Pad>>( |
| 125 | &mut self, |
| 126 | pad: &P, |
| 127 | fret: Result<gst::FlowSuccess, gst::FlowError>, |
| 128 | ) -> Result<gst::FlowSuccess, gst::FlowError> { |
| 129 | self.0.update_pad_flow(pad, fret) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | impl Default for UniqueFlowCombiner { |
| 134 | fn default() -> Self { |
| 135 | Self::new() |
| 136 | } |
| 137 | } |
| 138 | |