mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-11 19:06:33 +00:00
ffmpeg: make elements reusable after registry rescan
If the same instance of the plugin is asked to be initialised more that once, instances after the first one do not register the elements properly and the elements become not usable. For example, if you call gst_update_registry (), is not possible to create elements after the call since the plugin is asked to be initialised again and does not register the elements. Fixes #584291
This commit is contained in:
parent
6d643a134e
commit
cfbb046f1e
3 changed files with 43 additions and 53 deletions
|
@ -2731,21 +2731,19 @@ gst_ffmpegdec_register (GstPlugin * plugin)
|
||||||
type_name = g_strdup_printf ("ffdec_%s", plugin_name);
|
type_name = g_strdup_printf ("ffdec_%s", plugin_name);
|
||||||
g_free (plugin_name);
|
g_free (plugin_name);
|
||||||
|
|
||||||
/* if it's already registered, drop it */
|
type = g_type_from_name (type_name);
|
||||||
if (g_type_from_name (type_name)) {
|
|
||||||
g_free (type_name);
|
if (!type) {
|
||||||
goto next;
|
params = g_new0 (GstFFMpegDecClassParams, 1);
|
||||||
|
params->in_plugin = in_plugin;
|
||||||
|
params->srccaps = gst_caps_ref (srccaps);
|
||||||
|
params->sinkcaps = gst_caps_ref (sinkcaps);
|
||||||
|
|
||||||
|
/* create the gtype now */
|
||||||
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
||||||
|
g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) params);
|
||||||
}
|
}
|
||||||
|
|
||||||
params = g_new0 (GstFFMpegDecClassParams, 1);
|
|
||||||
params->in_plugin = in_plugin;
|
|
||||||
params->srccaps = gst_caps_ref (srccaps);
|
|
||||||
params->sinkcaps = gst_caps_ref (sinkcaps);
|
|
||||||
|
|
||||||
/* create the gtype now */
|
|
||||||
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
|
||||||
g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) params);
|
|
||||||
|
|
||||||
/* (Ronald) MPEG-4 gets a higher priority because it has been well-
|
/* (Ronald) MPEG-4 gets a higher priority because it has been well-
|
||||||
* tested and by far outperforms divxdec/xviddec - so we prefer it.
|
* tested and by far outperforms divxdec/xviddec - so we prefer it.
|
||||||
* msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
|
* msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
|
||||||
|
|
|
@ -1177,28 +1177,26 @@ gst_ffmpegenc_register (GstPlugin * plugin)
|
||||||
/* construct the type */
|
/* construct the type */
|
||||||
type_name = g_strdup_printf ("ffenc_%s", in_plugin->name);
|
type_name = g_strdup_printf ("ffenc_%s", in_plugin->name);
|
||||||
|
|
||||||
/* if it's already registered, drop it */
|
type = g_type_from_name (type_name);
|
||||||
if (g_type_from_name (type_name)) {
|
|
||||||
g_free (type_name);
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
params = g_new0 (GstFFMpegEncClassParams, 1);
|
if (!type) {
|
||||||
params->in_plugin = in_plugin;
|
params = g_new0 (GstFFMpegEncClassParams, 1);
|
||||||
params->srccaps = gst_caps_ref (srccaps);
|
params->in_plugin = in_plugin;
|
||||||
params->sinkcaps = gst_caps_ref (sinkcaps);
|
params->srccaps = gst_caps_ref (srccaps);
|
||||||
|
params->sinkcaps = gst_caps_ref (sinkcaps);
|
||||||
|
|
||||||
/* create the glib type now */
|
/* create the glib type now */
|
||||||
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
||||||
g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) params);
|
g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) params);
|
||||||
|
|
||||||
{
|
{
|
||||||
static const GInterfaceInfo preset_info = {
|
static const GInterfaceInfo preset_info = {
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_info);
|
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
|
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
|
||||||
|
|
|
@ -835,17 +835,6 @@ gst_ffmpegmux_register (GstPlugin * plugin)
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it's already registered, drop it */
|
|
||||||
if (g_type_from_name (type_name)) {
|
|
||||||
g_free (type_name);
|
|
||||||
gst_caps_unref (srccaps);
|
|
||||||
if (audiosinkcaps)
|
|
||||||
gst_caps_unref (audiosinkcaps);
|
|
||||||
if (videosinkcaps)
|
|
||||||
gst_caps_unref (videosinkcaps);
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fix up allowed caps for some muxers */
|
/* fix up allowed caps for some muxers */
|
||||||
if (strcmp (in_plugin->name, "flv") == 0) {
|
if (strcmp (in_plugin->name, "flv") == 0) {
|
||||||
const gint rates[] = { 44100, 22050, 11025 };
|
const gint rates[] = { 44100, 22050, 11025 };
|
||||||
|
@ -859,17 +848,22 @@ gst_ffmpegmux_register (GstPlugin * plugin)
|
||||||
gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
|
gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a cache for these properties */
|
type = g_type_from_name (type_name);
|
||||||
params = g_new0 (GstFFMpegMuxClassParams, 1);
|
|
||||||
params->in_plugin = in_plugin;
|
|
||||||
params->srccaps = srccaps;
|
|
||||||
params->videosinkcaps = videosinkcaps;
|
|
||||||
params->audiosinkcaps = audiosinkcaps;
|
|
||||||
|
|
||||||
/* create the type now */
|
if (!type) {
|
||||||
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
/* create a cache for these properties */
|
||||||
g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) params);
|
params = g_new0 (GstFFMpegMuxClassParams, 1);
|
||||||
g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
|
params->in_plugin = in_plugin;
|
||||||
|
params->srccaps = srccaps;
|
||||||
|
params->videosinkcaps = videosinkcaps;
|
||||||
|
params->audiosinkcaps = audiosinkcaps;
|
||||||
|
|
||||||
|
/* create the type now */
|
||||||
|
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
||||||
|
g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) params);
|
||||||
|
g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
|
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type)) {
|
||||||
g_free (type_name);
|
g_free (type_name);
|
||||||
|
|
Loading…
Reference in a new issue