mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
adding structure setters matching the templates for audio
Original commit message from CVS: adding structure setters matching the templates for audio
This commit is contained in:
parent
bb768f388e
commit
b2e8f0ecfd
3 changed files with 98 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
2004-01-12 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst-libs/gst/audio/audio.c: (_gst_audio_structure_set_list),
|
||||
(gst_audio_structure_set_int):
|
||||
* gst-libs/gst/audio/audio.h:
|
||||
add helper functions for _getcaps matching the standard audio
|
||||
templates
|
||||
|
||||
2004-01-12 David Schleef <ds@schleef.org>
|
||||
|
||||
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_link):
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "audio.h"
|
||||
|
||||
#include <gst/gststructure.h>
|
||||
|
||||
int
|
||||
gst_audio_frame_byte_size (GstPad* pad)
|
||||
{
|
||||
|
@ -185,6 +187,81 @@ gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* _getcaps helper functions
|
||||
* sets structure fields to default for audio type
|
||||
* flag determines which structure fields to set to default
|
||||
* keep these functions in sync with the templates in audio.h
|
||||
*/
|
||||
|
||||
/* private helper function
|
||||
* sets a list on the structure
|
||||
* pass in structure, fieldname for the list, type of the list values,
|
||||
* number of list values, and each of the values, terminating with NULL
|
||||
*/
|
||||
static void
|
||||
_gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
|
||||
GType type, int number, ...)
|
||||
{
|
||||
va_list varargs;
|
||||
GValue value = { 0 };
|
||||
GArray *array;
|
||||
int j;
|
||||
|
||||
g_return_if_fail (structure != NULL);
|
||||
|
||||
g_value_init (&value, GST_TYPE_LIST);
|
||||
array = g_value_peek_pointer (&value);
|
||||
|
||||
va_start (varargs, number);
|
||||
|
||||
for (j = 0; j < number; ++j)
|
||||
{
|
||||
int i;
|
||||
gboolean b;
|
||||
|
||||
GValue list_value = { 0 };
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case G_TYPE_INT:
|
||||
i = va_arg (varargs, int);
|
||||
g_value_init (&list_value, G_TYPE_INT);
|
||||
g_value_set_int (&list_value, i);
|
||||
break;
|
||||
case G_TYPE_BOOLEAN:
|
||||
b = va_arg (varargs, gboolean);
|
||||
g_value_init (&list_value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (&list_value, b);
|
||||
break;
|
||||
default:
|
||||
g_warning ("_gst_audio_structure_set_list: LIST of given type not implemented.");
|
||||
}
|
||||
g_array_append_val (array, list_value);
|
||||
|
||||
}
|
||||
gst_structure_set_value (structure, fieldname, &value);
|
||||
va_end (varargs);
|
||||
}
|
||||
|
||||
void
|
||||
gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag)
|
||||
{
|
||||
if (flag & GST_AUDIO_FIELD_RATE)
|
||||
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_CHANNELS)
|
||||
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_ENDIANNESS)
|
||||
_gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2, G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_WIDTH)
|
||||
_gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_DEPTH)
|
||||
gst_structure_set (structure, "depth", GST_TYPE_INT_RANGE, 1, 32, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_SIGNED)
|
||||
_gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE, FALSE, NULL);
|
||||
if (flag & GST_AUDIO_FIELD_BUFFER_FRAMES)
|
||||
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
{
|
||||
|
|
|
@ -111,5 +111,18 @@ long gst_audio_highest_sample_value (GstPad* pad);
|
|||
/* check if the buffer size is a whole multiple of the frame size */
|
||||
gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
|
||||
|
||||
/* functions useful for _getcaps functions */
|
||||
typedef enum {
|
||||
GST_AUDIO_FIELD_RATE = (1 << 0),
|
||||
GST_AUDIO_FIELD_CHANNELS = (1 << 1),
|
||||
GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
|
||||
GST_AUDIO_FIELD_WIDTH = (1 << 3),
|
||||
GST_AUDIO_FIELD_DEPTH = (1 << 4),
|
||||
GST_AUDIO_FIELD_SIGNED = (1 << 5),
|
||||
GST_AUDIO_FIELD_BUFFER_FRAMES = (1 << 6)
|
||||
} GstAudioFieldFlag;
|
||||
|
||||
void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue