2000-12-31 22:11:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-12-22 16:14:33 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2000-12-22 23:23:10 +00:00
|
|
|
static guint outcount, incount;
|
|
|
|
|
2000-12-22 16:14:33 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
buffer_handoff_sink (GstElement * src, GstBuffer * buf, GstElement * bin)
|
2000-12-22 16:14:33 +00:00
|
|
|
{
|
|
|
|
g_print ("\n\n *** buffer arrived in sink ***\n\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_set_state (bin, GST_STATE_NULL);
|
2000-12-22 23:23:10 +00:00
|
|
|
|
|
|
|
outcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
buffer_handoff_src (GstElement * src, GstBuffer * buf, GstElement * bin)
|
2000-12-22 23:23:10 +00:00
|
|
|
{
|
|
|
|
g_print ("\n\n *** buffer started in src ***\n\n");
|
|
|
|
incount++;
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* eos will be called when the src element has an end of stream */
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
eos (GstElement * element, gpointer data)
|
2000-12-22 16:14:33 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("have eos, quitting\n");
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2000-12-22 16:14:33 +00:00
|
|
|
{
|
|
|
|
GstXML *xml;
|
|
|
|
GList *toplevelelements;
|
|
|
|
gint i = 1;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_init (&argc, &argv);
|
2000-12-22 16:14:33 +00:00
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
g_print ("usage: %s <xml file>\n", argv[0]);
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("\n *** using testfile %s\n", argv[1]);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
xml = gst_xml_new ();
|
2001-06-01 18:24:41 +00:00
|
|
|
gst_xml_parse_file (xml, argv[1], NULL);
|
2000-12-22 16:14:33 +00:00
|
|
|
|
|
|
|
toplevelelements = gst_xml_get_topelements (xml);
|
|
|
|
|
|
|
|
while (toplevelelements) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *bin = (GstElement *) toplevelelements->data;
|
2000-12-22 16:14:33 +00:00
|
|
|
GstElement *src, *sink;
|
|
|
|
|
|
|
|
g_print ("\n ***** testcase %d\n", i++);
|
|
|
|
|
|
|
|
src = gst_bin_get_by_name (GST_BIN (bin), "fakesrc");
|
|
|
|
if (src) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (src), "handoff",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_CALLBACK (buffer_handoff_src), bin);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
2000-12-22 16:14:33 +00:00
|
|
|
g_print ("could not find src element\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
exit (-1);
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2000-12-22 16:14:33 +00:00
|
|
|
sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink");
|
|
|
|
if (sink) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (sink), "handoff",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_CALLBACK (buffer_handoff_sink), bin);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
2000-12-22 16:14:33 +00:00
|
|
|
g_print ("could not find sink element\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
exit (-1);
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-22 23:23:10 +00:00
|
|
|
incount = 0;
|
|
|
|
outcount = 0;
|
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* gst_element_set_state(bin, GST_STATE_READY); */
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
2000-12-22 16:14:33 +00:00
|
|
|
|
|
|
|
if (GST_IS_THREAD (bin)) {
|
2003-06-29 14:05:49 +00:00
|
|
|
g_usleep (G_USEC_PER_SEC);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
|
|
|
gst_bin_iterate (GST_BIN (bin));
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-22 23:23:10 +00:00
|
|
|
if (outcount != 1 && incount != 1) {
|
|
|
|
g_print ("test failed\n");
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
2000-12-22 16:14:33 +00:00
|
|
|
toplevelelements = g_list_next (toplevelelements);
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
exit (0);
|
2000-12-22 16:14:33 +00:00
|
|
|
}
|