summaryrefslogtreecommitdiffstats
path: root/gst/law/alaw-decode.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-06-30 15:59:20 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-06-30 15:59:20 +0200
commit89f0c37c9fc1debc75b28b9fc627a25c3769583b (patch)
tree039b26b4bb37a024dab9bc43c7c8171386c6adb8 /gst/law/alaw-decode.c
parent6d0007372b317b049f475fab0df0ea03195332dc (diff)
law: fix caps and negotiation
Fix the caps to include the depth (instead of width twice) in the caps of audio/x-raw-int. Fix negotiation to not only copy the rate/channels of the first structure.
Diffstat (limited to 'gst/law/alaw-decode.c')
-rw-r--r--gst/law/alaw-decode.c73
1 files changed, 42 insertions, 31 deletions
diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c
index ac4c6df5..d7b6f2f2 100644
--- a/gst/law/alaw-decode.c
+++ b/gst/law/alaw-decode.c
@@ -150,50 +150,61 @@ gst_alaw_dec_getcaps (GstPad * pad)
{
GstALawDec *alawdec;
GstPad *otherpad;
- GstCaps *base_caps, *othercaps;
+ GstCaps *othercaps, *result;
+ const GstCaps *templ;
+ gchar *name;
+ gint i;
alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
- base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
-
+ /* figure out the name of the caps we are going to return */
if (pad == alawdec->srcpad) {
+ name = "audio/x-raw-int";
otherpad = alawdec->sinkpad;
} else {
+ name = "audio/x-alaw";
otherpad = alawdec->srcpad;
}
+ /* get caps from the peer, this can return NULL when there is no peer */
othercaps = gst_pad_peer_get_caps (otherpad);
- if (othercaps) {
- GstStructure *structure;
- const GValue *orate, *ochans;
- const GValue *rate, *chans;
- GValue irate = { 0 };
- GValue ichans = { 0 };
-
- if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
- goto done;
-
- structure = gst_caps_get_structure (othercaps, 0);
- orate = gst_structure_get_value (structure, "rate");
- ochans = gst_structure_get_value (structure, "channels");
-
- structure = gst_caps_get_structure (base_caps, 0);
- rate = gst_structure_get_value (structure, "rate");
- chans = gst_structure_get_value (structure, "channels");
-
- if (orate) {
- gst_value_intersect (&irate, orate, rate);
- gst_structure_set_value (structure, "rate", &irate);
- }
- if (ochans) {
- gst_value_intersect (&ichans, ochans, chans);
- gst_structure_set_value (structure, "channels", &ichans);
- }
+ /* get the template caps to make sure we return something acceptable */
+ templ = gst_pad_get_pad_template_caps (pad);
- done:
+ if (othercaps) {
+ /* there was a peer */
+ othercaps = gst_caps_make_writable (othercaps);
+
+ /* go through the caps and remove the fields we don't want */
+ for (i = 0; i < gst_caps_get_size (othercaps); i++) {
+ GstStructure *structure;
+
+ structure = gst_caps_get_structure (othercaps, i);
+
+ /* adjust the name */
+ gst_structure_set_name (structure, name);
+
+ if (pad == alawdec->sinkpad) {
+ /* remove the fields we don't want */
+ gst_structure_remove_fields (structure, "width", "depth", "endianness",
+ "signed", NULL);
+ } else {
+ /* add fixed fields */
+ gst_structure_set (structure, "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+ }
+ }
+ /* filter against the allowed caps of the pad to return our result */
+ result = gst_caps_intersect (othercaps, templ);
gst_caps_unref (othercaps);
+ } else {
+ /* there was no peer, return the template caps */
+ result = gst_caps_copy (templ);
}
- return base_caps;
+
+ return result;
}
static void