From ad79edbe4253373a22aca89f3d908c5b86d33470 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 14 Jul 2003 08:32:38 +0000 Subject: [PATCH] Caps fixes and general cleanup. Original commit message from CVS: Caps fixes and general cleanup. --- gst/videofilter/gstvideobalance.c | 10 ++++---- gst/videofilter/gstvideofilter.c | 47 +++++++++++++++++++++++--------------- gst/videofilter/gstvideofilter.h | 1 + gst/videofilter/gstvideoflip.c | 10 ++++---- gst/videofilter/gstvideotemplate.c | 12 ++++++---- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c index 136015f..06ed0d6 100644 --- a/gst/videofilter/gstvideobalance.c +++ b/gst/videofilter/gstvideobalance.c @@ -144,9 +144,10 @@ gst_videobalance_src_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("src","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ()); @@ -161,9 +162,10 @@ gst_videobalance_sink_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("sink","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ()); diff --git a/gst/videofilter/gstvideofilter.c b/gst/videofilter/gstvideofilter.c index 36604e1..d56d39e 100644 --- a/gst/videofilter/gstvideofilter.c +++ b/gst/videofilter/gstvideofilter.c @@ -111,9 +111,10 @@ gst_videofilter_src_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("src","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ()); @@ -128,9 +129,10 @@ gst_videofilter_sink_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("sink","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ()); @@ -151,7 +153,7 @@ static GstCaps *gst_videofilter_format_get_caps(GstVideofilterFormat *format) fourcc = GST_MAKE_FOURCC(format->fourcc[0],format->fourcc[1],format->fourcc[2],format->fourcc[3]); if(format->bpp){ - caps = GST_CAPS_NEW ("videoflip", "video/raw", + caps = GST_CAPS_NEW ("videofilter", "video/x-raw-rgb", "format", GST_PROPS_FOURCC (fourcc), "depth", GST_PROPS_INT(format->bpp), "bpp", GST_PROPS_INT(format->depth), @@ -160,8 +162,12 @@ static GstCaps *gst_videofilter_format_get_caps(GstVideofilterFormat *format) "green_mask", GST_PROPS_INT(format->green_mask), "blue_mask", GST_PROPS_INT(format->blue_mask)); }else{ - caps = GST_CAPS_NEW ("videoflip", "video/raw", - "format", GST_PROPS_FOURCC (fourcc)); + caps = GST_CAPS_NEW ("videoflip", "video/x-raw-yuv", + "format", GST_PROPS_FOURCC (fourcc), + "height", GST_PROPS_INT_RANGE (1,G_MAXINT), + "width", GST_PROPS_INT_RANGE (1,G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0,G_MAXFLOAT) + ); } return caps; @@ -204,7 +210,7 @@ gst_videofilter_sink_getcaps (GstPad *pad, GstCaps *caps) /* get list of peer's caps */ peercaps = gst_pad_get_allowed_caps (videofilter->srcpad); - g_print("peercaps: %s\n", gst_caps_to_string(peercaps)); + //g_print("peercaps: %s\n", gst_caps_to_string(peercaps)); /* FIXME videofilter doesn't allow passthru of video formats it * doesn't understand. */ @@ -216,30 +222,26 @@ gst_videofilter_sink_getcaps (GstPad *pad, GstCaps *caps) GstCaps *fromcaps = gst_videofilter_format_get_caps(g_ptr_array_index( klass->formats,i)); - g_print("testing caps: %s\n", gst_caps_to_string(fromcaps)); + //g_print("testing caps: %s\n", gst_caps_to_string(fromcaps)); icaps = gst_caps_intersect(fromcaps, peercaps); //if(gst_caps_is_always_compatible(fromcaps, peercaps)){ if(icaps != NULL){ capslist = gst_caps_append(capslist, fromcaps); - g_print("(yes)\n"); - }else{ - g_print("(no)\n"); } //gst_caps_unref (fromcaps); if(icaps) gst_caps_unref (icaps); } gst_caps_unref (peercaps); - sizecaps = GST_CAPS_NEW("videofilter_size","video/raw", + sizecaps = GST_CAPS_NEW("videofilter_size","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(capslist, sizecaps); gst_caps_unref (sizecaps); - g_print("getcaps: %s\n",gst_caps_to_string(caps)); - return caps; } @@ -307,6 +309,7 @@ gst_videofilter_sink_link (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &videofilter->from_width); gst_caps_get_int (caps, "height", &videofilter->from_height); + gst_caps_get_float (caps, "framerate", &videofilter->framerate); gst_videofilter_setup(videofilter); @@ -314,10 +317,13 @@ gst_videofilter_sink_link (GstPad *pad, GstCaps *caps) gst_caps_set(peercaps, "width", GST_PROPS_INT (videofilter->to_width)); gst_caps_set(peercaps, "height", GST_PROPS_INT (videofilter->to_height)); + gst_caps_set(peercaps, "framerate", GST_PROPS_FLOAT (videofilter->framerate)); + + g_print("setting %s\n",gst_caps_to_string(peercaps)); ret = gst_pad_try_set_caps (videofilter->srcpad, peercaps); - gst_caps_unref(peercaps); + //gst_caps_unref(peercaps); if(ret==GST_PAD_LINK_OK || ret==GST_PAD_LINK_DONE){ caps = gst_pad_get_caps (videofilter->srcpad); @@ -482,13 +488,16 @@ void gst_videofilter_set_output_size(GstVideofilter *videofilter, srccaps = gst_caps_copy(gst_pad_get_caps(videofilter->srcpad)); + if(!GST_CAPS_IS_FIXED(srccaps)){ + return; + } + gst_caps_set(srccaps, "width", GST_PROPS_INT (videofilter->to_width)); gst_caps_set(srccaps, "height", GST_PROPS_INT (videofilter->to_height)); ret = gst_pad_try_set_caps (videofilter->srcpad, srccaps); - g_print("try_set_caps() returned %d\n", ret); - + g_return_if_fail(ret<0); } static void gst_videofilter_setup(GstVideofilter *videofilter) diff --git a/gst/videofilter/gstvideofilter.h b/gst/videofilter/gstvideofilter.h index 2b7d9f9..7867835 100644 --- a/gst/videofilter/gstvideofilter.h +++ b/gst/videofilter/gstvideofilter.h @@ -76,6 +76,7 @@ struct _GstVideofilter { /* private */ gint from_buf_size; gint to_buf_size; + gfloat framerate; GstBuffer *in_buf; GstBuffer *out_buf; diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c index 36cd5c0..cfa2b04 100644 --- a/gst/videofilter/gstvideoflip.c +++ b/gst/videofilter/gstvideoflip.c @@ -166,9 +166,10 @@ gst_videoflip_src_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("src","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); @@ -183,9 +184,10 @@ gst_videoflip_sink_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("sink","video/raw", + GstCaps *caps = GST_CAPS_NEW("sink","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); diff --git a/gst/videofilter/gstvideotemplate.c b/gst/videofilter/gstvideotemplate.c index 90c9750..f8ab5f6 100644 --- a/gst/videofilter/gstvideotemplate.c +++ b/gst/videofilter/gstvideotemplate.c @@ -132,9 +132,10 @@ gst_videotemplate_src_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("src","video/raw", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", + "width", GST_PROPS_INT_RANGE (1, G_MAXINT), + "height", GST_PROPS_INT_RANGE (1, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ()); @@ -149,9 +150,10 @@ gst_videotemplate_sink_template_factory(void) static GstPadTemplate *templ = NULL; if(!templ){ - GstCaps *caps = GST_CAPS_NEW("sink","video/raw", + GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); caps = gst_caps_intersect(caps, gst_videotemplate_get_capslist ()); -- 2.7.4