mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
plugin: util: add helper function to detect profiles in caps.
This commit is contained in:
parent
0a2a25981c
commit
67e7e15408
2 changed files with 71 additions and 0 deletions
|
@ -1008,3 +1008,66 @@ gst_vaapi_codecs_has_codec (GArray * codecs, GstVaapiCodec codec)
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_h26x_encoder_get_profiles_from_caps:
|
||||||
|
* @caps: a #GstCaps to detect
|
||||||
|
* @func: a #GstVaapiStrToProfileFunc
|
||||||
|
*
|
||||||
|
* This function will detect all profile strings in @caps and
|
||||||
|
* return the according GstVaapiProfile in array. This can just
|
||||||
|
* work for h264 and h265 now.
|
||||||
|
*
|
||||||
|
* Return: A #GArray of @GstVaapiProfile if succeed, %NULL if fail.
|
||||||
|
**/
|
||||||
|
GArray *
|
||||||
|
gst_vaapi_h26x_encoder_get_profiles_from_caps (GstCaps * caps,
|
||||||
|
GstVaapiStrToProfileFunc func)
|
||||||
|
{
|
||||||
|
guint i, j;
|
||||||
|
GstVaapiProfile profile;
|
||||||
|
GArray *profiles = NULL;
|
||||||
|
|
||||||
|
if (!caps)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
profiles = g_array_new (FALSE, FALSE, sizeof (GstVaapiProfile));
|
||||||
|
if (!profiles)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||||
|
GstStructure *const structure = gst_caps_get_structure (caps, i);
|
||||||
|
const GValue *const value = gst_structure_get_value (structure, "profile");
|
||||||
|
|
||||||
|
if (value && G_VALUE_HOLDS_STRING (value)) {
|
||||||
|
const gchar *str = g_value_get_string (value);
|
||||||
|
if (str) {
|
||||||
|
profile = func (str);
|
||||||
|
if (profile != GST_VAAPI_PROFILE_UNKNOWN)
|
||||||
|
g_array_append_val (profiles, profile);
|
||||||
|
}
|
||||||
|
} else if (value && GST_VALUE_HOLDS_LIST (value)) {
|
||||||
|
const GValue *v;
|
||||||
|
const gchar *str;
|
||||||
|
for (j = 0; j < gst_value_list_get_size (value); j++) {
|
||||||
|
v = gst_value_list_get_value (value, j);
|
||||||
|
if (!v || !G_VALUE_HOLDS_STRING (v))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
str = g_value_get_string (v);
|
||||||
|
if (str) {
|
||||||
|
profile = func (str);
|
||||||
|
if (profile != GST_VAAPI_PROFILE_UNKNOWN)
|
||||||
|
g_array_append_val (profiles, profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profiles->len == 0) {
|
||||||
|
g_array_unref (profiles);
|
||||||
|
profiles = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return profiles;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
#include "gstvaapivideomemory.h"
|
#include "gstvaapivideomemory.h"
|
||||||
|
|
||||||
|
typedef GstVaapiProfile (*GstVaapiStrToProfileFunc) (const gchar * str);
|
||||||
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
|
gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
|
||||||
|
@ -152,4 +155,9 @@ G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_codecs_has_codec (GArray * codecs, GstVaapiCodec codec);
|
gst_vaapi_codecs_has_codec (GArray * codecs, GstVaapiCodec codec);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GArray *
|
||||||
|
gst_vaapi_h26x_encoder_get_profiles_from_caps (GstCaps * caps,
|
||||||
|
GstVaapiStrToProfileFunc func);
|
||||||
|
|
||||||
#endif /* GST_VAAPI_PLUGIN_UTIL_H */
|
#endif /* GST_VAAPI_PLUGIN_UTIL_H */
|
||||||
|
|
Loading…
Reference in a new issue