Commit 7f512363 authored by Wim Taymans's avatar Wim Taymans

law: fix negotiation

parent 668e1559
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
......
......@@ -26,6 +26,8 @@
#include "config.h"
#endif
#include <gst/audio/audio.h>
#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;
}
......
......@@ -26,6 +26,7 @@
#include "config.h"
#endif
#include <gst/audio/audio.h>
#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;
}
......
......@@ -20,20 +20,16 @@
#include "config.h"
#endif
#include <gst/audio/audio.h>
#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 ]")
);
......
......@@ -26,16 +26,11 @@
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/audio/audio.h>
#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;
}
......
......@@ -26,6 +26,8 @@
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/audio/audio.h>
#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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment