Struct pipewire_wrapper::spa::pod::object::PodObjectRef
source · #[repr(transparent)]pub struct PodObjectRef { /* private fields */ }
Expand description
Object pod wrapper, used as param value type in the most cases. Pod value represented by ObjectType enum.
Examples
Parse value manually:
ⓘ
if let BasicType::OBJECT(obj) = pod.downcast().unwrap() {
if let ObjectType::OBJECT_FORMAT(format) = obj.param_value(ParamType::FORMAT).unwrap() {
for prop in format {
if let ObjectFormatType::VIDEO_SIZE(size) = prop.value()? {
todo!();
}
}
}
}
Parse as Info object:
ⓘ
if let Ok(BasicType::OBJECT(object)) = param.downcast() {
match object.body_type() {
Type::OBJECT_PROP_INFO => {
let info = ObjectPropInfoInfo::try_from(object).unwrap();
println ! ("Prop info: {:?}", info);
}
_ => todo!(),
}
}
Create the Object pod manually:
ⓘ
PodObjectRef::from_id_and_value(
ParamType::ENUM_FORMAT,
&ObjectType::OBJECT_ENUM_FORMAT(
AllocatedPodIterator::from_values(&[
ObjectEnumFormatType::MEDIA_TYPE(MediaType::AUDIO.to_alloc_pod().as_pod()),
ObjectEnumFormatType::MEDIA_SUBTYPE(MediaSubType::RAW.to_alloc_pod().as_pod()),
ObjectEnumFormatType::AUDIO_FORMAT(
PodEnumValue::from_default(AudioFormat::F32)
.to_alloc_pod()?
.as_pod()
.choice(),
),
ObjectEnumFormatType::AUDIO_CHANNELS(
PodIntRef::from_primitive(CHANNELS as i32)?.as_pod().into(),
),
ObjectEnumFormatType::AUDIO_RATE(
PodIntRef::from_primitive(RATE as i32)?.as_pod().into(),
),
])?
.iter(),
),
)
Build the pod with builder:
ⓘ
ObjectEnumFormatBuilder::default()
.body_id(ParamType::ENUM_FORMAT.into())
.media_type(MediaType::VIDEO)
.media_subtype(MediaSubType::RAW)
.video_format(ChoiceStructType::ENUM(PodEnumValue::from_default(
VideoFormat::RGB,
)))
.video_size(ChoiceStructType::RANGE(PodRangeValue::new(
RectangleRef::new(320, 240),
RectangleRef::new(1, 1),
RectangleRef::new(4096, 4096),
)))
.video_framerate(ChoiceStructType::NONE(FractionRef::new(25, 1)))
.build()?;
Implementations§
source§impl PodObjectRef
impl PodObjectRef
pub fn body_type(&self) -> Type
pub fn body_id(&self) -> u32
pub fn set_body_id(&mut self, id: u32)
pub fn from_id_and_value( id: impl Into<u32>, value: &<&Self as PodValue>::Value ) -> Result<AllocPod<Self>, PodError>
sourcepub fn param_value(
&self,
param_type: ParamType
) -> Result<ObjectType<'_>, PodError>
pub fn param_value( &self, param_type: ParamType ) -> Result<ObjectType<'_>, PodError>
Can be used to retrieve object value with specified body.id value, because body.id value can be Invalid for some reason.
Trait Implementations§
source§impl Debug for PodObjectRef
impl Debug for PodObjectRef
source§impl From<PodObjectRef> for spa_pod_object
impl From<PodObjectRef> for spa_pod_object
source§fn from(value: PodObjectRef) -> Self
fn from(value: PodObjectRef) -> Self
Converts to this type from the input type.
source§impl From<spa_pod_object> for PodObjectRef
impl From<spa_pod_object> for PodObjectRef
source§fn from(value: spa_pod_object) -> Self
fn from(value: spa_pod_object) -> Self
Converts to this type from the input type.
source§impl<'a> PodValue for &'a PodObjectRef
impl<'a> PodValue for &'a PodObjectRef
source§impl RawWrapper for PodObjectRef
impl RawWrapper for PodObjectRef
§type CType = spa_pod_object
type CType = spa_pod_object
External type
source§fn as_raw_ptr(&self) -> *mut Self::CType
fn as_raw_ptr(&self) -> *mut Self::CType
Raw ptr to the external type
source§fn from_raw(raw: Self::CType) -> Self
fn from_raw(raw: Self::CType) -> Self
Creates wrapper from the external value, can be use when external type has no raw pointers.
source§unsafe fn mut_from_raw_ptr<'lft>(raw: *mut Self::CType) -> &'lft mut Self
unsafe fn mut_from_raw_ptr<'lft>(raw: *mut Self::CType) -> &'lft mut Self
Cast external pointer to the borrowed mutable wrapper.
Panic when pointer is null.
Lifetime is not reliable and should be guaranteed explicitly. Read more
source§impl<'a> TryFrom<&'a PodObjectRef> for ObjectEnumFormatInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ObjectEnumFormatInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ObjectFormatInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ObjectFormatInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfoInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ObjectPropInfoInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamBuffersInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamBuffersInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamIOInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamIOInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamLatencyInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamLatencyInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamMetaInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamMetaInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamPortConfigInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamPortConfigInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamProcessLatencyInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamProcessLatencyInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamProfileInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamProfileInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ParamRouteInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ParamRouteInfo<'a>
source§impl<'a> TryFrom<&'a PodObjectRef> for ProfilerInfo<'a>
impl<'a> TryFrom<&'a PodObjectRef> for ProfilerInfo<'a>
Auto Trait Implementations§
impl RefUnwindSafe for PodObjectRef
impl Send for PodObjectRef
impl Sync for PodObjectRef
impl Unpin for PodObjectRef
impl UnwindSafe for PodObjectRef
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more