vaapipostproc: element warning if video direction is unsupported

If the video direction is unsupported by the driver, an element
warning is posted in the bus to notify the application.

gst_vaapi_enum_type_get_nick() was added in the library thus it can
be used elsewhere. It retrives the nick from an enum gtype.
This commit is contained in:
Víctor Manuel Jáquez Leal 2019-07-26 19:46:09 +02:00
parent 47ff72a6d4
commit c06b587819
4 changed files with 39 additions and 26 deletions

View file

@ -118,17 +118,6 @@ gst_vaapi_scale_method_get_type (void)
return g_type;
}
static const gchar *
gst_vaapi_get_video_direction_nick (GstVideoOrientationMethod method)
{
gpointer const klass = g_type_class_peek (GST_TYPE_VIDEO_ORIENTATION_METHOD);
GEnumValue *const e = g_enum_get_value (klass, method);
if (e)
return e->value_nick;
return "<unknown>";
}
GType
gst_vaapi_deinterlace_method_get_type (void)
{
@ -1996,23 +1985,15 @@ gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
from_GstVideoOrientationMethod (method, &va_mirror, &va_rotation);
if (va_mirror != VA_MIRROR_NONE && !(filter->mirror_flags & va_mirror)) {
GST_WARNING ("%s video-direction unsupported",
gst_vaapi_get_video_direction_nick (method));
return TRUE;
}
if (va_mirror != VA_MIRROR_NONE && !(filter->mirror_flags & va_mirror))
return FALSE;
if (va_rotation != VA_ROTATION_NONE
&& !(filter->rotation_flags & (1 << va_rotation))) {
GST_WARNING ("%s video-direction unsupported",
gst_vaapi_get_video_direction_nick (method));
return TRUE;
}
&& !(filter->rotation_flags & (1 << va_rotation)))
return FALSE;
}
#else
GST_WARNING ("%s video-direction unsupported",
gst_vaapi_get_video_direction_nick (method));
return TRUE;
return FALSE;
#endif
filter->video_direction = method;

View file

@ -215,3 +215,22 @@ gst_vaapi_type_define_enum_subset_from_mask (GstVaapiEnumSubset * subset,
}
return subset->type;
}
/**
* gst_vaapi_enum_type_get_nick:
* @type: an enum #GType
* @value: the value to get its nick
*
* Returns: (tranfer none); the string associated with
* @value. Otherwise "<unknown>"
**/
const gchar *
gst_vaapi_enum_type_get_nick (GType type, gint value)
{
gpointer const klass = g_type_class_peek (type);
GEnumValue *const e = g_enum_get_value (klass, value);
if (e)
return e->value_nick;
return "<unknown>";
}

View file

@ -157,6 +157,10 @@ G_PASTE(name,_get_type)(void) \
return gst_vaapi_type_define_enum_subset_from_mask(&subset, MASK); \
}
G_GNUC_INTERNAL
const gchar *
gst_vaapi_enum_type_get_nick (GType type, gint value);
G_END_DECLS
#endif /* GST_VAAPI_VALUE_H */

View file

@ -37,6 +37,8 @@
#include "gstcompat.h"
#include <gst/video/video.h>
#include <gst/vaapi/gstvaapivalue.h>
#include "gstvaapipostproc.h"
#include "gstvaapipostprocutil.h"
#include "gstvaapipluginutil.h"
@ -595,8 +597,15 @@ update_filter (GstVaapiPostproc * postproc)
if (postproc->flags & GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION) {
if (!gst_vaapi_filter_set_video_direction (postproc->filter,
postproc->video_direction))
return FALSE;
postproc->video_direction)) {
GST_ELEMENT_WARNING (postproc, LIBRARY, SETTINGS,
("Unsupported video direction '%s' by driver.",
gst_vaapi_enum_type_get_nick
(GST_TYPE_VIDEO_ORIENTATION_METHOD, postproc->video_direction)),
("video direction transformation ignored"));
/* Don't return FALSE because other filters might be set */
}
if (gst_vaapi_filter_get_video_direction_default (postproc->filter) ==
postproc->video_direction)