From 8cc018c1642eb754b3e5bb3d9685296910160545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 24 Oct 2021 18:45:38 +0300 Subject: [PATCH] examples: Move to the new, simplified encoding profile API --- examples/src/bin/encodebin.rs | 35 +++++++++++++++++------------------ examples/src/bin/ges.rs | 27 ++++++++++++--------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index 651d99ddc..55325d2c5 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -48,38 +48,37 @@ struct ErrorMessage { #[gboxed(type_name = "ErrorValue")] struct ErrorValue(Arc>>); -fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> { +fn configure_encodebin(encodebin: &gst::Element) { // To tell the encodebin what we want it to produce, we create an EncodingProfile // https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/GstEncodingProfile.html // This profile consists of information about the contained audio and video formats // as well as the container format we want everything to be combined into. // Every audiostream piped into the encodebin should be encoded using vorbis. - let audio_profile = gst_pbutils::EncodingAudioProfileBuilder::new() - .format(&gst::Caps::new_simple("audio/x-vorbis", &[])) - .presence(0) - .build()?; + let audio_profile = + gst_pbutils::EncodingAudioProfile::builder(&gst::Caps::builder("audio/x-vorbis").build()) + .presence(0) + .build(); // Every videostream piped into the encodebin should be encoded using theora. - let video_profile = gst_pbutils::EncodingVideoProfileBuilder::new() - .format(&gst::Caps::new_simple("video/x-theora", &[])) - .presence(0) - .build()?; + let video_profile = + gst_pbutils::EncodingVideoProfile::builder(&gst::Caps::builder("video/x-theora").build()) + .presence(0) + .build(); // All streams are then finally combined into a matroska container. - let container_profile = gst_pbutils::EncodingContainerProfileBuilder::new() - .name("container") - .format(&gst::Caps::new_simple("video/x-matroska", &[])) - .add_profile(&(video_profile)) - .add_profile(&(audio_profile)) - .build()?; + let container_profile = gst_pbutils::EncodingContainerProfile::builder( + &gst::Caps::builder("video/x-matroska").build(), + ) + .name("container") + .add_profile(&(video_profile)) + .add_profile(&(audio_profile)) + .build(); // Finally, apply the EncodingProfile onto our encodebin element. encodebin .set_property("profile", &container_profile) .expect("set profile property failed"); - - Ok(()) } fn example_main() -> Result<(), Error> { @@ -112,7 +111,7 @@ fn example_main() -> Result<(), Error> { // Configure the encodebin. // Here we tell the bin what format we expect it to create at its output. - configure_encodebin(&encodebin)?; + configure_encodebin(&encodebin); pipeline .add_many(&[&src, &encodebin, &sink]) diff --git a/examples/src/bin/ges.rs b/examples/src/bin/ges.rs index 3dd9a04b3..8db3ae7fe 100644 --- a/examples/src/bin/ges.rs +++ b/examples/src/bin/ges.rs @@ -47,25 +47,22 @@ mod examples_common; fn configure_pipeline(pipeline: &ges::Pipeline, output_name: &str) { // Every audiostream piped into the encodebin should be encoded using opus. - let audio_profile = gst_pbutils::EncodingAudioProfileBuilder::new() - .format(&gst::Caps::new_simple("audio/x-opus", &[])) - .build() - .expect("Failed to create audio profile"); + let audio_profile = + gst_pbutils::EncodingAudioProfile::builder(&gst::Caps::builder("audio/x-opus").build()) + .build(); // Every videostream piped into the encodebin should be encoded using vp8. - let video_profile = gst_pbutils::EncodingVideoProfileBuilder::new() - .format(&gst::Caps::new_simple("video/x-vp8", &[])) - .build() - .expect("Failed to create video profile"); + let video_profile = + gst_pbutils::EncodingVideoProfile::builder(&gst::Caps::builder("video/x-vp8").build()) + .build(); // All streams are then finally combined into a webm container. - let container_profile = gst_pbutils::EncodingContainerProfileBuilder::new() - .name("container") - .format(&gst::Caps::new_simple("video/webm", &[])) - .add_profile(&video_profile) - .add_profile(&audio_profile) - .build() - .expect("Failed to create container profile"); + let container_profile = + gst_pbutils::EncodingContainerProfile::builder(&gst::Caps::builder("video/webm").build()) + .name("container") + .add_profile(&video_profile) + .add_profile(&audio_profile) + .build(); // Apply the EncodingProfile to the pipeline, and set it to render mode let output_uri = format!("{}.webm", output_name);