* Since: 1.20
*/
static GstStaticPadTemplate video_src_factory =
-GST_STATIC_PAD_TEMPLATE ("video", GST_PAD_SRC, GST_PAD_SOMETIMES,
+GST_STATIC_PAD_TEMPLATE ("video", GST_PAD_SRC, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(memory:GLMemory), "
"format = (string) RGBA, "
"width = " GST_VIDEO_SIZE_RANGE ", "
static void
gst_wpe_src_set_location (GstWpeSrc * src, const gchar * location)
{
- GstPad *pad;
- GstPad *ghost_pad;
- GstProxyPad *proxy_pad;
-
g_object_set (src->video_src, "location", location, NULL);
-
- ghost_pad = gst_element_get_static_pad (GST_ELEMENT_CAST (src), "video");
- if (GST_IS_PAD (ghost_pad)) {
- gst_object_unref (ghost_pad);
- return;
- }
-
- gst_bin_add (GST_BIN_CAST (src), src->video_src);
-
- pad = gst_element_get_static_pad (GST_ELEMENT_CAST (src->video_src), "src");
- ghost_pad = gst_ghost_pad_new_from_template ("video", pad,
- gst_static_pad_template_get (&video_src_factory));
- proxy_pad = gst_proxy_pad_get_internal (GST_PROXY_PAD (ghost_pad));
- gst_pad_set_active (GST_PAD_CAST (proxy_pad), TRUE);
-
- gst_element_add_pad (GST_ELEMENT_CAST (src), GST_PAD_CAST (ghost_pad));
- gst_flow_combiner_add_pad (src->flow_combiner, GST_PAD_CAST (ghost_pad));
- gst_pad_set_chain_function (GST_PAD_CAST (proxy_pad), gst_wpe_src_chain_buffer);
-
- gst_object_unref (proxy_pad);
- gst_object_unref (pad);
}
static void
static void
gst_wpe_src_init (GstWpeSrc * src)
{
+ GstPad *pad;
+ GstPad *ghost_pad;
+ GstProxyPad *proxy_pad;
+
gst_bin_set_suppressed_flags (GST_BIN_CAST (src),
static_cast<GstElementFlags>(GST_ELEMENT_FLAG_SOURCE | GST_ELEMENT_FLAG_SINK));
GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_SOURCE);
src->audio_src_pads = g_hash_table_new (g_direct_hash, g_direct_equal);
src->flow_combiner = gst_flow_combiner_new ();
src->video_src = gst_element_factory_make ("wpevideosrc", NULL);
+
+ gst_bin_add (GST_BIN_CAST (src), src->video_src);
+
+ pad = gst_element_get_static_pad (GST_ELEMENT_CAST (src->video_src), "src");
+ ghost_pad = gst_ghost_pad_new_from_template ("video", pad,
+ gst_static_pad_template_get (&video_src_factory));
+ proxy_pad = gst_proxy_pad_get_internal (GST_PROXY_PAD (ghost_pad));
+ gst_pad_set_active (GST_PAD_CAST (proxy_pad), TRUE);
+
+ gst_element_add_pad (GST_ELEMENT_CAST (src), GST_PAD_CAST (ghost_pad));
+ gst_flow_combiner_add_pad (src->flow_combiner, GST_PAD_CAST (ghost_pad));
+ gst_pad_set_chain_function (GST_PAD_CAST (proxy_pad), gst_wpe_src_chain_buffer);
+
+ gst_object_unref (proxy_pad);
+ gst_object_unref (pad);
}
static gboolean
gchar *name = gst_pad_get_name (new_pad);
gchar *bin_name;
- if (g_str_has_prefix (name, "audio")) {
- out =
- gst_parse_bin_from_description
- ("audioresample ! audioconvert ! autoaudiosink", TRUE, NULL);
- } else {
- out =
- gst_parse_bin_from_description
- ("queue ! glcolorconvert ! gtkglsink enable-last-sample=0", TRUE, NULL);
- }
-
+ out = gst_parse_bin_from_description
+ ("audioresample ! audioconvert ! autoaudiosink", TRUE, NULL);
bin_name = g_strdup_printf ("%s-bin", name);
g_free (name);
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
- pipe1 = gst_pipeline_new (NULL);
+ pipe1 =
+ gst_parse_launch
+ ("wpesrc name=wpesrc ! queue ! glcolorconvert ! gtkglsink enable-last-sample=0",
+ NULL);
bus1 = gst_pipeline_get_bus (GST_PIPELINE (pipe1));
gst_bus_add_watch (bus1, (GstBusFunc) _bus_watch, pipe1);
- src = gst_element_factory_make ("wpesrc", NULL);
+ src = gst_bin_get_by_name (GST_BIN (pipe1), "wpesrc");
- gst_bin_add (GST_BIN_CAST (pipe1), src);
gst_element_set_state (GST_ELEMENT (pipe1), GST_STATE_READY);
g_signal_connect (src, "pad-added", G_CALLBACK (_wpe_pad_added), pipe1);
g_signal_connect (src, "pad-removed", G_CALLBACK (_wpe_pad_removed), pipe1);
g_object_set (src, "location", argv[1], NULL);
+ gst_clear_object (&src);
g_print ("Starting pipeline\n");
gst_element_set_state (GST_ELEMENT (pipe1), GST_STATE_PLAYING);