From 9567e9fdc575053c1ea2500ca61b3e39b704e7cf Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 8 Jul 2003 07:40:09 +0000 Subject: [PATCH] Fixes from caps changes Original commit message from CVS: Fixes from caps changes --- gst/videotestsrc/gstvideotestsrc.c | 35 ++++++++++++++++++++---------- gst/videotestsrc/videotestsrc.c | 30 ++++++++++++++++++++----- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 8629798ec3..d0513af8ab 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -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) { diff --git a/gst/videotestsrc/videotestsrc.c b/gst/videotestsrc/videotestsrc.c index 654b12a380..c201993113 100644 --- a/gst/videotestsrc/videotestsrc.c +++ b/gst/videotestsrc/videotestsrc.c @@ -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; }