v4l2: Ignore register issue and keep probing

Don't stop registering the other dynamic plugins if one registration
fails.
This commit is contained in:
Nicolas Dufresne 2017-07-27 10:51:07 -04:00
parent 4b8d0a294a
commit 1762c2e713
9 changed files with 25 additions and 29 deletions

View file

@ -119,7 +119,6 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
GstV4l2Iterator *it; GstV4l2Iterator *it;
gint video_fd = -1; gint video_fd = -1;
struct v4l2_capability vcap; struct v4l2_capability vcap;
gboolean ret = TRUE;
guint32 device_caps; guint32 device_caps;
it = gst_v4l2_iterator_new (); it = gst_v4l2_iterator_new ();
@ -183,23 +182,21 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
basename = g_path_get_basename (it->device_path); basename = g_path_get_basename (it->device_path);
if (gst_v4l2_is_video_dec (sink_caps, src_caps)) if (gst_v4l2_is_video_dec (sink_caps, src_caps)) {
ret = gst_v4l2_video_dec_register (plugin, basename, it->device_path, gst_v4l2_video_dec_register (plugin, basename, it->device_path,
sink_caps, src_caps); sink_caps, src_caps);
else if (gst_v4l2_is_h264_enc (sink_caps, src_caps)) } else if (gst_v4l2_is_h264_enc (sink_caps, src_caps)) {
ret = gst_v4l2_h264_enc_register (plugin, basename, it->device_path, gst_v4l2_h264_enc_register (plugin, basename, it->device_path,
sink_caps, src_caps); sink_caps, src_caps);
else if (gst_v4l2_is_transform (sink_caps, src_caps)) } else if (gst_v4l2_is_transform (sink_caps, src_caps)) {
ret = gst_v4l2_transform_register (plugin, basename, it->device_path, gst_v4l2_transform_register (plugin, basename, it->device_path,
sink_caps, src_caps); sink_caps, src_caps);
}
/* else if ( ... etc. */ /* else if ( ... etc. */
gst_caps_unref (sink_caps); gst_caps_unref (sink_caps);
gst_caps_unref (src_caps); gst_caps_unref (src_caps);
g_free (basename); g_free (basename);
if (!ret)
break;
} }
if (video_fd >= 0) if (video_fd >= 0)
@ -207,7 +204,7 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
gst_v4l2_iterator_free (it); gst_v4l2_iterator_free (it);
return ret; return TRUE;
} }
#endif #endif

View file

@ -531,11 +531,11 @@ gst_v4l2_is_h264_enc (GstCaps * sink_caps, GstCaps * src_caps)
return ret; return ret;
} }
gboolean void
gst_v4l2_h264_enc_register (GstPlugin * plugin, const gchar * basename, gst_v4l2_h264_enc_register (GstPlugin * plugin, const gchar * basename,
const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps) const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps)
{ {
return gst_v4l2_video_enc_register (plugin, GST_TYPE_V4L2_H264_ENC, gst_v4l2_video_enc_register (plugin, GST_TYPE_V4L2_H264_ENC,
"h264", basename, device_path, sink_caps, "h264", basename, device_path, sink_caps,
gst_static_caps_get (&src_template_caps), src_caps); gst_static_caps_get (&src_template_caps), src_caps);
} }

View file

@ -55,7 +55,7 @@ GType gst_v4l2_h264_enc_get_type (void);
gboolean gst_v4l2_is_h264_enc (GstCaps * sink_caps, GstCaps * src_caps); gboolean gst_v4l2_is_h264_enc (GstCaps * sink_caps, GstCaps * src_caps);
gboolean gst_v4l2_h264_enc_register (GstPlugin * plugin, const gchar * basename, void gst_v4l2_h264_enc_register (GstPlugin * plugin, const gchar * basename,
const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps); const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps);
G_END_DECLS G_END_DECLS

View file

