forked from mirrors/gstreamer-rs
gstreamer: Update for glib::Type API changes
This commit is contained in:
parent
cc6a51e73d
commit
a316d610eb
9 changed files with 41 additions and 66 deletions
|
@ -95,7 +95,7 @@ mod custom_meta {
|
|||
[ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _,
|
||||
));
|
||||
|
||||
assert_ne!(t, glib::Type::Invalid);
|
||||
assert_ne!(t, glib::Type::INVALID);
|
||||
|
||||
t
|
||||
});
|
||||
|
|
|
@ -727,7 +727,7 @@ macro_rules! define_meta_iter(
|
|||
|
||||
if meta.is_null() {
|
||||
return None;
|
||||
} else if self.meta_api == glib::Type::Invalid || glib::Type::from_glib((*(*meta).info).api) == self.meta_api {
|
||||
} else if self.meta_api == glib::Type::INVALID || glib::Type::from_glib((*(*meta).info).api) == self.meta_api {
|
||||
// FIXME: Workaround for a lifetime issue with the mutable iterator only
|
||||
let buffer = $prepare_buffer(self.buffer.as_mut_ptr());
|
||||
let item = $from_ptr(buffer, meta);
|
||||
|
|
|
@ -139,7 +139,7 @@ where
|
|||
let func_ptr = &mut func as *mut F as gpointer;
|
||||
|
||||
let mut accum = Some(init);
|
||||
let mut ret = glib::Value::from_type(glib::Type::Pointer);
|
||||
let mut ret = glib::Value::from_type(glib::Type::POINTER);
|
||||
glib::gobject_ffi::g_value_set_pointer(
|
||||
ret.to_glib_none_mut().0,
|
||||
&mut accum as *mut _ as gpointer,
|
||||
|
@ -357,7 +357,7 @@ unsafe extern "C" fn filter_boxed_get_type<T: StaticType + 'static>() -> glib::f
|
|||
let mut types = TYPES.lock().unwrap();
|
||||
let type_name = T::static_type().name();
|
||||
|
||||
if let Some(type_) = types.get(&type_name) {
|
||||
if let Some(type_) = types.get(type_name) {
|
||||
return *type_;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ unsafe extern "C" fn filter_boxed_get_type<T: StaticType + 'static>() -> glib::f
|
|||
type_
|
||||
};
|
||||
|
||||
types.insert(type_name, type_);
|
||||
types.insert(String::from(type_name), type_);
|
||||
|
||||
type_
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
|||
assert!(!ptr.is_null());
|
||||
|
||||
let meta_api = Self::get_meta_api();
|
||||
if meta_api != glib::Type::Invalid {
|
||||
if meta_api != glib::Type::INVALID {
|
||||
assert_eq!(
|
||||
meta_api,
|
||||
from_glib((*(*(ptr as *const ffi::GstMeta)).info).api)
|
||||
|
@ -50,7 +50,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
|||
assert!(!ptr.is_null());
|
||||
|
||||
let meta_api = Self::get_meta_api();
|
||||
if meta_api != glib::Type::Invalid {
|
||||
if meta_api != glib::Type::INVALID {
|
||||
assert_eq!(
|
||||
meta_api,
|
||||
from_glib((*(*(ptr as *const ffi::GstMeta)).info).api)
|
||||
|
@ -165,7 +165,7 @@ impl<'a> MetaRef<'a, Meta> {
|
|||
let target_type = T::get_meta_api();
|
||||
let type_ = self.get_api();
|
||||
|
||||
if type_ == glib::Type::Invalid || target_type == type_ {
|
||||
if type_ == glib::Type::INVALID || target_type == type_ {
|
||||
Some(unsafe { &*(self as *const MetaRef<'a, Meta> as *const MetaRef<'a, T>) })
|
||||
} else {
|
||||
None
|
||||
|
@ -217,7 +217,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> {
|
|||
let target_type = T::get_meta_api();
|
||||
let type_ = self.get_api();
|
||||
|
||||
if type_ == glib::Type::Invalid || target_type == type_ {
|
||||
if type_ == glib::Type::INVALID || target_type == type_ {
|
||||
Some(unsafe { &*(self as *mut MetaRefMut<'a, Meta, U> as *const MetaRefMut<'a, T, U>) })
|
||||
} else {
|
||||
None
|
||||
|
@ -241,7 +241,7 @@ unsafe impl MetaAPI for Meta {
|
|||
type GstType = ffi::GstMeta;
|
||||
|
||||
fn get_meta_api() -> glib::Type {
|
||||
glib::Type::Invalid
|
||||
glib::Type::INVALID
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1666,15 +1666,15 @@ impl<T: IsA<Pad> + IsA<glib::Object>> PadBuilder<T> {
|
|||
.get_some::<glib::Type>()
|
||||
.unwrap();
|
||||
|
||||
if gtype == glib::Type::Unit {
|
||||
if gtype == glib::Type::UNIT {
|
||||
// Nothing to be done, we can create any kind of pad
|
||||
} else if gtype.is_a(&type_) {
|
||||
} else if gtype.is_a(type_) {
|
||||
// We were asked to create a parent type of the template type, e.g. a gst::Pad for
|
||||
// a template that wants a gst_base::AggregatorPad. Not a problem: update the type
|
||||
type_ = gtype;
|
||||
} else {
|
||||
// Otherwise the requested type must be a subclass of the template pad type
|
||||
assert!(type_.is_a(>ype));
|
||||
assert!(type_.is_a(gtype));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -769,14 +769,14 @@ mod tests {
|
|||
s.get::<i32>("f2"),
|
||||
Err(GetError::from_value_get_error(
|
||||
"f2",
|
||||
value::GetError::new_type_mismatch(Type::String, Type::I32),
|
||||
value::GetError::new_type_mismatch(Type::STRING, Type::I32),
|
||||
))
|
||||
);
|
||||
assert_eq!(
|
||||
s.get_some::<bool>("f3"),
|
||||
Err(GetError::from_value_get_error(
|
||||
"f3",
|
||||
value::GetError::new_type_mismatch(Type::I32, Type::Bool),
|
||||
value::GetError::new_type_mismatch(Type::I32, Type::BOOL),
|
||||
))
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
|
@ -323,7 +323,7 @@ where
|
|||
f: F,
|
||||
) -> R {
|
||||
unsafe {
|
||||
assert!(element.get_type().is_a(&T::get_type()));
|
||||
assert!(element.get_type().is_a(T::get_type()));
|
||||
let ptr: *mut ffi::GstElement = element.as_ptr() as *mut _;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
|
@ -339,7 +339,7 @@ where
|
|||
) -> R {
|
||||
unsafe {
|
||||
let wrap = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
|
||||
assert!(wrap.get_type().is_a(&T::get_type()));
|
||||
assert!(wrap.get_type().is_a(T::get_type()));
|
||||
let ptr: *mut ffi::GstElement = wrap.to_glib_none().0;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<'a> Serialize for TagValuesSer<'a> {
|
|||
for value in tag_iter.deref_mut() {
|
||||
match value.type_() {
|
||||
glib::Type::F64 => ser_some_tag!(value, seq, f64),
|
||||
glib::Type::String => {
|
||||
glib::Type::STRING => {
|
||||
// See above comment about `Tag`s with `String` values
|
||||
ser_opt_value!(value, String, |_, value: Option<String>| {
|
||||
seq.serialize_element(&value.expect("String tag ser"))
|
||||
|
@ -66,7 +66,7 @@ impl<'a> Serialize for TagValuesSer<'a> {
|
|||
}
|
||||
glib::Type::U32 => ser_some_tag!(value, seq, u32),
|
||||
glib::Type::U64 => ser_some_tag!(value, seq, u64),
|
||||
glib::Type::Other(type_id) => {
|
||||
type_id => {
|
||||
if *DATE_OTHER_TYPE_ID == type_id {
|
||||
// See above comment about `Tag`s with `Date` values
|
||||
ser_opt_value!(value, Date, |_, value: Option<Date>| {
|
||||
|
@ -83,14 +83,10 @@ impl<'a> Serialize for TagValuesSer<'a> {
|
|||
} else {
|
||||
Err(ser::Error::custom(format!(
|
||||
"unimplemented `Tag` serialization for type {}",
|
||||
glib::Type::Other(type_id),
|
||||
type_id,
|
||||
)))
|
||||
}
|
||||
}
|
||||
type_ => Err(ser::Error::custom(format!(
|
||||
"unimplemented `Tag` serialization for type {}",
|
||||
type_
|
||||
))),
|
||||
}?;
|
||||
}
|
||||
seq.end()
|
||||
|
@ -181,13 +177,13 @@ impl<'de, 'a> Visitor<'de> for TagValuesVisitor<'a> {
|
|||
loop {
|
||||
let tag_value = match tag_type {
|
||||
glib::Type::F64 => de_some_tag!(self.0, seq, f64),
|
||||
glib::Type::String => {
|
||||
glib::Type::STRING => {
|
||||
// See comment above `TagValuesSer` definition about `Tag`s with `String` values
|
||||
de_some_tag!(self.0, seq, String)
|
||||
}
|
||||
glib::Type::U32 => de_some_tag!(self.0, seq, u32),
|
||||
glib::Type::U64 => de_some_tag!(self.0, seq, u64),
|
||||
glib::Type::Other(type_id) => {
|
||||
type_id => {
|
||||
if *DATE_OTHER_TYPE_ID == type_id {
|
||||
// See comment above `TagValuesSer` definition about `Tag`s with `Date` values
|
||||
// Need to deserialize as `date_time_serde::Date` new type
|
||||
|
@ -200,17 +196,10 @@ impl<'de, 'a> Visitor<'de> for TagValuesVisitor<'a> {
|
|||
} else {
|
||||
return Err(de::Error::custom(format!(
|
||||
"unimplemented deserialization for `Tag` {} with type `{}`",
|
||||
self.0,
|
||||
glib::Type::Other(type_id),
|
||||
self.0, type_id,
|
||||
)));
|
||||
}
|
||||
}
|
||||
type_ => {
|
||||
return Err(de::Error::custom(format!(
|
||||
"unimplemented deserialization for `Tag` {} with type `{}`",
|
||||
self.0, type_,
|
||||
)));
|
||||
}
|
||||
}?;
|
||||
|
||||
match tag_value {
|
||||
|
|
|
@ -20,27 +20,20 @@ use crate::Sample;
|
|||
use crate::date_time_serde;
|
||||
use crate::value::*;
|
||||
|
||||
fn get_other_type_id<T: StaticType>() -> usize {
|
||||
match T::static_type() {
|
||||
glib::Type::Other(type_id) => type_id,
|
||||
type_ => panic!("Expecting `Other` variant, found `{}`", type_),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) static ARRAY_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Array>);
|
||||
pub(crate) static BITMASK_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Bitmask>);
|
||||
pub(crate) static DATE_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Date>);
|
||||
pub(crate) static DATE_TIME_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<DateTime>);
|
||||
pub(crate) static FRACTION_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Fraction>);
|
||||
pub(crate) static FRACTION_RANGE_OTHER_TYPE_ID: Lazy<usize> =
|
||||
Lazy::new(get_other_type_id::<FractionRange>);
|
||||
pub(crate) static INT_RANGE_I32_OTHER_TYPE_ID: Lazy<usize> =
|
||||
Lazy::new(get_other_type_id::<IntRange<i32>>);
|
||||
pub(crate) static INT_RANGE_I64_OTHER_TYPE_ID: Lazy<usize> =
|
||||
Lazy::new(get_other_type_id::<IntRange<i64>>);
|
||||
pub(crate) static LIST_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<List>);
|
||||
pub(crate) static SAMPLE_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Sample>);
|
||||
pub(crate) static BUFFER_OTHER_TYPE_ID: Lazy<usize> = Lazy::new(get_other_type_id::<Buffer>);
|
||||
pub(crate) static ARRAY_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Array::static_type);
|
||||
pub(crate) static BITMASK_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Bitmask::static_type);
|
||||
pub(crate) static DATE_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Date::static_type);
|
||||
pub(crate) static DATE_TIME_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(DateTime::static_type);
|
||||
pub(crate) static FRACTION_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Fraction::static_type);
|
||||
pub(crate) static FRACTION_RANGE_OTHER_TYPE_ID: Lazy<glib::Type> =
|
||||
Lazy::new(FractionRange::static_type);
|
||||
pub(crate) static INT_RANGE_I32_OTHER_TYPE_ID: Lazy<glib::Type> =
|
||||
Lazy::new(IntRange::<i32>::static_type);
|
||||
pub(crate) static INT_RANGE_I64_OTHER_TYPE_ID: Lazy<glib::Type> =
|
||||
Lazy::new(IntRange::<i64>::static_type);
|
||||
pub(crate) static LIST_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(List::static_type);
|
||||
pub(crate) static SAMPLE_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Sample::static_type);
|
||||
pub(crate) static BUFFER_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Buffer::static_type);
|
||||
|
||||
impl<'a> Serialize for Fraction {
|
||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
|
@ -77,15 +70,15 @@ macro_rules! ser_value (
|
|||
match $value.type_() {
|
||||
glib::Type::I8 => ser_some_value!($value, i8, $ser_closure),
|
||||
glib::Type::U8 => ser_some_value!($value, u8, $ser_closure),
|
||||
glib::Type::Bool => ser_some_value!($value, bool, $ser_closure),
|
||||
glib::Type::BOOL => ser_some_value!($value, bool, $ser_closure),
|
||||
glib::Type::I32 => ser_some_value!($value, i32, $ser_closure),
|
||||
glib::Type::U32 => ser_some_value!($value, u32, $ser_closure),
|
||||
glib::Type::I64 => ser_some_value!($value, i64, $ser_closure),
|
||||
glib::Type::U64 => ser_some_value!($value, u64, $ser_closure),
|
||||
glib::Type::F32 => ser_some_value!($value, f32, $ser_closure),
|
||||
glib::Type::F64 => ser_some_value!($value, f64, $ser_closure),
|
||||
glib::Type::String => ser_opt_value!($value, String, $ser_closure),
|
||||
glib::Type::Other(type_id) => {
|
||||
glib::Type::STRING => ser_opt_value!($value, String, $ser_closure),
|
||||
type_id => {
|
||||
if *ARRAY_OTHER_TYPE_ID == type_id {
|
||||
ser_some_value!($value, Array, $ser_closure)
|
||||
} else if *BITMASK_OTHER_TYPE_ID == type_id {
|
||||
|
@ -116,19 +109,12 @@ macro_rules! ser_value (
|
|||
Err(
|
||||
ser::Error::custom(
|
||||
format!("unimplemented `Value` serialization for type {}",
|
||||
glib::Type::Other(type_id),
|
||||
type_id,
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
type_ => {
|
||||
Err(
|
||||
ser::Error::custom(
|
||||
format!("unimplemented `Value` serialization for type {}", type_)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue