mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
API: Make gst_audio_check_channel_positions() public.
Original commit message from CVS: * docs/libs/gst-plugins-base-libs-sections.txt: * gst-libs/gst/audio/multichannel.c: (gst_audio_check_channel_positions): * gst-libs/gst/audio/multichannel.h: API: Make gst_audio_check_channel_positions() public. * tests/check/libs/audio.c: (GST_START_TEST): Add some simple checks for gst_audio_check_channel_positions().
This commit is contained in:
parent
d5b8246724
commit
0de81029c8
5 changed files with 69 additions and 16 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-06-03 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* docs/libs/gst-plugins-base-libs-sections.txt:
|
||||||
|
* gst-libs/gst/audio/multichannel.c:
|
||||||
|
(gst_audio_check_channel_positions):
|
||||||
|
* gst-libs/gst/audio/multichannel.h:
|
||||||
|
API: Make gst_audio_check_channel_positions() public.
|
||||||
|
|
||||||
|
* tests/check/libs/audio.c: (GST_START_TEST):
|
||||||
|
Add some simple checks for gst_audio_check_channel_positions().
|
||||||
|
|
||||||
2008-06-02 Tim-Philipp Müller <tim.muller at collabora co uk>
|
2008-06-02 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||||
|
|
||||||
* sys/v4l/v4l_calls.c: (gst_v4l_get_chan_names):
|
* sys/v4l/v4l_calls.c: (gst_v4l_get_chan_names):
|
||||||
|
|
|
@ -143,6 +143,7 @@ gst_audio_get_channel_positions
|
||||||
gst_audio_set_caps_channel_positions_list
|
gst_audio_set_caps_channel_positions_list
|
||||||
gst_audio_set_channel_positions
|
gst_audio_set_channel_positions
|
||||||
gst_audio_set_structure_channel_positions_list
|
gst_audio_set_structure_channel_positions_list
|
||||||
|
gst_audio_check_channel_positions
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GST_TYPE_AUDIO_CHANNEL_POSITION
|
GST_TYPE_AUDIO_CHANNEL_POSITION
|
||||||
gst_audio_channel_position_get_type
|
gst_audio_channel_position_get_type
|
||||||
|
|
|
@ -25,20 +25,33 @@
|
||||||
|
|
||||||
#define GST_AUDIO_CHANNEL_POSITIONS_FIELD_NAME "channel-positions"
|
#define GST_AUDIO_CHANNEL_POSITIONS_FIELD_NAME "channel-positions"
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This function checks if basic assumptions apply:
|
* gst_audio_check_channel_positions:
|
||||||
* - does each position occur at most once?
|
* @pos: An array of #GstAudioChannelPosition.
|
||||||
* - invalid positions?
|
* @channels: The number of elements in @pos.
|
||||||
* - do conflicting positions occur?
|
*
|
||||||
* + front_mono vs. front_left/right
|
* This functions checks if the given channel positions are valid. Channel
|
||||||
* + none vs not-none
|
* positions are valid if:
|
||||||
|
* <itemizedlist>
|
||||||
|
* <listitem><para>No channel positions appears twice or all positions are %GST_AUDIO_CHANNEL_POSITION_NONE.
|
||||||
|
* </para></listitem>
|
||||||
|
* <listitem><para>Either all or none of the channel positions are %GST_AUDIO_CHANNEL_POSITION_NONE.
|
||||||
|
* </para></listitem>
|
||||||
|
* <listitem><para>%GST_AUDIO_CHANNEL_POSITION_FRONT_MONO and %GST_AUDIO_CHANNEL_POSITION_LEFT or %GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT don't appear together in the given positions.
|
||||||
|
* </para></listitem>
|
||||||
|
* </itemizedlist>
|
||||||
|
*
|
||||||
|
* Since: 0.10.20
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the given channel positions are valid
|
||||||
|
* and %FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
|
gboolean
|
||||||
static gboolean
|
|
||||||
gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
||||||
gint channels)
|
guint channels)
|
||||||
{
|
{
|
||||||
gint i, n;
|
gint i, n;
|
||||||
|
|
||||||
const struct
|
const struct
|
||||||
{
|
{
|
||||||
const GstAudioChannelPosition pos1[2];
|
const GstAudioChannelPosition pos1[2];
|
||||||
|
@ -52,13 +65,14 @@ gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
||||||
GST_AUDIO_CHANNEL_POSITION_INVALID}}
|
GST_AUDIO_CHANNEL_POSITION_INVALID}}
|
||||||
};
|
};
|
||||||
|
|
||||||
g_assert (pos != NULL && channels > 0);
|
g_return_val_if_fail (pos != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (channels > 0, FALSE);
|
||||||
|
|
||||||
/* check for invalid channel positions */
|
/* check for invalid channel positions */
|
||||||
for (n = 0; n < channels; n++) {
|
for (n = 0; n < channels; n++) {
|
||||||
if (pos[n] <= GST_AUDIO_CHANNEL_POSITION_INVALID ||
|
if (pos[n] <= GST_AUDIO_CHANNEL_POSITION_INVALID ||
|
||||||
pos[n] >= GST_AUDIO_CHANNEL_POSITION_NUM) {
|
pos[n] >= GST_AUDIO_CHANNEL_POSITION_NUM) {
|
||||||
g_warning ("Channel position %d for channel %d is invalid", pos[n], n);
|
GST_WARNING ("Channel position %d for channel %d is invalid", pos[n], n);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +83,7 @@ gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
||||||
if (pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE) {
|
if (pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE) {
|
||||||
for (n = 1; n < channels; ++n) {
|
for (n = 1; n < channels; ++n) {
|
||||||
if (pos[n] != GST_AUDIO_CHANNEL_POSITION_NONE) {
|
if (pos[n] != GST_AUDIO_CHANNEL_POSITION_NONE) {
|
||||||
g_warning ("Either all channel positions must be defined, or all "
|
GST_WARNING ("Either all channel positions must be defined, or all "
|
||||||
"be set to NONE, having only some defined is not allowed");
|
"be set to NONE, having only some defined is not allowed");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -90,13 +104,13 @@ gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
||||||
|
|
||||||
/* NONE may not occur mixed with other channel positions */
|
/* NONE may not occur mixed with other channel positions */
|
||||||
if (i == GST_AUDIO_CHANNEL_POSITION_NONE && count > 0) {
|
if (i == GST_AUDIO_CHANNEL_POSITION_NONE && count > 0) {
|
||||||
g_warning ("Either all channel positions must be defined, or all "
|
GST_WARNING ("Either all channel positions must be defined, or all "
|
||||||
"be set to NONE, having only some defined is not allowed");
|
"be set to NONE, having only some defined is not allowed");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
g_warning ("Channel position %d occurred %d times, not allowed",
|
GST_WARNING ("Channel position %d occurred %d times, not allowed",
|
||||||
i, count);
|
i, count);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +128,7 @@ gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found1 && found2) {
|
if (found1 && found2) {
|
||||||
g_warning ("Found conflicting channel positions %d/%d and %d",
|
GST_WARNING ("Found conflicting channel positions %d/%d and %d",
|
||||||
conf[i].pos1[0], conf[i].pos1[1], conf[i].pos2[0]);
|
conf[i].pos1[0], conf[i].pos1[1], conf[i].pos2[0]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -210,9 +224,13 @@ GstAudioChannelPosition *
|
||||||
gst_audio_get_channel_positions (GstStructure * str)
|
gst_audio_get_channel_positions (GstStructure * str)
|
||||||
{
|
{
|
||||||
GstAudioChannelPosition *pos;
|
GstAudioChannelPosition *pos;
|
||||||
|
|
||||||
gint channels, n;
|
gint channels, n;
|
||||||
|
|
||||||
const GValue *pos_val_arr, *pos_val_entry;
|
const GValue *pos_val_arr, *pos_val_entry;
|
||||||
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
GType t;
|
GType t;
|
||||||
|
|
||||||
/* get number of channels, general type checkups */
|
/* get number of channels, general type checkups */
|
||||||
|
@ -286,6 +304,7 @@ gst_audio_set_channel_positions (GstStructure * str,
|
||||||
GValue pos_val_arr = { 0 }, pos_val_entry = {
|
GValue pos_val_arr = { 0 }, pos_val_entry = {
|
||||||
0};
|
0};
|
||||||
gint channels, n;
|
gint channels, n;
|
||||||
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
/* get number of channels, checkups */
|
/* get number of channels, checkups */
|
||||||
|
@ -378,6 +397,7 @@ add_list_to_struct (GstStructure * str,
|
||||||
const GstAudioChannelPosition * pos, gint num_positions)
|
const GstAudioChannelPosition * pos, gint num_positions)
|
||||||
{
|
{
|
||||||
GstCaps *caps = gst_caps_new_empty ();
|
GstCaps *caps = gst_caps_new_empty ();
|
||||||
|
|
||||||
const GValue *chan_val;
|
const GValue *chan_val;
|
||||||
|
|
||||||
chan_val = gst_structure_get_value (str, "channels");
|
chan_val = gst_structure_get_value (str, "channels");
|
||||||
|
@ -385,6 +405,7 @@ add_list_to_struct (GstStructure * str,
|
||||||
gst_audio_set_structure_channel_positions_list (str, pos, num_positions);
|
gst_audio_set_structure_channel_positions_list (str, pos, num_positions);
|
||||||
} else if (G_VALUE_TYPE (chan_val) == GST_TYPE_LIST) {
|
} else if (G_VALUE_TYPE (chan_val) == GST_TYPE_LIST) {
|
||||||
gint size;
|
gint size;
|
||||||
|
|
||||||
const GValue *sub_val;
|
const GValue *sub_val;
|
||||||
|
|
||||||
size = gst_value_list_get_size (chan_val);
|
size = gst_value_list_get_size (chan_val);
|
||||||
|
@ -479,9 +500,13 @@ GstAudioChannelPosition *
|
||||||
gst_audio_fixate_channel_positions (GstStructure * str)
|
gst_audio_fixate_channel_positions (GstStructure * str)
|
||||||
{
|
{
|
||||||
GstAudioChannelPosition *pos;
|
GstAudioChannelPosition *pos;
|
||||||
|
|
||||||
gint channels, n, num_unfixed = 0, i, c;
|
gint channels, n, num_unfixed = 0, i, c;
|
||||||
|
|
||||||
const GValue *pos_val_arr, *pos_val_entry, *pos_val;
|
const GValue *pos_val_arr, *pos_val_entry, *pos_val;
|
||||||
|
|
||||||
gboolean res, is_stereo = TRUE;
|
gboolean res, is_stereo = TRUE;
|
||||||
|
|
||||||
GType t;
|
GType t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -90,6 +90,8 @@ void gst_audio_set_caps_channel_positions_list
|
||||||
GstAudioChannelPosition *
|
GstAudioChannelPosition *
|
||||||
gst_audio_fixate_channel_positions (GstStructure *str);
|
gst_audio_fixate_channel_positions (GstStructure *str);
|
||||||
|
|
||||||
|
gboolean gst_audio_check_channel_positions (const GstAudioChannelPosition * pos, guint channels);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_AUDIO_MULTICHANNEL_H__ */
|
#endif /* __GST_AUDIO_MULTICHANNEL_H__ */
|
||||||
|
|
|
@ -73,6 +73,12 @@ GST_START_TEST (test_multichannel_checks)
|
||||||
|
|
||||||
s = gst_structure_new ("audio/x-raw-int", "channels", G_TYPE_INT, 2, NULL);
|
s = gst_structure_new ("audio/x-raw-int", "channels", G_TYPE_INT, 2, NULL);
|
||||||
|
|
||||||
|
/* check if the audio channel position checks work */
|
||||||
|
fail_if (gst_audio_check_channel_positions (pos_2_mixed, 2));
|
||||||
|
fail_unless (gst_audio_check_channel_positions (pos_2_none, 2));
|
||||||
|
fail_unless (gst_audio_check_channel_positions (pos_2_flr, 2));
|
||||||
|
fail_if (gst_audio_check_channel_positions (pos_2_frr, 2));
|
||||||
|
|
||||||
/* this should not work and issue a warning: FRONT_MONO + NONE */
|
/* this should not work and issue a warning: FRONT_MONO + NONE */
|
||||||
_gst_check_expecting_log = TRUE;
|
_gst_check_expecting_log = TRUE;
|
||||||
gst_audio_set_channel_positions (s, pos_2_mixed);
|
gst_audio_set_channel_positions (s, pos_2_mixed);
|
||||||
|
@ -121,8 +127,11 @@ GST_END_TEST;
|
||||||
GST_START_TEST (test_buffer_clipping_time)
|
GST_START_TEST (test_buffer_clipping_time)
|
||||||
{
|
{
|
||||||
GstSegment s;
|
GstSegment s;
|
||||||
|
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
/* Clip start and end */
|
/* Clip start and end */
|
||||||
|
@ -302,8 +311,11 @@ GST_END_TEST;
|
||||||
GST_START_TEST (test_buffer_clipping_samples)
|
GST_START_TEST (test_buffer_clipping_samples)
|
||||||
{
|
{
|
||||||
GstSegment s;
|
GstSegment s;
|
||||||
|
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
/* Clip start and end */
|
/* Clip start and end */
|
||||||
|
@ -516,6 +528,7 @@ static Suite *
|
||||||
audio_suite (void)
|
audio_suite (void)
|
||||||
{
|
{
|
||||||
Suite *s = suite_create ("audio support library");
|
Suite *s = suite_create ("audio support library");
|
||||||
|
|
||||||
TCase *tc_chain = tcase_create ("general");
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
|
@ -533,6 +546,7 @@ main (int argc, char **argv)
|
||||||
int nf;
|
int nf;
|
||||||
|
|
||||||
Suite *s = audio_suite ();
|
Suite *s = audio_suite ();
|
||||||
|
|
||||||
SRunner *sr = srunner_create (s);
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
gst_check_init (&argc, &argv);
|
gst_check_init (&argc, &argv);
|
||||||
|
|
Loading…
Reference in a new issue