video effect on a simple pipeline every second.
</para>
<programlisting>
-<!-- example-begin effectswitch.c -->
+<!-- example-begin test-effect-switch.c -->
<![CDATA[
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <gst/gst.h>
static gchar *opt_effects = NULL;
gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));
- /* push current effect back into the queue */
+ /* push current event back into the queue */
g_queue_push_tail (&effects, gst_object_ref (cur_effect));
/* take next effect from the queue */
next = g_queue_pop_head (&effects);
GOptionContext *ctx;
GError *err = NULL;
GMainLoop *loop;
- GstElement *src, *sink;
+ GstElement *src, *q1, *q2, *effect, *filter1, *filter2, *sink;
gchar **effect_names, **e;
ctx = g_option_context_new ("");
- g_option_context_add_main_entries (ctx, options, NULL);
+ g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
g_option_context_add_group (ctx, gst_init_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_print ("Error initializing: %s\n", err->message);
}
g_option_context_free (ctx);
+ GST_FIXME ("Multiple things to check/fix, see source code");
+
if (opt_effects != NULL)
effect_names = g_strsplit (opt_effects, ",", -1);
else
src = gst_element_factory_make ("videotestsrc", NULL);
g_object_set (src, "is-live", TRUE, NULL);
- blockpad = gst_element_get_static_pad (src, "src");
+ filter1 = gst_element_factory_make ("capsfilter", NULL);
+ gst_util_set_object_arg (G_OBJECT (filter1), "caps",
+ "video/x-raw, width=320, height=240, "
+ "format={ I420, YV12, YUY2, UYVY, AYUV, Y41B, Y42B, "
+ "YVYU, Y444, v210, v216, NV12, NV21, UYVP, A420, YUV9, YVU9, IYU1 }");
+
+ q1 = gst_element_factory_make ("queue", NULL);
+
+ blockpad = gst_element_get_static_pad (q1, "src");
conv_before = gst_element_factory_make ("videoconvert", NULL);
- cur_effect = g_queue_pop_head (&effects);
+ effect = g_queue_pop_head (&effects);
+ cur_effect = effect;
conv_after = gst_element_factory_make ("videoconvert", NULL);
+ q2 = gst_element_factory_make ("queue", NULL);
+
+ filter2 = gst_element_factory_make ("capsfilter", NULL);
+ gst_util_set_object_arg (G_OBJECT (filter2), "caps",
+ "video/x-raw, width=320, height=240, "
+ "format={ RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR }");
+
sink = gst_element_factory_make ("ximagesink", NULL);
- gst_bin_add_many (GST_BIN (pipeline), src, conv_before, cur_effect,
- conv_after, sink, NULL);
+ gst_bin_add_many (GST_BIN (pipeline), src, filter1, q1, conv_before, effect,
+ conv_after, q2, sink, NULL);
- gst_element_link_many (src, conv_before, cur_effect, conv_after,
- sink, NULL);
+ gst_element_link_many (src, filter1, q1, conv_before, effect, conv_after,
+ q2, sink, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
return 0;
}
]]>
-<!-- example-end effectswitch.c -->
+<!-- example-end test-effect-switch.c -->
</programlisting>
<para>
Note how we added videoconvert elements before and after the effect.