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.
This commit is contained in:
Ronald S. Bultje 2003-12-23 22:50:06 +00:00
parent d3def8f8f2
commit 0475cf2613
11 changed files with 367 additions and 402 deletions

View file

@ -1,3 +1,23 @@
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> 2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get): * sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get):

View file

@ -33,47 +33,30 @@ GstElementDetails gst_divxdec_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>" "Ronald Bultje <rbultje@ronald.bitfreak.net>"
}; };
GST_PAD_TEMPLATE_FACTORY(sink_template, static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW( GST_STATIC_CAPS (
"divxdec_sink", "video/x-divx, "
"video/x-divx", "divxversion = (int) [ 3, 5 ], "
"divxversion", GST_PROPS_INT_RANGE(3, 5), "width = (int) [ 16, 4096 ], "
"width", GST_PROPS_INT_RANGE(0, G_MAXINT), "height = (int) [ 16, 4096 ], "
"height", GST_PROPS_INT_RANGE(0, G_MAXINT), "framerate = (double) [ 0, MAX ]"
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)
) )
) );
GST_PAD_TEMPLATE_FACTORY(src_template, static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
gst_caps_new( GST_STATIC_CAPS (
"divxdec_src", GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, UYVY }")
"video/x-raw-yuv", /* FIXME: 15/16/24/32bpp RGB */
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
) )
) );
/* DivxDec signals and args */ /* DivxDec signals and args */
@ -95,8 +78,8 @@ static void gst_divxdec_dispose (GObject *object);
static void gst_divxdec_chain (GstPad *pad, static void gst_divxdec_chain (GstPad *pad,
GstData *data); GstData *data);
static GstPadLinkReturn gst_divxdec_connect (GstPad *pad, static GstPadLinkReturn gst_divxdec_connect (GstPad *pad,
GstCaps *vscapslist); const GstCaps *vscapslist);
static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec); static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
/* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */ /* 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); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, 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_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); gst_element_class_set_details (element_class, &gst_divxdec_details);
} }
@ -187,7 +170,7 @@ gst_divxdec_init (GstDivxDec *divxdec)
{ {
/* create the sink pad */ /* create the sink pad */
divxdec->sinkpad = gst_pad_new_from_template( divxdec->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(sink_template), gst_static_pad_template_get (&sink_template),
"sink"); "sink");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->sinkpad); gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->sinkpad);
@ -196,7 +179,7 @@ gst_divxdec_init (GstDivxDec *divxdec)
/* create the src pad */ /* create the src pad */
divxdec->srcpad = gst_pad_new_from_template( divxdec->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(src_template), gst_static_pad_template_get (&src_template),
"src"); "src");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->srcpad); 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('I','4','2','0'), 0 },
{ GST_MAKE_FOURCC('Y','V','1','2'), 12, 12, { GST_MAKE_FOURCC('Y','V','1','2'), 12, 12,
GST_MAKE_FOURCC('Y','V','1','2'), 0 }, GST_MAKE_FOURCC('Y','V','1','2'), 0 },
#if 0
/* FIXME: someone fix RGB here please */
{ GST_MAKE_FOURCC('R','G','B',' '), 32, 32, { GST_MAKE_FOURCC('R','G','B',' '), 32, 32,
#if (G_BYTE_ORDER == G_BIG_ENDIAN) #if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC('A','B','G','R'), 32 }, GST_MAKE_FOURCC('A','B','G','R'), 32 },
@ -360,6 +345,7 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
3, 16 }, 3, 16 },
{ GST_MAKE_FOURCC('R','G','B',' '), 15, 16, { GST_MAKE_FOURCC('R','G','B',' '), 15, 16,
0, 16 }, 0, 16 },
#endif
{ 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0 }
}; };
gint i; gint i;
@ -367,6 +353,7 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
for (i = 0; fmt_list[i].fourcc != 0; i++) { for (i = 0; fmt_list[i].fourcc != 0; i++) {
divxdec->csp = fmt_list[i].csp; divxdec->csp = fmt_list[i].csp;
#if 0
/* try making a caps to set on the other side */ /* try making a caps to set on the other side */
if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) { if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) {
guint32 r_mask = 0, b_mask = 0, g_mask = 0; 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), "green_mask", GST_PROPS_INT(g_mask),
"blue_mask", GST_PROPS_INT(b_mask)); "blue_mask", GST_PROPS_INT(b_mask));
} else { } else {
caps = GST_CAPS_NEW("divxdec_src_pad_yuv", #endif
"video/x-raw-yuv", caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", GST_PROPS_INT(divxdec->width), "width", G_TYPE_INT, divxdec->width,
"height", GST_PROPS_INT(divxdec->height), "height", G_TYPE_INT, divxdec->height,
"framerate", GST_PROPS_FLOAT(divxdec->fps), "framerate", G_TYPE_DOUBLE, divxdec->fps,
"format", GST_PROPS_FOURCC(fmt_list[i].fourcc)); "format", GST_TYPE_FOURCC, fmt_list[i].fourcc,
} NULL);
/*}*/
if ((ret = gst_pad_try_set_caps(divxdec->srcpad, caps)) > 0) { if ((ret = gst_pad_try_set_caps(divxdec->srcpad, caps)) > 0) {
divxdec->csp = fmt_list[i].csp; divxdec->csp = fmt_list[i].csp;
@ -426,10 +414,11 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
static GstPadLinkReturn static GstPadLinkReturn
gst_divxdec_connect (GstPad *pad, gst_divxdec_connect (GstPad *pad,
GstCaps *vscaps) const GstCaps *caps)
{ {
GstDivxDec *divxdec; GstDivxDec *divxdec;
GstStructure *structure = gst_caps_get_structure (caps, 0);
divxdec = GST_DIVXDEC(gst_pad_get_parent (pad)); 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 */ /* 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; return GST_PAD_LINK_DELAYED;
/* if we get here, we know the input is divx. we /* if we get here, we know the input is divx. we
* only need to bother with the output colorspace */ * only need to bother with the output colorspace */
gst_caps_get_int(vscaps, "width", &divxdec->width); gst_structure_get_int(structure, "width", &divxdec->width);
gst_caps_get_int(vscaps, "height", &divxdec->height); gst_structure_get_int(structure, "height", &divxdec->height);
gst_caps_get_float(vscaps, "framerate", &divxdec->fps); gst_structure_get_double(structure, "framerate", &divxdec->fps);
return gst_divxdec_negotiate(divxdec); return gst_divxdec_negotiate(divxdec);
} }

View file

@ -55,7 +55,7 @@ struct _GstDivxDec {
guint32 csp; guint32 csp;
int bitcnt, bpp; int bitcnt, bpp;
int width, height; int width, height;
float fps; gdouble fps;
}; };
struct _GstDivxDecClass { struct _GstDivxDecClass {

View file

@ -34,48 +34,30 @@ GstElementDetails gst_divxenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>" "Ronald Bultje <rbultje@ronald.bitfreak.net>"
}; };
GST_PAD_TEMPLATE_FACTORY(sink_template, static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
gst_caps_new( GST_STATIC_CAPS (
"divxdec_src", GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }")
"video/x-raw-yuv", /* FIXME: 15/16/24/32bpp RGB */
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_PAD_TEMPLATE_FACTORY(src_template, static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW( GST_STATIC_CAPS (
"divxenc_sink", "video/x-divx, "
"video/x-divx", "divxversion = (int) 5, "
"divxversion", GST_PROPS_INT(5), "width = (int) [ 16, 4096 ], "
"width", GST_PROPS_INT_RANGE(0, G_MAXINT), "height = (int) [ 16, 4096 ], "
"height", GST_PROPS_INT_RANGE(0, G_MAXINT), "framerate = (double) [ 0, MAX ]"
"framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)
) )
) );
/* DivxEnc signals and args */ /* DivxEnc signals and args */
@ -100,7 +82,7 @@ static void gst_divxenc_dispose (GObject *object);
static void gst_divxenc_chain (GstPad *pad, static void gst_divxenc_chain (GstPad *pad,
GstData *data); GstData *data);
static GstPadLinkReturn gst_divxenc_connect (GstPad *pad, static GstPadLinkReturn gst_divxenc_connect (GstPad *pad,
GstCaps *vscapslist); const GstCaps *vscapslist);
/* properties */ /* properties */
static void gst_divxenc_set_property (GObject *object, 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); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, 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_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); gst_element_class_set_details (element_class, &gst_divxenc_details);
} }
@ -239,7 +221,7 @@ gst_divxenc_init (GstDivxEnc *divxenc)
{ {
/* create the sink pad */ /* create the sink pad */
divxenc->sinkpad = gst_pad_new_from_template( divxenc->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(sink_template), gst_static_pad_template_get (&sink_template),
"sink"); "sink");
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->sinkpad); gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->sinkpad);
@ -248,7 +230,7 @@ gst_divxenc_init (GstDivxEnc *divxenc)
/* create the src pad */ /* create the src pad */
divxenc->srcpad = gst_pad_new_from_template( divxenc->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(src_template), gst_static_pad_template_get (&src_template),
"src"); "src");
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->srcpad); gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->srcpad);
@ -397,11 +379,16 @@ gst_divxenc_chain (GstPad *pad,
static GstPadLinkReturn static GstPadLinkReturn
gst_divxenc_connect (GstPad *pad, gst_divxenc_connect (GstPad *pad,
GstCaps *vscaps) const GstCaps *caps)
{ {
GstDivxEnc *divxenc; 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)); divxenc = GST_DIVXENC(gst_pad_get_parent (pad));
@ -409,36 +396,32 @@ gst_divxenc_connect (GstPad *pad,
gst_divxenc_unset(divxenc); gst_divxenc_unset(divxenc);
/* we are not going to act on variable caps */ /* 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; return GST_PAD_LINK_DELAYED;
for (caps = vscaps; caps != NULL; caps = caps->next) { gst_structure_get_int(structure, "width", &w);
gint w,h,d; gst_structure_get_int(structure, "height", &h);
gfloat fps; gst_structure_get_double(structure, "framerate", &fps);
guint32 fourcc; gst_structure_get_fourcc(structure, "format", &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) { switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'): case GST_MAKE_FOURCC('I','4','2','0'):
divx_cs = GST_MAKE_FOURCC('I','4','2','0'); divx_cs = GST_MAKE_FOURCC('I','4','2','0');
break; break;
case GST_MAKE_FOURCC('Y','U','Y','2'): case GST_MAKE_FOURCC('Y','U','Y','2'):
divx_cs = GST_MAKE_FOURCC('Y','U','Y','2'); divx_cs = GST_MAKE_FOURCC('Y','U','Y','2');
break; break;
case GST_MAKE_FOURCC('Y','V','1','2'): case GST_MAKE_FOURCC('Y','V','1','2'):
divx_cs = GST_MAKE_FOURCC('Y','V','1','2'); divx_cs = GST_MAKE_FOURCC('Y','V','1','2');
break; break;
case GST_MAKE_FOURCC('Y','V','Y','U'): case GST_MAKE_FOURCC('Y','V','Y','U'):
divx_cs = GST_MAKE_FOURCC('Y','V','Y','U'); divx_cs = GST_MAKE_FOURCC('Y','V','Y','U');
break; break;
case GST_MAKE_FOURCC('U','Y','V','Y'): case GST_MAKE_FOURCC('U','Y','V','Y'):
divx_cs = GST_MAKE_FOURCC('U','Y','V','Y'); divx_cs = GST_MAKE_FOURCC('U','Y','V','Y');
break; break;
#if 0
/* someone fix RGB please */
case GST_MAKE_FOURCC('R','G','B',' '): case GST_MAKE_FOURCC('R','G','B',' '):
gst_caps_get_int(caps, "depth", &d); gst_caps_get_int(caps, "depth", &d);
switch (d) { switch (d) {
@ -450,43 +433,35 @@ gst_divxenc_connect (GstPad *pad,
divx_cs = 0; divx_cs = 0;
bitcnt = 32; bitcnt = 32;
break; break;
default: #endif
goto trynext; default:
} return GST_PAD_LINK_REFUSED;
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_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);
} }
divxenc->csp = divx_cs; return ret;
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);
}
return ret;
}
trynext:
continue;
} }
/* if we got here - it's not good */ /* if we got here - it's not good */

