law: fix negotiation

This commit is contained in:
Wim Taymans 2011-12-09 10:50:18 +01:00
parent 668e15598b
commit 7f51236346
6 changed files with 65 additions and 51 deletions

View file

@ -1,14 +1,16 @@
plugin_LTLIBRARIES = libgstalaw.la libgstmulaw.la plugin_LTLIBRARIES = libgstalaw.la libgstmulaw.la
libgstalaw_la_SOURCES = alaw-encode.c alaw-decode.c alaw.c libgstalaw_la_SOURCES = alaw-encode.c alaw-decode.c alaw.c
libgstalaw_la_CFLAGS = $(GST_CFLAGS) libgstalaw_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstalaw_la_LIBADD = $(GST_LIBS) libgstalaw_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) \
$(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR)
libgstalaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstalaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstalaw_la_LIBTOOLFLAGS = --tag=disable-static libgstalaw_la_LIBTOOLFLAGS = --tag=disable-static
libgstmulaw_la_SOURCES = mulaw-encode.c mulaw-conversion.c mulaw-decode.c mulaw.c libgstmulaw_la_SOURCES = mulaw-encode.c mulaw-conversion.c mulaw-decode.c mulaw.c
libgstmulaw_la_CFLAGS = $(GST_CFLAGS) libgstmulaw_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstmulaw_la_LIBADD = $(GST_LIBS) libgstmulaw_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) \
$(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR)
libgstmulaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstmulaw_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstmulaw_la_LIBTOOLFLAGS = --tag=disable-static libgstmulaw_la_LIBTOOLFLAGS = --tag=disable-static

View file

@ -26,6 +26,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/audio/audio.h>
#include "alaw-decode.h" #include "alaw-decode.h"
extern GstStaticPadTemplate alaw_dec_src_factory; extern GstStaticPadTemplate alaw_dec_src_factory;
@ -129,11 +131,8 @@ gst_alaw_dec_setcaps (GstALawDec * alawdec, GstCaps * caps)
if (!ret) if (!ret)
return FALSE; return FALSE;
outcaps = gst_caps_new_simple ("audio/x-raw-int", outcaps = gst_caps_new_simple ("audio/x-raw",
"width", G_TYPE_INT, 16, "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
"depth", G_TYPE_INT, 16,
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
ret = gst_pad_set_caps (alawdec->srcpad, outcaps); 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 */ /* figure out the name of the caps we are going to return */
if (pad == alawdec->srcpad) { if (pad == alawdec->srcpad) {
name = "audio/x-raw-int"; name = "audio/x-raw";
otherpad = alawdec->sinkpad; otherpad = alawdec->sinkpad;
} else { } else {
name = "audio/x-alaw"; name = "audio/x-alaw";
otherpad = alawdec->srcpad; otherpad = alawdec->srcpad;
} }
/* get caps from the peer, this can return NULL when there is no peer */ /* 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 */ /* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad); templ = gst_pad_get_pad_template_caps (pad);
@ -188,14 +187,11 @@ gst_alaw_dec_getcaps (GstPad * pad, GstCaps * filter)
if (pad == alawdec->sinkpad) { if (pad == alawdec->sinkpad) {
/* remove the fields we don't want */ /* remove the fields we don't want */
gst_structure_remove_fields (structure, "width", "depth", "endianness", gst_structure_remove_fields (structure, "format", NULL);
"signed", NULL);
} else { } else {
/* add fixed fields */ /* add fixed fields */
gst_structure_set (structure, "width", G_TYPE_INT, 16, gst_structure_set (structure, "format", G_TYPE_STRING,
"depth", G_TYPE_INT, 16, GST_AUDIO_NE (S16), NULL);
"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 */ /* 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 */ /* there was no peer, return the template caps */
result = gst_caps_copy (templ); result = gst_caps_copy (templ);
} }
if (filter && result) {
GstCaps *temp;
temp = gst_caps_intersect (result, filter);
gst_caps_unref (result);
result = temp;
}
return result; return result;
} }

View file

@ -26,6 +26,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/audio/audio.h>
#include "alaw-encode.h" #include "alaw-encode.h"
GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug); GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug);
@ -316,11 +317,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
name = "audio/x-alaw"; name = "audio/x-alaw";
otherpad = alawenc->sinkpad; otherpad = alawenc->sinkpad;
} else { } else {
name = "audio/x-raw-int"; name = "audio/x-raw";
otherpad = alawenc->srcpad; otherpad = alawenc->srcpad;
} }
/* get caps from the peer, this can return NULL when there is no peer */ /* 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 */ /* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad); templ = gst_pad_get_pad_template_caps (pad);
@ -340,14 +341,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
if (pad == alawenc->srcpad) { if (pad == alawenc->srcpad) {
/* remove the fields we don't want */ /* remove the fields we don't want */
gst_structure_remove_fields (structure, "width", "depth", "endianness", gst_structure_remove_fields (structure, "format", NULL);
"signed", NULL);
} else { } else {
/* add fixed fields */ /* add fixed fields */
gst_structure_set (structure, "width", G_TYPE_INT, 16, gst_structure_set (structure, "format", G_TYPE_STRING,
"depth", G_TYPE_INT, 16, GST_AUDIO_NE (S16), NULL);
"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 */ /* 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 */ /* there was no peer, return the template caps */
result = gst_caps_copy (templ); result = gst_caps_copy (templ);
} }
if (filter && result) {
GstCaps *temp;
temp = gst_caps_intersect (result, filter);
gst_caps_unref (result);
result = temp;
}
return result; return result;
} }

