summaryrefslogtreecommitdiffstats
path: root/ext/speex
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
commitce51f6173ca1c37d90f8e2e316d90316583d7755 (patch)
tree270b121765a11455f5bf8166b526d7ac336dc56c /ext/speex
parentf43f0a9fd781bafab689e46bd936af9cb5ed2690 (diff)
Merge CAPS branch
Original commit message from CVS: Merge CAPS branch
Diffstat (limited to 'ext/speex')
-rw-r--r--ext/speex/gstspeexdec.c87
-rw-r--r--ext/speex/gstspeexenc.c90
2 files changed, 81 insertions, 96 deletions
diff --git a/ext/speex/gstspeexdec.c b/ext/speex/gstspeexdec.c
index 7fd5dc53..5e249a73 100644
--- a/ext/speex/gstspeexdec.c
+++ b/ext/speex/gstspeexdec.c
@@ -51,7 +51,7 @@ static void gst_speexdec_class_init (GstSpeexDec *klass);
static void gst_speexdec_init (GstSpeexDec *speexdec);
static void gst_speexdec_chain (GstPad *pad, GstData *_data);
-static GstPadLinkReturn gst_speexdec_sinkconnect (GstPad *pad, GstCaps *caps);
+static GstPadLinkReturn gst_speexdec_sinkconnect (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
/*static guint gst_speexdec_signals[LAST_SIGNAL] = { 0 }; */
@@ -77,45 +77,41 @@ gst_speexdec_get_type(void) {
return speexdec_type;
}
-GST_CAPS_FACTORY (speex_caps_factory,
- GST_CAPS_NEW (
- "speex_speex",
- "audio/x-speex",
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
+static GstStaticPadTemplate speex_sink_template =
+GST_STATIC_PAD_TEMPLATE (
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-speex, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
)
-)
-
-GST_CAPS_FACTORY (raw_caps_factory,
- GST_CAPS_NEW (
- "speex_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 speex_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_speexdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstCaps *raw_caps, *speex_caps;
- raw_caps = GST_CAPS_GET (raw_caps_factory);
- speex_caps = GST_CAPS_GET (speex_caps_factory);
-
- speexdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- speex_caps, NULL);
- speexdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- raw_caps, NULL);
- gst_element_class_add_pad_template (element_class, speexdec_sink_template);
- gst_element_class_add_pad_template (element_class, speexdec_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&speex_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&speex_sink_template));
gst_element_class_set_details (element_class, &gst_speexdec_details);
}
@@ -147,29 +143,26 @@ gst_speexdec_init (GstSpeexDec *speexdec)
}
static GstPadLinkReturn
-gst_speexdec_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_speexdec_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstSpeexDec *speexdec;
gint rate;
+ GstStructure *structure;
speexdec = GST_SPEEXDEC (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 (speexdec->srcpad,
- GST_CAPS_NEW (
- "speex_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)
- )))
+ 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)))
{
return GST_PAD_LINK_OK;
}
diff --git a/ext/speex/gstspeexenc.c b/ext/speex/gstspeexenc.c
index c6be4aa7..14cee352 100644
--- a/ext/speex/gstspeexenc.c
+++ b/ext/speex/gstspeexenc.c
@@ -52,7 +52,7 @@ static void gst_speexenc_class_init (GstSpeexEnc *klass);
static void gst_speexenc_init (GstSpeexEnc *speexenc);
static void gst_speexenc_chain (GstPad *pad,GstData *_data);
-static GstPadLinkReturn gst_speexenc_sinkconnect (GstPad *pad, GstCaps *caps);
+static GstPadLinkReturn gst_speexenc_sinkconnect (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
static guint gst_speexenc_signals[LAST_SIGNAL] = { 0 };
@@ -79,45 +79,41 @@ gst_speexenc_get_type (void)
return speexenc_type;
}
-GST_CAPS_FACTORY (speex_caps_factory,
- GST_CAPS_NEW (
- "speex_speex",
- "audio/x-speex",
- "rate", GST_PROPS_INT_RANGE (1000, 48000),
- "channels", GST_PROPS_INT (1)
+static GstStaticPadTemplate speex_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"
)
-)
-
-GST_CAPS_FACTORY (raw_caps_factory,
- GST_CAPS_NEW (
- "speex_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 speex_src_template =
+GST_STATIC_PAD_TEMPLATE (
+ "src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-speex, "
+ "rate = (int) [ 1000, 48000 ], "
+ "channels = (int) 1"
)
-)
+);
static void
gst_speexenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstCaps *raw_caps, *speex_caps;
- raw_caps = GST_CAPS_GET (raw_caps_factory);
- speex_caps = GST_CAPS_GET (speex_caps_factory);
-
- speexenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- raw_caps, NULL);
- speexenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- speex_caps, NULL);
- gst_element_class_add_pad_template (element_class, speexenc_sink_template);
- gst_element_class_add_pad_template (element_class, speexenc_src_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&speex_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&speex_src_template));
gst_element_class_set_details (element_class, &gst_speexenc_details);
}
@@ -160,22 +156,20 @@ gst_speexenc_init (GstSpeexEnc *speexenc)
}
static GstPadLinkReturn
-gst_speexenc_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_speexenc_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstSpeexEnc *speexenc;
+ GstStructure *structure;
speexenc = GST_SPEEXENC (gst_pad_get_parent (pad));
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
- gst_caps_get_int (caps, "rate", &speexenc->rate);
- if (gst_pad_try_set_caps (speexenc->srcpad, GST_CAPS_NEW (
- "speex_speex",
- "audio/x-speex",
- "rate", GST_PROPS_INT (speexenc->rate),
- "channels", GST_PROPS_INT (1)
- )))
+ structure = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (structure, "rate", &speexenc->rate);
+ if (gst_pad_try_set_caps (speexenc->srcpad,
+ gst_caps_new_simple ("audio/x-speex",
+ "rate", G_TYPE_INT, speexenc->rate,
+ "channels", G_TYPE_INT, 1,
+ NULL)))
{
speex_init_header(&speexenc->header, speexenc->rate, 1, speexenc->mode);
speexenc->header.frames_per_packet = speexenc->n_packets;
@@ -211,12 +205,10 @@ gst_speexenc_chain (GstPad *pad, GstData *_data)
if (!GST_PAD_CAPS (speexenc->srcpad)) {
if (!gst_pad_try_set_caps (speexenc->srcpad,
- GST_CAPS_NEW (
- "speex_enc",
- "audio/x-speex",
- "rate", GST_PROPS_INT (speexenc->rate),
- "channels", GST_PROPS_INT (1)
- )))
+ gst_caps_new_simple ("audio/x-speex",
+ "rate", G_TYPE_INT, speexenc->rate,
+ "channels", G_TYPE_INT, 1,
+ NULL)))
{
gst_element_error (GST_ELEMENT (speexenc), "could not negotiate");
return;