mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
adding basic tests for fakesrc fakesink and tee
Original commit message from CVS: adding basic tests for fakesrc fakesink and tee
This commit is contained in:
parent
d04d01cc3b
commit
ace842815e
8 changed files with 312 additions and 22 deletions
|
@ -1,9 +1,9 @@
|
||||||
testprogs = tee
|
testprogs = tee fake
|
||||||
|
|
||||||
TESTS = $(testprogs)
|
TESTS = $(testprogs)
|
||||||
|
|
||||||
check_PROGRAMS = $(testprogs)
|
check_PROGRAMS = $(testprogs)
|
||||||
|
|
||||||
tee_LDADD = $(GST_LIBS)
|
LDADD = $(GST_LIBS)
|
||||||
tee_CFLAGS = $(GST_CFLAGS)
|
CFLAGS = $(GST_CFLAGS)
|
||||||
|
|
||||||
|
|
45
tests/old/testsuite/elements/events.h
Normal file
45
tests/old/testsuite/elements/events.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/gstpropsprivate.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* no need to librify this simple function set
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_props (gpointer data, gpointer user_data)
|
||||||
|
{
|
||||||
|
GstPropsEntry *entry = (GstPropsEntry *)data;
|
||||||
|
GstElement *element = GST_ELEMENT (user_data);
|
||||||
|
|
||||||
|
g_print ("%s: %s: ", gst_element_get_name (element),
|
||||||
|
g_quark_to_string (entry->propid));
|
||||||
|
switch (entry->propstype) {
|
||||||
|
case GST_PROPS_INT_ID:
|
||||||
|
g_print ("%d\n", entry->data.int_data);
|
||||||
|
break;
|
||||||
|
case GST_PROPS_STRING_ID:
|
||||||
|
g_print ("%s\n", entry->data.string_data.string);
|
||||||
|
break;
|
||||||
|
case GST_PROPS_FLOAT_ID:
|
||||||
|
g_print ("%f\n", entry->data.float_data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_print ("unknown\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_func (GstElement *element, GstEvent *event)
|
||||||
|
{
|
||||||
|
GstProps *props;
|
||||||
|
|
||||||
|
if (event == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_INFO) {
|
||||||
|
props = GST_EVENT_INFO_PROPS (event);
|
||||||
|
|
||||||
|
g_list_foreach (props->properties, print_props, GST_EVENT_SRC (event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
68
tests/old/testsuite/elements/fake.c
Normal file
68
tests/old/testsuite/elements/fake.c
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* test for fakesrc and fakesink element
|
||||||
|
* this tests for proxying of caps
|
||||||
|
* thomas@apestaart.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
el = (GstElement *) gst_elementfactory_make (element, name);
|
||||||
|
if (el == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
GstElement *pipeline = NULL;
|
||||||
|
GstElement *src, *sink;
|
||||||
|
|
||||||
|
/* init */
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* create */
|
||||||
|
g_print ("Creating pipeline\n");
|
||||||
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (pipeline), "event", G_CALLBACK (event_func), NULL);
|
||||||
|
g_print ("Creating elements\n");
|
||||||
|
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
||||||
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
||||||
|
if (!(sink = element_create ("sink", "fakesink"))) return 1;
|
||||||
|
|
||||||
|
/* add */
|
||||||
|
g_print ("Adding elements to bin\n");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), src);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink);
|
||||||
|
|
||||||
|
/* connect */
|
||||||
|
g_print ("Connecting elements\n");
|
||||||
|
gst_pad_connect (gst_element_get_pad (src, "src"),
|
||||||
|
gst_element_get_pad (sink, "sink"));
|
||||||
|
|
||||||
|
/* set to play */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
g_print ("Done !\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
GstElement *
|
GstElement *
|
||||||
element_create (char *name, char *element)
|
element_create (char *name, char *element)
|
||||||
|
@ -32,7 +33,7 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *pipeline = NULL;
|
GstElement *pipeline = NULL;
|
||||||
GstElement *tee, *src, *sink1, *sink2;
|
GstElement *tee, *src, *sink1, *sink2;
|
||||||
GstPad *tee_src;
|
GstPad *tee_src1, *tee_src2;
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
|
@ -40,26 +41,57 @@ main (int argc, char *argv[])
|
||||||
/* create */
|
/* create */
|
||||||
g_print ("Creating pipeline\n");
|
g_print ("Creating pipeline\n");
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
//g_assert (GST_IS_PIPELINE (pipeline));
|
g_signal_connect (G_OBJECT (pipeline), "event", G_CALLBACK (event_func), NULL);
|
||||||
|
|
||||||
g_print ("Creating elements\n");
|
g_print ("Creating elements\n");
|
||||||
if (!(tee = element_create ("tee", "tee"))) return 1;
|
if (!(tee = element_create ("tee", "tee"))) return 1;
|
||||||
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
||||||
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
||||||
if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
|
if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
|
||||||
if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
|
if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
|
||||||
|
|
||||||
/* add */
|
/* add */
|
||||||
g_print ("Adding elements to bin\n");
|
g_print ("Adding elements to bin\n");
|
||||||
gst_bin_add (GST_BIN (pipeline), src);
|
gst_bin_add (GST_BIN (pipeline), src);
|
||||||
gst_bin_add (GST_BIN (pipeline), tee);
|
gst_bin_add (GST_BIN (pipeline), tee);
|
||||||
|
|
||||||
/* request one pad from tee */
|
|
||||||
tee_src = gst_element_request_pad_by_name (tee, "src%d");
|
|
||||||
|
|
||||||
/* connect */
|
/* connect input part */
|
||||||
gst_pad_connect (tee_src, gst_element_get_pad (sink1, "sink"));
|
g_print ("Connecting input elements\n");
|
||||||
|
gst_pad_connect (gst_element_get_pad (src, "src"),
|
||||||
|
gst_element_get_pad (tee, "sink"));
|
||||||
|
|
||||||
|
/* request one pad from tee */
|
||||||
|
g_print ("Requesting first pad\n");
|
||||||
|
tee_src1 = gst_element_request_pad_by_name (tee, "src%d");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink1);
|
||||||
|
gst_pad_connect (tee_src1, gst_element_get_pad (sink1, "sink"));
|
||||||
|
|
||||||
/* set to play */
|
/* set to play */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
/* pause and request another pad */
|
||||||
|
g_print ("Requesting second pad\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
tee_src2 = gst_element_request_pad_by_name (tee, "src%d");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink2);
|
||||||
|
gst_pad_connect (tee_src2, gst_element_get_pad (sink2, "sink"));
|
||||||
|
|
||||||
|
/* now we have two fakesinks connected, iterate */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
/* remove the first one, iterate */
|
||||||
|
g_print ("Removing first sink\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
gst_pad_disconnect (tee_src1, gst_element_get_pad (sink1, "sink"));
|
||||||
|
gst_pad_destroy (tee_src1);
|
||||||
|
gst_bin_remove (GST_BIN (pipeline), sink1);
|
||||||
|
|
||||||
|
/* only second fakesink connected, iterate */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
gst_bin_iterate (GST_BIN (pipeline));
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
testprogs = tee
|
testprogs = tee fake
|
||||||
|
|
||||||
TESTS = $(testprogs)
|
TESTS = $(testprogs)
|
||||||
|
|
||||||
check_PROGRAMS = $(testprogs)
|
check_PROGRAMS = $(testprogs)
|
||||||
|
|
||||||
tee_LDADD = $(GST_LIBS)
|
LDADD = $(GST_LIBS)
|
||||||
tee_CFLAGS = $(GST_CFLAGS)
|
CFLAGS = $(GST_CFLAGS)
|
||||||
|
|
||||||
|
|
45
testsuite/elements/events.h
Normal file
45
testsuite/elements/events.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/gstpropsprivate.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* no need to librify this simple function set
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_props (gpointer data, gpointer user_data)
|
||||||
|
{
|
||||||
|
GstPropsEntry *entry = (GstPropsEntry *)data;
|
||||||
|
GstElement *element = GST_ELEMENT (user_data);
|
||||||
|
|
||||||
|
g_print ("%s: %s: ", gst_element_get_name (element),
|
||||||
|
g_quark_to_string (entry->propid));
|
||||||
|
switch (entry->propstype) {
|
||||||
|
case GST_PROPS_INT_ID:
|
||||||
|
g_print ("%d\n", entry->data.int_data);
|
||||||
|
break;
|
||||||
|
case GST_PROPS_STRING_ID:
|
||||||
|
g_print ("%s\n", entry->data.string_data.string);
|
||||||
|
break;
|
||||||
|
case GST_PROPS_FLOAT_ID:
|
||||||
|
g_print ("%f\n", entry->data.float_data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_print ("unknown\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_func (GstElement *element, GstEvent *event)
|
||||||
|
{
|
||||||
|
GstProps *props;
|
||||||
|
|
||||||
|
if (event == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_INFO) {
|
||||||
|
props = GST_EVENT_INFO_PROPS (event);
|
||||||
|
|
||||||
|
g_list_foreach (props->properties, print_props, GST_EVENT_SRC (event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
68
testsuite/elements/fake.c
Normal file
68
testsuite/elements/fake.c
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* test for fakesrc and fakesink element
|
||||||
|
* this tests for proxying of caps
|
||||||
|
* thomas@apestaart.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
el = (GstElement *) gst_elementfactory_make (element, name);
|
||||||
|
if (el == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
GstElement *pipeline = NULL;
|
||||||
|
GstElement *src, *sink;
|
||||||
|
|
||||||
|
/* init */
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* create */
|
||||||
|
g_print ("Creating pipeline\n");
|
||||||
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (pipeline), "event", G_CALLBACK (event_func), NULL);
|
||||||
|
g_print ("Creating elements\n");
|
||||||
|
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
||||||
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
||||||
|
if (!(sink = element_create ("sink", "fakesink"))) return 1;
|
||||||
|
|
||||||
|
/* add */
|
||||||
|
g_print ("Adding elements to bin\n");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), src);
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink);
|
||||||
|
|
||||||
|
/* connect */
|
||||||
|
g_print ("Connecting elements\n");
|
||||||
|
gst_pad_connect (gst_element_get_pad (src, "src"),
|
||||||
|
gst_element_get_pad (sink, "sink"));
|
||||||
|
|
||||||
|
/* set to play */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
g_print ("Done !\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
GstElement *
|
GstElement *
|
||||||
element_create (char *name, char *element)
|
element_create (char *name, char *element)
|
||||||
|
@ -32,7 +33,7 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *pipeline = NULL;
|
GstElement *pipeline = NULL;
|
||||||
GstElement *tee, *src, *sink1, *sink2;
|
GstElement *tee, *src, *sink1, *sink2;
|
||||||
GstPad *tee_src;
|
GstPad *tee_src1, *tee_src2;
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
|
@ -40,26 +41,57 @@ main (int argc, char *argv[])
|
||||||
/* create */
|
/* create */
|
||||||
g_print ("Creating pipeline\n");
|
g_print ("Creating pipeline\n");
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
//g_assert (GST_IS_PIPELINE (pipeline));
|
g_signal_connect (G_OBJECT (pipeline), "event", G_CALLBACK (event_func), NULL);
|
||||||
|
|
||||||
g_print ("Creating elements\n");
|
g_print ("Creating elements\n");
|
||||||
if (!(tee = element_create ("tee", "tee"))) return 1;
|
if (!(tee = element_create ("tee", "tee"))) return 1;
|
||||||
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
if (!(src = element_create ("src", "fakesrc"))) return 1;
|
||||||
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
||||||
if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
|
if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
|
||||||
if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
|
if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
|
||||||
|
|
||||||
/* add */
|
/* add */
|
||||||
g_print ("Adding elements to bin\n");
|
g_print ("Adding elements to bin\n");
|
||||||
gst_bin_add (GST_BIN (pipeline), src);
|
gst_bin_add (GST_BIN (pipeline), src);
|
||||||
gst_bin_add (GST_BIN (pipeline), tee);
|
gst_bin_add (GST_BIN (pipeline), tee);
|
||||||
|
|
||||||
/* request one pad from tee */
|
|
||||||
tee_src = gst_element_request_pad_by_name (tee, "src%d");
|
|
||||||
|
|
||||||
/* connect */
|
/* connect input part */
|
||||||
gst_pad_connect (tee_src, gst_element_get_pad (sink1, "sink"));
|
g_print ("Connecting input elements\n");
|
||||||
|
gst_pad_connect (gst_element_get_pad (src, "src"),
|
||||||
|
gst_element_get_pad (tee, "sink"));
|
||||||
|
|
||||||
|
/* request one pad from tee */
|
||||||
|
g_print ("Requesting first pad\n");
|
||||||
|
tee_src1 = gst_element_request_pad_by_name (tee, "src%d");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink1);
|
||||||
|
gst_pad_connect (tee_src1, gst_element_get_pad (sink1, "sink"));
|
||||||
|
|
||||||
/* set to play */
|
/* set to play */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
/* pause and request another pad */
|
||||||
|
g_print ("Requesting second pad\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
tee_src2 = gst_element_request_pad_by_name (tee, "src%d");
|
||||||
|
gst_bin_add (GST_BIN (pipeline), sink2);
|
||||||
|
gst_pad_connect (tee_src2, gst_element_get_pad (sink2, "sink"));
|
||||||
|
|
||||||
|
/* now we have two fakesinks connected, iterate */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
/* remove the first one, iterate */
|
||||||
|
g_print ("Removing first sink\n");
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
gst_pad_disconnect (tee_src1, gst_element_get_pad (sink1, "sink"));
|
||||||
|
gst_pad_destroy (tee_src1);
|
||||||
|
gst_bin_remove (GST_BIN (pipeline), sink1);
|
||||||
|
|
||||||
|
/* only second fakesink connected, iterate */
|
||||||
|
g_print ("Doing 1 iteration\n");
|
||||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
gst_bin_iterate (GST_BIN (pipeline));
|
gst_bin_iterate (GST_BIN (pipeline));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue