2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstelement.c: The base element, all elements derive from this
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* #define GST_DEBUG_ENABLED */
|
2001-12-04 22:12:50 +00:00
|
|
|
#include <glib.h>
|
2001-12-13 23:37:47 +00:00
|
|
|
#include <stdarg.h>
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstelement.h"
|
|
|
|
#include "gstextratypes.h"
|
2001-01-13 13:51:08 +00:00
|
|
|
#include "gstbin.h"
|
2001-05-25 21:00:07 +00:00
|
|
|
#include "gstscheduler.h"
|
2001-12-18 19:03:07 +00:00
|
|
|
#include "gstevent.h"
|
2001-03-03 17:38:26 +00:00
|
|
|
#include "gstutils.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* Element signals and args */
|
|
|
|
enum {
|
|
|
|
STATE_CHANGE,
|
|
|
|
NEW_PAD,
|
2001-05-25 21:00:07 +00:00
|
|
|
PAD_REMOVED,
|
2000-01-30 09:03:00 +00:00
|
|
|
ERROR,
|
2001-12-18 19:03:07 +00:00
|
|
|
EVENT,
|
2000-12-29 02:28:04 +00:00
|
|
|
EOS,
|
2000-01-30 09:03:00 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
static void gst_element_class_init (GstElementClass *klass);
|
|
|
|
static void gst_element_init (GstElement *element);
|
2001-05-26 22:58:15 +00:00
|
|
|
static void gst_element_base_class_init (GstElementClass *klass);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void gst_element_set_property (GObject *object, guint prop_id,
|
|
|
|
const GValue *value, GParamSpec *pspec);
|
|
|
|
static void gst_element_get_property (GObject *object, guint prop_id, GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-09-28 19:16:02 +00:00
|
|
|
static void gst_element_dispose (GObject *object);
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
static GstElementStateReturn gst_element_change_state (GstElement *element);
|
2001-12-18 19:03:07 +00:00
|
|
|
static void gst_element_send_event_func (GstElement *element, GstEvent *event);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2001-01-29 00:06:02 +00:00
|
|
|
static xmlNodePtr gst_element_save_thyself (GstObject *object, xmlNodePtr parent);
|
2001-06-24 21:18:28 +00:00
|
|
|
GstElement* gst_element_restore_thyself (xmlNodePtr self, GstObject *parent);
|
|
|
|
#endif
|
2000-07-17 17:14:15 +00:00
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
GType _gst_element_type = 0;
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
|
|
|
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
GType gst_element_get_type (void)
|
|
|
|
{
|
|
|
|
if (!_gst_element_type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
static const GTypeInfo element_info = {
|
2000-01-30 09:03:00 +00:00
|
|
|
sizeof(GstElementClass),
|
2001-06-25 01:20:11 +00:00
|
|
|
(GBaseInitFunc)gst_element_base_class_init,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)gst_element_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstElement),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc)gst_element_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
2001-10-17 10:21:27 +00:00
|
|
|
_gst_element_type = g_type_register_static(GST_TYPE_OBJECT, "GstElement", &element_info, G_TYPE_FLAG_ABSTRACT);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-10-17 10:21:27 +00:00
|
|
|
return _gst_element_type;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static void
|
|
|
|
gst_element_class_init (GstElementClass *klass)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-01-29 00:06:02 +00:00
|
|
|
GstObjectClass *gstobject_class;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
gobject_class = (GObjectClass*) klass;
|
2001-01-29 00:06:02 +00:00
|
|
|
gstobject_class = (GstObjectClass*) klass;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
parent_class = g_type_class_ref(GST_TYPE_OBJECT);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
gst_element_signals[STATE_CHANGE] =
|
2001-12-18 19:03:07 +00:00
|
|
|
g_signal_new ("state_change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
2001-12-04 22:12:50 +00:00
|
|
|
G_STRUCT_OFFSET (GstElementClass, state_change), NULL, NULL,
|
|
|
|
gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_INT, G_TYPE_INT);
|
2000-01-30 09:03:00 +00:00
|
|
|
gst_element_signals[NEW_PAD] =
|
2001-12-18 19:03:07 +00:00
|
|
|
g_signal_new ("new_pad", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
2001-12-04 22:12:50 +00:00
|
|
|
G_STRUCT_OFFSET (GstElementClass, new_pad), NULL, NULL,
|
2001-12-18 19:03:07 +00:00
|
|
|
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_POINTER);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_signals[PAD_REMOVED] =
|
2001-12-18 19:03:07 +00:00
|
|
|
g_signal_new ("pad_removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
2001-12-04 22:12:50 +00:00
|
|
|
G_STRUCT_OFFSET (GstElementClass, pad_removed), NULL, NULL,
|
2001-12-18 19:03:07 +00:00
|
|
|
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_POINTER);
|
2000-01-30 09:03:00 +00:00
|
|
|
gst_element_signals[ERROR] =
|
2001-12-18 19:03:07 +00:00
|
|
|
g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
2001-12-04 22:12:50 +00:00
|
|
|
G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL,
|
|
|
|
gst_marshal_VOID__STRING, G_TYPE_NONE,1,
|
2001-12-18 19:03:07 +00:00
|
|
|
G_TYPE_STRING);
|
|
|
|
gst_element_signals[EVENT] =
|
|
|
|
g_signal_new ("event", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstElementClass, event), NULL, NULL,
|
|
|
|
gst_marshal_VOID__POINTER, G_TYPE_NONE,1,
|
|
|
|
G_TYPE_POINTER);
|
2000-12-29 02:28:04 +00:00
|
|
|
gst_element_signals[EOS] =
|
2001-12-18 19:03:07 +00:00
|
|
|
g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
2001-12-04 22:12:50 +00:00
|
|
|
G_STRUCT_OFFSET (GstElementClass,eos), NULL, NULL,
|
|
|
|
gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_element_set_property);
|
|
|
|
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_element_get_property);
|
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_element_dispose);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2001-12-04 22:12:50 +00:00
|
|
|
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_element_save_thyself);
|
|
|
|
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_element_restore_thyself);
|
2001-06-24 21:18:28 +00:00
|
|
|
#endif
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state);
|
2001-12-18 19:03:07 +00:00
|
|
|
klass->send_event = GST_DEBUG_FUNCPTR (gst_element_send_event_func);
|
|
|
|
klass->elementfactory = NULL;
|
|
|
|
klass->padtemplates = NULL;
|
|
|
|
klass->numpadtemplates = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-05-26 22:58:15 +00:00
|
|
|
static void
|
|
|
|
gst_element_base_class_init (GstElementClass *klass)
|
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-05-26 22:58:15 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
gobject_class = (GObjectClass*) klass;
|
2001-05-26 22:58:15 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_element_set_property);
|
|
|
|
gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_element_get_property);
|
2001-05-26 22:58:15 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 03:10:44 +00:00
|
|
|
static void
|
|
|
|
gst_element_init (GstElement *element)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-07-17 17:14:15 +00:00
|
|
|
element->current_state = GST_STATE_NULL;
|
2001-12-18 19:03:07 +00:00
|
|
|
element->pending_state = GST_STATE_VOID_PENDING;
|
2000-01-30 09:03:00 +00:00
|
|
|
element->numpads = 0;
|
2000-12-20 09:39:43 +00:00
|
|
|
element->numsrcpads = 0;
|
|
|
|
element->numsinkpads = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
element->pads = NULL;
|
|
|
|
element->loopfunc = NULL;
|
2001-05-25 21:00:07 +00:00
|
|
|
element->sched = NULL;
|
2001-12-22 21:18:17 +00:00
|
|
|
element->sched_private = NULL;
|
2001-12-18 19:03:07 +00:00
|
|
|
element->state_mutex = g_mutex_new ();
|
|
|
|
element->state_cond = g_cond_new ();
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
static void
|
2001-06-25 01:20:11 +00:00
|
|
|
gst_element_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GstElementClass *oclass = (GstElementClass *)G_OBJECT_GET_CLASS(object);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
if (oclass->set_property)
|
|
|
|
(oclass->set_property)(object,prop_id,value,pspec);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2001-06-25 17:22:58 +00:00
|
|
|
gst_element_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GstElementClass *oclass = (GstElementClass *)G_OBJECT_GET_CLASS(object);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
if (oclass->get_property)
|
|
|
|
(oclass->get_property)(object,prop_id,value,pspec);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
/**
|
|
|
|
* gst_element_set_name:
|
|
|
|
* @element: GstElement to set name of
|
|
|
|
* @name: new name of element
|
|
|
|
*
|
|
|
|
* Set the name of the element, getting rid of the old name if there was
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_set_name (GstElement *element, const gchar *name)
|
|
|
|
{
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
|
|
|
gst_object_set_name (GST_OBJECT (element), name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_get_name:
|
|
|
|
* @element: GstElement to get name of
|
|
|
|
*
|
|
|
|
* Get the name of the element.
|
|
|
|
*
|
|
|
|
* Returns: name of the element
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
gst_element_get_name (GstElement *element)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
|
|
|
|
return GST_OBJECT_NAME (element);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_set_parent:
|
|
|
|
* @element: GstElement to set parent of
|
2001-01-31 20:27:00 +00:00
|
|
|
* @parent: new parent of the object
|
2001-01-29 00:06:02 +00:00
|
|
|
*
|
|
|
|
* Set the parent of the element.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_set_parent (GstElement *element, GstObject *parent)
|
|
|
|
{
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (GST_OBJECT_PARENT (element) == NULL);
|
|
|
|
g_return_if_fail (parent != NULL);
|
2001-06-25 01:20:11 +00:00
|
|
|
g_return_if_fail (GST_IS_OBJECT (parent));
|
2001-01-29 00:06:02 +00:00
|
|
|
g_return_if_fail ((gpointer)element != (gpointer)parent);
|
|
|
|
|
|
|
|
gst_object_set_parent (GST_OBJECT (element), parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_get_parent:
|
|
|
|
* @element: GstElement to get the parent of
|
|
|
|
*
|
|
|
|
* Get the parent of the element.
|
|
|
|
*
|
|
|
|
* Returns: parent of the element
|
|
|
|
*/
|
|
|
|
GstObject*
|
|
|
|
gst_element_get_parent (GstElement *element)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
|
|
|
|
return GST_OBJECT_PARENT (element);
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_element_add_pad:
|
|
|
|
* @element: element to add pad to
|
|
|
|
* @pad: pad to add
|
|
|
|
*
|
|
|
|
* Add a pad (connection point) to the element, setting the parent of the
|
|
|
|
* pad to the element (and thus adding a reference).
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
|
|
|
gst_element_add_pad (GstElement *element, GstPad *pad)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* first check to make sure the pad's parent is already set */
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_if_fail (GST_PAD_PARENT (pad) == NULL);
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* then check to see if there's already a pad by that name here */
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_if_fail (gst_object_check_uniqueness (element->pads, GST_PAD_NAME(pad)) == TRUE);
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/* set the pad's parent */
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG (GST_CAT_ELEMENT_PADS,"setting parent of pad '%s' to '%s'\n",
|
|
|
|
GST_PAD_NAME (pad), GST_ELEMENT_NAME (element));
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_object_set_parent (GST_OBJECT (pad), GST_OBJECT (element));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* add it to the list */
|
2000-11-11 15:13:50 +00:00
|
|
|
element->pads = g_list_append (element->pads, pad);
|
2000-01-30 09:03:00 +00:00
|
|
|
element->numpads++;
|
2000-12-20 09:39:43 +00:00
|
|
|
if (gst_pad_get_direction (pad) == GST_PAD_SRC)
|
|
|
|
element->numsrcpads++;
|
|
|
|
else
|
|
|
|
element->numsinkpads++;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* emit the NEW_PAD signal */
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_emit (G_OBJECT (element), gst_element_signals[NEW_PAD], 0, pad);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
/**
|
|
|
|
* gst_element_remove_pad:
|
|
|
|
* @element: element to remove pad from
|
|
|
|
* @pad: pad to remove
|
|
|
|
*
|
|
|
|
* Remove a pad (connection point) from the element,
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_remove_pad (GstElement *element, GstPad *pad)
|
|
|
|
{
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
|
|
|
|
g_return_if_fail (GST_PAD_PARENT (pad) == element);
|
|
|
|
|
|
|
|
/* add it to the list */
|
|
|
|
element->pads = g_list_remove (element->pads, pad);
|
|
|
|
element->numpads--;
|
|
|
|
if (gst_pad_get_direction (pad) == GST_PAD_SRC)
|
|
|
|
element->numsrcpads--;
|
|
|
|
else
|
|
|
|
element->numsinkpads--;
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_emit (G_OBJECT (element), gst_element_signals[PAD_REMOVED], 0, pad);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
gst_object_unparent (GST_OBJECT (pad));
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_element_add_ghost_pad:
|
|
|
|
* @element: element to add ghost pad to
|
2001-01-20 02:57:46 +00:00
|
|
|
* @pad: pad from which the new ghost pad will be created
|
|
|
|
* @name: name of the new ghost pad
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
2001-01-20 02:57:46 +00:00
|
|
|
* Create a ghost pad from the given pad, and add it to the list of pads
|
|
|
|
* for this element.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
|
|
|
gst_element_add_ghost_pad (GstElement *element, GstPad *pad, gchar *name)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-01-20 02:57:46 +00:00
|
|
|
GstPad *ghostpad;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* then check to see if there's already a pad by that name here */
|
2001-05-25 21:00:07 +00:00
|
|
|
g_return_if_fail (gst_object_check_uniqueness (element->pads, name) == TRUE);
|
|
|
|
|
|
|
|
GST_DEBUG(GST_CAT_ELEMENT_PADS,"creating new ghost pad called %s, from pad %s:%s\n",
|
|
|
|
name,GST_DEBUG_PAD_NAME(pad));
|
2001-01-20 02:57:46 +00:00
|
|
|
ghostpad = gst_ghost_pad_new (name, pad);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* add it to the list */
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_ELEMENT_PADS,"adding ghost pad %s to element %s\n",
|
|
|
|
name, GST_ELEMENT_NAME (element));
|
2001-01-20 02:57:46 +00:00
|
|
|
element->pads = g_list_append (element->pads, ghostpad);
|
2000-01-30 09:03:00 +00:00
|
|
|
element->numpads++;
|
2001-12-14 22:59:21 +00:00
|
|
|
/* set the parent of the ghostpad */
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_object_set_parent (GST_OBJECT (ghostpad), GST_OBJECT (element));
|
2001-01-20 02:57:46 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_ELEMENT_PADS,"added ghostpad %s:%s\n",GST_DEBUG_PAD_NAME(ghostpad));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-31 22:18:05 +00:00
|
|
|
/* emit the NEW_GHOST_PAD signal */
|
2001-12-04 22:12:50 +00:00
|
|
|
g_signal_emit (G_OBJECT (element), gst_element_signals[NEW_PAD], 0, ghostpad);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-01 17:25:43 +00:00
|
|
|
/**
|
|
|
|
* gst_element_remove_ghost_pad:
|
|
|
|
* @element: element to remove the ghost pad from
|
|
|
|
* @pad: ghost pad to remove
|
|
|
|
*
|
|
|
|
* removes a ghost pad from an element
|
2001-01-20 03:10:44 +00:00
|
|
|
*
|
2001-01-01 17:25:43 +00:00
|
|
|
*/
|
2000-12-31 22:18:05 +00:00
|
|
|
void
|
|
|
|
gst_element_remove_ghost_pad (GstElement *element, GstPad *pad)
|
|
|
|
{
|
|
|
|
g_return_if_fail (element != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (pad != NULL);
|
2001-07-11 12:33:17 +00:00
|
|
|
g_return_if_fail (GST_IS_GHOST_PAD (pad));
|
2000-12-31 22:18:05 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* FIXME this is redundant?
|
|
|
|
* wingo 10-july-2001: I don't think so, you have to actually remove the pad
|
|
|
|
* from the element. gst_pad_remove_ghost_pad just removes the ghostpad from
|
|
|
|
* the real pad's ghost pad list
|
|
|
|
*/
|
2001-07-11 12:33:17 +00:00
|
|
|
gst_pad_remove_ghost_pad (GST_PAD (GST_PAD_REALIZE (pad)), pad);
|
|
|
|
gst_element_remove_pad (element, pad);
|
2000-12-31 22:18:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_pad:
|
|
|
|
* @element: element to find pad of
|
|
|
|
* @name: name of pad to retrieve
|
|
|
|
*
|
|
|
|
* Retrieve a pad from the element by name.
|
|
|
|
*
|
|
|
|
* Returns: requested pad if found, otherwise NULL.
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstPad*
|
2001-01-20 03:10:44 +00:00
|
|
|
gst_element_get_pad (GstElement *element, const gchar *name)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *walk;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
2001-01-03 20:44:28 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* if there aren't any pads, well, we're not likely to find one */
|
2000-01-30 09:03:00 +00:00
|
|
|
if (!element->numpads)
|
|
|
|
return NULL;
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* look through the list, matching by name */
|
2000-01-30 09:03:00 +00:00
|
|
|
walk = element->pads;
|
|
|
|
while (walk) {
|
2001-01-29 00:06:02 +00:00
|
|
|
GstPad *pad = GST_PAD(walk->data);
|
2001-05-25 21:00:07 +00:00
|
|
|
if (!strcmp (GST_PAD_NAME(pad), name)) {
|
|
|
|
GST_INFO(GST_CAT_ELEMENT_PADS,"found pad %s:%s",GST_DEBUG_PAD_NAME(pad));
|
2001-01-29 00:06:02 +00:00
|
|
|
return pad;
|
2001-01-03 20:44:28 +00:00
|
|
|
}
|
2000-11-11 15:13:50 +00:00
|
|
|
walk = g_list_next (walk);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_INFO(GST_CAT_ELEMENT_PADS,"no such pad '%s' in element \"%s\"",name,GST_ELEMENT_NAME(element));
|
2000-01-30 09:03:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_get_pad_list:
|
|
|
|
* @element: element to get pads of
|
|
|
|
*
|
|
|
|
* Retrieve a list of the pads associated with the element.
|
|
|
|
*
|
2000-03-27 19:53:43 +00:00
|
|
|
* Returns: GList of pads
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GList*
|
2001-01-20 03:10:44 +00:00
|
|
|
gst_element_get_pad_list (GstElement *element)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* return the list of pads */
|
2000-01-30 09:03:00 +00:00
|
|
|
return element->pads;
|
|
|
|
}
|
|
|
|
|
2001-07-11 12:33:17 +00:00
|
|
|
/**
|
|
|
|
* gst_element_class_add_padtemplate:
|
|
|
|
* @klass: element class to add padtemplate to
|
|
|
|
* @templ: padtemplate to add
|
|
|
|
*
|
|
|
|
* Add a padtemplate to an element class. This is useful if you have derived a custom
|
|
|
|
* bin and wish to provide an on-request pad at runtime. Plugin writers should use
|
|
|
|
* gst_elementfactory_add_padtemplate instead.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_class_add_padtemplate (GstElementClass *klass, GstPadTemplate *templ)
|
|
|
|
{
|
|
|
|
g_return_if_fail (klass != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
|
|
|
g_return_if_fail (templ != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PADTEMPLATE (templ));
|
|
|
|
|
|
|
|
klass->padtemplates = g_list_append (klass->padtemplates, templ);
|
|
|
|
klass->numpadtemplates++;
|
|
|
|
}
|
|
|
|
|
2000-12-28 00:18:26 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_padtemplate_list:
|
|
|
|
* @element: element to get padtemplates of
|
|
|
|
*
|
|
|
|
* Retrieve a list of the padtemplates associated with the element.
|
|
|
|
*
|
|
|
|
* Returns: GList of padtemplates
|
|
|
|
*/
|
|
|
|
GList*
|
|
|
|
gst_element_get_padtemplate_list (GstElement *element)
|
|
|
|
{
|
|
|
|
GstElementClass *oclass;
|
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
|
2000-12-28 00:18:26 +00:00
|
|
|
|
2001-07-11 12:33:17 +00:00
|
|
|
return oclass->padtemplates;
|
2000-12-28 00:18:26 +00:00
|
|
|
}
|
|
|
|
|
2001-01-18 23:46:15 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_padtemplate_by_name:
|
|
|
|
* @element: element to get padtemplate of
|
|
|
|
* @name: the name of the padtemplate to get.
|
|
|
|
*
|
|
|
|
* Retrieve a padtemplate from this element with the
|
|
|
|
* given name.
|
|
|
|
*
|
|
|
|
* Returns: the padtemplate with the given name
|
|
|
|
*/
|
|
|
|
GstPadTemplate*
|
|
|
|
gst_element_get_padtemplate_by_name (GstElement *element, const guchar *name)
|
|
|
|
{
|
|
|
|
GList *padlist;
|
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
padlist = gst_element_get_padtemplate_list (element);
|
|
|
|
|
|
|
|
while (padlist) {
|
|
|
|
GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data;
|
|
|
|
|
|
|
|
if (!strcmp (padtempl->name_template, name))
|
|
|
|
return padtempl;
|
2001-01-19 22:15:21 +00:00
|
|
|
|
2001-01-18 23:46:15 +00:00
|
|
|
padlist = g_list_next (padlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-01-23 18:42:23 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_padtemplate_by_compatible:
|
|
|
|
* @element: element to get padtemplate of
|
|
|
|
* @templ: a template to find a compatible template for
|
|
|
|
*
|
|
|
|
* Generate a padtemplate for this element compatible with the given
|
|
|
|
* template, ie able to link to it.
|
|
|
|
*
|
|
|
|
* Returns: the padtemplate
|
|
|
|
*/
|
|
|
|
static GstPadTemplate*
|
|
|
|
gst_element_get_padtemplate_by_compatible (GstElement *element, GstPadTemplate *compattempl)
|
|
|
|
{
|
|
|
|
GstPadTemplate *newtempl = NULL;
|
|
|
|
GList *padlist;
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_ELEMENT_PADS,"gst_element_get_padtemplate_by_compatible()\n");
|
2001-01-23 18:42:23 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
g_return_val_if_fail (compattempl != NULL, NULL);
|
|
|
|
|
|
|
|
padlist = gst_element_get_padtemplate_list (element);
|
|
|
|
|
|
|
|
while (padlist) {
|
|
|
|
GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data;
|
|
|
|
gboolean compat = FALSE;
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* Ignore name
|
|
|
|
* Ignore presence
|
|
|
|
* Check direction (must be opposite)
|
|
|
|
* Check caps
|
|
|
|
*/
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_CAPS,"checking direction and caps\n");
|
2001-01-23 18:42:23 +00:00
|
|
|
if (padtempl->direction == GST_PAD_SRC &&
|
|
|
|
compattempl->direction == GST_PAD_SINK) {
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_CAPS,"compatible direction: found src pad template\n");
|
2001-03-12 21:02:12 +00:00
|
|
|
compat = gst_caps_check_compatibility(GST_PADTEMPLATE_CAPS (padtempl),
|
|
|
|
GST_PADTEMPLATE_CAPS (compattempl));
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_CAPS,"caps are %scompatible\n", (compat?"":"not "));
|
2001-01-23 18:42:23 +00:00
|
|
|
} else if (padtempl->direction == GST_PAD_SINK &&
|
|
|
|
compattempl->direction == GST_PAD_SRC) {
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_CAPS,"compatible direction: found sink pad template\n");
|
2001-03-12 21:02:12 +00:00
|
|
|
compat = gst_caps_check_compatibility(GST_PADTEMPLATE_CAPS (compattempl),
|
|
|
|
GST_PADTEMPLATE_CAPS (padtempl));
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_DEBUG(GST_CAT_CAPS,"caps are %scompatible\n", (compat?"":"not "));
|
2001-01-23 18:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (compat) {
|
|
|
|
newtempl = padtempl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
padlist = g_list_next (padlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newtempl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstPad*
|
2001-10-17 10:21:27 +00:00
|
|
|
gst_element_request_pad (GstElement *element, GstPadTemplate *templ, const gchar* name)
|
2001-01-18 23:46:15 +00:00
|
|
|
{
|
|
|
|
GstPad *newpad = NULL;
|
|
|
|
GstElementClass *oclass;
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
|
2001-01-18 23:46:15 +00:00
|
|
|
if (oclass->request_new_pad)
|
2001-10-17 10:21:27 +00:00
|
|
|
newpad = (oclass->request_new_pad)(element, templ, name);
|
2001-01-18 23:46:15 +00:00
|
|
|
|
2001-01-19 22:15:21 +00:00
|
|
|
return newpad;
|
2001-01-18 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
2001-01-23 18:42:23 +00:00
|
|
|
/**
|
|
|
|
* gst_element_request_compatible_pad:
|
|
|
|
* @element: element to request a new pad from
|
|
|
|
* @templ: a pad template to which the new pad should be able to connect
|
|
|
|
*
|
|
|
|
* Request a new pad from the element. The template will
|
|
|
|
* be used to decide what type of pad to create. This function
|
|
|
|
* is typically used for elements with a padtemplate with presence
|
|
|
|
* GST_PAD_REQUEST.
|
|
|
|
*
|
|
|
|
* Returns: the new pad that was created.
|
|
|
|
*/
|
|
|
|
GstPad*
|
|
|
|
gst_element_request_compatible_pad (GstElement *element, GstPadTemplate *templ)
|
|
|
|
{
|
|
|
|
GstPadTemplate *templ_new;
|
|
|
|
GstPad *pad = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
g_return_val_if_fail (templ != NULL, NULL);
|
|
|
|
|
|
|
|
templ_new = gst_element_get_padtemplate_by_compatible (element, templ);
|
2001-03-07 21:52:56 +00:00
|
|
|
if (templ_new != NULL)
|
2001-10-17 10:21:27 +00:00
|
|
|
pad = gst_element_request_pad (element, templ_new, NULL);
|
2001-01-23 18:42:23 +00:00
|
|
|
|
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
2001-01-19 22:15:21 +00:00
|
|
|
/**
|
|
|
|
* gst_element_request_pad_by_name:
|
|
|
|
* @element: element to request a new pad from
|
|
|
|
* @name: the name of the padtemplate to use.
|
|
|
|
*
|
|
|
|
* Request a new pad from the element. The name argument will
|
|
|
|
* be used to decide what padtemplate to use. This function
|
|
|
|
* is typically used for elements with a padtemplate with presence
|
|
|
|
* GST_PAD_REQUEST.
|
|
|
|
*
|
|
|
|
* Returns: the new pad that was created.
|
|
|
|
*/
|
2001-01-18 23:46:15 +00:00
|
|
|
GstPad*
|
|
|
|
gst_element_request_pad_by_name (GstElement *element, const gchar *name)
|
|
|
|
{
|
2001-10-17 10:21:27 +00:00
|
|
|
GstPadTemplate *templ = NULL;
|
2001-01-18 23:46:15 +00:00
|
|
|
GstPad *pad;
|
2001-10-17 10:21:27 +00:00
|
|
|
const gchar *req_name = NULL;
|
|
|
|
gboolean templ_found = FALSE;
|
|
|
|
GList *list;
|
|
|
|
gint n;
|
2001-01-18 23:46:15 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
if (strstr (name, "%d")) {
|
|
|
|
templ = gst_element_get_padtemplate_by_name (element, name);
|
|
|
|
req_name = NULL;
|
|
|
|
} else {
|
|
|
|
list = gst_element_get_padtemplate_list(element);
|
|
|
|
while (!templ_found && list) {
|
|
|
|
templ = (GstPadTemplate*) list->data;
|
|
|
|
if (strstr (templ->name_template, "%d")) {
|
|
|
|
if (sscanf(name, templ->name_template, &n)) {
|
|
|
|
templ_found = TRUE;
|
|
|
|
req_name = name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-15 19:13:45 +00:00
|
|
|
if (templ == NULL)
|
2001-10-17 10:21:27 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pad = gst_element_request_pad (element, templ, req_name);
|
|
|
|
|
2001-01-18 23:46:15 +00:00
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_element_connect:
|
|
|
|
* @src: element containing source pad
|
|
|
|
* @srcpadname: name of pad in source element
|
|
|
|
* @dest: element containing destination pad
|
|
|
|
* @destpadname: name of pad in destination element
|
|
|
|
*
|
|
|
|
* Connect the two named pads of the source and destination elements.
|
|
|
|
* Side effect is that if one of the pads has no parent, it becomes a
|
|
|
|
* child of the parent of the other element. If they have different
|
|
|
|
* parents, the connection fails.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2001-01-06 02:35:17 +00:00
|
|
|
gst_element_connect (GstElement *src, const gchar *srcpadname,
|
2001-01-20 03:10:44 +00:00
|
|
|
GstElement *dest, const gchar *destpadname)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstPad *srcpad,*destpad;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_if_fail (src != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT(src));
|
|
|
|
g_return_if_fail (srcpadname != NULL);
|
|
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT(dest));
|
|
|
|
g_return_if_fail (destpadname != NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* obtain the pads requested */
|
2000-11-11 15:13:50 +00:00
|
|
|
srcpad = gst_element_get_pad (src, srcpadname);
|
2000-12-29 10:02:17 +00:00
|
|
|
if (srcpad == NULL) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_ERROR(src,"source element has no pad \"%s\"",srcpadname);
|
2000-12-29 10:02:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-12-09 09:13:09 +00:00
|
|
|
destpad = gst_element_get_pad (dest, destpadname);
|
2000-12-29 10:02:17 +00:00
|
|
|
if (srcpad == NULL) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_ERROR(dest,"destination element has no pad \"%s\"",destpadname);
|
2000-12-29 10:02:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* we're satisified they can be connected, let's do it */
|
|
|
|
gst_pad_connect(srcpad,destpad);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* gst_element_disconnect:
|
|
|
|
* @src: element containing source pad
|
|
|
|
* @srcpadname: name of pad in source element
|
|
|
|
* @dest: element containing destination pad
|
|
|
|
* @destpadname: name of pad in destination element
|
|
|
|
*
|
|
|
|
* Disconnect the two named pads of the source and destination elements.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2001-01-06 02:35:17 +00:00
|
|
|
gst_element_disconnect (GstElement *src, const gchar *srcpadname,
|
2001-01-20 03:10:44 +00:00
|
|
|
GstElement *dest, const gchar *destpadname)
|
2001-01-06 02:35:17 +00:00
|
|
|
{
|
|
|
|
GstPad *srcpad,*destpad;
|
|
|
|
|
|
|
|
g_return_if_fail (src != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT(src));
|
|
|
|
g_return_if_fail (srcpadname != NULL);
|
|
|
|
g_return_if_fail (dest != NULL);
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT(dest));
|
|
|
|
g_return_if_fail (destpadname != NULL);
|
|
|
|
|
|
|
|
/* obtain the pads requested */
|
|
|
|
srcpad = gst_element_get_pad (src, srcpadname);
|
|
|
|
if (srcpad == NULL) {
|
|
|
|
GST_ERROR(src,"source element has no pad \"%s\"",srcpadname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
destpad = gst_element_get_pad (dest, destpadname);
|
|
|
|
if (srcpad == NULL) {
|
|
|
|
GST_ERROR(dest,"destination element has no pad \"%s\"",destpadname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we're satisified they can be disconnected, let's do it */
|
|
|
|
gst_pad_disconnect(srcpad,destpad);
|
|
|
|
}
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
static void
|
|
|
|
gst_element_message (GstElement *element, const gchar *type, const gchar *info, va_list var_args)
|
|
|
|
{
|
|
|
|
GstEvent *event;
|
|
|
|
GstProps *props;
|
|
|
|
gchar *string;
|
|
|
|
|
|
|
|
string = g_strdup_vprintf (info, var_args);
|
|
|
|
|
2001-12-25 02:15:46 +00:00
|
|
|
GST_INFO (GST_CAT_EVENT, "%s sends message %s", GST_ELEMENT_NAME (element),
|
|
|
|
string);
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
event = gst_event_new_info (type, GST_PROPS_STRING (string), NULL);
|
|
|
|
gst_element_send_event (element, event);
|
|
|
|
|
|
|
|
g_free (string);
|
|
|
|
}
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
|
|
|
* gst_element_error:
|
|
|
|
* @element: Element with the error
|
2001-12-28 20:20:26 +00:00
|
|
|
* @error: A printf-like string describing the error
|
|
|
|
* @...: optional arguments for the string
|
2000-02-02 06:26:44 +00:00
|
|
|
*
|
|
|
|
* This function is used internally by elements to signal an error
|
|
|
|
* condition. It results in the "error" signal.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2001-12-18 19:03:07 +00:00
|
|
|
gst_element_error (GstElement *element, const gchar *error, ...)
|
|
|
|
{
|
|
|
|
va_list var_args;
|
2001-12-22 21:18:17 +00:00
|
|
|
GstObject *parent;
|
2001-12-18 19:03:07 +00:00
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (error != NULL);
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
va_start (var_args, error);
|
|
|
|
gst_element_message (element, "error", error, var_args);
|
|
|
|
va_end (var_args);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
|
|
|
parent = GST_ELEMENT_PARENT (element);
|
|
|
|
|
|
|
|
if (parent && GST_IS_BIN (parent)) {
|
|
|
|
gst_bin_child_error (GST_BIN (parent), element);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element->sched) {
|
|
|
|
gst_scheduler_error (element->sched, element);
|
|
|
|
}
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_info:
|
|
|
|
* @element: Element with the info
|
|
|
|
* @info: String describing the info
|
2002-01-01 15:58:51 +00:00
|
|
|
* @...: arguments for the string.
|
2001-12-18 19:03:07 +00:00
|
|
|
*
|
|
|
|
* This function is used internally by elements to signal an info
|
|
|
|
* condition. It results in the "info" signal.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_info (GstElement *element, const gchar *info, ...)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-12-18 19:03:07 +00:00
|
|
|
va_list var_args;
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (info != NULL);
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
va_start (var_args, info);
|
|
|
|
gst_element_message (element, "info", info, var_args);
|
|
|
|
va_end (var_args);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
static void
|
|
|
|
gst_element_send_event_func (GstElement *element, GstEvent *event)
|
|
|
|
{
|
|
|
|
if (GST_OBJECT_PARENT (element)) {
|
|
|
|
gst_element_send_event (GST_ELEMENT (GST_OBJECT_PARENT (element)), event);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
default:
|
|
|
|
g_signal_emit (G_OBJECT (element), gst_element_signals[EVENT], 0, event);
|
|
|
|
}
|
|
|
|
gst_event_free (event);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-12-18 19:03:07 +00:00
|
|
|
/**
|
|
|
|
* gst_element_send_event:
|
|
|
|
* @element: Element generating the event
|
|
|
|
* @event: the event to send
|
|
|
|
*
|
|
|
|
* This function is used intenally by elements to send an event to
|
|
|
|
* the app. It will result in an "event" signal.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_element_send_event (GstElement *element, GstEvent *event)
|
|
|
|
{
|
|
|
|
GstElementClass *oclass = (GstElementClass *) G_OBJECT_GET_CLASS (element);
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
g_return_if_fail (event);
|
|
|
|
|
|
|
|
if (GST_EVENT_SRC (event) == NULL)
|
|
|
|
GST_EVENT_SRC (event) = gst_object_ref (GST_OBJECT (element));
|
|
|
|
|
|
|
|
if (oclass->send_event)
|
|
|
|
(oclass->send_event) (element, event);
|
|
|
|
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_state:
|
|
|
|
* @element: element to get state of
|
|
|
|
*
|
|
|
|
* Gets the state of the element.
|
|
|
|
*
|
|
|
|
* Returns: The element state
|
|
|
|
*/
|
2001-10-17 10:21:27 +00:00
|
|
|
GstElementState
|
2001-10-21 18:00:31 +00:00
|
|
|
gst_element_get_state (GstElement *element)
|
2001-10-17 10:21:27 +00:00
|
|
|
{
|
2001-10-21 18:00:31 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_VOID_PENDING);
|
2001-10-17 10:21:27 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
return GST_STATE (element);
|
2001-10-17 10:21:27 +00:00
|
|
|
}
|
|
|
|
|
2001-12-09 13:17:54 +00:00
|
|
|
/**
|
|
|
|
* gst_element_wait_state_change:
|
|
|
|
* @element: element wait for
|
|
|
|
*
|
|
|
|
* Wait and block until the element changed its state.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_element_wait_state_change (GstElement *element)
|
|
|
|
{
|
2001-12-18 19:03:07 +00:00
|
|
|
g_mutex_lock (element->state_mutex);
|
|
|
|
g_cond_wait (element->state_cond, element->state_mutex);
|
|
|
|
g_mutex_unlock (element->state_mutex);
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_element_set_state:
|
|
|
|
* @element: element to change state of
|
|
|
|
* @state: new element state
|
|
|
|
*
|
2000-09-14 20:31:03 +00:00
|
|
|
* Sets the state of the element. This function will only set
|
|
|
|
* the elements pending state.
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* Returns: whether or not the state was successfully set.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
gint
|
|
|
|
gst_element_set_state (GstElement *element, GstElementState state)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementClass *oclass;
|
2000-11-23 08:13:43 +00:00
|
|
|
GstElementState curpending;
|
2000-07-17 17:14:15 +00:00
|
|
|
GstElementStateReturn return_val = GST_STATE_SUCCESS;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* g_print("gst_element_set_state(\"%s\",%08lx)\n", */
|
|
|
|
/* element->name,state); */
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES,element, "setting state from %s to %s\n",
|
|
|
|
gst_element_statename(GST_STATE(element)),
|
|
|
|
gst_element_statename(state));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* start with the current state */
|
2000-11-23 08:13:43 +00:00
|
|
|
curpending = GST_STATE(element);
|
2000-11-23 20:39:54 +00:00
|
|
|
|
|
|
|
/* loop until the final requested state is set */
|
2001-12-04 22:12:50 +00:00
|
|
|
while (GST_STATE(element) != state && GST_STATE (element) != GST_STATE_VOID_PENDING) {
|
2000-11-23 20:39:54 +00:00
|
|
|
/* move the curpending state in the correct direction */
|
2001-01-15 19:25:26 +00:00
|
|
|
if (curpending < state) curpending<<=1;
|
|
|
|
else curpending>>=1;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* set the pending state variable */
|
2001-12-14 22:59:21 +00:00
|
|
|
/* FIXME: should probably check to see that we don't already have one */
|
2000-11-23 08:13:43 +00:00
|
|
|
GST_STATE_PENDING (element) = curpending;
|
2001-05-25 21:00:07 +00:00
|
|
|
if (curpending != state)
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"intermediate: setting state to %s\n",
|
|
|
|
gst_element_statename(curpending));
|
2000-11-23 08:13:43 +00:00
|
|
|
|
2000-11-23 20:39:54 +00:00
|
|
|
/* call the state change function so it can set the state */
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
|
2000-11-23 08:13:43 +00:00
|
|
|
if (oclass->change_state)
|
|
|
|
return_val = (oclass->change_state)(element);
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
switch (return_val) {
|
|
|
|
case GST_STATE_FAILURE:
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"have failed change_state return\n");
|
|
|
|
return return_val;
|
|
|
|
case GST_STATE_ASYNC:
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES,element,"element will change state async\n");
|
|
|
|
return return_val;
|
|
|
|
default:
|
|
|
|
/* Last thing we do is verify that a successful state change really
|
|
|
|
* did change the state... */
|
|
|
|
if (GST_STATE(element) != curpending) {
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_STATES, element, "element claimed state-change success, but state didn't change\n");
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
}
|
|
|
|
break;
|
2000-12-28 22:12:02 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
2001-08-06 20:37:21 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return return_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
|
|
|
gst_element_change_state (GstElement *element)
|
|
|
|
{
|
|
|
|
GstElementState old_state;
|
2001-12-22 21:18:17 +00:00
|
|
|
GstObject *parent;
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
|
|
|
|
|
|
|
|
old_state = GST_STATE (element);
|
|
|
|
|
|
|
|
if (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING || old_state == GST_STATE_PENDING (element)) {
|
2001-12-22 21:18:17 +00:00
|
|
|
GST_INFO (GST_CAT_STATES, "no state change needed for element %s (VOID_PENDING)", GST_ELEMENT_NAME (element));
|
2001-12-04 22:12:50 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_STATES, "%s default handler sets state from %s to %s %d", GST_ELEMENT_NAME (element),
|
|
|
|
gst_element_statename (old_state),
|
|
|
|
gst_element_statename (GST_STATE_PENDING (element)),
|
|
|
|
GST_STATE_TRANSITION (element));
|
|
|
|
|
2001-12-20 20:03:10 +00:00
|
|
|
/* tell the scheduler if we have one */
|
2001-12-22 21:18:17 +00:00
|
|
|
if (element->sched) {
|
|
|
|
if (gst_scheduler_state_transition (element->sched, element, GST_STATE_TRANSITION (element))
|
|
|
|
!= GST_STATE_SUCCESS) {
|
|
|
|
return GST_STATE_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
GST_STATE (element) = GST_STATE_PENDING (element);
|
|
|
|
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
parent = GST_ELEMENT_PARENT (element);
|
|
|
|
|
|
|
|
if (parent && GST_IS_BIN (parent)) {
|
|
|
|
gst_bin_child_state_change (GST_BIN (parent), old_state, GST_STATE (element), element);
|
2001-12-18 19:03:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2001-12-25 02:15:46 +00:00
|
|
|
g_mutex_lock (element->state_mutex);
|
|
|
|
g_cond_signal (element->state_cond);
|
|
|
|
g_mutex_unlock (element->state_mutex);
|
|
|
|
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return GST_STATE_SUCCESS;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
|
|
|
* gst_element_get_factory:
|
|
|
|
* @element: element to request the factory
|
|
|
|
*
|
|
|
|
* Retrieves the factory that was used to create this element
|
|
|
|
*
|
|
|
|
* Returns: the factory used for creating this element
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstElementFactory*
|
2001-01-20 03:10:44 +00:00
|
|
|
gst_element_get_factory (GstElement *element)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-08-21 21:20:38 +00:00
|
|
|
GstElementClass *oclass;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
2001-01-20 03:10:44 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
|
2000-08-21 21:20:38 +00:00
|
|
|
|
|
|
|
return oclass->elementfactory;
|
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
static void
|
2001-09-28 19:16:02 +00:00
|
|
|
gst_element_dispose (GObject *object)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
GstElement *element = GST_ELEMENT (object);
|
2001-12-15 22:37:35 +00:00
|
|
|
GList *pads, *test;
|
2001-09-28 19:16:02 +00:00
|
|
|
GstPad *pad;
|
2001-12-15 22:37:35 +00:00
|
|
|
gint i;
|
2001-09-28 19:16:02 +00:00
|
|
|
|
|
|
|
GST_DEBUG_ELEMENT (GST_CAT_REFCOUNTING, element, "dispose\n");
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-15 22:37:35 +00:00
|
|
|
/* first we break all our connections with the ouside */
|
2001-05-25 21:00:07 +00:00
|
|
|
if (element->pads) {
|
|
|
|
GList *orig;
|
|
|
|
orig = pads = g_list_copy (element->pads);
|
|
|
|
while (pads) {
|
|
|
|
pad = GST_PAD (pads->data);
|
2001-12-15 22:37:35 +00:00
|
|
|
gst_object_destroy (GST_OBJECT (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
pads = g_list_next (pads);
|
|
|
|
}
|
|
|
|
g_list_free (orig);
|
|
|
|
g_list_free (element->pads);
|
|
|
|
element->pads = NULL;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
element->numsrcpads = 0;
|
|
|
|
element->numsinkpads = 0;
|
2001-12-15 22:37:35 +00:00
|
|
|
element->numpads = 0;
|
2001-12-18 19:03:07 +00:00
|
|
|
g_mutex_free (element->state_mutex);
|
|
|
|
g_cond_free (element->state_cond);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-09-28 19:16:02 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 06:45:56 +00:00
|
|
|
#ifndef GST_DISABLE_LOADSAVE
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_element_save_thyself:
|
|
|
|
* @element: GstElement to save
|
|
|
|
* @parent: the xml parent node
|
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Saves the element as part of the given XML structure
|
2000-03-27 19:53:43 +00:00
|
|
|
*
|
|
|
|
* Returns: the new xml node
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
static xmlNodePtr
|
|
|
|
gst_element_save_thyself (GstObject *object,
|
2001-01-20 03:10:44 +00:00
|
|
|
xmlNodePtr parent)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *pads;
|
|
|
|
GstElementClass *oclass;
|
2001-12-15 01:01:57 +00:00
|
|
|
/* FIXME : this is needed for glib2 */
|
|
|
|
/* GType type; */
|
2001-01-29 00:06:02 +00:00
|
|
|
GstElement *element;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (object), parent);
|
|
|
|
|
|
|
|
element = GST_ELEMENT (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS(element));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
xmlNewChild(parent, NULL, "name", GST_ELEMENT_NAME(element));
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
if (oclass->elementfactory != NULL) {
|
2001-01-29 00:06:02 +00:00
|
|
|
GstElementFactory *factory = (GstElementFactory *)oclass->elementfactory;
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
xmlNewChild (parent, NULL, "type", GST_OBJECT_NAME (factory));
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNewChild (parent, NULL, "version", factory->details->version);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* if (element->manager) */
|
|
|
|
/* xmlNewChild(parent, NULL, "manager", GST_ELEMENT_NAME(element->manager)); */
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* FIXME FIXME FIXME! */
|
|
|
|
/* output all args to the element */
|
2001-12-15 01:01:57 +00:00
|
|
|
/*
|
2001-06-25 01:20:11 +00:00
|
|
|
type = G_OBJECT_TYPE (element);
|
|
|
|
while (type != G_TYPE_INVALID) {
|
2000-01-30 09:03:00 +00:00
|
|
|
GtkArg *args;
|
|
|
|
guint32 *flags;
|
|
|
|
guint num_args,i;
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
args = gtk_object_query_args (type, &flags, &num_args);
|
2001-01-20 03:10:44 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
for (i=0; i<num_args; i++) {
|
2001-06-25 01:20:11 +00:00
|
|
|
if ((args[i].type > G_TYPE_NONE) &&
|
2000-11-11 15:13:50 +00:00
|
|
|
(flags[i] & GTK_ARG_READABLE)) {
|
2000-01-30 09:03:00 +00:00
|
|
|
xmlNodePtr arg;
|
2001-06-25 01:20:11 +00:00
|
|
|
gtk_object_getv (G_OBJECT (element), 1, &args[i]);
|
2001-01-29 00:06:02 +00:00
|
|
|
arg = xmlNewChild (parent, NULL, "arg", NULL);
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "name", args[i].name);
|
2000-01-30 09:03:00 +00:00
|
|
|
switch (args[i].type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_CHAR:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%c", G_VALUE_CHAR (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_UCHAR:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%d", G_VALUE_UCHAR (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-12-15 01:01:57 +00:00
|
|
|
case G_TYPE_BOOLEAN:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
G_VALUE_BOOL (args[i]) ? "true" : "false");
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_INT:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%d", G_VALUE_INT (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_LONG:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%ld", G_VALUE_LONG (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_ULONG:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%lu", G_VALUE_ULONG (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_FLOAT:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%f", G_VALUE_FLOAT (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_DOUBLE:
|
2000-11-11 15:13:50 +00:00
|
|
|
xmlNewChild (arg, NULL, "value",
|
2001-06-25 01:20:11 +00:00
|
|
|
g_strdup_printf ("%g", G_VALUE_DOUBLE (args[i])));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2001-06-25 01:20:11 +00:00
|
|
|
case G_TYPE_STRING:
|
|
|
|
xmlNewChild (arg, NULL, "value", G_VALUE_STRING (args[i]));
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2000-11-11 15:13:50 +00:00
|
|
|
default:
|
|
|
|
if (args[i].type == GST_TYPE_FILENAME) {
|
2001-06-25 01:20:11 +00:00
|
|
|
xmlNewChild (arg, NULL, "value", G_VALUE_STRING (args[i]));
|
2000-11-11 15:13:50 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-11 15:13:50 +00:00
|
|
|
type = gtk_type_parent (type);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-06-25 01:20:11 +00:00
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
pads = GST_ELEMENT_PADS (element);
|
|
|
|
|
2000-12-28 00:18:26 +00:00
|
|
|
while (pads) {
|
2001-01-29 00:06:02 +00:00
|
|
|
GstPad *pad = GST_PAD (pads->data);
|
2001-12-14 22:59:21 +00:00
|
|
|
/* figure out if it's a direct pad or a ghostpad */
|
2001-03-07 21:52:56 +00:00
|
|
|
if (GST_ELEMENT (GST_OBJECT_PARENT (pad)) == element) {
|
|
|
|
xmlNodePtr padtag = xmlNewChild (parent, NULL, "pad", NULL);
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_object_save_thyself (GST_OBJECT (pad), padtag);
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
2000-12-28 00:18:26 +00:00
|
|
|
pads = g_list_next (pads);
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
return parent;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-09-27 19:33:10 +00:00
|
|
|
/**
|
2001-05-25 21:00:07 +00:00
|
|
|
* gst_element_restore_thyself:
|
2001-01-29 00:06:02 +00:00
|
|
|
* @self: the xml node
|
2001-01-31 20:27:00 +00:00
|
|
|
* @parent: the parent of this object when it's loaded
|
2000-09-27 19:33:10 +00:00
|
|
|
*
|
2001-01-06 22:05:15 +00:00
|
|
|
* Load the element from the XML description
|
2000-09-27 19:33:10 +00:00
|
|
|
*
|
|
|
|
* Returns: the new element
|
|
|
|
*/
|
2000-11-11 15:13:50 +00:00
|
|
|
GstElement*
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_restore_thyself (xmlNodePtr self, GstObject *parent)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr children = self->xmlChildrenNode;
|
2000-09-27 19:33:10 +00:00
|
|
|
GstElement *element;
|
2001-01-29 00:06:02 +00:00
|
|
|
GstObjectClass *oclass;
|
2000-09-27 19:33:10 +00:00
|
|
|
guchar *name = NULL;
|
|
|
|
guchar *value = NULL;
|
|
|
|
guchar *type = NULL;
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* first get the needed tags to construct the element */
|
2000-09-27 19:33:10 +00:00
|
|
|
while (children) {
|
2000-11-11 15:13:50 +00:00
|
|
|
if (!strcmp (children->name, "name")) {
|
2001-09-13 20:12:17 +00:00
|
|
|
name = xmlNodeGetContent (children);
|
2000-12-29 10:02:17 +00:00
|
|
|
} else if (!strcmp (children->name, "type")) {
|
2001-09-13 20:12:17 +00:00
|
|
|
type = xmlNodeGetContent (children);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
|
|
|
children = children->next;
|
|
|
|
}
|
2000-12-23 03:17:52 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
GST_INFO (GST_CAT_XML,"loading \"%s\" of type \"%s\"", name, type);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
element = gst_elementfactory_make (type, name);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2000-12-23 03:17:52 +00:00
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* ne need to set the parent on this object bacause the pads */
|
|
|
|
/* will go through the hierarchy to connect to thier peers */
|
2001-01-29 00:06:02 +00:00
|
|
|
if (parent)
|
|
|
|
gst_object_set_parent (GST_OBJECT (element), parent);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* we have the element now, set the arguments */
|
2001-01-29 00:06:02 +00:00
|
|
|
children = self->xmlChildrenNode;
|
2000-09-27 19:33:10 +00:00
|
|
|
|
|
|
|
while (children) {
|
2000-12-28 00:18:26 +00:00
|
|
|
if (!strcmp (children->name, "arg")) {
|
2001-01-18 11:16:53 +00:00
|
|
|
xmlNodePtr child = children->xmlChildrenNode;
|
2000-09-27 19:33:10 +00:00
|
|
|
|
|
|
|
while (child) {
|
2000-11-11 15:13:50 +00:00
|
|
|
if (!strcmp (child->name, "name")) {
|
2001-09-13 20:12:17 +00:00
|
|
|
name = xmlNodeGetContent (child);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
2000-11-11 15:13:50 +00:00
|
|
|
else if (!strcmp (child->name, "value")) {
|
2001-09-13 20:12:17 +00:00
|
|
|
value = xmlNodeGetContent (child);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
|
|
|
child = child->next;
|
|
|
|
}
|
2001-07-11 12:33:17 +00:00
|
|
|
gst_util_set_object_arg ((GObject *)G_OBJECT (element), name, value);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
2000-12-28 00:18:26 +00:00
|
|
|
children = children->next;
|
|
|
|
}
|
2001-12-14 22:59:21 +00:00
|
|
|
/* we have the element now, set the pads */
|
2001-01-29 00:06:02 +00:00
|
|
|
children = self->xmlChildrenNode;
|
2000-12-28 00:18:26 +00:00
|
|
|
|
|
|
|
while (children) {
|
|
|
|
if (!strcmp (children->name, "pad")) {
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_pad_load_and_connect (children, GST_OBJECT (element));
|
2000-12-28 00:18:26 +00:00
|
|
|
}
|
2000-09-27 19:33:10 +00:00
|
|
|
children = children->next;
|
|
|
|
}
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_OBJECT_CLASS (G_OBJECT_GET_CLASS(element));
|
2000-09-27 19:33:10 +00:00
|
|
|
if (oclass->restore_thyself)
|
2001-01-29 00:06:02 +00:00
|
|
|
(oclass->restore_thyself) (GST_OBJECT (element), self);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
gst_object_unparent (GST_OBJECT (element));
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
gst_class_signal_emit_by_name (GST_OBJECT (element), "object_loaded", self);
|
|
|
|
|
2000-09-27 19:33:10 +00:00
|
|
|
return element;
|
|
|
|
}
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif /* GST_DISABLE_LOADSAVE */
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2002-01-01 15:58:51 +00:00
|
|
|
/**
|
|
|
|
* gst_element_yield:
|
|
|
|
* @element: Element to yield
|
|
|
|
*
|
|
|
|
* Request a yield operation for the child. The scheduler will typically
|
|
|
|
* give control to another element.
|
|
|
|
*/
|
2001-12-22 23:19:17 +00:00
|
|
|
void
|
|
|
|
gst_element_yield (GstElement *element)
|
|
|
|
{
|
|
|
|
if (GST_ELEMENT_SCHED (element)) {
|
|
|
|
gst_scheduler_yield (GST_ELEMENT_SCHED (element), element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-01 15:58:51 +00:00
|
|
|
/**
|
|
|
|
* gst_element_interrupt:
|
|
|
|
* @element: Element to interrupt
|
|
|
|
*
|
|
|
|
* Request the scheduler of this element to interrupt the execution of
|
|
|
|
* this element and scheduler another one.
|
|
|
|
*
|
|
|
|
* Returns: a boolean indicating that the child should exit its chain/loop/get
|
|
|
|
* function ASAP, depending on the scheduler implementation.
|
|
|
|
*/
|
2001-12-27 00:47:41 +00:00
|
|
|
gboolean
|
2001-12-22 23:19:17 +00:00
|
|
|
gst_element_interrupt (GstElement *element)
|
|
|
|
{
|
|
|
|
if (GST_ELEMENT_SCHED (element)) {
|
2001-12-27 00:47:41 +00:00
|
|
|
return gst_scheduler_interrupt (GST_ELEMENT_SCHED (element), element);
|
2001-12-22 23:19:17 +00:00
|
|
|
}
|
2001-12-27 00:47:41 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
2001-12-22 23:19:17 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
2001-05-25 21:00:07 +00:00
|
|
|
* gst_element_set_sched:
|
2000-02-02 06:26:44 +00:00
|
|
|
* @element: Element to set manager of.
|
2001-12-04 22:12:50 +00:00
|
|
|
* @sched: @GstScheduler to set.
|
2000-02-02 06:26:44 +00:00
|
|
|
*
|
2001-05-25 21:00:07 +00:00
|
|
|
* Sets the scheduler of the element. For internal use only, unless you're
|
2000-02-02 06:26:44 +00:00
|
|
|
* writing a new bin subclass.
|
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_set_sched (GstElement *element,
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler *sched)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-12-28 20:20:26 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
|
|
|
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", sched);
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
element->sched = sched;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
2001-05-25 21:00:07 +00:00
|
|
|
* gst_element_get_sched:
|
2000-02-02 06:26:44 +00:00
|
|
|
* @element: Element to get manager of.
|
|
|
|
*
|
2001-05-25 21:00:07 +00:00
|
|
|
* Returns the scheduler of the element.
|
2000-02-02 06:26:44 +00:00
|
|
|
*
|
2001-05-25 21:00:07 +00:00
|
|
|
* Returns: Element's scheduler
|
2000-02-02 06:26:44 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler*
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_get_sched (GstElement *element)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-12-28 20:20:26 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
return element->sched;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 06:26:44 +00:00
|
|
|
/**
|
|
|
|
* gst_element_set_loop_function:
|
|
|
|
* @element: Element to set loop function of.
|
|
|
|
* @loop: Pointer to loop function.
|
|
|
|
*
|
|
|
|
* This sets the loop function for the element. The function pointed to
|
|
|
|
* can deviate from the GstElementLoopFunction definition in type of
|
|
|
|
* pointer only.
|
2000-11-23 21:49:09 +00:00
|
|
|
*
|
|
|
|
* NOTE: in order for this to take effect, the current loop function *must*
|
|
|
|
* exit. Assuming the loop function itself is the only one who will cause
|
|
|
|
* a new loopfunc to be assigned, this should be no problem.
|
2000-02-02 06:26:44 +00:00
|
|
|
*/
|
2001-01-20 03:10:44 +00:00
|
|
|
void
|
2000-11-11 15:13:50 +00:00
|
|
|
gst_element_set_loop_function(GstElement *element,
|
2001-01-20 03:10:44 +00:00
|
|
|
GstElementLoopFunction loop)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2001-12-28 20:20:26 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2000-11-23 21:49:09 +00:00
|
|
|
/* set the loop function */
|
2000-01-30 09:03:00 +00:00
|
|
|
element->loopfunc = loop;
|
2000-11-23 21:49:09 +00:00
|
|
|
|
|
|
|
/* set the NEW_LOOPFUNC flag so everyone knows to go try again */
|
2001-12-28 20:20:26 +00:00
|
|
|
GST_FLAG_SET (element, GST_ELEMENT_NEW_LOOPFUNC);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2000-12-29 02:28:04 +00:00
|
|
|
|
|
|
|
/**
|
2001-12-28 20:20:26 +00:00
|
|
|
* gst_element_set_eos:
|
|
|
|
* @element: element to set to the EOS state
|
2001-01-20 03:10:44 +00:00
|
|
|
*
|
2001-12-28 20:20:26 +00:00
|
|
|
* Perform the actions needed to bring the element in the EOS state.
|
2000-12-29 02:28:04 +00:00
|
|
|
*/
|
|
|
|
void
|
2001-12-28 20:20:26 +00:00
|
|
|
gst_element_set_eos (GstElement *element)
|
2001-01-13 13:51:08 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2001-12-28 20:20:26 +00:00
|
|
|
GST_DEBUG (GST_CAT_EVENT, "setting EOS on element %s\n", GST_OBJECT_NAME (element));
|
|
|
|
|
|
|
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_emit (G_OBJECT (element), gst_element_signals[EOS], 0);
|
2001-01-13 13:51:08 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_element_statename:
|
|
|
|
* @state: The state to get the name of
|
|
|
|
*
|
|
|
|
* Gets a string representing the given state.
|
|
|
|
*
|
|
|
|
* Returns: a string with the statename.
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
gst_element_statename (GstElementState state)
|
|
|
|
{
|
2001-05-25 21:00:07 +00:00
|
|
|
switch (state) {
|
|
|
|
#ifdef GST_DEBUG_COLOR
|
2001-06-25 01:20:11 +00:00
|
|
|
case GST_STATE_VOID_PENDING: return "NONE_PENDING";break;
|
2001-05-25 21:00:07 +00:00
|
|
|
case GST_STATE_NULL: return "\033[01;37mNULL\033[00m";break;
|
|
|
|
case GST_STATE_READY: return "\033[01;31mREADY\033[00m";break;
|
|
|
|
case GST_STATE_PLAYING: return "\033[01;32mPLAYING\033[00m";break;
|
|
|
|
case GST_STATE_PAUSED: return "\033[01;33mPAUSED\033[00m";break;
|
2001-12-04 22:12:50 +00:00
|
|
|
default: return g_strdup_printf ("\033[01;37;41mUNKNOWN!\033[00m(%d)", state);
|
2001-05-25 21:00:07 +00:00
|
|
|
#else
|
2001-06-25 01:20:11 +00:00
|
|
|
case GST_STATE_VOID_PENDING: return "NONE_PENDING";break;
|
2001-05-25 21:00:07 +00:00
|
|
|
case GST_STATE_NULL: return "NULL";break;
|
|
|
|
case GST_STATE_READY: return "READY";break;
|
|
|
|
case GST_STATE_PLAYING: return "PLAYING";break;
|
|
|
|
case GST_STATE_PAUSED: return "PAUSED";break;
|
|
|
|
default: return "UNKNOWN!";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2001-12-13 23:37:47 +00:00
|
|
|
|
|
|
|
static void
|
2001-12-14 00:02:21 +00:00
|
|
|
gst_element_populate_std_props (GObjectClass * klass,
|
|
|
|
const char *prop_name, guint arg_id, GParamFlags flags)
|
2001-12-13 23:37:47 +00:00
|
|
|
{
|
2001-12-14 00:02:21 +00:00
|
|
|
GQuark prop_id = g_quark_from_string (prop_name);
|
2001-12-14 11:11:54 +00:00
|
|
|
GParamSpec *pspec;
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
static GQuark fd_id = 0;
|
|
|
|
static GQuark blocksize_id;
|
|
|
|
static GQuark bytesperread_id;
|
|
|
|
static GQuark dump_id;
|
|
|
|
static GQuark filesize_id;
|
|
|
|
static GQuark mmapsize_id;
|
|
|
|
static GQuark location_id;
|
|
|
|
static GQuark offset_id;
|
|
|
|
static GQuark silent_id;
|
|
|
|
static GQuark touch_id;
|
|
|
|
|
|
|
|
if (!fd_id) {
|
|
|
|
fd_id = g_quark_from_static_string ("fd");
|
|
|
|
blocksize_id = g_quark_from_static_string ("blocksize");
|
|
|
|
bytesperread_id = g_quark_from_static_string ("bytesperread");
|
|
|
|
dump_id = g_quark_from_static_string ("dump");
|
|
|
|
filesize_id = g_quark_from_static_string ("filesize");
|
|
|
|
mmapsize_id = g_quark_from_static_string ("mmapsize");
|
|
|
|
location_id = g_quark_from_static_string ("location");
|
|
|
|
offset_id = g_quark_from_static_string ("offset");
|
|
|
|
silent_id = g_quark_from_static_string ("silent");
|
|
|
|
touch_id = g_quark_from_static_string ("touch");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prop_id == fd_id) {
|
2001-12-14 11:11:54 +00:00
|
|
|
pspec = g_param_spec_int ("fd", "File-descriptor",
|
2001-12-14 18:11:52 +00:00
|
|
|
"File-descriptor for the file being read",
|
|
|
|
0, G_MAXINT, 0, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
}
|
|
|
|
else if (prop_id == blocksize_id) {
|
|
|
|
pspec = g_param_spec_ulong ("blocksize", "Block Size",
|
2001-12-14 18:11:52 +00:00
|
|
|
"Block size to read per buffer",
|
|
|
|
0, G_MAXULONG, 4096, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == bytesperread_id) {
|
2001-12-14 18:11:52 +00:00
|
|
|
pspec = g_param_spec_int ("bytesperread", "bytesperread",
|
|
|
|
"bytesperread",
|
2001-12-14 00:02:21 +00:00
|
|
|
G_MININT, G_MAXINT, 0, flags);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == dump_id) {
|
|
|
|
pspec = g_param_spec_boolean ("dump", "dump", "dump", FALSE, flags);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == filesize_id) {
|
|
|
|
pspec = g_param_spec_int64 ("filesize", "File Size",
|
2001-12-14 18:11:52 +00:00
|
|
|
"Size of the file being read",
|
|
|
|
0, G_MAXINT64, 0, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == mmapsize_id) {
|
|
|
|
pspec = g_param_spec_ulong ("mmapsize", "mmap() Block Size",
|
|
|
|
"Size in bytes of mmap()d regions",
|
|
|
|
0, G_MAXULONG, 4 * 1048576, flags);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == location_id) {
|
|
|
|
pspec = g_param_spec_string ("location", "File Location",
|
2001-12-14 18:11:52 +00:00
|
|
|
"Location of the file to read",
|
|
|
|
NULL, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == offset_id) {
|
|
|
|
pspec = g_param_spec_int64 ("offset", "File Offset",
|
2001-12-14 18:11:52 +00:00
|
|
|
"Byte offset of current read pointer",
|
|
|
|
0, G_MAXINT64, 0, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == silent_id) {
|
2001-12-14 18:11:52 +00:00
|
|
|
pspec = g_param_spec_boolean ("silent", "silent", "silent",
|
|
|
|
FALSE, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (prop_id == touch_id) {
|
|
|
|
pspec = g_param_spec_boolean ("touch", "Touch read data",
|
2001-12-14 18:11:52 +00:00
|
|
|
"Touch data to force disk read before "
|
|
|
|
"push ()", TRUE, flags);
|
2001-12-14 00:02:21 +00:00
|
|
|
}
|
2001-12-14 11:11:54 +00:00
|
|
|
else {
|
2001-12-14 12:25:12 +00:00
|
|
|
g_warning ("Unknown - 'standard' property '%s' id %d from klass %s",
|
|
|
|
prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass)));
|
2001-12-14 11:11:54 +00:00
|
|
|
pspec = NULL;
|
|
|
|
}
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
if (pspec) {
|
|
|
|
g_object_class_install_property (klass, arg_id, pspec);
|
|
|
|
}
|
2001-12-13 23:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_install_std_props:
|
|
|
|
* @klass: the class to add the properties to
|
|
|
|
* @first_name: the first in a NULL terminated
|
|
|
|
* 'name', 'id', 'flags' triplet list.
|
2002-01-01 15:58:51 +00:00
|
|
|
* @...: the triplet list
|
2001-12-13 23:37:47 +00:00
|
|
|
*
|
|
|
|
* Add a list of standardized properties with types to the @klass.
|
|
|
|
* the id is for the property switch in your get_prop method, and
|
|
|
|
* the flags determine readability / writeability.
|
|
|
|
**/
|
|
|
|
void
|
2001-12-14 00:02:21 +00:00
|
|
|
gst_element_install_std_props (GstElementClass * klass, const char *first_name, ...)
|
2001-12-13 23:37:47 +00:00
|
|
|
{
|
2001-12-14 00:02:21 +00:00
|
|
|
const char *name;
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
va_list args;
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
va_start (args, first_name);
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
name = first_name;
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
while (name) {
|
|
|
|
int arg_id = va_arg (args, int);
|
|
|
|
int flags = va_arg (args, int);
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id, flags);
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
name = va_arg (args, char *);
|
|
|
|
}
|
2001-12-13 23:37:47 +00:00
|
|
|
|
2001-12-14 00:02:21 +00:00
|
|
|
va_end (args);
|
|
|
|
}
|
2001-12-14 18:11:52 +00:00
|
|
|
|