mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
manual: Replace manual's effectswitch.c with newer test-effect-switch.c
https://bugzilla.gnome.org/show_bug.cgi?id=721100
This commit is contained in:
parent
97103c90b0
commit
cb1657fcea
1 changed files with 33 additions and 11 deletions
|
@ -1369,8 +1369,12 @@ main (int argc, char **argv)
|
|||
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;
|
||||
|
@ -1397,7 +1401,7 @@ event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
|||
|
||||
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);
|
||||
|
@ -1498,11 +1502,11 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
@ -1510,6 +1514,8 @@ main (int argc, char **argv)
|
|||
}
|
||||
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
|
||||
|
@ -1530,21 +1536,37 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
||||
|
@ -1562,7 +1584,7 @@ main (int argc, char **argv)
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue