Caps fixes and general cleanup.
authorDavid Schleef <ds@schleef.org>
Mon, 14 Jul 2003 08:32:38 +0000 (08:32 +0000)
committerDavid Schleef <ds@schleef.org>
Mon, 14 Jul 2003 08:32:38 +0000 (08:32 +0000)
Original commit message from CVS:
Caps fixes and general cleanup.

gst/videofilter/gstvideobalance.c
gst/videofilter/gstvideofilter.c
gst/videofilter/gstvideofilter.h
gst/videofilter/gstvideoflip.c
gst/videofilter/gstvideotemplate.c

index 136015fb47412e594e5b64a1a1337be16184b7c1..06ed0d6dc353a8f5bebf81c2422b37f30123b856 100644 (file)
@@ -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 ());
 
index 36604e1ebdfb6af997a87104a1a5b694eb9cfeb9..d56d39e4feb47e69c214e6f12b0b8f556ee9dcae 100644 (file)
@@ -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)
index 2b7d9f9dee044f14b84823a07c1b9f19338fdb57..786783506e80df9d6b3da0d466a3bdacc19a0836 100644 (file)
@@ -76,6 +76,7 @@ struct _GstVideofilter {
   /* private */
   gint from_buf_size;
   gint to_buf_size;
+  gfloat framerate;
 
   GstBuffer *in_buf;
   GstBuffer *out_buf;
index 36cd5c08f4b80b04b5e46114d0bd3cb27a372dd2..cfa2b0479828aa3513e1b853a4043fb93a7d2bc0 100644 (file)
@@ -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 ());
 
index 90c9750cca74afb42b09d0cc141f4f48f30c0966..f8ab5f6539d52fb980f2c8d45594d2a7023864cf 100644 (file)
@@ -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 ());