gst_plugins_good/gst/autodetect/gstautovideosink.c
changeset 16 8e837d1bf446
parent 2 5505e8908944
equal deleted inserted replaced
15:4b0c6ed43234 16:8e837d1bf446
    20 
    20 
    21 /**
    21 /**
    22  * SECTION:element-autovideosink
    22  * SECTION:element-autovideosink
    23  * @see_also: autoaudiosink, ximagesink, xvimagesink, sdlvideosink
    23  * @see_also: autoaudiosink, ximagesink, xvimagesink, sdlvideosink
    24  *
    24  *
    25  * <refsect2>
       
    26  * <para>
       
    27  * autovideosink is a video sink that automatically detects an appropriate
    25  * autovideosink is a video sink that automatically detects an appropriate
    28  * video sink to use.  It does so by scanning the registry for all elements
    26  * video sink to use.  It does so by scanning the registry for all elements
    29  * that have <quote>Sink</quote> and <quote>Video</quote> in the class field
    27  * that have <quote>Sink</quote> and <quote>Video</quote> in the class field
    30  * of their element information, and also have a non-zero autoplugging rank.
    28  * of their element information, and also have a non-zero autoplugging rank.
    31  * </para>
    29  *
       
    30  * <refsect2>
    32  * <title>Example launch line</title>
    31  * <title>Example launch line</title>
    33  * <para>
    32  * |[
    34  * <programlisting>
       
    35  * gst-launch -v -m videotestsrc ! autovideosink
    33  * gst-launch -v -m videotestsrc ! autovideosink
    36  * </programlisting>
    34  * ]|
    37  * </para>
       
    38  * </refsect2>
    35  * </refsect2>
    39  */
    36  */
    40 
    37 
    41 #ifdef HAVE_CONFIG_H
    38 #ifdef HAVE_CONFIG_H
    42 #include "config.h"
    39 #include "config.h"
    70 static const GstElementDetails gst_auto_video_sink_details =
    67 static const GstElementDetails gst_auto_video_sink_details =
    71 GST_ELEMENT_DETAILS ("Auto video sink",
    68 GST_ELEMENT_DETAILS ("Auto video sink",
    72     "Sink/Video",
    69     "Sink/Video",
    73     "Wrapper video sink for automatically detected video sink",
    70     "Wrapper video sink for automatically detected video sink",
    74     "Ronald Bultje <rbultje@ronald.bitfreak.net>\n"
    71     "Ronald Bultje <rbultje@ronald.bitfreak.net>\n"
    75     "Jan Schmidt <thaytan@noraisin.net");
    72     "Jan Schmidt <thaytan@noraisin.net>");
    76 
    73 
    77 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
    74 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
    78     GST_PAD_SINK,
    75     GST_PAD_SINK,
    79     GST_PAD_ALWAYS,
    76     GST_PAD_ALWAYS,
    80     GST_STATIC_CAPS_ANY);
    77     GST_STATIC_CAPS_ANY);
   158 
   155 
   159   /* fakesink placeholder */
   156   /* fakesink placeholder */
   160   sink->kid = gst_element_factory_make ("fakesink", "tempsink");
   157   sink->kid = gst_element_factory_make ("fakesink", "tempsink");
   161   gst_bin_add (GST_BIN (sink), sink->kid);
   158   gst_bin_add (GST_BIN (sink), sink->kid);
   162 
   159 
   163   /* pad */
   160   /* pad, setting this target should always work */
   164   targetpad = gst_element_get_pad (sink->kid, "sink");
   161   targetpad = gst_element_get_static_pad (sink->kid, "sink");
   165   gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
   162   gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
   166   gst_object_unref (targetpad);
   163   gst_object_unref (targetpad);
   167 }
   164 }
   168 
   165 
   169 static GstStaticCaps raw_caps =
   166 static GstStaticCaps raw_caps =
   352   sink->kid = esink;
   349   sink->kid = esink;
   353   gst_bin_add (GST_BIN (sink), esink);
   350   gst_bin_add (GST_BIN (sink), esink);
   354 
   351 
   355   /* attach ghost pad */
   352   /* attach ghost pad */
   356   GST_DEBUG_OBJECT (sink, "Re-assigning ghostpad");
   353   GST_DEBUG_OBJECT (sink, "Re-assigning ghostpad");
   357   targetpad = gst_element_get_pad (sink->kid, "sink");
   354   targetpad = gst_element_get_static_pad (sink->kid, "sink");
   358   gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
   355   if (!gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad))
       
   356     goto target_failed;
       
   357 
   359   gst_object_unref (targetpad);
   358   gst_object_unref (targetpad);
   360   GST_DEBUG_OBJECT (sink, "done changing auto video sink");
   359   GST_DEBUG_OBJECT (sink, "done changing auto video sink");
   361 
   360 
   362   return TRUE;
   361   return TRUE;
   363 
   362 
   366   {
   365   {
   367     GST_ELEMENT_ERROR (sink, LIBRARY, INIT, (NULL),
   366     GST_ELEMENT_ERROR (sink, LIBRARY, INIT, (NULL),
   368         ("Failed to find a supported video sink"));
   367         ("Failed to find a supported video sink"));
   369     return FALSE;
   368     return FALSE;
   370   }
   369   }
       
   370 target_failed:
       
   371   {
       
   372     GST_ELEMENT_ERROR (sink, LIBRARY, INIT, (NULL),
       
   373         ("Failed to set target pad"));
       
   374     gst_object_unref (targetpad);
       
   375     return FALSE;
       
   376   }
   371 }
   377 }
   372 
   378 
   373 static GstStateChangeReturn
   379 static GstStateChangeReturn
   374 gst_auto_video_sink_change_state (GstElement * element,
   380 gst_auto_video_sink_change_state (GstElement * element,
   375     GstStateChange transition)
   381     GstStateChange transition)