test for disconnect and reconnect of elements

Original commit message from CVS:
test for disconnect and reconnect of elements
This commit is contained in:
Thomas Vander Stichele 2001-06-01 22:23:24 +00:00
parent f36b5fc981
commit 8d262037b9
2 changed files with 89 additions and 1 deletions

View file

@ -2,7 +2,7 @@ SUBDIRS = sched eos nego
noinst_PROGRAMS = init loadall simplefake states caps queue registry \ noinst_PROGRAMS = init loadall simplefake states caps queue registry \
paranoia rip mp3encode autoplug props case4 markup load tee autoplug2 autoplug3 \ paranoia rip mp3encode autoplug props case4 markup load tee autoplug2 autoplug3 \
capsconnect padfactory autoplug4 incsched reaping threadlock mp1vid capsconnect padfactory autoplug4 incsched reaping threadlock mp1vid reconnect
# we have nothing but apps here, we can do this safely # we have nothing but apps here, we can do this safely
LIBS += $(GST_LIBS) LIBS += $(GST_LIBS)

88
tests/reconnect.c Normal file
View file

@ -0,0 +1,88 @@
/*
* reconnect.c - test disconnect and reconnect
* thomas@apestaart.org
*
* Latest change : 31/05/2001
*
* Version : 0.1
*/
#include <stdlib.h>
#include <gst/gst.h>
#include <unistd.h>
#define DEBUG
/* function prototypes */
GstElement *main_bin;
GstElement *fakesrc;
GstElement *fakesink;
int main (int argc, char *argv[])
{
int i;
gst_init (&argc, &argv);
/* set up input channel and main bin */
g_print ("creating main bin\n");
/* create an audio src */
fakesrc = gst_elementfactory_make ("fakesrc", "fakesrc");
fakesink = gst_elementfactory_make ("fakesink", "fakesink");
/*
gtk_object_set (GTK_OBJECT (fakesink), "silent", TRUE, NULL);
*/
/* create main bin */
main_bin = gst_pipeline_new ("bin");
gst_bin_add (GST_BIN (main_bin), fakesrc);
gst_bin_add (GST_BIN (main_bin), fakesink);
gst_pad_connect (gst_element_get_pad (fakesrc, "src"),
gst_element_get_pad (fakesink, "sink"));
/* start playing */
g_print ("setting to play\n");
gst_element_set_state (main_bin, GST_STATE_PLAYING);
for (i = 0; i < 5; ++i)
{
g_print ("going to iterate\n");
gst_bin_iterate (GST_BIN (main_bin));
g_print ("back from iterate\n");
}
/* disconnect and reconnect fakesink */
g_print ("disconnecting...\n");
gst_pad_disconnect (gst_element_get_pad (fakesrc, "src"),
gst_element_get_pad (fakesink, "sink"));
g_print ("reconnecting...\n");
gst_pad_connect (gst_element_get_pad (fakesrc, "src"),
gst_element_get_pad (fakesink, "sink"));
for (i = 0; i < 5; ++i)
{
g_print ("going to iterate\n");
gst_bin_iterate (GST_BIN (main_bin));
g_print ("back from iterate\n");
}
g_print ("we're done iterating.\n");
/* stop the bin */
gst_element_set_state(main_bin, GST_STATE_NULL);
/*
gst_object_destroy (GST_OBJECT (fakesink));
gst_object_destroy (GST_OBJECT (main_bin));
*/
exit(0);
}