fix fixate and link

Original commit message from CVS:
fix fixate and link
This commit is contained in:
Thomas Vander Stichele 2004-08-12 15:58:52 +00:00
parent 2a0e5ee507
commit df4c4fbead
4 changed files with 43 additions and 41 deletions

View file

@ -1,3 +1,12 @@
2004-08-12 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_src_link), (gst_v4lsrc_fixate):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_set_capture):
fix fixate function to handle nonsimple caps.
remove bogus check in _link
cleanups
2004-08-12 Zaheer Abbas Merali <zaheerabbas at merali dot org> 2004-08-12 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_class_init), (gst_lame_init): * ext/lame/gstlame.c: (gst_lame_class_init), (gst_lame_init):

View file

@ -713,6 +713,7 @@ gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
GST_DEBUG_OBJECT (v4lsrc, "trying to set_capture %dx%d, palette %d", GST_DEBUG_OBJECT (v4lsrc, "trying to set_capture %dx%d, palette %d",
w, h, palette); w, h, palette);
/* this only fills in v4lsrc->mmap values */
if (!gst_v4lsrc_set_capture (v4lsrc, w, h, palette)) { if (!gst_v4lsrc_set_capture (v4lsrc, w, h, palette)) {
GST_WARNING_OBJECT (v4lsrc, "could not set_capture %dx%d, palette %d", GST_WARNING_OBJECT (v4lsrc, "could not set_capture %dx%d, palette %d",
w, h, palette); w, h, palette);
@ -721,29 +722,8 @@ gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
/* first try the negotiated settings using try_capture */ /* first try the negotiated settings using try_capture */
if (!gst_v4lsrc_try_capture (v4lsrc, w, h, palette)) { if (!gst_v4lsrc_try_capture (v4lsrc, w, h, palette)) {
GST_DEBUG_OBJECT (v4lsrc, "failed trying palette %d for w/h", palette); GST_DEBUG_OBJECT (v4lsrc, "failed trying palette %d for %dx%d", palette,
return GST_PAD_LINK_REFUSED; w, h);
}
if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc)))
GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities");
GST_DEBUG_OBJECT (v4lsrc, "done checking, with w %d h %d palette %d\n",
vwin->width, vwin->height, palette);
if (vwin->width != v4lsrc->mmap.width) {
/* We consider this a device error since it was called with fixed
* caps that the device doesn't accept. Still, there should be
* a way to handle this more gracefully, maybe provide a fixate
* function */
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SETTINGS, (NULL),
("Tried setting %dx%d but got %dx%d back as suggestion",
v4lsrc->mmap.width, v4lsrc->mmap.height, vwin->width,
vwin->height));
return GST_PAD_LINK_REFUSED;
}
if (vwin->height != v4lsrc->mmap.height) {
GST_ELEMENT_ERROR (v4lsrc, RESOURCE, SETTINGS, (NULL),
("Tried setting %dx%d but got %dx%d back as suggestion",
v4lsrc->mmap.width, v4lsrc->mmap.height, vwin->width,
vwin->height));
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
@ -763,28 +743,44 @@ gst_v4lsrc_fixate (GstPad * pad, const GstCaps * caps)
{ {
GstStructure *structure; GstStructure *structure;
GstCaps *newcaps; GstCaps *newcaps;
int i;
int targetwidth, targetheight;
GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad)); GstV4lSrc *v4lsrc = GST_V4LSRC (gst_pad_get_parent (pad));
struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap; struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap;
struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin;
if (gst_caps_get_size (caps) > 1) /* if device not yet open, no way to fixate */
return NULL; if (!GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) {
GST_DEBUG_OBJECT (v4lsrc, "device closed, cannot fixate");
if (!vcap) {
GST_DEBUG_OBJECT (v4lsrc, "don't have device caps, cannot fixate");
return NULL; return NULL;
} }
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d", GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d",
vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight); vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight);
targetwidth = vcap->minwidth;
targetheight = vcap->minheight;
if (gst_caps_structure_fixate_field_nearest_int (structure, "width", /* if we can get the current vwin settings, we use those to fixate */
vcap->maxwidth)) { if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc)))
return newcaps; GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities");
else {
targetwidth = vwin->width;
targetheight = vwin->height;
} }
if (gst_caps_structure_fixate_field_nearest_int (structure, "height", GST_DEBUG_OBJECT (v4lsrc, "targetting %dx%d", targetwidth, targetheight);
vcap->maxheight)) {
return newcaps; newcaps = gst_caps_copy (caps);
for (i = 0; i < gst_caps_get_size (caps); ++i) {
structure = gst_caps_get_structure (newcaps, i);
if (gst_caps_structure_fixate_field_nearest_int (structure, "width",
targetwidth)) {
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_int (structure, "height",
targetheight)) {
return newcaps;
}
} }
gst_caps_free (newcaps); gst_caps_free (newcaps);
return NULL; return NULL;

View file

@ -73,6 +73,7 @@ static const char *norm_name[] = {
/****************************************************** /******************************************************
* gst_v4l_get_capabilities(): * gst_v4l_get_capabilities():
* get the device's capturing capabilities * get the device's capturing capabilities
* sets v4lelement->vcap and v4lelement->vwin
* return value: TRUE on success, FALSE on error * return value: TRUE on success, FALSE on error
******************************************************/ ******************************************************/

View file

@ -154,11 +154,7 @@ gst_v4lsrc_set_capture (GstV4lSrc * v4lsrc,
gint width, gint height, gint palette) gint width, gint height, gint palette)
{ {
GST_DEBUG_OBJECT (v4lsrc, GST_DEBUG_OBJECT (v4lsrc,
"capture properties set to width = %d, height = %d, palette = %d", "capture properties set to %dx%d, palette %d", width, height, palette);
width, height, palette);
/*GST_V4L_CHECK_OPEN(GST_V4LELEMENT(v4lsrc)); */
/*GST_V4L_CHECK_NOT_ACTIVE(GST_V4LELEMENT(v4lsrc)); */
v4lsrc->mmap.width = width; v4lsrc->mmap.width = width;
v4lsrc->mmap.height = height; v4lsrc->mmap.height = height;