summaryrefslogtreecommitdiffstats
path: root/ext/audiofile
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
committerDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
commitb144bc6c58979f49a6e8e04a04a65f771247297a (patch)
tree648bc437ca5562bc7c67224ad71ef90dfacc12d1 /ext/audiofile
parent2309d726b7b0c37dbd9c57c653e2053ec6258ac8 (diff)
downloadgst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.gz
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.bz2
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.zip
Merge CAPS branch
Original commit message from CVS: Merge CAPS branch
Diffstat (limited to 'ext/audiofile')
-rw-r--r--ext/audiofile/gstafparse.c83
-rw-r--r--ext/audiofile/gstafsink.c53
-rw-r--r--ext/audiofile/gstafsrc.c48
3 files changed, 83 insertions, 101 deletions
diff --git a/ext/audiofile/gstafparse.c b/ext/audiofile/gstafparse.c
index 6df1ca2e..f61d64f4 100644
--- a/ext/audiofile/gstafparse.c
+++ b/ext/audiofile/gstafparse.c
@@ -50,42 +50,34 @@ enum {
};
/* added a src factory function to force audio/raw MIME type */
-GST_PAD_TEMPLATE_FACTORY (afparse_src_factory,
+static GstStaticPadTemplate afparse_src_factory =
+GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "audiofile_src",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (TRUE), GST_PROPS_BOOLEAN (FALSE)),
- "width", GST_PROPS_INT_RANGE (8, 16),
- "depth", GST_PROPS_INT_RANGE (8, 16),
- "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),
- "channels", GST_PROPS_INT_RANGE (1, 2)
+ GST_STATIC_CAPS (
+ "audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]"
)
-)
+);
-GST_PAD_TEMPLATE_FACTORY (afparse_sink_factory,
+static GstStaticPadTemplate afparse_sink_factory =
+GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "afparse_sink_aiff",
- "audio/x-aiff",
- NULL
- ),
- GST_CAPS_NEW (
- "afparse_sink_wav",
- "audio/x-wav",
- NULL
- ),
- GST_CAPS_NEW (
- "afparse_sink_snd",
- "audio/x-au",
- NULL
+ GST_STATIC_CAPS (
+ "audio/x-aiff; "
+ "audio/x-wav; "
+ "audio/x-au"
)
-)
+);
static void gst_afparse_base_init (gpointer g_class);
static void gst_afparse_class_init(GstAFParseClass *klass);
@@ -131,8 +123,10 @@ gst_afparse_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afparse_src_factory));
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afparse_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&afparse_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&afparse_sink_factory));
gst_element_class_set_details (element_class, &afparse_details);
}
@@ -154,10 +148,12 @@ gst_afparse_class_init (GstAFParseClass *klass)
static void
gst_afparse_init (GstAFParse *afparse)
{
- afparse->srcpad = gst_pad_new_from_template (afparse_src_factory (), "src");
+ afparse->srcpad = gst_pad_new_from_template (
+ gst_element_get_pad_template (GST_ELEMENT (afparse), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);
- afparse->sinkpad = gst_pad_new_from_template (afparse_sink_factory (), "sink");
+ afparse->sinkpad = gst_pad_new_from_template (
+ gst_element_get_pad_template (GST_ELEMENT (afparse), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);
@@ -191,7 +187,6 @@ gst_afparse_loop(GstElement *element)
{
GstAFParse *afparse;
GstBuffer *buf;
- GstBufferPool *bufpool;
gint numframes = 0, frames_to_bytes, frames_per_read, bytes_per_read;
guint8 *data;
gboolean bypass_afread = TRUE;
@@ -230,7 +225,6 @@ gst_afparse_loop(GstElement *element)
frames_per_read = afparse->frames_per_read;
bytes_per_read = frames_per_read * frames_to_bytes;
- bufpool = gst_buffer_pool_get_default (bytes_per_read, 8);
afSeekFrame(afparse->file, AF_DEFAULT_TRACK, 0);
if (bypass_afread){
@@ -269,7 +263,7 @@ gst_afparse_loop(GstElement *element)
}
else {
do {
- buf = gst_buffer_new_from_pool (bufpool, 0, 0);
+ buf = gst_buffer_new_and_alloc (bytes_per_read);
GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
data = GST_BUFFER_DATA(buf);
numframes = afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
@@ -290,7 +284,6 @@ gst_afparse_loop(GstElement *element)
while (TRUE);
}
gst_afparse_close_file (afparse);
- gst_buffer_pool_unref(bufpool);
gst_bytestream_destroy ((GstByteStream*) afparse->vfile->closure);
@@ -389,17 +382,15 @@ gst_afparse_open_file (GstAFParse *afparse)
/* set caps on src */
/*FIXME: add all the possible formats, especially float ! */
gst_pad_try_set_caps (afparse->srcpad,
- GST_CAPS_NEW (
- "af_src",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */
- "signed", GST_PROPS_BOOLEAN (afparse->is_signed),
- "width", GST_PROPS_INT (afparse->width),
- "depth", GST_PROPS_INT (afparse->width),
- "rate", GST_PROPS_INT (afparse->rate),
- "channels", GST_PROPS_INT (afparse->channels)
- )
- );
+ gst_caps_new_simple (
+ "audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, afparse->is_signed,
+ "width", G_TYPE_INT, afparse->width,
+ "depth", G_TYPE_INT, afparse->width,
+ "rate", G_TYPE_INT, afparse->rate,
+ "channels", G_TYPE_INT, afparse->channels,
+ NULL));
GST_FLAG_SET (afparse, GST_AFPARSE_OPEN);
diff --git a/ext/audiofile/gstafsink.c b/ext/audiofile/gstafsink.c
index efe242d4..5b6b702e 100644
--- a/ext/audiofile/gstafsink.c
+++ b/ext/audiofile/gstafsink.c
@@ -52,22 +52,19 @@ enum {
/* added a sink factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
-GST_PAD_TEMPLATE_FACTORY (afsink_sink_factory,
+static GstStaticPadTemplate afsink_sink_factory =
+GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "audiofile_sink",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_LIST (
- GST_PROPS_BOOLEAN (TRUE),
- GST_PROPS_BOOLEAN (FALSE)
- ),
- "width", GST_PROPS_INT_RANGE (8, 16),
- "depth", GST_PROPS_INT_RANGE (8, 16),
- "rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/
- "channels", GST_PROPS_INT_RANGE (1, 2)
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]"
)
);
@@ -143,7 +140,8 @@ gst_afsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afsink_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&afsink_sink_factory));
gst_element_class_set_details (element_class, &afsink_details);
}
@@ -188,7 +186,7 @@ gst_afsink_init (GstAFSink *afsink)
/* GstPad *pad; this is now done in the struct */
afsink->sinkpad = gst_pad_new_from_template (
- GST_PAD_TEMPLATE_GET (afsink_sink_factory), "sink");
+ gst_element_get_pad_template (GST_ELEMENT (afsink), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afsink), afsink->sinkpad);
gst_pad_set_chain_function (afsink->sinkpad, gst_afsink_chain);
@@ -284,7 +282,8 @@ static gboolean
gst_afsink_open_file (GstAFSink *sink)
{
AFfilesetup outfilesetup;
- GstCaps *caps;
+ const GstCaps *caps;
+ GstStructure *structure;
int sample_format; /* audiofile's sample format, look in audiofile.h */
int byte_order = 0; /* audiofile's byte order defines */
@@ -301,22 +300,18 @@ gst_afsink_open_file (GstAFSink *sink)
*/
/* get the audio parameters */
- caps = NULL;
g_return_val_if_fail (GST_IS_PAD (sink->sinkpad), FALSE);
caps = GST_PAD_CAPS (sink->sinkpad);
- if (caps == NULL)
- {
- /* FIXME : Please change this to a better warning method ! */
- printf ("WARNING: gstafsink chain : Could not get caps of pad !\n");
- }
- else
- {
- gst_caps_get_int (caps, "channels", &sink->channels);
- gst_caps_get_int (caps, "width", &sink->width);
- gst_caps_get_int (caps, "rate", &sink->rate);
- gst_caps_get_boolean (caps, "signed", &sink->is_signed);
- gst_caps_get_int (caps, "endianness", &sink->endianness_data);
+ if (caps == NULL) {
+ g_critical ("gstafsink chain : Could not get caps of pad !\n");
+ } else {
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "channels", &sink->channels);
+ gst_structure_get_int (structure, "width", &sink->width);
+ gst_structure_get_int (structure, "rate", &sink->rate);
+ gst_structure_get_boolean (structure, "signed", &sink->is_signed);
+ gst_structure_get_int (structure, "endianness", &sink->endianness_data);
}
GST_DEBUG ("channels %d, width %d, rate %d, signed %s",
sink->channels, sink->width, sink->rate,
diff --git a/ext/audiofile/gstafsrc.c b/ext/audiofile/gstafsrc.c
index 13e228fc..0520463d 100644
--- a/ext/audiofile/gstafsrc.c
+++ b/ext/audiofile/gstafsrc.c
@@ -51,22 +51,19 @@ enum {
/* added a src factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
-GST_PAD_TEMPLATE_FACTORY (afsrc_src_factory,
+static GstStaticPadTemplate afsrc_src_factory =
+GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "audiofile_src",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_LIST (
- GST_PROPS_BOOLEAN (TRUE),
- GST_PROPS_BOOLEAN (FALSE)
- ),
- "width", GST_PROPS_INT_RANGE (8, 16),
- "depth", GST_PROPS_INT_RANGE (8, 16),
- "rate", GST_PROPS_INT_RANGE (4000, 48000), /*FIXME*/
- "channels", GST_PROPS_INT_RANGE (1, 2)
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]"
)
);
@@ -142,7 +139,8 @@ gst_afsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (afsrc_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&afsrc_src_factory));
gst_element_class_set_details (element_class, &afsrc_details);
}
@@ -178,7 +176,8 @@ static void
gst_afsrc_init (GstAFSrc *afsrc)
{
/* no need for a template, caps are set based on file, right ? */
- afsrc->srcpad = gst_pad_new_from_template (afsrc_src_factory (), "src");
+ afsrc->srcpad = gst_pad_new_from_template (
+ gst_element_get_pad_template (GST_ELEMENT (afsrc), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afsrc), afsrc->srcpad);
gst_pad_set_get_function (afsrc->srcpad, gst_afsrc_get);
@@ -342,17 +341,14 @@ gst_afsrc_open_file (GstAFSrc *src)
/* set caps on src */
/*FIXME: add all the possible formats, especially float ! */
gst_pad_try_set_caps (src->srcpad,
- GST_CAPS_NEW (
- "af_src",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */
- "signed", GST_PROPS_BOOLEAN (src->is_signed),
- "width", GST_PROPS_INT (src->width),
- "depth", GST_PROPS_INT (src->width),
- "rate", GST_PROPS_INT (src->rate),
- "channels", GST_PROPS_INT (src->channels)
- )
- );
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, src->is_signed,
+ "width", G_TYPE_INT, src->width,
+ "depth", G_TYPE_INT, src->width,
+ "rate", G_TYPE_INT, src->rate,
+ "channels", G_TYPE_INT, src->channels,
+ NULL));
GST_FLAG_SET (src, GST_AFSRC_OPEN);