Commit 0475cf26 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Fix caps breakage after Dave's caps branch merge.

Original commit message from CVS:
2003-12-23  Ronald Bultje  <rbultje@ronald.bitfreak.net>

* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
parent d3def8f8
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get):
......
......@@ -33,47 +33,30 @@ GstElementDetails gst_divxdec_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
GST_PAD_TEMPLATE_FACTORY(sink_template,
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW(
"divxdec_sink",
"video/x-divx",
"divxversion", GST_PROPS_INT_RANGE(3, 5),
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
"height", GST_PROPS_INT_RANGE(0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)
GST_STATIC_CAPS (
"video/x-divx, "
"divxversion = (int) [ 3, 5 ], "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"framerate = (double) [ 0, MAX ]"
)
)
);
GST_PAD_TEMPLATE_FACTORY(src_template,
static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
gst_caps_new(
"divxdec_src",
"video/x-raw-yuv",
GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(
GST_PROPS_LIST(
GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y'))
)
)
),
gst_caps_new(
"divxdec_src_rgb1",
"video/x-raw-rgb",
GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32
),
gst_caps_new(
"divxdec_src_rgb2",
"video/x-raw-rgb",
GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16
GST_STATIC_CAPS (
GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, UYVY }")
/* FIXME: 15/16/24/32bpp RGB */
)
)
);
/* DivxDec signals and args */
......@@ -95,8 +78,8 @@ static void gst_divxdec_dispose (GObject *object);
static void gst_divxdec_chain (GstPad *pad,
GstData *data);
static GstPadLinkReturn gst_divxdec_connect (GstPad *pad,
GstCaps *vscapslist);
static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec);
const GstCaps *vscapslist);
static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec);
static GstElementClass *parent_class = NULL;
/* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */
......@@ -163,9 +146,9 @@ gst_divxdec_base_init (GstDivxDecClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_template));
gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_template));
gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_divxdec_details);
}
......@@ -187,7 +170,7 @@ gst_divxdec_init (GstDivxDec *divxdec)
{
/* create the sink pad */
divxdec->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(sink_template),
gst_static_pad_template_get (&sink_template),
"sink");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->sinkpad);
......@@ -196,7 +179,7 @@ gst_divxdec_init (GstDivxDec *divxdec)
/* create the src pad */
divxdec->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(src_template),
gst_static_pad_template_get (&src_template),
"src");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->srcpad);
......@@ -344,6 +327,8 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
GST_MAKE_FOURCC('I','4','2','0'), 0 },
{ GST_MAKE_FOURCC('Y','V','1','2'), 12, 12,
GST_MAKE_FOURCC('Y','V','1','2'), 0 },
#if 0
/* FIXME: someone fix RGB here please */
{ GST_MAKE_FOURCC('R','G','B',' '), 32, 32,
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC('A','B','G','R'), 32 },
......@@ -360,6 +345,7 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
3, 16 },
{ GST_MAKE_FOURCC('R','G','B',' '), 15, 16,
0, 16 },
#endif
{ 0, 0, 0, 0, 0 }
};
gint i;
......@@ -367,6 +353,7 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
for (i = 0; fmt_list[i].fourcc != 0; i++) {
divxdec->csp = fmt_list[i].csp;
#if 0
/* try making a caps to set on the other side */
if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) {
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
......@@ -401,13 +388,14 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
"green_mask", GST_PROPS_INT(g_mask),
"blue_mask", GST_PROPS_INT(b_mask));
} else {
caps = GST_CAPS_NEW("divxdec_src_pad_yuv",
"video/x-raw-yuv",
"width", GST_PROPS_INT(divxdec->width),
"height", GST_PROPS_INT(divxdec->height),
"framerate", GST_PROPS_FLOAT(divxdec->fps),
"format", GST_PROPS_FOURCC(fmt_list[i].fourcc));
}
#endif
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, divxdec->width,
"height", G_TYPE_INT, divxdec->height,
"framerate", G_TYPE_DOUBLE, divxdec->fps,
"format", GST_TYPE_FOURCC, fmt_list[i].fourcc,
NULL);
/*}*/
if ((ret = gst_pad_try_set_caps(divxdec->srcpad, caps)) > 0) {
divxdec->csp = fmt_list[i].csp;
......@@ -426,10 +414,11 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
static GstPadLinkReturn
gst_divxdec_connect (GstPad *pad,
GstCaps *vscaps)
gst_divxdec_connect (GstPad *pad,
const GstCaps *caps)
{
GstDivxDec *divxdec;
GstStructure *structure = gst_caps_get_structure (caps, 0);
divxdec = GST_DIVXDEC(gst_pad_get_parent (pad));
......@@ -439,14 +428,14 @@ gst_divxdec_connect (GstPad *pad,
}
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED(vscaps))
if (!gst_caps_is_fixed(caps))
return GST_PAD_LINK_DELAYED;
/* if we get here, we know the input is divx. we
* only need to bother with the output colorspace */
gst_caps_get_int(vscaps, "width", &divxdec->width);
gst_caps_get_int(vscaps, "height", &divxdec->height);
gst_caps_get_float(vscaps, "framerate", &divxdec->fps);
gst_structure_get_int(structure, "width", &divxdec->width);
gst_structure_get_int(structure, "height", &divxdec->height);
gst_structure_get_double(structure, "framerate", &divxdec->fps);
return gst_divxdec_negotiate(divxdec);
}
......
......@@ -55,7 +55,7 @@ struct _GstDivxDec {
guint32 csp;
int bitcnt, bpp;
int width, height;
float fps;
gdouble fps;
};
struct _GstDivxDecClass {
......
......@@ -34,48 +34,30 @@ GstElementDetails gst_divxenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
GST_PAD_TEMPLATE_FACTORY(sink_template,
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
gst_caps_new(
"divxdec_src",
"video/x-raw-yuv",
GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(
GST_PROPS_LIST(
GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')),
GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y'))
)
)
),
gst_caps_new(
"divxdec_src_rgb1",
"video/x-raw-rgb",
GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32
),
gst_caps_new(
"divxdec_src_rgb2",
"video/x-raw-rgb",
GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16
GST_STATIC_CAPS (
GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }")
/* FIXME: 15/16/24/32bpp RGB */
)
)
);
GST_PAD_TEMPLATE_FACTORY(src_template,
static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW(
"divxenc_sink",
"video/x-divx",
"divxversion", GST_PROPS_INT(5),
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
"height", GST_PROPS_INT_RANGE(0, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)
GST_STATIC_CAPS (
"video/x-divx, "
"divxversion = (int) 5, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"framerate = (double) [ 0, MAX ]"
)
)
);
/* DivxEnc signals and args */
......@@ -100,7 +82,7 @@ static void gst_divxenc_dispose (GObject *object);
static void gst_divxenc_chain (GstPad *pad,
GstData *data);
static GstPadLinkReturn gst_divxenc_connect (GstPad *pad,
GstCaps *vscapslist);
const GstCaps *vscapslist);
/* properties */
static void gst_divxenc_set_property (GObject *object,
......@@ -181,9 +163,9 @@ gst_divxenc_base_init (GstDivxEncClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_template));
gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_template));
gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_divxenc_details);
}
......@@ -239,7 +221,7 @@ gst_divxenc_init (GstDivxEnc *divxenc)
{
/* create the sink pad */
divxenc->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(sink_template),
gst_static_pad_template_get (&sink_template),
"sink");
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->sinkpad);
......@@ -248,7 +230,7 @@ gst_divxenc_init (GstDivxEnc *divxenc)
/* create the src pad */
divxenc->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(src_template),
gst_static_pad_template_get (&src_template),
"src");
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->srcpad);
......@@ -397,11 +379,16 @@ gst_divxenc_chain (GstPad *pad,
static GstPadLinkReturn
gst_divxenc_connect (GstPad *pad,
GstCaps *vscaps)
gst_divxenc_connect (GstPad *pad,
const GstCaps *caps)
{
GstDivxEnc *divxenc;
GstCaps *caps;
GstStructure *structure = gst_caps_get_structure (caps, 0);
gint w,h;
gdouble fps;
guint32 fourcc;
guint32 divx_cs;
gint bitcnt = 0;
divxenc = GST_DIVXENC(gst_pad_get_parent (pad));
......@@ -409,36 +396,32 @@ gst_divxenc_connect (GstPad *pad,
gst_divxenc_unset(divxenc);
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED(vscaps))
if (!gst_caps_is_fixed(caps))
return GST_PAD_LINK_DELAYED;
for (caps = vscaps; caps != NULL; caps = caps->next) {
gint w,h,d;
gfloat fps;
guint32 fourcc;
guint32 divx_cs;
gint bitcnt = 0;
gst_caps_get_int(caps, "width", &w);
gst_caps_get_int(caps, "height", &h);
gst_caps_get_float(caps, "framerate", &fps);
gst_caps_get_fourcc_int(caps, "format", &fourcc);
switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
divx_cs = GST_MAKE_FOURCC('I','4','2','0');
break;
case GST_MAKE_FOURCC('Y','U','Y','2'):
divx_cs = GST_MAKE_FOURCC('Y','U','Y','2');
break;
case GST_MAKE_FOURCC('Y','V','1','2'):
divx_cs = GST_MAKE_FOURCC('Y','V','1','2');
break;
case GST_MAKE_FOURCC('Y','V','Y','U'):
divx_cs = GST_MAKE_FOURCC('Y','V','Y','U');
break;
case GST_MAKE_FOURCC('U','Y','V','Y'):
divx_cs = GST_MAKE_FOURCC('U','Y','V','Y');
break;
gst_structure_get_int(structure, "width", &w);
gst_structure_get_int(structure, "height", &h);
gst_structure_get_double(structure, "framerate", &fps);
gst_structure_get_fourcc(structure, "format", &fourcc);
switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
divx_cs = GST_MAKE_FOURCC('I','4','2','0');
break;
case GST_MAKE_FOURCC('Y','U','Y','2'):
divx_cs = GST_MAKE_FOURCC('Y','U','Y','2');
break;
case GST_MAKE_FOURCC('Y','V','1','2'):
divx_cs = GST_MAKE_FOURCC('Y','V','1','2');
break;
case GST_MAKE_FOURCC('Y','V','Y','U'):
divx_cs = GST_MAKE_FOURCC('Y','V','Y','U');
break;
case GST_MAKE_FOURCC('U','Y','V','Y'):
divx_cs = GST_MAKE_FOURCC('U','Y','V','Y');
break;
#if 0
/* someone fix RGB please */
case GST_MAKE_FOURCC('R','G','B',' '):
gst_caps_get_int(caps, "depth", &d);
switch (d) {
......@@ -450,43 +433,35 @@ gst_divxenc_connect (GstPad *pad,
divx_cs = 0;
bitcnt = 32;
break;
default:
goto trynext;
}
break;
default:
goto trynext;
}
divxenc->csp = divx_cs;
divxenc->bitcnt = bitcnt;
divxenc->width = w;
divxenc->height = h;
divxenc->fps = fps;
/* try it */
if (gst_divxenc_setup(divxenc)) {
GstPadLinkReturn ret;
GstCaps *new_caps;
new_caps = GST_CAPS_NEW("divxenc_src_caps",
"video/x-divx",
"divxversion", GST_PROPS_INT(5),
"width", GST_PROPS_INT(w),
"height", GST_PROPS_INT(h),
"framerate", GST_PROPS_FLOAT(fps));
ret = gst_pad_try_set_caps(divxenc->srcpad, new_caps);
if (ret <= 0) {
gst_divxenc_unset(divxenc);
}
#endif
default:
return GST_PAD_LINK_REFUSED;
}
return ret;
divxenc->csp = divx_cs;
divxenc->bitcnt = bitcnt;
divxenc->width = w;
divxenc->height = h;
divxenc->fps = fps;
/* try it */
if (gst_divxenc_setup(divxenc)) {
GstPadLinkReturn ret;
GstCaps *new_caps;
new_caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 5,
"width", G_TYPE_INT, w,
"height", G_TYPE_INT, h,
"framerate", G_TYPE_DOUBLE, fps,
NULL);
ret = gst_pad_try_set_caps(divxenc->srcpad, new_caps);
if (ret <= 0) {
gst_divxenc_unset(divxenc);
}
trynext:
continue;
return ret;
}
/* if we got here - it's not good */
......
......@@ -23,54 +23,44 @@
#include "gstfaac.h"
GST_PAD_TEMPLATE_FACTORY (src_template,
static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"faac_mpeg_templ",
"audio/mpeg",
"systemstream", GST_PROPS_BOOLEAN (FALSE),
"mpegversion", GST_PROPS_LIST (
GST_PROPS_INT (4), /* we prefer 4 */
GST_PROPS_INT (2)
),
"channels", GST_PROPS_INT_RANGE (1, 6),
"samplerate", GST_PROPS_INT_RANGE (8000, 96000)
GST_STATIC_CAPS (
"audio/mpeg, "
"mpegversion = (int) { 4, 2 }, "
"channels = (int) [ 1, 6 ], "
"rate = (int) [ 8000, 96000 ]"
)
);
GST_PAD_TEMPLATE_FACTORY (sink_template,
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"faac_int16_templ",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 6)
),
GST_CAPS_NEW (
"faac_int24_templ",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (32),
"depth", GST_PROPS_INT (24),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 6)
),
GST_CAPS_NEW (
"faac_float_templ",
"audio/x-raw-float",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"depth", GST_PROPS_INT (32), /* float */
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 6)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) TRUE, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 8000, 96000 ], "
"channels = (int) [ 1, 6]; "
"audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) TRUE, "
"width = (int) 32, "
"depth = (int) 24, "
"rate = (int) [ 8000, 96000], "
"channels = (int) [ 1, 6]; "
"audio/x-raw-float, "
"endianness = (int) BYTE_ORDER, "
"depth = (int) 32, " /* sizeof (gfloat) */
"rate = (int) [ 8000, 96000], "
"channels = (int) [ 1, 6]"
)
);
......@@ -99,10 +89,10 @@ static void gst_faac_get_property (GObject *object,
static GstPadLinkReturn
gst_faac_sinkconnect (GstPad *pad,
GstCaps *caps);
const GstCaps *caps);
static GstPadLinkReturn
gst_faac_srcconnect (GstPad *pad,
GstCaps *caps);
const GstCaps *caps);
static void gst_faac_chain (GstPad *pad,
GstData *data);
static GstElementStateReturn
......@@ -149,9 +139,9 @@ gst_faac_base_init (GstFaacClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_template));
gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_template));
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_faac_details);
}
......@@ -245,13 +235,13 @@ gst_faac_init (GstFaac *faac)
GST_FLAG_SET (faac, GST_ELEMENT_EVENT_AWARE);
faac->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_template), "sink");
gst_static_pad_template_get (&sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (faac), faac->sinkpad);
gst_pad_set_chain_function (faac->sinkpad, gst_faac_chain);
gst_pad_set_link_function (faac->sinkpad, gst_faac_sinkconnect);
faac->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_template), "src");
gst_static_pad_template_get (&src_template), "src");
gst_element_add_pad (GST_ELEMENT (faac), faac->srcpad);
gst_pad_set_link_function (faac->srcpad, gst_faac_srcconnect);
......@@ -264,12 +254,16 @@ gst_faac_init (GstFaac *faac)
}
static GstPadLinkReturn
gst_faac_sinkconnect (GstPad *pad,
GstCaps *caps)
gst_faac_sinkconnect (GstPad *pad,
const GstCaps *caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
faacEncHandle *handle;
gint channels, samplerate, depth;
gulong samples, bytes, fmt = 0, bps = 0;
if (!GST_CAPS_IS_FIXED (caps))
if (!gst_caps_is_fixed (caps))
return GST_PAD_LINK_DELAYED;
if (faac->handle) {
......@@ -281,66 +275,58 @@ gst_faac_sinkconnect (GstPad *pad,
faac->cache = NULL;
}
for (; caps != NULL; caps = caps->next) {
faacEncHandle *handle;
gint channels, samplerate, depth;
gulong samples, bytes, fmt = 0, bps = 0;
gst_structure_get_int (structure, "channels", &channels);
gst_structure_get_int (structure, "rate", &samplerate);
gst_structure_get_int (structure, "depth", &depth);
gst_caps_get (caps, "channels", &channels,
"rate", &samplerate,
"depth", &depth, NULL);
/* open a new handle to the encoder */
if (!(handle = faacEncOpen (samplerate, channels,
&samples, &bytes)))
return GST_PAD_LINK_REFUSED;
/* open a new handle to the encoder */
if (!(handle = faacEncOpen (samplerate, channels,
&samples, &bytes)))
continue;
switch (depth) {
case 16:
fmt = FAAC_INPUT_16BIT;
bps = 2;
break;
case 24:
fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
bps = 4;
break;
case 32:
fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
bps = 4;
break;
}
if (!fmt) {
faacEncClose (handle);
continue;
}
switch (depth) {
case 16:
fmt = FAAC_INPUT_16BIT;
bps = 2;
break;
case 24:
fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
bps = 4;
break;
case 32:
fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
bps = 4;
break;
}
faac->format = fmt;
faac->bps = bps;
faac->handle = handle;
faac->bytes = bytes;
faac->samples = samples;
faac->channels = channels;
faac->samplerate = samplerate;
/* if the other side was already set-up, redo that */
if (GST_PAD_CAPS (faac->srcpad))
return gst_faac_srcconnect (faac->srcpad,
gst_pad_get_allowed_caps (faac->srcpad));
/* else, that'll be done later */
return GST_PAD_LINK_OK;
if (!fmt) {
faacEncClose (handle);
return GST_PAD_LINK_REFUSED;
}
return GST_PAD_LINK_REFUSED;
faac->format = fmt;
faac->bps = bps;
faac->handle = handle;
faac->bytes = bytes;
faac->samples = samples;
faac->channels = channels;
faac->samplerate = samplerate;
/* if the other side was already set-up, redo that */
if (GST_PAD_CAPS (faac->srcpad))
return gst_faac_srcconnect (faac->srcpad,
gst_pad_get_caps (GST_PAD_PEER (faac->srcpad)));
/* else, that'll be done later */
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
gst_faac_srcconnect (GstPad *pad,
GstCaps *caps)
gst_faac_srcconnect (GstPad *pad,
const GstCaps *caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstCaps *t;
gint n;
if (!faac->handle ||
(faac->samplerate == -1 || faac->channels == -1)) {
......@@ -348,20 +334,22 @@ gst_faac_srcconnect (GstPad *pad,
}
/* we do samplerate/channels ourselves */
for (t = caps; t != NULL; t = t->next) {
gst_props_remove_entry_by_name (t->properties, "rate");
gst_props_remove_entry_by_name (t->properties, "channels");
for (n = 0; n < gst_caps_get_size (caps); n++) {
GstStructure *structure = gst_caps_get_structure (caps, n);
gst_structure_remove_field (structure, "rate");
gst_structure_remove_field (structure, "channels");
}
/* go through list */