plugins: handle if gst_video_info_from_caps() fails

Let's play safe and return error if, somehow, the received caps are wrong.
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-05-23 17:55:35 +02:00
parent 6d8b7056cc
commit 9159328434

View file

@ -509,7 +509,8 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
if (!pool) if (!pool)
goto error_create_pool; goto error_create_pool;
gst_video_info_from_caps (&vi, caps); if (!gst_video_info_from_caps (&vi, caps))
goto error_invalid_caps;
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) { if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) {
GST_DEBUG ("assume video buffer pool format is NV12"); GST_DEBUG ("assume video buffer pool format is NV12");
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12, gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
@ -529,6 +530,11 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
error_invalid_caps:
{
GST_ERROR_OBJECT (plugin, "invalid caps %" GST_PTR_FORMAT, caps);
return FALSE;
}
error_create_pool: error_create_pool:
{ {
GST_ERROR_OBJECT (plugin, "failed to create buffer pool"); GST_ERROR_OBJECT (plugin, "failed to create buffer pool");
@ -702,7 +708,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
if (!gst_vaapi_plugin_base_ensure_display (plugin)) if (!gst_vaapi_plugin_base_ensure_display (plugin))
goto error_ensure_display; goto error_ensure_display;
gst_video_info_from_caps (&vi, caps); if (!gst_video_info_from_caps (&vi, caps))
goto error_invalid_caps;
if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED)
gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12, gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi)); GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
@ -779,6 +786,11 @@ error_no_caps:
GST_ERROR_OBJECT (plugin, "no caps specified"); GST_ERROR_OBJECT (plugin, "no caps specified");
return FALSE; return FALSE;
} }
error_invalid_caps:
{
GST_ERROR_OBJECT (plugin, "invalid caps %" GST_PTR_FORMAT, caps);
return FALSE;
}
error_ensure_display: error_ensure_display:
{ {
GST_ERROR_OBJECT (plugin, "failed to ensure display of type %d", GST_ERROR_OBJECT (plugin, "failed to ensure display of type %d",