mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
nvcodec: Clean up pointless return values around plugin init
Any plugin which returned FALSE from plugin_init will be blacklisted so the plugin will be unusable even if an user install required runtime dependency next time. So that's the reason why nvcodec returns TRUE always. This commit is to remove possible misreading code.
This commit is contained in:
parent
7b9045d846
commit
733c109ce9
5 changed files with 17 additions and 32 deletions
|
@ -1122,7 +1122,7 @@ typedef struct
|
|||
cudaVideoChromaFormat format;
|
||||
} GstNvdecChromaMap;
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
gst_nvdec_register (GstPlugin * plugin, GType type, cudaVideoCodec codec_type,
|
||||
const gchar * codec, const gchar * sink_caps_string, guint rank,
|
||||
gint device_count)
|
||||
|
@ -1274,8 +1274,6 @@ gst_nvdec_register (GstPlugin * plugin, GType type, cudaVideoCodec codec_type,
|
|||
gst_clear_caps (&sink_templ);
|
||||
gst_clear_caps (&src_templ);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
@ -1316,13 +1314,12 @@ const GstNvCodecMap codec_map[] = {
|
|||
{cudaVideoCodec_VP9, "vp9", "video/x-vp9"}
|
||||
};
|
||||
|
||||
gboolean
|
||||
void
|
||||
gst_nvdec_plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
gint i;
|
||||
CUresult cuda_ret;
|
||||
gint dev_count = 0;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_nvdec_debug_category, "nvdec", 0,
|
||||
"Debug category for the nvdec element");
|
||||
|
@ -1346,26 +1343,24 @@ gst_nvdec_plugin_init (GstPlugin * plugin)
|
|||
codec_map[i].codec_name, 0, GST_RANK_PRIMARY, sink_templ, src_templ);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
cuda_ret = CuInit (0);
|
||||
if (cuda_ret != CUDA_SUCCESS) {
|
||||
GST_ERROR ("Failed to initialize CUDA API");
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
cuda_ret = CuDeviceGetCount (&dev_count);
|
||||
if (cuda_ret != CUDA_SUCCESS || dev_count == 0) {
|
||||
GST_ERROR ("No CUDA devices detected");
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (codec_map); i++) {
|
||||
ret &= gst_nvdec_register (plugin, GST_TYPE_NVDEC, codec_map[i].codec,
|
||||
gst_nvdec_register (plugin, GST_TYPE_NVDEC, codec_map[i].codec,
|
||||
codec_map[i].codec_name, codec_map[i].sink_caps_string,
|
||||
GST_RANK_PRIMARY, dev_count);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ struct _GstNvDecClass
|
|||
|
||||
GType gst_nvdec_get_type (void);
|
||||
|
||||
gboolean gst_nvdec_plugin_init (GstPlugin * plugin);
|
||||
void gst_nvdec_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -635,7 +635,7 @@ gst_nv_enc_get_supported_codec_profiles (gpointer enc, GUID codec_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
gst_nv_enc_register (GstPlugin * plugin, GType type, GUID codec_id,
|
||||
const gchar * codec, guint rank, gint device_count)
|
||||
{
|
||||
|
@ -780,22 +780,18 @@ gst_nv_enc_register (GstPlugin * plugin, GType type, GUID codec_id,
|
|||
gst_clear_caps (&sink_templ);
|
||||
gst_clear_caps (&src_templ);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
void
|
||||
gst_nvenc_plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_nvenc_debug, "nvenc", 0, "Nvidia NVENC encoder");
|
||||
|
||||
nvenc_api.version = NV_ENCODE_API_FUNCTION_LIST_VER;
|
||||
if (!load_nvenc_library ()) {
|
||||
GST_INFO ("Failed to load nvenc library");
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nvEncodeAPICreateInstance (&nvenc_api) != NV_ENC_SUCCESS) {
|
||||
|
@ -809,23 +805,19 @@ gst_nvenc_plugin_init (GstPlugin * plugin)
|
|||
cuda_ret = CuInit (0);
|
||||
if (cuda_ret != CUDA_SUCCESS) {
|
||||
GST_ERROR ("Failed to initialize CUDA API");
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
cuda_ret = CuDeviceGetCount (&dev_count);
|
||||
if (cuda_ret != CUDA_SUCCESS || dev_count == 0) {
|
||||
GST_ERROR ("No CUDA devices detected");
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
ret &=
|
||||
gst_nv_enc_register (plugin, GST_TYPE_NV_H264_ENC,
|
||||
gst_nv_enc_register (plugin, GST_TYPE_NV_H264_ENC,
|
||||
NV_ENC_CODEC_H264_GUID, "h264", GST_RANK_PRIMARY * 2, dev_count);
|
||||
ret &=
|
||||
gst_nv_enc_register (plugin, GST_TYPE_NV_H265_ENC,
|
||||
gst_nv_enc_register (plugin, GST_TYPE_NV_H265_ENC,
|
||||
NV_ENC_CODEC_HEVC_GUID, "h265", GST_RANK_PRIMARY * 2, dev_count);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ GValue * gst_nv_enc_get_supported_codec_profiles (gpointer enc,
|
|||
GUID codec_id);
|
||||
|
||||
|
||||
gboolean gst_nvenc_plugin_init (GstPlugin * plugin);
|
||||
void gst_nvenc_plugin_init (GstPlugin * plugin);
|
||||
|
||||
|
||||
#endif /* __GST_NVENC_H_INCLUDED__ */
|
||||
|
|
|
@ -38,19 +38,17 @@
|
|||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
if (!gst_cuda_load_library ())
|
||||
return TRUE;
|
||||
|
||||
#if HAVE_NVCODEC_GST_GL
|
||||
/* FIXME: make nvdec usable without OpenGL dependency */
|
||||
if (gst_cuvid_load_library ()) {
|
||||
ret &= gst_nvdec_plugin_init (plugin);
|
||||
gst_nvdec_plugin_init (plugin);
|
||||
}
|
||||
#endif
|
||||
|
||||
ret &= gst_nvenc_plugin_init (plugin);
|
||||
gst_nvenc_plugin_init (plugin);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue