mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 15:36:42 +00:00
nvcodec: Keep requested rank for default device
Fix for default encoder and decoder element factory to make them have higher rank than the others.
This commit is contained in:
parent
92afa74939
commit
a2ada54265
2 changed files with 14 additions and 6 deletions
|
@ -1977,12 +1977,12 @@ gst_nv_base_enc_register (GstPlugin * plugin, GType type, const char *codec,
|
||||||
GType subtype;
|
GType subtype;
|
||||||
gchar *type_name;
|
gchar *type_name;
|
||||||
GstNvEncClassData *cdata;
|
GstNvEncClassData *cdata;
|
||||||
|
gboolean is_default = TRUE;
|
||||||
|
|
||||||
cdata = g_new0 (GstNvEncClassData, 1);
|
cdata = g_new0 (GstNvEncClassData, 1);
|
||||||
cdata->sink_caps = gst_caps_ref (sink_caps);
|
cdata->sink_caps = gst_caps_ref (sink_caps);
|
||||||
cdata->src_caps = gst_caps_ref (src_caps);
|
cdata->src_caps = gst_caps_ref (src_caps);
|
||||||
cdata->cuda_device_id = device_id;
|
cdata->cuda_device_id = device_id;
|
||||||
cdata->is_default = TRUE;
|
|
||||||
|
|
||||||
g_type_query (type, &type_query);
|
g_type_query (type, &type_query);
|
||||||
memset (&type_info, 0, sizeof (type_info));
|
memset (&type_info, 0, sizeof (type_info));
|
||||||
|
@ -1996,13 +1996,17 @@ gst_nv_base_enc_register (GstPlugin * plugin, GType type, const char *codec,
|
||||||
if (g_type_from_name (type_name) != 0) {
|
if (g_type_from_name (type_name) != 0) {
|
||||||
g_free (type_name);
|
g_free (type_name);
|
||||||
type_name = g_strdup_printf ("nv%sdevice%denc", codec, device_id);
|
type_name = g_strdup_printf ("nv%sdevice%denc", codec, device_id);
|
||||||
cdata->is_default = FALSE;
|
is_default = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cdata->is_default = is_default;
|
||||||
subtype = g_type_register_static (type, type_name, &type_info, 0);
|
subtype = g_type_register_static (type, type_name, &type_info, 0);
|
||||||
|
|
||||||
/* make lower rank than default device */
|
/* make lower rank than default device */
|
||||||
if (!gst_element_register (plugin, type_name, rank - 1, subtype))
|
if (rank > 0 && !is_default)
|
||||||
|
rank--;
|
||||||
|
|
||||||
|
if (!gst_element_register (plugin, type_name, rank, subtype))
|
||||||
GST_WARNING ("Failed to register plugin '%s'", type_name);
|
GST_WARNING ("Failed to register plugin '%s'", type_name);
|
||||||
|
|
||||||
g_free (type_name);
|
g_free (type_name);
|
||||||
|
|
|
@ -1007,6 +1007,7 @@ gst_nvdec_subclass_register (GstPlugin * plugin, GType type,
|
||||||
GType subtype;
|
GType subtype;
|
||||||
gchar *type_name;
|
gchar *type_name;
|
||||||
GstNvDecClassData *cdata;
|
GstNvDecClassData *cdata;
|
||||||
|
gboolean is_default = TRUE;
|
||||||
|
|
||||||
cdata = g_new0 (GstNvDecClassData, 1);
|
cdata = g_new0 (GstNvDecClassData, 1);
|
||||||
cdata->sink_caps = gst_caps_ref (sink_caps);
|
cdata->sink_caps = gst_caps_ref (sink_caps);
|
||||||
|
@ -1014,7 +1015,6 @@ gst_nvdec_subclass_register (GstPlugin * plugin, GType type,
|
||||||
cdata->codec_type = codec_type;
|
cdata->codec_type = codec_type;
|
||||||
cdata->codec = g_strdup (codec);
|
cdata->codec = g_strdup (codec);
|
||||||
cdata->cuda_device_id = device_id;
|
cdata->cuda_device_id = device_id;
|
||||||
cdata->is_default = TRUE;
|
|
||||||
|
|
||||||
g_type_query (type, &type_query);
|
g_type_query (type, &type_query);
|
||||||
memset (&type_info, 0, sizeof (type_info));
|
memset (&type_info, 0, sizeof (type_info));
|
||||||
|
@ -1028,13 +1028,17 @@ gst_nvdec_subclass_register (GstPlugin * plugin, GType type,
|
||||||
if (g_type_from_name (type_name) != 0) {
|
if (g_type_from_name (type_name) != 0) {
|
||||||
g_free (type_name);
|
g_free (type_name);
|
||||||
type_name = g_strdup_printf ("nv%sdevice%ddec", codec, device_id);
|
type_name = g_strdup_printf ("nv%sdevice%ddec", codec, device_id);
|
||||||
cdata->is_default = FALSE;
|
is_default = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cdata->is_default = is_default;
|
||||||
subtype = g_type_register_static (type, type_name, &type_info, 0);
|
subtype = g_type_register_static (type, type_name, &type_info, 0);
|
||||||
|
|
||||||
/* make lower rank than default device */
|
/* make lower rank than default device */
|
||||||
if (!gst_element_register (plugin, type_name, rank - 1, subtype))
|
if (rank > 0 && !is_default)
|
||||||
|
rank--;
|
||||||
|
|
||||||
|
if (!gst_element_register (plugin, type_name, rank, subtype))
|
||||||
GST_WARNING ("Failed to register plugin '%s'", type_name);
|
GST_WARNING ("Failed to register plugin '%s'", type_name);
|
||||||
|
|
||||||
g_free (type_name);
|
g_free (type_name);
|
||||||
|
|
Loading…
Reference in a new issue