2002-11-18 22:48:26 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
/* threadf.c
|
|
|
|
* this tests if we can make a GThread and construct and interate a pipeline
|
|
|
|
* inside it
|
|
|
|
* used to fail because of cothread ctx key not being reset on context
|
|
|
|
* destroy
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_IDENTITIES 29
|
|
|
|
#define RUNS_PER_IDENTITY 5
|
|
|
|
|
2004-09-06 15:57:11 +00:00
|
|
|
volatile gboolean running = FALSE;
|
|
|
|
volatile gboolean done = FALSE;
|
2002-11-18 22:48:26 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
construct_pipeline (GstElement * pipeline, gint identities)
|
2002-11-18 22:48:26 +00:00
|
|
|
{
|
2002-12-07 14:16:52 +00:00
|
|
|
GstElement *src, *sink;
|
|
|
|
GstElement *identity = NULL;
|
2002-11-18 22:48:26 +00:00
|
|
|
GstElement *from;
|
|
|
|
int i;
|
|
|
|
|
2002-12-05 23:43:49 +00:00
|
|
|
identity = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
|
|
|
sink = gst_element_factory_make ("fakesink", NULL);
|
2002-11-18 22:48:26 +00:00
|
|
|
g_assert (src);
|
|
|
|
g_assert (sink);
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
|
|
|
from = src;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < identities; ++i) {
|
2002-11-18 22:48:26 +00:00
|
|
|
identity = gst_element_factory_make ("identity", NULL);
|
|
|
|
g_assert (identity);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), identity);
|
2003-01-09 20:02:34 +00:00
|
|
|
if (!(gst_element_link (from, identity)))
|
|
|
|
g_print ("Warning: can't link identity with previous element\n");
|
2002-11-18 22:48:26 +00:00
|
|
|
from = identity;
|
|
|
|
}
|
2003-01-09 20:02:34 +00:00
|
|
|
gst_element_link (identity, sink);
|
2002-11-18 22:48:26 +00:00
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "num_buffers", 10, "sizetype", 3, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
thread (void)
|
|
|
|
{
|
|
|
|
int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
|
|
|
|
int i;
|
|
|
|
GstElement *pipeline;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 30; i < runs; ++i) {
|
2002-11-18 22:48:26 +00:00
|
|
|
pipeline = gst_pipeline_new ("main_pipeline");
|
|
|
|
g_assert (pipeline);
|
|
|
|
|
|
|
|
g_print ("Run %d, using %d identities\n", i, i / RUNS_PER_IDENTITY + 1);
|
|
|
|
construct_pipeline (pipeline, i / RUNS_PER_IDENTITY + 1);
|
|
|
|
if (!gst_element_set_state (pipeline, GST_STATE_PLAYING))
|
|
|
|
g_print ("WARNING: can't set pipeline to play\n");
|
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline)))
|
|
|
|
g_print ("+");
|
|
|
|
g_print ("\n");
|
|
|
|
g_print ("Unreffing pipeline\n");
|
|
|
|
g_object_unref (G_OBJECT (pipeline));
|
|
|
|
}
|
2002-11-19 23:21:28 +00:00
|
|
|
done = TRUE;
|
2002-11-18 22:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (gint argc, gchar * argv[])
|
2002-11-18 22:48:26 +00:00
|
|
|
{
|
|
|
|
done = FALSE;
|
|
|
|
|
|
|
|
g_thread_init (NULL);
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
g_thread_create ((GThreadFunc) thread, NULL, FALSE, NULL);
|
|
|
|
g_print ("main: created GThread\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
while (!done)
|
|
|
|
g_usleep (G_USEC_PER_SEC);
|
2002-11-18 22:48:26 +00:00
|
|
|
g_print ("main: done\n");
|
|
|
|
return 0;
|
|
|
|
}
|