Fixes from caps changes
authorDavid Schleef <ds@schleef.org>
Tue, 8 Jul 2003 07:40:09 +0000 (07:40 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 8 Jul 2003 07:40:09 +0000 (07:40 +0000)
Original commit message from CVS:
Fixes from caps changes

gst/videotestsrc/gstvideotestsrc.c
gst/videotestsrc/videotestsrc.c

index 8629798ec3967f056030ca3a90adc017891430d1..d0513af8abe29a74ea93270bd1c79b37ca5d191c 100644 (file)
@@ -88,12 +88,12 @@ videotestsrc_src_template_factory(void)
   if(!templ){
     GstCaps *caps;
     GstCaps *caps1 = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+               "width", GST_PROPS_INT_RANGE (1, G_MAXINT),
+               "height", GST_PROPS_INT_RANGE (1, G_MAXINT),
                 "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
     GstCaps *caps2 = GST_CAPS_NEW("src","video/x-raw-rgb",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+               "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(caps1, gst_videotestsrc_get_capslist ());
@@ -214,6 +214,12 @@ gst_videotestsrc_srcconnect (GstPad * pad, GstCaps * caps)
     GstCaps *caps1 = gst_caps_copy_1(caps);
     GstPadLinkReturn ret;
 
+    gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT((float)videotestsrc->rate));
+    gst_caps_set(caps1, "width", GST_PROPS_INT(videotestsrc->width));
+    gst_caps_set(caps1, "height", GST_PROPS_INT(videotestsrc->height));
+
+    //g_print("%s\n", gst_caps_to_string(caps1));
+
     ret = gst_pad_try_set_caps(pad, caps1);
 
     if (ret != GST_PAD_LINK_OK &&
@@ -234,17 +240,22 @@ gst_videotestsrc_srcconnect (GstPad * pad, GstCaps * caps)
   }
 
   if (caps == NULL) {
-    GST_DEBUG (
-              "videotestsrc: no suitable opposite-side caps found");
+    GST_DEBUG ("videotestsrc: no suitable opposite-side caps found");
     return GST_PAD_LINK_REFUSED;
   }
 
   GST_DEBUG ("videotestsrc: using fourcc element %p %s\n",
        videotestsrc->fourcc, videotestsrc->fourcc->name);
 
-  gst_caps_get_int (caps, "width", &videotestsrc->width);
-  gst_caps_get_int (caps, "height", &videotestsrc->height);
-  gst_caps_get_float (caps, "framerate", &videotestsrc->rate);
+  if(videotestsrc->width==0){
+    gst_caps_get_int (caps, "width", &videotestsrc->width);
+  }
+  if(videotestsrc->height==0){
+    gst_caps_get_int (caps, "height", &videotestsrc->height);
+  }
+  if(videotestsrc->rate==0){
+    gst_caps_get_float (caps, "framerate", &videotestsrc->rate);
+  }
 
   videotestsrc->bpp = videotestsrc->fourcc->bitspp;
 
@@ -332,11 +343,11 @@ gst_videotestsrc_getcaps (GstPad * pad, GstCaps * caps)
              GST_CAPS_NEW("ack","video/x-raw-yuv",
                "width",GST_PROPS_INT_RANGE(16,4096),
                "height",GST_PROPS_INT_RANGE(16,4096),
-               "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)),
+                "framerate", GST_PROPS_FLOAT(vts->rate)),
              GST_CAPS_NEW("ack","video/x-raw-rgb",
                "width",GST_PROPS_INT_RANGE(16,4096),
                "height",GST_PROPS_INT_RANGE(16,4096),
-               "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT)));
+                "framerate", GST_PROPS_FLOAT(vts->rate)));
   }
 
   /* ref intersection and return it */
@@ -389,7 +400,7 @@ gst_videotestsrc_get (GstPad * pad)
 
   newsize = (videotestsrc->width * videotestsrc->height * videotestsrc->bpp) >> 3;
 
-  GST_DEBUG ("size=%ld %dx%d", newsize, videotestsrc->width, videotestsrc->height);
+  GST_DEBUG ("size=%ld %dx%d\n", newsize, videotestsrc->width, videotestsrc->height);
 
   buf = NULL;
   if (videotestsrc->pool) {
index 654b12a3800d4992d76ec99da5d28fe3c15ce43f..c201993113c17673a163c969841afa3b08a4651b 100644 (file)
@@ -379,15 +379,33 @@ int n_fourccs = sizeof (fourcc_list) / sizeof (fourcc_list[0]);
 struct fourcc_list_struct *paintinfo_find_by_caps(GstCaps *caps)
 {
   int i;
+  const char *mimetype = gst_caps_get_mime(caps);
+  guint32 format;
 
-  for (i = 0; i < n_fourccs; i++) {
-    GstCaps *c;
-    
-    c = gst_caps_intersect(caps,paint_get_caps(fourcc_list + i));
-    if(c){
-      return fourcc_list + i;
+  if(strcmp(mimetype, "video/x-raw-yuv")==0){
+    char *s;
+    int fourcc;
+
+    gst_caps_get(caps, "format", &format);
+    for (i = 0; i < n_fourccs; i++) {
+      s = fourcc_list[i].fourcc;
+      g_print("testing " GST_FOURCC_FORMAT " and %s\n",
+         GST_FOURCC_ARGS(format), s);
+      fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
+      if(fourcc == format){
+        return fourcc_list + i;
+      }
     }
+  }else if(strcmp(mimetype, "video/x-raw-yuv")==0){
+    g_warning("video/x-raw-rgb not implemented");
+    return NULL;
+  }else{
+    g_warning("unknown format");
+    return NULL;
   }
+
+  g_warning("format not found");
+
   return NULL;
 }