2002-02-05 11:48:36 +00:00
|
|
|
/*
|
|
|
|
* test for fakesrc and fakesink element
|
|
|
|
* thomas@apestaart.org
|
2002-02-05 13:24:46 +00:00
|
|
|
* originally written for 0.3.2
|
2002-02-05 11:48:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2002-02-12 13:53:15 +00:00
|
|
|
#include "property.h"
|
2002-02-05 11:48:36 +00:00
|
|
|
|
|
|
|
GstElement *
|
|
|
|
element_create (char *name, char *element)
|
|
|
|
/*
|
|
|
|
* create the element
|
|
|
|
* print an error if it can't be created
|
|
|
|
* return NULL if it couldn't be created
|
|
|
|
* return element if it did work
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
GstElement *el = NULL;
|
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
el = (GstElement *) gst_element_factory_make (element, name);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (el == NULL) {
|
2002-02-05 11:48:36 +00:00
|
|
|
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
|
|
|
|
return NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else
|
2002-02-05 11:48:36 +00:00
|
|
|
return el;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GstElement *pipeline = NULL;
|
|
|
|
GstElement *src, *sink;
|
2002-05-09 14:50:54 +00:00
|
|
|
gint retval = 0;
|
2002-02-05 11:48:36 +00:00
|
|
|
|
|
|
|
/* init */
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
/* create */
|
|
|
|
g_print ("Creating pipeline\n");
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
|
|
|
2002-02-12 13:53:15 +00:00
|
|
|
g_print ("Connecting signals to pipeline\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (pipeline, "deep_notify",
|
|
|
|
G_CALLBACK (property_change_callback), NULL);
|
2002-02-12 13:53:15 +00:00
|
|
|
g_print ("Creating elements\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(src = element_create ("src", "fakesrc")))
|
|
|
|
return 1;
|
2002-02-05 11:48:36 +00:00
|
|
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(sink = element_create ("sink", "fakesink")))
|
|
|
|
return 1;
|
|
|
|
|
2002-02-05 11:48:36 +00:00
|
|
|
/* add */
|
|
|
|
g_print ("Adding elements to bin\n");
|
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), sink);
|
|
|
|
|
2003-01-10 04:54:20 +00:00
|
|
|
/* link */
|
|
|
|
g_print ("Linking elements\n");
|
2002-05-09 14:26:20 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-05-09 14:50:54 +00:00
|
|
|
|
|
|
|
/* we expect this to give an error */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) {
|
|
|
|
g_warning
|
2004-03-15 19:27:17 +00:00
|
|
|
("Iterating a bin with unlinked elements should return FALSE !\n");
|
2002-05-09 14:50:54 +00:00
|
|
|
retval = 1;
|
|
|
|
}
|
2002-05-09 14:26:20 +00:00
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_pad_link (gst_element_get_pad (src, "src"),
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_get_pad (sink, "sink"));
|
2003-01-09 14:15:37 +00:00
|
|
|
|
2002-02-05 11:48:36 +00:00
|
|
|
/* set to play */
|
|
|
|
g_print ("Doing 1 iteration\n");
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2002-05-09 14:50:54 +00:00
|
|
|
|
|
|
|
/* we expect this to work */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) {
|
2003-01-10 04:54:20 +00:00
|
|
|
g_error ("Iterating a bin with linked elements should return TRUE !\n");
|
2002-05-09 14:50:54 +00:00
|
|
|
retval = 1;
|
|
|
|
}
|
2002-02-05 11:48:36 +00:00
|
|
|
|
|
|
|
g_print ("Done !\n");
|
2002-05-09 14:50:54 +00:00
|
|
|
return retval;
|
2002-02-05 11:48:36 +00:00
|
|
|
}
|