View file

@ -20,20 +20,16 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/audio/audio.h>
#include "alaw-encode.h" #include "alaw-encode.h"
#include "alaw-decode.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", GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, " GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", " "format = (string) " GST_AUDIO_NE (S16) ", "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]") "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_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, " GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " INT_FORMAT ", " "format = (string) " GST_AUDIO_NE (S16) ", "
"rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]") "rate = (int) [ 8000, 192000 ], " "channels = (int) [ 1, 2 ]")
); );

View file

@ -26,16 +26,11 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/audio/audio.h>
#include "mulaw-decode.h" #include "mulaw-decode.h"
#include "mulaw-conversion.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_src_factory;
extern GstStaticPadTemplate mulaw_dec_sink_factory; extern GstStaticPadTemplate mulaw_dec_sink_factory;
@ -77,7 +72,7 @@ mulawdec_setcaps (GstMuLawDec * mulawdec, GstCaps * caps)
return FALSE; return FALSE;
outcaps = gst_caps_new_simple ("audio/x-raw", 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); "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
ret = gst_pad_set_caps (mulawdec->srcpad, outcaps); ret = gst_pad_set_caps (mulawdec->srcpad, outcaps);
gst_caps_unref (outcaps); gst_caps_unref (outcaps);
@ -111,7 +106,7 @@ mulawdec_getcaps (GstPad * pad, GstCaps * filter)
otherpad = mulawdec->srcpad; otherpad = mulawdec->srcpad;
} }
/* get caps from the peer, this can return NULL when there is no peer */ /* 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 */ /* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad); 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); gst_structure_remove_fields (structure, "format", NULL);
} else { } else {
/* add fixed fields */ /* add fixed fields */
gst_structure_set (structure, "format", G_TYPE_STRING, INT_FORMAT, gst_structure_set (structure, "format", G_TYPE_STRING,
NULL); GST_AUDIO_NE (S16), NULL);
} }
} }
/* filter against the allowed caps of the pad to return our result */ /* 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 */ /* there was no peer, return the template caps */
result = gst_caps_copy (templ); result = gst_caps_copy (templ);
} }
if (filter && result) {
GstCaps *temp;
temp = gst_caps_intersect (result, filter);
gst_caps_unref (result);
result = temp;
}
return result; return result;
} }

View file

@ -26,6 +26,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/audio/audio.h>
#include "mulaw-encode.h" #include "mulaw-encode.h"
#include "mulaw-conversion.h" #include "mulaw-conversion.h"
@ -71,11 +73,11 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter)
name = "audio/x-mulaw"; name = "audio/x-mulaw";
otherpad = mulawenc->sinkpad; otherpad = mulawenc->sinkpad;
} else { } else {
name = "audio/x-raw-int"; name = "audio/x-raw";
otherpad = mulawenc->srcpad; otherpad = mulawenc->srcpad;
} }
/* get caps from the peer, this can return NULL when there is no peer */ /* 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 */ /* get the template caps to make sure we return something acceptable */
templ = gst_pad_get_pad_template_caps (pad); templ = gst_pad_get_pad_template_caps (pad);
@ -95,14 +97,11 @@ mulawenc_getcaps (GstPad * pad, GstCaps * filter)
if (pad == mulawenc->srcpad) { if (pad == mulawenc->srcpad) {
/* remove the fields we don't want */ /* remove the fields we don't want */
gst_structure_remove_fields (structure, "width", "depth", "endianness", gst_structure_remove_fields (structure, "format", NULL);
"signed", NULL);
} else { } else {
/* add fixed fields */ /* add fixed fields */
gst_structure_set (structure, "width", G_TYPE_INT, 16, gst_structure_set (structure, "format", G_TYPE_STRING,
"depth", G_TYPE_INT, 16, GST_AUDIO_NE (S16), NULL);
"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 */ /* 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 */ /* there was no peer, return the template caps */
result = gst_caps_copy (templ); result = gst_caps_copy (templ);
} }
if (filter && result) {
GstCaps *temp;
temp = gst_caps_intersect (result, filter);
gst_caps_unref (result);
result = temp;
}
return result; return result;
} }