gstreamer: Remove deprecated APIs

They were deprecated in the previous release or even older releases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1352>
This commit is contained in:
Sebastian Dröge 2023-11-23 13:31:16 +02:00
parent c82ba6ffe0
commit 897c7dfd39
4 changed files with 14 additions and 177 deletions

View file

@ -49,19 +49,6 @@ impl Caps {
unsafe { from_glib_full(ffi::gst_caps_new_any()) }
}
#[doc(alias = "gst_caps_new_simple")]
#[deprecated = "Use `Caps::builder()` or `Caps::new_empty()`"]
#[allow(deprecated)]
pub fn new_simple(name: impl IntoGStr, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Self {
skip_assert_initialized!();
let mut caps = Caps::new_empty();
let structure = Structure::new(name, values);
caps.get_mut().unwrap().append_structure(structure);
caps
}
#[doc(alias = "gst_caps_new_empty_simple")]
pub fn new_empty_simple(name: impl IntoGStr) -> Self {
skip_assert_initialized!();
@ -316,6 +303,7 @@ impl std::iter::Extend<Caps> for CapsRef {
impl CapsRef {
#[doc(alias = "gst_caps_set_value")]
#[doc(alias = "gst_caps_set_simple")]
pub fn set(&mut self, name: impl IntoGStr, value: impl ToSendValue + Sync) {
let value = value.to_send_value();
self.set_value(name, value);
@ -330,22 +318,6 @@ impl CapsRef {
}
}
#[doc(alias = "gst_caps_set_simple")]
#[deprecated = "Use `CapsRef::set()`"]
pub fn set_simple(&mut self, values: &[(&str, &(dyn ToSendValue + Sync))]) {
for &(name, value) in values {
let value = value.to_value();
unsafe {
ffi::gst_caps_set_value(
self.as_mut_ptr(),
name.to_glib_none().0,
value.to_glib_none().0,
);
}
}
}
#[doc(alias = "get_structure")]
#[doc(alias = "gst_caps_get_structure")]
pub fn structure(&self, idx: u32) -> Option<&StructureRef> {
@ -1158,42 +1130,21 @@ mod tests {
use crate::{Array, Fraction};
#[test]
#[allow(deprecated)]
fn test_simple() {
fn test_builder() {
crate::init().unwrap();
let mut caps = Caps::new_simple(
"foo/bar",
&[
("int", &12),
("bool", &true),
("string", &"bla"),
("fraction", &Fraction::new(1, 2)),
("array", &Array::new([1, 2])),
],
);
let mut caps = Caps::builder("foo/bar")
.field("int", 12)
.field("bool", true)
.field("string", "bla")
.field("fraction", Fraction::new(1, 2))
.field("array", Array::new([1, 2]))
.build();
assert_eq!(
caps.to_string(),
"foo/bar, int=(int)12, bool=(boolean)true, string=(string)bla, fraction=(fraction)1/2, array=(int)< 1, 2 >"
);
{
let s = caps.structure(0).unwrap();
assert_eq!(
s,
Structure::new(
"foo/bar",
&[
("int", &12),
("bool", &true),
("string", &"bla"),
("fraction", &Fraction::new(1, 2)),
("array", &Array::new([1, 2])),
],
)
.as_ref()
);
}
assert!(caps
.features(0)
.unwrap()
@ -1207,23 +1158,6 @@ mod tests {
.features(0)
.unwrap()
.is_equal(CapsFeatures::new(["foo:bla"]).as_ref()));
}
#[test]
fn test_builder() {
crate::init().unwrap();
let caps = Caps::builder("foo/bar")
.field("int", 12)
.field("bool", true)
.field("string", "bla")
.field("fraction", Fraction::new(1, 2))
.field("array", Array::new([1, 2]))
.build();
assert_eq!(
caps.to_string(),
"foo/bar, int=(int)12, bool=(boolean)true, string=(string)bla, fraction=(fraction)1/2, array=(int)< 1, 2 >"
);
let caps = Caps::builder("foo/bar")
.field("int", 12)

View file

@ -11,37 +11,6 @@ use crate::{
};
impl ElementFactory {
#[doc(alias = "gst_element_factory_create_with_properties")]
#[track_caller]
#[deprecated = "Use create() instead"]
pub fn create_with_properties(
&self,
properties: &[(&str, &dyn ToValue)],
) -> Result<Element, glib::BoolError> {
let mut builder = self.create();
builder.properties = properties
.iter()
.map(|(name, value)| (*name, ValueOrStr::Value(value.to_value())))
.collect();
builder.build()
}
#[doc(alias = "gst_element_factory_make_with_properties")]
#[track_caller]
#[deprecated = "Use make() instead"]
pub fn make_with_properties(
factoryname: &str,
properties: &[(&str, &dyn ToValue)],
) -> Result<Element, glib::BoolError> {
skip_assert_initialized!();
let mut builder = Self::make(factoryname);
builder.properties = properties
.iter()
.map(|(name, value)| (*name, ValueOrStr::Value(value.to_value())))
.collect();
builder.build()
}
#[doc(alias = "gst_element_factory_create")]
#[doc(alias = "gst_element_factory_create_with_properties")]
#[track_caller]

View file

@ -48,27 +48,12 @@ impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecFraction {
}
impl ParamSpecFraction {
#[doc(alias = "gst_param_spec_fraction")]
pub fn builder(name: &str) -> ParamSpecFractionBuilder {
assert_initialized_main_thread!();
ParamSpecFractionBuilder::new(name)
}
#[deprecated = "Use builder() instead"]
#[allow(clippy::new_ret_no_self)]
#[doc(alias = "gst_param_spec_fraction")]
pub fn new<'a>(
name: &str,
nick: impl Into<Option<&'a str>>,
blurb: impl Into<Option<&'a str>>,
min: crate::Fraction,
max: crate::Fraction,
default: crate::Fraction,
flags: glib::ParamFlags,
) -> glib::ParamSpec {
assert_initialized_main_thread!();
unsafe { Self::new_unchecked(name, nick, blurb, min, max, default, flags) }
}
unsafe fn new_unchecked<'a>(
name: &str,
nick: impl Into<Option<&'a str>>,
@ -259,26 +244,12 @@ impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecArray {
}
impl ParamSpecArray {
#[doc(alias = "gst_param_spec_array")]
pub fn builder(name: &str) -> ParamSpecArrayBuilder {
assert_initialized_main_thread!();
ParamSpecArrayBuilder::new(name)
}
#[allow(clippy::new_ret_no_self)]
#[doc(alias = "gst_param_spec_array")]
#[deprecated = "Use builder() instead"]
pub fn new<'a>(
name: &str,
nick: impl Into<Option<&'a str>>,
blurb: impl Into<Option<&'a str>>,
element_spec: Option<&glib::ParamSpec>,
flags: glib::ParamFlags,
) -> glib::ParamSpec {
assert_initialized_main_thread!();
unsafe { Self::new_unchecked(name, nick, blurb, element_spec, flags) }
}
unsafe fn new_unchecked<'a>(
name: &str,
nick: impl Into<Option<&'a str>>,
@ -439,20 +410,9 @@ mod tests {
use super::*;
#[test]
#[allow(deprecated)]
fn test_trait() {
crate::init().unwrap();
let _pspec = ParamSpecFraction::new(
"foo",
"Foo",
"Foo Bar",
(0, 1).into(),
(100, 1).into(),
(1, 1).into(),
glib::ParamFlags::READWRITE,
);
let _pspec = ParamSpecFraction::builder("foo")
.nick("Foo")
.blurb("Foo Bar")

View file

@ -12,7 +12,7 @@ use std::{
use glib::{
prelude::*,
translate::*,
value::{FromValue, SendValue, ToSendValue},
value::{FromValue, SendValue},
IntoGStr,
};
@ -65,19 +65,6 @@ impl Structure {
}
}
#[doc(alias = "gst_structure_new")]
#[deprecated = "Use `Structure::builder()` or `Structure::new_empty()`"]
pub fn new(name: impl IntoGStr, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Structure {
skip_assert_initialized!();
let mut structure = Structure::new_empty(name);
for &(f, v) in values {
structure.set_value(f, v.to_send_value());
}
structure
}
#[allow(clippy::should_implement_trait)]
pub fn from_iter(
name: impl IntoGStr,
@ -1124,7 +1111,6 @@ mod tests {
use super::*;
#[test]
#[allow(deprecated)]
fn new_set_get() {
use glib::{value, Type};
@ -1176,24 +1162,12 @@ mod tests {
assert_eq!(v[2].0, "f3");
assert_eq!(v[2].1.get::<i32>(), Ok(123i32));
let s2 = Structure::new("test", &[("f1", &"abc"), ("f2", &"bcd"), ("f3", &123i32)]);
assert_eq!(s, s2);
}
#[test]
fn test_builder() {
crate::init().unwrap();
let s = Structure::builder("test")
let s2 = Structure::builder("test")
.field("f1", "abc")
.field("f2", String::from("bcd"))
.field("f3", 123i32)
.build();
assert_eq!(s.name(), "test");
assert_eq!(s.get::<&str>("f1"), Ok("abc"));
assert_eq!(s.get::<&str>("f2"), Ok("bcd"));
assert_eq!(s.get::<i32>("f3"), Ok(123i32));
assert_eq!(s, s2);
}
#[test]