mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-04-28 07:55:22 +00:00
fallbackswitch: Report None as active-pad if we had no output yet
Instead of the main stream, pretending all to be ok.
This commit is contained in:
parent
44ad0a2f52
commit
7945de32eb
1 changed files with 14 additions and 8 deletions
|
@ -38,7 +38,7 @@ use std::sync::{Mutex, RwLock};
|
||||||
struct FallbackSwitch {
|
struct FallbackSwitch {
|
||||||
sinkpad: gst_base::AggregatorPad,
|
sinkpad: gst_base::AggregatorPad,
|
||||||
fallback_sinkpad: RwLock<Option<gst_base::AggregatorPad>>,
|
fallback_sinkpad: RwLock<Option<gst_base::AggregatorPad>>,
|
||||||
active_sinkpad: Mutex<gst::Pad>,
|
active_sinkpad: Mutex<Option<gst::Pad>>,
|
||||||
output_state: Mutex<OutputState>,
|
output_state: Mutex<OutputState>,
|
||||||
pad_states: RwLock<PadStates>,
|
pad_states: RwLock<PadStates>,
|
||||||
settings: Mutex<Settings>,
|
settings: Mutex<Settings>,
|
||||||
|
@ -149,7 +149,7 @@ impl FallbackSwitch {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut active_sinkpad = self.active_sinkpad.lock().unwrap();
|
let mut active_sinkpad = self.active_sinkpad.lock().unwrap();
|
||||||
let pad_change = &*active_sinkpad != self.sinkpad.upcast_ref::<gst::Pad>();
|
let pad_change = active_sinkpad.as_ref() != Some(self.sinkpad.upcast_ref::<gst::Pad>());
|
||||||
if pad_change {
|
if pad_change {
|
||||||
if buffer.get_flags().contains(gst::BufferFlags::DELTA_UNIT) {
|
if buffer.get_flags().contains(gst::BufferFlags::DELTA_UNIT) {
|
||||||
gst_info!(
|
gst_info!(
|
||||||
|
@ -166,7 +166,7 @@ impl FallbackSwitch {
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_info!(CAT, obj: agg, "Active pad changed to sinkpad");
|
gst_info!(CAT, obj: agg, "Active pad changed to sinkpad");
|
||||||
*active_sinkpad = self.sinkpad.clone().upcast();
|
*active_sinkpad = Some(self.sinkpad.clone().upcast());
|
||||||
}
|
}
|
||||||
drop(active_sinkpad);
|
drop(active_sinkpad);
|
||||||
|
|
||||||
|
@ -275,7 +275,8 @@ impl FallbackSwitch {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut active_sinkpad = self.active_sinkpad.lock().unwrap();
|
let mut active_sinkpad = self.active_sinkpad.lock().unwrap();
|
||||||
let pad_change = &*active_sinkpad != fallback_sinkpad.upcast_ref::<gst::Pad>();
|
let pad_change =
|
||||||
|
active_sinkpad.as_ref() != Some(fallback_sinkpad.upcast_ref::<gst::Pad>());
|
||||||
if pad_change {
|
if pad_change {
|
||||||
if buffer.get_flags().contains(gst::BufferFlags::DELTA_UNIT) {
|
if buffer.get_flags().contains(gst::BufferFlags::DELTA_UNIT) {
|
||||||
gst_info!(
|
gst_info!(
|
||||||
|
@ -292,7 +293,7 @@ impl FallbackSwitch {
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_info!(CAT, obj: agg, "Active pad changed to fallback sinkpad");
|
gst_info!(CAT, obj: agg, "Active pad changed to fallback sinkpad");
|
||||||
*active_sinkpad = fallback_sinkpad.clone().upcast();
|
*active_sinkpad = Some(fallback_sinkpad.clone().upcast());
|
||||||
}
|
}
|
||||||
drop(active_sinkpad);
|
drop(active_sinkpad);
|
||||||
|
|
||||||
|
@ -374,9 +375,9 @@ impl ObjectSubclass for FallbackSwitch {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
sinkpad: sinkpad.clone(),
|
sinkpad,
|
||||||
fallback_sinkpad: RwLock::new(None),
|
fallback_sinkpad: RwLock::new(None),
|
||||||
active_sinkpad: Mutex::new(sinkpad.upcast()),
|
active_sinkpad: Mutex::new(None),
|
||||||
output_state: Mutex::new(OutputState::default()),
|
output_state: Mutex::new(OutputState::default()),
|
||||||
pad_states: RwLock::new(PadStates::default()),
|
pad_states: RwLock::new(PadStates::default()),
|
||||||
settings: Mutex::new(Settings::default()),
|
settings: Mutex::new(Settings::default()),
|
||||||
|
@ -535,13 +536,18 @@ impl ElementImpl for FallbackSwitch {
|
||||||
|
|
||||||
impl AggregatorImpl for FallbackSwitch {
|
impl AggregatorImpl for FallbackSwitch {
|
||||||
fn start(&self, _agg: &gst_base::Aggregator) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, _agg: &gst_base::Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
*self.active_sinkpad.lock().unwrap() = self.sinkpad.clone().upcast();
|
|
||||||
*self.output_state.lock().unwrap() = OutputState::default();
|
*self.output_state.lock().unwrap() = OutputState::default();
|
||||||
*self.pad_states.write().unwrap() = PadStates::default();
|
*self.pad_states.write().unwrap() = PadStates::default();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stop(&self, _agg: &gst_base::Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
|
*self.active_sinkpad.lock().unwrap() = None;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn sink_event_pre_queue(
|
fn sink_event_pre_queue(
|
||||||
&self,
|
&self,
|
||||||
agg: &gst_base::Aggregator,
|
agg: &gst_base::Aggregator,
|
||||||
|
|
Loading…
Reference in a new issue