View file

@ -23,54 +23,44 @@
#include "gstfaac.h" #include "gstfaac.h"
GST_PAD_TEMPLATE_FACTORY (src_template, static GstStaticPadTemplate src_template =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (
"faac_mpeg_templ", "audio/mpeg, "
"audio/mpeg", "mpegversion = (int) { 4, 2 }, "
"systemstream", GST_PROPS_BOOLEAN (FALSE), "channels = (int) [ 1, 6 ], "
"mpegversion", GST_PROPS_LIST ( "rate = (int) [ 8000, 96000 ]"
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_PAD_TEMPLATE_FACTORY (sink_template, static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (
"faac_int16_templ", "audio/x-raw-int, "
"audio/x-raw-int", "endianness = (int) BYTE_ORDER, "
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed = (boolean) TRUE, "
"signed", GST_PROPS_BOOLEAN (TRUE), "width = (int) 16, "
"width", GST_PROPS_INT (16), "depth = (int) 16, "
"depth", GST_PROPS_INT (16), "rate = (int) [ 8000, 96000 ], "
"rate", GST_PROPS_INT_RANGE (8000, 96000), "channels = (int) [ 1, 6]; "
"channels", GST_PROPS_INT_RANGE (1, 6) "audio/x-raw-int, "
), "endianness = (int) BYTE_ORDER, "
GST_CAPS_NEW ( "signed = (boolean) TRUE, "
"faac_int24_templ", "width = (int) 32, "
"audio/x-raw-int", "depth = (int) 24, "
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "rate = (int) [ 8000, 96000], "
"signed", GST_PROPS_BOOLEAN (TRUE), "channels = (int) [ 1, 6]; "
"width", GST_PROPS_INT (32), "audio/x-raw-float, "
"depth", GST_PROPS_INT (24), "endianness = (int) BYTE_ORDER, "
"rate", GST_PROPS_INT_RANGE (8000, 96000), "depth = (int) 32, " /* sizeof (gfloat) */
"channels", GST_PROPS_INT_RANGE (1, 6) "rate = (int) [ 8000, 96000], "
), "channels = (int) [ 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)
) )
); );
@ -99,10 +89,10 @@ static void gst_faac_get_property (GObject *object,
static GstPadLinkReturn static GstPadLinkReturn
gst_faac_sinkconnect (GstPad *pad, gst_faac_sinkconnect (GstPad *pad,
GstCaps *caps); const GstCaps *caps);
static GstPadLinkReturn static GstPadLinkReturn
gst_faac_srcconnect (GstPad *pad, gst_faac_srcconnect (GstPad *pad,
GstCaps *caps); const GstCaps *caps);
static void gst_faac_chain (GstPad *pad, static void gst_faac_chain (GstPad *pad,
GstData *data); GstData *data);
static GstElementStateReturn static GstElementStateReturn
@ -149,9 +139,9 @@ gst_faac_base_init (GstFaacClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, 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_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); 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); GST_FLAG_SET (faac, GST_ELEMENT_EVENT_AWARE);
faac->sinkpad = gst_pad_new_from_template ( 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_element_add_pad (GST_ELEMENT (faac), faac->sinkpad);
gst_pad_set_chain_function (faac->sinkpad, gst_faac_chain); gst_pad_set_chain_function (faac->sinkpad, gst_faac_chain);
gst_pad_set_link_function (faac->sinkpad, gst_faac_sinkconnect); gst_pad_set_link_function (faac->sinkpad, gst_faac_sinkconnect);
faac->srcpad = gst_pad_new_from_template ( 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_element_add_pad (GST_ELEMENT (faac), faac->srcpad);
gst_pad_set_link_function (faac->srcpad, gst_faac_srcconnect); gst_pad_set_link_function (faac->srcpad, gst_faac_srcconnect);
@ -264,12 +254,16 @@ gst_faac_init (GstFaac *faac)
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_faac_sinkconnect (GstPad *pad, gst_faac_sinkconnect (GstPad *pad,
GstCaps *caps) const GstCaps *caps)
{ {
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad)); 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; return GST_PAD_LINK_DELAYED;
if (faac->handle) { if (faac->handle) {
@ -281,66 +275,58 @@ gst_faac_sinkconnect (GstPad *pad,
faac->cache = NULL; faac->cache = NULL;
} }
for (; caps != NULL; caps = caps->next) { gst_structure_get_int (structure, "channels", &channels);
faacEncHandle *handle; gst_structure_get_int (structure, "rate", &samplerate);
gint channels, samplerate, depth; gst_structure_get_int (structure, "depth", &depth);
gulong samples, bytes, fmt = 0, bps = 0;
gst_caps_get (caps, "channels", &channels, /* open a new handle to the encoder */
"rate", &samplerate, if (!(handle = faacEncOpen (samplerate, channels,
"depth", &depth, NULL); &samples, &bytes)))
return GST_PAD_LINK_REFUSED;
/* open a new handle to the encoder */ switch (depth) {
if (!(handle = faacEncOpen (samplerate, channels, case 16:
&samples, &bytes))) fmt = FAAC_INPUT_16BIT;
continue; bps = 2;
break;
switch (depth) { case 24:
case 16: fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
fmt = FAAC_INPUT_16BIT; bps = 4;
bps = 2; break;
break; case 32:
case 24: fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */ bps = 4;
bps = 4; break;
break;
case 32:
fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
bps = 4;
break;
}
if (!fmt) {
faacEncClose (handle);
continue;
}
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;
} }
return GST_PAD_LINK_REFUSED; if (!fmt) {
faacEncClose (handle);
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 static GstPadLinkReturn
gst_faac_srcconnect (GstPad *pad, gst_faac_srcconnect (GstPad *pad,
GstCaps *caps) const GstCaps *caps)
{ {
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad)); GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstCaps *t; gint n;
if (!faac->handle || if (!faac->handle ||
(faac->samplerate == -1 || faac->channels == -1)) { (faac->samplerate == -1 || faac->channels == -1)) {
@ -348,20 +334,22 @@ gst_faac_srcconnect (GstPad *pad,
} }
/* we do samplerate/channels ourselves */ /* we do samplerate/channels ourselves */
for (t = caps; t != NULL; t = t->next) { for (n = 0; n < gst_caps_get_size (caps); n++) {
gst_props_remove_entry_by_name (t->properties, "rate"); GstStructure *structure = gst_caps_get_structure (caps, n);
gst_props_remove_entry_by_name (t->properties, "channels"); gst_structure_remove_field (structure, "rate");
gst_structure_remove_field (structure, "channels");
} }
/* go through list */ /* go through list */
caps = gst_caps_normalize (caps); caps = gst_caps_normalize (caps);
for ( ; caps != NULL; caps = caps->next) { for (n = 0; n < gst_caps_get_size (caps); n++) {
GstStructure *structure = gst_caps_get_structure (caps, n);
faacEncConfiguration *conf; faacEncConfiguration *conf;
gint mpegversion = 0; gint mpegversion = 0;
GstCaps *newcaps; GstCaps *newcaps;
GstPadLinkReturn ret; GstPadLinkReturn ret;
gst_caps_get_int (caps, "mpegversion", &mpegversion); gst_structure_get_int (structure, "mpegversion", &mpegversion);
/* new conf */ /* new conf */
conf = faacEncGetCurrentConfiguration (faac->handle); conf = faacEncGetCurrentConfiguration (faac->handle);
@ -388,12 +376,11 @@ gst_faac_srcconnect (GstPad *pad,
continue; continue;
} }
newcaps = GST_CAPS_NEW ("faac_mpeg_caps", newcaps = gst_caps_new_simple ("audio/mpeg",
"audio/mpeg", "mpegversion", G_TYPE_INT, mpegversion,
"systemstream", GST_PROPS_BOOLEAN (FALSE), "channels", G_TYPE_INT, faac->channels,
"mpegversion", GST_PROPS_INT (mpegversion), "rate", G_TYPE_INT, faac->samplerate,
"channels", GST_PROPS_INT (faac->channels), NULL);
"rate", GST_PROPS_INT (faac->samplerate));
ret = gst_pad_try_set_caps (faac->srcpad, newcaps); ret = gst_pad_try_set_caps (faac->srcpad, newcaps);
switch (ret) { switch (ret) {

View file

@ -25,52 +25,76 @@
#include "gstmpeg2enc.hh" #include "gstmpeg2enc.hh"
GST_PAD_TEMPLATE_FACTORY (sink_templ, /*
"sink", * We can't use fractions in static pad templates, so
GST_PAD_SINK, * we do something manual...
GST_PAD_ALWAYS, */
GST_CAPS_NEW ( static void
"mpeg2enc_sink", add_fps (GstCaps *caps)
"video/x-raw-yuv", {
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), GstStructure *structure = gst_caps_get_structure (caps, 0);
"width", GST_PROPS_INT_RANGE (16, 4096), GValue list = { 0 }, fps = { 0 };
"height", GST_PROPS_INT_RANGE (16, 4096), gdouble fpss[] = { 24.0/1.001, 24.0, 25.0,
"framerate", GST_PROPS_LIST ( 30.0/1.001, 30.0, 50.0,
GST_PROPS_FLOAT (24/1.001), 60.0/1.001, 60.0, 0 };
GST_PROPS_FLOAT (24.), guint n;
GST_PROPS_FLOAT (25.),
GST_PROPS_FLOAT (30/1.001),
GST_PROPS_FLOAT (30.),
GST_PROPS_FLOAT (50.),
GST_PROPS_FLOAT (60/1.001),
GST_PROPS_FLOAT (60.)
)
)
)
GST_PAD_TEMPLATE_FACTORY (src_templ, g_value_init (&list, GST_TYPE_LIST);
"src", g_value_init (&fps, G_TYPE_DOUBLE);
GST_PAD_SRC, for (n = 0; fpss[n] != 0; n++) {
GST_PAD_ALWAYS, g_value_set_double (&fps, fpss[n]);
GST_CAPS_NEW ( gst_value_list_append_value (&list, &fps);
"mpeg2enc_src", }
"video/mpeg", gst_structure_set_value (structure, "framerate", &list);
"systemstream", GST_PROPS_BOOLEAN (FALSE), g_value_unset (&list);
"mpegversion", GST_PROPS_INT_RANGE (1, 2), g_value_unset (&fps);
"width", GST_PROPS_INT_RANGE (16, 4096), }
"height", GST_PROPS_INT_RANGE (16, 4096),
"framerate", GST_PROPS_LIST ( static GstPadTemplate *
GST_PROPS_FLOAT (24/1.001), sink_templ (void)
GST_PROPS_FLOAT (24.), {
GST_PROPS_FLOAT (25.), static GstPadTemplate *templ = NULL;
GST_PROPS_FLOAT (30/1.001),
GST_PROPS_FLOAT (30.), if (!templ) {
GST_PROPS_FLOAT (50.), GstCaps *caps;
GST_PROPS_FLOAT (60/1.001),
GST_PROPS_FLOAT (60.) caps = gst_caps_new_simple ("video/x-raw-yuv",
) "format", GST_TYPE_FOURCC,
) GST_MAKE_FOURCC ('I','4','2','0'),
) "width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
NULL);
add_fps (caps);
templ = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, caps);
}
return templ;
}
static GstPadTemplate *
src_templ (void)
{
static GstPadTemplate *templ = NULL;
if (!templ) {
GstCaps *caps;
caps = gst_caps_new_simple ("video/mpeg",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"mpegversion", GST_TYPE_INT_RANGE, 1, 2,
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
NULL);
add_fps (caps);
templ = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, caps);
}
return templ;
}
static void gst_mpeg2enc_base_init (GstMpeg2encClass *klass); static void gst_mpeg2enc_base_init (GstMpeg2encClass *klass);
static void gst_mpeg2enc_class_init (GstMpeg2encClass *klass); static void gst_mpeg2enc_class_init (GstMpeg2encClass *klass);
@ -81,10 +105,9 @@ static void gst_mpeg2enc_loop (GstElement *element);
static GstPadLinkReturn static GstPadLinkReturn
gst_mpeg2enc_sink_link (GstPad *pad, gst_mpeg2enc_sink_link (GstPad *pad,
GstCaps *caps); const GstCaps *caps);
static GstCaps * static GstCaps *
gst_mpeg2enc_src_getcaps (GstPad *pad, gst_mpeg2enc_src_getcaps (GstPad *pad);
GstCaps *caps);
static GstElementStateReturn static GstElementStateReturn
gst_mpeg2enc_change_state (GstElement *element); gst_mpeg2enc_change_state (GstElement *element);
@ -140,10 +163,8 @@ gst_mpeg2enc_base_init (GstMpeg2encClass *klass)
}; };
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class, src_templ ());
GST_PAD_TEMPLATE_GET (src_templ)); gst_element_class_add_pad_template (element_class, sink_templ ());
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_templ));
gst_element_class_set_details (element_class, gst_element_class_set_details (element_class,
&gst_mpeg2enc_details); &gst_mpeg2enc_details);
} }
@ -235,12 +256,12 @@ gst_mpeg2enc_loop (GstElement *element)
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_mpeg2enc_sink_link (GstPad *pad, gst_mpeg2enc_sink_link (GstPad *pad,
GstCaps *caps) const GstCaps *caps)
{ {
GstMpeg2enc *enc = GST_MPEG2ENC (gst_pad_get_parent (pad)); GstMpeg2enc *enc = GST_MPEG2ENC (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) if (!gst_caps_is_fixed (caps))
return GST_PAD_LINK_DELAYED; return GST_PAD_LINK_DELAYED;
if (enc->encoder) { if (enc->encoder) {
@ -252,8 +273,7 @@ gst_mpeg2enc_sink_link (GstPad *pad,
} }
static GstCaps * static GstCaps *
gst_mpeg2enc_src_getcaps (GstPad *pad, gst_mpeg2enc_src_getcaps (GstPad *pad)
GstCaps *caps)
{ {
GstMpeg2enc *enc = GST_MPEG2ENC (gst_pad_get_parent (pad)); GstMpeg2enc *enc = GST_MPEG2ENC (gst_pad_get_parent (pad));
@ -261,8 +281,8 @@ gst_mpeg2enc_src_getcaps (GstPad *pad,
return enc->encoder->getFormat (); return enc->encoder->getFormat ();
} }
return gst_caps_ref (gst_pad_template_get_caps ( return (GstCaps* ) gst_pad_template_get_caps (
gst_element_get_pad_template (gst_pad_get_parent (pad), "src"))); gst_element_get_pad_template (gst_pad_get_parent (pad), "src"));
} }
static void static void

View file

@ -85,11 +85,11 @@ GstMpeg2Encoder::getFormat ()
{ {
gdouble fps = Y4M_RATIO_DBL (mpeg_framerate (options.frame_rate)); gdouble fps = Y4M_RATIO_DBL (mpeg_framerate (options.frame_rate));
return GST_CAPS_NEW ("mpeg2enc_src", return gst_caps_new_simple ("video/mpeg",
"video/mpeg", "systemstream", G_TYPE_BOOLEAN, FALSE,
"systemstream", GST_PROPS_BOOLEAN (FALSE), "mpegversion", G_TYPE_INT, options.mpeg,
"mpegversion", GST_PROPS_INT (options.mpeg), "width", G_TYPE_INT, options.in_img_width,
"width", GST_PROPS_INT (options.in_img_width), "height", G_TYPE_INT, options.in_img_height,
"height", GST_PROPS_INT (options.in_img_height), "framerate", G_TYPE_DOUBLE, fps,
"framerate", GST_PROPS_FLOAT (fps)); NULL);
} }

View file

@ -42,7 +42,7 @@ GstMpeg2EncPictureReader::GstMpeg2EncPictureReader (GstPad *in_pad,
GstMpeg2EncPictureReader::~GstMpeg2EncPictureReader () GstMpeg2EncPictureReader::~GstMpeg2EncPictureReader ()
{ {
gst_caps_unref (caps); gst_caps_free (caps);
} }
/* /*
@ -52,12 +52,13 @@ GstMpeg2EncPictureReader::~GstMpeg2EncPictureReader ()
void void
GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams &strm) GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams &strm)
{ {
GstStructure *structure = gst_caps_get_structure (caps, 0);
gint width, height; gint width, height;
gfloat fps; gdouble fps;
gst_caps_get (caps, "width", &width, gst_structure_get_int (structure, "width", &width);
"height", &height, gst_structure_get_int (structure, "height", &height);
"framerate", &fps, NULL); gst_structure_get_double (structure, "framerate", &fps);
strm.horizontal_size = width; strm.horizontal_size = width;
strm.vertical_size = height; strm.vertical_size = height;

View file

@ -65,39 +65,32 @@ enum {
ARG_DIGITAL_PCM ARG_DIGITAL_PCM
}; };
static GstStaticPadTemplate dxr3audiosink_pcm_sink_factory =
GST_PAD_TEMPLATE_FACTORY (dxr3audiosink_pcm_sink_factory, GST_STATIC_PAD_TEMPLATE (
"pcm_sink", "pcm_sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (
"dxr3audiosink_pcm_sink", "audio/x-raw-int, "
"audio/x-raw-int", "endianness = (int) BYTE_ORDER, "
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed = (boolean) TRUE, "
"signed", GST_PROPS_BOOLEAN (TRUE), "width = (int) 16, "
"width", GST_PROPS_INT (16), "depth = (int) 16, "
"depth", GST_PROPS_INT (16), "rate = (int) { 32000, 44100, 48000, 66000 }, "
"rate", GST_PROPS_LIST ( "channels = (int) 2"
GST_PROPS_INT (32000),
GST_PROPS_INT (44100),
GST_PROPS_INT (48000),
GST_PROPS_INT (66000)
),
"channels", GST_PROPS_INT (2)
) )
) );
GST_PAD_TEMPLATE_FACTORY (dxr3audiosink_ac3_sink_factory, static GstStaticPadTemplate dxr3audiosink_ac3_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"ac3_sink", "ac3_sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (
"dxr3audiosink_ac3_sink", "audio/x-ac3"
"audio/x-ac3",
NULL
/* no parameters needed, we don't need a parsed stream */ /* no parameters needed, we don't need a parsed stream */
) )
) );
GST_PAD_EVENT_MASK_FUNCTION(dxr3audiosink_get_event_mask, GST_PAD_EVENT_MASK_FUNCTION(dxr3audiosink_get_event_mask,
@ -128,7 +121,7 @@ static void dxr3audiosink_set_clock (GstElement *element,
GstClock *clock); GstClock *clock);
static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad *pad, static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad *pad,
GstCaps *caps); const GstCaps *caps);
static void dxr3audiosink_set_scr (Dxr3AudioSink *sink, static void dxr3audiosink_set_scr (Dxr3AudioSink *sink,
guint32 scr); guint32 scr);
@ -182,9 +175,9 @@ dxr3audiosink_base_init (Dxr3AudioSinkClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (dxr3audiosink_pcm_sink_factory)); gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (dxr3audiosink_ac3_sink_factory)); gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory));
gst_element_class_set_details (element_class, gst_element_class_set_details (element_class,
&dxr3audiosink_details); &dxr3audiosink_details);
} }
@ -226,22 +219,18 @@ dxr3audiosink_class_init (Dxr3AudioSinkClass *klass)
static void static void
dxr3audiosink_init (Dxr3AudioSink *sink) dxr3audiosink_init (Dxr3AudioSink *sink)
{ {
GstCaps *caps;
GstPadTemplate *temp; GstPadTemplate *temp;
/* Create the PCM pad. */ /* Create the PCM pad. */
temp = GST_PAD_TEMPLATE_GET (dxr3audiosink_pcm_sink_factory); temp = gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory);
sink->pcm_sinkpad = gst_pad_new_from_template (temp, "pcm_sink"); sink->pcm_sinkpad = gst_pad_new_from_template (temp, "pcm_sink");
gst_pad_set_chain_function (sink->pcm_sinkpad, dxr3audiosink_chain_pcm); gst_pad_set_chain_function (sink->pcm_sinkpad, dxr3audiosink_chain_pcm);
gst_pad_set_link_function (sink->pcm_sinkpad, dxr3audiosink_pcm_sinklink); gst_pad_set_link_function (sink->pcm_sinkpad, dxr3audiosink_pcm_sinklink);
gst_element_add_pad (GST_ELEMENT (sink), sink->pcm_sinkpad); gst_element_add_pad (GST_ELEMENT (sink), sink->pcm_sinkpad);
/* Create the AC3 pad. */ /* Create the AC3 pad. */
temp = GST_PAD_TEMPLATE_GET (dxr3audiosink_ac3_sink_factory); temp = gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory);
sink->ac3_sinkpad = gst_pad_new_from_template (temp, "ac3_sink"); sink->ac3_sinkpad = gst_pad_new_from_template (temp, "ac3_sink");
caps = gst_pad_template_get_caps (temp);
gst_pad_try_set_caps (sink->ac3_sinkpad, caps);
gst_caps_unref (caps);
gst_pad_set_chain_function (sink->ac3_sinkpad, dxr3audiosink_chain_ac3); gst_pad_set_chain_function (sink->ac3_sinkpad, dxr3audiosink_chain_ac3);
gst_element_add_pad (GST_ELEMENT (sink), sink->ac3_sinkpad); gst_element_add_pad (GST_ELEMENT (sink), sink->ac3_sinkpad);
@ -506,30 +495,17 @@ dxr3audiosink_set_clock (GstElement *element, GstClock *clock)
static GstPadLinkReturn static GstPadLinkReturn
dxr3audiosink_pcm_sinklink (GstPad *pad, GstCaps *caps) dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps)
{ {
Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad)); Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
const gchar* mimetype; GstStructure *structure = gst_caps_get_structure (caps, 0);
gint rate; gint rate;
if (!GST_CAPS_IS_FIXED(caps)) { if (!gst_caps_is_fixed (caps)) {
return GST_PAD_LINK_DELAYED; return GST_PAD_LINK_DELAYED;
} }
mimetype = gst_caps_get_mime(caps); gst_structure_get_int (structure, "rate", &rate);
if (strcmp (mimetype, "audio/x-raw-int") != 0) {
return GST_PAD_LINK_REFUSED;
}
if (!gst_caps_has_property (caps, "rate")) {
return GST_PAD_LINK_REFUSED;
}
gst_caps_get_int (caps, "rate", &rate);
if (rate != 32000 && rate != 44100 &&
rate != 48000 && rate != 66000) {
return GST_PAD_LINK_DELAYED;
}
sink->rate = rate; sink->rate = rate;
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;

