[MOVED FROM BAD] Merge CAPS branch

Original commit message from CVS:
Merge CAPS branch
This commit is contained in:
David Schleef 2003-12-22 01:47:09 +00:00 committed by Jan Schmidt
parent 5d8667c892
commit cdbd6a095a

View file

@ -44,28 +44,23 @@ enum {
ARG_0 ARG_0
}; };
GST_PAD_TEMPLATE_FACTORY (y4mencode_src_factory, static GstStaticPadTemplate y4mencode_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS ("application/x-yuv4mpeg, "
"test_src", "y4mversion = (int) 1"
"application/x-yuv4mpeg",
"y4mversion", GST_PROPS_INT (1)
) )
) );
GST_PAD_TEMPLATE_FACTORY (y4mencode_sink_factory, static GstStaticPadTemplate y4mencode_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 (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420"))
"test_src", );
"video/x-raw-yuv",
GST_VIDEO_YUV_PAD_TEMPLATE_PROPS (
GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")))
)
)
static void gst_y4mencode_base_init (gpointer g_class); static void gst_y4mencode_base_init (gpointer g_class);
static void gst_y4mencode_class_init (GstY4mEncodeClass *klass); static void gst_y4mencode_class_init (GstY4mEncodeClass *klass);
@ -119,9 +114,9 @@ gst_y4mencode_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (y4mencode_src_factory)); gst_static_pad_template_get (&y4mencode_src_factory));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (y4mencode_sink_factory)); gst_static_pad_template_get (&y4mencode_sink_factory));
gst_element_class_set_details (element_class, &y4mencode_details); gst_element_class_set_details (element_class, &y4mencode_details);
} }
static void static void
@ -142,12 +137,12 @@ gst_y4mencode_class_init (GstY4mEncodeClass *klass)
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_y4mencode_sinkconnect (GstPad *pad, GstCaps *caps) gst_y4mencode_sinkconnect (GstPad *pad, const GstCaps *caps)
{ {
GstY4mEncode *filter; GstY4mEncode *filter;
gint idx = -1, i; gint idx = -1, i;
gfloat fps; gdouble fps;
float framerates[] = { gdouble framerates[] = {
00.000, 00.000,
23.976, 24.000, /* 24fps movie */ 23.976, 24.000, /* 24fps movie */
25.000, /* PAL */ 25.000, /* PAL */
@ -155,22 +150,22 @@ gst_y4mencode_sinkconnect (GstPad *pad, GstCaps *caps)
50.000, 50.000,
59.940, 60.000 59.940, 60.000
}; };
GstStructure *structure;
filter = GST_Y4MENCODE (gst_pad_get_parent (pad)); filter = GST_Y4MENCODE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) structure = gst_caps_get_structure (caps, 0);
return GST_PAD_LINK_DELAYED;
gst_caps_get_int (caps, "width", &filter->width); gst_structure_get_int (structure, "width", &filter->width);
gst_caps_get_int (caps, "height", &filter->height); gst_structure_get_int (structure, "height", &filter->height);
gst_caps_get_float (caps, "framerate", &fps); gst_structure_get_double (structure, "framerate", &fps);
/* find fps idx */ /* find fps idx */
for (i = 1; i < 9; i++) { for (i = 1; i < 9; i++) {
if (idx == -1) { if (idx == -1) {
idx = i; idx = i;
} else { } else {
gfloat old_diff = fabs(framerates[idx] - fps), gdouble old_diff = fabs(framerates[idx] - fps),
new_diff = fabs(framerates[i] - fps); new_diff = fabs(framerates[i] - fps);
if (new_diff < old_diff) { if (new_diff < old_diff) {
@ -187,13 +182,13 @@ static void
gst_y4mencode_init (GstY4mEncode *filter) gst_y4mencode_init (GstY4mEncode *filter)
{ {
filter->sinkpad = gst_pad_new_from_template( filter->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (y4mencode_sink_factory), "sink"); gst_static_pad_template_get (&y4mencode_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
gst_pad_set_chain_function (filter->sinkpad, gst_y4mencode_chain); gst_pad_set_chain_function (filter->sinkpad, gst_y4mencode_chain);
gst_pad_set_link_function (filter->sinkpad, gst_y4mencode_sinkconnect); gst_pad_set_link_function (filter->sinkpad, gst_y4mencode_sinkconnect);
filter->srcpad = gst_pad_new_from_template( filter->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (y4mencode_src_factory), "src"); gst_static_pad_template_get (&y4mencode_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->init = TRUE; filter->init = TRUE;