summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@hotmail.com>2020-01-08 15:04:18 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-14 11:36:17 +0000
commit0a2a25981cd280640be389883cca5f14c09792da (patch)
treedb7a9d197b02818ce3902109f92ba8a9e8edf044
parent3737692dd4f7d50c988d9029905ab8216d692559 (diff)
libs: encoder: add a helper function to get all supported profiles
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c49
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.h3
2 files changed, 52 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 1befb562..b743a5a5 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -1764,6 +1764,55 @@ gst_vaapi_encoder_get_entrypoint (GstVaapiEncoder * encoder,
return GST_VAAPI_ENTRYPOINT_INVALID;
}
+/**
+ * gst_vaapi_encoder_get_available_profiles:
+ * @encoder: a #GstVaapiEncoder
+ *
+ * Collect all supported #GstVaapiProfile of current @encoder's #GstVaapiCodec,
+ * and return them as a #GArray
+ *
+ * Returns: An #GArray of #GstVaapiProfile.
+ **/
+GArray *
+gst_vaapi_encoder_get_available_profiles (GstVaapiEncoder * encoder)
+{
+ GstVaapiCodec codec;
+ GArray *all_profiles = NULL;
+ GArray *profiles = NULL;
+ GstVaapiProfile profile;
+ guint i;
+
+ g_return_val_if_fail (encoder != NULL, 0);
+
+ codec = GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data->codec;
+
+ all_profiles = gst_vaapi_display_get_encode_profiles
+ (GST_VAAPI_ENCODER_DISPLAY (encoder));
+ if (!all_profiles)
+ goto out;
+
+ /* Add all supported profiles belong to current codec */
+ profiles = g_array_new (FALSE, FALSE, sizeof (GstVaapiProfile));
+ if (!profiles)
+ goto out;
+
+ for (i = 0; i < all_profiles->len; i++) {
+ profile = g_array_index (all_profiles, GstVaapiProfile, i);
+ if (gst_vaapi_profile_get_codec (profile) == codec)
+ g_array_append_val (profiles, profile);
+ }
+
+out:
+ if (all_profiles)
+ g_array_unref (all_profiles);
+ if (profiles && profiles->len == 0) {
+ g_array_unref (profiles);
+ profiles = NULL;
+ }
+
+ return profiles;
+}
+
/** Returns a GType for the #GstVaapiEncoderTune set */
GType
gst_vaapi_encoder_tune_get_type (void)
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.h b/gst-libs/gst/vaapi/gstvaapiencoder.h
index 1d81baf1..fbc81e39 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.h
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.h
@@ -192,6 +192,9 @@ GstVaapiEntrypoint
gst_vaapi_encoder_get_entrypoint (GstVaapiEncoder * encoder,
GstVaapiProfile profile);
+GArray *
+gst_vaapi_encoder_get_available_profiles (GstVaapiEncoder * encoder);
+
G_END_DECLS
#endif /* GST_VAAPI_ENCODER_H */