Fixes from caps changes

Original commit message from CVS:
Fixes from caps changes
This commit is contained in:
David Schleef 2003-07-08 07:40:09 +00:00
parent a88415b831
commit 9567e9fdc5
2 changed files with 47 additions and 18 deletions

View file

@ -88,12 +88,12 @@ videotestsrc_src_template_factory(void)
if(!templ){ if(!templ){
GstCaps *caps; GstCaps *caps;
GstCaps *caps1 = GST_CAPS_NEW("src","video/x-raw-yuv", GstCaps *caps1 = GST_CAPS_NEW("src","video/x-raw-yuv",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT), "width", GST_PROPS_INT_RANGE (1, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT), "height", GST_PROPS_INT_RANGE (1, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
GstCaps *caps2 = GST_CAPS_NEW("src","video/x-raw-rgb", GstCaps *caps2 = GST_CAPS_NEW("src","video/x-raw-rgb",
"width", GST_PROPS_INT_RANGE (0, G_MAXINT), "width", GST_PROPS_INT_RANGE (1, G_MAXINT),
"height", GST_PROPS_INT_RANGE (0, G_MAXINT), "height", GST_PROPS_INT_RANGE (1, G_MAXINT),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
caps = gst_caps_intersect(caps1, gst_videotestsrc_get_capslist ()); 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); GstCaps *caps1 = gst_caps_copy_1(caps);
GstPadLinkReturn ret; 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); ret = gst_pad_try_set_caps(pad, caps1);
if (ret != GST_PAD_LINK_OK && if (ret != GST_PAD_LINK_OK &&
@ -234,17 +240,22 @@ gst_videotestsrc_srcconnect (GstPad * pad, GstCaps * caps)
} }
if (caps == NULL) { if (caps == NULL) {
GST_DEBUG ( GST_DEBUG ("videotestsrc: no suitable opposite-side caps found");
"videotestsrc: no suitable opposite-side caps found");
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
GST_DEBUG ("videotestsrc: using fourcc element %p %s\n", GST_DEBUG ("videotestsrc: using fourcc element %p %s\n",
videotestsrc->fourcc, videotestsrc->fourcc->name); videotestsrc->fourcc, videotestsrc->fourcc->name);
if(videotestsrc->width==0){
gst_caps_get_int (caps, "width", &videotestsrc->width); gst_caps_get_int (caps, "width", &videotestsrc->width);
}
if(videotestsrc->height==0){
gst_caps_get_int (caps, "height", &videotestsrc->height); gst_caps_get_int (caps, "height", &videotestsrc->height);
}
if(videotestsrc->rate==0){
gst_caps_get_float (caps, "framerate", &videotestsrc->rate); gst_caps_get_float (caps, "framerate", &videotestsrc->rate);
}
videotestsrc->bpp = videotestsrc->fourcc->bitspp; videotestsrc->bpp = videotestsrc->fourcc->bitspp;
@ -332,11 +343,11 @@ gst_videotestsrc_getcaps (GstPad * pad, GstCaps * caps)
GST_CAPS_NEW("ack","video/x-raw-yuv", GST_CAPS_NEW("ack","video/x-raw-yuv",
"width",GST_PROPS_INT_RANGE(16,4096), "width",GST_PROPS_INT_RANGE(16,4096),
"height",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", GST_CAPS_NEW("ack","video/x-raw-rgb",
"width",GST_PROPS_INT_RANGE(16,4096), "width",GST_PROPS_INT_RANGE(16,4096),
"height",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 */ /* ref intersection and return it */
@ -389,7 +400,7 @@ gst_videotestsrc_get (GstPad * pad)
newsize = (videotestsrc->width * videotestsrc->height * videotestsrc->bpp) >> 3; 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; buf = NULL;
if (videotestsrc->pool) { if (videotestsrc->pool) {

View 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) struct fourcc_list_struct *paintinfo_find_by_caps(GstCaps *caps)
{ {
int i; int i;
const char *mimetype = gst_caps_get_mime(caps);
guint32 format;
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++) { for (i = 0; i < n_fourccs; i++) {
GstCaps *c; s = fourcc_list[i].fourcc;
g_print("testing " GST_FOURCC_FORMAT " and %s\n",
c = gst_caps_intersect(caps,paint_get_caps(fourcc_list + i)); GST_FOURCC_ARGS(format), s);
if(c){ fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
if(fourcc == format){
return fourcc_list + i; 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; return NULL;
} }