mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-10 12:29:44 +00:00
Use let-else instead of match for weak reference upgrades
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1375>
This commit is contained in:
parent
74c04d79c9
commit
855b03a9ea
18 changed files with 90 additions and 135 deletions
|
@ -642,9 +642,8 @@ impl ObjectImpl for S3HlsSink {
|
||||||
self.hlssink.connect("get-playlist-stream", false, {
|
self.hlssink.connect("get-playlist-stream", false, {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
move |args| -> Option<glib::Value> {
|
move |args| -> Option<glib::Value> {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return None;
|
||||||
None => return None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let s3client = self_.s3client_from_settings();
|
let s3client = self_.s3client_from_settings();
|
||||||
|
@ -677,9 +676,8 @@ impl ObjectImpl for S3HlsSink {
|
||||||
self.hlssink.connect("get-fragment-stream", false, {
|
self.hlssink.connect("get-fragment-stream", false, {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
move |args| -> Option<glib::Value> {
|
move |args| -> Option<glib::Value> {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return None;
|
||||||
None => return None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let s3client = self_.s3client_from_settings();
|
let s3client = self_.s3client_from_settings();
|
||||||
|
@ -712,9 +710,8 @@ impl ObjectImpl for S3HlsSink {
|
||||||
self.hlssink.connect("delete-fragment", false, {
|
self.hlssink.connect("delete-fragment", false, {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
move |args| -> Option<glib::Value> {
|
move |args| -> Option<glib::Value> {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return None;
|
||||||
None => return None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let s3_client = self_.s3client_from_settings();
|
let s3_client = self_.s3client_from_settings();
|
||||||
|
|
|
@ -269,9 +269,8 @@ fn main() -> Result<(), Error> {
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::StateChanged(state_changed) => {
|
MessageView::StateChanged(state_changed) => {
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
let Some(pipeline) = pipeline_weak.upgrade() else {
|
||||||
Some(pipeline) => pipeline,
|
break;
|
||||||
None => break,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut need_write = write_playlist.lock().unwrap();
|
let mut need_write = write_playlist.lock().unwrap();
|
||||||
|
|
|
@ -782,9 +782,8 @@ impl ObjectImpl for HlsSink3 {
|
||||||
.connect("format-location-full", false, {
|
.connect("format-location-full", false, {
|
||||||
let imp_weak = self.downgrade();
|
let imp_weak = self.downgrade();
|
||||||
move |args| {
|
move |args| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
Some(imp) => imp,
|
return Some(None::<String>.to_value());
|
||||||
None => return Some(None::<String>.to_value()),
|
|
||||||
};
|
};
|
||||||
let fragment_id = args[1].get::<u32>().unwrap();
|
let fragment_id = args[1].get::<u32>().unwrap();
|
||||||
gst::info!(CAT, imp: imp, "Got fragment-id: {}", fragment_id);
|
gst::info!(CAT, imp: imp, "Got fragment-id: {}", fragment_id);
|
||||||
|
@ -1322,9 +1321,8 @@ impl ObjectImpl for HlsCmafSink {
|
||||||
settings.appsink.set_callbacks(
|
settings.appsink.set_callbacks(
|
||||||
gst_app::AppSinkCallbacks::builder()
|
gst_app::AppSinkCallbacks::builder()
|
||||||
.new_sample(move |sink| {
|
.new_sample(move |sink| {
|
||||||
let imp = match self_weak.upgrade() {
|
let Some(imp) = self_weak.upgrade() else {
|
||||||
Some(imp) => imp,
|
return Err(gst::FlowError::Eos);
|
||||||
_ => return Err(gst::FlowError::Eos),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let sample = sink.pull_sample().map_err(|_| gst::FlowError::Eos)?;
|
let sample = sink.pull_sample().map_err(|_| gst::FlowError::Eos)?;
|
||||||
|
|
|
@ -87,9 +87,8 @@ impl DeviceProviderImpl for DeviceProvider {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
*thread_guard = Some(thread::spawn(move || {
|
*thread_guard = Some(thread::spawn(move || {
|
||||||
{
|
{
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut find_guard = imp.find.lock().unwrap();
|
let mut find_guard = imp.find.lock().unwrap();
|
||||||
|
@ -109,9 +108,8 @@ impl DeviceProviderImpl for DeviceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if !imp.is_running.load(atomic::Ordering::SeqCst) {
|
if !imp.is_running.load(atomic::Ordering::SeqCst) {
|
||||||
|
|
|
@ -761,14 +761,12 @@ impl Receiver {
|
||||||
|
|
||||||
// Capture until error or shutdown
|
// Capture until error or shutdown
|
||||||
loop {
|
loop {
|
||||||
let receiver = match receiver.upgrade().map(Receiver) {
|
let Some(receiver) = receiver.upgrade().map(Receiver) else {
|
||||||
None => break,
|
break;
|
||||||
Some(receiver) => receiver,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let element = match receiver.0.element.upgrade() {
|
let Some(element) = receiver.0.element.upgrade() else {
|
||||||
None => return,
|
break;
|
||||||
Some(element) => element,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let flushing = {
|
let flushing = {
|
||||||
|
|
|
@ -431,9 +431,8 @@ impl SignallableImpl for Signaller {
|
||||||
webrtcbin: &gst::Element| {
|
webrtcbin: &gst::Element| {
|
||||||
let obj_weak = signaller.downgrade();
|
let obj_weak = signaller.downgrade();
|
||||||
webrtcbin.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
webrtcbin.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
||||||
let obj = match obj_weak.upgrade() {
|
let Some(obj) = obj_weak.upgrade() else {
|
||||||
Some(obj) => obj,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let state =
|
let state =
|
||||||
|
|
|
@ -426,9 +426,8 @@ impl WhepSrc {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin
|
self.webrtcbin
|
||||||
.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = webrtcbin.property::<WebRTCICEGatheringState>("ice-gathering-state");
|
let state = webrtcbin.property::<WebRTCICEGatheringState>("ice-gathering-state");
|
||||||
|
@ -458,9 +457,8 @@ impl WhepSrc {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin
|
self.webrtcbin
|
||||||
.connect_notify(Some("ice-connection-state"), move |webrtcbin, _pspec| {
|
.connect_notify(Some("ice-connection-state"), move |webrtcbin, _pspec| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = webrtcbin.property::<WebRTCICEConnectionState>("ice-connection-state");
|
let state = webrtcbin.property::<WebRTCICEConnectionState>("ice-connection-state");
|
||||||
|
@ -489,9 +487,8 @@ impl WhepSrc {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin
|
self.webrtcbin
|
||||||
.connect_notify(Some("connection-state"), move |webrtcbin, _pspec| {
|
.connect_notify(Some("connection-state"), move |webrtcbin, _pspec| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = webrtcbin.property::<WebRTCPeerConnectionState>("connection-state");
|
let state = webrtcbin.property::<WebRTCPeerConnectionState>("connection-state");
|
||||||
|
@ -520,9 +517,8 @@ impl WhepSrc {
|
||||||
|
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin.connect_pad_added(move |_, pad| {
|
self.webrtcbin.connect_pad_added(move |_, pad| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gst::debug!(
|
gst::debug!(
|
||||||
|
@ -547,9 +543,8 @@ impl WhepSrc {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin.connect("on-negotiation-needed", false, {
|
self.webrtcbin.connect("on-negotiation-needed", false, {
|
||||||
move |_| {
|
move |_| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return None;
|
||||||
None => return None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let settings = self_.settings.lock().unwrap();
|
let settings = self_.settings.lock().unwrap();
|
||||||
|
@ -780,9 +775,8 @@ impl WhepSrc {
|
||||||
fn generate_offer(&self) {
|
fn generate_offer(&self) {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
let promise = gst::Promise::with_change_func(move |reply| {
|
let promise = gst::Promise::with_change_func(move |reply| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let reply = match reply {
|
let reply = match reply {
|
||||||
|
|
|
@ -357,9 +357,8 @@ impl ObjectImpl for WhipSink {
|
||||||
let self_weak = self.downgrade();
|
let self_weak = self.downgrade();
|
||||||
self.webrtcbin
|
self.webrtcbin
|
||||||
.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
.connect_notify(Some("ice-gathering-state"), move |webrtcbin, _pspec| {
|
||||||
let self_ = match self_weak.upgrade() {
|
let Some(self_) = self_weak.upgrade() else {
|
||||||
Some(self_) => self_,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = webrtcbin.property::<WebRTCICEGatheringState>("ice-gathering-state");
|
let state = webrtcbin.property::<WebRTCICEGatheringState>("ice-gathering-state");
|
||||||
|
|
|
@ -105,9 +105,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let video_sink_weak = video_sink.downgrade();
|
let video_sink_weak = video_sink.downgrade();
|
||||||
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(100), move || {
|
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(100), move || {
|
||||||
let video_sink = match video_sink_weak.upgrade() {
|
let Some(video_sink) = video_sink_weak.upgrade() else {
|
||||||
Some(video_sink) => video_sink,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = video_sink
|
let position = video_sink
|
||||||
|
@ -121,9 +120,8 @@ fn create_ui(app: >k::Application) {
|
||||||
let video_src_pad_weak = video_src_pad.downgrade();
|
let video_src_pad_weak = video_src_pad.downgrade();
|
||||||
let drop_id = RefCell::new(None);
|
let drop_id = RefCell::new(None);
|
||||||
drop_button.connect_toggled(move |drop_button| {
|
drop_button.connect_toggled(move |drop_button| {
|
||||||
let video_src_pad = match video_src_pad_weak.upgrade() {
|
let Some(video_src_pad) = video_src_pad_weak.upgrade() else {
|
||||||
Some(video_src_pad) => video_src_pad,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let drop = drop_button.is_active();
|
let drop = drop_button.is_active();
|
||||||
|
@ -140,9 +138,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
window.connect_close_request(move |_| {
|
window.connect_close_request(move |_| {
|
||||||
let app = match app_weak.upgrade() {
|
let Some(app) = app_weak.upgrade() else {
|
||||||
Some(app) => app,
|
return glib::Propagation::Stop;
|
||||||
None => return glib::Propagation::Stop,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
app.quit();
|
app.quit();
|
||||||
|
@ -155,9 +152,8 @@ fn create_ui(app: >k::Application) {
|
||||||
.add_watch_local(move |_, msg| {
|
.add_watch_local(move |_, msg| {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
let app = match app_weak.upgrade() {
|
let Some(app) = app_weak.upgrade() else {
|
||||||
Some(app) => app,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Break,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
|
|
|
@ -2893,9 +2893,8 @@ impl FallbackSrc {
|
||||||
self.obj().call_async(move |element| {
|
self.obj().call_async(move |element| {
|
||||||
let imp = element.imp();
|
let imp = element.imp();
|
||||||
|
|
||||||
let source = match source_weak.upgrade() {
|
let Some(source) = source_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(source) => source,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove blocking pad probes if they are still there as otherwise shutting down the
|
// Remove blocking pad probes if they are still there as otherwise shutting down the
|
||||||
|
@ -3081,9 +3080,8 @@ impl FallbackSrc {
|
||||||
let element_weak = element.downgrade();
|
let element_weak = element.downgrade();
|
||||||
timeout
|
timeout
|
||||||
.wait_async(move |_clock, _time, _id| {
|
.wait_async(move |_clock, _time, _id| {
|
||||||
let element = match element_weak.upgrade() {
|
let Some(element) = element_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(element) => element,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gst::debug!(CAT, obj: element, "Woke up, retrying");
|
gst::debug!(CAT, obj: element, "Woke up, retrying");
|
||||||
|
@ -3305,9 +3303,8 @@ impl FallbackSrc {
|
||||||
let element_weak = self.obj().downgrade();
|
let element_weak = self.obj().downgrade();
|
||||||
timeout
|
timeout
|
||||||
.wait_async(move |_clock, _time, _id| {
|
.wait_async(move |_clock, _time, _id| {
|
||||||
let element = match element_weak.upgrade() {
|
let Some(element) = element_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(element) => element,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
element.call_async(move |element| {
|
element.call_async(move |element| {
|
||||||
|
|
|
@ -583,9 +583,8 @@ impl FallbackSwitch {
|
||||||
let imp_weak = self.downgrade();
|
let imp_weak = self.downgrade();
|
||||||
timeout_id
|
timeout_id
|
||||||
.wait_async(move |_clock, _time, clock_id| {
|
.wait_async(move |_clock, _time, clock_id| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
imp.on_timeout(clock_id);
|
imp.on_timeout(clock_id);
|
||||||
})
|
})
|
||||||
|
|
|
@ -217,14 +217,12 @@ fn create_ui(app: >k::Application) {
|
||||||
let video_sink_weak = video_sink.downgrade();
|
let video_sink_weak = video_sink.downgrade();
|
||||||
let togglerecord_weak = togglerecord.downgrade();
|
let togglerecord_weak = togglerecord.downgrade();
|
||||||
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(100), move || {
|
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(100), move || {
|
||||||
let video_sink = match video_sink_weak.upgrade() {
|
let Some(video_sink) = video_sink_weak.upgrade() else {
|
||||||
Some(video_sink) => video_sink,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let togglerecord = match togglerecord_weak.upgrade() {
|
let Some(togglerecord) = togglerecord_weak.upgrade() else {
|
||||||
Some(togglerecord) => togglerecord,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = video_sink
|
let position = video_sink
|
||||||
|
@ -244,9 +242,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let togglerecord_weak = togglerecord.downgrade();
|
let togglerecord_weak = togglerecord.downgrade();
|
||||||
record_button.connect_clicked(move |button| {
|
record_button.connect_clicked(move |button| {
|
||||||
let togglerecord = match togglerecord_weak.upgrade() {
|
let Some(togglerecord) = togglerecord_weak.upgrade() else {
|
||||||
Some(togglerecord) => togglerecord,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let recording = !togglerecord.property::<bool>("record");
|
let recording = !togglerecord.property::<bool>("record");
|
||||||
|
@ -257,9 +254,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let record_button_weak = record_button.downgrade();
|
let record_button_weak = record_button.downgrade();
|
||||||
finish_button.connect_clicked(move |button| {
|
finish_button.connect_clicked(move |button| {
|
||||||
let record_button = match record_button_weak.upgrade() {
|
let Some(record_button) = record_button_weak.upgrade() else {
|
||||||
Some(record_button) => record_button,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
record_button.set_sensitive(false);
|
record_button.set_sensitive(false);
|
||||||
|
@ -271,9 +267,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let app_weak = app.downgrade();
|
let app_weak = app.downgrade();
|
||||||
window.connect_close_request(move |_| {
|
window.connect_close_request(move |_| {
|
||||||
let app = match app_weak.upgrade() {
|
let Some(app) = app_weak.upgrade() else {
|
||||||
Some(app) => app,
|
return glib::Propagation::Stop;
|
||||||
None => return glib::Propagation::Stop,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
app.quit();
|
app.quit();
|
||||||
|
@ -286,9 +281,8 @@ fn create_ui(app: >k::Application) {
|
||||||
.add_watch_local(move |_, msg| {
|
.add_watch_local(move |_, msg| {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
let app = match app_weak.upgrade() {
|
let Some(app) = app_weak.upgrade() else {
|
||||||
Some(app) => app,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Break,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
|
|
|
@ -192,9 +192,8 @@ impl PipelineSnapshot {
|
||||||
for signal in &mut signals {
|
for signal in &mut signals {
|
||||||
match signal {
|
match signal {
|
||||||
SIGUSR1 => {
|
SIGUSR1 => {
|
||||||
let tracer = match tracer_weak.upgrade() {
|
let Some(tracer) = tracer_weak.upgrade() else {
|
||||||
Some(tracer) => tracer,
|
break;
|
||||||
None => break,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipelines = {
|
let pipelines = {
|
||||||
|
|
|
@ -37,9 +37,8 @@ fn create_pipeline(uris: Vec<String>, iterations: u32) -> anyhow::Result<gst::Pi
|
||||||
|
|
||||||
let pipeline_weak = pipeline.downgrade();
|
let pipeline_weak = pipeline.downgrade();
|
||||||
playlist.connect_pad_added(move |_playlist, src_pad| {
|
playlist.connect_pad_added(move |_playlist, src_pad| {
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
let Some(pipeline) = pipeline_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(pipeline) => pipeline,
|
|
||||||
};
|
};
|
||||||
let pad_name = src_pad.name();
|
let pad_name = src_pad.name();
|
||||||
|
|
||||||
|
@ -66,9 +65,8 @@ fn create_pipeline(uris: Vec<String>, iterations: u32) -> anyhow::Result<gst::Pi
|
||||||
|
|
||||||
let pipeline_weak = pipeline.downgrade();
|
let pipeline_weak = pipeline.downgrade();
|
||||||
playlist.connect_pad_removed(move |_playlist, pad| {
|
playlist.connect_pad_removed(move |_playlist, pad| {
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
let Some(pipeline) = pipeline_weak.upgrade() else {
|
||||||
None => return,
|
return;
|
||||||
Some(pipeline) => pipeline,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// remove sink bin that was handling the pad
|
// remove sink bin that was handling the pad
|
||||||
|
|
|
@ -1078,9 +1078,8 @@ impl UriPlaylistBin {
|
||||||
);
|
);
|
||||||
|
|
||||||
src_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, move |pad, _info| {
|
src_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, move |pad, _info| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
Some(imp) => imp,
|
return gst::PadProbeReturn::Remove;
|
||||||
None => return gst::PadProbeReturn::Remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(parent) = pad.parent() {
|
if let Some(parent) = pad.parent() {
|
||||||
|
@ -1294,9 +1293,8 @@ impl UriPlaylistBin {
|
||||||
return gst::PadProbeReturn::Pass;
|
return gst::PadProbeReturn::Pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
let element = match element_weak.upgrade() {
|
let Some(element) = element_weak.upgrade() else {
|
||||||
Some(element) => element,
|
return gst::PadProbeReturn::Remove;
|
||||||
None => return gst::PadProbeReturn::Remove,
|
|
||||||
};
|
};
|
||||||
let imp = element.imp();
|
let imp = element.imp();
|
||||||
|
|
||||||
|
@ -1396,14 +1394,12 @@ impl UriPlaylistBin {
|
||||||
let item_weak = item.downgrade();
|
let item_weak = item.downgrade();
|
||||||
|
|
||||||
sink_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, move |pad, info| {
|
sink_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, move |pad, info| {
|
||||||
let element = match element_weak.upgrade() {
|
let Some(element) = element_weak.upgrade() else {
|
||||||
Some(element) => element,
|
return gst::PadProbeReturn::Remove;
|
||||||
None => return gst::PadProbeReturn::Remove,
|
|
||||||
};
|
};
|
||||||
let parent = pad.parent().unwrap();
|
let parent = pad.parent().unwrap();
|
||||||
let item = match Item::upgrade(&item_weak) {
|
let Some(item) = Item::upgrade(&item_weak) else {
|
||||||
Some(item) => item,
|
return gst::PadProbeReturn::Remove;
|
||||||
None => return gst::PadProbeReturn::Remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if !item.is_streaming() {
|
if !item.is_streaming() {
|
||||||
|
|
|
@ -110,9 +110,8 @@ fn test(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
let Some(pipeline) = pipeline_weak.upgrade() else {
|
||||||
Some(pipeline) => pipeline,
|
return;
|
||||||
None => return,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let sink = gst::ElementFactory::make("fakesink").build().unwrap();
|
let sink = gst::ElementFactory::make("fakesink").build().unwrap();
|
||||||
|
|
|
@ -290,9 +290,8 @@ impl TranscriberBin {
|
||||||
let comp_sinkpad = &state.cccombiner.static_pad("sink").unwrap();
|
let comp_sinkpad = &state.cccombiner.static_pad("sink").unwrap();
|
||||||
// Drop caption meta from video buffer if user preference is transcription
|
// Drop caption meta from video buffer if user preference is transcription
|
||||||
comp_sinkpad.add_probe(gst::PadProbeType::BUFFER, move |_, probe_info| {
|
comp_sinkpad.add_probe(gst::PadProbeType::BUFFER, move |_, probe_info| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return gst::PadProbeReturn::Remove,
|
return gst::PadProbeReturn::Remove;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let settings = imp.settings.lock().unwrap();
|
let settings = imp.settings.lock().unwrap();
|
||||||
|
@ -431,9 +430,8 @@ impl TranscriberBin {
|
||||||
| gst::PadProbeType::BUFFER
|
| gst::PadProbeType::BUFFER
|
||||||
| gst::PadProbeType::EVENT_DOWNSTREAM,
|
| gst::PadProbeType::EVENT_DOWNSTREAM,
|
||||||
move |_pad, _info| {
|
move |_pad, _info| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return gst::PadProbeReturn::Pass,
|
return gst::PadProbeReturn::Remove;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
imp.disable_transcription_bin();
|
imp.disable_transcription_bin();
|
||||||
|
@ -645,9 +643,8 @@ impl TranscriberBin {
|
||||||
| gst::PadProbeType::BUFFER
|
| gst::PadProbeType::BUFFER
|
||||||
| gst::PadProbeType::EVENT_DOWNSTREAM,
|
| gst::PadProbeType::EVENT_DOWNSTREAM,
|
||||||
move |_pad, _info| {
|
move |_pad, _info| {
|
||||||
let imp = match imp_weak.upgrade() {
|
let Some(imp) = imp_weak.upgrade() else {
|
||||||
None => return gst::PadProbeReturn::Remove,
|
return gst::PadProbeReturn::Remove;
|
||||||
Some(imp) => imp,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if imp.reconfigure_transcription_bin(lang_code_only).is_err() {
|
if imp.reconfigure_transcription_bin(lang_code_only).is_err() {
|
||||||
|
|
|
@ -75,9 +75,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let pipeline_weak = pipeline.downgrade();
|
let pipeline_weak = pipeline.downgrade();
|
||||||
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(500), move || {
|
let timeout_id = glib::timeout_add_local(std::time::Duration::from_millis(500), move || {
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
let Some(pipeline) = pipeline_weak.upgrade() else {
|
||||||
Some(pipeline) => pipeline,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = pipeline.query_position::<gst::ClockTime>();
|
let position = pipeline.query_position::<gst::ClockTime>();
|
||||||
|
@ -96,9 +95,8 @@ fn create_ui(app: >k::Application) {
|
||||||
.add_watch_local(move |_, msg| {
|
.add_watch_local(move |_, msg| {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
let app = match app_weak.upgrade() {
|
let Some(app) = app_weak.upgrade() else {
|
||||||
Some(app) => app,
|
return glib::ControlFlow::Break;
|
||||||
None => return glib::ControlFlow::Break,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
|
|
Loading…
Reference in a new issue