Move from imp.instance() to imp.obj()

It's doing the same thing and is shorter.
This commit is contained in:
Sebastian Dröge 2022-10-23 23:03:22 +03:00
parent 86776be58c
commit 9a68f6e221
91 changed files with 507 additions and 572 deletions

View file

@ -1655,7 +1655,7 @@ impl AudioLoudNorm {
_ => (),
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
#[allow(clippy::single_match)]
@ -1678,7 +1678,7 @@ impl AudioLoudNorm {
false
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -1767,7 +1767,7 @@ impl ObjectImpl for AudioLoudNorm {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -154,7 +154,7 @@ impl AudioRNNoise {
state.process(in_data, out_data);
}
self.instance().src_pad().push(buffer)
self.obj().src_pad().push(buffer)
}
fn generate_output(&self, state: &mut State) -> Result<GenerateOutputSuccess, gst::FlowError> {
@ -329,7 +329,7 @@ impl BaseTransformImpl for AudioRNNoise {
if direction == gst::PadDirection::Src {
if let gst::QueryViewMut::Latency(q) = query.view_mut() {
let mut upstream_query = gst::query::Latency::new();
if self.instance().sink_pad().peer_query(&mut upstream_query) {
if self.obj().sink_pad().peer_query(&mut upstream_query) {
let (live, mut min, mut max) = upstream_query.result();
gst::debug!(
CAT,

View file

@ -412,7 +412,7 @@ impl BaseTransformImpl for EbuR128Level {
})?;
let mut timestamp = buf.pts();
let segment = self.instance().segment().downcast::<gst::ClockTime>().ok();
let segment = self.obj().segment().downcast::<gst::ClockTime>().ok();
let buf = gst_audio::AudioBufferRef::from_buffer_ref_readable(buf, &state.info).map_err(
|_| {
@ -563,14 +563,12 @@ impl BaseTransformImpl for EbuR128Level {
gst::debug!(CAT, imp: self, "Posting message {}", s);
let msg = gst::message::Element::builder(s)
.src(&*self.instance())
.build();
let msg = gst::message::Element::builder(s).src(&*self.obj()).build();
// Release lock while posting the message to avoid deadlocks
drop(state_guard);
let _ = self.instance().post_message(msg);
let _ = self.obj().post_message(msg);
state_guard = self.state.borrow_mut();
state = state_guard.as_mut().ok_or_else(|| {

View file

@ -394,7 +394,7 @@ impl HrtfRender {
state.reset_processors();
drop(state_guard);
self.instance().src_pad().push(outbuf)
self.obj().src_pad().push(outbuf)
}
}

View file

@ -136,7 +136,7 @@ impl AudioDecoderImpl for ClaxonDec {
} else if let Ok(tstreaminfo) = claxon_streaminfo(&inmap[13..]) {
if let Ok(taudio_info) = gstaudioinfo(&tstreaminfo) {
// To speed up negotiation
let element = self.instance();
let element = self.obj();
if element.set_output_format(&taudio_info).is_err()
|| element.negotiate().is_err()
{
@ -198,7 +198,7 @@ impl AudioDecoderImpl for ClaxonDec {
);
}
self.instance().finish_frame(None, 1)
self.obj().finish_frame(None, 1)
}
}
@ -225,7 +225,7 @@ impl ClaxonDec {
audio_info
);
let element = self.instance();
let element = self.obj();
element.set_output_format(&audio_info)?;
element.negotiate()?;
@ -260,10 +260,10 @@ impl ClaxonDec {
let mut reader = claxon::frame::FrameReader::new(&mut cursor);
let result = match reader.read_next_or_eof(buffer) {
Ok(Some(result)) => result,
Ok(None) => return self.instance().finish_frame(None, 1),
Ok(None) => return self.obj().finish_frame(None, 1),
Err(err) => {
return gst_audio::audio_decoder_error!(
self.instance(),
self.obj(),
1,
gst::StreamError::Decode,
["Failed to decode packet: {:?}", err]
@ -288,7 +288,7 @@ impl ClaxonDec {
let depth_adjusted = depth.adjust_samples(v);
let outbuf = gst::Buffer::from_mut_slice(depth_adjusted);
self.instance().finish_frame(Some(outbuf), 1)
self.obj().finish_frame(Some(outbuf), 1)
}
}

View file

@ -230,7 +230,7 @@ impl CsoundFilter {
drop(state_lock);
drop(csound);
self.instance().src_pad().push(buffer)
self.obj().src_pad().push(buffer)
}
fn generate_output(&self, state: &mut State) -> Result<GenerateOutputSuccess, gst::FlowError> {

View file

@ -186,7 +186,7 @@ impl AudioDecoderImpl for LewtonDec {
// Ignore empty packets unless we have no headers yet
if inmap.len() == 0 {
self.instance().finish_frame(None, 1)?;
self.obj().finish_frame(None, 1)?;
if state.headerset.is_some() {
return Ok(gst::FlowSuccess::Ok);
@ -243,7 +243,7 @@ impl LewtonDec {
}
}
self.instance().finish_frame(None, 1)
self.obj().finish_frame(None, 1)
}
fn initialize(&self, state: &mut State) -> Result<(), gst::FlowError> {
@ -351,8 +351,8 @@ impl LewtonDec {
state.audio_info = Some(audio_info.clone());
state.reorder_map = reorder_map;
self.instance().set_output_format(&audio_info)?;
self.instance().negotiate()?;
self.obj().set_output_format(&audio_info)?;
self.obj().negotiate()?;
Ok(())
}
@ -374,7 +374,7 @@ impl LewtonDec {
Ok(decoded) => decoded,
Err(err) => {
return audio_decoder_error!(
self.instance(),
self.obj(),
1,
gst::StreamError::Decode,
["Failed to decode packet: {:?}", err]
@ -384,7 +384,7 @@ impl LewtonDec {
if decoded.channel_count != audio_info.channels() as usize {
return audio_decoder_error!(
self.instance(),
self.obj(),
1,
gst::StreamError::Decode,
[
@ -399,12 +399,12 @@ impl LewtonDec {
gst::debug!(CAT, imp: self, "Got {} decoded samples", sample_count);
if sample_count == 0 {
return self.instance().finish_frame(None, 1);
return self.obj().finish_frame(None, 1);
}
let outbuf = if let Some(ref reorder_map) = state.reorder_map {
let mut outbuf = self
.instance()
.obj()
.allocate_output_buffer(sample_count as usize * audio_info.bpf() as usize);
{
// And copy the decoded data into our output buffer while reordering the channels to the
@ -451,7 +451,7 @@ impl LewtonDec {
gst::Buffer::from_mut_slice(CastVec(decoded.samples))
};
self.instance().finish_frame(Some(outbuf), 1)
self.obj().finish_frame(Some(outbuf), 1)
}
}

View file

@ -442,7 +442,7 @@ impl URIHandlerImpl for SpotifyAudioSrc {
for (key, value) in url.query_pairs() {
match key.as_ref() {
"username" | "password" | "cache-credentials" | "cache-files" => {
self.instance().set_property(&key, value.as_ref());
self.obj().set_property(&key, value.as_ref());
}
_ => {
gst::warning!(CAT, imp: self, "unsupported query: {}={}", key, value);
@ -450,7 +450,7 @@ impl URIHandlerImpl for SpotifyAudioSrc {
}
}
self.instance()
self.obj()
.set_property("track", format!("{}:{}", url.scheme(), url.path()));
Ok(())

View file

@ -174,7 +174,7 @@ impl ObjectImpl for FileSrc {
fn constructed(&self) {
self.parent_constructed();
self.instance().set_format(gst::Format::Bytes);
self.obj().set_format(gst::Format::Bytes);
}
}

View file

@ -300,7 +300,7 @@ impl Decrypter {
}
QueryViewMut::Duration(q) => {
if q.format() != gst::Format::Bytes {
return gst::Pad::query_default(pad, Some(&*self.instance()), query);
return gst::Pad::query_default(pad, Some(&*self.obj()), query);
}
/* First let's query the bytes duration upstream */
@ -341,7 +341,7 @@ impl Decrypter {
true
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -594,7 +594,7 @@ impl ObjectImpl for Decrypter {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -243,9 +243,9 @@ impl Encrypter {
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -256,7 +256,7 @@ impl Encrypter {
match event.view() {
EventView::Seek(_) => false,
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -278,7 +278,7 @@ impl Encrypter {
}
QueryViewMut::Duration(q) => {
if q.format() != gst::Format::Bytes {
return gst::Pad::query_default(pad, Some(&*self.instance()), query);
return gst::Pad::query_default(pad, Some(&*self.obj()), query);
}
/* First let's query the bytes duration upstream */
@ -318,7 +318,7 @@ impl Encrypter {
true
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -406,7 +406,7 @@ impl ObjectImpl for Encrypter {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -610,7 +610,7 @@ impl TestSink {
// Enable backpressure for items
let (item_sender, item_receiver) = flume::bounded(0);
let task_impl = TestSinkTask::new(&*self.instance(), item_receiver);
let task_impl = TestSinkTask::new(&*self.obj(), item_receiver);
self.task.prepare(task_impl, context).block_on()?;
*self.item_sender.lock().unwrap() = Some(item_sender);
@ -794,7 +794,7 @@ impl ObjectImpl for TestSink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SINK);
}

View file

@ -337,7 +337,7 @@ impl TestSrc {
drop(settings);
self.task
.prepare(SrcTask::new(self.instance().clone()), context)
.prepare(SrcTask::new(self.obj().clone()), context)
.block_on()?;
if raise_log_level {
@ -528,7 +528,7 @@ impl ObjectImpl for TestSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}

View file

@ -315,7 +315,7 @@ impl AppSrc {
let do_timestamp = self.settings.lock().unwrap().do_timestamp;
if do_timestamp {
let elem = self.instance();
let elem = self.obj();
if let Some(clock) = elem.clock() {
let base_time = elem.base_time();
let now = clock.time();
@ -384,7 +384,7 @@ impl AppSrc {
*self.sender.lock().unwrap() = Some(sender);
self.task
.prepare(AppSrcTask::new(self.instance().clone(), receiver), context)
.prepare(AppSrcTask::new(self.obj().clone(), receiver), context)
.block_on()?;
gst::debug!(CAT, imp: self, "Prepared");
@ -556,7 +556,7 @@ impl ObjectImpl for AppSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}

View file

@ -470,7 +470,7 @@ impl ObjectImpl for InputSelector {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);
}
@ -554,7 +554,7 @@ impl ElementImpl for InputSelector {
gst::Pad::from_template(templ, Some(format!("sink_{}", pads.pad_serial).as_str()));
pads.pad_serial += 1;
sink_pad.set_active(true).unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
let sink_pad = PadSink::new(sink_pad, InputSelectorPadSinkHandler::default());
let ret = sink_pad.gst_pad().clone();
@ -567,11 +567,9 @@ impl ElementImpl for InputSelector {
drop(pads);
drop(state);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
Some(ret)
}
@ -580,14 +578,12 @@ impl ElementImpl for InputSelector {
let mut pads = self.pads.lock().unwrap();
let sink_pad = pads.sink_pads.remove(pad).unwrap();
drop(sink_pad);
self.instance().remove_pad(pad).unwrap();
self.obj().remove_pad(pad).unwrap();
drop(pads);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
fn provide_clock(&self) -> Option<gst::Clock> {

View file

@ -341,7 +341,7 @@ impl SinkHandler {
pt
);
let element = jb.instance();
let element = jb.obj();
if dts.is_none() {
dts = pts;
@ -523,7 +523,7 @@ impl SinkHandler {
// Reschedule if needed
let (_, next_wakeup) =
jb.src_pad_handler
.next_wakeup(&jb.instance(), &state, latency, context_wait);
.next_wakeup(&jb.obj(), &state, latency, context_wait);
if let Some((next_wakeup, _)) = next_wakeup {
if let Some((previous_next_wakeup, ref abort_handle)) = state.wait_handle {
if previous_next_wakeup.is_none()
@ -1262,11 +1262,7 @@ impl JitterBuffer {
self.task
.prepare(
JitterBufferTask::new(
&*self.instance(),
&self.src_pad_handler,
&self.sink_pad_handler,
),
JitterBufferTask::new(&*self.obj(), &self.src_pad_handler, &self.sink_pad_handler),
context,
)
.block_on()?;
@ -1407,11 +1403,9 @@ impl ObjectImpl for JitterBuffer {
let state = self.state.lock().unwrap();
state.jbuf.set_delay(latency);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
"do-lost" => {
let mut settings = self.settings.lock().unwrap();
@ -1484,7 +1478,7 @@ impl ObjectImpl for JitterBuffer {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);

View file

@ -588,7 +588,7 @@ impl ObjectImpl for ProxySink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SINK);
}
@ -957,7 +957,7 @@ impl ProxySrc {
})?;
let dataqueue = DataQueue::new(
&self.instance().clone().upcast(),
&self.obj().clone().upcast(),
self.src_pad.gst_pad(),
if settings.max_size_buffers == 0 {
None
@ -989,10 +989,7 @@ impl ProxySrc {
*self.dataqueue.lock().unwrap() = Some(dataqueue.clone());
self.task
.prepare(
ProxySrcTask::new(self.instance().clone(), dataqueue),
ts_ctx,
)
.prepare(ProxySrcTask::new(self.obj().clone(), dataqueue), ts_ctx)
.block_on()?;
gst::debug!(SRC_CAT, imp: self, "Prepared");
@ -1150,7 +1147,7 @@ impl ObjectImpl for ProxySrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}

View file

@ -559,7 +559,7 @@ impl Queue {
let settings = self.settings.lock().unwrap().clone();
let dataqueue = DataQueue::new(
&self.instance().clone().upcast(),
&self.obj().clone().upcast(),
self.src_pad.gst_pad(),
if settings.max_size_buffers == 0 {
None
@ -589,7 +589,7 @@ impl Queue {
})?;
self.task
.prepare(QueueTask::new(self.instance().clone(), dataqueue), context)
.prepare(QueueTask::new(self.obj().clone(), dataqueue), context)
.block_on()?;
gst::debug!(CAT, imp: self, "Prepared");
@ -729,7 +729,7 @@ impl ObjectImpl for Queue {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
}

View file

@ -163,7 +163,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
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.instance();
let elem = imp.obj();
// FIXME with GAT on `Self::ElementImpl`, we should be able to
// use `.upcast::<gst::Element>()`
//
@ -199,7 +199,7 @@ pub trait PadSrcHandler: Clone + Send + Sync + 'static {
} else {
gst::log!(RUNTIME_CAT, obj: pad.gst_pad(), "Handling {:?}", query);
let elem = imp.instance();
let elem = imp.obj();
// FIXME with GAT on `Self::ElementImpl`, we should be able to
// use `.upcast::<gst::Element>()`
//
@ -571,7 +571,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
assert!(!event.is_serialized());
gst::log!(RUNTIME_CAT, obj: pad.gst_pad(), "Handling {:?}", event);
let elem = imp.instance();
let elem = imp.obj();
// FIXME with GAT on `Self::ElementImpl`, we should be able to
// use `.upcast::<gst::Element>()`
//
@ -646,7 +646,7 @@ pub trait PadSinkHandler: Clone + Send + Sync + 'static {
} else {
gst::log!(RUNTIME_CAT, obj: pad.gst_pad(), "Handling {:?}", query);
let elem = imp.instance();
let elem = imp.obj();
// FIXME with GAT on `Self::ElementImpl`, we should be able to
// use `.upcast::<gst::Element>()`
//
@ -845,7 +845,7 @@ impl PadSink {
|| Err(FlowError::Error),
move |imp| {
let this_weak = PadSinkWeak(Arc::downgrade(&inner_arc));
let elem = imp.instance().clone();
let elem = imp.obj().clone();
if let Some((ctx, task_id)) = Context::current_task() {
let delayed_fut = async move {
@ -874,7 +874,7 @@ impl PadSink {
|| Err(FlowError::Error),
move |imp| {
let this_weak = PadSinkWeak(Arc::downgrade(&inner_arc));
let elem = imp.instance().clone();
let elem = imp.obj().clone();
if let Some((ctx, task_id)) = Context::current_task() {
let delayed_fut = async move {
@ -907,7 +907,7 @@ impl PadSink {
move |imp| {
if event.is_serialized() {
let this_weak = PadSinkWeak(Arc::downgrade(&inner_arc));
let elem = imp.instance().clone();
let elem = imp.obj().clone();
if let Some((ctx, task_id)) = Context::current_task() {
let delayed_fut = async move {

View file

@ -437,7 +437,7 @@ impl TcpClientSrc {
let _ = self
.task
.prepare(
TcpClientSrcTask::new(self.instance().clone(), saddr, buffer_pool),
TcpClientSrcTask::new(self.obj().clone(), saddr, buffer_pool),
context,
)
.check()?;
@ -582,7 +582,7 @@ impl ObjectImpl for TcpClientSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}

View file

@ -840,7 +840,7 @@ impl UdpSink {
// Enable backpressure for items
let (item_sender, item_receiver) = flume::bounded(0);
let (cmd_sender, cmd_receiver) = flume::unbounded();
let task_impl = UdpSinkTask::new(&*self.instance(), item_receiver, cmd_receiver);
let task_impl = UdpSinkTask::new(&*self.obj(), item_receiver, cmd_receiver);
self.task.prepare(task_impl, context).block_on()?;
*self.item_sender.lock().unwrap() = Some(item_sender);
@ -1248,7 +1248,7 @@ impl ObjectImpl for UdpSink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SINK);
}

View file

@ -575,7 +575,7 @@ impl UdpSrc {
*self.configured_caps.lock().unwrap() = None;
self.task
.prepare(UdpSrcTask::new(self.instance().clone()), context)
.prepare(UdpSrcTask::new(self.obj().clone()), context)
.block_on()?;
gst::debug!(CAT, imp: self, "Prepared");
@ -775,7 +775,7 @@ impl ObjectImpl for UdpSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}

View file

@ -237,7 +237,7 @@ mod imp_src {
self.task
.prepare(
ElementSrcTestTask::new(self.instance().clone(), receiver),
ElementSrcTestTask::new(self.obj().clone(), receiver),
context,
)
.block_on()?;
@ -325,7 +325,7 @@ mod imp_src {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.src_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SOURCE);
}
@ -617,7 +617,7 @@ mod imp_sink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(self.sink_pad.gst_pad()).unwrap();
obj.set_element_flags(gst::ElementFlags::SINK);
}

View file

@ -183,7 +183,7 @@ impl ObjectImpl for FlvDemux {
fn constructed(&self) {
self.parent_constructed();
self.instance().add_pad(&self.sinkpad).unwrap();
self.obj().add_pad(&self.sinkpad).unwrap();
}
}
@ -351,12 +351,12 @@ impl FlvDemux {
let mut flow_combiner = self.flow_combiner.lock().unwrap();
if let Some(pad) = self.audio_srcpad.lock().unwrap().take() {
self.instance().remove_pad(&pad).unwrap();
self.obj().remove_pad(&pad).unwrap();
flow_combiner.remove_pad(&pad);
}
if let Some(pad) = self.video_srcpad.lock().unwrap().take() {
self.instance().remove_pad(&pad).unwrap();
self.obj().remove_pad(&pad).unwrap();
flow_combiner.remove_pad(&pad);
}
@ -370,21 +370,21 @@ impl FlvDemux {
match event.view() {
EventView::Eos(..) => {
// TODO implement
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Segment(..) => {
// TODO implement
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::FlushStart(..) => {
// TODO implement
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::FlushStop(..) => {
// TODO implement
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -432,7 +432,7 @@ impl FlvDemux {
false
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -444,7 +444,7 @@ impl FlvDemux {
// TODO: Implement
false
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -610,7 +610,7 @@ impl FlvDemux {
}
}
Event::HaveAllStreams => {
self.instance().no_more_pads();
self.obj().no_more_pads();
}
}
}
@ -619,7 +619,7 @@ impl FlvDemux {
}
fn create_srcpad(&self, name: &str, caps: &gst::Caps) -> gst::Pad {
let templ = self.instance().element_class().pad_template(name).unwrap();
let templ = self.obj().element_class().pad_template(name).unwrap();
let srcpad = gst::Pad::builder_with_template(&templ, Some(name))
.event_function(|pad, parent, event| {
FlvDemux::catch_panic_pad_function(
@ -639,7 +639,7 @@ impl FlvDemux {
srcpad.set_active(true).unwrap();
let full_stream_id = srcpad.create_stream_id(&*self.instance(), Some(name));
let full_stream_id = srcpad.create_stream_id(&*self.obj(), Some(name));
// FIXME group id
srcpad.push_event(gst::event::StreamStart::new(&full_stream_id));
srcpad.push_event(gst::event::Caps::new(caps));
@ -650,7 +650,7 @@ impl FlvDemux {
self.flow_combiner.lock().unwrap().add_pad(&srcpad);
self.instance().add_pad(&srcpad).unwrap();
self.obj().add_pad(&srcpad).unwrap();
srcpad
}

View file

@ -436,7 +436,7 @@ impl FMP4Mux {
// If this is a multi-stream element then we need to update the PTS/DTS positions according
// to the output segment, specifically to re-timestamp them with the running time and
// adjust for the segment shift to compensate for negative DTS.
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
let (pts_position, dts_position) = if class.as_ref().variant.is_single_stream() {
(pts_position, dts_position)
@ -898,7 +898,7 @@ impl FMP4Mux {
VecDeque<Buffer>,
)],
) -> Result<Option<gst::ClockTime>, gst::FlowError> {
let aggregator = self.instance();
let aggregator = self.obj();
if aggregator.class().as_ref().variant != super::Variant::ONVIF {
return Ok(None);
}
@ -1297,7 +1297,7 @@ impl FMP4Mux {
state.sequence_number += 1;
let (mut fmp4_fragment_header, moof_offset) =
boxes::create_fmp4_fragment_header(super::FragmentHeaderConfiguration {
variant: self.instance().class().as_ref().variant,
variant: self.obj().class().as_ref().variant,
sequence_number,
streams: streams.as_slice(),
buffers: interleaved_buffers.as_slice(),
@ -1429,7 +1429,7 @@ impl FMP4Mux {
fn create_streams(&self, state: &mut State) -> Result<(), gst::FlowError> {
for pad in self
.instance()
.obj()
.sink_pads()
.into_iter()
.map(|pad| pad.downcast::<gst_base::AggregatorPad>().unwrap())
@ -1528,7 +1528,7 @@ impl FMP4Mux {
settings: &Settings,
at_eos: bool,
) -> Result<Option<(gst::BufferList, gst::Caps)>, gst::FlowError> {
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
let variant = class.as_ref().variant;
@ -1666,7 +1666,7 @@ impl ObjectImpl for FMP4Mux {
if settings.fragment_duration != fragment_duration {
settings.fragment_duration = fragment_duration;
drop(settings);
self.instance().set_latency(fragment_duration, None);
self.obj().set_latency(fragment_duration, None);
}
}
@ -1744,7 +1744,7 @@ impl ObjectImpl for FMP4Mux {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
let class = obj.class();
for templ in class.pad_template_list().filter(|templ| {
templ.presence() == gst::PadPresence::Always
@ -1866,7 +1866,7 @@ impl AggregatorImpl for FMP4Mux {
// Only forward the segment event verbatim if this is a single stream variant.
// Otherwise we have to produce a default segment and re-timestamp all buffers
// with their running time.
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
if class.as_ref().variant.is_single_stream() {
aggregator.update_segment(&segment);
@ -1945,7 +1945,7 @@ impl AggregatorImpl for FMP4Mux {
// For non-single-stream variants configure a default segment that allows for negative
// DTS so that we can correctly re-timestamp buffers with their running times.
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
if !class.as_ref().variant.is_single_stream() {
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
@ -2127,12 +2127,12 @@ impl AggregatorImpl for FMP4Mux {
if let Some(caps) = caps {
gst::debug!(CAT, imp: self, "Setting caps on source pad: {:?}", caps);
self.instance().set_src_caps(&caps);
self.obj().set_src_caps(&caps);
}
if let Some(buffers) = buffers {
gst::trace!(CAT, imp: self, "Pushing buffer list {:?}", buffers);
self.instance().finish_buffer_list(buffers)?;
self.obj().finish_buffer_list(buffers)?;
}
if all_eos {
@ -2147,8 +2147,8 @@ impl AggregatorImpl for FMP4Mux {
super::HeaderUpdateMode::None => unreachable!(),
super::HeaderUpdateMode::Rewrite => {
let mut q = gst::query::Seeking::new(gst::Format::Bytes);
if self.instance().src_pad().peer_query(&mut q) && q.result().0 {
let aggregator = self.instance();
if self.obj().src_pad().peer_query(&mut q) && q.result().0 {
let aggregator = self.obj();
aggregator.set_src_caps(&caps);
@ -2175,7 +2175,7 @@ impl AggregatorImpl for FMP4Mux {
}
}
super::HeaderUpdateMode::Update => {
let aggregator = self.instance();
let aggregator = self.obj();
aggregator.set_src_caps(&caps);
if let Err(err) = aggregator.finish_buffer_list(buffer_list) {

View file

@ -223,10 +223,10 @@ impl TranscribeParse {
EventView::FlushStop(..) => {
let mut state = self.state.lock().unwrap();
*state = State::default();
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(..) => match self.drain() {
Ok(()) => gst::Pad::event_default(pad, Some(&*self.instance()), event),
Ok(()) => gst::Pad::event_default(pad, Some(&*self.obj()), event),
Err(err) => {
gst::error!(CAT, imp: self, "failed to drain on EOS: {}", err);
element_imp_error!(
@ -239,7 +239,7 @@ impl TranscribeParse {
}
},
EventView::Segment(..) | EventView::Caps(..) => true,
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -284,7 +284,7 @@ impl ObjectImpl for TranscribeParse {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -223,7 +223,7 @@ impl Transcriber {
/* First, check our pending buffers */
let mut items = vec![];
let now = match self.instance().current_running_time() {
let now = match self.obj().current_running_time() {
Some(now) => now,
None => {
return true;
@ -645,7 +645,7 @@ impl Transcriber {
false
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -664,7 +664,7 @@ impl Transcriber {
},
EventView::FlushStart(_) => {
gst::info!(CAT, imp: self, "Received flush start, disconnecting");
let mut ret = gst::Pad::event_default(pad, Some(&*self.instance()), event);
let mut ret = gst::Pad::event_default(pad, Some(&*self.obj()), event);
match self.srcpad.stop_task() {
Err(err) => {
@ -684,7 +684,7 @@ impl Transcriber {
EventView::FlushStop(_) => {
gst::info!(CAT, imp: self, "Received flush stop, restarting task");
if gst::Pad::event_default(pad, Some(&*self.instance()), event) {
if gst::Pad::event_default(pad, Some(&*self.obj()), event) {
match self.start_task() {
Err(err) => {
gst::error!(CAT, imp: self, "Failed to start srcpad task: {}", err);
@ -722,7 +722,7 @@ impl Transcriber {
true
}
EventView::StreamStart(_) => true,
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -737,7 +737,7 @@ impl Transcriber {
if let Some(buffer) = &buffer {
let running_time = state.in_segment.to_running_time(buffer.pts());
let now = self.instance().current_running_time();
let now = self.obj().current_running_time();
delay = running_time.opt_checked_sub(now).ok().flatten();
}
@ -1202,7 +1202,7 @@ impl ObjectImpl for Transcriber {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
obj.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);

View file

@ -576,7 +576,7 @@ impl ObjectImpl for S3HlsSink {
fn constructed(&self) {
self.parent_constructed();
self.instance().add(&self.hlssink).unwrap();
self.obj().add(&self.hlssink).unwrap();
let mut settings = self.settings.lock().unwrap();
@ -830,7 +830,7 @@ impl ElementImpl for S3HlsSink {
let sink_pad =
gst::GhostPad::from_template_with_target(templ, Some("audio"), &audio_pad)
.unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
sink_pad.set_active(true).unwrap();
settings.audio_sink = true;
@ -850,7 +850,7 @@ impl ElementImpl for S3HlsSink {
let sink_pad =
gst::GhostPad::from_template_with_target(templ, Some("video"), &video_pad)
.unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
sink_pad.set_active(true).unwrap();
settings.video_sink = true;

View file

@ -412,7 +412,7 @@ impl ObjectImpl for S3Src {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_format(gst::Format::Bytes);
/* Set a larger default blocksize to make read more efficient */
obj.set_blocksize(256 * 1024);

View file

@ -189,7 +189,7 @@ impl HlsSink3 {
state.current_segment_location = Some(segment_file_location.clone());
let fragment_stream = self
.instance()
.obj()
.emit_by_name::<Option<gio::OutputStream>>(
SIGNAL_GET_FRAGMENT_STREAM,
&[&segment_file_location],
@ -280,7 +280,7 @@ impl HlsSink3 {
// Acquires the playlist file handle so we can update it with new content. By default, this
// is expected to be the same file every time.
let mut playlist_stream = self
.instance()
.obj()
.emit_by_name::<Option<gio::OutputStream>>(
SIGNAL_GET_PLAYLIST_STREAM,
&[&playlist_location],
@ -323,7 +323,7 @@ impl HlsSink3 {
for _ in 0..state.old_segment_locations.len() - max_num_segments {
let old_segment_location = state.old_segment_locations.remove(0);
if !self
.instance()
.obj()
.emit_by_name::<bool>(SIGNAL_DELETE_FRAGMENT, &[&old_segment_location])
{
gst::error!(CAT, imp: self, "Could not delete fragment");
@ -617,7 +617,7 @@ impl ObjectImpl for HlsSink3 {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_element_flags(gst::ElementFlags::SINK);
obj.set_suppressed_flags(gst::ElementFlags::SINK | gst::ElementFlags::SOURCE);
@ -772,7 +772,7 @@ impl ElementImpl for HlsSink3 {
let sink_pad =
gst::GhostPad::from_template_with_target(templ, Some("audio"), &peer_pad)
.unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
sink_pad.set_active(true).unwrap();
settings.audio_sink = true;
@ -792,7 +792,7 @@ impl ElementImpl for HlsSink3 {
let sink_pad =
gst::GhostPad::from_template_with_target(templ, Some("video"), &peer_pad)
.unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
sink_pad.set_active(true).unwrap();
settings.video_sink = true;
@ -823,7 +823,7 @@ impl ElementImpl for HlsSink3 {
}
pad.set_active(false).unwrap();
self.instance().remove_pad(pad).unwrap();
self.obj().remove_pad(pad).unwrap();
if "audio" == ghost_pad.name() {
settings.audio_sink = false;

View file

@ -177,14 +177,14 @@ impl DeviceProvider {
current_devices_guard.retain(|d| !expired_devices.contains(d));
// And also notify the device provider of them having disappeared
for old_device in expired_devices {
self.instance().device_remove(&old_device);
self.obj().device_remove(&old_device);
}
// Now go through all new devices and announce them
for source in sources {
gst::log!(CAT, imp: self, "Source {:?} appeared", source);
let device = super::Device::new(&source);
self.instance().device_add(&device);
self.obj().device_add(&device);
current_devices_guard.push(device);
}
}

View file

@ -290,14 +290,14 @@ impl BaseSinkImpl for NdiSink {
// Skip empty/gap buffers from ndisinkcombiner
if buffer.size() != 0 {
let timecode = self
.instance()
.obj()
.segment()
.downcast::<gst::ClockTime>()
.ok()
.and_then(|segment| {
segment
.to_running_time(buffer.pts())
.zip(self.instance().base_time())
.zip(self.obj().base_time())
})
.and_then(|(running_time, base_time)| running_time.checked_add(base_time))
.map(|time| (time.nseconds() / 100) as i64)
@ -331,14 +331,14 @@ impl BaseSinkImpl for NdiSink {
}
} else if let Some(ref info) = state.audio_info {
let timecode = self
.instance()
.obj()
.segment()
.downcast::<gst::ClockTime>()
.ok()
.and_then(|segment| {
segment
.to_running_time(buffer.pts())
.zip(self.instance().base_time())
.zip(self.obj().base_time())
})
.and_then(|(running_time, base_time)| running_time.checked_add(base_time))
.map(|time| (time.nseconds() / 100) as i64)

View file

@ -59,7 +59,7 @@ impl ObjectImpl for NdiSinkCombiner {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.video_pad).unwrap();
}
}
@ -161,7 +161,7 @@ impl AggregatorImpl for NdiSinkCombiner {
return None;
}
let sink_templ = self.instance().pad_template("audio").unwrap();
let sink_templ = self.obj().pad_template("audio").unwrap();
if templ != &sink_templ {
gst::error!(CAT, imp: self, "Wrong pad template");
return None;
@ -467,7 +467,7 @@ impl AggregatorImpl for NdiSinkCombiner {
.unwrap_or(true)
{
let timecode = self
.instance()
.obj()
.base_time()
.zip(audio_running_time)
.map(|(base_time, audio_running_time)| {
@ -522,7 +522,7 @@ impl AggregatorImpl for NdiSinkCombiner {
"Finishing video buffer {:?}",
current_video_buffer
);
self.instance().finish_buffer(current_video_buffer)
self.obj().finish_buffer(current_video_buffer)
}
fn sink_event(&self, pad: &gst_base::AggregatorPad, event: gst::Event) -> bool {
@ -562,10 +562,10 @@ impl AggregatorImpl for NdiSinkCombiner {
drop(state_storage);
self.instance().set_latency(latency, gst::ClockTime::NONE);
self.obj().set_latency(latency, gst::ClockTime::NONE);
// The video caps are passed through as the audio is included only in a meta
self.instance().set_src_caps(&caps);
self.obj().set_src_caps(&caps);
} else {
let info = match gst_audio::AudioInfo::from_caps(&caps) {
Ok(info) => info,
@ -582,7 +582,7 @@ impl AggregatorImpl for NdiSinkCombiner {
EventView::Segment(segment) if pad == &self.video_pad => {
let segment = segment.segment();
gst::debug!(CAT, obj: pad, "Updating segment {:?}", segment);
self.instance().update_segment(segment);
self.obj().update_segment(segment);
}
_ => (),
}
@ -596,7 +596,7 @@ impl AggregatorImpl for NdiSinkCombiner {
match query.view_mut() {
QueryViewMut::Caps(_) if pad == &self.video_pad => {
// Directly forward caps queries
let srcpad = self.instance().static_pad("src").unwrap();
let srcpad = self.obj().static_pad("src").unwrap();
return srcpad.peer_query(query);
}
_ => (),

View file

@ -170,7 +170,7 @@ impl ObjectImpl for NdiSrc {
// Initialize live-ness and notify the base class that
// we'd like to operate in Time format
let obj = self.instance();
let obj = self.obj();
obj.set_live(true);
obj.set_format(gst::Format::Time);
}
@ -285,11 +285,9 @@ impl ObjectImpl for NdiSrc {
timestamp_mode
);
if settings.timestamp_mode != timestamp_mode {
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
settings.timestamp_mode = timestamp_mode;
}
@ -407,7 +405,7 @@ impl ElementImpl for NdiSrc {
impl BaseSrcImpl for NdiSrc {
fn negotiate(&self) -> Result<(), gst::LoggableError> {
self.instance()
self.obj()
.set_caps(&gst::Caps::builder("application/x-ndi").build())
.map_err(|_| gst::loggable_error!(CAT, "Failed to negotiate caps",))
}
@ -440,7 +438,7 @@ impl BaseSrcImpl for NdiSrc {
}
let receiver = Receiver::connect(
self.instance().upcast_ref(),
self.obj().upcast_ref(),
settings.ndi_name.as_deref(),
settings.url_address.as_deref(),
&settings.receiver_ndi_name,
@ -593,10 +591,8 @@ impl BaseSrcImpl for NdiSrc {
drop(state);
if latency_changed {
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
let _ = self.obj().post_message(
gst::message::Latency::builder().src(&*self.obj()).build(),
);
}

View file

@ -69,7 +69,7 @@ impl ObjectImpl for NdiSrcDemux {
fn constructed(&self) {
self.parent_constructed();
self.instance().add_pad(&self.sinkpad).unwrap();
self.obj().add_pad(&self.sinkpad).unwrap();
}
}
@ -139,7 +139,7 @@ impl ElementImpl for NdiSrcDemux {
.iter()
.flatten()
{
self.instance().remove_pad(pad).unwrap();
self.obj().remove_pad(pad).unwrap();
}
*state = State::default();
}
@ -179,11 +179,7 @@ impl NdiSrcDemux {
} else {
gst::debug!(CAT, imp: self, "Adding audio pad with caps {}", caps);
let templ = self
.instance()
.element_class()
.pad_template("audio")
.unwrap();
let templ = self.obj().element_class().pad_template("audio").unwrap();
let pad = gst::Pad::builder_with_template(&templ, Some("audio"))
.flags(gst::PadFlags::FIXED_CAPS)
.build();
@ -232,11 +228,7 @@ impl NdiSrcDemux {
} else {
gst::debug!(CAT, imp: self, "Adding video pad with caps {}", caps);
let templ = self
.instance()
.element_class()
.pad_template("video")
.unwrap();
let templ = self.obj().element_class().pad_template("video").unwrap();
let pad = gst::Pad::builder_with_template(&templ, Some("video"))
.flags(gst::PadFlags::FIXED_CAPS)
.build();
@ -284,9 +276,9 @@ impl NdiSrcDemux {
meta.remove().unwrap();
if add_pad {
self.instance().add_pad(&srcpad).unwrap();
if self.instance().num_src_pads() == 2 {
self.instance().no_more_pads();
self.obj().add_pad(&srcpad).unwrap();
if self.obj().num_src_pads() == 2 {
self.obj().no_more_pads();
}
}
@ -305,7 +297,7 @@ impl NdiSrcDemux {
gst::log!(CAT, imp: self, "Handling event {:?}", event);
if let EventView::Eos(_) = event.view() {
if self.instance().num_src_pads() == 0 {
if self.obj().num_src_pads() == 0 {
// error out on EOS if no src pad are available
gst::element_imp_error!(
self,
@ -314,6 +306,6 @@ impl NdiSrcDemux {
);
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}

View file

@ -61,7 +61,7 @@ impl ObjectImpl for OnvifMetadataCombiner {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.media_sink_pad).unwrap();
obj.add_pad(&self.meta_sink_pad).unwrap();
}
@ -381,7 +381,7 @@ impl AggregatorImpl for OnvifMetadataCombiner {
gst::log!(CAT, imp: self, "Updating position: {:?}", position);
self.instance().set_position(position);
self.obj().set_position(position);
self.finish_buffer(buffer)
} else if self.media_sink_pad.is_eos() {
@ -404,7 +404,7 @@ impl AggregatorImpl for OnvifMetadataCombiner {
| QueryViewMut::Allocation(..) => self.media_sink_pad.peer_query(query),
QueryViewMut::AcceptCaps(q) => {
let caps = q.caps_owned();
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
let templ = class.pad_template("media").unwrap();
let templ_caps = templ.caps();
@ -424,14 +424,14 @@ impl AggregatorImpl for OnvifMetadataCombiner {
EventView::Caps(e) => {
if aggregator_pad.upcast_ref::<gst::Pad>() == &self.media_sink_pad {
gst::info!(CAT, imp: self, "Pushing caps {}", e.caps());
self.instance().set_src_caps(&e.caps_owned());
self.obj().set_src_caps(&e.caps_owned());
}
true
}
EventView::Segment(e) => {
if aggregator_pad.upcast_ref::<gst::Pad>() == &self.media_sink_pad {
self.instance().update_segment(e.segment());
self.obj().update_segment(e.segment());
}
self.parent_sink_event(aggregator_pad, event)
}
@ -452,17 +452,17 @@ impl AggregatorImpl for OnvifMetadataCombiner {
| QueryViewMut::Uri(..)
| QueryViewMut::Allocation(..) => {
if aggregator_pad == &self.media_sink_pad {
self.instance().src_pad().peer_query(query)
self.obj().src_pad().peer_query(query)
} else {
self.parent_sink_query(aggregator_pad, query)
}
}
QueryViewMut::Caps(q) => {
if aggregator_pad == &self.media_sink_pad {
self.instance().src_pad().peer_query(query)
self.obj().src_pad().peer_query(query)
} else {
let filter = q.filter_owned();
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
let templ = class.pad_template("meta").unwrap();
let templ_caps = templ.caps();
@ -480,10 +480,10 @@ impl AggregatorImpl for OnvifMetadataCombiner {
}
QueryViewMut::AcceptCaps(q) => {
if aggregator_pad.upcast_ref::<gst::Pad>() == &self.media_sink_pad {
self.instance().src_pad().peer_query(query);
self.obj().src_pad().peer_query(query);
} else {
let caps = q.caps_owned();
let aggregator = self.instance();
let aggregator = self.obj();
let class = aggregator.class();
let templ = class.pad_template("meta").unwrap();
let templ_caps = templ.caps();
@ -498,7 +498,7 @@ impl AggregatorImpl for OnvifMetadataCombiner {
}
fn next_time(&self) -> Option<gst::ClockTime> {
self.instance().simple_get_next_time()
self.obj().simple_get_next_time()
}
fn negotiate(&self) -> bool {

View file

@ -83,7 +83,7 @@ impl ElementImpl for OnvifMetadataDepay {
impl RTPBaseDepayloadImpl for OnvifMetadataDepay {
fn set_caps(&self, _caps: &gst::Caps) -> Result<(), gst::LoggableError> {
let element = self.instance();
let element = self.obj();
let src_pad = element.src_pad();
let src_caps = src_pad.pad_template_caps();
src_pad.push_event(gst::event::Caps::builder(&src_caps).build());

View file

@ -700,9 +700,9 @@ impl OnvifMetadataOverlay {
EventView::FlushStop(..) => {
let mut state = self.state.lock().unwrap();
state.composition = None;
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -785,7 +785,7 @@ impl ObjectImpl for OnvifMetadataOverlay {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -522,7 +522,7 @@ impl OnvifMetadataParse {
earliest_utc_time,
);
let (clock, base_time) = match (self.instance().clock(), self.instance().base_time()) {
let (clock, base_time) = match (self.obj().clock(), self.obj().base_time()) {
(Some(clock), Some(base_time)) => (clock, base_time),
_ => {
gst::warning!(
@ -840,7 +840,7 @@ impl OnvifMetadataParse {
drop(state);
self.cond.notify_all();
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
gst::EventView::FlushStop(_) => {
let _ = self.srcpad.stop_task();
@ -854,7 +854,7 @@ impl OnvifMetadataParse {
state.out_segment.set_position(gst::ClockTime::NONE);
state.last_flow_ret = Ok(gst::FlowSuccess::Ok);
drop(state);
let mut res = gst::Pad::event_default(pad, Some(&*self.instance()), event);
let mut res = gst::Pad::event_default(pad, Some(&*self.obj()), event);
if res {
res = self.src_start_task().is_ok();
}
@ -917,7 +917,7 @@ impl OnvifMetadataParse {
gst::debug!(CAT, obj: pad, "Configuring latency of {}", latency);
if previous_latency != latency {
let element = self.instance();
let element = self.obj();
let _ = element.post_message(
gst::message::Latency::builder().src(&*element).build(),
);
@ -1010,7 +1010,7 @@ impl OnvifMetadataParse {
gst::StreamError::Failed,
["Got EOS event before creating UTC/running time mapping"]
);
return gst::Pad::event_default(pad, Some(&*self.instance()), event);
return gst::Pad::event_default(pad, Some(&*self.obj()), event);
}
let current_running_time = in_segment
@ -1028,7 +1028,7 @@ impl OnvifMetadataParse {
true
}
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -1059,7 +1059,7 @@ impl OnvifMetadataParse {
gst::fixme!(CAT, obj: pad, "Dropping allocation query");
false
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -1076,7 +1076,7 @@ impl OnvifMetadataParse {
drop(state);
self.cond.notify_all();
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
gst::EventView::FlushStop(_) => {
let _ = self.srcpad.stop_task();
@ -1090,13 +1090,13 @@ impl OnvifMetadataParse {
state.out_segment.set_position(gst::ClockTime::NONE);
state.last_flow_ret = Ok(gst::FlowSuccess::Ok);
drop(state);
let mut res = gst::Pad::event_default(pad, Some(&*self.instance()), event);
let mut res = gst::Pad::event_default(pad, Some(&*self.obj()), event);
if res {
res = self.src_start_task().is_ok();
}
res
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -1151,7 +1151,7 @@ impl OnvifMetadataParse {
ret
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -1255,8 +1255,8 @@ impl OnvifMetadataParse {
// Drain until the current clock running time minus the configured latency when
// live
if let Some((now, base_time)) = Option::zip(
self.instance().clock().and_then(|clock| clock.time()),
self.instance().base_time(),
self.obj().clock().and_then(|clock| clock.time()),
self.obj().base_time(),
) {
gst::trace!(
CAT,
@ -1505,11 +1505,9 @@ impl ObjectImpl for OnvifMetadataParse {
"latency" => {
self.settings.lock().unwrap().latency = value.get().expect("type checked upstream");
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
"max-lateness" => {
self.settings.lock().unwrap().max_lateness =
@ -1530,7 +1528,7 @@ impl ObjectImpl for OnvifMetadataParse {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -140,7 +140,7 @@ impl RTPBasePayloadImpl for OnvifMetadataPay {
return Err(gst::FlowError::Error);
}
let mtu = self.instance().mtu();
let mtu = self.obj().mtu();
let payload_size = gst_rtp::calc_payload_len(mtu, 0, 0) as usize;
let mut chunks = utf8.as_bytes().chunks(payload_size).peekable();
@ -180,11 +180,11 @@ impl RTPBasePayloadImpl for OnvifMetadataPay {
}
}
self.instance().push_list(buflist)
self.obj().push_list(buflist)
}
fn set_caps(&self, _caps: &gst::Caps) -> Result<(), gst::LoggableError> {
self.instance()
self.obj()
.set_options("application", true, "VND.ONVIF.METADATA", 90000);
Ok(())

View file

@ -497,7 +497,7 @@ impl RaptorqDec {
self.reset();
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
fn fec_sink_event(&self, pad: &gst::Pad, event: gst::Event) -> bool {
@ -516,7 +516,7 @@ impl RaptorqDec {
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
fn iterate_internal_links(&self, pad: &gst::Pad) -> gst::Iterator<gst::Pad> {
@ -719,7 +719,7 @@ impl ObjectImpl for RaptorqDec {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}
@ -850,7 +850,7 @@ impl ElementImpl for RaptorqDec {
drop(sinkpad_fec_guard);
self.instance().add_pad(&sinkpad_fec).unwrap();
self.obj().add_pad(&sinkpad_fec).unwrap();
Some(sinkpad_fec)
}
@ -861,7 +861,7 @@ impl ElementImpl for RaptorqDec {
if let Some(pad) = pad_guard.take() {
drop(pad_guard);
pad.set_active(false).unwrap();
self.instance().remove_pad(&pad).unwrap();
self.obj().remove_pad(&pad).unwrap();
}
}
}

View file

@ -180,7 +180,7 @@ impl RaptorqEnc {
.map(|n| ((n * delay_step) as u64).mseconds())
.collect::<Vec<_>>();
let base_time = self.instance().base_time();
let base_time = self.obj().base_time();
let running_time = state.segment.to_running_time(now_pts);
for (target_time, repair_packet) in Iterator::zip(
@ -313,7 +313,7 @@ impl RaptorqEnc {
}
};
let clock = match self_.instance().clock() {
let clock = match self_.obj().clock() {
Some(clock) => clock,
None => {
// No clock provided, push buffer immediately
@ -505,7 +505,7 @@ impl RaptorqEnc {
// Push stream events on FEC srcpad as well
let stream_id = self
.srcpad_fec
.create_stream_id(&*self.instance(), Some("fec"))
.create_stream_id(&*self.obj(), Some("fec"))
.to_string();
let kmax = extended_source_block_symbols(state.symbols_per_block as u32);
@ -543,7 +543,7 @@ impl RaptorqEnc {
_ => (),
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
fn iterate_internal_links(&self, pad: &gst::Pad) -> gst::Iterator<gst::Pad> {
@ -846,7 +846,7 @@ impl ObjectImpl for RaptorqEnc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
obj.add_pad(&self.srcpad_fec).unwrap();

View file

@ -261,14 +261,14 @@ impl ReqwestHttpSrc {
// unless using proxy, because proxy is client specific.
if proxy.is_none() {
let mut q = gst::query::Context::new(REQWEST_CLIENT_CONTEXT);
if self.instance().src_pad().peer_query(&mut q) {
if self.obj().src_pad().peer_query(&mut q) {
if let Some(context) = q.context_owned() {
self.instance().set_context(&context);
self.obj().set_context(&context);
}
} else {
let _ = self.instance().post_message(
let _ = self.obj().post_message(
gst::message::NeedContext::builder(REQWEST_CLIENT_CONTEXT)
.src(&*self.instance())
.src(&*self.obj())
.build(),
);
}
@ -317,10 +317,10 @@ impl ReqwestHttpSrc {
let s = context.structure_mut();
s.set("client", &client);
}
self.instance().set_context(&context);
let _ = self.instance().post_message(
self.obj().set_context(&context);
let _ = self.obj().post_message(
gst::message::HaveContext::builder(context)
.src(&*self.instance())
.src(&*self.obj())
.build(),
);
}
@ -793,7 +793,7 @@ impl ObjectImpl for ReqwestHttpSrc {
}
"is-live" => {
let is_live = value.get().expect("type checked upstream");
self.instance().set_live(is_live);
self.obj().set_live(is_live);
Ok(())
}
"user-id" => {
@ -897,7 +897,7 @@ impl ObjectImpl for ReqwestHttpSrc {
let settings = self.settings.lock().unwrap();
settings.user_agent.to_value()
}
"is-live" => self.instance().is_live().to_value(),
"is-live" => self.obj().is_live().to_value(),
"user-id" => {
let settings = self.settings.lock().unwrap();
settings.user_id.to_value()
@ -948,7 +948,7 @@ impl ObjectImpl for ReqwestHttpSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_automatic_eos(false);
obj.set_format(gst::Format::Bytes);
}
@ -1173,16 +1173,14 @@ impl PushSrcImpl for ReqwestHttpSrc {
if let Some(caps) = caps {
gst::debug!(CAT, imp: self, "Setting caps {:?}", caps);
self.instance()
self.obj()
.set_caps(&caps)
.map_err(|_| gst::FlowError::NotNegotiated)?;
}
if let Some(tags) = tags {
gst::debug!(CAT, imp: self, "Sending iradio tags {:?}", tags);
self.instance()
.src_pad()
.push_event(gst::event::Tag::new(tags));
self.obj().src_pad().push_event(gst::event::Tag::new(tags));
}
let future = async {

View file

@ -217,7 +217,7 @@ impl RTPAv1Pay {
state.obus.len()
);
let payload_limit = gst_rtp::calc_payload_len(self.instance().mtu(), 0, 0);
let payload_limit = gst_rtp::calc_payload_len(self.obj().mtu(), 0, 0);
// Create information about the packet that can be created now while iterating over the
// OBUs and return this if a full packet can indeed be created now.
@ -601,8 +601,7 @@ impl ElementImpl for RTPAv1Pay {
impl RTPBasePayloadImpl for RTPAv1Pay {
fn set_caps(&self, _caps: &gst::Caps) -> Result<(), gst::LoggableError> {
self.instance()
.set_options("video", true, "AV1", CLOCK_RATE);
self.obj().set_options("video", true, "AV1", CLOCK_RATE);
gst::debug!(CAT, imp: self, "setting caps");
@ -636,7 +635,7 @@ impl RTPBasePayloadImpl for RTPAv1Pay {
drop(state);
if !list.is_empty() {
self.instance().push_list(list)
self.obj().push_list(list)
} else {
Ok(gst::FlowSuccess::Ok)
}
@ -663,7 +662,7 @@ impl RTPBasePayloadImpl for RTPAv1Pay {
self.reset(&mut state);
}
if !list.is_empty() {
let _ = self.instance().push_list(list);
let _ = self.obj().push_list(list);
}
}
gst::EventView::FlushStop(_) => {

View file

@ -1178,7 +1178,7 @@ impl ObjectSubclass for BandwidthEstimator {
parent,
|| false,
|this| {
let bwe = this.instance();
let bwe = this.obj();
if let Some(structure) = event.structure() {
if structure.name() == "RTPTWCCPackets" {
@ -1220,7 +1220,7 @@ impl ObjectSubclass for BandwidthEstimator {
"Panic activating src pad with mode"
))
},
|this| this.src_activatemode(pad, &this.instance(), mode, active),
|this| this.src_activatemode(pad, &this.obj(), mode, active),
)
})
.flags(gst::PadFlags::PROXY_CAPS | gst::PadFlags::PROXY_ALLOCATION)
@ -1238,7 +1238,7 @@ impl ObjectImpl for BandwidthEstimator {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -248,10 +248,10 @@ impl Signaller {
}
pub fn start(&self, element: &WebRTCSink) {
let this = self.instance().clone();
let this = self.obj().clone();
let element_clone = element.clone();
task::spawn(async move {
let this = Self::from_instance(&this);
let this = this.imp();
if let Err(err) = this.connect(&element_clone).await {
element_clone.handle_signalling_error(err.into());
}

View file

@ -2,7 +2,7 @@
use crate::webrtcsink::{Signallable, WebRTCSink};
use gst::glib;
use gst::subclass::prelude::ObjectSubclassExt;
use gst::subclass::prelude::*;
use std::error::Error;
mod imp;
@ -16,7 +16,7 @@ unsafe impl Sync for Signaller {}
impl Signallable for Signaller {
fn start(&mut self, element: &WebRTCSink) -> Result<(), Box<dyn Error>> {
let signaller = imp::Signaller::from_instance(self);
let signaller = self.imp();
signaller.start(element);
Ok(())
@ -28,7 +28,7 @@ impl Signallable for Signaller {
peer_id: &str,
sdp: &gst_webrtc::WebRTCSessionDescription,
) -> Result<(), Box<dyn Error>> {
let signaller = imp::Signaller::from_instance(self);
let signaller = self.imp();
signaller.handle_sdp(element, peer_id, sdp);
Ok(())
}
@ -41,18 +41,18 @@ impl Signallable for Signaller {
sdp_mline_index: Option<u32>,
sdp_mid: Option<String>,
) -> Result<(), Box<dyn Error>> {
let signaller = imp::Signaller::from_instance(self);
let signaller = self.imp();
signaller.handle_ice(element, session_id, candidate, sdp_mline_index, sdp_mid);
Ok(())
}
fn stop(&mut self, element: &WebRTCSink) {
let signaller = imp::Signaller::from_instance(self);
let signaller = self.imp();
signaller.stop(element);
}
fn session_ended(&mut self, element: &WebRTCSink, session_id: &str) {
let signaller = imp::Signaller::from_instance(self);
let signaller = self.imp();
signaller.end_session(element, session_id);
}
}

View file

@ -200,7 +200,7 @@ fn create_navigation_event(sink: &super::WebRTCSink, msg: &str) {
gst::log!(CAT, obj: sink, "Processing navigation event: {:?}", event);
if let Some(mid) = event.mid {
let this = WebRTCSink::from_instance(sink);
let this = sink.imp();
let state = this.state.lock().unwrap();
if let Some(stream_name) = state.mids.get(&mid) {
@ -213,7 +213,7 @@ fn create_navigation_event(sink: &super::WebRTCSink, msg: &str) {
}
}
} else {
let this = WebRTCSink::from_instance(sink);
let this = sink.imp();
let state = this.state.lock().unwrap();
let event = gst::event::Navigation::new(event.event.structure());
@ -1296,7 +1296,7 @@ impl WebRTCSink {
gst::debug!(CAT, "Created offer for session {}", session_id);
if let Some(element) = element.upgrade() {
let this = Self::from_instance(&element);
let this = element.imp();
let reply = match reply {
Ok(Some(reply)) => reply,
Ok(None) => {
@ -1496,7 +1496,7 @@ impl WebRTCSink {
let session_id_clone = session_id.clone();
webrtcbin.connect("on-ice-candidate", false, move |values| {
if let Some(element) = element_clone.upgrade() {
let this = Self::from_instance(&element);
let this = element.imp();
let sdp_m_line_index = values[1].get::<u32>().expect("Invalid argument");
let candidate = values[2].get::<String>().expect("Invalid argument");
this.on_ice_candidate(
@ -1519,7 +1519,7 @@ impl WebRTCSink {
match state {
gst_webrtc::WebRTCPeerConnectionState::Failed => {
let this = Self::from_instance(&element);
let this = element.imp();
gst::warning!(
CAT,
obj: element,
@ -1550,7 +1550,7 @@ impl WebRTCSink {
if let Some(element) = element_clone.upgrade() {
let state = webrtcbin
.property::<gst_webrtc::WebRTCICEConnectionState>("ice-connection-state");
let this = Self::from_instance(&element);
let this = element.imp();
match state {
gst_webrtc::WebRTCICEConnectionState::Failed => {
@ -1679,7 +1679,7 @@ impl WebRTCSink {
task::spawn(async move {
while let Some(msg) = bus_stream.next().await {
if let Some(element) = element_clone.upgrade() {
let this = Self::from_instance(&element);
let this = element.imp();
match msg.view() {
gst::MessageView::Error(err) => {
gst::error!(
@ -2049,7 +2049,7 @@ impl WebRTCSink {
let promise = gst::Promise::with_change_func(move |reply| {
gst::debug!(CAT, "received reply {:?}", reply);
if let Some(element) = element.upgrade() {
let this = Self::from_instance(&element);
let this = element.imp();
this.on_remote_description_set(&element, session_id);
}
@ -2278,7 +2278,7 @@ impl WebRTCSink {
let element_clone = element.downgrade();
task::spawn(async move {
if let Some(element) = element_clone.upgrade() {
let this = Self::from_instance(&element);
let this = element.imp();
let (fut, handle) =
futures::future::abortable(this.lookup_streams_caps(&element));
@ -2660,7 +2660,7 @@ impl ObjectImpl for WebRTCSink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_suppressed_flags(gst::ElementFlags::SINK | gst::ElementFlags::SOURCE);
obj.set_element_flags(gst::ElementFlags::SINK);
}
@ -2728,7 +2728,7 @@ impl ElementImpl for WebRTCSink {
_name: Option<&str>,
_caps: Option<&gst::Caps>,
) -> Option<gst::Pad> {
let element = self.instance();
let element = self.obj();
if element.current_state() > gst::State::Ready {
gst::error!(CAT, "element pads can only be requested before starting");
return None;
@ -2751,7 +2751,7 @@ impl ElementImpl for WebRTCSink {
WebRTCSink::catch_panic_pad_function(
parent,
|| false,
|this| this.sink_event(pad.upcast_ref(), &*this.instance(), event),
|this| this.sink_event(pad.upcast_ref(), &*this.obj(), event),
)
})
.build();
@ -2778,7 +2778,7 @@ impl ElementImpl for WebRTCSink {
&self,
transition: gst::StateChange,
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
let element = self.instance();
let element = self.obj();
if let gst::StateChange::ReadyToPaused = transition {
if let Err(err) = self.prepare(&*element) {
gst::element_error!(

View file

@ -89,8 +89,7 @@ impl WebRTCSink {
pub fn with_signaller(signaller: Box<dyn SignallableObject>) -> Self {
let ret: WebRTCSink = glib::Object::new(&[]);
let ws = imp::WebRTCSink::from_instance(&ret);
let ws = ret.imp();
ws.set_signaller(signaller).unwrap();
ret
@ -101,8 +100,7 @@ impl WebRTCSink {
session_id: &str,
sdp: &gst_webrtc::WebRTCSessionDescription,
) -> Result<(), WebRTCSinkError> {
let ws = imp::WebRTCSink::from_instance(self);
let ws = self.imp();
ws.handle_sdp(self, session_id, sdp)
}
@ -116,26 +114,22 @@ impl WebRTCSink {
sdp_mid: Option<String>,
candidate: &str,
) -> Result<(), WebRTCSinkError> {
let ws = imp::WebRTCSink::from_instance(self);
let ws = self.imp();
ws.handle_ice(self, session_id, sdp_m_line_index, sdp_mid, candidate)
}
pub fn handle_signalling_error(&self, error: Box<dyn Error + Send + Sync>) {
let ws = imp::WebRTCSink::from_instance(self);
let ws = self.imp();
ws.handle_signalling_error(self, anyhow::anyhow!(error));
}
pub fn start_session(&self, session_id: &str, peer_id: &str) -> Result<(), WebRTCSinkError> {
let ws = imp::WebRTCSink::from_instance(self);
let ws = self.imp();
ws.start_session(self, session_id, peer_id)
}
pub fn end_session(&self, session_id: &str) -> Result<(), WebRTCSinkError> {
let ws = imp::WebRTCSink::from_instance(self);
let ws = self.imp();
ws.remove_session(self, session_id, false)
}
}

View file

@ -137,7 +137,7 @@ impl ElementImpl for WhipSink {
let sink_pad = gst::GhostPad::new(Some(&wb_sink_pad.name()), gst::PadDirection::Sink);
sink_pad.set_target(Some(&wb_sink_pad)).unwrap();
self.instance().add_pad(&sink_pad).unwrap();
self.obj().add_pad(&sink_pad).unwrap();
Some(sink_pad.upcast())
}
@ -234,7 +234,7 @@ impl ObjectImpl for WhipSink {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_suppressed_flags(gst::ElementFlags::SINK | gst::ElementFlags::SOURCE);
obj.set_element_flags(gst::ElementFlags::SINK);
obj.add(&self.webrtcbin).unwrap();

View file

@ -183,7 +183,7 @@ impl ObjectImpl for TextAhead {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sink_pad).unwrap();
obj.add_pad(&self.src_pad).unwrap();
}
@ -304,11 +304,11 @@ impl TextAhead {
while !state.pending.is_empty() {
let _ = self.push_pending(&mut state);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
gst::EventView::Caps(_caps) => {
// set caps on src pad
let element = self.instance();
let element = self.obj();
let templ = element.class().pad_template("src").unwrap();
let _ = self.src_pad.push_event(gst::event::Caps::new(templ.caps()));
true
@ -326,9 +326,9 @@ impl TextAhead {
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}

View file

@ -169,8 +169,8 @@ impl JsonGstEnc {
let caps = gst::Caps::builder("application/x-json").build();
self.srcpad.push_event(gst::event::Caps::new(&caps))
}
EventView::Eos(_) => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
EventView::Eos(_) => gst::Pad::event_default(pad, Some(&*self.obj()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -215,7 +215,7 @@ impl ObjectImpl for JsonGstEnc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -39,9 +39,7 @@ impl PullState {
fn new(imp: &JsonGstParse, pad: &gst::Pad) -> Self {
Self {
need_stream_start: true,
stream_id: pad
.create_stream_id(&*imp.instance(), Some("src"))
.to_string(),
stream_id: pad.create_stream_id(&*imp.obj(), Some("src")).to_string(),
offset: 0,
duration: None,
}
@ -633,14 +631,14 @@ impl JsonGstParse {
self.flush(&mut state);
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(_) => {
gst::log!(CAT, obj: pad, "Draining");
if let Err(err) = self.handle_buffer(None) {
gst::error!(CAT, obj: pad, "Failed to drain parser: {:?}", err);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => {
if event.is_sticky()
@ -652,7 +650,7 @@ impl JsonGstParse {
state.pending_events.push(event);
true
} else {
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}
}
@ -757,7 +755,7 @@ impl JsonGstParse {
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
match event.view() {
EventView::Seek(e) => self.perform_seek(e),
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -811,7 +809,7 @@ impl JsonGstParse {
self.sinkpad.peer_query(query)
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -890,7 +888,7 @@ impl ObjectImpl for JsonGstParse {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -159,7 +159,7 @@ impl ObjectImpl for RegEx {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -324,7 +324,7 @@ impl TextWrap {
if state.start_ts.is_some() {
true
} else {
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}
EventView::FlushStart(_) => {
@ -333,7 +333,7 @@ impl TextWrap {
*state = State::default();
state.options = options;
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(_) => {
let mut state = self.state.lock().unwrap();
@ -357,9 +357,9 @@ impl TextWrap {
} else {
drop(state);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -388,7 +388,7 @@ impl TextWrap {
}
ret
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -483,7 +483,7 @@ impl ObjectImpl for TextWrap {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}
@ -518,11 +518,9 @@ impl ObjectImpl for TextWrap {
settings.accumulate_time.display(),
);
drop(settings);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
}
_ => unimplemented!(),

View file

@ -181,7 +181,7 @@ impl ObjectImpl for Identity {
// Here we actually add the pads we created in Identity::new() to the
// element so that GStreamer is aware of their existence.
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -139,7 +139,7 @@ impl ObjectImpl for ProgressBin {
// Here we actually add the pads we created in ProgressBin::new() to the
// element so that GStreamer is aware of their existence.
let obj = self.instance();
let obj = self.obj();
// Add the progressreport element to the bin.
obj.add(&self.progress).unwrap();

View file

@ -212,7 +212,7 @@ impl ObjectImpl for SineSrc {
// Call the parent class' ::constructed() implementation first
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
// Initialize live-ness and notify the base class that
// we'd like to operate in Time format
obj.set_live(DEFAULT_IS_LIVE);
@ -236,11 +236,9 @@ impl ObjectImpl for SineSrc {
settings.samples_per_buffer = samples_per_buffer;
drop(settings);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
"freq" => {
let mut settings = self.settings.lock().unwrap();
@ -380,8 +378,7 @@ impl ElementImpl for SineSrc {
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
// Configure live'ness once here just before starting the source
if let gst::StateChange::ReadyToPaused = transition {
self.instance()
.set_live(self.settings.lock().unwrap().is_live);
self.obj().set_live(self.settings.lock().unwrap().is_live);
}
// Call the parent class' implementation of ::change_state()
@ -406,7 +403,7 @@ impl BaseSrcImpl for SineSrc {
gst::debug!(CAT, imp: self, "Configuring for caps {}", caps);
self.instance()
self.obj()
.set_blocksize(info.bpf() * (*self.settings.lock().unwrap()).samples_per_buffer);
let settings = *self.settings.lock().unwrap();
@ -442,11 +439,9 @@ impl BaseSrcImpl for SineSrc {
drop(state);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
Ok(())
}
@ -748,15 +743,14 @@ impl PushSrcImpl for SineSrc {
// Waiting happens based on the pipeline clock, which means that a real live source
// with its own clock would require various translations between the two clocks.
// This is out of scope for the tutorial though.
if self.instance().is_live() {
let (clock, base_time) =
match Option::zip(self.instance().clock(), self.instance().base_time()) {
None => return Ok(CreateSuccess::NewBuffer(buffer)),
Some(res) => res,
};
if self.obj().is_live() {
let (clock, base_time) = match Option::zip(self.obj().clock(), self.obj().base_time()) {
None => return Ok(CreateSuccess::NewBuffer(buffer)),
Some(res) => res,
};
let segment = self
.instance()
.obj()
.segment()
.downcast::<gst::format::Time>()
.unwrap();

View file

@ -73,7 +73,7 @@ impl ObjectImpl for CustomSource {
"source" => {
let source = value.get::<gst::Element>().unwrap();
self.source.set(source.clone()).unwrap();
self.instance().add(&source).unwrap();
self.obj().add(&source).unwrap();
}
_ => unreachable!(),
}
@ -82,7 +82,7 @@ impl ObjectImpl for CustomSource {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_suppressed_flags(gst::ElementFlags::SOURCE | gst::ElementFlags::SINK);
obj.set_element_flags(gst::ElementFlags::SOURCE);
obj.set_bin_flags(gst::BinFlags::STREAMS_AWARE);
@ -285,11 +285,11 @@ impl CustomSource {
let (templ, name) = if stream_type.contains(gst::StreamType::AUDIO) {
let name = format!("audio_{}", state.num_audio);
state.num_audio += 1;
(self.instance().pad_template("audio_%u").unwrap(), name)
(self.obj().pad_template("audio_%u").unwrap(), name)
} else {
let name = format!("video_{}", state.num_video);
state.num_video += 1;
(self.instance().pad_template("video_%u").unwrap(), name)
(self.obj().pad_template("video_%u").unwrap(), name)
};
let ghost_pad = gst::GhostPad::builder_with_template(&templ, Some(&name))
@ -306,7 +306,7 @@ impl CustomSource {
drop(state);
ghost_pad.set_active(true).unwrap();
self.instance().add_pad(&ghost_pad).unwrap();
self.obj().add_pad(&ghost_pad).unwrap();
Ok(())
}
@ -331,7 +331,7 @@ impl CustomSource {
ghost_pad.set_active(false).unwrap();
let _ = ghost_pad.set_target(None::<&gst::Pad>);
let _ = self.instance().remove_pad(&ghost_pad);
let _ = self.obj().remove_pad(&ghost_pad);
}
fn handle_source_no_more_pads(&self) {
@ -348,11 +348,11 @@ impl CustomSource {
.build();
drop(state);
self.instance().no_more_pads();
self.obj().no_more_pads();
let _ = self.instance().post_message(
let _ = self.obj().post_message(
gst::message::StreamsSelected::builder(&collection)
.src(&*self.instance())
.src(&*self.obj())
.build(),
);
}
@ -381,7 +381,7 @@ impl CustomSource {
for pad in pads {
let _ = pad.ghost_pad.set_target(None::<&gst::Pad>);
let _ = self.instance().remove_pad(&pad.ghost_pad);
let _ = self.obj().remove_pad(&pad.ghost_pad);
}
}
}

View file

@ -705,7 +705,7 @@ impl ObjectImpl for FallbackSrc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_suppressed_flags(gst::ElementFlags::SOURCE | gst::ElementFlags::SINK);
obj.set_element_flags(gst::ElementFlags::SOURCE);
obj.set_bin_flags(gst::BinFlags::STREAMS_AWARE);
@ -1016,7 +1016,7 @@ impl FallbackSrc {
let source = match source {
Source::Uri(ref uri) => {
let uri = self
.instance()
.obj()
.emit_by_name::<glib::GString>("update-uri", &[uri]);
let source = gst::ElementFactory::make("uridecodebin3")
@ -1070,7 +1070,7 @@ impl FallbackSrc {
imp.handle_source_pad_removed(pad, false);
});
self.instance().add(&bin).unwrap();
self.obj().add(&bin).unwrap();
SourceBin {
source: bin,
@ -1132,8 +1132,7 @@ impl FallbackSrc {
None => return,
Some(element) => element,
};
let src = FallbackSrc::from_instance(&element);
let src = element.imp();
src.handle_source_pad_removed(pad, true);
});
@ -1144,7 +1143,7 @@ impl FallbackSrc {
// possible errors and retry, without causing the whole bin state change to fail
bin.set_locked_state(true);
self.instance().add(&bin).unwrap();
self.obj().add(&bin).unwrap();
Some(SourceBin {
source: bin,
@ -1175,7 +1174,7 @@ impl FallbackSrc {
.build()
.expect("No fallbackswitch found");
self.instance().add(&switch).unwrap();
self.obj().add(&switch).unwrap();
let dummy_srcpad = dummy_source.static_pad("src").unwrap();
let dummy_sinkpad = switch.request_pad_simple("sink_%u").unwrap();
@ -1197,7 +1196,7 @@ impl FallbackSrc {
let srcpad = switch.static_pad("src").unwrap();
let templ = self
.instance()
.obj()
.pad_template(if is_audio { "audio" } else { "video" })
.unwrap();
let ghostpad = gst::GhostPad::builder_with_template(&templ, Some(&templ.name()))
@ -1216,7 +1215,7 @@ impl FallbackSrc {
let _ = ghostpad.set_active(true);
self.instance().add_pad(&ghostpad).unwrap();
self.obj().add_pad(&ghostpad).unwrap();
Stream {
main_branch: None,
@ -1271,7 +1270,7 @@ impl FallbackSrc {
&settings.fallback_video_caps,
settings.min_latency,
);
self.instance().add(&video_dummy_source).unwrap();
self.obj().add(&video_dummy_source).unwrap();
let stream = self.create_stream(
settings.timeout,
@ -1294,7 +1293,7 @@ impl FallbackSrc {
&settings.fallback_audio_caps,
settings.min_latency,
);
self.instance().add(&audio_dummy_source).unwrap();
self.obj().add(&audio_dummy_source).unwrap();
let stream = self.create_stream(
settings.timeout,
@ -1332,9 +1331,9 @@ impl FallbackSrc {
drop(state_guard);
self.instance().no_more_pads();
self.obj().no_more_pads();
self.instance().notify("status");
self.obj().notify("status");
gst::debug!(CAT, imp: self, "Started");
Ok(())
@ -1349,7 +1348,7 @@ impl FallbackSrc {
};
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
// In theory all streams should've been removed from the source's pad-removed signal
// handler when going from Paused to Ready but better safe than sorry here
@ -1357,7 +1356,7 @@ impl FallbackSrc {
.iter()
.filter_map(|v| v.as_ref())
{
let element = self.instance();
let element = self.obj();
for branch in [&stream.main_branch, &stream.fallback_branch]
.iter()
@ -1395,7 +1394,7 @@ impl FallbackSrc {
.iter_mut()
.flatten()
{
self.instance().remove(&source.source).unwrap();
self.obj().remove(&source.source).unwrap();
if let Some(timeout) = source.pending_restart_timeout.take() {
timeout.unschedule();
@ -1418,7 +1417,7 @@ impl FallbackSrc {
.flatten()
{
let _ = source.set_state(gst::State::Null);
self.instance().remove(source).unwrap();
self.obj().remove(source).unwrap();
}
gst::debug!(CAT, imp: self, "Stopped");
@ -1471,7 +1470,7 @@ impl FallbackSrc {
let source = source.source.clone();
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
let res = source.set_state(transition.next());
match res {
@ -1493,7 +1492,7 @@ impl FallbackSrc {
fallback_source,
);
drop(state_guard);
self.instance().notify("statistics");
self.obj().notify("statistics");
}
}
Ok(res) => {
@ -1560,7 +1559,7 @@ impl FallbackSrc {
pad: &gst::ProxyPad,
buffer: gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
let res = gst::ProxyPad::chain_default(pad, Some(&*self.instance()), buffer);
let res = gst::ProxyPad::chain_default(pad, Some(&*self.obj()), buffer);
let mut state_guard = self.state.lock();
let state = match &mut *state_guard {
@ -1998,7 +1997,7 @@ impl FallbackSrc {
});
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
Ok(())
}
@ -2189,7 +2188,7 @@ impl FallbackSrc {
gst::debug!(CAT, imp: self, "Live source, unblocking directly");
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
return Ok(());
}
@ -2236,13 +2235,13 @@ impl FallbackSrc {
self.unblock_pads(state, fallback_source);
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
Ok(())
}
fn unblock_pads(&self, state: &mut State, fallback_source: bool) {
let current_running_time = match self.instance().current_running_time() {
let current_running_time = match self.obj().current_running_time() {
Some(current_running_time) => current_running_time,
None => {
gst::debug!(CAT, imp: self, "Waiting for current_running_time");
@ -2590,7 +2589,7 @@ impl FallbackSrc {
self.unblock_pads(state, fallback_source);
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
}
fn handle_buffering(&self, m: &gst::message::Buffering) {
@ -2683,8 +2682,8 @@ impl FallbackSrc {
}
drop(state_guard);
self.instance().notify("status");
self.instance().notify("statistics");
self.obj().notify("status");
self.obj().notify("statistics");
}
fn handle_streams_selected(&self, m: &gst::message::StreamsSelected) {
@ -2767,7 +2766,7 @@ impl FallbackSrc {
self.unblock_pads(state, fallback_source);
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
}
fn handle_error(&self, m: &gst::message::Error) -> bool {
@ -2794,8 +2793,8 @@ impl FallbackSrc {
if src == state.source.source || src.has_as_ancestor(&state.source.source) {
self.handle_source_error(state, RetryReason::Error, false);
drop(state_guard);
self.instance().notify("status");
self.instance().notify("statistics");
self.obj().notify("status");
self.obj().notify("statistics");
return true;
}
@ -2804,8 +2803,8 @@ impl FallbackSrc {
if src == source.source || src.has_as_ancestor(&source.source) {
self.handle_source_error(state, RetryReason::Error, true);
drop(state_guard);
self.instance().notify("status");
self.instance().notify("statistics");
self.obj().notify("status");
self.obj().notify("statistics");
return true;
}
}
@ -2887,7 +2886,7 @@ impl FallbackSrc {
}
let source_weak = source.source.downgrade();
self.instance().call_async(move |element| {
self.obj().call_async(move |element| {
let imp = element.imp();
let source = match source_weak.upgrade() {
@ -3299,7 +3298,7 @@ impl FallbackSrc {
);
let timeout = clock.new_single_shot_id(wait_time);
let element_weak = self.instance().downgrade();
let element_weak = self.obj().downgrade();
timeout
.wait_async(move |_clock, _time, _id| {
let element = match element_weak.upgrade() {
@ -3469,7 +3468,7 @@ impl FallbackSrc {
}
drop(state_guard);
self.instance().notify("status");
self.obj().notify("status");
}
fn stats(&self) -> gst::Structure {

View file

@ -318,8 +318,8 @@ impl SinkState {
extra_time: gst::ClockTime,
) -> Option<gst::SingleShotClockId> {
let running_time = running_time?;
let clock = imp.instance().clock()?;
let base_time = imp.instance().base_time()?;
let clock = imp.obj().clock()?;
let base_time = imp.obj().base_time()?;
let wait_until = running_time + base_time;
let wait_until = wait_until.saturating_add(extra_time);
@ -412,7 +412,7 @@ impl FallbackSwitch {
let mut best_priority = 0u32;
let mut best_pad = None;
for pad in self.instance().sink_pads() {
for pad in self.obj().sink_pads() {
/* Don't consider the active sinkpad */
let pad = pad.downcast_ref::<super::FallbackSwitchSinkPad>().unwrap();
let pad_imp = pad.imp();
@ -461,7 +461,7 @@ impl FallbackSwitch {
}
fn cancel_waits(&self) {
for pad in self.instance().sink_pads() {
for pad in self.obj().sink_pads() {
let pad = pad.downcast_ref::<super::FallbackSwitchSinkPad>().unwrap();
let pad_imp = pad.imp();
let mut pad_state = pad_imp.state.lock();
@ -477,12 +477,12 @@ impl FallbackSwitch {
) {
state.cancel_timeout();
let clock = match self.instance().clock() {
let clock = match self.obj().clock() {
None => return,
Some(clock) => clock,
};
let base_time = match self.instance().base_time() {
let base_time = match self.obj().base_time() {
Some(base_time) => base_time,
None => return,
};
@ -777,7 +777,7 @@ impl FallbackSwitch {
std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep)
});
self.instance().notify(PROP_ACTIVE_PAD);
self.obj().notify(PROP_ACTIVE_PAD);
}
if discont_pending && !buffer.flags().contains(gst::BufferFlags::DISCONT) {
@ -931,7 +931,7 @@ impl FallbackSwitch {
std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep)
});
self.instance().notify(PROP_ACTIVE_PAD);
self.obj().notify(PROP_ACTIVE_PAD);
}
self.src_pad.push_event(event)
}
@ -953,7 +953,7 @@ impl FallbackSwitch {
self.active_sinkpad.lock().as_ref() == Some(pad)
}
_ => {
gst::Pad::query_default(pad, Some(&*self.instance()), query);
gst::Pad::query_default(pad, Some(&*self.obj()), query);
false
}
};
@ -983,7 +983,7 @@ impl FallbackSwitch {
let mut min_latency = gst::ClockTime::ZERO;
let mut max_latency = gst::ClockTime::NONE;
for pad in self.instance().sink_pads() {
for pad in self.obj().sink_pads() {
let mut peer_query = gst::query::Latency::new();
ret = pad.peer_query(&mut peer_query);
@ -1017,7 +1017,7 @@ impl FallbackSwitch {
if let Some(sinkpad) = sinkpad {
sinkpad.peer_query(query)
} else {
gst::Pad::query_default(pad, Some(&*self.instance()), query)
gst::Pad::query_default(pad, Some(&*self.obj()), query)
}
}
_ => {
@ -1144,11 +1144,9 @@ impl ObjectImpl for FallbackSwitch {
settings.timeout = new_value;
debug!(CAT, imp: self, "Timeout now {}", settings.timeout);
drop(settings);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
PROP_LATENCY => {
let mut settings = self.settings.lock();
@ -1156,11 +1154,9 @@ impl ObjectImpl for FallbackSwitch {
settings.latency = new_value;
drop(settings);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
PROP_MIN_UPSTREAM_LATENCY => {
let mut settings = self.settings.lock();
@ -1168,11 +1164,9 @@ impl ObjectImpl for FallbackSwitch {
settings.min_upstream_latency = new_value;
drop(settings);
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
PROP_IMMEDIATE_FALLBACK => {
let mut settings = self.settings.lock();
@ -1221,7 +1215,7 @@ impl ObjectImpl for FallbackSwitch {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.src_pad).unwrap();
obj.set_element_flags(gst::ElementFlags::REQUIRE_CLOCK);
}
@ -1284,7 +1278,7 @@ impl ElementImpl for FallbackSwitch {
let mut state = self.state.lock();
let prev_active_pad = self.active_sinkpad.lock().take();
*state = State::default();
let pads = self.instance().sink_pads();
let pads = self.obj().sink_pads();
if let Some(pad) = pads.first() {
let pad = pad.downcast_ref::<super::FallbackSwitchSinkPad>().unwrap();
@ -1295,7 +1289,7 @@ impl ElementImpl for FallbackSwitch {
drop(state);
if prev_active_pad.as_ref() != Some(pad) {
self.instance().notify(PROP_ACTIVE_PAD);
self.obj().notify(PROP_ACTIVE_PAD);
}
}
for pad in pads {
@ -1318,7 +1312,7 @@ impl ElementImpl for FallbackSwitch {
}
gst::StateChange::PausedToReady => {
*self.state.lock() = State::default();
for pad in self.instance().sink_pads() {
for pad in self.obj().sink_pads() {
let pad = pad.downcast_ref::<super::FallbackSwitchSinkPad>().unwrap();
let pad_imp = pad.imp();
*pad_imp.state.lock() = SinkState::default();
@ -1378,7 +1372,7 @@ impl ElementImpl for FallbackSwitch {
.build();
pad.set_active(true).unwrap();
self.instance().add_pad(&pad).unwrap();
self.obj().add_pad(&pad).unwrap();
let notify_active_pad = match &mut *self.active_sinkpad.lock() {
active_sinkpad @ None => {
@ -1396,16 +1390,14 @@ impl ElementImpl for FallbackSwitch {
drop(state);
if notify_active_pad {
self.instance().notify(PROP_ACTIVE_PAD);
self.obj().notify(PROP_ACTIVE_PAD);
}
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
self.instance().child_added(&pad, &pad.name());
self.obj().child_added(&pad, &pad.name());
Some(pad.upcast())
}
@ -1416,14 +1408,12 @@ impl ElementImpl for FallbackSwitch {
drop(pad_state);
let _ = pad.set_active(false);
self.instance().remove_pad(pad).unwrap();
self.obj().remove_pad(pad).unwrap();
self.instance().child_removed(pad, &pad.name());
let _ = self.instance().post_message(
gst::message::Latency::builder()
.src(&*self.instance())
.build(),
);
self.obj().child_removed(pad, &pad.name());
let _ = self
.obj()
.post_message(gst::message::Latency::builder().src(&*self.obj()).build());
}
}
@ -1432,12 +1422,12 @@ impl ElementImpl for FallbackSwitch {
// This allows accessing the pads and their properties from e.g. gst-launch.
impl ChildProxyImpl for FallbackSwitch {
fn children_count(&self) -> u32 {
let object = self.instance();
let object = self.obj();
object.num_pads() as u32
}
fn child_by_name(&self, name: &str) -> Option<glib::Object> {
let object = self.instance();
let object = self.obj();
object
.pads()
.into_iter()
@ -1446,7 +1436,7 @@ impl ChildProxyImpl for FallbackSwitch {
}
fn child_by_index(&self, index: u32) -> Option<glib::Object> {
let object = self.instance();
let object = self.obj();
object
.pads()
.into_iter()

View file

@ -497,7 +497,7 @@ impl ToggleRecord {
drop(rec_state);
drop(state);
self.instance().notify("recording");
self.obj().notify("recording");
Ok(HandleResult::Drop)
}
@ -583,7 +583,7 @@ impl ToggleRecord {
drop(rec_state);
drop(state);
self.instance().notify("recording");
self.obj().notify("recording");
Ok(HandleResult::Pass(data))
}
@ -1187,7 +1187,7 @@ impl ToggleRecord {
);
if recording_state_updated {
self.instance().notify("recording");
self.obj().notify("recording");
}
return Err(gst::FlowError::Eos);
@ -1444,7 +1444,7 @@ impl ToggleRecord {
};
if recording_state_changed {
self.instance().notify("recording");
self.obj().notify("recording");
}
// If a serialized event and coming after Segment and a new Segment is pending,
@ -1859,7 +1859,7 @@ impl ObjectImpl for ToggleRecord {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.main_stream.sinkpad).unwrap();
obj.add_pad(&self.main_stream.srcpad).unwrap();
}
@ -1982,7 +1982,7 @@ impl ElementImpl for ToggleRecord {
let mut rec_state = self.state.lock();
*rec_state = State::default();
drop(rec_state);
self.instance().notify("recording");
self.obj().notify("recording");
}
Ok(success)
@ -2001,7 +2001,7 @@ impl ElementImpl for ToggleRecord {
let id = *pad_count;
*pad_count += 1;
let templ = self.instance().pad_template("sink_%u").unwrap();
let templ = self.obj().pad_template("sink_%u").unwrap();
let sinkpad =
gst::Pad::builder_with_template(&templ, Some(format!("sink_{}", id).as_str()))
.chain_function(|pad, parent, buffer| {
@ -2034,7 +2034,7 @@ impl ElementImpl for ToggleRecord {
})
.build();
let templ = self.instance().pad_template("src_%u").unwrap();
let templ = self.obj().pad_template("src_%u").unwrap();
let srcpad = gst::Pad::builder_with_template(&templ, Some(format!("src_{}", id).as_str()))
.event_function(|pad, parent, event| {
ToggleRecord::catch_panic_pad_function(
@ -2072,8 +2072,8 @@ impl ElementImpl for ToggleRecord {
drop(pads);
drop(other_streams_guard);
self.instance().add_pad(&sinkpad).unwrap();
self.instance().add_pad(&srcpad).unwrap();
self.obj().add_pad(&sinkpad).unwrap();
self.obj().add_pad(&srcpad).unwrap();
Some(sinkpad)
}
@ -2105,7 +2105,7 @@ impl ElementImpl for ToggleRecord {
stream.srcpad.set_active(false).unwrap();
stream.sinkpad.set_active(false).unwrap();
self.instance().remove_pad(&stream.sinkpad).unwrap();
self.instance().remove_pad(&stream.srcpad).unwrap();
self.obj().remove_pad(&stream.sinkpad).unwrap();
self.obj().remove_pad(&stream.srcpad).unwrap();
}
}

View file

@ -174,7 +174,7 @@ impl ObjectImpl for BufferLateness {
fn constructed(&self) {
self.parent_constructed();
if let Some(params) = self.instance().property::<Option<String>>("params") {
if let Some(params) = self.obj().property::<Option<String>>("params") {
let mut state = self.state.lock().unwrap();
state.settings.update_from_params(self, params);
}

View file

@ -134,7 +134,7 @@ impl ObjectImpl for PipelineSnapshot {
self.parent_constructed();
let mut settings = Settings::default();
if let Some(params) = self.instance().property::<Option<String>>("params") {
if let Some(params) = self.obj().property::<Option<String>>("params") {
settings.update_from_params(self, params);
}
@ -185,7 +185,7 @@ impl PipelineSnapshot {
let mut signals = Signals::new(&[SIGUSR1])?;
let signal_handle = signals.handle();
let tracer_weak = self.instance().downgrade();
let tracer_weak = self.obj().downgrade();
let pipelines = self.pipelines.clone();
let thread_handle = std::thread::spawn(move || {

View file

@ -201,7 +201,7 @@ impl ObjectImpl for QueueLevels {
fn constructed(&self) {
self.parent_constructed();
if let Some(params) = self.instance().property::<Option<String>>("params") {
if let Some(params) = self.obj().property::<Option<String>>("params") {
let mut state = self.state.lock().unwrap();
state.settings.update_from_params(self, params);
}

View file

@ -205,7 +205,7 @@ impl State {
// send pending messages then unblock pads
for msg in messages {
let _ = imp.instance().post_message(msg);
let _ = imp.obj().post_message(msg);
}
channels.send(true);
@ -826,7 +826,7 @@ impl ObjectImpl for UriPlaylistBin {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.set_suppressed_flags(gst::ElementFlags::SOURCE | gst::ElementFlags::SINK);
obj.set_element_flags(gst::ElementFlags::SOURCE);
}
@ -978,7 +978,7 @@ impl UriPlaylistBin {
.build()
.map_err(|e| PlaylistError::PluginMissing { error: e.into() })?;
self.instance().add(&streamsynchronizer).unwrap();
self.obj().add(&streamsynchronizer).unwrap();
let settings = self.settings.lock().unwrap();
@ -1015,7 +1015,7 @@ impl UriPlaylistBin {
let _ = uridecodebin.set_state(gst::State::Null);
});
self.instance().remove(&uridecodebin).unwrap();
self.obj().remove(&uridecodebin).unwrap();
}
if state.waiting_for_stream_collection.is_some()
@ -1062,7 +1062,7 @@ impl UriPlaylistBin {
let uridecodebin = item.uridecodebin();
self.instance().add(&uridecodebin).unwrap();
self.obj().add(&uridecodebin).unwrap();
let item_clone = item.clone();
assert!(state.waiting_for_stream_collection.is_none());
@ -1217,7 +1217,7 @@ impl UriPlaylistBin {
}
fn process_decodebin_pad(&self, src_pad: &gst::Pad) {
let element = self.instance();
let element = self.obj();
let start_next = {
let mut state_guard = self.state.lock().unwrap();
@ -1561,7 +1561,7 @@ impl UriPlaylistBin {
streamsynchronizer.release_request_pad(&ss_sink);
// remove associated ghost pad
let src_pads = imp.instance().src_pads();
let src_pads = imp.obj().src_pads();
let ghost = src_pads
.iter()
.find(|pad| {
@ -1569,9 +1569,9 @@ impl UriPlaylistBin {
ghost.target().is_none()
})
.unwrap();
imp.instance().remove_pad(ghost).unwrap();
imp.obj().remove_pad(ghost).unwrap();
imp.instance().remove(&concat).unwrap();
imp.obj().remove(&concat).unwrap();
let _ = concat.set_state(gst::State::Null);
}
}
@ -1636,7 +1636,7 @@ impl UriPlaylistBin {
uridecodebin.call_async(move |uridecodebin| {
let _ = uridecodebin.set_state(gst::State::Null);
});
let _ = self.instance().remove(&uridecodebin);
let _ = self.obj().remove(&uridecodebin);
let details = gst::Structure::builder("details");
let details = details.field("uri", item.uri());
@ -1672,7 +1672,7 @@ impl UriPlaylistBin {
current_iteration = 0;
}
let element = self.instance();
let element = self.obj();
if current_iteration != state.current_iteration {
state.current_iteration = current_iteration;
element.notify("current-iteration");

View file

@ -110,7 +110,7 @@ impl VideoDecoderImpl for CdgDec {
{
let mut out_info = self.output_info.lock().unwrap();
if out_info.is_none() {
let instance = self.instance();
let instance = self.obj();
let output_state = instance.set_output_state(
gst_video::VideoFormat::Rgba,
CDG_WIDTH,
@ -144,7 +144,7 @@ impl VideoDecoderImpl for CdgDec {
Some(cmd) => cmd,
None => {
// Not a CDG command
self.instance().release_frame(frame);
self.obj().release_frame(frame);
return Ok(gst::FlowSuccess::Ok);
}
};
@ -152,7 +152,7 @@ impl VideoDecoderImpl for CdgDec {
let mut cdg_inter = self.cdg_inter.lock().unwrap();
cdg_inter.handle_cmd(cmd);
self.instance().allocate_output_frame(&mut frame, None)?;
self.obj().allocate_output_frame(&mut frame, None)?;
{
let output = frame.output_buffer_mut().unwrap();
let info = self.output_info.lock().unwrap();
@ -190,7 +190,7 @@ impl VideoDecoderImpl for CdgDec {
gst::debug!(CAT, imp: self, "Finish frame pts={}", frame.pts().display());
self.instance().finish_frame(frame)
self.obj().finish_frame(frame)
}
fn decide_allocation(

View file

@ -110,14 +110,14 @@ fn time_to_bytes(time: gst::ClockTime) -> Bytes {
impl BaseParseImpl for CdgParse {
fn start(&self) -> Result<(), gst::ErrorMessage> {
self.instance().set_min_frame_size(CDG_PACKET_SIZE as u32);
self.obj().set_min_frame_size(CDG_PACKET_SIZE as u32);
/* Set duration */
let mut query = gst::query::Duration::new(gst::Format::Bytes);
if self.instance().src_pad().query(&mut query) {
if self.obj().src_pad().query(&mut query) {
let size = query.result();
let bytes: Option<Bytes> = size.try_into().unwrap();
self.instance().set_duration(bytes.map(bytes_to_time), 0);
self.obj().set_duration(bytes.map(bytes_to_time), 0);
}
Ok(())
@ -127,7 +127,7 @@ impl BaseParseImpl for CdgParse {
&self,
mut frame: gst_base::BaseParseFrame,
) -> Result<(gst::FlowSuccess, u32), gst::FlowError> {
if self.instance().src_pad().current_caps().is_none() {
if self.obj().src_pad().current_caps().is_none() {
// Set src pad caps
let src_caps = gst::Caps::builder("video/x-cdg")
.field("width", CDG_WIDTH as i32)
@ -136,7 +136,7 @@ impl BaseParseImpl for CdgParse {
.field("parsed", true)
.build();
self.instance()
self.obj()
.src_pad()
.push_event(gst::event::Caps::new(&src_caps));
}
@ -202,8 +202,7 @@ impl BaseParseImpl for CdgParse {
gst::debug!(CAT, imp: self, "Found frame pts={}", pts);
self.instance()
.finish_frame(frame, CDG_PACKET_SIZE as u32)?;
self.obj().finish_frame(frame, CDG_PACKET_SIZE as u32)?;
Ok((gst::FlowSuccess::Ok, skip))
}

View file

@ -208,10 +208,10 @@ impl CCDetect {
}
if notify_cc608 {
self.instance().notify("cc608");
self.obj().notify("cc608");
}
if notify_cc708 {
self.instance().notify("cc708");
self.obj().notify("cc708");
}
Ok(())

View file

@ -507,9 +507,9 @@ impl Cea608Overlay {
let mut state = self.state.lock().unwrap();
state.caption_frame = CaptionFrame::default();
state.composition = None;
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -644,7 +644,7 @@ impl ObjectImpl for Cea608Overlay {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -932,7 +932,7 @@ impl Cea608ToJson {
*state = State::default();
state.settings = old_settings;
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(..) => {
if let Some(lines) = self.state.borrow_mut().drain_pending(self) {
@ -942,9 +942,9 @@ impl Cea608ToJson {
let _ = self.output(lines);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -993,7 +993,7 @@ impl ObjectImpl for Cea608ToJson {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -367,7 +367,7 @@ impl Cea608ToTt {
_ => (),
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}
@ -414,7 +414,7 @@ impl ObjectImpl for Cea608ToTt {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -435,10 +435,10 @@ impl JsonToVtt {
),
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event);
gst::Pad::event_default(pad, Some(&*self.obj()), event);
true
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -453,7 +453,7 @@ impl JsonToVtt {
let buffers = state.handle_eos(self);
drop(state);
let _ = self.output(buffers);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Caps(..) => {
let mut downstream_caps = match self.srcpad.allowed_caps() {
@ -506,7 +506,7 @@ impl JsonToVtt {
};
/* FIXME: Handle segment updates by draining? */
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Gap(ev) => {
gst::log!(CAT, obj: pad, "Handling gap {:?}", ev);
@ -516,7 +516,7 @@ impl JsonToVtt {
let _ = self.output(buffers);
true
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -626,7 +626,7 @@ impl ObjectImpl for JsonToVtt {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -375,7 +375,7 @@ impl MccEnc {
.build();
self.srcpad.push_event(gst::event::Caps::new(&caps))
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -388,7 +388,7 @@ impl MccEnc {
gst::log!(CAT, obj: pad, "Dropping seek event");
false
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -408,7 +408,7 @@ impl MccEnc {
);
true
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -504,7 +504,7 @@ impl ObjectImpl for MccEnc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -46,9 +46,7 @@ impl PullState {
fn new(imp: &MccParse, pad: &gst::Pad) -> Self {
Self {
need_stream_start: true,
stream_id: pad
.create_stream_id(&*imp.instance(), Some("src"))
.to_string(),
stream_id: pad.create_stream_id(&*imp.obj(), Some("src")).to_string(),
offset: 0,
duration: gst::ClockTime::NONE,
}
@ -883,14 +881,14 @@ impl MccParse {
let state = self.flush(state);
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(_) => {
gst::log!(CAT, obj: pad, "Draining");
if let Err(err) = self.handle_buffer(None, false) {
gst::error!(CAT, obj: pad, "Failed to drain parser: {:?}", err);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => {
if event.is_sticky()
@ -902,7 +900,7 @@ impl MccParse {
state.pending_events.push(event);
true
} else {
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}
}
@ -1007,7 +1005,7 @@ impl MccParse {
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
match event.view() {
EventView::Seek(e) => self.perform_seek(e),
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -1061,7 +1059,7 @@ impl MccParse {
self.sinkpad.peer_query(query)
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -1140,7 +1138,7 @@ impl ObjectImpl for MccParse {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -307,9 +307,9 @@ impl SccEnc {
gst::error!(CAT, obj: pad, "Failed to write a line after EOS: {:?}", err);
return false;
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -322,7 +322,7 @@ impl SccEnc {
gst::log!(CAT, obj: pad, "Dropping seek event");
false
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -342,7 +342,7 @@ impl SccEnc {
);
true
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -391,7 +391,7 @@ impl ObjectImpl for SccEnc {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -40,9 +40,7 @@ impl PullState {
fn new(imp: &SccParse, pad: &gst::Pad) -> Self {
Self {
need_stream_start: true,
stream_id: pad
.create_stream_id(&*imp.instance(), Some("src"))
.to_string(),
stream_id: pad.create_stream_id(&*imp.obj(), Some("src")).to_string(),
offset: 0,
duration: gst::ClockTime::NONE,
}
@ -762,14 +760,14 @@ impl SccParse {
let state = self.flush(state);
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(_) => {
gst::log!(CAT, obj: pad, "Draining");
if let Err(err) = self.handle_buffer(None) {
gst::error!(CAT, obj: pad, "Failed to drain parser: {:?}", err);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => {
if event.is_sticky()
@ -781,7 +779,7 @@ impl SccParse {
state.pending_events.push(event);
true
} else {
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
}
}
@ -886,7 +884,7 @@ impl SccParse {
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
match event.view() {
EventView::Seek(e) => self.perform_seek(e),
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -940,7 +938,7 @@ impl SccParse {
self.sinkpad.peer_query(query)
}
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
}
@ -1019,7 +1017,7 @@ impl ObjectImpl for SccParse {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -220,7 +220,7 @@ impl TranscriberBin {
gst::PadProbeReturn::Ok
});
self.instance().add(&state.internal_bin)?;
self.obj().add(&state.internal_bin)?;
state.cccombiner.set_property("latency", 100.mseconds());
@ -411,8 +411,7 @@ impl TranscriberBin {
QueryViewMut::Latency(q) => {
let mut upstream_query = gst::query::Latency::new();
let ret =
gst::Pad::query_default(pad, Some(&*self.instance()), &mut upstream_query);
let ret = gst::Pad::query_default(pad, Some(&*self.obj()), &mut upstream_query);
if ret {
let (_, mut min, _) = upstream_query.result();
@ -437,7 +436,7 @@ impl TranscriberBin {
ret
}
_ => gst::Pad::query_default(pad, Some(&*self.instance()), query),
_ => gst::Pad::query_default(pad, Some(&*self.obj()), query),
}
}
@ -520,9 +519,9 @@ impl TranscriberBin {
}
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -750,7 +749,7 @@ impl ObjectImpl for TranscriberBin {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.audio_srcpad).unwrap();
obj.add_pad(&self.audio_sinkpad).unwrap();
obj.add_pad(&self.video_srcpad).unwrap();
@ -890,8 +889,8 @@ impl BinImpl for TranscriberBin {
let mut settings = self.settings.lock().unwrap();
settings.passthrough = true;
drop(settings);
self.instance().notify("passthrough");
self.instance().call_async(move |bin| {
self.obj().notify("passthrough");
self.obj().call_async(move |bin| {
let thiz = bin.imp();
thiz.block_and_update(true);
});

View file

@ -933,7 +933,7 @@ impl TtToCea608 {
drop(state);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::FlushStop(_) => {
let mut state = self.state.lock().unwrap();
@ -950,9 +950,9 @@ impl TtToCea608 {
drop(settings);
drop(state);
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -1036,7 +1036,7 @@ impl ObjectImpl for TtToCea608 {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -132,8 +132,8 @@ impl TtToJson {
.build();
self.srcpad.push_event(gst::event::Caps::new(&caps))
}
EventView::Eos(_) => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
EventView::Eos(_) => gst::Pad::event_default(pad, Some(&*self.obj()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -237,7 +237,7 @@ impl ObjectImpl for TtToJson {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}

View file

@ -157,7 +157,7 @@ impl Dav1dDec {
let input_state = state.input_state.clone();
drop(state_guard);
let instance = self.instance();
let instance = self.obj();
let output_state =
instance.set_output_state(format, pic.width(), pic.height(), Some(&input_state))?;
instance.negotiate(output_state)?;
@ -214,9 +214,9 @@ impl Dav1dDec {
}
Err(err) => {
gst::error!(CAT, "Sending data failed (error code: {})", err);
self.instance().release_frame(frame);
self.obj().release_frame(frame);
gst_video::video_decoder_error!(
&*self.instance(),
&*self.obj(),
1,
gst::StreamError::Decode,
["Sending data failed (error code {})", err]
@ -246,7 +246,7 @@ impl Dav1dDec {
Err(err) => {
gst::error!(CAT, "Sending data failed (error code: {})", err);
gst_video::video_decoder_error!(
&*self.instance(),
&*self.obj(),
1,
gst::StreamError::Decode,
["Sending data failed (error code {})", err]
@ -359,7 +359,7 @@ impl Dav1dDec {
state_guard = self.handle_resolution_change(state_guard, pic)?;
let instance = self.instance();
let instance = self.obj();
let output_state = instance
.output_state()
.expect("Output state not set. Shouldn't happen!");
@ -412,7 +412,7 @@ impl Dav1dDec {
);
gst_video::video_decoder_error!(
&*self.instance(),
&*self.obj(),
1,
gst::StreamError::Decode,
["Retrieving decoded picture failed (error code {})", err]
@ -596,7 +596,7 @@ impl VideoDecoderImpl for Dav1dDec {
Some(ref info) => {
let mut upstream_latency = gst::query::Latency::new();
if self.instance().sink_pad().peer_query(&mut upstream_latency) {
if self.obj().sink_pad().peer_query(&mut upstream_latency) {
let (live, mut min, mut max) = upstream_latency.result();
// For autodetection: 1 if live, else whatever dav1d gives us
let frame_latency: u64 = if max_frame_delay < 0 && live {
@ -665,7 +665,7 @@ impl VideoDecoderImpl for Dav1dDec {
let mut latency_query = gst::query::Latency::new();
let mut is_live = false;
if self.instance().sink_pad().peer_query(&mut latency_query) {
if self.obj().sink_pad().peer_query(&mut latency_query) {
is_live = latency_query.result().0;
}

View file

@ -371,7 +371,7 @@ impl VideoDecoderImpl for Ffv1Dec {
let format = get_output_format(decoder.config_record())
.ok_or_else(|| gst::loggable_error!(CAT, "Unsupported format"))?;
let instance = self.instance();
let instance = self.obj();
let output_state = instance
.set_output_state(format, info.width(), info.height(), Some(state))
.map_err(|err| gst::loggable_error!(CAT, "Failed to set output params: {}", err))?;
@ -437,7 +437,7 @@ impl VideoDecoderImpl for Ffv1Dec {
drop(state);
frame.set_output_buffer(buf);
self.instance().finish_frame(frame)?;
self.obj().finish_frame(frame)?;
Ok(gst::FlowSuccess::Ok)
}

View file

@ -275,7 +275,7 @@ impl VideoEncoderImpl for GifEnc {
*self.state.borrow_mut() = Some(state);
}
let instance = self.instance();
let instance = self.obj();
let output_state = instance
.set_output_state(gst::Caps::builder("image/gif").build(), Some(state))
.map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?;
@ -397,7 +397,7 @@ impl VideoEncoderImpl for GifEnc {
// Currently not using incremental frames -> every frame is a keyframe
frame.set_flags(gst_video::VideoCodecFrameFlags::SYNC_POINT);
frame.set_output_buffer(output_buffer);
self.instance().finish_frame(Some(frame))
self.obj().finish_frame(Some(frame))
}
}
@ -425,7 +425,7 @@ impl GifEnc {
});
if let Some(trailer_buffer) = trailer_buffer {
// manually push GIF trailer to the encoder's src pad
self.instance().src_pad().push(trailer_buffer)?;
self.obj().src_pad().push(trailer_buffer)?;
}
Ok(gst::FlowSuccess::Ok)

View file

@ -85,7 +85,7 @@ impl ObjectImpl for PaintableSink {
"paintable" => {
let mut paintable = self.paintable.lock().unwrap();
if paintable.is_none() {
self.instance().initialize_paintable(&mut paintable);
self.obj().initialize_paintable(&mut paintable);
}
let paintable = match &*paintable {
@ -183,7 +183,7 @@ impl ElementImpl for PaintableSink {
gst::StateChange::NullToReady => {
let mut paintable = self.paintable.lock().unwrap();
if paintable.is_none() {
self.instance().initialize_paintable(&mut paintable);
self.obj().initialize_paintable(&mut paintable);
}
if paintable.is_none() {

View file

@ -158,10 +158,10 @@ impl SinkPaintable {
old_size,
new_size,
);
self.instance().invalidate_size();
self.obj().invalidate_size();
}
self.instance().invalidate_contents();
self.obj().invalidate_contents();
}
}
}

View file

@ -295,7 +295,7 @@ impl VideoEncoderImpl for PngEncoder {
*self.state.lock() = Some(state);
}
let instance = self.instance();
let instance = self.obj();
let output_state = instance
.set_output_state(gst::Caps::builder("image/png").build(), Some(state))
.map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?;
@ -335,6 +335,6 @@ impl VideoEncoderImpl for PngEncoder {
// There are no such incremental frames in the png format
frame.set_flags(gst_video::VideoCodecFrameFlags::SYNC_POINT);
frame.set_output_buffer(output_buffer);
self.instance().finish_frame(Some(frame))
self.obj().finish_frame(Some(frame))
}
}

View file

@ -805,7 +805,7 @@ impl VideoEncoderImpl for Rav1Enc {
video_info,
});
let instance = self.instance();
let instance = self.obj();
let output_state = instance
.set_output_state(
gst::Caps::builder("video/x-av1")
@ -913,7 +913,7 @@ impl Rav1Enc {
packet_type
);
let instance = self.instance();
let instance = self.obj();
let mut frame = instance
.frame(frame_number as i32)
.expect("frame not found");

View file

@ -304,7 +304,7 @@ impl ObjectImpl for RoundedCorners {
border_radius
);
settings.border_radius_px = border_radius;
self.instance().reconfigure_src();
self.obj().reconfigure_src();
}
}
_ => unimplemented!(),
@ -462,10 +462,10 @@ impl BaseTransformImpl for RoundedCorners {
);
if out_info.format() == VideoFormat::I420 {
self.instance().set_passthrough(true);
self.obj().set_passthrough(true);
return Ok(());
} else {
self.instance().set_passthrough(false);
self.obj().set_passthrough(false);
}
// See "A420" planar 4:4:2:0 AYUV section
@ -487,7 +487,7 @@ impl BaseTransformImpl for RoundedCorners {
&self,
inbuf: InputBuffer,
) -> Result<PrepareOutputBufferSuccess, gst::FlowError> {
if self.instance().is_passthrough() {
if self.obj().is_passthrough() {
return Ok(PrepareOutputBufferSuccess::InputBuffer);
}

View file

@ -105,7 +105,7 @@ impl ColorDetect {
.map(|c| ((c.r as u32) << 16) | ((c.g as u32) << 8) | (c.b as u32)),
);
self.instance()
self.obj()
.post_message(
gst::message::Element::builder(
gst::structure::Structure::builder("colordetect")

View file

@ -196,7 +196,7 @@ impl ElementImpl for VideoCompare {
// Since we are releasing the reference pad, we need to select a new pad for the
// comparisons. At the moment we have no defined criteria to select the next
// reference sink pad, so we choose the first that comes.
for sink_pad in self.instance().sink_pads() {
for sink_pad in self.obj().sink_pads() {
if current_reference_pad != sink_pad {
// Choose the first available left sink pad
*reference_pad = Some(sink_pad);
@ -317,7 +317,7 @@ impl VideoAggregatorImpl for VideoCompare {
// Loop through all remaining sink pads and compare the latest available buffer
for pad in self
.instance()
.obj()
.sink_pads()
.into_iter()
.map(|pad| pad.downcast::<gst_video::VideoAggregatorPad>().unwrap())
@ -369,7 +369,7 @@ impl VideoAggregatorImpl for VideoCompare {
"Image detected {}",
message.running_time.unwrap().display()
);
let element = self.instance();
let element = self.obj();
let _ = element.post_message(
gst::message::Element::builder(message.into())
.src(element.as_ref())

View file

@ -241,16 +241,16 @@ impl WebPDec {
EventView::FlushStop(..) => {
let mut state = self.state.lock().unwrap();
*state = State::default();
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Eos(..) => {
if let Err(err) = self.decode() {
self.post_error_message(err);
}
gst::Pad::event_default(pad, Some(&*self.instance()), event)
gst::Pad::event_default(pad, Some(&*self.obj()), event)
}
EventView::Segment(..) => true,
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
@ -260,7 +260,7 @@ impl WebPDec {
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
match event.view() {
EventView::Seek(..) => false,
_ => gst::Pad::event_default(pad, Some(&*self.instance()), event),
_ => gst::Pad::event_default(pad, Some(&*self.obj()), event),
}
}
}
@ -309,7 +309,7 @@ impl ObjectImpl for WebPDec {
fn constructed(&self) {
self.parent_constructed();
let obj = self.instance();
let obj = self.obj();
obj.add_pad(&self.sinkpad).unwrap();
obj.add_pad(&self.srcpad).unwrap();
}