@ -1166,7 +1166,7 @@ gst_v4l2_is_transform (GstCaps * sink_caps, GstCaps * src_caps)
return ret; return ret;
} }
gboolean void
gst_v4l2_transform_register (GstPlugin * plugin, const gchar * basename, gst_v4l2_transform_register (GstPlugin * plugin, const gchar * basename,
const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps) const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps)
{ {
@ -1193,9 +1193,8 @@ gst_v4l2_transform_register (GstPlugin * plugin, const gchar * basename,
type_name = g_strdup_printf ("v4l2%sconvert", basename); type_name = g_strdup_printf ("v4l2%sconvert", basename);
subtype = g_type_register_static (type, type_name, &type_info, 0); subtype = g_type_register_static (type, type_name, &type_info, 0);
gst_element_register (plugin, type_name, GST_RANK_NONE, subtype); if (!gst_element_register (plugin, type_name, GST_RANK_NONE, subtype))
GST_WARNING ("Failed to register plugin '%s'", type_name);
g_free (type_name); g_free (type_name);
return TRUE;
} }

View file

@ -74,7 +74,7 @@ struct _GstV4l2TransformClass
GType gst_v4l2_transform_get_type (void); GType gst_v4l2_transform_get_type (void);
gboolean gst_v4l2_is_transform (GstCaps * sink_caps, GstCaps * src_caps); gboolean gst_v4l2_is_transform (GstCaps * sink_caps, GstCaps * src_caps);
gboolean gst_v4l2_transform_register (GstPlugin * plugin, void gst_v4l2_transform_register (GstPlugin * plugin,
const gchar *basename, const gchar *basename,
const gchar *device_path, const gchar *device_path,
GstCaps * sink_caps, GstCaps * src_caps); GstCaps * sink_caps, GstCaps * src_caps);

View file

@ -1059,7 +1059,7 @@ G_STMT_START { \
#undef SET_META #undef SET_META
} }
gboolean void
gst_v4l2_video_dec_register (GstPlugin * plugin, const gchar * basename, gst_v4l2_video_dec_register (GstPlugin * plugin, const gchar * basename,
const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps) const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps)
{ {
@ -1098,10 +1098,10 @@ gst_v4l2_video_dec_register (GstPlugin * plugin, const gchar * basename,
type_info.instance_init = gst_v4l2_video_dec_subinstance_init; type_info.instance_init = gst_v4l2_video_dec_subinstance_init;
subtype = g_type_register_static (type, type_name, &type_info, 0); subtype = g_type_register_static (type, type_name, &type_info, 0);
gst_element_register (plugin, type_name, GST_RANK_PRIMARY + 1, subtype); if (!gst_element_register (plugin, type_name, GST_RANK_PRIMARY + 1,
subtype))
GST_WARNING ("Failed to register plugin '%s'", type_name);
g_free (type_name); g_free (type_name);
} }
return TRUE;
} }

View file

@ -76,7 +76,7 @@ struct _GstV4l2VideoDecClass
GType gst_v4l2_video_dec_get_type (void); GType gst_v4l2_video_dec_get_type (void);
gboolean gst_v4l2_is_video_dec (GstCaps * sink_caps, GstCaps * src_caps); gboolean gst_v4l2_is_video_dec (GstCaps * sink_caps, GstCaps * src_caps);
gboolean gst_v4l2_video_dec_register (GstPlugin * plugin, void gst_v4l2_video_dec_register (GstPlugin * plugin,
const gchar *basename, const gchar *basename,
const gchar *device_path, const gchar *device_path,
GstCaps * sink_caps, GstCaps * src_caps); GstCaps * sink_caps, GstCaps * src_caps);

View file

@ -903,7 +903,7 @@ gst_v4l2_video_enc_subclass_init (gpointer g_class, gpointer data)
} }
/* Probing functions */ /* Probing functions */
gboolean void
gst_v4l2_video_enc_register (GstPlugin * plugin, GType type, gst_v4l2_video_enc_register (GstPlugin * plugin, GType type,
const char *codec, const gchar * basename, const gchar * device_path, const char *codec, const gchar * basename, const gchar * device_path,
GstCaps * sink_caps, GstCaps * codec_caps, GstCaps * src_caps) GstCaps * sink_caps, GstCaps * codec_caps, GstCaps * src_caps)
@ -942,9 +942,9 @@ gst_v4l2_video_enc_register (GstPlugin * plugin, GType type,
} }
subtype = g_type_register_static (type, type_name, &type_info, 0); subtype = g_type_register_static (type, type_name, &type_info, 0);
gst_element_register (plugin, type_name, GST_RANK_PRIMARY + 1, subtype);
if (!gst_element_register (plugin, type_name, GST_RANK_PRIMARY + 1, subtype))
GST_WARNING ("Failed to register plugin '%s'", type_name);
g_free (type_name); g_free (type_name);
return TRUE;
} }

View file

@ -79,7 +79,7 @@ struct _GstV4l2VideoEncClass
GType gst_v4l2_video_enc_get_type (void); GType gst_v4l2_video_enc_get_type (void);
gboolean gst_v4l2_video_enc_register (GstPlugin * plugin, GType type, void gst_v4l2_video_enc_register (GstPlugin * plugin, GType type,
const char *codec, const gchar * basename, const gchar * device_path, const char *codec, const gchar * basename, const gchar * device_path,
GstCaps * sink_caps, GstCaps *codec_caps, GstCaps * src_caps); GstCaps * sink_caps, GstCaps *codec_caps, GstCaps * src_caps);