Commit b0fb95b9 authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2videoenc: Turn gst_v4l2_is_video_enc into a helper

This reduces the amount of code needed in each codec class.
parent 040e2521
......@@ -189,7 +189,7 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
if (gst_v4l2_is_video_dec (sink_caps, src_caps)) {
gst_v4l2_video_dec_register (plugin, basename, it->device_path,
sink_caps, src_caps);
} else if (gst_v4l2_is_video_enc (sink_caps, src_caps)) {
} else if (gst_v4l2_is_video_enc (sink_caps, src_caps, NULL)) {
if (gst_v4l2_is_h264_enc (sink_caps, src_caps))
gst_v4l2_h264_enc_register (plugin, basename, it->device_path,
sink_caps, src_caps);
......
......@@ -102,18 +102,8 @@ gst_v4l2_h263_enc_class_init (GstV4l2H263EncClass * klass)
gboolean
gst_v4l2_is_h263_enc (GstCaps * sink_caps, GstCaps * src_caps)
{
gboolean ret = FALSE;
GstCaps *codec_caps;
codec_caps = gst_static_caps_get (&src_template_caps);
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_can_intersect (src_caps, codec_caps))
ret = TRUE;
gst_caps_unref (codec_caps);
return ret;
return gst_v4l2_is_video_enc (sink_caps, src_caps,
gst_static_caps_get (&src_template_caps));
}
void
......
......@@ -517,18 +517,8 @@ gst_v4l2_h264_enc_class_init (GstV4l2H264EncClass * klass)
gboolean
gst_v4l2_is_h264_enc (GstCaps * sink_caps, GstCaps * src_caps)
{
gboolean ret = FALSE;
GstCaps *codec_caps;
codec_caps = gst_static_caps_get (&src_template_caps);
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_can_intersect (src_caps, codec_caps))
ret = TRUE;
gst_caps_unref (codec_caps);
return ret;
return gst_v4l2_is_video_enc (sink_caps, src_caps,
gst_static_caps_get (&src_template_caps));
}
void
......
......@@ -413,18 +413,8 @@ gst_v4l2_mpeg4_enc_class_init (GstV4l2Mpeg4EncClass * klass)
gboolean
gst_v4l2_is_mpeg4_enc (GstCaps * sink_caps, GstCaps * src_caps)
{
gboolean ret = FALSE;
GstCaps *codec_caps;
codec_caps = gst_static_caps_get (&src_template_caps);
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_can_intersect (src_caps, codec_caps))
ret = TRUE;
gst_caps_unref (codec_caps);
return ret;
return gst_v4l2_is_video_enc (sink_caps, src_caps,
gst_static_caps_get (&src_template_caps));
}
void
......
......@@ -904,12 +904,21 @@ gst_v4l2_video_enc_subclass_init (gpointer g_class, gpointer data)
/* Probing functions */
gboolean
gst_v4l2_is_video_enc (GstCaps * sink_caps, GstCaps * src_caps)
gst_v4l2_is_video_enc (GstCaps * sink_caps, GstCaps * src_caps,
GstCaps * codec_caps)
{
gboolean ret = FALSE;
gboolean (*check_caps) (const GstCaps *, const GstCaps *);
if (codec_caps) {
check_caps = gst_caps_can_intersect;
} else {
codec_caps = gst_v4l2_object_get_codec_caps ();
check_caps = gst_caps_is_subset;
}
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_is_subset (src_caps, gst_v4l2_object_get_codec_caps ()))
&& check_caps (src_caps, gst_v4l2_object_get_codec_caps ()))
ret = TRUE;
return ret;
......
......@@ -79,7 +79,8 @@ struct _GstV4l2VideoEncClass
GType gst_v4l2_video_enc_get_type (void);
gboolean gst_v4l2_is_video_enc (GstCaps * sink_caps, GstCaps * src_caps);
gboolean gst_v4l2_is_video_enc (GstCaps * sink_caps, GstCaps * src_caps,
GstCaps * codec_caps);
void gst_v4l2_video_enc_register (GstPlugin * plugin, GType type,
const char *codec, const gchar * basename, const gchar * device_path,
......
......@@ -297,18 +297,8 @@ gst_v4l2_vp8_enc_class_init (GstV4l2Vp8EncClass * klass)
gboolean
gst_v4l2_is_vp8_enc (GstCaps * sink_caps, GstCaps * src_caps)
{
gboolean ret = FALSE;
GstCaps *codec_caps;
codec_caps = gst_static_caps_get (&src_template_caps);
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_can_intersect (src_caps, codec_caps))
ret = TRUE;
gst_caps_unref (codec_caps);
return ret;
return gst_v4l2_is_video_enc (sink_caps, src_caps,
gst_static_caps_get (&src_template_caps));
}
void
......
......@@ -297,18 +297,8 @@ gst_v4l2_vp9_enc_class_init (GstV4l2Vp9EncClass * klass)
gboolean
gst_v4l2_is_vp9_enc (GstCaps * sink_caps, GstCaps * src_caps)
{
gboolean ret = FALSE;
GstCaps *codec_caps;
codec_caps = gst_static_caps_get (&src_template_caps);
if (gst_caps_is_subset (sink_caps, gst_v4l2_object_get_raw_caps ())
&& gst_caps_can_intersect (src_caps, codec_caps))
ret = TRUE;
gst_caps_unref (codec_caps);
return ret;
return gst_v4l2_is_video_enc (sink_caps, src_caps,
gst_static_caps_get (&src_template_caps));
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment