[longomatch/dvcam: 6/6] First try to fix dv1394 sources



commit dc941c94030df18dedf37a761c8a1c7e9d9e43e4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Jun 3 01:42:44 2010 +0200

    First try to fix dv1394 sources

 libcesarplayer/src/gst-camera-capturer.c |   57 ++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 10 deletions(-)
---
diff --git a/libcesarplayer/src/gst-camera-capturer.c b/libcesarplayer/src/gst-camera-capturer.c
index ab731b4..6ca233e 100644
--- a/libcesarplayer/src/gst-camera-capturer.c
+++ b/libcesarplayer/src/gst-camera-capturer.c
@@ -900,12 +900,53 @@ gst_camera_capture_videosrc_buffer_probe (GstPad * pad, GstBuffer * buf,
   return TRUE;
 }
 
+static void
+cb_new_pad (GstElement *element,
+	    GstPad     *pad,
+	    gpointer    data)
+{
+  GstElement *sink = GST_ELEMENT(data);
+
+  gst_pad_link (pad, gst_element_get_pad (sink, "sink"));
+}
+
+static GstElement *
+gst_camera_capture_create_source_bin (GstCameraCapturer * gcc)
+{
+  GstElement *bin;
+  GstElement *source;
+  GstElement *decoder;
+  GstElement *colorspace;
+  GstElement *videorate;
+  GstElement *videoscale;
+  GstPad *src_pad;
+
+  bin = gst_bin_new ("videosource");
+  source = gst_element_factory_make(DVVIDEOSRC, NULL);
+  decoder = gst_element_factory_make("decodebin2", NULL);
+  colorspace = gst_element_factory_make("ffmpegcolorspace", NULL);
+  videorate = gst_element_factory_make("videorate", NULL);
+  videoscale = gst_element_factory_make("videoscale", NULL);
+
+  gst_bin_add_many (GST_BIN(bin), source, decoder, colorspace, videorate, videoscale, NULL);
+  gst_element_link (source, decoder);
+  gst_element_link_many (colorspace, videorate, videoscale, NULL);
+
+  g_signal_connect (decoder, "pad-added", G_CALLBACK
+      (cb_new_pad),colorspace);
+
+  /* add ghostpad */
+  src_pad = gst_element_get_static_pad (videoscale, "src");
+  gst_element_add_pad (bin, gst_ghost_pad_new ("src", src_pad));
+  gst_object_unref (GST_OBJECT (src_pad));
+
+  return bin;
+}
+
 gboolean
 gst_camera_capturer_set_source (GstCameraCapturer * gcc,
     GstCameraCaptureSourceType source_type, GError **err)
 {
-  gchar *bin;
-
   if (gcc->priv->source_type == source_type)
     return TRUE;
   gcc->priv->source_type = source_type;
@@ -913,17 +954,13 @@ gst_camera_capturer_set_source (GstCameraCapturer * gcc,
   switch (gcc->priv->source_type) {
     case GST_CAMERA_CAPTURE_SOURCE_TYPE_DV:
     {
-      bin = g_strdup_printf ("%s ! queue ! video/x-dv "
-          "! dvdemux name=demux .video ! queue "
-          "! ffdec_dv ! queue ! ffmpegcolorspace ! videorate ! videoscale"
-          " .demux ", DVVIDEOSRC);
-      gcc->priv->videosrc = gst_parse_bin_from_description (bin, TRUE, err);
-      gcc->priv->audiosrc = gcc->priv->videosrc;
+      gcc->priv->videosrc = gst_camera_capture_create_source_bin (gcc);
+      /*gcc->priv->audiosrc = gcc->priv->videosrc;*/
     }
-    case GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW:
+   case GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW:
     default:
     {
-      bin = g_strdup_printf ("%s ! ffmpegcolorspace ! videorate ! videoscale",
+      gchar *bin = g_strdup_printf ("%s ! ffmpegcolorspace ! videorate ! videoscale",
           RAWVIDEOSRC);
       gcc->priv->videosrc = gst_parse_bin_from_description (bin, TRUE, err);
       gcc->priv->audiosrc = gst_element_factory_make (AUDIOSRC, "audiosource");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]