summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-04-19 02:00:24 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2004-04-19 02:00:24 +0000
commit47e43d5a7e45a73ad2f64fbd924dc992ca3ede4d (patch)
treeb7e56359678223175b86592c1b27657a35a3a743
parentf3acf1d3eb081efba18de0dc0ee408994109840c (diff)
downloadgst-plugins-bad-47e43d5a7e45a73ad2f64fbd924dc992ca3ede4d.tar.gz
gst-plugins-bad-47e43d5a7e45a73ad2f64fbd924dc992ca3ede4d.tar.bz2
gst-plugins-bad-47e43d5a7e45a73ad2f64fbd924dc992ca3ede4d.zip
ext/gsm/gstgsmdec.c: Fix capsnego, simplify chain function slightly.
Original commit message from CVS: * ext/gsm/gstgsmdec.c: (gst_gsmdec_init), (gst_gsmdec_getcaps), (gst_gsmdec_link), (gst_gsmdec_chain): Fix capsnego, simplify chain function slightly. * gst/qtdemux/qtdemux.c: (qtdemux_audio_caps): Add GSM.
-rw-r--r--ChangeLog8
-rw-r--r--ext/gsm/gstgsmdec.c76
-rw-r--r--gst/qtdemux/qtdemux.c4
3 files changed, 64 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index ee0d9d79..d8423b1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2004-04-18 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * ext/gsm/gstgsmdec.c: (gst_gsmdec_init), (gst_gsmdec_getcaps),
+ (gst_gsmdec_link), (gst_gsmdec_chain):
+ Fix capsnego, simplify chain function slightly.
+ * gst/qtdemux/qtdemux.c: (qtdemux_audio_caps):
+ Add GSM.
+
+2004-04-18 Ronald Bultje <rbultje@ronald.bitfreak.net>
+
* gst/wavparse/gstwavparse.c: (gst_wavparse_init),
(gst_wavparse_destroy_sourcepad), (gst_wavparse_create_sourcepad),
(gst_wavparse_parse_fmt), (gst_wavparse_change_state):
diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c
index 1b845a64..33c470e9 100644
--- a/ext/gsm/gstgsmdec.c
+++ b/ext/gsm/gstgsmdec.c
@@ -51,8 +51,8 @@ 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,
- const GstCaps * caps);
+static GstCaps *gst_gsmdec_getcaps (GstPad * pad);
+static GstPadLinkReturn gst_gsmdec_link (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
@@ -133,41 +133,77 @@ gst_gsmdec_init (GstGSMDec * gsmdec)
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);
+ gst_pad_set_getcaps_function (gsmdec->sinkpad, gst_gsmdec_getcaps);
+ gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_link);
+ gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gsmdec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gsmdec_src_template), "src");
+ gst_pad_set_getcaps_function (gsmdec->srcpad, gst_gsmdec_getcaps);
+ gst_pad_set_link_function (gsmdec->srcpad, gst_gsmdec_link);
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
gsmdec->bufsize = 0;
}
+static GstCaps *
+gst_gsmdec_getcaps (GstPad * pad)
+{
+ GstGSMDec *gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
+ const GValue *rate_value;
+ GstPad *otherpad;
+ GstCaps *othercaps, *basecaps;
+
+ if (pad == gsmdec->srcpad) {
+ otherpad = gsmdec->sinkpad;
+ basecaps = 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, NULL);
+ } else {
+ otherpad = gsmdec->srcpad;
+ basecaps = gst_caps_new_simple ("audio/x-gsm", NULL);
+ }
+
+ othercaps = gst_pad_get_allowed_caps (otherpad);
+ rate_value = gst_structure_get_value (gst_caps_get_structure (othercaps,
+ 0), "rate");
+ gst_structure_set_value (gst_caps_get_structure (basecaps, 0), "rate",
+ rate_value);
+
+ return basecaps;
+}
+
static GstPadLinkReturn
-gst_gsmdec_sinkconnect (GstPad * pad, const GstCaps * caps)
+gst_gsmdec_link (GstPad * pad, const GstCaps * caps)
{
- GstGSMDec *gsmdec;
+ GstGSMDec *gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
+ GstPad *otherpad;
+ GstCaps *othercaps;
gint rate;
GstStructure *structure;
- gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
-
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_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;
+ if (pad == gsmdec->sinkpad) {
+ otherpad = gsmdec->srcpad;
+ othercaps = 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, NULL);
+ } else {
+ otherpad = gsmdec->sinkpad;
+ othercaps = gst_caps_new_simple ("audio/x-gsm", NULL);
}
- return GST_PAD_LINK_REFUSED;
+
+ gst_caps_set_simple (othercaps,
+ "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, 1, NULL);
+
+ return gst_pad_try_set_caps (otherpad, othercaps);
}
static void
@@ -211,12 +247,8 @@ gst_gsmdec_chain (GstPad * pad, GstData * _data)
while (size >= 33) {
GstBuffer *outbuf;
- outbuf = gst_buffer_new ();
- GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
- GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
-
+ outbuf = gst_buffer_new_and_alloc (160 * sizeof (gsm_signal));
gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
-
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
size -= 33;
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c
index 3303c6c9..21fe6284 100644
--- a/gst/qtdemux/qtdemux.c
+++ b/gst/qtdemux/qtdemux.c
@@ -2031,6 +2031,8 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, guint32 fourcc, const guint8 * data)
"bitrate", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 40),
"blocksize", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 44), NULL);
}
+ case GST_MAKE_FOURCC ('a', 'g', 's', 'm'):
+ return gst_caps_new_simple ("audio/x-gsm", NULL);
case GST_MAKE_FOURCC ('q', 't', 'v', 'r'):
/* ? */
case GST_MAKE_FOURCC ('Q', 'D', 'M', 'C'):
@@ -2039,8 +2041,6 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, guint32 fourcc, const guint8 * data)
/* IMA 4:1 */
case GST_MAKE_FOURCC ('Q', 'c', 'l', 'p'):
/* QUALCOMM PureVoice */
- case GST_MAKE_FOURCC ('a', 'g', 's', 'm'):
- /* ? */
default:
g_critical ("Don't know how to convert fourcc '" GST_FOURCC_FORMAT
"' to caps\n", GST_FOURCC_ARGS (fourcc));