From 8618085d46f44c09f9366066d99bc70221db038d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 Apr 2019 18:17:42 +0300 Subject: [PATCH] Port examples/tutorials to the explicit Option parameter changes --- examples/src/bin/appsink.rs | 4 ++-- examples/src/bin/appsrc.rs | 2 +- examples/src/bin/glupload.rs | 2 +- examples/src/bin/rtsp-server-record.rs | 4 ++-- tutorials/src/bin/basic-tutorial-2.rs | 8 +++---- tutorials/src/bin/basic-tutorial-3.rs | 10 ++++---- tutorials/src/bin/basic-tutorial-4.rs | 4 ++-- tutorials/src/bin/basic-tutorial-6.rs | 6 ++--- tutorials/src/bin/basic-tutorial-7.rs | 23 +++++++++--------- tutorials/src/bin/basic-tutorial-8.rs | 33 +++++++++++++------------- 10 files changed, 49 insertions(+), 47 deletions(-) diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index 31bc70ebd..26c321fe9 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -70,7 +70,7 @@ fn create_pipeline() -> Result { // provide the format we request. // This can be set after linking the two objects, because format negotiation between // both elements will happen during pre-rolling of the pipeline. - appsink.set_caps(&gst::Caps::new_simple( + appsink.set_caps(Some(&gst::Caps::new_simple( "audio/x-raw", &[ ("format", &gst_audio::AUDIO_FORMAT_S16.to_string()), @@ -78,7 +78,7 @@ fn create_pipeline() -> Result { ("channels", &(1i32)), ("rate", &gst::IntRange::::new(1, i32::MAX)), ], - )); + ))); // Getting data out of the appsink is done by setting callbacks on it. // The appsink will then call those handlers, as soon as data is available. diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index 12223f904..5f64a3b6d 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -73,7 +73,7 @@ fn create_pipeline() -> Result { .build() .expect("Failed to create video info"); - appsrc.set_caps(&video_info.to_caps().unwrap()); + appsrc.set_caps(Some(&video_info.to_caps().unwrap())); appsrc.set_property_format(gst::Format::Time); // Our frame counter, that is stored in the mutable environment diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index cfc3071a8..118d694bb 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -558,7 +558,7 @@ impl App { .field("format", &gst_video::VideoFormat::Rgba.to_string()) .field("texture-target", &"2D") .build(); - appsink.set_caps(&caps); + appsink.set_caps(Some(&caps)); // get the glupload element to extract later the used context in it let mut iter = sink.dynamic_cast::().unwrap().iterate_elements(); diff --git a/examples/src/bin/rtsp-server-record.rs b/examples/src/bin/rtsp-server-record.rs index 92f2d575d..9035b8a40 100644 --- a/examples/src/bin/rtsp-server-record.rs +++ b/examples/src/bin/rtsp-server-record.rs @@ -106,11 +106,11 @@ fn main_loop() -> Result<(), Error> { ); } - auth.set_tls_certificate(&cert); + auth.set_tls_certificate(Some(&cert)); auth.add_basic(basic.as_str(), &token); // Here, we tell the RTSP server about the authentication method we // configured above. - server.set_auth(&auth); + server.set_auth(Some(&auth)); factory.set_launch(args[1].as_str()); // Tell the RTSP server that we want to work in RECORD mode (clients send) diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index 52af6b656..44c1df23e 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -9,13 +9,13 @@ fn tutorial_main() { gst::init().unwrap(); // Create the elements - let source = gst::ElementFactory::make("videotestsrc", "source") + let source = gst::ElementFactory::make("videotestsrc", Some("source")) .expect("Could not create source element."); - let sink = - gst::ElementFactory::make("autovideosink", "sink").expect("Could not create sink element"); + let sink = gst::ElementFactory::make("autovideosink", Some("sink")) + .expect("Could not create sink element"); // Create the empty pipeline - let pipeline = gst::Pipeline::new("test-pipeline"); + let pipeline = gst::Pipeline::new(Some("test-pipeline")); // Build the pipeline pipeline.add_many(&[&source, &sink]).unwrap(); diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index 756ff8bfa..db692502f 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -9,15 +9,15 @@ fn tutorial_main() { gst::init().unwrap(); // Create the elements - let source = gst::ElementFactory::make("uridecodebin", "source") + let source = gst::ElementFactory::make("uridecodebin", Some("source")) .expect("Could not create uridecodebin element."); - let convert = gst::ElementFactory::make("audioconvert", "convert") + let convert = gst::ElementFactory::make("audioconvert", Some("convert")) .expect("Could not create convert element."); - let sink = - gst::ElementFactory::make("autoaudiosink", "sink").expect("Could not create sink element."); + let sink = gst::ElementFactory::make("autoaudiosink", Some("sink")) + .expect("Could not create sink element."); // Create the empty pipeline - let pipeline = gst::Pipeline::new("test-pipeline"); + let pipeline = gst::Pipeline::new(Some("test-pipeline")); // Build the pipeline Note that we are NOT linking the source at this // point. We will do it later. diff --git a/tutorials/src/bin/basic-tutorial-4.rs b/tutorials/src/bin/basic-tutorial-4.rs index c42d58ff1..cd194bfd9 100644 --- a/tutorials/src/bin/basic-tutorial-4.rs +++ b/tutorials/src/bin/basic-tutorial-4.rs @@ -21,8 +21,8 @@ fn tutorial_main() { gst::init().unwrap(); // Creat the playbin element - let playbin = - gst::ElementFactory::make("playbin", "playbin").expect("Failed to create playbin element"); + let playbin = gst::ElementFactory::make("playbin", Some("playbin")) + .expect("Failed to create playbin element"); // Set the URI to play let uri = diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index 3d014f5dc..c0dced96b 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -94,14 +94,14 @@ fn tutorial_main() { // Ask the factories to instantiate actual elements let source = source_factory - .create("source") + .create(Some("source")) .expect("Failed to create source element"); let sink = sink_factory - .create("sink") + .create(Some("sink")) .expect("Failed to create sink element"); // Create the empty pipeline - let pipeline = gst::Pipeline::new("test-pipeline"); + let pipeline = gst::Pipeline::new(Some("test-pipeline")); pipeline.add_many(&[&source, &sink]).unwrap(); source.link(&sink).expect("Elements could not be linked."); diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index b6fa43512..5e9ede154 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -11,18 +11,19 @@ fn tutorial_main() { return; } - let audio_source = gst::ElementFactory::make("audiotestsrc", "audio_source").unwrap(); - let tee = gst::ElementFactory::make("tee", "tee").unwrap(); - let audio_queue = gst::ElementFactory::make("queue", "audio_queue").unwrap(); - let audio_convert = gst::ElementFactory::make("audioconvert", "audio_convert").unwrap(); - let audio_resample = gst::ElementFactory::make("audioresample", "audio_resample").unwrap(); - let audio_sink = gst::ElementFactory::make("autoaudiosink", "audio_sink").unwrap(); - let video_queue = gst::ElementFactory::make("queue", "video_queue").unwrap(); - let visual = gst::ElementFactory::make("wavescope", "visual").unwrap(); - let video_convert = gst::ElementFactory::make("videoconvert", "video_convert").unwrap(); - let video_sink = gst::ElementFactory::make("autovideosink", "video_sink").unwrap(); + let audio_source = gst::ElementFactory::make("audiotestsrc", Some("audio_source")).unwrap(); + let tee = gst::ElementFactory::make("tee", Some("tee")).unwrap(); + let audio_queue = gst::ElementFactory::make("queue", Some("audio_queue")).unwrap(); + let audio_convert = gst::ElementFactory::make("audioconvert", Some("audio_convert")).unwrap(); + let audio_resample = + gst::ElementFactory::make("audioresample", Some("audio_resample")).unwrap(); + let audio_sink = gst::ElementFactory::make("autoaudiosink", Some("audio_sink")).unwrap(); + let video_queue = gst::ElementFactory::make("queue", Some("video_queue")).unwrap(); + let visual = gst::ElementFactory::make("wavescope", Some("visual")).unwrap(); + let video_convert = gst::ElementFactory::make("videoconvert", Some("video_convert")).unwrap(); + let video_sink = gst::ElementFactory::make("autovideosink", Some("video_sink")).unwrap(); - let pipeline = gst::Pipeline::new("test-pipeline"); + let pipeline = gst::Pipeline::new(Some("test-pipeline")); audio_source.set_property("freq", &215.0).unwrap(); visual.set_property_from_str("shader", "none"); diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index dfb782fd7..030f574f9 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -52,21 +52,22 @@ fn main() { return; } - let appsrc = gst::ElementFactory::make("appsrc", "audio_source").unwrap(); - let tee = gst::ElementFactory::make("tee", "tee").unwrap(); - let audio_queue = gst::ElementFactory::make("queue", "audio_queue").unwrap(); - let audio_convert1 = gst::ElementFactory::make("audioconvert", "audio_convert1").unwrap(); - let audio_resample = gst::ElementFactory::make("audioresample", "audio_resample").unwrap(); - let audio_sink = gst::ElementFactory::make("autoaudiosink", "audio_sink").unwrap(); - let video_queue = gst::ElementFactory::make("queue", "video_queue").unwrap(); - let audio_convert2 = gst::ElementFactory::make("audioconvert", "audio_convert2").unwrap(); - let visual = gst::ElementFactory::make("wavescope", "visual").unwrap(); - let video_convert = gst::ElementFactory::make("videoconvert", "video_convert").unwrap(); - let video_sink = gst::ElementFactory::make("autovideosink", "video_sink").unwrap(); - let app_queue = gst::ElementFactory::make("queue", "app_queue").unwrap(); - let appsink = gst::ElementFactory::make("appsink", "app_sink").unwrap(); + let appsrc = gst::ElementFactory::make("appsrc", Some("audio_source")).unwrap(); + let tee = gst::ElementFactory::make("tee", Some("tee")).unwrap(); + let audio_queue = gst::ElementFactory::make("queue", Some("audio_queue")).unwrap(); + let audio_convert1 = gst::ElementFactory::make("audioconvert", Some("audio_convert1")).unwrap(); + let audio_resample = + gst::ElementFactory::make("audioresample", Some("audio_resample")).unwrap(); + let audio_sink = gst::ElementFactory::make("autoaudiosink", Some("audio_sink")).unwrap(); + let video_queue = gst::ElementFactory::make("queue", Some("video_queue")).unwrap(); + let audio_convert2 = gst::ElementFactory::make("audioconvert", Some("audio_convert2")).unwrap(); + let visual = gst::ElementFactory::make("wavescope", Some("visual")).unwrap(); + let video_convert = gst::ElementFactory::make("videoconvert", Some("video_convert")).unwrap(); + let video_sink = gst::ElementFactory::make("autovideosink", Some("video_sink")).unwrap(); + let app_queue = gst::ElementFactory::make("queue", Some("app_queue")).unwrap(); + let appsink = gst::ElementFactory::make("appsink", Some("app_sink")).unwrap(); - let pipeline = gst::Pipeline::new("test-pipeline"); + let pipeline = gst::Pipeline::new(Some("test-pipeline")); visual.set_property_from_str("shader", "none"); visual.set_property_from_str("style", "lines"); @@ -130,7 +131,7 @@ fn main() { let appsrc = appsrc .dynamic_cast::() .expect("Source element is expected to be an appsrc!"); - appsrc.set_caps(&audio_caps); + appsrc.set_caps(Some(&audio_caps)); appsrc.set_property_format(gst::Format::Time); let appsink = appsink @@ -216,7 +217,7 @@ fn main() { // configure appsink appsink.set_emit_signals(true); - appsink.set_caps(&audio_caps); + appsink.set_caps(Some(&audio_caps)); let data_weak = Arc::downgrade(&data); appsink.connect_new_sample(move |_| {