pub struct Info { /* private fields */ }
Expand description

Represents the format of data provided in a stream or processed by a sink.

Implementations§

source§

impl Info

source

pub fn new() -> Option<Self>

Allocates a new Info structure.

Clients must initialise at least the encoding field themselves. Returns None on failure.

source

pub fn new_from_string(s: &str) -> Option<Self>

Parses a human-readable string of the form generated by print() into an Info structure.

Returns None on failure.

source

pub fn new_from_sample_spec(ss: &Spec, map: Option<&Map>) -> Option<Self>

Utility function to take a Spec and generate the corresponding Info.

Note that if you want the server to choose some of the stream parameters, for example the sample rate, so that they match the device parameters, then you shouldn’t use this function. In order to allow the server to choose a parameter value, that parameter must be left unspecified in the Info object, and this function always specifies all parameters. An exception is the channel map: if you pass None for the channel map, then the channel map will be left unspecified, allowing the server to choose it.

Returns None on failure.

source

pub fn is_valid(&self) -> bool

Checks whether the Info structure is valid.

source

pub fn is_pcm(&self) -> bool

Checks whether the Info structure represents a PCM (i.e. uncompressed data) format.

source

pub fn is_compatible_with(&self, with: &Self) -> bool

Checks whether the format represented by self is a subset of the format represented by with.

This means that with must have all the fields that self does, but the reverse need not be true. This is typically expected to be used to check if a stream’s format is compatible with a given sink. In such a case, self would be the sink’s format and with would be the streams.

source

pub fn print(&self) -> String

Gets a human-readable string representing the given format.

source

pub fn to_sample_spec(&self, ss: &mut Spec, map: &mut Map) -> Result<(), PAErr>

Utility function to generate a Spec and Map corresponding to a given Info.

The conversion for PCM formats is straight-forward. For non-PCM formats, if there is a fixed size-time conversion (i.e. all IEC61937-encapsulated formats), a “fake” sample spec whose size-time conversion corresponds to this format is provided and the channel map argument is ignored. For formats with variable size-time conversion, this function will fail.

source

pub fn get_encoding(&self) -> Encoding

Gets the encoding.

source

pub fn set_encoding(&mut self, encoding: Encoding)

Sets the encoding attribute.

source

pub fn get_properties(&self) -> &Proplist

Gets an immutable reference to the property list.

source

pub fn get_properties_mut(&mut self) -> &mut Proplist

Gets a mutable reference to the property list.

source

pub fn get_prop_type(&self, key: &str) -> PropType

Gets the type of property key.

source

pub fn get_prop_int(&self, key: &str) -> Result<i32, PAErr>

Gets an integer property.

source

pub fn get_prop_int_range(&self, key: &str) -> Result<(i32, i32), PAErr>

Gets an integer range property. On success, returns min-max tuple.

source

pub fn get_prop_int_array(&self, key: &str) -> Option<Vec<i32>>

Gets an integer array property.

Returns None on error.

source

pub fn get_prop_string(&self, key: &str) -> Option<String>

Gets a string property.

source

pub fn get_prop_string_array(&self, key: &str) -> Option<Vec<String>>

Gets a string array property.

source

pub fn get_sample_format(&self) -> Result<Format, PAErr>

Available on crate feature pa_v13 only.

Gets the sample format stored in the format info.

Returns Err if the sample format property is not set at all, or is invalid.

source

pub fn get_rate(&self) -> Result<u32, PAErr>

Available on crate feature pa_v13 only.

Gets the sample rate stored in the format info.

Returns Err if the sample rate property is not set at all, or is invalid.

source

pub fn get_channel_count(&self) -> Result<u8, PAErr>

Available on crate feature pa_v13 only.

Gets the channel count stored in the format info.

Returns Err if the channels property is not set at all, or is invalid.

source

pub fn get_channel_map(&self) -> Result<Map, PAErr>

Available on crate feature pa_v13 only.

Gets the channel map stored in the format info.

Returns Err if the channel map property is not set at all, or if the string form it is stored in within the property set fails to parse successfully.

source

pub fn set_prop_int(&mut self, key: &str, value: i32)

Sets an integer property.

source

pub fn set_prop_int_array(&mut self, key: &str, values: &[i32])

Sets a property with a list of integer values.

source

pub fn set_prop_int_range(&mut self, key: &str, min: i32, max: i32)

Sets a property which can have any value in a given integer range.

source

pub fn set_prop_string(&mut self, key: &str, value: &str)

Sets a string property.

source

pub fn set_prop_string_array(&mut self, key: &str, values: &[&str])

Sets a property with a list of string values.

source

pub fn set_sample_format(&mut self, sf: Format)

Convenience method to set the sample format as a property.

Note for PCM: If the sample format is left unspecified in the Info object, then the server will select the stream sample format. In that case the stream sample format will most likely match the device sample format, meaning that sample format conversion will be avoided.

source

pub fn set_rate(&mut self, rate: i32)

Convenience method to set the sampling rate as a property.

Note for PCM: If the sample rate is left unspecified in the Info object, then the server will select the stream sample rate. In that case the stream sample rate will most likely match the device sample rate, meaning that sample rate conversion will be avoided.

source

pub fn set_channels(&mut self, channels: u32)

Convenience method to set the number of channels as a property.

Note for PCM: If the channel count is left unspecified in the Info object, then the server will select the stream channel count. In that case the stream channel count will most likely match the device channel count, meaning that up/downmixing will be avoided.

source

pub fn set_channel_map(&mut self, map: &Map)

Convenience method to set the channel map as a property.

Note for PCM: If the channel map is left unspecified in the Info object, then the server will select the stream channel map. In that case the stream channel map will most likely match the device channel map, meaning that remixing will be avoided.

Trait Implementations§

source§

impl Clone for Info

source§

fn clone(&self) -> Self

Returns a new Info struct and representing the same format. If this is called on a ‘weak’ instance, a non-weak object is returned.

1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Info

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Info

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Info

source§

impl Sync for Info

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.