summaryrefslogtreecommitdiffstats
path: root/ext/gsm
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/gsm
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/gsm')
-rw-r--r--ext/gsm/gstgsmdec.c93
-rw-r--r--ext/gsm/gstgsmenc.c100
2 files changed, 90 insertions, 103 deletions
diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c
index 095140c1..1359ce97 100644
--- a/ext/gsm/gstgsmdec.c
+++ b/ext/gsm/gstgsmdec.c
@@ -25,8 +25,6 @@
#include "gstgsmdec.h"
-static GstPadTemplate *gsmdec_src_template, *gsmdec_sink_template;
-
/* elementfactory information */
GstElementDetails gst_gsmdec_details = {
"GSM audio decoder",
@@ -51,7 +49,7 @@ static void gst_gsmdec_class_init (GstGSMDec *klass);
static void gst_gsmdec_init (GstGSMDec *gsmdec);
static void gst_gsmdec_chain (GstPad *pad, GstData *_data);
-static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps);
+static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
/*static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 }; */
@@ -77,39 +75,43 @@ gst_gsmdec_get_type(void) {
return gsmdec_type;
}
-GST_CAPS_FACTORY (gsm_caps_factory,
- GST_CAPS_NEW (
- "gsm_gsm",
- "audio/x-gsm",
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
- )
-)
-
-GST_CAPS_FACTORY (raw_caps_factory,
- GST_CAPS_NEW (
- "gsm_raw",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_BOOLEAN (TRUE),
- "width", GST_PROPS_INT (16),
- "depth", GST_PROPS_INT (16),
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
+static GstStaticPadTemplate gsmdec_sink_template =
+GST_STATIC_PAD_TEMPLATE (
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ "audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
+ )
+);
+
+static GstStaticPadTemplate gsmdec_src_template =
+GST_STATIC_PAD_TEMPLATE (
+ "src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ "audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
)
-)
+);
static void
gst_gsmdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gsmdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS, gsm_caps_factory(), NULL);
- gsmdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS, raw_caps_factory(), NULL);
- gst_element_class_add_pad_template (element_class, gsmdec_sink_template);
- gst_element_class_add_pad_template (element_class, gsmdec_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gsmdec_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gsmdec_src_template));
gst_element_class_set_details (element_class, &gst_gsmdec_details);
}
@@ -129,12 +131,14 @@ gst_gsmdec_init (GstGSMDec *gsmdec)
GST_DEBUG ("gst_gsmdec_init: initializing");
/* create the sink and src pads */
- gsmdec->sinkpad = gst_pad_new_from_template (gsmdec_sink_template, "sink");
+ gsmdec->sinkpad = gst_pad_new_from_template (
+ gst_static_pad_template_get (&gsmdec_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain);
gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_sinkconnect);
- gsmdec->srcpad = gst_pad_new_from_template (gsmdec_src_template, "src");
+ gsmdec->srcpad = gst_pad_new_from_template (
+ gst_static_pad_template_get (&gsmdec_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
@@ -142,29 +146,26 @@ gst_gsmdec_init (GstGSMDec *gsmdec)
}
static GstPadLinkReturn
-gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstGSMDec *gsmdec;
gint rate;
+ GstStructure *structure;
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
- gst_caps_get_int (caps, "rate", &rate);
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "rate", &rate);
if (gst_pad_try_set_caps (gsmdec->srcpad,
- GST_CAPS_NEW (
- "gsm_raw",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_BOOLEAN (TRUE),
- "width", GST_PROPS_INT (16),
- "depth", GST_PROPS_INT (16),
- "rate", GST_PROPS_INT (rate),
- "channels", GST_PROPS_INT (1)
- )) > 0)
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, rate,
+ "channels", G_TYPE_INT, 1,
+ NULL)) > 0)
{
return GST_PAD_LINK_OK;
}
diff --git a/ext/gsm/gstgsmenc.c b/ext/gsm/gstgsmenc.c
index d8949b54..a608fea0 100644
--- a/ext/gsm/gstgsmenc.c
+++ b/ext/gsm/gstgsmenc.c
@@ -25,8 +25,6 @@
#include "gstgsmenc.h"
-static GstPadTemplate *gsmenc_src_template, *gsmenc_sink_template;
-
/* elementfactory information */
GstElementDetails gst_gsmenc_details = {
"GSM audio encoder",
@@ -52,7 +50,7 @@ static void gst_gsmenc_class_init (GstGSMEnc *klass);
static void gst_gsmenc_init (GstGSMEnc *gsmenc);
static void gst_gsmenc_chain (GstPad *pad,GstData *_data);
-static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, GstCaps *caps);
+static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
static guint gst_gsmenc_signals[LAST_SIGNAL] = { 0 };
@@ -79,45 +77,43 @@ gst_gsmenc_get_type (void)
return gsmenc_type;
}
-GST_CAPS_FACTORY (gsm_caps_factory,
- GST_CAPS_NEW (
- "gsm_gsm",
- "audio/x-gsm",
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
+static GstStaticPadTemplate gsmenc_src_template =
+GST_STATIC_PAD_TEMPLATE (
+ "src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ "audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
)
-)
-
-GST_CAPS_FACTORY (raw_caps_factory,
- GST_CAPS_NEW (
- "gsm_raw",
- "audio/x-raw-int",
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "signed", GST_PROPS_BOOLEAN (TRUE),
- "width", GST_PROPS_INT (16),
- "depth", GST_PROPS_INT (16),
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
+);
+
+static GstStaticPadTemplate gsmenc_sink_template =
+GST_STATIC_PAD_TEMPLATE (
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (
+ "audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
)
-)
+);
static void
gst_gsmenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstCaps *raw_caps, *gsm_caps;
- raw_caps = GST_CAPS_GET (raw_caps_factory);
- gsm_caps = GST_CAPS_GET (gsm_caps_factory);
-
- gsmenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- raw_caps, NULL);
- gsmenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- gsm_caps, NULL);
- gst_element_class_add_pad_template (element_class, gsmenc_sink_template);
- gst_element_class_add_pad_template (element_class, gsmenc_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gsmenc_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gsmenc_src_template));
gst_element_class_set_details (element_class, &gst_gsmenc_details);
}
@@ -143,12 +139,14 @@ static void
gst_gsmenc_init (GstGSMEnc *gsmenc)
{
/* create the sink and src pads */
- gsmenc->sinkpad = gst_pad_new_from_template (gsmenc_sink_template, "sink");
+ gsmenc->sinkpad = gst_pad_new_from_template (
+ gst_static_pad_template_get (&gsmenc_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad);
gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain);
gst_pad_set_link_function (gsmenc->sinkpad, gst_gsmenc_sinkconnect);
- gsmenc->srcpad = gst_pad_new_from_template (gsmenc_src_template, "src");
+ gsmenc->srcpad = gst_pad_new_from_template (
+ gst_static_pad_template_get (&gsmenc_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad);
gsmenc->state = gsm_create ();
@@ -158,22 +156,20 @@ gst_gsmenc_init (GstGSMEnc *gsmenc)
}
static GstPadLinkReturn
-gst_gsmenc_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstGSMEnc *gsmenc;
+ GstStructure *structure;
gsmenc = GST_GSMENC (gst_pad_get_parent (pad));
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
- gst_caps_get_int (caps, "rate", &gsmenc->rate);
- if (gst_pad_try_set_caps (gsmenc->srcpad, GST_CAPS_NEW (
- "gsm_gsm",
- "audio/x-gsm",
- "rate", GST_PROPS_INT (gsmenc->rate),
- "channels", GST_PROPS_INT (1)
- )) > 0)
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "rate", &gsmenc->rate);
+ if (gst_pad_try_set_caps (gsmenc->srcpad,
+ gst_caps_new_simple("audio/x-gsm",
+ "rate", G_TYPE_INT, gsmenc->rate,
+ "channels", G_TYPE_INT, 1,
+ NULL)) > 0)
{
return GST_PAD_LINK_OK;
}
@@ -195,16 +191,6 @@ gst_gsmenc_chain (GstPad *pad, GstData *_data)
gsmenc = GST_GSMENC (GST_OBJECT_PARENT (pad));
- if (!GST_PAD_CAPS (gsmenc->srcpad)) {
- gst_pad_try_set_caps (gsmenc->srcpad,
- GST_CAPS_NEW (
- "gsm_enc",
- "audio/x-gsm",
- "rate", GST_PROPS_INT (gsmenc->rate),
- "channels", GST_PROPS_INT (1)
- ));
- }
-
data = (gsm_signal*) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf) / sizeof (gsm_signal);