Merge branch 'upstream/1.16' into tizen_gst_1.16.2
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2.c
index 9a30037..e3e54d1 100644 (file)
 #include "gstv4l2sink.h"
 #include "gstv4l2radio.h"
 #include "gstv4l2videodec.h"
+#include "gstv4l2fwhtenc.h"
+#include "gstv4l2h263enc.h"
+#include "gstv4l2h264enc.h"
+#include "gstv4l2h265enc.h"
+#include "gstv4l2jpegenc.h"
+#include "gstv4l2mpeg4enc.h"
+#include "gstv4l2vp8enc.h"
+#include "gstv4l2vp9enc.h"
 #include "gstv4l2deviceprovider.h"
 #include "gstv4l2transform.h"
 
-/* used in v4l2_calls.c and v4l2src_calls.c */
+/* used in gstv4l2object.c and v4l2_calls.c */
 GST_DEBUG_CATEGORY (v4l2_debug);
 #define GST_CAT_DEFAULT v4l2_debug
 
@@ -118,9 +126,10 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
   GstV4l2Iterator *it;
   gint video_fd = -1;
   struct v4l2_capability vcap;
-  gboolean ret = TRUE;
   guint32 device_caps;
 
+  GST_DEBUG ("Probing devices");
+
   it = gst_v4l2_iterator_new ();
 
   while (gst_v4l2_iterator_next (it)) {
@@ -149,12 +158,7 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
     else
       device_caps = vcap.capabilities;
 
-    if (!((device_caps & (V4L2_CAP_VIDEO_M2M | V4L2_CAP_VIDEO_M2M_MPLANE)) ||
-            /* But legacy driver may expose both CAPTURE and OUTPUT */
-            ((device_caps &
-                    (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) &&
-                (device_caps &
-                    (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE)))))
+    if (!GST_V4L2_IS_M2M (device_caps))
       continue;
 
     GST_DEBUG ("Probing '%s' located at '%s'",
@@ -182,20 +186,54 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
 
     basename = g_path_get_basename (it->device_path);
 
-    if (gst_v4l2_is_video_dec (sink_caps, src_caps))
-      ret = gst_v4l2_video_dec_register (plugin, basename, it->device_path,
+    /* Caps won't be freed if the subclass is not instantiated */
+    GST_MINI_OBJECT_FLAG_SET (sink_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+    GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+
+    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_transform (sink_caps, src_caps))
-      ret = gst_v4l2_transform_register (plugin, basename, it->device_path,
+    } else if (gst_v4l2_is_video_enc (sink_caps, src_caps, NULL)) {
+      if (gst_v4l2_is_fwht_enc (sink_caps, src_caps))
+        gst_v4l2_fwht_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_h264_enc (sink_caps, src_caps))
+        gst_v4l2_h264_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_h265_enc (sink_caps, src_caps))
+        gst_v4l2_h265_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_mpeg4_enc (sink_caps, src_caps))
+        gst_v4l2_mpeg4_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_h263_enc (sink_caps, src_caps))
+        gst_v4l2_h263_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_jpeg_enc (sink_caps, src_caps))
+        gst_v4l2_jpeg_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_vp8_enc (sink_caps, src_caps))
+        gst_v4l2_vp8_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+
+      if (gst_v4l2_is_vp9_enc (sink_caps, src_caps))
+        gst_v4l2_vp9_enc_register (plugin, basename, it->device_path,
+            sink_caps, src_caps);
+    } else if (gst_v4l2_is_transform (sink_caps, src_caps)) {
+      gst_v4l2_transform_register (plugin, basename, it->device_path,
           sink_caps, src_caps);
+    }
     /* else if ( ... etc. */
 
     gst_caps_unref (sink_caps);
     gst_caps_unref (src_caps);
     g_free (basename);
-
-    if (!ret)
-      break;
   }
 
   if (video_fd >= 0)
@@ -203,7 +241,7 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
 
   gst_v4l2_iterator_free (it);
 
-  return ret;
+  return TRUE;
 }
 #endif