From ccfb8246be63fac8316d99e8c79da3d1d3195be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 18 Dec 2019 07:50:10 +0200 Subject: [PATCH] Fix compilation after gstreamer-rs!383 --- gst-plugin-audiofx/src/audioecho.rs | 2 +- gst-plugin-cdg/src/cdgdec.rs | 4 ++-- gst-plugin-cdg/src/cdgparse.rs | 4 ++-- gst-plugin-cdg/tests/cdgdec.rs | 4 ++-- gst-plugin-closedcaption/src/mcc_enc.rs | 2 +- gst-plugin-closedcaption/src/scc_enc.rs | 2 +- gst-plugin-closedcaption/tests/mcc_parse.rs | 6 +++--- .../examples/gtk_fallbackswitch.rs | 3 ++- gst-plugin-file/src/filesink.rs | 2 +- gst-plugin-file/src/filesrc.rs | 2 +- gst-plugin-lewton/src/lewtondec.rs | 12 ++++++------ gst-plugin-rav1e/src/rav1enc.rs | 2 +- gst-plugin-rusoto/src/s3sink.rs | 2 +- gst-plugin-sodium/src/decrypter.rs | 4 ++-- gst-plugin-sodium/tests/decrypter.rs | 2 +- gst-plugin-sodium/tests/encrypter.rs | 2 +- gst-plugin-threadshare/examples/benchmark.rs | 3 ++- gst-plugin-togglerecord/examples/gtk_recording.rs | 5 +++-- gst-plugin-togglerecord/tests/tests.rs | 2 +- gst-plugin-tutorial/src/rgb2gray.rs | 9 +++++---- 20 files changed, 39 insertions(+), 35 deletions(-) diff --git a/gst-plugin-audiofx/src/audioecho.rs b/gst-plugin-audiofx/src/audioecho.rs index 488191e2..0fec1538 100644 --- a/gst-plugin-audiofx/src/audioecho.rs +++ b/gst-plugin-audiofx/src/audioecho.rs @@ -265,7 +265,7 @@ impl BaseTransformImpl for AudioEcho { let mut state_guard = self.state.lock().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::NotNegotiated)?; - let mut map = buf.map_writable().ok_or(gst::FlowError::Error)?; + let mut map = buf.map_writable().map_err(|_| gst::FlowError::Error)?; match state.info.format() { gst_audio::AUDIO_FORMAT_F64 => { diff --git a/gst-plugin-cdg/src/cdgdec.rs b/gst-plugin-cdg/src/cdgdec.rs index 48e760c3..f62550f7 100644 --- a/gst-plugin-cdg/src/cdgdec.rs +++ b/gst-plugin-cdg/src/cdgdec.rs @@ -123,7 +123,7 @@ impl VideoDecoderImpl for CdgDec { let cmd = { let input = frame.get_input_buffer().unwrap(); - let map = input.map_readable().ok_or_else(|| { + let map = input.map_readable().map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, @@ -155,7 +155,7 @@ impl VideoDecoderImpl for CdgDec { let mut out_frame = gst_video::VideoFrameRef::from_buffer_ref_writable(output, info.as_ref().unwrap()) - .ok_or_else(|| { + .map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, diff --git a/gst-plugin-cdg/src/cdgparse.rs b/gst-plugin-cdg/src/cdgparse.rs index 13e12b1a..9242627c 100644 --- a/gst-plugin-cdg/src/cdgparse.rs +++ b/gst-plugin-cdg/src/cdgparse.rs @@ -152,7 +152,7 @@ impl BaseParseImpl for CdgParse { // Scan for CDG instruction let input = frame.get_buffer().unwrap(); let skip = { - let map = input.map_readable().ok_or_else(|| { + let map = input.map_readable().map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, @@ -176,7 +176,7 @@ impl BaseParseImpl for CdgParse { } let (keyframe, header) = { - let map = input.map_readable().ok_or_else(|| { + let map = input.map_readable().map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, diff --git a/gst-plugin-cdg/tests/cdgdec.rs b/gst-plugin-cdg/tests/cdgdec.rs index f192f9d9..c9a6b134 100644 --- a/gst-plugin-cdg/tests/cdgdec.rs +++ b/gst-plugin-cdg/tests/cdgdec.rs @@ -65,9 +65,9 @@ fn test_cdgdec() { // Add a handler to the "new-sample" signal. .new_sample(move |appsink| { // Pull the sample in question out of the appsink's buffer. - let sample = appsink.pull_sample().ok_or(gst::FlowError::Eos)?; + let sample = appsink.pull_sample().map_err(|_| gst::FlowError::Eos)?; let buffer = sample.get_buffer().ok_or(gst::FlowError::Error)?; - let map = buffer.map_readable().ok_or(gst::FlowError::Error)?; + let map = buffer.map_readable().map_err(|_| gst::FlowError::Error)?; // First frame fully blue map.as_slice() diff --git a/gst-plugin-closedcaption/src/mcc_enc.rs b/gst-plugin-closedcaption/src/mcc_enc.rs index 304b3c29..82fd0f6e 100644 --- a/gst-plugin-closedcaption/src/mcc_enc.rs +++ b/gst-plugin-closedcaption/src/mcc_enc.rs @@ -345,7 +345,7 @@ impl MccEnc { let _ = write!(outbuf, "{}\t", meta.get_tc()); - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { gst_element_error!( element, gst::StreamError::Format, diff --git a/gst-plugin-closedcaption/src/scc_enc.rs b/gst-plugin-closedcaption/src/scc_enc.rs index 0d5bf98e..ee0172f4 100644 --- a/gst-plugin-closedcaption/src/scc_enc.rs +++ b/gst-plugin-closedcaption/src/scc_enc.rs @@ -158,7 +158,7 @@ impl State { let first_buf = self.internal_buffer.first().unwrap(); for buffer in self.internal_buffer.iter() { - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { gst_element_error!( element, gst::StreamError::Format, diff --git a/gst-plugin-closedcaption/tests/mcc_parse.rs b/gst-plugin-closedcaption/tests/mcc_parse.rs index 50c51d91..82b47aaf 100644 --- a/gst-plugin-closedcaption/tests/mcc_parse.rs +++ b/gst-plugin-closedcaption/tests/mcc_parse.rs @@ -148,7 +148,7 @@ fn test_pull() { while h.events_in_queue() != 0 { let event = h.pull_event(); - if let Some(event) = event { + if let Ok(event) = event { match event.view() { EventView::Eos(_) => { done = true; @@ -185,7 +185,7 @@ fn test_pull() { let mut done = false; while h.buffers_in_queue() != 0 { - if let Some(buffer) = h.pull() { + if let Ok(buffer) = h.pull() { let pts = buffer.get_pts(); assert!(pts > gst::SECOND && pts < 2 * gst::SECOND); } @@ -194,7 +194,7 @@ fn test_pull() { while h.events_in_queue() != 0 { let event = h.pull_event(); - if let Some(event) = event { + if let Ok(event) = event { match event.view() { EventView::Eos(_) => { done = true; diff --git a/gst-plugin-fallbackswitch/examples/gtk_fallbackswitch.rs b/gst-plugin-fallbackswitch/examples/gtk_fallbackswitch.rs index 73bb27b5..21bc8925 100644 --- a/gst-plugin-fallbackswitch/examples/gtk_fallbackswitch.rs +++ b/gst-plugin-fallbackswitch/examples/gtk_fallbackswitch.rs @@ -204,7 +204,8 @@ fn create_ui(app: >k::Application) { }; glib::Continue(true) - }); + }) + .expect("Failed to add bus watch"); pipeline.set_state(gst::State::Playing).unwrap(); diff --git a/gst-plugin-file/src/filesink.rs b/gst-plugin-file/src/filesink.rs index 01add296..ee912ec1 100644 --- a/gst-plugin-file/src/filesink.rs +++ b/gst-plugin-file/src/filesink.rs @@ -274,7 +274,7 @@ impl BaseSinkImpl for FileSink { }; gst_trace!(CAT, obj: element, "Rendering {:?}", buffer); - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { gst_element_error!(element, gst::CoreError::Failed, ["Failed to map buffer"]); gst::FlowError::Error })?; diff --git a/gst-plugin-file/src/filesrc.rs b/gst-plugin-file/src/filesrc.rs index d7ece2ef..7d7b9f55 100644 --- a/gst-plugin-file/src/filesrc.rs +++ b/gst-plugin-file/src/filesrc.rs @@ -325,7 +325,7 @@ impl BaseSrcImpl for FileSrc { } let size = { - let mut map = buffer.map_writable().ok_or_else(|| { + let mut map = buffer.map_writable().map_err(|_| { gst_element_error!(element, gst::LibraryError::Failed, ["Failed to map buffer"]); gst::FlowError::Error })?; diff --git a/gst-plugin-lewton/src/lewtondec.rs b/gst-plugin-lewton/src/lewtondec.rs index ad011ec3..473a43f0 100644 --- a/gst-plugin-lewton/src/lewtondec.rs +++ b/gst-plugin-lewton/src/lewtondec.rs @@ -186,7 +186,7 @@ impl AudioDecoderImpl for LewtonDec { Some(inbuf) => inbuf, }; - let inmap = inbuf.map_readable().ok_or_else(|| { + let inmap = inbuf.map_readable().map_err(|_| { gst_error!(CAT, obj: element, "Failed to buffer readable"); gst::FlowError::Error })?; @@ -277,7 +277,7 @@ impl LewtonDec { }; // First try to parse the headers - let ident_map = ident_buf.map_readable().ok_or_else(|| { + let ident_map = ident_buf.map_readable().map_err(|_| { gst_error!(CAT, obj: element, "Failed to map ident buffer readable"); gst::FlowError::Error })?; @@ -290,7 +290,7 @@ impl LewtonDec { gst::FlowError::Error })?; - let comment_map = comment_buf.map_readable().ok_or_else(|| { + let comment_map = comment_buf.map_readable().map_err(|_| { gst_error!(CAT, obj: element, "Failed to map comment buffer readable"); gst::FlowError::Error })?; @@ -303,7 +303,7 @@ impl LewtonDec { gst::FlowError::Error })?; - let setup_map = setup_buf.map_readable().ok_or_else(|| { + let setup_map = setup_buf.map_readable().map_err(|_| { gst_error!(CAT, obj: element, "Failed to map setup buffer readable"); gst::FlowError::Error })?; @@ -420,7 +420,7 @@ impl LewtonDec { let mut outbuf = element .allocate_output_buffer(sample_count as usize * audio_info.bpf() as usize) - .ok_or_else(|| { + .map_err(|_| { gst_element_error!( element, gst::StreamError::Decode, @@ -433,7 +433,7 @@ impl LewtonDec { // while reordering the channels to the GStreamer channel order { let outbuf = outbuf.get_mut().unwrap(); - let mut outmap = outbuf.map_writable().ok_or_else(|| { + let mut outmap = outbuf.map_writable().map_err(|_| { gst_element_error!( element, gst::StreamError::Decode, diff --git a/gst-plugin-rav1e/src/rav1enc.rs b/gst-plugin-rav1e/src/rav1enc.rs index 14bd0d37..7c8b99cd 100644 --- a/gst-plugin-rav1e/src/rav1enc.rs +++ b/gst-plugin-rav1e/src/rav1enc.rs @@ -692,7 +692,7 @@ impl VideoEncoderImpl for Rav1Enc { let in_frame = gst_video::VideoFrameRef::from_buffer_ref_readable(&*input_buffer, &state.video_info) - .ok_or_else(|| { + .map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, diff --git a/gst-plugin-rusoto/src/s3sink.rs b/gst-plugin-rusoto/src/s3sink.rs index f52902a3..89d7b79c 100644 --- a/gst-plugin-rusoto/src/s3sink.rs +++ b/gst-plugin-rusoto/src/s3sink.rs @@ -507,7 +507,7 @@ impl BaseSinkImpl for S3Sink { } gst_trace!(CAT, obj: element, "Rendering {:?}", buffer); - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { gst_element_error!(element, gst::CoreError::Failed, ["Failed to map buffer"]); gst::FlowError::Error })?; diff --git a/gst-plugin-sodium/src/decrypter.rs b/gst-plugin-sodium/src/decrypter.rs index 3859d723..593e1727 100644 --- a/gst-plugin-sodium/src/decrypter.rs +++ b/gst-plugin-sodium/src/decrypter.rs @@ -128,7 +128,7 @@ impl State { buffer: &gst::Buffer, chunk_index: u64, ) -> Result { - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { gst_element_error!( element, gst::StreamError::Format, @@ -406,7 +406,7 @@ impl Decrypter { return Err(err); } - let map = buffer.map_readable().ok_or_else(|| { + let map = buffer.map_readable().map_err(|_| { let err = gst_loggable_error!(CAT, "Failed to map buffer readable"); err.log_with_object(element); err diff --git a/gst-plugin-sodium/tests/decrypter.rs b/gst-plugin-sodium/tests/decrypter.rs index f18456ae..6b9809e8 100644 --- a/gst-plugin-sodium/tests/decrypter.rs +++ b/gst-plugin-sodium/tests/decrypter.rs @@ -109,7 +109,7 @@ fn test_pipeline() { // Add a handler to the "new-sample" signal. .new_sample(move |appsink| { // Pull the sample in question out of the appsink's buffer. - let sample = appsink.pull_sample().ok_or(gst::FlowError::Eos)?; + let sample = appsink.pull_sample().map_err(|_| gst::FlowError::Eos)?; let buffer = sample.get_buffer().ok_or(gst::FlowError::Error)?; let mut adapter = adapter_clone.lock().unwrap(); diff --git a/gst-plugin-sodium/tests/encrypter.rs b/gst-plugin-sodium/tests/encrypter.rs index 5afc6ad1..e2f6dc83 100644 --- a/gst-plugin-sodium/tests/encrypter.rs +++ b/gst-plugin-sodium/tests/encrypter.rs @@ -94,7 +94,7 @@ fn encrypt_file() { h.push_event(gst::Event::new_eos().build()); println!("Pulling buffer..."); - while let Some(buf) = h.pull() { + while let Ok(buf) = h.pull() { adapter.push(buf); if adapter.available() >= expected_output.len() { break; diff --git a/gst-plugin-threadshare/examples/benchmark.rs b/gst-plugin-threadshare/examples/benchmark.rs index fd677a47..ac43d89b 100644 --- a/gst-plugin-threadshare/examples/benchmark.rs +++ b/gst-plugin-threadshare/examples/benchmark.rs @@ -162,7 +162,8 @@ fn main() { }; glib::Continue(true) - }); + }) + .expect("Failed to add bus watch"); pipeline.set_state(gst::State::Playing).unwrap(); diff --git a/gst-plugin-togglerecord/examples/gtk_recording.rs b/gst-plugin-togglerecord/examples/gtk_recording.rs index c77b4a51..8f0bc0bb 100644 --- a/gst-plugin-togglerecord/examples/gtk_recording.rs +++ b/gst-plugin-togglerecord/examples/gtk_recording.rs @@ -57,7 +57,7 @@ fn create_pipeline() -> ( let video_convert2 = gst::ElementFactory::make("videoconvert", None).unwrap(); let (video_sink, video_widget) = - if let Some(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) { + if let Ok(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) { let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap(); glsinkbin.set_property("sink", >kglsink).unwrap(); @@ -325,7 +325,8 @@ fn create_ui(app: >k::Application) { }; glib::Continue(true) - }); + }) + .expect("Failed to add bus watch"); pipeline.set_state(gst::State::Playing).unwrap(); diff --git a/gst-plugin-togglerecord/tests/tests.rs b/gst-plugin-togglerecord/tests/tests.rs index bd50d93a..84219616 100644 --- a/gst-plugin-togglerecord/tests/tests.rs +++ b/gst-plugin-togglerecord/tests/tests.rs @@ -253,7 +253,7 @@ fn recv_buffers( #[test] fn test_create() { init(); - assert!(gst::ElementFactory::make("togglerecord", None).is_some()); + assert!(gst::ElementFactory::make("togglerecord", None).is_ok()); } #[test] diff --git a/gst-plugin-tutorial/src/rgb2gray.rs b/gst-plugin-tutorial/src/rgb2gray.rs index 3ec9dbf1..0dd6df5c 100644 --- a/gst-plugin-tutorial/src/rgb2gray.rs +++ b/gst-plugin-tutorial/src/rgb2gray.rs @@ -445,7 +445,7 @@ impl BaseTransformImpl for Rgb2Gray { // info that is passed here let in_frame = gst_video::VideoFrameRef::from_buffer_ref_readable(inbuf.as_ref(), &state.in_info) - .ok_or_else(|| { + .map_err(|_| { gst_element_error!( element, gst::CoreError::Failed, @@ -456,15 +456,16 @@ impl BaseTransformImpl for Rgb2Gray { // And now map the output buffer writable, so we can fill it. let mut out_frame = - gst_video::VideoFrameRef::from_buffer_ref_writable(outbuf, &state.out_info) - .ok_or_else(|| { + gst_video::VideoFrameRef::from_buffer_ref_writable(outbuf, &state.out_info).map_err( + |_| { gst_element_error!( element, gst::CoreError::Failed, ["Failed to map output buffer writable"] ); gst::FlowError::Error - })?; + }, + )?; // Keep the various metadata we need for working with the video frames in // local variables. This saves some typing below.