diff options
author | Olivier Crete <olivier.crete@collabora.co.uk> | 2007-11-10 05:14:27 +0000 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.co.uk> | 2009-03-03 14:34:06 -0500 |
commit | 38006a4c22a60a75935b081644544d35e38fa524 (patch) | |
tree | 625468771a5d9cba263b533fa3166328e7255ccf /ext | |
parent | 7f0628b5f983ab7b30e94ed88b99157d53ea5bd6 (diff) | |
download | gst-plugins-bad-38006a4c22a60a75935b081644544d35e38fa524.tar.gz gst-plugins-bad-38006a4c22a60a75935b081644544d35e38fa524.tar.bz2 gst-plugins-bad-38006a4c22a60a75935b081644544d35e38fa524.zip |
[MOVED FROM GST-P-FARSIGHT] Make the _set_caps function of mimic enc more robust
20071110051427-3e2dc-381a71f2cbfdbf508e941b672e9058c82fabce24.gz
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mimic/gstmimenc.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/ext/mimic/gstmimenc.c b/ext/mimic/gstmimenc.c index 5bd48363..d94ed3bb 100644 --- a/ext/mimic/gstmimenc.c +++ b/ext/mimic/gstmimenc.c @@ -175,7 +175,7 @@ gst_mimenc_setcaps (GstPad *pad, GstCaps *caps) { GstMimEnc *filter; GstStructure *structure; - int ret, height, width; + int ret = TRUE, height, width; filter = GST_MIMENC (gst_pad_get_parent (pad)); g_return_val_if_fail (filter != NULL, FALSE); @@ -183,17 +183,34 @@ gst_mimenc_setcaps (GstPad *pad, GstCaps *caps) structure = gst_caps_get_structure( caps, 0 ); ret = gst_structure_get_int( structure, "width", &width ); + if (!ret) { + GST_DEBUG_OBJECT (filter, "No width set"); + goto out; + } ret = gst_structure_get_int( structure, "height", &height ); - filter->width = (guint16)width; - filter->height = (guint16)height; - filter->res = (width == 320) ? MIMIC_RES_HIGH : MIMIC_RES_LOW; - GST_DEBUG ("Got info from caps w : %d, h : %d", filter->width, filter->height); if (!ret) { - gst_object_unref(filter); - return FALSE; + GST_DEBUG_OBJECT (filter, "No height set"); + goto out; + } + + if (width == 320 && height == 240) + filter->res = MIMIC_RES_HIGH; + else if (width == 160 && height == 120) + filter->res = MIMIC_RES_LOW; + else { + GST_WARNING_OBJECT (filter, "Invalid resolution %dx%d", width, height); + ret = FALSE; + goto out; } + + filter->width = (guint16)width; + filter->height = (guint16)height; + + GST_DEBUG_OBJECT (filter,"Got info from caps w : %d, h : %d", + filter->width, filter->height); + out: gst_object_unref(filter); - return TRUE; + return ret; } static GstFlowReturn |