View file

@ -61,11 +61,12 @@ enum {
}; };
GST_PAD_TEMPLATE_FACTORY (dxr3spusink_sink_factory, static GstStaticPadTemplate dxr3spusink_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
NULL GST_STATIC_CAPS_ANY
); );
@ -149,7 +150,7 @@ dxr3spusink_base_init (Dxr3SpuSinkClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (dxr3spusink_sink_factory)); gst_static_pad_template_get (&dxr3spusink_sink_factory));
gst_element_class_set_details (element_class, gst_element_class_set_details (element_class,
&dxr3spusink_details); &dxr3spusink_details);
} }
@ -222,7 +223,7 @@ dxr3spusink_init (Dxr3SpuSink *sink)
GstPad *pad; GstPad *pad;
pad = gst_pad_new_from_template ( pad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (dxr3spusink_sink_factory), "sink"); gst_static_pad_template_get (&dxr3spusink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad); gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3spusink_chain); gst_pad_set_chain_function (pad, dxr3spusink_chain);

View file

@ -78,23 +78,19 @@ enum {
#define START_CODE_SEQUENCE_HEADER 0xB3 #define START_CODE_SEQUENCE_HEADER 0xB3
#define START_CODE_SEQUENCE_END 0xB7 #define START_CODE_SEQUENCE_END 0xB7
static GstStaticPadTemplate dxr3videosink_sink_factory =
GST_PAD_TEMPLATE_FACTORY (dxr3videosink_sink_factory, GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (
"dxr3videosink_sink", "video/mpeg, "
"video/mpeg", "mpegversion = (int) { 1, 2 }, "
"mpegversion", GST_PROPS_LIST ( "systemstream = (boolean) FALSE"
GST_PROPS_INT (1),
GST_PROPS_INT (2)
),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
/* width/height/framerate omitted, we don't /* width/height/framerate omitted, we don't
* need a parsed stream */ * need a parsed stream */
) )
) );
GST_PAD_EVENT_MASK_FUNCTION (dxr3videosink_get_event_mask, GST_PAD_EVENT_MASK_FUNCTION (dxr3videosink_get_event_mask,
@ -178,7 +174,7 @@ dxr3videosink_base_init (Dxr3VideoSinkClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (dxr3videosink_sink_factory)); gst_static_pad_template_get (&dxr3videosink_sink_factory));
gst_element_class_set_details (element_class, gst_element_class_set_details (element_class,
&dxr3videosink_details); &dxr3videosink_details);
} }
@ -218,7 +214,7 @@ dxr3videosink_init (Dxr3VideoSink *sink)
GstPad *pad; GstPad *pad;
pad = gst_pad_new_from_template ( pad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (dxr3videosink_sink_factory), "sink"); gst_static_pad_template_get (&dxr3videosink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad); gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3videosink_chain); gst_pad_set_chain_function (pad, dxr3videosink_chain);