mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 11:30:59 +00:00
ts/pad: don't pass self as ref in remaining handler traits functions
- They are either unit types or `Clone` (in which case they are implemented as pointers). - Internally, we already use an owned version, so there's no need to get a reference. - It facilitates implementation if the handler must be moved into a closure or a `Future`.
This commit is contained in:
parent
43e28e5a6d
commit
554ce7e7d6
11 changed files with 42 additions and 40 deletions
|
@ -133,7 +133,7 @@ impl PadSinkHandler for TestSinkPadHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, _pad: &PadSinkRef, imp: &TestSink, event: gst::Event) -> bool {
|
||||
fn sink_event(self, _pad: &PadSinkRef, imp: &TestSink, event: gst::Event) -> bool {
|
||||
if let EventView::FlushStart(..) = event.view() {
|
||||
return imp.task.flush_start().await_maybe_on_context().is_ok();
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ struct AppSrcPadHandler;
|
|||
impl PadSrcHandler for AppSrcPadHandler {
|
||||
type ElementImpl = AppSrc;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &AppSrc, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &AppSrc, event: gst::Event) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
use gst::EventView;
|
||||
|
@ -103,7 +103,7 @@ impl PadSrcHandler for AppSrcPadHandler {
|
|||
ret
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, imp: &AppSrc, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, imp: &AppSrc, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
use gst::QueryViewMut;
|
||||
|
|
|
@ -219,7 +219,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, _pad: &PadSinkRef, imp: &InputSelector, event: gst::Event) -> bool {
|
||||
fn sink_event(self, _pad: &PadSinkRef, imp: &InputSelector, event: gst::Event) -> bool {
|
||||
/* Drop all events for now */
|
||||
if let gst::EventView::FlushStart(..) = event.view() {
|
||||
/* Unblock downstream */
|
||||
|
@ -234,7 +234,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
|
|||
true
|
||||
}
|
||||
|
||||
fn sink_query(&self, pad: &PadSinkRef, imp: &InputSelector, query: &mut gst::QueryRef) -> bool {
|
||||
fn sink_query(self, pad: &PadSinkRef, imp: &InputSelector, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling query {:?}", query);
|
||||
|
||||
if query.is_serialized() {
|
||||
|
@ -254,7 +254,7 @@ struct InputSelectorPadSrcHandler;
|
|||
impl PadSrcHandler for InputSelectorPadSrcHandler {
|
||||
type ElementImpl = InputSelector;
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, imp: &InputSelector, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, imp: &InputSelector, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
use gst::QueryViewMut;
|
||||
|
|
|
@ -562,7 +562,7 @@ impl PadSinkHandler for SinkHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &PadSinkRef, jb: &JitterBuffer, event: gst::Event) -> bool {
|
||||
fn sink_event(self, pad: &PadSinkRef, jb: &JitterBuffer, event: gst::Event) -> bool {
|
||||
use gst::EventView;
|
||||
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
@ -870,7 +870,7 @@ impl SrcHandler {
|
|||
impl PadSrcHandler for SrcHandler {
|
||||
type ElementImpl = JitterBuffer;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, jb: &JitterBuffer, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, jb: &JitterBuffer, event: gst::Event) -> bool {
|
||||
use gst::EventView;
|
||||
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
@ -907,7 +907,7 @@ impl PadSrcHandler for SrcHandler {
|
|||
jb.sink_pad.gst_pad().push_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, jb: &JitterBuffer, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, jb: &JitterBuffer, query: &mut gst::QueryRef) -> bool {
|
||||
use gst::QueryViewMut;
|
||||
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Forwarding {:?}", query);
|
||||
|
|
|
@ -243,7 +243,7 @@ impl PadSinkHandler for ProxySinkPadHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &PadSinkRef, imp: &ProxySink, event: gst::Event) -> bool {
|
||||
fn sink_event(self, pad: &PadSinkRef, imp: &ProxySink, event: gst::Event) -> bool {
|
||||
gst::debug!(SINK_CAT, obj: pad.gst_pad(), "Handling non-serialized {:?}", event);
|
||||
|
||||
let src_pad = {
|
||||
|
@ -666,7 +666,7 @@ struct ProxySrcPadHandler;
|
|||
impl PadSrcHandler for ProxySrcPadHandler {
|
||||
type ElementImpl = ProxySrc;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &ProxySrc, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &ProxySrc, event: gst::Event) -> bool {
|
||||
gst::log!(SRC_CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
let sink_pad = {
|
||||
|
@ -718,7 +718,7 @@ impl PadSrcHandler for ProxySrcPadHandler {
|
|||
}
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, _proxysrc: &ProxySrc, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, _proxysrc: &ProxySrc, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(SRC_CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
use gst::QueryViewMut;
|
||||
|
|
|
@ -113,7 +113,7 @@ impl PadSinkHandler for QueuePadSinkHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &PadSinkRef, imp: &Queue, event: gst::Event) -> bool {
|
||||
fn sink_event(self, pad: &PadSinkRef, imp: &Queue, event: gst::Event) -> bool {
|
||||
gst::debug!(CAT, obj: pad.gst_pad(), "Handling non-serialized {:?}", event);
|
||||
|
||||
if let gst::EventView::FlushStart(..) = event.view() {
|
||||
|
@ -164,7 +164,7 @@ impl PadSinkHandler for QueuePadSinkHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_query(&self, pad: &PadSinkRef, imp: &Queue, query: &mut gst::QueryRef) -> bool {
|
||||
fn sink_query(self, pad: &PadSinkRef, imp: &Queue, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
if query.is_serialized() {
|
||||
|
@ -184,7 +184,7 @@ struct QueuePadSrcHandler;
|
|||
impl PadSrcHandler for QueuePadSrcHandler {
|
||||
type ElementImpl = Queue;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &Queue, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &Queue, event: gst::Event) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
use gst::EventView;
|
||||
|
@ -213,7 +213,7 @@ impl PadSrcHandler for QueuePadSrcHandler {
|
|||
imp.sink_pad.gst_pad().push_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, imp: &Queue, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, imp: &Queue, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
if let gst::QueryViewMut::Scheduling(q) = query.view_mut() {
|
||||
|
|
|
@ -122,7 +122,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
|
|||
type ElementImpl: ElementImpl + ObjectSubclass;
|
||||
|
||||
fn src_activate(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSrcRef,
|
||||
_imp: &Self::ElementImpl,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -151,7 +151,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn src_activatemode(
|
||||
&self,
|
||||
self,
|
||||
_pad: &PadSrcRef,
|
||||
_imp: &Self::ElementImpl,
|
||||
_mode: gst::PadMode,
|
||||
|
@ -160,7 +160,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &Self::ElementImpl, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &Self::ElementImpl, event: gst::Event) -> bool {
|
||||
gst::log!(RUNTIME_CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
let elem = imp.obj();
|
||||
|
@ -174,7 +174,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn src_event_full(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSrcRef,
|
||||
imp: &Self::ElementImpl,
|
||||
event: gst::Event,
|
||||
|
@ -186,7 +186,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn src_query(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSrcRef,
|
||||
imp: &Self::ElementImpl,
|
||||
query: &mut gst::QueryRef,
|
||||
|
@ -406,7 +406,7 @@ impl PadSrc {
|
|||
"Panic in PadSrc activate"
|
||||
))
|
||||
},
|
||||
move |imp| handler.src_activate(&PadSrcRef::new(inner_arc), imp),
|
||||
move |imp| H::src_activate(handler, &PadSrcRef::new(inner_arc), imp),
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -428,7 +428,7 @@ impl PadSrc {
|
|||
move |imp| {
|
||||
let this_ref = PadSrcRef::new(inner_arc);
|
||||
this_ref.activate_mode_hook(mode, active)?;
|
||||
handler.src_activatemode(&this_ref, imp, mode, active)
|
||||
H::src_activatemode(handler, &this_ref, imp, mode, active)
|
||||
},
|
||||
)
|
||||
});
|
||||
|
@ -444,7 +444,9 @@ impl PadSrc {
|
|||
H::ElementImpl::catch_panic_pad_function(
|
||||
parent,
|
||||
|| Err(FlowError::Error),
|
||||
move |imp| handler.src_event_full(&PadSrcRef::new(inner_arc), imp, event),
|
||||
move |imp| {
|
||||
H::src_event_full(handler, &PadSrcRef::new(inner_arc), imp, event)
|
||||
},
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -458,7 +460,7 @@ impl PadSrc {
|
|||
|| false,
|
||||
move |imp| {
|
||||
if !query.is_serialized() {
|
||||
handler.src_query(&PadSrcRef::new(inner_arc), imp, query)
|
||||
H::src_query(handler, &PadSrcRef::new(inner_arc), imp, query)
|
||||
} else {
|
||||
gst::fixme!(RUNTIME_CAT, obj: inner_arc.gst_pad(), "Serialized Query not supported");
|
||||
false
|
||||
|
@ -511,7 +513,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
|
|||
type ElementImpl: ElementImpl + ObjectSubclass;
|
||||
|
||||
fn sink_activate(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSinkRef,
|
||||
_imp: &Self::ElementImpl,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -540,7 +542,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn sink_activatemode(
|
||||
&self,
|
||||
self,
|
||||
_pad: &PadSinkRef,
|
||||
_imp: &Self::ElementImpl,
|
||||
_mode: gst::PadMode,
|
||||
|
@ -567,7 +569,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
|
|||
future::err(FlowError::NotSupported).boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &PadSinkRef, imp: &Self::ElementImpl, event: gst::Event) -> bool {
|
||||
fn sink_event(self, pad: &PadSinkRef, imp: &Self::ElementImpl, event: gst::Event) -> bool {
|
||||
assert!(!event.is_serialized());
|
||||
gst::log!(RUNTIME_CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
|
@ -604,7 +606,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn sink_event_full(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSinkRef,
|
||||
imp: &Self::ElementImpl,
|
||||
event: gst::Event,
|
||||
|
@ -633,7 +635,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
|
|||
}
|
||||
|
||||
fn sink_query(
|
||||
&self,
|
||||
self,
|
||||
pad: &PadSinkRef,
|
||||
imp: &Self::ElementImpl,
|
||||
query: &mut gst::QueryRef,
|
||||
|
@ -807,7 +809,7 @@ impl PadSink {
|
|||
"Panic in PadSink activate"
|
||||
))
|
||||
},
|
||||
move |imp| handler.sink_activate(&PadSinkRef::new(inner_arc), imp),
|
||||
move |imp| H::sink_activate(handler, &PadSinkRef::new(inner_arc), imp),
|
||||
)
|
||||
});
|
||||
|
||||
|
@ -829,7 +831,7 @@ impl PadSink {
|
|||
move |imp| {
|
||||
let this_ref = PadSinkRef::new(inner_arc);
|
||||
this_ref.activate_mode_hook(mode, active)?;
|
||||
handler.sink_activatemode(&this_ref, imp, mode, active)
|
||||
H::sink_activatemode(handler, &this_ref, imp, mode, active)
|
||||
},
|
||||
)
|
||||
});
|
||||
|
@ -945,7 +947,7 @@ impl PadSink {
|
|||
|| false,
|
||||
move |imp| {
|
||||
if !query.is_serialized() {
|
||||
handler.sink_query(&PadSinkRef::new(inner_arc), imp, query)
|
||||
H::sink_query(handler, &PadSinkRef::new(inner_arc), imp, query)
|
||||
} else {
|
||||
gst::fixme!(RUNTIME_CAT, obj: inner_arc.gst_pad(), "Serialized Query not supported");
|
||||
false
|
||||
|
|
|
@ -96,7 +96,7 @@ struct TcpClientSrcPadHandler;
|
|||
impl PadSrcHandler for TcpClientSrcPadHandler {
|
||||
type ElementImpl = TcpClientSrc;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &TcpClientSrc, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &TcpClientSrc, event: gst::Event) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
use gst::EventView;
|
||||
|
@ -117,7 +117,7 @@ impl PadSrcHandler for TcpClientSrcPadHandler {
|
|||
ret
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, imp: &TcpClientSrc, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, imp: &TcpClientSrc, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
use gst::QueryViewMut;
|
||||
|
|
|
@ -190,7 +190,7 @@ impl PadSinkHandler for UdpSinkPadHandler {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, _pad: &PadSinkRef, imp: &UdpSink, event: gst::Event) -> bool {
|
||||
fn sink_event(self, _pad: &PadSinkRef, imp: &UdpSink, event: gst::Event) -> bool {
|
||||
if let EventView::FlushStart(..) = event.view() {
|
||||
return imp.task.flush_start().await_maybe_on_context().is_ok();
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ struct UdpSrcPadHandler;
|
|||
impl PadSrcHandler for UdpSrcPadHandler {
|
||||
type ElementImpl = UdpSrc;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &UdpSrc, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &UdpSrc, event: gst::Event) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
use gst::EventView;
|
||||
|
@ -134,7 +134,7 @@ impl PadSrcHandler for UdpSrcPadHandler {
|
|||
ret
|
||||
}
|
||||
|
||||
fn src_query(&self, pad: &PadSrcRef, imp: &UdpSrc, query: &mut gst::QueryRef) -> bool {
|
||||
fn src_query(self, pad: &PadSrcRef, imp: &UdpSrc, query: &mut gst::QueryRef) -> bool {
|
||||
gst::log!(CAT, obj: pad.gst_pad(), "Handling {:?}", query);
|
||||
|
||||
use gst::QueryViewMut;
|
||||
|
|
|
@ -89,7 +89,7 @@ mod imp_src {
|
|||
impl PadSrcHandler for PadSrcTestHandler {
|
||||
type ElementImpl = ElementSrcTest;
|
||||
|
||||
fn src_event(&self, pad: &PadSrcRef, imp: &ElementSrcTest, event: gst::Event) -> bool {
|
||||
fn src_event(self, pad: &PadSrcRef, imp: &ElementSrcTest, event: gst::Event) -> bool {
|
||||
gst::log!(SRC_CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
let ret = match event.view() {
|
||||
|
@ -465,7 +465,7 @@ mod imp_sink {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn sink_event(&self, pad: &PadSinkRef, imp: &ElementSinkTest, event: gst::Event) -> bool {
|
||||
fn sink_event(self, pad: &PadSinkRef, imp: &ElementSinkTest, event: gst::Event) -> bool {
|
||||
gst::debug!(SINK_CAT, obj: pad.gst_pad(), "Handling non-serialized {:?}", event);
|
||||
|
||||
match event.view() {
|
||||
|
|
Loading…
Reference in a new issue