From 7f512363462ffc63c810efe6474a9e1c3e20d860 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 9 Dec 2011 10:50:18 +0100 Subject: [PATCH] law: fix negotiation --- gst/law/Makefile.am | 10 ++++++---- gst/law/alaw-decode.c | 28 +++++++++++++++------------- gst/law/alaw-encode.c | 21 +++++++++++++-------- gst/law/alaw.c | 12 ++++-------- gst/law/mulaw-decode.c | 22 ++++++++++++---------- gst/law/mulaw-encode.c | 23 +++++++++++++++-------- 6 files changed, 65 insertions(+), 51 deletions(-) diff --git a/gst/law/Makefile.am b/gst/law/Makefile.am index 16bff25..158a998 100644 --- a/gst/law/Makefile.am +++ b/gst/law/Makefile.am @@ -1,14 +1,16 @@ plugin_LTLIBRARIES = libgstalaw.la libgstmulaw.la libgstalaw_la_SOURCES = alaw-encode.c alaw-decode.c alaw.c -libgstalaw_la_CFLAGS = $(GST_CFLAGS) -libgstalaw_la_LIBADD = $(GST_LIBS) +libgstalaw_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) +libgstalaw_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) \ + $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) libgstalaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstalaw_la_LIBTOOLFLAGS = --tag=disable-static libgstmulaw_la_SOURCES = mulaw-encode.c mulaw-conversion.c mulaw-decode.c mulaw.c -libgstmulaw_la_CFLAGS = $(GST_CFLAGS) -libgstmulaw_la_LIBADD = $(GST_LIBS) +libgstmulaw_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) +libgstmulaw_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) \ + $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) libgstmulaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmulaw_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c index 4d7d7bd..f88bec8 100644 --- a/gst/law/alaw-decode.c +++ b/gst/law/alaw-decode.c @@ -26,6 +26,8 @@ #include "config.h" #endif +#include + #include "alaw-decode.h" extern GstStaticPadTemplate alaw_dec_src_factory; @@ -129,11 +131,8 @@ gst_alaw_dec_setcaps (GstALawDec * alawdec, GstCaps * caps) if (!ret) return FALSE; - outcaps = gst_caps_new_simple ("audio/x-raw-int", - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, + outcaps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (S16), "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); ret = gst_pad_set_caps (alawdec->srcpad, outcaps); @@ -161,14 +160,14 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter) /* figure out the name of the caps we are going to return */ if (pad == alawdec->srcpad) { - name = "audio/x-raw-int"; + name = "audio/x-raw"; 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_query_caps (otherpad, filter); + othercaps = gst_pad_peer_query_caps (otherpad, NULL); /* get the template caps to make sure we return something acceptable */ templ = gst_pad_get_pad_template_caps (pad); @@ -188,14 +187,11 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter) if (pad == alawdec->sinkpad) { /* remove the fields we don't want */ - gst_structure_remove_fields (structure, "width", "depth", "endianness", - "signed", NULL); + gst_structure_remove_fields (structure, "format", 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); + gst_structure_set (structure, "format", G_TYPE_STRING, + GST_AUDIO_NE (S16), NULL); } } /* filter against the allowed caps of the pad to return our result */ @@ -205,7 +201,13 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter) /* there was no peer, return the template caps */ result = gst_caps_copy (templ); } + if (filter && result) { + GstCaps *temp; + temp = gst_caps_intersect (result, filter); + gst_caps_unref (result); + result = temp; + } return result; } diff --git a/gst/law/alaw-encode.c b/gst/law/alaw-encode.c index a115534..208e533 100644 --- a/gst/law/alaw-encode.c +++ b/gst/law/alaw-encode.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include #include "alaw-encode.h" GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug); @@ -316,11 +317,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter) name = "audio/x-alaw"; otherpad = alawenc->sinkpad; } else { - name = "audio/x-raw-int"; + name = "audio/x-raw"; otherpad = alawenc->srcpad; } /* get caps from the peer, this can return NULL when there is no peer */ - othercaps = gst_pad_peer_query_caps (otherpad, filter); + othercaps = gst_pad_peer_query_caps (otherpad, NULL); /* get the template caps to make sure we return something acceptable */ templ = gst_pad_get_pad_template_caps (pad); @@ -340,14 +341,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter) if (pad == alawenc->srcpad) { /* remove the fields we don't want */ - gst_structure_remove_fields (structure, "width", "depth", "endianness", - "signed", NULL); + gst_structure_remove_fields (structure, "format", 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); + gst_structure_set (structure, "format", G_TYPE_STRING, + GST_AUDIO_NE (S16), NULL); } } /* filter against the allowed caps of the pad to return our result */ @@ -357,6 +355,13 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter) /* there was no peer, return the template caps */ result = gst_caps_copy (templ); } + if (filter && result) { + GstCaps *temp; + + temp = gst_caps_intersect (result, filter); + gst_caps_unref (result); + result = temp; + } return result; } diff --git a/gst/law/alaw.c b/gst/law/alaw.c index 9e34205..5d9d8f7 100644 --- a/gst/law/alaw.c +++ b/gst/law/alaw.c @@ -20,20 +20,16 @@ #include "config.h" #endif +#include + #include "alaw-encode.h" #include "alaw-decode.h" -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define INT_FORMAT "S16LE" -#else -#define INT_FORMAT "S16BE" -#endif - GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw, " - "format = (string) " INT_FORMAT ", " + "format = (string) " GST_AUDIO_NE (S16) ", " "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]") ); @@ -48,7 +44,7 @@ GstStaticPadTemplate alaw_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw, " - "format = (string) " INT_FORMAT ", " + "format = (string) " GST_AUDIO_NE (S16) ", " "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]") ); diff --git a/gst/law/mulaw-decode.c b/gst/law/mulaw-decode.c index e5fb33d..d98390d 100644 --- a/gst/law/mulaw-decode.c +++ b/gst/law/mulaw-decode.c @@ -26,16 +26,11 @@ #include "config.h" #endif #include +#include #include "mulaw-decode.h" #include "mulaw-conversion.h" -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define INT_FORMAT "S16LE" -#else -#define INT_FORMAT "S16BE" -#endif - extern GstStaticPadTemplate mulaw_dec_src_factory; extern GstStaticPadTemplate mulaw_dec_sink_factory; @@ -77,7 +72,7 @@ mulawdec_setcaps (GstMuLawDec * mulawdec, GstCaps * caps) return FALSE; outcaps = gst_caps_new_simple ("audio/x-raw", - "format", G_TYPE_STRING, INT_FORMAT, + "format", G_TYPE_STRING, GST_AUDIO_NE (S16), "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); ret = gst_pad_set_caps (mulawdec->srcpad, outcaps); gst_caps_unref (outcaps); @@ -111,7 +106,7 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter) otherpad = mulawdec->srcpad; } /* get caps from the peer, this can return NULL when there is no peer */ - othercaps = gst_pad_peer_query_caps (otherpad, filter); + othercaps = gst_pad_peer_query_caps (otherpad, NULL); /* get the template caps to make sure we return something acceptable */ templ = gst_pad_get_pad_template_caps (pad); @@ -134,8 +129,8 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter) gst_structure_remove_fields (structure, "format", NULL); } else { /* add fixed fields */ - gst_structure_set (structure, "format", G_TYPE_STRING, INT_FORMAT, - NULL); + gst_structure_set (structure, "format", G_TYPE_STRING, + GST_AUDIO_NE (S16), NULL); } } /* filter against the allowed caps of the pad to return our result */ @@ -145,6 +140,13 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter) /* there was no peer, return the template caps */ result = gst_caps_copy (templ); } + if (filter && result) { + GstCaps *temp; + + temp = gst_caps_intersect (result, filter); + gst_caps_unref (result); + result = temp; + } return result; } diff --git a/gst/law/mulaw-encode.c b/gst/law/mulaw-encode.c index 7517f62..feff2b5 100644 --- a/gst/law/mulaw-encode.c +++ b/gst/law/mulaw-encode.c @@ -26,6 +26,8 @@ #include "config.h" #endif #include +#include + #include "mulaw-encode.h" #include "mulaw-conversion.h" @@ -71,11 +73,11 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter) name = "audio/x-mulaw"; otherpad = mulawenc->sinkpad; } else { - name = "audio/x-raw-int"; + name = "audio/x-raw"; otherpad = mulawenc->srcpad; } /* get caps from the peer, this can return NULL when there is no peer */ - othercaps = gst_pad_peer_query_caps (otherpad, filter); + othercaps = gst_pad_peer_query_caps (otherpad, NULL); /* get the template caps to make sure we return something acceptable */ templ = gst_pad_get_pad_template_caps (pad); @@ -95,14 +97,11 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter) if (pad == mulawenc->srcpad) { /* remove the fields we don't want */ - gst_structure_remove_fields (structure, "width", "depth", "endianness", - "signed", NULL); + gst_structure_remove_fields (structure, "format", 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); + gst_structure_set (structure, "format", G_TYPE_STRING, + GST_AUDIO_NE (S16), NULL); } } /* filter against the allowed caps of the pad to return our result */ @@ -112,6 +111,14 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter) /* there was no peer, return the template caps */ result = gst_caps_copy (templ); } + if (filter && result) { + GstCaps *temp; + + temp = gst_caps_intersect (result, filter); + gst_caps_unref (result); + result = temp; + } + return result; } -- 2.7.4