2011-02-25 12:35:14 +05:30
|
|
|
#ifndef fooformathfoo
|
|
|
|
|
#define fooformathfoo
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of PulseAudio.
|
|
|
|
|
|
|
|
|
|
Copyright 2011 Intel Corporation
|
|
|
|
|
Copyright 2011 Collabora Multimedia
|
|
|
|
|
Copyright 2011 Arun Raghavan <arun.raghavan@collabora.co.uk>
|
|
|
|
|
|
|
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
|
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
along with PulseAudio; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#include <pulse/cdecl.h>
|
2011-06-13 15:04:33 +02:00
|
|
|
#include <pulse/gccmacro.h>
|
2011-02-25 12:35:14 +05:30
|
|
|
#include <pulse/proplist.h>
|
2011-04-13 15:37:25 +05:30
|
|
|
#include <pulse/sample.h>
|
|
|
|
|
#include <pulse/channelmap.h>
|
2011-02-25 12:35:14 +05:30
|
|
|
|
2011-12-12 13:19:45 +01:00
|
|
|
/** \file
|
2012-02-06 09:47:39 +05:30
|
|
|
* Utility functions for handling a stream or sink format. */
|
2011-12-12 13:19:45 +01:00
|
|
|
|
2011-02-25 12:35:14 +05:30
|
|
|
PA_C_DECL_BEGIN
|
|
|
|
|
|
2011-09-27 18:57:48 +05:30
|
|
|
/** Represents the type of encoding used in a stream or accepted by a sink. \since 1.0 */
|
2011-02-25 12:35:14 +05:30
|
|
|
typedef enum pa_encoding {
|
|
|
|
|
PA_ENCODING_ANY,
|
|
|
|
|
/**< Any encoding format, PCM or compressed */
|
|
|
|
|
|
|
|
|
|
PA_ENCODING_PCM,
|
|
|
|
|
/**< Any PCM format */
|
|
|
|
|
|
|
|
|
|
PA_ENCODING_AC3_IEC61937,
|
|
|
|
|
/**< AC3 data encapsulated in IEC 61937 header/padding */
|
|
|
|
|
|
|
|
|
|
PA_ENCODING_EAC3_IEC61937,
|
|
|
|
|
/**< EAC3 data encapsulated in IEC 61937 header/padding */
|
|
|
|
|
|
|
|
|
|
PA_ENCODING_MPEG_IEC61937,
|
|
|
|
|
/**< MPEG-1 or MPEG-2 (Part 3, not AAC) data encapsulated in IEC 61937 header/padding */
|
|
|
|
|
|
2011-03-09 20:50:25 +05:30
|
|
|
PA_ENCODING_DTS_IEC61937,
|
|
|
|
|
/**< DTS data encapsulated in IEC 61937 header/padding */
|
|
|
|
|
|
2011-02-25 12:35:14 +05:30
|
|
|
PA_ENCODING_MAX,
|
|
|
|
|
/**< Valid encoding types must be less than this value */
|
|
|
|
|
|
|
|
|
|
PA_ENCODING_INVALID = -1,
|
|
|
|
|
/**< Represents an invalid encoding */
|
|
|
|
|
} pa_encoding_t;
|
|
|
|
|
|
2011-03-08 20:15:36 +05:30
|
|
|
/** Returns a printable string representing the given encoding type. \since 1.0 */
|
|
|
|
|
const char *pa_encoding_to_string(pa_encoding_t e) PA_GCC_CONST;
|
|
|
|
|
|
2011-08-12 21:55:48 +05:30
|
|
|
/** Converts a string of the form returned by \a pa_encoding_to_string() back to a \a pa_encoding_t. \since 1.0 */
|
|
|
|
|
pa_encoding_t pa_encoding_from_string(const char *encoding);
|
|
|
|
|
|
2011-09-27 18:57:48 +05:30
|
|
|
/** Represents the format of data provided in a stream or processed by a sink. \since 1.0 */
|
2011-02-25 12:35:14 +05:30
|
|
|
typedef struct pa_format_info {
|
|
|
|
|
pa_encoding_t encoding;
|
|
|
|
|
/**< The encoding used for the format */
|
|
|
|
|
|
|
|
|
|
pa_proplist *plist;
|
|
|
|
|
/**< Additional encoding-specific properties such as sample rate, bitrate, etc. */
|
|
|
|
|
} pa_format_info;
|
|
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Allocates a new \a pa_format_info structure. Clients must initialise at least the encoding field themselves. \since 1.0 */
|
2011-02-25 12:35:14 +05:30
|
|
|
pa_format_info* pa_format_info_new(void);
|
|
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Returns a new \a pa_format_info struct and representing the same format as \a src. \since 1.0 */
|
2011-02-25 12:35:14 +05:30
|
|
|
pa_format_info* pa_format_info_copy(const pa_format_info *src);
|
|
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Frees a \a pa_format_info structure. \since 1.0 */
|
2011-02-25 12:35:14 +05:30
|
|
|
void pa_format_info_free(pa_format_info *f);
|
|
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Returns non-zero when the format info structure is valid. \since 1.0 */
|
2011-03-08 20:14:46 +05:30
|
|
|
int pa_format_info_valid(const pa_format_info *f);
|
2011-02-25 12:35:14 +05:30
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Returns non-zero when the format info structure represents a PCM (i.e.\ uncompressed data) format. \since 1.0 */
|
2011-03-08 20:14:46 +05:30
|
|
|
int pa_format_info_is_pcm(const pa_format_info *f);
|
2011-03-01 16:34:06 +05:30
|
|
|
|
2011-12-12 13:19:43 +01:00
|
|
|
/** Returns non-zero if the format represented by \a first is a subset of
|
|
|
|
|
* the format represented by \a second. This means that \a second must
|
2011-03-29 17:16:08 +05:30
|
|
|
* have all the fields that \a first 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,
|
|
|
|
|
* \a first would be the sink's format and \a second would be the
|
2012-02-06 09:47:39 +05:30
|
|
|
* stream's. \since 1.0 */
|
2011-03-29 17:16:08 +05:30
|
|
|
int pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second);
|
|
|
|
|
|
2011-03-08 20:15:36 +05:30
|
|
|
/** Maximum required string length for
|
|
|
|
|
* pa_format_info_snprint(). Please note that this value can change
|
|
|
|
|
* with any release without warning and without being considered API
|
|
|
|
|
* or ABI breakage. You should not use this definition anywhere where
|
|
|
|
|
* it might become part of an ABI. \since 1.0 */
|
|
|
|
|
#define PA_FORMAT_INFO_SNPRINT_MAX 256
|
|
|
|
|
|
|
|
|
|
/** Return a human-readable string representing the given format. \since 1.0 */
|
|
|
|
|
char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f);
|
|
|
|
|
|
2011-08-12 21:55:48 +05:30
|
|
|
/** Parse a human-readable string of the form generated by
|
|
|
|
|
* \a pa_format_info_snprint() into a pa_format_info structure. \since 1.0 */
|
|
|
|
|
pa_format_info* pa_format_info_from_string(const char *str);
|
|
|
|
|
|
2012-02-06 11:34:47 +05:30
|
|
|
/** Utility function to take a \a pa_sample_spec and generate the corresponding \a pa_format_info. \since 2.0 */
|
|
|
|
|
pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_map *map);
|
|
|
|
|
|
|
|
|
|
/** Utility function to generate a \a pa_sample_spec and \a pa_channel_map corresponding to a given \a pa_format_info. Returns
|
|
|
|
|
* a negative integer if conversion failed and 0 on success. \since 2.0 */
|
|
|
|
|
int pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
|
|
|
|
|
|
2012-02-06 17:17:34 +05:30
|
|
|
/** Represents the type of value type of a property on a \ref pa_format_info. \since 2.0 */
|
|
|
|
|
typedef enum pa_prop_type_t {
|
|
|
|
|
PA_PROP_TYPE_INT,
|
|
|
|
|
/**< Integer property */
|
|
|
|
|
|
|
|
|
|
PA_PROP_TYPE_INT_RANGE,
|
|
|
|
|
/**< Integer range property */
|
|
|
|
|
|
|
|
|
|
PA_PROP_TYPE_INT_ARRAY,
|
|
|
|
|
/**< Integer array property */
|
|
|
|
|
|
|
|
|
|
PA_PROP_TYPE_STRING,
|
|
|
|
|
/**< String property */
|
|
|
|
|
|
|
|
|
|
PA_PROP_TYPE_STRING_ARRAY,
|
|
|
|
|
/**< String array property */
|
|
|
|
|
|
|
|
|
|
PA_PROP_TYPE_INVALID = -1,
|
|
|
|
|
/**< Represents an invalid type */
|
|
|
|
|
} pa_prop_type_t;
|
|
|
|
|
|
|
|
|
|
/** Gets the type of property \a key in a given \ref pa_format_info. \since 2.0 */
|
|
|
|
|
pa_prop_type_t pa_format_info_get_prop_type(pa_format_info *f, const char *key);
|
|
|
|
|
|
2012-02-06 11:14:53 +05:30
|
|
|
/** Gets an integer property from the given format info. Returns 0 on success and a negative integer on failure. \since 2.0 */
|
|
|
|
|
int pa_format_info_get_prop_int(pa_format_info *f, const char *key, int *v);
|
2012-02-06 16:18:49 +05:30
|
|
|
/** Gets an integer range property from the given format info. Returns 0 on success and a negative integer on failure.
|
|
|
|
|
* \since 2.0 */
|
|
|
|
|
int pa_format_info_get_prop_int_range(pa_format_info *f, const char *key, int *min, int *max);
|
|
|
|
|
/** Gets an integer array property from the given format info. \a values contains the values and \a n_values contains the
|
|
|
|
|
* number of elements. The caller must free \a values using \ref pa_xfree. Returns 0 on success and a negative integer on
|
|
|
|
|
* failure. \since 2.0 */
|
|
|
|
|
int pa_format_info_get_prop_int_array(pa_format_info *f, const char *key, int **values, int *n_values);
|
2012-02-06 11:14:53 +05:30
|
|
|
/** Gets a string property from the given format info. The caller must free the returned string using \ref pa_xfree. Returns
|
|
|
|
|
* 0 on success and a negative integer on failure. \since 2.0 */
|
|
|
|
|
int pa_format_info_get_prop_string(pa_format_info *f, const char *key, char **v);
|
2012-02-06 16:18:49 +05:30
|
|
|
/** Gets a string array property from the given format info. \a values contains the values and \a n_values contains
|
|
|
|
|
* the number of elements. The caller must free \a values using \ref pa_format_info_free_string_array. Returns 0 on success and
|
|
|
|
|
* a negative integer on failure. \since 2.0 */
|
|
|
|
|
int pa_format_info_get_prop_string_array(pa_format_info *f, const char *key, char ***values, int *n_values);
|
|
|
|
|
|
|
|
|
|
/** Frees a string array returned by \ref pa_format_info_get_prop_string_array. \since 2.0 */
|
|
|
|
|
void pa_format_info_free_string_array(char **values, int n_values);
|
2012-02-06 11:14:53 +05:30
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Sets an integer property on the given format info. \since 1.0 */
|
2011-04-13 14:05:18 +05:30
|
|
|
void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Sets a property with a list of integer values on the given format info. \since 1.0 */
|
2011-04-13 14:05:18 +05:30
|
|
|
void pa_format_info_set_prop_int_array(pa_format_info *f, const char *key, const int *values, int n_values);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Sets a property which can have any value in a given integer range on the given format info. \since 1.0 */
|
2011-04-13 14:05:18 +05:30
|
|
|
void pa_format_info_set_prop_int_range(pa_format_info *f, const char *key, int min, int max);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Sets a string property on the given format info. \since 1.0 */
|
2011-04-13 14:05:18 +05:30
|
|
|
void pa_format_info_set_prop_string(pa_format_info *f, const char *key, const char *value);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Sets a property with a list of string values on the given format info. \since 1.0 */
|
2011-04-13 14:05:18 +05:30
|
|
|
void pa_format_info_set_prop_string_array(pa_format_info *f, const char *key, const char **values, int n_values);
|
|
|
|
|
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Convenience method to set the sample format as a property on the given format. \since 1.0 */
|
2011-04-13 15:37:25 +05:30
|
|
|
void pa_format_info_set_sample_format(pa_format_info *f, pa_sample_format_t sf);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Convenience method to set the sampling rate as a property on the given format. \since 1.0 */
|
2011-04-13 15:37:25 +05:30
|
|
|
void pa_format_info_set_rate(pa_format_info *f, int rate);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Convenience method to set the number of channels as a property on the given format. \since 1.0 */
|
2011-04-13 15:37:25 +05:30
|
|
|
void pa_format_info_set_channels(pa_format_info *f, int channels);
|
2012-02-06 09:47:39 +05:30
|
|
|
/** Convenience method to set the channel map as a property on the given format. \since 1.0 */
|
2011-04-13 15:37:25 +05:30
|
|
|
void pa_format_info_set_channel_map(pa_format_info *f, const pa_channel_map *map);
|
|
|
|
|
|
2011-02-25 12:35:14 +05:30
|
|
|
PA_C_DECL_END
|
|
|
|
|
|
|
|
|
|
#endif
|