Commit 9987a75b authored by Wim Taymans's avatar Wim Taymans
Browse files

Implemented some test cases... they all fail :-(

Original commit message from CVS:
Implemented some test cases... they all fail :-(
Added a flag to identity to for loop_based behaviour.
Added a signal to fakesink when a buffer is consumed.
parent a914e7b2
......@@ -34,6 +34,7 @@ GstElementDetails gst_fakesink_details = {
/* FakeSink signals and args */
enum {
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
......@@ -49,7 +50,7 @@ static void gst_fakesink_init(GstFakeSink *fakesink);
static void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
static GstSinkClass *parent_class = NULL;
//static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_fakesink_get_type (void)
......@@ -75,10 +76,20 @@ gst_fakesink_get_type (void)
static void
gst_fakesink_class_init (GstFakeSinkClass *klass)
{
GtkObjectClass *gtkobject_class;
GstSinkClass *gstsink_class;
gtkobject_class = (GtkObjectClass*)klass;
gstsink_class = (GstSinkClass*)klass;
gst_fakesink_signals[SIGNAL_HANDOFF] =
gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstFakeSinkClass, handoff),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (gtkobject_class, gst_fakesink_signals,
LAST_SIGNAL);
parent_class = gtk_type_class (GST_TYPE_SINK);
}
......@@ -114,4 +125,8 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_print("(%s:%s)< ",GST_DEBUG_PAD_NAME(pad));
gst_buffer_unref (buf);
gtk_signal_emit (GTK_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF],
fakesink);
}
......@@ -56,6 +56,9 @@ struct _GstFakeSink {
struct _GstFakeSinkClass {
GstSinkClass parent_class;
/* signals */
void (*handoff) (GstElement *element,GstPad *pad);
};
GtkType gst_fakesink_get_type(void);
......
......@@ -39,7 +39,7 @@ enum {
enum {
ARG_0,
ARG_CONTROL
ARG_LOOP_BASED,
};
......@@ -86,11 +86,11 @@ gst_identity_class_init (GstIdentityClass *klass)
parent_class = gtk_type_class (GST_TYPE_FILTER);
//gtk_object_add_arg_type("GstIdentity::control", GTK_TYPE_INT,
// GTK_ARG_READWRITE, ARG_CONTROL);
gtk_object_add_arg_type ("GstIdentity::loop_based", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_LOOP_BASED);
//gtkobject_class->set_arg = gst_identity_set_arg;
//gtkobject_class->get_arg = gst_identity_get_arg;
gtkobject_class->set_arg = gst_identity_set_arg;
gtkobject_class->get_arg = gst_identity_get_arg;
}
static void
......@@ -103,7 +103,7 @@ gst_identity_init (GstIdentity *identity)
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
identity->control = 0;
identity->loop_based = FALSE;
}
static void
......@@ -121,6 +121,22 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
gst_pad_push (identity->srcpad, buf);
}
static void
gst_identity_loop (GstElement *element)
{
GstIdentity *identity;
GstBuffer *buf;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_IDENTITY (element));
identity = GST_IDENTITY (element);
buf = gst_pad_pull (identity->sinkpad);
gst_pad_push (identity->srcpad, buf);
}
static void
gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)
{
......@@ -132,8 +148,16 @@ gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)
identity = GST_IDENTITY (object);
switch(id) {
case ARG_CONTROL:
identity->control = GTK_VALUE_INT (*arg);
case ARG_LOOP_BASED:
identity->loop_based = GTK_VALUE_BOOL (*arg);
if (identity->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (identity), gst_identity_loop);
gst_pad_set_chain_function (identity->sinkpad, NULL);
}
else {
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
}
break;
default:
break;
......@@ -149,8 +173,8 @@ static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) {
identity = GST_IDENTITY (object);
switch (id) {
case ARG_CONTROL:
GTK_VALUE_INT (*arg) = identity->control;
case ARG_LOOP_BASED:
GTK_VALUE_BOOL (*arg) = identity->loop_based;
break;
default:
arg->type = GTK_TYPE_INVALID;
......
......@@ -54,7 +54,7 @@ struct _GstIdentity {
GstPad *sinkpad;
GstPad *srcpad;
gint control;
gboolean loop_based;
};
struct _GstIdentityClass {
......
......@@ -20,17 +20,14 @@
#include "gstdebug.h"
#include "gstautoplug.h"
#define MAX_COST 999999
typedef guint (*GstAutoplugCostFunction) (gpointer src, gpointer dest, gpointer data);
typedef GList* (*GstAutoplugListFunction) (gpointer data);
static void gst_autoplug_class_init (GstAutoplugClass *klass);
static void gst_autoplug_init (GstAutoplug *autoplug);
static GList* gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
GstAutoplugCostFunction cost_function,
gpointer data);
struct _gst_autoplug_node
{
gpointer iNode;
......@@ -40,69 +37,33 @@ struct _gst_autoplug_node
typedef struct _gst_autoplug_node gst_autoplug_node;
static GList*
gst_autoplug_enqueue (GList *queue, gpointer iNode, gint iDist, gpointer iPrev)
{
gst_autoplug_node *node = g_malloc (sizeof (gst_autoplug_node));
node->iNode = iNode;
node->iDist = iDist;
node->iPrev = iPrev;
queue = g_list_append (queue, node);
return queue;
}
static GList*
gst_autoplug_dequeue (GList *queue, gpointer *iNode, gint *iDist, gpointer *iPrev)
{
GList *head;
gst_autoplug_node *node;
head = g_list_first (queue);
if (head) {
node = (gst_autoplug_node *)head->data;
*iNode = node->iNode;
*iPrev = node->iPrev;
*iDist = node->iDist;
head = g_list_remove (queue, node);
static GstObjectClass *parent_class = NULL;
GtkType gst_autoplug_get_type(void) {
static GtkType autoplug_type = 0;
if (!autoplug_type) {
static const GtkTypeInfo autoplug_info = {
"GstAutoplug",
sizeof(GstElement),
sizeof(GstElementClass),
(GtkClassInitFunc)gst_autoplug_class_init,
(GtkObjectInitFunc)gst_autoplug_init,
(GtkArgSetFunc)NULL,
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
autoplug_type = gtk_type_unique(GST_TYPE_AUTOPLUG,&autoplug_info);
}
return head;
return autoplug_type;
}
static gint
find_factory (gst_autoplug_node *rgnNodes, GstElementFactory *factory)
{
gint i=0;
while (rgnNodes[i].iNode) {
if (rgnNodes[i].iNode == factory) return i;
i++;
}
return 0;
static void
gst_autoplug_class_init(GstAutoplugClass *klass) {
parent_class = gtk_type_class(GST_TYPE_OBJECT);
}
static GList*
construct_path (gst_autoplug_node *rgnNodes, GstElementFactory *factory)
{
GstElementFactory *current;
GList *factories = NULL;
current = rgnNodes[find_factory(rgnNodes, factory)].iPrev;
while (current != NULL)
{
gpointer next;
next = rgnNodes[find_factory(rgnNodes, current)].iPrev;
if (next) factories = g_list_prepend (factories, current);
current = next;
}
return factories;
static void gst_autoplug_init(GstAutoplug *autoplug) {
}
static gboolean
......@@ -144,25 +105,6 @@ gst_autoplug_elementfactory_get_list (gpointer data)
return gst_elementfactory_get_list ();
}
static guint
gst_autoplug_elementfactory_find_cost (gpointer src, gpointer dest, gpointer data)
{
if (gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest)) {
return 1;
}
return MAX_COST;
}
GList*
gst_autoplug_factories (GstElementFactory *srcfactory, GstElementFactory *sinkfactory)
{
return gst_autoplug_func (srcfactory, sinkfactory,
gst_autoplug_elementfactory_get_list,
gst_autoplug_elementfactory_find_cost,
NULL);
}
typedef struct {
GstCaps *src;
GstCaps *sink;
......@@ -192,8 +134,10 @@ gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
res = gst_autoplug_can_match ((GstElementFactory *)src, (GstElementFactory *)dest);
}
if (res) return 1;
return MAX_COST;
if (res)
return 1;
else
return GST_AUTOPLUG_MAX_COST;
}
GList*
......@@ -210,34 +154,69 @@ gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps)
&caps);
}
GList*
gst_autoplug_elements (GstElement *src, GstElement *sink)
static gint
find_factory (gst_autoplug_node *rgnNodes, gpointer factory)
{
return NULL;
gint i=0;
while (rgnNodes[i].iNode) {
if (rgnNodes[i].iNode == factory) return i;
i++;
}
return 0;
}
GList*
gst_autoplug_caps_to_factory (GstCaps *srccaps, GstElementFactory *sinkfactory)
static GList*
construct_path (gst_autoplug_node *rgnNodes, gpointer factory)
{
return NULL;
GstElementFactory *current;
GList *factories = NULL;
current = rgnNodes[find_factory(rgnNodes, factory)].iPrev;
while (current != NULL)
{
gpointer next;
next = rgnNodes[find_factory(rgnNodes, current)].iPrev;
if (next) factories = g_list_prepend (factories, current);
current = next;
}
return factories;
}
GList*
gst_autoplug_factory_to_caps (GstElementFactory *srcfactory, GstCaps *sinkcaps)
static GList*
gst_autoplug_enqueue (GList *queue, gpointer iNode, gint iDist, gpointer iPrev)
{
return NULL;
gst_autoplug_node *node = g_malloc (sizeof (gst_autoplug_node));
node->iNode = iNode;
node->iDist = iDist;
node->iPrev = iPrev;
queue = g_list_append (queue, node);
return queue;
}
static GList*
gst_autoplug_dequeue (GList *queue, gpointer *iNode, gint *iDist, gpointer *iPrev)
{
GList *head;
gst_autoplug_node *node;
head = g_list_first (queue);
if (head) {
node = (gst_autoplug_node *)head->data;
*iNode = node->iNode;
*iPrev = node->iPrev;
*iDist = node->iDist;
head = g_list_remove (queue, node);
}
return head;
}
/**
* gst_type_get_sink_to_src:
* @sinkid: the id of the sink
* @srcid: the id of the source
*
* return a list of elementfactories that convert the source
* type id to the sink type id
*
* Returns: a list of elementfactories
*/
static GList*
gst_autoplug_func (gpointer src, gpointer sink,
GstAutoplugListFunction list_function,
......@@ -253,8 +232,6 @@ gst_autoplug_func (gpointer src, gpointer sink,
GList *factories;
guint num_factories;
DEBUG ("%p %p\n", src, sink);
elements = g_list_append (elements, sink);
elements = g_list_append (elements, src);
......@@ -274,7 +251,7 @@ gst_autoplug_func (gpointer src, gpointer sink,
rgnNodes[i].iDist = 0;
}
else {
rgnNodes[i].iDist = MAX_COST;
rgnNodes[i].iDist = GST_AUTOPLUG_MAX_COST;
}
factories = g_list_next (factories);
......@@ -292,8 +269,8 @@ gst_autoplug_func (gpointer src, gpointer sink,
gpointer current = factories2->data;
iCost = cost_function (iNode, current, data);
if (iCost != MAX_COST) {
if((MAX_COST == rgnNodes[i].iDist) ||
if (iCost != GST_AUTOPLUG_MAX_COST) {
if((GST_AUTOPLUG_MAX_COST == rgnNodes[i].iDist) ||
(rgnNodes[i].iDist > (iCost + iDist))) {
rgnNodes[i].iDist = iDist + iCost;
rgnNodes[i].iPrev = iNode;
......
......@@ -27,17 +27,36 @@
extern "C" {
#endif /* __cplusplus */
#define GST_TYPE_AUTOPLUG \
(gst_object_get_type())
#define GST_AUTOPLUG(obj) \
(GTK_CHECK_CAST((obj),GST_TYPE_AUTOPLUG,GstAutoplug))
#define GST_AUTOPLUG_CLASS(klass) \
(GTK_CHECK_CLASS_CAST((klass),GST_TYPE_AUTOPLUG,GstAutoplugClass))
#define GST_IS_AUTOPLUG(obj) \
(GTK_CHECK_TYPE((obj),GST_TYPE_AUTOPLUG))
#define GST_IS_AUTOPLUG_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_AUTOPLUG))
GList* gst_autoplug_factories (GstElementFactory *srcfactory,
GstElementFactory *sinkfactory);
GList* gst_autoplug_elements (GstElement *src,
GstElement *sink);
typedef struct _GstAutoplug GstAutoplug;
typedef struct _GstAutoplugClass GstAutoplugClass;
GList* gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps);
#define GST_AUTOPLUG_MAX_COST 999999
typedef guint (*GstAutoplugCostFunction) (gpointer src, gpointer dest, gpointer data);
typedef GList* (*GstAutoplugListFunction) (gpointer data);
struct _GstAutoplug {
GtkObject object;
};
GList* gst_autoplug_caps_to_factory (GstCaps *srccaps, GstElementFactory *sinkfactory);
struct _GstAutoplugClass {
GtkObjectClass parent_class;
};
GList* gst_autoplug_factory_to_caps (GstElementFactory *srcfactory, GstCaps *sinkcaps);
GtkType gst_autoplug_get_type (void);
GList* gst_autoplug_caps (GstCaps *srccaps, GstCaps *sinkcaps);
#ifdef __cplusplus
......
......@@ -157,7 +157,8 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
gst_bin_add (GST_BIN (pipeline), typefind);
gst_bin_create_plan (GST_BIN (pipeline));
//gst_bin_create_plan (GST_BIN (pipeline));
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
// keep pushing buffers... the have_type signal handler will set the found flag
......
......@@ -17,6 +17,7 @@
* Boston, MA 02111-1307, USA.
*/
#include "gstdebug.h"
#include "gstxml.h"
static void gst_xml_class_init (GstXMLClass *klass);
......@@ -107,7 +108,6 @@ gst_xml_new (const guchar *fname, const guchar *root)
xml = GST_XML(gtk_type_new(GST_TYPE_XML));
xml->elements = g_hash_table_new(g_str_hash, g_str_equal);
xml->topelements = NULL;
field = doc->root->childs;
......@@ -116,7 +116,11 @@ gst_xml_new (const guchar *fname, const guchar *root)
if (!strcmp(field->name, "element")) {
GstElement *element;
xml->elements = g_hash_table_new(g_str_hash, g_str_equal);
element = gst_element_load_thyself(field, xml->elements);
g_hash_table_destroy (xml->elements);
xml->topelements = g_list_prepend (xml->topelements, element);
}
......@@ -163,7 +167,7 @@ gst_xml_get_element (GstXML *xml, const guchar *name)
g_return_val_if_fail(xml != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
g_print("gstxml: getting element \"%s\"\n", name);
DEBUG ("gstxml: getting element \"%s\"\n", name);
element = g_hash_table_lookup(xml->elements, name);
......
......@@ -18,8 +18,6 @@ main (int argc, char *argv[])
glade_init();
glade_gnome_init();
gst_type_dump ();
play = gst_media_play_new ();
if (argc > 1) {
......
......@@ -34,6 +34,7 @@ GstElementDetails gst_fakesink_details = {
/* FakeSink signals and args */
enum {
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
......@@ -49,7 +50,7 @@ static void gst_fakesink_init(GstFakeSink *fakesink);
static void gst_fakesink_chain(GstPad *pad,GstBuffer *buf);
static GstSinkClass *parent_class = NULL;
//static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_fakesink_get_type (void)
......@@ -75,10 +76,20 @@ gst_fakesink_get_type (void)
static void
gst_fakesink_class_init (GstFakeSinkClass *klass)
{
GtkObjectClass *gtkobject_class;
GstSinkClass *gstsink_class;
gtkobject_class = (GtkObjectClass*)klass;
gstsink_class = (GstSinkClass*)klass;
gst_fakesink_signals[SIGNAL_HANDOFF] =
gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstFakeSinkClass, handoff),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (gtkobject_class, gst_fakesink_signals,
LAST_SIGNAL);
parent_class = gtk_type_class (GST_TYPE_SINK);
}
......@@ -114,4 +125,8 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_print("(%s:%s)< ",GST_DEBUG_PAD_NAME(pad));
gst_buffer_unref (buf);
gtk_signal_emit (GTK_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF],
fakesink);
}
......@@ -56,6 +56,9 @@ struct _GstFakeSink {
struct _GstFakeSinkClass {
GstSinkClass parent_class;
/* signals */
void (*handoff) (GstElement *element,GstPad *pad);
};
GtkType gst_fakesink_get_type(void);
......
......@@ -39,7 +39,7 @@ enum {
enum {
ARG_0,
ARG_CONTROL
ARG_LOOP_BASED,
};
......@@ -86,11 +86,11 @@ gst_identity_class_init (GstIdentityClass *klass)
parent_class = gtk_type_class (GST_TYPE_FILTER);
//gtk_object_add_arg_type("GstIdentity::control", GTK_TYPE_INT,
// GTK_ARG_READWRITE, ARG_CONTROL);
gtk_object_add_arg_type ("GstIdentity::loop_based", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_LOOP_BASED);
//gtkobject_class->set_arg = gst_identity_set_arg;
//gtkobject_class->get_arg = gst_identity_get_arg;
gtkobject_class->set_arg = gst_identity_set_arg;
gtkobject_class->get_arg = gst_identity_get_arg;
}
static void
......@@ -103,7 +103,7 @@ gst_identity_init (GstIdentity *identity)
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
identity->control = 0;
identity->loop_based = FALSE;
}
static void
......@@ -121,6 +121,22 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
gst_pad_push (identity->srcpad, buf);
}
static void
gst_identity_loop (GstElement *element)
{
GstIdentity *identity;
GstBuffer *buf;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_IDENTITY (element));
identity = GST_IDENTITY (element);
buf = gst_pad_pull (identity->sinkpad);
gst_pad_push (identity->srcpad, buf);
}
static void
gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)