2004-03-13 Thomas Vander Stichele <thomas at apestaart dot org>
+ * *.c, *.h: commit of gst-indent run on core
+
+2004-03-13 Thomas Vander Stichele <thomas at apestaart dot org>
+
* tools/gst-indent:
* tools/Makefile.am:
add our indentation style as a script
/*
* BonoboControl data
*/
-typedef struct {
- BonoboControl *bonobo_object;
- BonoboUIComponent *uic;
+typedef struct
+{
+ BonoboControl *bonobo_object;
+ BonoboUIComponent *uic;
- GstPlay *play;
+ GstPlay *play;
} control_data_t;
/*
* encounters a fatal CORBA exception.
*/
static void
-control_system_exception_cb (BonoboControl *control, CORBA_Object corba_object,
- CORBA_Environment *ev, gpointer data)
+control_system_exception_cb (BonoboControl * control, CORBA_Object corba_object,
+ CORBA_Environment * ev, gpointer data)
{
bonobo_object_unref (BONOBO_OBJECT (control));
}
static void
-control_update (control_data_t *control_data)
+control_update (control_data_t * control_data)
{
gtk_widget_queue_draw (GTK_WIDGET (control_data->play));
}
static void
-verb_Play_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname)
+verb_Play_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname)
{
control_data_t *control_data = (control_data_t *) user_data;
}
static void
-verb_Pause_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname)
+verb_Pause_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname)
{
control_data_t *control_data = (control_data_t *) user_data;
}
static void
-verb_Stop_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname)
+verb_Stop_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname)
{
control_data_t *control_data = (control_data_t *) user_data;
control_update (control_data);
}
-typedef struct {
+typedef struct
+{
control_data_t *control_data;
GtkFileSelection *selector;
} file_select_struct;
-
-static void
-filename_selected (GtkButton *ok, gpointer user_data)
+
+static void
+filename_selected (GtkButton * ok, gpointer user_data)
{
file_select_struct *select = (file_select_struct *) user_data;
gchar *selected_filename;
-
- selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(select->selector));
+
+ selected_filename =
+ gtk_file_selection_get_filename (GTK_FILE_SELECTION (select->selector));
gst_play_set_uri (select->control_data->play, selected_filename);
gst_play_play (select->control_data->play);
control_update (select->control_data);
- g_free(select);
+ g_free (select);
}
static void
-verb_Open_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname)
+verb_Open_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname)
{
control_data_t *control_data = (control_data_t *) user_data;
- file_select_struct *data = g_new0(file_select_struct, 1);
+ file_select_struct *data = g_new0 (file_select_struct, 1);
GtkWidget *file_selector;
- file_selector = gtk_file_selection_new("Select a media file");
-
+ file_selector = gtk_file_selection_new ("Select a media file");
+
data->selector = GTK_FILE_SELECTION (file_selector);
data->control_data = control_data;
-
- gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
- "clicked", GTK_SIGNAL_FUNC (filename_selected), data);
-
- gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
- "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
- (gpointer) file_selector);
-
- gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button),
- "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
- (gpointer) file_selector);
-
+
+ gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
+ ok_button), "clicked", GTK_SIGNAL_FUNC (filename_selected), data);
+
+ gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
+ ok_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ (gpointer) file_selector);
+
+ gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
+ cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ (gpointer) file_selector);
+
gtk_widget_show (file_selector);
}
* in with our container's menus.
*/
static void
-control_create_menus (control_data_t *control_data)
+control_create_menus (control_data_t * control_data)
{
BonoboControl *control = control_data->bonobo_object;
Bonobo_UIContainer remote_uic;
GdkPixbuf *pixbuf;
- static char ui [] =
- "<Root>"
- " <commands>"
- " <cmd name=\"Play\" _label=\"Play\" _tip=\"Play\"/>"
- " <cmd name=\"Pause\" _label=\"Pause\" _tip=\"Pause\"/>"
- " <cmd name=\"Stop\" _label=\"Stop\" _tip=\"Stop\"/>"
- " <cmd name=\"Open\" _label=\"Open Media\" _tip=\"Open a media stream\"/>"
- " </commands>"
- " <menu>"
- " <submenu name=\"Player\" _label=\"_Player\">"
- " <menuitem name=\"Open\" pixtype=\"stock\" pixname=\"Open\" verb=\"\"/>"
- " <separator/>"
- " <menuitem name=\"Play\" verb=\"\"/>"
- " <menuitem name=\"Pause\" verb=\"\"/>"
- " <menuitem name=\"Stop\" verb=\"\"/>"
- " </submenu>"
- " </menu>"
- " <dockitem name=\"GstMediaPlay\">"
- " <toolitem name=\"Play\" type=\"toggle\" verb=\"\"/>"
- " <toolitem name=\"Pause\" type=\"toggle\" verb=\"\"/>"
- " <toolitem name=\"Stop\" type=\"toggle\" verb=\"\"/>"
- " </dockitem>"
- "</Root>";
-
- g_print("create menu\n");
+ static char ui[] =
+ "<Root>"
+ " <commands>"
+ " <cmd name=\"Play\" _label=\"Play\" _tip=\"Play\"/>"
+ " <cmd name=\"Pause\" _label=\"Pause\" _tip=\"Pause\"/>"
+ " <cmd name=\"Stop\" _label=\"Stop\" _tip=\"Stop\"/>"
+ " <cmd name=\"Open\" _label=\"Open Media\" _tip=\"Open a media stream\"/>"
+ " </commands>"
+ " <menu>"
+ " <submenu name=\"Player\" _label=\"_Player\">"
+ " <menuitem name=\"Open\" pixtype=\"stock\" pixname=\"Open\" verb=\"\"/>"
+ " <separator/>"
+ " <menuitem name=\"Play\" verb=\"\"/>"
+ " <menuitem name=\"Pause\" verb=\"\"/>"
+ " <menuitem name=\"Stop\" verb=\"\"/>"
+ " </submenu>"
+ " </menu>"
+ " <dockitem name=\"GstMediaPlay\">"
+ " <toolitem name=\"Play\" type=\"toggle\" verb=\"\"/>"
+ " <toolitem name=\"Pause\" type=\"toggle\" verb=\"\"/>"
+ " <toolitem name=\"Stop\" type=\"toggle\" verb=\"\"/>"
+ " </dockitem>" "</Root>";
+
+ g_print ("create menu\n");
/*
* Get our container's UIContainer server.
*/
node = bonobo_ui_node_from_string (ui);
bonobo_ui_util_translate_ui (node);
bonobo_ui_util_fixup_help (control_data->uic, node,
- DATADIR, "gstmediaplay");
-
+ DATADIR, "gstmediaplay");
+
bonobo_ui_component_set_tree (control_data->uic, "/", node, NULL);
bonobo_ui_node_free (node);
bonobo_ui_util_set_pixbuf (control_data->uic, "/commands/Stop", pixbuf);
gdk_pixbuf_unref (pixbuf);
- g_print("create menu done\n");
+ g_print ("create menu done\n");
}
static void
-control_remove_menus (control_data_t *control_data)
+control_remove_menus (control_data_t * control_data)
{
bonobo_ui_component_unset_container (control_data->uic);
}
* Clean up our supplementary BonoboControl data sturctures.
*/
static void
-control_destroy_cb (BonoboControl *control, gpointer data)
+control_destroy_cb (BonoboControl * control, gpointer data)
{
control_data_t *control_data = (control_data_t *) data;
control_data->play = NULL;
-
- g_free (control_data);
+
+ g_free (control_data);
running_objects--;
if (running_objects > 0)
return;
-
+
/*
* When the last object has gone, unref the factory & quit.
*/
}
static void
-control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
+control_activate_cb (BonoboControl * control, gboolean activate, gpointer data)
{
control_data_t *control_data = (control_data_t *) data;
}
static void
-control_set_frame_cb (BonoboControl *control, gpointer data)
+control_set_frame_cb (BonoboControl * control, gpointer data)
{
control_create_menus ((control_data_t *) data);
}
static BonoboObject *
-bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data)
+bonobo_gstmediaplay_factory (BonoboGenericFactory * this, void *data)
{
- BonoboControl *bonobo_object;
- control_data_t *control_data;
- GtkWidget *vbox;
+ BonoboControl *bonobo_object;
+ control_data_t *control_data;
+ GtkWidget *vbox;
gst_init (NULL, NULL);
/*
vbox = gtk_vbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (control_data->play),
- TRUE, TRUE, 0);
+ TRUE, TRUE, 0);
gtk_widget_show_all (vbox);
gst_play_set_uri (control_data->play, "/opt/data/armageddon1.mpg");
* the "activate" signal.
*/
gtk_signal_connect (GTK_OBJECT (bonobo_object), "activate",
- GTK_SIGNAL_FUNC (control_activate_cb), control_data);
+ GTK_SIGNAL_FUNC (control_activate_cb), control_data);
gtk_signal_connect (GTK_OBJECT (bonobo_object), "set_frame",
- GTK_SIGNAL_FUNC (control_set_frame_cb), control_data);
+ GTK_SIGNAL_FUNC (control_set_frame_cb), control_data);
/*
* The "system_exception" signal is raised when the BonoboControl
* encounters a fatal CORBA exception.
*/
gtk_signal_connect (GTK_OBJECT (bonobo_object), "system_exception",
- GTK_SIGNAL_FUNC (control_system_exception_cb), control_data);
+ GTK_SIGNAL_FUNC (control_system_exception_cb), control_data);
/*
* We'll need to be able to cleanup when this control gets
* destroyed.
*/
gtk_signal_connect (GTK_OBJECT (bonobo_object), "destroy",
- GTK_SIGNAL_FUNC (control_destroy_cb), control_data);
+ GTK_SIGNAL_FUNC (control_destroy_cb), control_data);
bonobo_ui_component_add_verb (control_data->uic, "Play",
- verb_Play_cb, control_data);
+ verb_Play_cb, control_data);
bonobo_ui_component_add_verb (control_data->uic, "Pause",
- verb_Pause_cb, control_data);
+ verb_Pause_cb, control_data);
bonobo_ui_component_add_verb (control_data->uic, "Stop",
- verb_Stop_cb, control_data);
+ verb_Stop_cb, control_data);
bonobo_ui_component_add_verb (control_data->uic, "Open",
- verb_Open_cb, control_data);
+ verb_Open_cb, control_data);
/*
* Count the new running object
*/
running_objects++;
- g_print("running objects: %d\n", running_objects);
+ g_print ("running objects: %d\n", running_objects);
return BONOBO_OBJECT (bonobo_object);
}
static void
init_gstmediaplay_factory (void)
{
- factory = bonobo_generic_factory_new (
- "OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18",
- bonobo_gstmediaplay_factory, NULL);
+ factory =
+ bonobo_generic_factory_new
+ ("OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18",
+ bonobo_gstmediaplay_factory, NULL);
}
static void
CORBA_exception_init (&ev);
- gnome_init_with_popt_table("bonobo-gstmediaplay", VERSION,
- argc, argv,
- oaf_popt_options, 0, NULL);
+ gnome_init_with_popt_table ("bonobo-gstmediaplay", VERSION,
+ argc, argv, oaf_popt_options, 0, NULL);
orb = oaf_init (argc, argv);
if (bonobo_init (orb, NULL, NULL) == FALSE)
CORBA_exception_free (&ev);
}
-
+
int
main (int argc, char **argv)
{
#include <gst/gst.h>
#include <config.h>
-static BonoboObject* gstreamer_factory (BonoboGenericFactory *factory,
- gpointer user_data)
+static BonoboObject *
+gstreamer_factory (BonoboGenericFactory * factory, gpointer user_data)
{
- return BONOBO_OBJECT (bonobo_media_gstreamer_new ());
+ return BONOBO_OBJECT (bonobo_media_gstreamer_new ());
}
-static void init_bonobo (int argc, char **argv)
+static void
+init_bonobo (int argc, char **argv)
{
- CORBA_ORB orb;
+ CORBA_ORB orb;
- gnome_init_with_popt_table ("bonobo-media-gstreamer", VERSION,
- argc, argv,
- oaf_popt_options, 0, NULL);
+ gnome_init_with_popt_table ("bonobo-media-gstreamer", VERSION,
+ argc, argv, oaf_popt_options, 0, NULL);
- orb = oaf_init (argc, argv);
+ orb = oaf_init (argc, argv);
- if (bonobo_init (orb, NULL, NULL) == FALSE)
- g_error ("Could not initialize Bonobo");
+ if (bonobo_init (orb, NULL, NULL) == FALSE)
+ g_error ("Could not initialize Bonobo");
}
-static void last_unref_cb (BonoboObject *bonobo_object,
- BonoboGenericFactory *factory)
+static void
+last_unref_cb (BonoboObject * bonobo_object, BonoboGenericFactory * factory)
{
- bonobo_object_unref (BONOBO_OBJECT (factory));
- gtk_main_quit ();
+ bonobo_object_unref (BONOBO_OBJECT (factory));
+ gtk_main_quit ();
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- BonoboGenericFactory *factory;
+ BonoboGenericFactory *factory;
- gst_init (&argc, &argv);
- init_bonobo (argc, argv);
+ gst_init (&argc, &argv);
+ init_bonobo (argc, argv);
- factory = bonobo_generic_factory_new (
- "OAFIID:Bonobo_Media_GStreamer_Factory",
- gstreamer_factory, NULL);
+ factory = bonobo_generic_factory_new ("OAFIID:Bonobo_Media_GStreamer_Factory",
+ gstreamer_factory, NULL);
- gtk_signal_connect (GTK_OBJECT (bonobo_context_running_get ()), "last_unref",
- GTK_SIGNAL_FUNC (last_unref_cb), factory);
+ gtk_signal_connect (GTK_OBJECT (bonobo_context_running_get ()), "last_unref",
+ GTK_SIGNAL_FUNC (last_unref_cb), factory);
- bonobo_main ();
+ bonobo_main ();
- return 0;
+ return 0;
}
@use_threads:
-<!-- ##### VARIABLE g_log_domain_gstreamer ##### -->
-<para>
-The variable that holds the GStreamer log domain
-</para>
-
-
<!-- ##### MACRO GST_VERSION_MAJOR ##### -->
<para>
The major version of GStreamer at compile time
</para>
+<!-- ##### SIGNAL GstBin::element-added ##### -->
+<para>
+
+</para>
+
+@gstbin: the object which received the signal.
+@arg1: the element that was added to the bin
+
+<!-- ##### SIGNAL GstBin::element-removed ##### -->
+<para>
+
+</para>
+
+@gstbin: the object which received the signal.
+@arg1: the element that was removed from the bin
+
+<!-- ##### SIGNAL GstBin::iterate ##### -->
+<para>
+This signal is emitted when a bin iterates, either automatically or
+due to a #gst_bin_iterate() call. The return value is used to
+determine if the object method handler processed any data.
+In most normal cases, a user-provided signal handler should return
+FALSE.
+</para>
+
+@gstbin: the object which received the signal.
+@Returns: TRUE if the state of the bin was advanced.
+
<!-- ##### USER_FUNCTION GstBinPrePostIterateFunction ##### -->
<para>
The signature of the callback for the post and pre iterate function as set with
@clock:
-<!-- ##### SIGNAL GstBin::element-added ##### -->
-<para>
-
-</para>
-
-@gstbin: the object which received the signal.
-@arg1: the element that was added to the bin
-
-<!-- ##### SIGNAL GstBin::element-removed ##### -->
-<para>
-
-</para>
-
-@gstbin: the object which received the signal.
-@arg1: the element that was removed from the bin
-
-<!-- ##### SIGNAL GstBin::iterate ##### -->
-<para>
-This signal is emitted when a bin iterates, either automatically or
-due to a #gst_bin_iterate() call. The return value is used to
-determine if the object method handler processed any data.
-In most normal cases, a user-provided signal handler should return
-FALSE.
-</para>
-
-@gstbin: the object which received the signal.
-@Returns: TRUE if the state of the bin was advanced.
-
</para>
+<!-- ##### ARG GstClock:event-diff ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG GstClock:max-diff ##### -->
+<para>
+Maximum allowed diff for clock sync requests against the real time.
+</para>
+
+<!-- ##### ARG GstClock:stats ##### -->
+<para>
+Boolean property to activate stat generation on the clock.
+</para>
+
<!-- ##### FUNCTION gst_clock_set_speed ##### -->
<para>
@id:
-<!-- ##### ARG GstClock:event-diff ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG GstClock:max-diff ##### -->
-<para>
-Maximum allowed diff for clock sync requests against the real time.
-</para>
-
-<!-- ##### ARG GstClock:stats ##### -->
-<para>
-Boolean property to activate stat generation on the clock.
-</para>
-
</para>
-<!-- ##### ENUM GstCPUFlags ##### -->
-<para>
-Flags that represent cpu capabilities
-</para>
-
-@GST_CPU_FLAG_MMX: The cpu is mmx enabled
-@GST_CPU_FLAG_SSE: The cpu is sse enabled
-@GST_CPU_FLAG_MMXEXT: The cpu has extended mmx instructions
-@GST_CPU_FLAG_3DNOW: The cpu is 3DNOW enabled
-
<!-- ##### FUNCTION gst_cpu_get_flags ##### -->
<para>
Request a set of bits specifiying the features of the CPU.
</para>
+<!-- ##### SIGNAL GstElement::eos ##### -->
+<para>
+Signal emited when the element goes to PAUSED due to an end-of-stream
+condition.
+</para>
+
+@gstelement: the object which received the signal.
+
+<!-- ##### SIGNAL GstElement::error ##### -->
+<para>
+This signal is emitted when an element has encountered an error that caused
+it to fail performing its function.
+</para>
+
+@gstelement: the object which received the signal.
+@arg1: the original #GstElement that generated the error.
+@arg2: a #GError containing the translated error message.
+@arg3: a debug string providing additional untranslated debug information, or NULL.
+
+<!-- ##### SIGNAL GstElement::found-tag ##### -->
+<para>
+
+</para>
+
+@gstelement: the object which received the signal.
+@arg1:
+@arg2:
+
+<!-- ##### SIGNAL GstElement::new-pad ##### -->
+<para>
+Is triggered whenever a new pad is added to an element.
+</para>
+
+@gstelement: the object which received the signal.
+@arg1: the new pad that was added
+
+<!-- ##### SIGNAL GstElement::pad-removed ##### -->
+<para>
+Is triggered whenever a pad has been removed from the element.
+</para>
+
+@gstelement: the object which received the signal.
+@arg1: The pad that was removed.
+
+<!-- ##### SIGNAL GstElement::state-change ##### -->
+<para>
+Is triggered whenever the state of an element changes.
+</para>
+
+@gstelement: the object which received the signal.
+@arg1: the new state of the object
+@arg2:
+
<!-- ##### MACRO gst_element_get_name ##### -->
<para>
Gets the name of the element.
@...: list of query types.
-<!-- ##### SIGNAL GstElement::eos ##### -->
-<para>
-Signal emited when the element goes to PAUSED due to an end-of-stream
-condition.
-</para>
-
-@gstelement: the object which received the signal.
-
-<!-- ##### SIGNAL GstElement::error ##### -->
-<para>
-This signal is emitted when an element has encountered an error that caused
-it to fail performing its function.
-</para>
-
-@gstelement: the object which received the signal.
-@arg1: the original #GstElement that generated the error.
-@arg2: a #GError containing the translated error message.
-@arg3: a debug string providing additional untranslated debug information, or NULL.
-
-<!-- ##### SIGNAL GstElement::found-tag ##### -->
-<para>
-
-</para>
-
-@gstelement: the object which received the signal.
-@arg1:
-@arg2:
-
-<!-- ##### SIGNAL GstElement::new-pad ##### -->
-<para>
-Is triggered whenever a new pad is added to an element.
-</para>
-
-@gstelement: the object which received the signal.
-@arg1: the new pad that was added
-
-<!-- ##### SIGNAL GstElement::pad-removed ##### -->
-<para>
-Is triggered whenever a pad has been removed from the element.
-</para>
-
-@gstelement: the object which received the signal.
-@arg1: The pad that was removed.
-
-<!-- ##### SIGNAL GstElement::state-change ##### -->
-<para>
-Is triggered whenever the state of an element changes.
-</para>
-
-@gstelement: the object which received the signal.
-@arg1: the new state of the object
-@arg2:
-
#GstPad, #GstElement
</para>
-<!-- ##### ENUM GstFormat ##### -->
-<para>
-Standard predefined formats
-</para>
-
-@GST_FORMAT_UNDEFINED: undefined format
-@GST_FORMAT_DEFAULT: the default format of the pad/element
-@GST_FORMAT_BYTES: bytes
-@GST_FORMAT_TIME: time in nanoseconds
-@GST_FORMAT_BUFFERS: buffers
-@GST_FORMAT_PERCENT: percentage of stream
-
<!-- ##### MACRO GST_FORMAT_PERCENT_MAX ##### -->
<para>
The PERCENT format is between 0 and this value
</para>
+<!-- ##### SIGNAL GstIndex::entry-added ##### -->
+<para>
+Is emited when a new entry is added to the index.
+</para>
+
+@gstindex: the object which received the signal.
+@arg1: The entry added to the index.
+
+<!-- ##### ARG GstIndex:resolver ##### -->
+<para>
+
+</para>
+
<!-- ##### FUNCTION gst_index_new ##### -->
<para>
@id:
-<!-- ##### SIGNAL GstIndex::entry-added ##### -->
-<para>
-Is emited when a new entry is added to the index.
-</para>
-
-@gstindex: the object which received the signal.
-@arg1: The entry added to the index.
-
-<!-- ##### ARG GstIndex:resolver ##### -->
-<para>
-
-</para>
-
#GstAtomic, #GstBuffer, #GstEvent, #GstData
</para>
-<!-- ##### STRUCT GstMemChunk ##### -->
-<para>
-The memchunk structure
-</para>
-
-
<!-- ##### FUNCTION gst_mem_chunk_new ##### -->
<para>
</para>
+<!-- ##### SIGNAL GstObject::deep-notify ##### -->
+<para>
+The deep notify signal is used to be notified of property changes.
+it is typically attached to the toplevel bin to receive notifications
+from all the elements contained in that bin.
+</para>
+
+@gstobject: the object which received the signal.
+@arg1: the object that originated the signal
+@arg2: the property that changed
+
+<!-- ##### SIGNAL GstObject::object-saved ##### -->
+<para>
+Is trigered whenever a new object is saved to XML. You can connect to
+this signal to insert custom XML tags into the core XML.
+</para>
+
+@gstobject: the object which received the signal.
+@arg1: the xmlNodePtr of the parent node
+
+<!-- ##### SIGNAL GstObject::parent-set ##### -->
+<para>
+Is emitted when the parent of an object is set.
+</para>
+
+@gstobject: the object which received the signal.
+@arg1: the new parent
+
+<!-- ##### SIGNAL GstObject::parent-unset ##### -->
+<para>
+Is emitted when the parent of an object is unset.
+</para>
+
+@gstobject: the object which received the signal.
+@arg1: the old parent
+
+<!-- ##### ARG GstObject:name ##### -->
+<para>
+The name of the object
+</para>
+
<!-- ##### MACRO GST_FLAGS ##### -->
<para>
This macro returns the entire set of flags for the object.
@Returns:
-<!-- ##### SIGNAL GstObject::deep-notify ##### -->
-<para>
-The deep notify signal is used to be notified of property changes.
-it is typically attached to the toplevel bin to receive notifications
-from all the elements contained in that bin.
-</para>
-
-@gstobject: the object which received the signal.
-@arg1: the object that originated the signal
-@arg2: the property that changed
-
-<!-- ##### SIGNAL GstObject::object-saved ##### -->
-<para>
-Is trigered whenever a new object is saved to XML. You can connect to
-this signal to insert custom XML tags into the core XML.
-</para>
-
-@gstobject: the object which received the signal.
-@arg1: the xmlNodePtr of the parent node
-
-<!-- ##### SIGNAL GstObject::parent-set ##### -->
-<para>
-Is emitted when the parent of an object is set.
-</para>
-
-@gstobject: the object which received the signal.
-@arg1: the new parent
-
-<!-- ##### SIGNAL GstObject::parent-unset ##### -->
-<para>
-Is emitted when the parent of an object is unset.
-</para>
-
-@gstobject: the object which received the signal.
-@arg1: the old parent
-
-<!-- ##### ARG GstObject:name ##### -->
-<para>
-The name of the object
-</para>
-
</para>
+<!-- ##### ARG GstGhostPad:real-pad ##### -->
+<para>
+
+</para>
+
<!-- ##### FUNCTION gst_ghost_pad_new ##### -->
<para>
</para>
+<!-- ##### SIGNAL GstPadTemplate::pad-created ##### -->
+<para>
+This signal is fired when an element creates a pad from this
+template.
+</para>
+
+@gstpadtemplate: the object which received the signal.
+@arg1: The pad that was created.
+
<!-- ##### ENUM GstPadTemplateFlags ##### -->
<para>
Flags for the padtemplate
@Returns:
-<!-- ##### SIGNAL GstPadTemplate::pad-created ##### -->
-<para>
-This signal is fired when an element creates a pad from this
-template.
-</para>
-
-@gstpadtemplate: the object which received the signal.
-@arg1: The pad that was created.
-
-<!-- ##### FUNCTION gst_plugin_error_quark ##### -->
-<para>
-Get the error quark
-</para>
-
-@Returns: The error quark used in GError messages
-
-
<!-- ##### ENUM GstPluginError ##### -->
<para>
The plugin loading errors
#GstPad, #GstElement
</para>
-<!-- ##### ENUM GstQueryType ##### -->
-<para>
-Standard predefined Query types
-</para>
-
-@GST_QUERY_NONE: invalid query type
-@GST_QUERY_TOTAL: total length of stream
-@GST_QUERY_POSITION: current position in stream
-@GST_QUERY_LATENCY: latency of stream
-@GST_QUERY_JITTER: current jitter of stream
-@GST_QUERY_START: start of configured segment
-@GST_QUERY_SEGMENT_END: end of configured segment
-@GST_QUERY_RATE: current rate of the stream
-
<!-- ##### MACRO GST_QUERY_TYPE_RATE_DEN ##### -->
<para>
Rates are relative to this value
</para>
-@type:
+@Param1:
@Returns:
+<!-- # Unused Parameters # -->
+@type:
<!-- ##### FUNCTION gst_query_type_get_definitions ##### -->
@pool: The pool that is being destroyed
@user_data: user data as set on th bufferpool
+<!-- ##### ENUM GstCPUFlags ##### -->
+<para>
+Flags that represent cpu capabilities
+</para>
+
+@GST_CPU_FLAG_MMX: The cpu is mmx enabled
+@GST_CPU_FLAG_SSE: The cpu is sse enabled
+@GST_CPU_FLAG_MMXEXT: The cpu has extended mmx instructions
+@GST_CPU_FLAG_3DNOW: The cpu is 3DNOW enabled
+
<!-- ##### STRUCT GstCacheAssociation ##### -->
<para>
</para>
+<!-- ##### ENUM GstFormat ##### -->
+<para>
+Standard predefined formats
+</para>
+
+@GST_FORMAT_UNDEFINED: undefined format
+@GST_FORMAT_DEFAULT: the default format of the pad/element
+@GST_FORMAT_BYTES: bytes
+@GST_FORMAT_TIME: time in nanoseconds
+@GST_FORMAT_BUFFERS: buffers
+@GST_FORMAT_PERCENT: percentage of stream
+
<!-- ##### STRUCT GstHttpSrc ##### -->
<para>
</para>
+<!-- ##### STRUCT GstMemChunk ##### -->
+<para>
+The memchunk structure
+</para>
+
+
<!-- ##### STRUCT GstMemChunkElement ##### -->
<para>
An entry in the memchunk area
</para>
+<!-- ##### ENUM GstQueryType ##### -->
+<para>
+Standard predefined Query types
+</para>
+
+@GST_QUERY_NONE: invalid query type
+@GST_QUERY_TOTAL: total length of stream
+@GST_QUERY_POSITION: current position in stream
+@GST_QUERY_LATENCY: latency of stream
+@GST_QUERY_JITTER: current jitter of stream
+@GST_QUERY_START: start of configured segment
+@GST_QUERY_SEGMENT_END: end of configured segment
+@GST_QUERY_RATE: current rate of the stream
+
<!-- ##### STRUCT GstQueue ##### -->
<para>
@global_reg:
@local_reg:
+<!-- ##### ENUM GstRegistryReturn ##### -->
+<para>
+The return value of registry operations
+</para>
+
+@GST_REGISTRY_OK: The registry reported no error.
+@GST_REGISTRY_LOAD_ERROR: There was a load error
+@GST_REGISTRY_SAVE_ERROR: There was an error saving the registry
+@GST_REGISTRY_PLUGIN_LOAD_ERROR: There was an error loading a plugin
+@GST_REGISTRY_PLUGIN_SIGNATURE_ERROR: There was an error saving a plugin
+
<!-- ##### STRUCT GstRegistryWrite ##### -->
<para>
</para>
+<!-- ##### ENUM GstTagMergeMode ##### -->
+<para>
+
+</para>
+
+@GST_TAG_MERGE_UNDEFINED:
+@GST_TAG_MERGE_REPLACE_ALL:
+@GST_TAG_MERGE_REPLACE:
+@GST_TAG_MERGE_APPEND:
+@GST_TAG_MERGE_PREPEND:
+@GST_TAG_MERGE_KEEP:
+@GST_TAG_MERGE_KEEP_ALL:
+@GST_TAG_MERGE_COUNT:
+
<!-- ##### STRUCT GstTee ##### -->
<para>
</para>
+<!-- ##### SIGNAL GstXML::object-loaded ##### -->
+<para>
+
+</para>
+
+@gstxml: the object which received the signal.
+@arg1:
+@arg2:
+
<!-- ##### USER_FUNCTION GstXMLRegistryAddPathList ##### -->
<para>
@llink:
@Returns:
+<!-- ##### VARIABLE g_log_domain_gstreamer ##### -->
+<para>
+The variable that holds the GStreamer log domain
+</para>
+
+
<!-- ##### MACRO g_object_class_find_property ##### -->
<para>
@Returns:
+<!-- ##### FUNCTION gst_plugin_error_quark ##### -->
+<para>
+Get the error quark
+</para>
+
+@Returns: The error quark used in GError messages
+
<!-- ##### FUNCTION gst_plugin_feature_get_type ##### -->
<para>
#GstPlugin, #GstPluginFeature
</para>
-<!-- ##### ENUM GstRegistryReturn ##### -->
-<para>
-The return value of registry operations
-</para>
-
-@GST_REGISTRY_OK: The registry reported no error.
-@GST_REGISTRY_LOAD_ERROR: There was a load error
-@GST_REGISTRY_SAVE_ERROR: There was an error saving the registry
-@GST_REGISTRY_PLUGIN_LOAD_ERROR: There was an error loading a plugin
-@GST_REGISTRY_PLUGIN_SIGNATURE_ERROR: There was an error saving a plugin
-
<!-- ##### ENUM GstRegistryFlags ##### -->
<para>
Flags for the registry
</para>
-<!-- ##### ENUM GstTagMergeMode ##### -->
-<para>
-
-</para>
-
-@GST_TAG_MERGE_UNDEFINED:
-@GST_TAG_MERGE_REPLACE_ALL:
-@GST_TAG_MERGE_REPLACE:
-@GST_TAG_MERGE_APPEND:
-@GST_TAG_MERGE_PREPEND:
-@GST_TAG_MERGE_KEEP:
-@GST_TAG_MERGE_KEEP_ALL:
-@GST_TAG_MERGE_COUNT:
-
<!-- ##### ENUM GstTagFlag ##### -->
<para>
</para>
-<!-- ##### FUNCTION gst_thread_new ##### -->
-<para>
-
-</para>
-
-@name:
-@Returns:
-
-
<!-- ##### SIGNAL GstThread::shutdown ##### -->
<para>
The thread priority
</para>
+<!-- ##### FUNCTION gst_thread_new ##### -->
+<para>
+
+</para>
+
+@name:
+@Returns:
+
+
@Returns:
-<!-- ##### SIGNAL GstXML::object-loaded ##### -->
-<para>
-
-</para>
-
-@:
-@:
-@:
-
-@gstxml: the object which received the signal.
-@arg1:
-@arg2:
-
-<!-- ##### SIGNAL GstXML::object-loaded ##### -->
-<para>
-
-</para>
-
-@gstxml: the object which received the signal.
-@arg1:
-@arg2:
-
static gchar *_subject, *_category;
static gint _testnum = 0;
static gboolean _passed;
-static gint _total_tests = 0,_passed_tests = 0;
+static gint _total_tests = 0, _passed_tests = 0;
static gint _random_size;
-void tabpad(gchar *str,gint width) {
+void
+tabpad (gchar * str, gint width)
+{
int i;
- for (i=0;i<width-strlen(str);i++)
- fprintf(stderr," ");
+
+ for (i = 0; i < width - strlen (str); i++)
+ fprintf (stderr, " ");
}
#define TEST_SUBJECT(subject) fprintf(stderr,"Subject: %s\n",subject),_subject = subject
_total_tests++; \
}G_STMT_END;
-void SETUP_RANDOM_SIZE(void *random,gint size) {
+void
+SETUP_RANDOM_SIZE (void *random, gint size)
+{
int i;
- if (random) g_free(random);
+
+ if (random)
+ g_free (random);
_random_size = size;
- random = g_malloc(_random_size);
- for (i=0;i<_random_size;i++)
- ((unsigned char *)random)[i] = i;
+ random = g_malloc (_random_size);
+ for (i = 0; i < _random_size; i++)
+ ((unsigned char *) random)[i] = i;
}
#define SETUP_RANDOM(random,type) SETUP_RANDOM_SIZE(random,sizeof(type))
-gboolean RANDOM_OK(void *random) {
+gboolean
+RANDOM_OK (void *random)
+{
int i;
- for (i=0;i<_random_size;i++) {
- if (((unsigned char *)random)[i] != i) {
- SETUP_RANDOM_SIZE(random,_random_size);
+
+ for (i = 0; i < _random_size; i++) {
+ if (((unsigned char *) random)[i] != i) {
+ SETUP_RANDOM_SIZE (random, _random_size);
return FALSE;
}
}
return TRUE;
}
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstObject *object;
GstObject *parent;
GstObject *newparent;
GtkObject *gtkobject;
GstObject *curparent;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
- TEST_SUBJECT("GstObject");
+ TEST_SUBJECT ("GstObject");
- TEST_CATEGORY("Creation");
+ TEST_CATEGORY ("Creation");
- TEST("create object");
+ TEST ("create object");
/* setup */
/* action */
- object = gst_object_new();
+ object = gst_object_new ();
/* assertions */
- ASSERT(object != NULL);
- ASSERT(GST_IS_OBJECT(object));
+ ASSERT (object != NULL);
+ ASSERT (GST_IS_OBJECT (object));
/* cleanup */
- g_free(object);
- ENDTEST();
+ g_free (object);
+ ENDTEST ();
/* new category */
- TEST_CATEGORY("Refcounting");
+ TEST_CATEGORY ("Refcounting");
/* category setup */
- object = gst_object_new();
+ object = gst_object_new ();
- TEST("new object");
+ TEST ("new object");
/* setup */
/* action */
/* assertions */
- ASSERT(object->refcount == 1);
- ASSERT(GTK_OBJECT_FLOATING(object) == TRUE);
+ ASSERT (object->refcount == 1);
+ ASSERT (GTK_OBJECT_FLOATING (object) == TRUE);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("increment refcount");
+ TEST ("increment refcount");
/* setup */
/* action */
- gst_object_ref(object);
+ gst_object_ref (object);
/* assertions */
- ASSERT(object->refcount == 2);
- ASSERT(GTK_OBJECT_FLOATING(object) == TRUE);
+ ASSERT (object->refcount == 2);
+ ASSERT (GTK_OBJECT_FLOATING (object) == TRUE);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("sink object");
+ TEST ("sink object");
/* setup */
/* action */
- gst_object_sink(object);
+ gst_object_sink (object);
/* assertions */
- ASSERT(object->refcount == 1);
- ASSERT(GTK_OBJECT_FLOATING(object) == FALSE);
+ ASSERT (object->refcount == 1);
+ ASSERT (GTK_OBJECT_FLOATING (object) == FALSE);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("increment refcount after sink");
+ TEST ("increment refcount after sink");
/* setup */
/* action */
- gst_object_ref(object);
+ gst_object_ref (object);
/* assertions */
- ASSERT(object->refcount == 2);
- ASSERT(GTK_OBJECT_FLOATING(object) == FALSE);
+ ASSERT (object->refcount == 2);
+ ASSERT (GTK_OBJECT_FLOATING (object) == FALSE);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("decrement refcount after sink");
+ TEST ("decrement refcount after sink");
/* setup */
/* action */
- gst_object_unref(object);
+ gst_object_unref (object);
/* assertions */
- ASSERT(object->refcount == 1);
- ASSERT(GTK_OBJECT_FLOATING(object) == FALSE);
+ ASSERT (object->refcount == 1);
+ ASSERT (GTK_OBJECT_FLOATING (object) == FALSE);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
/* category cleanup */
- g_free(object);
+ g_free (object);
/* new category */
- TEST_CATEGORY("Parentage");
+ TEST_CATEGORY ("Parentage");
/* category setup */
- object = gst_object_new();
- parent = gst_object_new();
- newparent = gst_object_new();
- gtkobject = gtk_type_new(gtk_object_get_type());
+ object = gst_object_new ();
+ parent = gst_object_new ();
+ newparent = gst_object_new ();
+ gtkobject = gtk_type_new (gtk_object_get_type ());
/* category assertions */
- ASSERT(object != NULL);
- ASSERT(object->refcount == 1);
- ASSERT(object->parent == NULL);
- ASSERT(parent != NULL);
- ASSERT(newparent != NULL);
- ASSERT(gtkobject != NULL);
- ASSERT(!GST_IS_OBJECT(gtkobject));
-
- TEST("gst_object_set_parent: null object");
+ ASSERT (object != NULL);
+ ASSERT (object->refcount == 1);
+ ASSERT (object->parent == NULL);
+ ASSERT (parent != NULL);
+ ASSERT (newparent != NULL);
+ ASSERT (gtkobject != NULL);
+ ASSERT (!GST_IS_OBJECT (gtkobject));
+
+ TEST ("gst_object_set_parent: null object");
/* setup */
/* action */
- gst_object_set_parent(NULL,NULL);
+ gst_object_set_parent (NULL, NULL);
/* assertions */
- ASSERT(object->parent == NULL);
+ ASSERT (object->parent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: invalid object");
+ TEST ("gst_object_set_parent: invalid object");
/* setup */
/* action */
- gst_object_set_parent((GstObject*)gtkobject,NULL);
+ gst_object_set_parent ((GstObject *) gtkobject, NULL);
/* assertions */
- ASSERT(object->parent == NULL);
+ ASSERT (object->parent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: null parent");
+ TEST ("gst_object_set_parent: null parent");
/* setup */
/* action */
- gst_object_set_parent(object,NULL);
+ gst_object_set_parent (object, NULL);
/* assertions */
- ASSERT(object->parent == NULL);
+ ASSERT (object->parent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: invalid parent");
+ TEST ("gst_object_set_parent: invalid parent");
/* setup */
/* action */
- gst_object_set_parent(object,(GstObject*)gtkobject);
+ gst_object_set_parent (object, (GstObject *) gtkobject);
/* assertions */
- ASSERT(object->parent == NULL);
+ ASSERT (object->parent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: valid object, parent is object");
+ TEST ("gst_object_set_parent: valid object, parent is object");
/* setup */
/* action */
- gst_object_set_parent(object,object);
+ gst_object_set_parent (object, object);
/* assertions */
- ASSERT(object->parent == NULL);
+ ASSERT (object->parent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: valid object and parent");
+ TEST ("gst_object_set_parent: valid object and parent");
/* setup */
/* action */
- gst_object_set_parent(object,parent);
+ gst_object_set_parent (object, parent);
/* assertions */
- ASSERT(object->parent == parent);
+ ASSERT (object->parent == parent);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_set_parent: parent already set");
+ TEST ("gst_object_set_parent: parent already set");
/* setup */
/* action */
- gst_object_set_parent(object,newparent);
+ gst_object_set_parent (object, newparent);
/* assertions */
- ASSERT(object->parent != newparent);
- ASSERT(object->parent == parent);
+ ASSERT (object->parent != newparent);
+ ASSERT (object->parent == parent);
/* cleanup */
- g_free(object);
- ENDTEST();
+ g_free (object);
+ ENDTEST ();
- TEST("gst_object_get_parent: null object");
+ TEST ("gst_object_get_parent: null object");
/* setup */
/* action */
- curparent = gst_object_get_parent(NULL);
+ curparent = gst_object_get_parent (NULL);
/* assertions */
- ASSERT(curparent == NULL);
+ ASSERT (curparent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_get_parent: invalid object");
+ TEST ("gst_object_get_parent: invalid object");
/* setup */
/* action */
- curparent = gst_object_get_parent((GstObject*)gtkobject);
+ curparent = gst_object_get_parent ((GstObject *) gtkobject);
/* assertions */
- ASSERT(curparent == NULL);
+ ASSERT (curparent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_get_parent: no parent");
+ TEST ("gst_object_get_parent: no parent");
/* setup */
- object = gst_object_new();
+ object = gst_object_new ();
/* action */
- curparent = gst_object_get_parent(object);
+ curparent = gst_object_get_parent (object);
/* assertions */
- ASSERT(curparent == NULL);
+ ASSERT (curparent == NULL);
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_get_parent: valid parent");
+ TEST ("gst_object_get_parent: valid parent");
/* setup */
- gst_object_set_parent(object,parent);
+ gst_object_set_parent (object, parent);
/* action */
- curparent = gst_object_get_parent(object);
+ curparent = gst_object_get_parent (object);
/* assertions */
- ASSERT(curparent == parent);
+ ASSERT (curparent == parent);
/* cleanup */
- g_free(object);
- ENDTEST();
+ g_free (object);
+ ENDTEST ();
- TEST("gst_object_unparent: null object");
+ TEST ("gst_object_unparent: null object");
/* setup */
/* action */
- gst_object_unparent(NULL);
+ gst_object_unparent (NULL);
/* assertions */
/* NONE - FIXME! */
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_unparent: invalid object");
+ TEST ("gst_object_unparent: invalid object");
/* setup */
/* action */
- gst_object_unparent((GstObject*)gtkobject);
+ gst_object_unparent ((GstObject *) gtkobject);
/* assertions */
/* NONE - FIXME! */
/* cleanup */
- ENDTEST();
+ ENDTEST ();
- TEST("gst_object_unparent: no parent");
+ TEST ("gst_object_unparent: no parent");
/* setup */
- object = gst_object_new();
-
+ object = gst_object_new ();
+
/* category cleanup */
- g_free(object);
- g_free(parent);
- g_free(newparent);
- g_free(gtkobject);
+ g_free (object);
+ g_free (parent);
+ g_free (newparent);
+ g_free (gtkobject);
- fprintf(stderr,"\n\nTotal tests:\t%d\n",_total_tests);
- fprintf(stderr,"Total passed:\t%d\n",_passed_tests);
- fprintf(stderr,"Total FAILED:\t%d\n",_total_tests-_passed_tests);
+ fprintf (stderr, "\n\nTotal tests:\t%d\n", _total_tests);
+ fprintf (stderr, "Total passed:\t%d\n", _passed_tests);
+ fprintf (stderr, "Total FAILED:\t%d\n", _total_tests - _passed_tests);
}
#include <gst/gst.h>
static void
-fill_queue (GstElement *queue, gint level, GstBin *pipeline)
+fill_queue (GstElement * queue, gint level, GstBin * pipeline)
{
/* this needs to iterate till something is pushed
* in the queue */
gst_bin_iterate (pipeline);
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *queue, *src, *pipeline;
GstBuffer *buffer;
gboolean done = FALSE;
GstPad *pad;
-
+
gst_init (&argc, &argv);
queue = gst_element_factory_make ("queue", "queue");
gst_element_link_many (src, queue, NULL);
pad = gst_element_get_pad (queue, "src");
- g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline);
+ g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue),
+ pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- do {
+ do {
/* get buffer into the app */
buffer = GST_RPAD_GETFUNC (pad) (pad);
/* just exit on any event */
if (GST_IS_EVENT (buffer)) {
done = TRUE;
- }
- else {
+ } else {
gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
}
gst_data_unref (GST_DATA (buffer));
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
-
+
return 0;
}
#define DEBUG
-gboolean playing = TRUE;
-gboolean cut_start_signalled = FALSE;
-gboolean cut_stop_signalled = FALSE;
-
-int id = 0; /* increment this for each new cut */
-GstElement *main_bin;
-GstElement *audiosrc;
-GstElement *queue;
-GstElement *thread;
-GstElement *cutter;
-GstElement *disksink;
-GstElement *encoder;
-char buffer[255];
+gboolean playing = TRUE;
+gboolean cut_start_signalled = FALSE;
+gboolean cut_stop_signalled = FALSE;
+
+int id = 0; /* increment this for each new cut */
+GstElement *main_bin;
+GstElement *audiosrc;
+GstElement *queue;
+GstElement *thread;
+GstElement *cutter;
+GstElement *disksink;
+GstElement *encoder;
+char buffer[255];
/* signal callbacks */
-void cut_start (GstElement *element)
+void
+cut_start (GstElement * element)
{
g_print ("\nDEBUG: main: cut start\n");
/* we should pause the pipeline, unlink cutter and disksink
{
time_t seconds;
struct tm *ct;
+
time (&seconds);
ct = localtime (&seconds);
/* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */
- sprintf (buffer, "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav",
- ct->tm_year + 1900, ct->tm_mon, ct->tm_mday,
- ct->tm_hour, ct->tm_min, ct->tm_sec);
+ sprintf (buffer,
+ "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav",
+ ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min,
+ ct->tm_sec);
}
g_print ("DEBUG: cut_start: setting new location to %s\n", buffer);
g_object_set (G_OBJECT (disksink), "location", buffer, NULL);
return;
}
-void cut_start_signal (GstElement *element)
+void
+cut_start_signal (GstElement * element)
{
g_print ("\nDEBUG: main: cut start signal\n");
cut_start_signalled = TRUE;
}
-void cut_stop (GstElement *element)
+void
+cut_stop (GstElement * element)
{
g_print ("\nDEBUG: main: cut stop\n");
/* we should pause the pipeline, unlink disksink, create a fake disksink,
return;
}
-void cut_stop_signal (GstElement *element)
+void
+cut_stop_signal (GstElement * element)
{
g_print ("\nDEBUG: main: cut stop signal\n");
cut_stop_signalled = TRUE;
}
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
/*int i, j; */
/*gboolean done; */
-
+
/*char buffer[20]; */
-
+
/*output_channel_t *channel_out; */
-
+
GstElement *audiosrc;
- gst_init (&argc,&argv);
+ gst_init (&argc, &argv);
/*
if (argc == 1)
{
g_print("usage: %s <filename1> <filename2> <...>\n", argv[0]);
exit(-1);
}*/
-
+
/* set up input channel and main bin */
- g_print ("creating main bin\n");
+ g_print ("creating main bin\n");
/* create cutter */
cutter = gst_element_factory_make ("cutter", "cutter");
- g_object_set (G_OBJECT (cutter),
- "threshold_dB", -40.0,
- "runlength", 0.5,
- "prelength", 1.0,
- NULL);
+ g_object_set (G_OBJECT (cutter),
+ "threshold_dB", -40.0, "runlength", 0.5, "prelength", 1.0, NULL);
/* create an audio src */
if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src")))
/* set params */
- g_object_set (G_OBJECT (audiosrc), "frequency", 44100,
- "channels", 1,
- "format", 16, NULL);
+ g_object_set (G_OBJECT (audiosrc), "frequency", 44100,
+ "channels", 1, "format", 16, NULL);
if (!(encoder = gst_element_factory_make ("passthrough", "encoder")))
g_error ("Could not create 'passthrough' element !\n");
-
+
if (!(disksink = gst_element_factory_make ("afsink", "disk_sink")))
g_error ("Could not create 'afsink' element !\n");
-
+
g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL);
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
-
+
/* create main bin */
main_bin = gst_pipeline_new ("bin");
g_assert (main_bin != NULL);
/* set signal handlers */
g_print ("setting signal handlers\n");
- g_signal_connect (G_OBJECT(cutter), "cut_start",
- (GCallback)cut_start_signal, NULL);
- g_signal_connect (G_OBJECT(cutter), "cut_stop",
- (GCallback)cut_stop_signal, NULL);
+ g_signal_connect (G_OBJECT (cutter), "cut_start",
+ (GCallback) cut_start_signal, NULL);
+ g_signal_connect (G_OBJECT (cutter), "cut_stop",
+ (GCallback) cut_stop_signal, NULL);
/* start playing */
g_print ("setting to play\n");
g_print ("setting thread to play\n");
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
*/
- while (playing)
- {
+ while (playing) {
/* g_print ("> "); */
- gst_bin_iterate (GST_BIN (main_bin));
+ gst_bin_iterate (GST_BIN (main_bin));
/* g_print (" <"); */
- if (cut_start_signalled)
- {
- g_print ("\nDEBUG: main: cut_start_signalled true !\n");
- cut_start (cutter);
- cut_start_signalled = FALSE;
- }
- if (cut_stop_signalled)
- {
- g_print ("\nDEBUG: main: cut_stop_signalled true !\n");
- cut_stop (cutter);
- cut_stop_signalled = FALSE;
- }
+ if (cut_start_signalled) {
+ g_print ("\nDEBUG: main: cut_start_signalled true !\n");
+ cut_start (cutter);
+ cut_start_signalled = FALSE;
+ }
+ if (cut_stop_signalled) {
+ g_print ("\nDEBUG: main: cut_stop_signalled true !\n");
+ cut_stop (cutter);
+ cut_stop_signalled = FALSE;
+ }
}
g_print ("we're done iterating.\n");
/* stop the bin */
gst_object_unref (GST_OBJECT (disksink));
gst_object_unref (GST_OBJECT (main_bin));
- exit(0);
+ exit (0);
}
* thomas@apestaart.org
*/
-typedef struct
+typedef struct
{
GstElement *pipe;
GstElement *disksink;
GstElement *audiosink;
-
+
char *location;
int channel_id;
} output_channel_t;
#include <stdlib.h>
#include <gst/gst.h>
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *osssink;
/* link the elements */
gst_element_link_many (filesrc, decoder, osssink, NULL);
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
exit (0);
}
-
#include <gst/gst.h>
static void
-gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline)
+gst_play_have_type (GstElement * typefind, GstCaps * caps,
+ GstElement * pipeline)
{
GstElement *osssink;
GstElement *new_element;
/* unlink_pads the typefind from the pipeline and remove it */
gst_element_unlink_pads (cache, "src", typefind, "sink");
gst_bin_remove (GST_BIN (autobin), typefind);
-
+
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
autoplug = gst_autoplug_factory_make ("staticrender");
g_assert (autoplug != NULL);
- new_element = gst_autoplug_to_renderers (autoplug,
- caps,
- osssink,
- NULL);
+ new_element = gst_autoplug_to_renderers (autoplug, caps, osssink, NULL);
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");
}
static void
-gst_play_cache_empty (GstElement *element, GstElement *pipeline)
+gst_play_cache_empty (GstElement * element, GstElement * pipeline)
{
GstElement *autobin;
GstElement *filesrc;
fprintf (stderr, "done with cache_empty\n");
}
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc;
GstElement *pipeline;
autobin = gst_bin_new ("autobin");
cache = gst_element_factory_make ("autoplugcache", "cache");
- g_signal_connect (G_OBJECT (cache), "cache_empty",
- G_CALLBACK (gst_play_cache_empty), pipeline);
+ g_signal_connect (G_OBJECT (cache), "cache_empty",
+ G_CALLBACK (gst_play_cache_empty), pipeline);
typefind = gst_element_factory_make ("typefind", "typefind");
- g_signal_connect (G_OBJECT (typefind), "have_type",
- G_CALLBACK (gst_play_have_type), pipeline);
+ g_signal_connect (G_OBJECT (typefind), "have_type",
+ G_CALLBACK (gst_play_have_type), pipeline);
gst_bin_add (GST_BIN (autobin), cache);
gst_bin_add (GST_BIN (autobin), typefind);
gst_element_link_pads (cache, "src", typefind, "sink");
- gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink");
+ gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"),
+ "sink");
- gst_bin_add (GST_BIN( pipeline), autobin);
+ gst_bin_add (GST_BIN (pipeline), autobin);
gst_element_link_pads (filesrc, "src", autobin, "sink");
/* start playing */
- gst_element_set_state( GST_ELEMENT (pipeline), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_object_unref (GST_OBJECT (pipeline));
- exit(0);
+ exit (0);
}
-
#include <gst/gst.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *pipeline;
GstElement *filesrc;
return -1;
}
- pipeline = (GstElement*) gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
+ pipeline =
+ (GstElement *)
+ gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
if (!pipeline) {
fprintf (stderr, "Parse error: %s", error->message);
exit (1);
}
-
+
filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc");
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
-
+
return 0;
}
/*#define AUTOPLUG * define if you want autoplugging of input channels * */
/* function prototypes */
-input_channel_t* create_input_channel (int id, char* location);
-void destroy_input_channel (input_channel_t *pipe);
-void env_register_cp (GstElement *volenv, double cp_time, double cp_level);
+input_channel_t *create_input_channel (int id, char *location);
+void destroy_input_channel (input_channel_t * pipe);
+void env_register_cp (GstElement * volenv, double cp_time, double cp_level);
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element)
+void
+eos (GstElement * element)
{
- g_print("have eos, quitting ?\n");
+ g_print ("have eos, quitting ?\n");
/* playing = FALSE; */
}
-G_GNUC_UNUSED static GstCaps*
-gst_play_type_find (GstBin *bin, GstElement *element)
+G_GNUC_UNUSED static GstCaps *
+gst_play_type_find (GstBin * bin, GstElement * element)
{
GstElement *typefind;
GstElement *pipeline;
GstCaps *caps = NULL;
GST_DEBUG ("GstPipeline: typefind for element \"%s\"",
- GST_ELEMENT_NAME(element));
+ GST_ELEMENT_NAME (element));
pipeline = gst_pipeline_new ("autoplug_pipeline");
-
+
typefind = gst_element_factory_make ("typefind", "typefind");
g_return_val_if_fail (typefind != NULL, FALSE);
gst_pad_link (gst_element_get_pad (element, "src"),
- gst_element_get_pad (typefind, "sink"));
+ gst_element_get_pad (typefind, "sink"));
gst_bin_add (bin, typefind);
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (bin));
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
/* push a buffer... the have_type signal handler will set the found flag */
gst_bin_iterate (GST_BIN (pipeline));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
caps = gst_pad_get_caps (gst_element_get_pad (element, "src"));
gst_pad_unlink (gst_element_get_pad (element, "src"),
- gst_element_get_pad (typefind, "sink"));
+ gst_element_get_pad (typefind, "sink"));
gst_bin_remove (bin, typefind);
gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin));
gst_object_unref (GST_OBJECT (typefind));
gst_object_unref (GST_OBJECT (pipeline));
-
+
return caps;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
int i, j;
int num_channels;
-
+
char buffer[20];
-
- GList *input_channels; /* structure holding all the input channels */
-
+
+ GList *input_channels; /* structure holding all the input channels */
+
input_channel_t *channel_in;
-
+
GstElement *main_bin;
GstElement *adder;
GstElement *audiosink;
- GstPad *pad; /* to request pads for the adder */
+ GstPad *pad; /* to request pads for the adder */
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc == 1) {
- g_print("usage: %s <filename1> <filename2> <...>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename1> <filename2> <...>\n", argv[0]);
+ exit (-1);
}
num_channels = argc - 1;
-
+
/* set up output channel and main bin */
-
+
/* create adder */
adder = gst_element_factory_make ("adder", "adderel");
audiosink = gst_element_factory_make ("esdsink", "play_audio");
/* create main bin */
- main_bin = gst_pipeline_new("bin");
+ main_bin = gst_pipeline_new ("bin");
/* link adder and output to bin */
- GST_INFO ( "main: adding adder to bin");
- gst_bin_add (GST_BIN(main_bin), adder);
- GST_INFO ( "main: adding audiosink to bin");
- gst_bin_add (GST_BIN(main_bin), audiosink);
+ GST_INFO ("main: adding adder to bin");
+ gst_bin_add (GST_BIN (main_bin), adder);
+ GST_INFO ("main: adding audiosink to bin");
+ gst_bin_add (GST_BIN (main_bin), audiosink);
/* link adder and audiosink */
- gst_pad_link(gst_element_get_pad(adder,"src"),
- gst_element_get_pad(audiosink,"sink"));
-
+ gst_pad_link (gst_element_get_pad (adder, "src"),
+ gst_element_get_pad (audiosink, "sink"));
+
/* start looping */
input_channels = NULL;
-
- for (i = 1; i < argc; ++i)
- {
+
+ for (i = 1; i < argc; ++i) {
printf ("Opening channel %d from file %s...\n", i, argv[i]);
channel_in = create_input_channel (i, argv[i]);
input_channels = g_list_append (input_channels, channel_in);
- if (i > 1) gst_element_set_state (main_bin, GST_STATE_PAUSED);
- gst_bin_add (GST_BIN(main_bin), channel_in->pipe);
+ if (i > 1)
+ gst_element_set_state (main_bin, GST_STATE_PAUSED);
+ gst_bin_add (GST_BIN (main_bin), channel_in->pipe);
/* request pads and link to adder */
- GST_INFO ( "requesting pad\n");
+ GST_INFO ("requesting pad\n");
pad = gst_element_get_request_pad (adder, "sink%d");
printf ("\tGot new adder sink pad %s\n", gst_pad_get_name (pad));
sprintf (buffer, "channel%d", i);
* at a level ensuring no distortion
* example for three songs :
* song1 : starts at full level, plays 5 seconds, faded out at 10 seconds,
- * sleep until 25, fade to end level at 30
+ * sleep until 25, fade to end level at 30
* song2 : starts silent, fades in at 5 seconds, full blast at 10 seconds,
- * full level until 15, faded out at 20, sleep until 25, fade to end at 30
+ * full level until 15, faded out at 20, sleep until 25, fade to end at 30
* song3 : starts muted, fades in from 15, full at 20, until 25, fade to end level
*/
- if (i == 1)
- {
+ if (i == 1) {
/* first song gets special treatment for end style */
- env_register_cp (channel_in->volenv, 0.0, 1.0);
- }
- else
- {
- env_register_cp (channel_in->volenv, 0.0 , 0.0000001); /* start muted */
- env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
- env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
+ env_register_cp (channel_in->volenv, 0.0, 1.0);
+ } else {
+ env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */
+ env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
+ env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
}
- env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
+ env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
- if (i != num_channels)
- {
- env_register_cp (channel_in->volenv, i * 10.0 , 0.0000001); /* fade to black */
- env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
- }
- env_register_cp (channel_in->volenv, num_channels * 10.0 , 1.0 / num_channels); /* to end level */
+ if (i != num_channels) {
+ env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */
+ env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
+ }
+ env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */
#ifndef GST_DISABLE_LOADSAVE
gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w"));
#endif
/* start playing */
- gst_element_set_state(main_bin, GST_STATE_PLAYING);
+ gst_element_set_state (main_bin, GST_STATE_PLAYING);
/* write out the schedule */
- gst_scheduler_show(GST_ELEMENT_SCHED(main_bin));
+ gst_scheduler_show (GST_ELEMENT_SCHED (main_bin));
playing = TRUE;
j = 0;
/*printf ("main: start iterating from 0"); */
- while (playing && j < 100)
- {
+ while (playing && j < 100) {
/* printf ("main: iterating %d\n", j); */
- gst_bin_iterate(GST_BIN(main_bin));
- /*fprintf(stderr,"after iterate()\n"); */
+ gst_bin_iterate (GST_BIN (main_bin));
+ /*fprintf(stderr,"after iterate()\n"); */
++j;
}
}
printf ("main: all the channels are open\n");
- while (playing)
- {
- gst_bin_iterate(GST_BIN(main_bin));
+ while (playing) {
+ gst_bin_iterate (GST_BIN (main_bin));
/*fprintf(stderr,"after iterate()\n"); */
}
/* stop the bin */
- gst_element_set_state(main_bin, GST_STATE_NULL);
+ gst_element_set_state (main_bin, GST_STATE_NULL);
- while (input_channels)
- {
+ while (input_channels) {
destroy_input_channel (input_channels->data);
input_channels = g_list_next (input_channels);
}
g_list_free (input_channels);
-
- gst_object_unref(GST_OBJECT(audiosink));
- gst_object_unref(GST_OBJECT(main_bin));
+ gst_object_unref (GST_OBJECT (audiosink));
- exit(0);
+ gst_object_unref (GST_OBJECT (main_bin));
+
+ exit (0);
}
-input_channel_t*
-create_input_channel (int id, char* location)
+input_channel_t *
+create_input_channel (int id, char *location)
{
/* create an input channel, reading from location
* return a pointer to the channel
*/
input_channel_t *channel;
-
- char buffer[20]; /* hold the names */
+
+ char buffer[20]; /* hold the names */
/* GstAutoplug *autoplug;
GstCaps *srccaps; */
- GstElement *new_element;
+ GstElement *new_element;
GstElement *decoder;
- GST_DEBUG ( "c_i_p : creating channel with id %d for file %s",
- id, location);
-
+ GST_DEBUG ("c_i_p : creating channel with id %d for file %s", id, location);
+
/* allocate channel */
channel = (input_channel_t *) malloc (sizeof (input_channel_t));
- if (channel == NULL)
- {
+ if (channel == NULL) {
printf ("create_input_channel : could not allocate memory for channel !\n");
return NULL;
}
/* create channel */
- GST_DEBUG ( "c_i_p : creating pipeline");
+ GST_DEBUG ("c_i_p : creating pipeline");
sprintf (buffer, "pipeline%d", id);
channel->pipe = gst_bin_new (buffer);
- g_assert(channel->pipe != NULL);
-
+ g_assert (channel->pipe != NULL);
+
/* create elements */
- GST_DEBUG ( "c_i_p : creating filesrc");
+ GST_DEBUG ("c_i_p : creating filesrc");
sprintf (buffer, "filesrc%d", id);
channel->filesrc = gst_element_factory_make ("filesrc", buffer);
- g_assert(channel->filesrc != NULL);
+ g_assert (channel->filesrc != NULL);
- GST_DEBUG ( "c_i_p : setting location");
- g_object_set(G_OBJECT(channel->filesrc),"location", location, NULL);
+ GST_DEBUG ("c_i_p : setting location");
+ g_object_set (G_OBJECT (channel->filesrc), "location", location, NULL);
/* add filesrc to the bin before autoplug */
- gst_bin_add(GST_BIN(channel->pipe), channel->filesrc);
+ gst_bin_add (GST_BIN (channel->pipe), channel->filesrc);
/* link signal to eos of filesrc */
- g_signal_connect (G_OBJECT(channel->filesrc),"eos",
- G_CALLBACK(eos),NULL);
+ g_signal_connect (G_OBJECT (channel->filesrc), "eos", G_CALLBACK (eos), NULL);
#ifdef DEBUG
sprintf (buffer, "volenv%d", id);
channel->volenv = gst_element_factory_make ("volenv", buffer);
- g_assert(channel->volenv != NULL);
+ g_assert (channel->volenv != NULL);
/* autoplug the pipe */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_bin_remove (GST_BIN (pipeline), channel->pipe);
-
+
}
#endif
g_print ("could not autoplug, unknown media type...\n");
exit (-1);
}
-
#ifdef DEBUG
printf ("DEBUG : c_i_p : creating autoplug\n");
#endif
#ifdef DEBUG
printf ("DEBUG : c_i_p : autoplugging\n");
#endif
-
- new_element = gst_autoplug_to_caps (autoplug, srccaps,
- gst_caps_new ("audio/raw", NULL), NULL);
-
+
+ new_element = gst_autoplug_to_caps (autoplug, srccaps,
+ gst_caps_new ("audio/raw", NULL), NULL);
+
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");
exit (-1);
}
-
#else
new_element = gst_bin_new ("autoplug_bin");
/* static plug, use mad plugin and assume mp3 input */
printf ("using static plugging for input channel\n");
- decoder = gst_element_factory_make ("mad", "mpg123");
- if (!decoder)
- {
+ decoder = gst_element_factory_make ("mad", "mpg123");
+ if (!decoder) {
fprintf (stderr, "Could not get a decoder element !\n");
exit (1);
}
gst_bin_add (GST_BIN (new_element), decoder);
- gst_element_add_ghost_pad (new_element,
- gst_element_get_pad (decoder, "sink"), "sink");
- gst_element_add_ghost_pad (new_element,
- gst_element_get_pad (decoder, "src"), "src_00");
-
-#endif
+ gst_element_add_ghost_pad (new_element,
+ gst_element_get_pad (decoder, "sink"), "sink");
+ gst_element_add_ghost_pad (new_element,
+ gst_element_get_pad (decoder, "src"), "src_00");
+
+#endif
#ifndef GST_DISABLE_LOADSAVE
gst_xml_write_file (GST_ELEMENT (new_element), fopen ("mixer.gst", "w"));
-#endif
+#endif
- gst_bin_add (GST_BIN(channel->pipe), channel->volenv);
+ gst_bin_add (GST_BIN (channel->pipe), channel->volenv);
gst_bin_add (GST_BIN (channel->pipe), new_element);
-
+
gst_element_link_pads (channel->filesrc, "src", new_element, "sink");
gst_element_link_pads (new_element, "src_00", channel->volenv, "sink");
-
+
/* add a ghost pad */
sprintf (buffer, "channel%d", id);
gst_element_add_ghost_pad (channel->pipe,
- gst_element_get_pad (channel->volenv, "src"), buffer);
+ gst_element_get_pad (channel->volenv, "src"), buffer);
+
-
#ifdef DEBUG
printf ("DEBUG : c_i_p : end function\n");
#endif
}
void
-destroy_input_channel (input_channel_t *channel)
+destroy_input_channel (input_channel_t * channel)
{
/*
* destroy an input channel
*/
-
+
#ifdef DEBUG
printf ("DEBUG : d_i_p : start\n");
#endif
free (channel);
}
-void env_register_cp (GstElement *volenv, double cp_time, double cp_level)
+void
+env_register_cp (GstElement * volenv, double cp_time, double cp_level)
{
char buffer[30];
sprintf (buffer, "%f:%f", cp_time, cp_level);
- g_object_set(G_OBJECT(volenv), "controlpoint", buffer, NULL);
+ g_object_set (G_OBJECT (volenv), "controlpoint", buffer, NULL);
}
* thomas@apestaart.org
*/
-typedef struct
+typedef struct
{
GstElement *pipe, *filesrc, *volenv;
-
+
char *location;
int channel_id;
} input_channel_t;
#include <gst/gst.h>
-static GstElement*
+static GstElement *
make_bin (gint count)
{
GstElement *bin;
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *aggregator, *sink;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("main");
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
-
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+
aggregator = gst_element_factory_make ("aggregator", "mixer");
sink = gst_element_factory_make ("fakesink", "sink");
i = 4;
while (i--)
gst_bin_iterate (GST_BIN (pipeline));
-
+
g_print ("playing bin1\n");
gst_element_set_state (bin1, GST_STATE_PLAYING);
* plugin, as well as author and version data. Use the GST_ELEMENT_DETAILS
* macro when defining it.
*/
-static GstElementDetails example_details = GST_ELEMENT_DETAILS (
- "An example plugin",
- "Example/FirstExample",
- "Shows the basic structure of a plugin",
- "your name <your.name@your.isp>"
-);
+static GstElementDetails example_details =
+GST_ELEMENT_DETAILS ("An example plugin",
+ "Example/FirstExample",
+ "Shows the basic structure of a plugin",
+ "your name <your.name@your.isp>");
/* These are the signals that this element can fire. They are zero-
* based because the numbers themselves are private to the object.
* LAST_SIGNAL is used for initialization of the signal array.
*/
-enum {
+enum
+{
ASDF,
/* FILL ME */
LAST_SIGNAL
/* Arguments are identified the same way, but cannot be zero, so you
* must leave the ARG_0 entry in as a placeholder.
*/
-enum {
+enum
+{
ARG_0,
ARG_ACTIVE
- /* FILL ME */
+ /* FILL ME */
};
/* The PadFactory structures describe what pads the element has or
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink", /* The name of the pad */
- GST_PAD_SINK, /* Direction of the pad */
- GST_PAD_ALWAYS, /* The pad exists for every instance */
- GST_STATIC_CAPS (
- "unknown/unknown, " /* The MIME media type */
- "foo:int=1, " /* an integer property */
- "bar:boolean=true, " /* a boolean property */
- "baz:int={ 1, 3 }" /* a list of values */
- )
-);
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */
+ GST_PAD_SINK, /* Direction of the pad */
+ GST_PAD_ALWAYS, /* The pad exists for every instance */
+ GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */
+ "foo:int=1, " /* an integer property */
+ "bar:boolean=true, " /* a boolean property */
+ "baz:int={ 1, 3 }" /* a list of values */
+ )
+ );
/* This factory is much simpler, and defines the source pad. */
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "unknown/unknown"
- )
-);
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("unknown/unknown")
+ );
/* A number of functon prototypes are given so we can refer to them later. */
-static void gst_example_class_init (GstExampleClass *klass);
-static void gst_example_init (GstExample *example);
+static void gst_example_class_init (GstExampleClass * klass);
+static void gst_example_init (GstExample * example);
-static void gst_example_chain (GstPad *pad, GstData *_data);
+static void gst_example_chain (GstPad * pad, GstData * _data);
-static void gst_example_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_example_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_example_change_state (GstElement *element);
+static void gst_example_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_example_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_example_change_state (GstElement * element);
/* The parent class pointer needs to be kept around for some object
* operations.
* and pointers to the various functions that define the class.
*/
GType
-gst_example_get_type(void)
+gst_example_get_type (void)
{
static GType example_type = 0;
if (!example_type) {
static const GTypeInfo example_info = {
- sizeof(GstExampleClass),
+ sizeof (GstExampleClass),
NULL,
NULL,
- (GClassInitFunc)gst_example_class_init,
+ (GClassInitFunc) gst_example_class_init,
NULL,
NULL,
- sizeof(GstExample),
+ sizeof (GstExample),
0,
- (GInstanceInitFunc)gst_example_init,
+ (GInstanceInitFunc) gst_example_init,
};
- example_type = g_type_register_static(GST_TYPE_ELEMENT, "GstExample", &example_info, 0);
+ example_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info,
+ 0);
}
return example_type;
}
* it, based on the pointer to the function provided above.
*/
static void
-gst_example_class_init (GstExampleClass *klass)
+gst_example_class_init (GstExampleClass * klass)
{
/* Class pointers are needed to supply pointers to the private
* implementations of parent class methods.
/* Since the example class contains the parent classes, you can simply
* cast the pointer to get access to the parent classes.
*/
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
/* The parent class is needed for class method overrides. */
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
/* Here we add an argument to the object. This argument is an integer,
* and can be both read and written.
*/
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE,
- g_param_spec_int("active","active","active",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
/* Here we add a signal to the object. This is avery useless signal
* called asdf. The signal will also pass a pointer to the listeners
* which happens to be the example element itself */
gst_example_signals[ASDF] =
- g_signal_new("asdf", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL,
- g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- GST_TYPE_EXAMPLE);
+ g_signal_new ("asdf", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_EXAMPLE);
/* The last thing is to provide the functions that implement get and set
* the plugin.
*/
static void
-gst_example_init(GstExample *example)
+gst_example_init (GstExample * example)
{
/* First we create the sink pad, which is the input to the element.
* We will use the template constructed by the factory.
*/
- example->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ example->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
/* Setting the chain function allows us to supply the function that will
* actually be performing the work. Without this, the element would do
* nothing, with undefined results (assertion failures and such).
*/
- gst_pad_set_chain_function(example->sinkpad,gst_example_chain);
+ gst_pad_set_chain_function (example->sinkpad, gst_example_chain);
/* We then must add this pad to the element's list of pads. The base
* element class manages the list of pads, and provides accessors to it.
*/
- gst_element_add_pad(GST_ELEMENT(example),example->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (example), example->sinkpad);
/* The src pad, the output of the element, is created and registered
* in the same way, with the exception of the chain function. Source
* pads don't have chain functions, because they can't accept buffers,
* they only produce them.
*/
- example->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
- gst_element_add_pad(GST_ELEMENT(example),example->srcpad);
+ example->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (example), example->srcpad);
/* Initialization of element's private variables. */
example->active = FALSE;
* as the buffer provided by the peer element.
*/
static void
-gst_example_chain (GstPad *pad, GstData *_data)
+gst_example_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstExample *example;
/* Some of these checks are of dubious value, since if there were not
* already true, the chain function would never be called.
*/
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* We need to get a pointer to the element this pad belogs to. */
- example = GST_EXAMPLE(gst_pad_get_parent (pad));
+ example = GST_EXAMPLE (gst_pad_get_parent (pad));
/* A few more sanity checks to make sure that the element that owns
* this pad is the right kind of element, in case something got confused.
*/
- g_return_if_fail(example != NULL);
- g_return_if_fail(GST_IS_EXAMPLE(example));
+ g_return_if_fail (example != NULL);
+ g_return_if_fail (GST_IS_EXAMPLE (example));
/* If we are supposed to be doing something, here's where it happens. */
if (example->active) {
/* In this example we're going to copy the buffer to another one,
* so we need to allocate a new buffer first. */
- outbuf = gst_buffer_new();
+ outbuf = gst_buffer_new ();
/* We need to copy the size and offset of the buffer at a minimum. */
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf);
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf);
/* Then allocate the memory for the new buffer */
- GST_BUFFER_DATA (outbuf) = (guchar *)g_malloc (GST_BUFFER_SIZE (outbuf));
+ GST_BUFFER_DATA (outbuf) = (guchar *) g_malloc (GST_BUFFER_SIZE (outbuf));
/* Then copy the data in the incoming buffer into the new buffer. */
- memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (outbuf));
+ memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (outbuf));
/* we don't need the incomming buffer anymore so we unref it. When we are
* the last plugin with a handle to the buffer, its memory will be freed */
* in the pipeline, through the element's source pad, which is stored
* in the element's structure.
*/
- gst_pad_push(example->srcpad,GST_DATA (outbuf));
+ gst_pad_push (example->srcpad, GST_DATA (outbuf));
/* For fun we'll emit our useless signal here */
- g_signal_emit(G_OBJECT (example), gst_example_signals[ASDF], 0,
- example);
+ g_signal_emit (G_OBJECT (example), gst_example_signals[ASDF], 0, example);
- /* If we're not doing something, just send the original incoming buffer. */
+ /* If we're not doing something, just send the original incoming buffer. */
} else {
- gst_pad_push(example->srcpad,GST_DATA (buf));
+ gst_pad_push (example->srcpad, GST_DATA (buf));
}
}
* enable the element to respond to various arguments.
*/
static void
-gst_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_example_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstExample *example;
/* It's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_EXAMPLE(object));
+ g_return_if_fail (GST_IS_EXAMPLE (object));
/* Get a pointer of the right type. */
- example = GST_EXAMPLE(object);
+ example = GST_EXAMPLE (object);
/* Check the argument id to see which argument we're setting. */
switch (prop_id) {
* is running, if you are using threads.
*/
example->active = g_value_get_int (value);
- g_print("example: set active to %d\n",example->active);
+ g_print ("example: set active to %d\n", example->active);
break;
default:
break;
/* The set function is simply the inverse of the get fuction. */
static void
-gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_example_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstExample *example;
/* It's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_EXAMPLE(object));
- example = GST_EXAMPLE(object);
+ g_return_if_fail (GST_IS_EXAMPLE (object));
+ example = GST_EXAMPLE (object);
switch (prop_id) {
case ARG_ACTIVE:
* in the various state transitions.
*/
static GstElementStateReturn
-gst_example_change_state (GstElement *element)
+gst_example_change_state (GstElement * element)
{
GstExample *example;
-
+
/* cast to our plugin */
- example = GST_EXAMPLE(element);
-
+ example = GST_EXAMPLE (element);
+
/* we perform our actions based on the state transition
* of the element */
switch (GST_STATE_TRANSITION (element)) {
- /* The NULL to READY transition is used to
- * create threads (if any) */
+ /* The NULL to READY transition is used to
+ * create threads (if any) */
case GST_STATE_NULL_TO_READY:
break;
- /* In the READY to PAUSED state, the element should
- * open devices (if any) */
+ /* In the READY to PAUSED state, the element should
+ * open devices (if any) */
case GST_STATE_READY_TO_PAUSED:
break;
- /* In the PAUSED to PLAYING state, the element should
- * prepare itself for operation or continue after a PAUSE */
+ /* In the PAUSED to PLAYING state, the element should
+ * prepare itself for operation or continue after a PAUSE */
case GST_STATE_PAUSED_TO_PLAYING:
break;
- /* In the PLAYING to PAUSED state, the element should
- * PAUSE itself and make sure it can resume operation */
+ /* In the PLAYING to PAUSED state, the element should
+ * PAUSE itself and make sure it can resume operation */
case GST_STATE_PLAYING_TO_PAUSED:
break;
- /* In the PAUSED to READY state, the element should reset
- * its internal state and close any devices. */
+ /* In the PAUSED to READY state, the element should reset
+ * its internal state and close any devices. */
case GST_STATE_PAUSED_TO_READY:
break;
- /* The element should free all resources, terminate threads
- * and put itself into its initial state again */
+ /* The element should free all resources, terminate threads
+ * and put itself into its initial state again */
case GST_STATE_READY_TO_NULL:
break;
}
* this function is called to register everything that the plugin provides.
*/
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* We need to register each element we provide with the plugin. This consists
* of the name of the element, a rank that gives the importance of the element
* when compared to similar plugins and the GType identifier.
*/
- if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, GST_TYPE_EXAMPLE))
+ if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL,
+ GST_TYPE_EXAMPLE))
return FALSE;
/* Now we can return successfully. */
* The symbol pointing to this structure is the only symbol looked up when
* loading the plugin.
*/
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR, /* The major version of the core that this was built with */
- GST_VERSION_MINOR, /* The minor version of the core that this was built with */
- "example", /* The name of the plugin. This must be unique: plugins with
- * the same name will be assumed to be identical, and only
- * one will be loaded. */
- "an example plugin", /* a short description of the plugin in English */
- plugin_init, /* Pointer to the initialisation function for the plugin. */
- "0.1", /* The version number of the plugin */
- "LGPL", /* ieffective license the plugin can be shipped with. Must be
- * valid for all libraries it links to, too. */
- "my nifty plugin package",
- /* package this plugin belongs to. */
- "http://www.mydomain.com"
- /* originating URL for this plugin. This is the place to look
- * for updates, information and so on. */
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */
+ GST_VERSION_MINOR, /* The minor version of the core that this was built with */
+ "example", /* The name of the plugin. This must be unique: plugins with
+ * the same name will be assumed to be identical, and only
+ * one will be loaded. */
+ "an example plugin", /* a short description of the plugin in English */
+ plugin_init, /* Pointer to the initialisation function for the plugin. */
+ "0.1", /* The version number of the plugin */
+ "LGPL", /* ieffective license the plugin can be shipped with. Must be
+ * valid for all libraries it links to, too. */
+ "my nifty plugin package",
+ /* package this plugin belongs to. */
+ "http://www.mydomain.com"
+ /* originating URL for this plugin. This is the place to look
+ * for updates, information and so on. */
+ );
#include <gst/gst.h>
G_BEGIN_DECLS
-
/* This is the definition of the element's object structure. */
typedef struct _GstExample GstExample;
* the beginning of the object. This allows the element to be cast to
* an Element or even an Object.
*/
-struct _GstExample {
+struct _GstExample
+{
GstElement element;
/* We need to keep track of our pads, so we do so here. */
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* We'll use this to decide whether to do anything to the data we get. */
gboolean active;
* structure. */
typedef struct _GstExampleClass GstExampleClass;
-struct _GstExampleClass {
+struct _GstExampleClass
+{
GstElementClass parent_class;
/* signals */
- void (*asdf) (GstElement *element, GstExample *example);
+ void (*asdf) (GstElement * element, GstExample * example);
};
/* Five standard preprocessing macros are used in the Gtk+ object system.
/* This is the only prototype needed, because it is used in the above
* GST_TYPE_EXAMPLE macro.
*/
-GType gst_example_get_type(void);
+GType gst_example_get_type (void);
G_END_DECLS
-
#endif /* __GST_EXAMPLE_H__ */
#include <stdlib.h>
#include <gst/gst.h>
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *parse, *decode, *queue;
GstElement *bin;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, parse, decode, queue, NULL);
- gst_bin_add(GST_BIN(thread), osssink);
- gst_bin_add(GST_BIN(bin), thread);
+ gst_bin_add (GST_BIN (thread), osssink);
+ gst_bin_add (GST_BIN (bin), thread);
gst_element_link_many (filesrc, parse, decode, queue, osssink, NULL);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- while (gst_bin_iterate(GST_BIN(bin)));
+ while (gst_bin_iterate (GST_BIN (bin)));
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue;
GstElement *pipeline;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- pipeline = gst_pipeline_new("pipeline");
- g_assert(pipeline != NULL);
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect (G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
/*
- gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
- gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue);
+ gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
+ gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue);
- gst_bin_add(GST_BIN(thread), osssink);
+ gst_bin_add(GST_BIN(thread), osssink);
- gst_pad_link(gst_element_get_pad(queue,"src"),
- gst_element_get_pad(osssink,"sink"));
+ gst_pad_link(gst_element_get_pad(queue,"src"),
+ gst_element_get_pad(osssink,"sink"));
- if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
- g_print("cannot autoplug pipeline\n");
- exit(-1);
- }
- */
+ if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
+ g_print("cannot autoplug pipeline\n");
+ exit(-1);
+ }
+ */
- gst_bin_add(GST_BIN(pipeline), thread);
+ gst_bin_add (GST_BIN (pipeline), thread);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(pipeline));
+ gst_bin_iterate (GST_BIN (pipeline));
}
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *parse, *decode;
GstElement *bin;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
/* add objects to the main bin */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), queue);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), queue);
- gst_bin_add(GST_BIN(thread), parse);
- gst_bin_add(GST_BIN(thread), decode);
- gst_bin_add(GST_BIN(thread), osssink);
+ gst_bin_add (GST_BIN (thread), parse);
+ gst_bin_add (GST_BIN (thread), decode);
+ gst_bin_add (GST_BIN (thread), osssink);
gst_element_link_many (filesrc, queue, parse, decode, osssink, NULL);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
}
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *queue2, *parse, *decode;
GstElement *bin;
GstElement *thread, *thread2;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
- thread2 = gst_thread_new("thread2");
- g_assert(thread2 != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
+ thread2 = gst_thread_new ("thread2");
+ g_assert (thread2 != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
- queue2 = gst_element_factory_make("queue", "queue2");
+ queue = gst_element_factory_make ("queue", "queue");
+ queue2 = gst_element_factory_make ("queue", "queue2");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
/* add objects to the main bin */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), queue);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), queue);
- gst_bin_add(GST_BIN(thread), parse);
- gst_bin_add(GST_BIN(thread), decode);
- gst_bin_add(GST_BIN(thread), queue2);
+ gst_bin_add (GST_BIN (thread), parse);
+ gst_bin_add (GST_BIN (thread), decode);
+ gst_bin_add (GST_BIN (thread), queue2);
- gst_bin_add(GST_BIN(thread2), osssink);
+ gst_bin_add (GST_BIN (thread2), osssink);
gst_element_link_many (filesrc, queue, parse, decode, queue2, osssink, NULL);
- gst_bin_add(GST_BIN(bin), thread);
- gst_bin_add(GST_BIN(bin), thread2);
+ gst_bin_add (GST_BIN (bin), thread);
+ gst_bin_add (GST_BIN (bin), thread2);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
}
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
#include <string.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *tag_changer, *filesink;
gchar *artist, *title, *ext, *filename;
-
+
/* initialize GStreamer */
gst_init (&argc, &argv);
artist = argv[1];
artist = g_strdup (artist);
ext = strrchr (artist, '.');
- if (ext) *ext = '\0';
+ if (ext)
+ *ext = '\0';
title = strstr (artist, " - ");
if (title == NULL) {
g_print ("The format of the mp3 file is invalid.\n");
}
*title = '\0';
title += 3;
-
-
+
+
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("pipeline");
g_assert (bin);
g_assert (filesink);
/* set the filenames */
- filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */
+ filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL);
/* make sure the tag setter uses our stuff
(though that should already be default) */
- gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_KEEP);
+ gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer),
+ GST_TAG_MERGE_KEEP);
/* set the tagging information */
gst_tag_setter_add (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_REPLACE,
- GST_TAG_ARTIST, artist,
- GST_TAG_TITLE, title,
- NULL);
+ GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, tag_changer, filesink, NULL);
/* link the elements */
g_assert (gst_element_link_many (filesrc, tag_changer, filesink));
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
return 0;
}
-
#include <string.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *encoder, *filesink;
gchar *artist, *title, *ext, *filename;
-
+
/* initialize GStreamer */
gst_init (&argc, &argv);
artist = argv[1];
artist = g_strdup (artist);
ext = strrchr (artist, '.');
- if (ext) *ext = '\0';
+ if (ext)
+ *ext = '\0';
title = strstr (artist, " - ");
if (title == NULL) {
g_print ("The format of the mp3 file is invalid.\n");
}
*title = '\0';
title += 3;
-
-
+
+
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("pipeline");
g_assert (bin);
g_print ("cound not find plugin \"vorbisenc\"");
return 1;
}
-
+
/* and a file writer */
filesink = gst_element_factory_make ("filesink", "filesink");
g_assert (filesink);
/* set the filenames */
- filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */
+ filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL);
g_free (filename);
gst_tag_setter_set_merge_mode (GST_TAG_SETTER (encoder), GST_TAG_MERGE_KEEP);
/* set the tagging information */
gst_tag_setter_add (GST_TAG_SETTER (encoder), GST_TAG_MERGE_REPLACE,
- GST_TAG_ARTIST, artist,
- GST_TAG_TITLE, title,
- NULL);
+ GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, encoder, filesink, NULL);
/* link the elements */
gst_element_link_many (filesrc, decoder, encoder, filesink, NULL);
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
return 0;
}
-
#include <gst/gst.h>
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- GstThread *thread = GST_THREAD(data);
- g_print("have eos, quitting\n");
+ GstThread *thread = GST_THREAD (data);
+
+ g_print ("have eos, quitting\n");
/* stop the bin */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
- gst_main_quit();
+ gst_main_quit ();
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink;
GstElement *pipeline;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- pipeline = gst_pipeline_new("pipeline");
- g_assert(pipeline != NULL);
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
/*
- gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
- gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink);
+ gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
+ gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink);
- if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
- g_print("unable to handle stream\n");
- exit(-1);
- }
- */
+ if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
+ g_print("unable to handle stream\n");
+ exit(-1);
+ }
+ */
/*gst_bin_remove(GST_BIN(pipeline), filesrc); */
/*gst_bin_add(GST_BIN(thread), filesrc); */
- gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline));
+ gst_bin_add (GST_BIN (thread), GST_ELEMENT (pipeline));
/* make it ready */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
- gst_main();
+ gst_main ();
- gst_object_unref(GST_OBJECT(thread));
+ gst_object_unref (GST_OBJECT (thread));
- exit(0);
+ exit (0);
}
#include <gst/gst.h>
void
-type_found (GstElement *typefind, const GstCaps * caps)
+type_found (GstElement * typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
-
- doc = xmlNewDoc ("1.0");
+
+ doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL);
xmlDocDump (stdout, doc);
}
-int
-main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *typefind;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new bin to hold the elements */
- bin = gst_pipeline_new("bin");
- g_assert(bin != NULL);
+ bin = gst_pipeline_new ("bin");
+ g_assert (bin != NULL);
/* create a file reader */
- filesrc = gst_element_factory_make("filesrc", "file_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
+ filesrc = gst_element_factory_make ("filesrc", "file_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
- typefind = gst_element_factory_make("typefind", "typefind");
- g_assert(typefind != NULL);
+ typefind = gst_element_factory_make ("typefind", "typefind");
+ g_assert (typefind != NULL);
/* add objects to the main pipeline */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), typefind);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), typefind);
- g_signal_connect (G_OBJECT (typefind), "have_type",
- G_CALLBACK (type_found), NULL);
+ g_signal_connect (G_OBJECT (typefind), "have_type",
+ G_CALLBACK (type_found), NULL);
gst_element_link (filesrc, typefind);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
static void
-object_saved (GstObject *object, xmlNodePtr parent, gpointer data)
+object_saved (GstObject * object, xmlNodePtr parent, gpointer data)
{
xmlNodePtr child;
xmlNsPtr ns;
-
+
/* first see if the namespace is already known */
- ns = xmlSearchNsByHref (parent->doc, parent, "http://gstreamer.net/gst-test/1.0/");
+ ns = xmlSearchNsByHref (parent->doc, parent,
+ "http://gstreamer.net/gst-test/1.0/");
if (ns == NULL) {
xmlNodePtr root = xmlDocGetRootElement (parent->doc);
+
/* add namespace to root node */
ns = xmlNewNs (root, "http://gstreamer.net/gst-test/1.0/", "test");
}
- child = xmlNewChild(parent, ns, "comment", NULL);
-
- xmlNewChild(child, NULL, "text", (gchar *)data);
+ child = xmlNewChild (parent, ns, "comment", NULL);
+
+ xmlNewChild (child, NULL, "text", (gchar *) data);
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *queue2, *decode;
GstElement *pipeline;
GstElement *thread, *thread2;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create new threads to hold the elements */
/* these signals will allow us to save custom tags with the gst xml output */
g_signal_connect (G_OBJECT (thread), "object_saved",
- G_CALLBACK (object_saved),
- g_strdup ("decoder thread"));
+ G_CALLBACK (object_saved), g_strdup ("decoder thread"));
g_signal_connect (G_OBJECT (thread2), "object_saved",
- G_CALLBACK (object_saved),
- g_strdup ("render thread"));
-
+ G_CALLBACK (object_saved), g_strdup ("render thread"));
+
/* create a new bin to hold the elements */
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
exit (0);
}
-
gboolean playing;
G_GNUC_UNUSED static void
-xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data)
+xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data)
{
xmlNodePtr children = self->xmlChildrenNode;
xmlNodePtr nodes = children->xmlChildrenNode;
while (nodes) {
- if (!strcmp (nodes->name, "text")) {
- gchar *name = g_strdup (xmlNodeGetContent (nodes));
- g_print ("object %s loaded with comment '%s'\n",
- gst_object_get_name (object), name);
+ if (!strcmp (nodes->name, "text")) {
+ gchar *name = g_strdup (xmlNodeGetContent (nodes));
+
+ g_print ("object %s loaded with comment '%s'\n",
+ gst_object_get_name (object), name);
}
nodes = nodes->next;
}
}
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstXML *xml;
GstElement *pipeline;
gboolean ret;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
xml = gst_xml_new ();
/* G_CALLBACK (xml_loaded), xml); */
if (argc == 2)
- ret = gst_xml_parse_file(xml, argv[1], NULL);
+ ret = gst_xml_parse_file (xml, argv[1], NULL);
else
- ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
-
+ ret = gst_xml_parse_file (xml, "xmlTest.gst", NULL);
+
g_assert (ret == TRUE);
- pipeline = gst_xml_get_element(xml, "pipeline");
+ pipeline = gst_xml_get_element (xml, "pipeline");
g_assert (pipeline != NULL);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
- while (gst_bin_iterate(GST_BIN(pipeline)));
+ while (gst_bin_iterate (GST_BIN (pipeline)));
- gst_element_set_state(pipeline, GST_STATE_NULL);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
* though the GLib version should take a function as argument...
*/
static void
-g_list_free_list_and_elements (GList *list)
+g_list_free_list_and_elements (GList * list)
{
GList *walk = list;
-
- while (walk)
- {
+
+ while (walk) {
g_free (walk->data);
walk = g_list_next (walk);
}
g_list_free (list);
}
+
/**
* gst_autoplug_caps_intersect:
* @src: a source #GstCaps
* Returns: TRUE, if both caps intersect.
*/
gboolean
-gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink)
+gst_autoplug_caps_intersect (const GstCaps * src, const GstCaps * sink)
{
GstCaps *caps;
/* get an intersection */
caps = gst_caps_intersect (src, sink);
-
+
/* if the caps can't link, there is no intersection */
if (gst_caps_is_empty (caps)) {
gst_caps_free (caps);
return FALSE;
}
-
+
/* hurrah, we can link, now remove the intersection */
gst_caps_free (caps);
return TRUE;
* Returns: #GstPadTemplate that can connect to the given caps
*/
GstPadTemplate *
-gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src)
+gst_autoplug_can_connect_src (GstElementFactory * fac, const GstCaps * src)
{
GList *templs;
-
+
templs = fac->padtemplates;
-
- while (templs)
- {
- if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) &&
- gst_autoplug_caps_intersect (src,
- GST_PAD_TEMPLATE_CAPS (templs->data)))
- {
+
+ while (templs) {
+ if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) &&
+ gst_autoplug_caps_intersect (src,
+ GST_PAD_TEMPLATE_CAPS (templs->data))) {
return GST_PAD_TEMPLATE (templs->data);
}
templs = g_list_next (templs);
}
-
- return NULL;
+
+ return NULL;
}
+
/**
* gst_autoplug_can_connect_sink:
* @fac: factory to connect to
* Returns: #GstPadTemplate that can connect to the given caps
*/
GstPadTemplate *
-gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink)
+gst_autoplug_can_connect_sink (GstElementFactory * fac, const GstCaps * sink)
{
GList *templs;
-
+
templs = fac->padtemplates;
-
- while (templs)
- {
+
+ while (templs) {
GstCaps *caps = GST_PAD_TEMPLATE_CAPS (templs->data);
+
if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) &&
- gst_autoplug_caps_intersect (caps, sink))
- {
+ gst_autoplug_caps_intersect (caps, sink)) {
return GST_PAD_TEMPLATE (templs->data);
}
templs = g_list_next (templs);
}
- return NULL;
+ return NULL;
}
+
GstPadTemplate *
-gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
+gst_autoplug_can_match (GstElementFactory * src, GstElementFactory * dest)
{
GList *srctemps, *desttemps;
srctemps = src->padtemplates;
while (srctemps) {
- GstPadTemplate *srctemp = (GstPadTemplate *)srctemps->data;
+ GstPadTemplate *srctemp = (GstPadTemplate *) srctemps->data;
desttemps = dest->padtemplates;
while (desttemps) {
- GstPadTemplate *desttemp = (GstPadTemplate *)desttemps->data;
+ GstPadTemplate *desttemp = (GstPadTemplate *) desttemps->data;
if (srctemp->direction == GST_PAD_SRC &&
- desttemp->direction == GST_PAD_SINK) {
- if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp),
- gst_pad_template_get_caps (desttemp))) {
- GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"",
- GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
- return desttemp;
- }
+ desttemp->direction == GST_PAD_SINK) {
+ if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp),
+ gst_pad_template_get_caps (desttemp))) {
+ GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"",
+ GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
+ return desttemp;
+ }
}
desttemps = g_list_next (desttemps);
}
srctemps = g_list_next (srctemps);
}
- GST_DEBUG ("factory \"%s\" cannot connect with factory \"%s\"",
- GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
+ GST_DEBUG ("factory \"%s\" cannot connect with factory \"%s\"",
+ GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
return NULL;
}
/* returns TRUE if the factory has padtemplates with the specified direction */
gboolean
-gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir)
+gst_autoplug_factory_has_direction (GstElementFactory * fac,
+ GstPadDirection dir)
{
GList *templs = fac->padtemplates;
-
- while (templs)
- {
- if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir)
- {
+
+ while (templs) {
+ if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
return TRUE;
}
templs = g_list_next (templs);
}
-
+
return FALSE;
}
* These functions return a new list so be sure to free it.
*/
GList *
-gst_autoplug_factories_sinks (GList *factories)
+gst_autoplug_factories_sinks (GList * factories)
{
GList *ret = NULL;
-
- while (factories)
- {
+
+ while (factories) {
if (gst_autoplug_factory_has_sink (factories->data))
ret = g_list_prepend (ret, factories->data);
factories = g_list_next (factories);
}
- return ret;
+ return ret;
}
+
GList *
-gst_autoplug_factories_srcs (GList *factories)
+gst_autoplug_factories_srcs (GList * factories)
{
GList *ret = NULL;
-
- while (factories)
- {
+
+ while (factories) {
if (gst_autoplug_factory_has_src (factories->data))
ret = g_list_prepend (ret, factories->data);
factories = g_list_next (factories);
}
- return ret;
+ return ret;
}
-GList *
-gst_autoplug_factories_filters (GList *factories)
+
+GList *
+gst_autoplug_factories_filters (GList * factories)
{
GList *ret = NULL;
-
- while (factories)
- {
+
+ while (factories) {
/* if you want it faster do src/sink check at once, don't call two functions */
- if (gst_autoplug_factory_has_src (factories->data) && gst_autoplug_factory_has_sink (factories->data))
+ if (gst_autoplug_factory_has_src (factories->data)
+ && gst_autoplug_factory_has_sink (factories->data))
ret = g_list_prepend (ret, factories->data);
factories = g_list_next (factories);
}
- return ret;
+ return ret;
}
-static gint
-gst_autoplug_rank_compare (const GstElementFactory *a, const GstElementFactory *b)
+static gint
+gst_autoplug_rank_compare (const GstElementFactory * a,
+ const GstElementFactory * b)
{
- if (GST_PLUGIN_FEATURE (a)->rank > GST_PLUGIN_FEATURE (b)->rank) return -1;
- return (GST_PLUGIN_FEATURE (a)->rank < GST_PLUGIN_FEATURE (b)->rank) ? 1 : 0;
+ if (GST_PLUGIN_FEATURE (a)->rank > GST_PLUGIN_FEATURE (b)->rank)
+ return -1;
+ return (GST_PLUGIN_FEATURE (a)->rank < GST_PLUGIN_FEATURE (b)->rank) ? 1 : 0;
}
/* returns all factories which have sinks with non-NULL caps and srcs with
* rank descending.
*/
GList *
-gst_autoplug_factories_filters_with_sink_caps (GList *factories)
+gst_autoplug_factories_filters_with_sink_caps (GList * factories)
{
GList *ret = NULL;
GstElementFactory *factory;
GList *templs;
- while (factories)
- {
+ while (factories) {
factory = (GstElementFactory *) factories->data;
templs = factory->padtemplates;
- if (GST_PLUGIN_FEATURE (factory)->rank > 0){
+ if (GST_PLUGIN_FEATURE (factory)->rank > 0) {
gboolean have_src = FALSE;
gboolean have_sink = FALSE;
- while (templs)
- {
- if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC)
- {
- have_src = TRUE;
- }
- if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL))
- {
- have_sink = TRUE;
- }
- if (have_src && have_sink)
- {
- ret = g_list_prepend (ret, factory);
- break;
- }
- templs = g_list_next (templs);
+ while (templs) {
+ if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) {
+ have_src = TRUE;
+ }
+ if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK)
+ && (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL)) {
+ have_sink = TRUE;
+ }
+ if (have_src && have_sink) {
+ ret = g_list_prepend (ret, factory);
+ break;
+ }
+ templs = g_list_next (templs);
}
}
factories = g_list_next (factories);
}
- return g_list_sort(ret, (GCompareFunc)gst_autoplug_rank_compare);
+ return g_list_sort (ret, (GCompareFunc) gst_autoplug_rank_compare);
}
/* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir
*/
GList *
-gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates)
+gst_autoplug_factories_at_most_templates (GList * factories,
+ GstPadDirection dir, guint maxtemplates)
{
GList *ret = NULL;
-
- while (factories)
- {
+
+ while (factories) {
guint count = 0;
GList *templs = ((GstElementFactory *) factories->data)->padtemplates;
- while (templs)
- {
- if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir)
- {
- count++;
+ while (templs) {
+ if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
+ count++;
}
if (count > maxtemplates)
- break;
+ break;
templs = g_list_next (templs);
}
if (count <= maxtemplates)
ret = g_list_prepend (ret, factories->data);
-
+
factories = g_list_next (factories);
}
return ret;
}
+
/*********************************************************************
*
* SHORTEST PATH ALGORITHM
* to get the shortest path.
*/
GList *
-gst_autoplug_sp (const GstCaps *srccaps, const GstCaps *sinkcaps, GList *factories)
+gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps,
+ GList * factories)
{
GList *factory_nodes = NULL;
- guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */
- GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */
-
+ guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */
+ GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */
+
g_return_val_if_fail (srccaps != NULL, NULL);
g_return_val_if_fail (sinkcaps != NULL, NULL);
-
+
GST_INFO ("attempting to autoplug via shortest path from %"
GST_PTR_FORMAT " to %" GST_PTR_FORMAT, srccaps, sinkcaps);
/* wrap all factories as GstAutoplugNode
* initialize the cost */
- while (factories)
- {
+ while (factories) {
GstAutoplugNode *node = g_new0 (GstAutoplugNode, 1);
+
node->prev = NULL;
node->fac = (GstElementFactory *) factories->data;
GST_DEBUG ("trying with %s", node->fac->details.longname);
node->templ = gst_autoplug_can_connect_src (node->fac, srccaps);
- node->cost = (node->templ ? gst_autoplug_get_cost (node->fac)
- : GST_AUTOPLUG_MAX_COST);
+ node->cost = (node->templ ? gst_autoplug_get_cost (node->fac)
+ : GST_AUTOPLUG_MAX_COST);
node->endpoint = gst_autoplug_can_connect_sink (node->fac, sinkcaps);
if (node->templ && node->endpoint)
- GST_DEBUG ("%s makes connection possible",
- node->fac->details.longname);
+ GST_DEBUG ("%s makes connection possible", node->fac->details.longname);
else
GST_DEBUG ("direct connection with %s not possible",
- node->fac->details.longname);
- if ((node->endpoint != NULL) &&
- ((bestnode == NULL) || (node->cost < bestnode->cost)))
- {
+ node->fac->details.longname);
+ if ((node->endpoint != NULL) &&
+ ((bestnode == NULL) || (node->cost < bestnode->cost))) {
bestnode = node;
}
factory_nodes = g_list_prepend (factory_nodes, node);
curcost = node->cost < curcost ? node->cost : curcost;
factories = g_list_next (factories);
}
-
+
/* check if we even have possible endpoints */
- if (bestnode == NULL)
- {
+ if (bestnode == NULL) {
GST_DEBUG ("no factory found that could connect to sink caps");
g_list_free_list_and_elements (factory_nodes);
return NULL;
}
-
+
/* iterate until we found the best path */
- while (curcost < GST_AUTOPLUG_MAX_COST)
- {
+ while (curcost < GST_AUTOPLUG_MAX_COST) {
GList *nodes = factory_nodes;
- guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */
- GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost, GST_OBJECT_NAME (bestnode->fac), bestnode->cost);
+ guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */
+
+ GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost,
+ GST_OBJECT_NAME (bestnode->fac), bestnode->cost);
/* check if we already have a valid best connection to the sink */
- if (bestnode->cost <= curcost)
- {
+ if (bestnode->cost <= curcost) {
GList *ret;
- GST_DEBUG ("found a way to connect via %s", GST_OBJECT_NAME ((GstObject *) bestnode->fac));
+
+ GST_DEBUG ("found a way to connect via %s",
+ GST_OBJECT_NAME ((GstObject *) bestnode->fac));
/* enter all factories into the return list */
ret = g_list_prepend (NULL, bestnode->fac);
bestnode = bestnode->prev;
- while (bestnode != NULL)
- {
- ret = g_list_prepend (ret, bestnode->fac);
- bestnode = bestnode->prev;
+ while (bestnode != NULL) {
+ ret = g_list_prepend (ret, bestnode->fac);
+ bestnode = bestnode->prev;
}
g_list_free_list_and_elements (factory_nodes);
return ret;
}
-
+
/* iterate over all factories we have
* if they have the current cost, calculate if this
* factory supplies shorter paths to other elements
*/
- while (nodes)
- {
- if (((GstAutoplugNode *) nodes->data)->cost == curcost)
- {
- /* now check all elements if we got a shorter path */
- GList *sinknodes = factory_nodes;
- GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data;
- while (sinknodes)
- {
- GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data;
- GstPadTemplate *templ;
- if ((sinknode->cost > srcnode->cost + gst_autoplug_get_cost (sinknode->fac)) && (templ = gst_autoplug_can_match(srcnode->fac, sinknode->fac)))
- {
- /* we got a shorter path
- * now enter that path to that node */
- sinknode->prev = srcnode;
- sinknode->templ = templ;
- sinknode->cost = srcnode->cost + gst_autoplug_get_cost (sinknode->fac);
- /* make sure to set which cost to view next */
- nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost;
- /* did we get a new best node? */
- if (sinknode->endpoint && (sinknode->cost < bestnode->cost))
- {
- bestnode = sinknode;
- }
- }
- sinknodes = g_list_next (sinknodes);
- }
- /* FIXME: for speed remove the item we just iterated with from the factory_nodes
- * but don't free it yet and don't forget to free it.
- */
+ while (nodes) {
+ if (((GstAutoplugNode *) nodes->data)->cost == curcost) {
+ /* now check all elements if we got a shorter path */
+ GList *sinknodes = factory_nodes;
+ GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data;
+
+ while (sinknodes) {
+ GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data;
+ GstPadTemplate *templ;
+
+ if ((sinknode->cost >
+ srcnode->cost + gst_autoplug_get_cost (sinknode->fac))
+ && (templ =
+ gst_autoplug_can_match (srcnode->fac, sinknode->fac))) {
+ /* we got a shorter path
+ * now enter that path to that node */
+ sinknode->prev = srcnode;
+ sinknode->templ = templ;
+ sinknode->cost =
+ srcnode->cost + gst_autoplug_get_cost (sinknode->fac);
+ /* make sure to set which cost to view next */
+ nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost;
+ /* did we get a new best node? */
+ if (sinknode->endpoint && (sinknode->cost < bestnode->cost)) {
+ bestnode = sinknode;
+ }
+ }
+ sinknodes = g_list_next (sinknodes);
+ }
+ /* FIXME: for speed remove the item we just iterated with from the factory_nodes
+ * but don't free it yet and don't forget to free it.
+ */
}
nodes = g_list_next (nodes);
}
curcost = nextcost;
}
-
- GST_DEBUG ("found no path from source caps to sink caps");
+
+ GST_DEBUG ("found no path from source caps to sink caps");
g_list_free_list_and_elements (factory_nodes);
- return NULL;
+ return NULL;
}
/* struct for a node, in the search tree */
typedef struct _GstAutoplugNode GstAutoplugNode;
-
-struct _GstAutoplugNode {
- GstAutoplugNode *prev; /* previous node */
- GstElementFactory *fac; /* factory of element to connect to */
- GstPadTemplate *templ; /* template which can connect */
- guint cost; /* total cost to get here */
- GstPadTemplate *endpoint; /* pad template that can connect to sink caps */
+
+struct _GstAutoplugNode
+{
+ GstAutoplugNode *prev; /* previous node */
+ GstElementFactory *fac; /* factory of element to connect to */
+ GstPadTemplate *templ; /* template which can connect */
+ guint cost; /* total cost to get here */
+ GstPadTemplate *endpoint; /* pad template that can connect to sink caps */
};
/* helper functions */
-gboolean gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink);
-GstPadTemplate * gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src);
-GstPadTemplate * gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink);
-GstPadTemplate * gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest);
-gboolean gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir);
+gboolean gst_autoplug_caps_intersect (const GstCaps * src,
+ const GstCaps * sink);
+GstPadTemplate *gst_autoplug_can_connect_src (GstElementFactory * fac,
+ const GstCaps * src);
+GstPadTemplate *gst_autoplug_can_connect_sink (GstElementFactory * fac,
+ const GstCaps * sink);
+GstPadTemplate *gst_autoplug_can_match (GstElementFactory * src,
+ GstElementFactory * dest);
+gboolean gst_autoplug_factory_has_direction (GstElementFactory * fac,
+ GstPadDirection dir);
#define gst_autoplug_factory_has_sink(fac) gst_autoplug_factory_has_direction((fac), GST_PAD_SINK)
#define gst_autoplug_factory_has_src(fac) gst_autoplug_factory_has_direction((fac), GST_PAD_SRC)
#define gst_autoplug_get_cost(fac) 1
/* factory selections */
-GList * gst_autoplug_factories_sinks (GList *factories);
-GList * gst_autoplug_factories_srcs (GList *factories);
-GList * gst_autoplug_factories_filters (GList *factories);
-GList * gst_autoplug_factories_filters_with_sink_caps(GList *factories);
-GList * gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates);
+GList *gst_autoplug_factories_sinks (GList * factories);
+GList *gst_autoplug_factories_srcs (GList * factories);
+GList *gst_autoplug_factories_filters (GList * factories);
+GList *gst_autoplug_factories_filters_with_sink_caps (GList * factories);
+GList *gst_autoplug_factories_at_most_templates (GList * factories,
+ GstPadDirection dir, guint maxtemplates);
/* shortest path algorithm */
-GList * gst_autoplug_sp (const GstCaps *src_caps, const GstCaps *sink_caps, GList *factories);
+GList *gst_autoplug_sp (const GstCaps * src_caps, const GstCaps * sink_caps,
+ GList * factories);
#endif /* __GST_SEARCHFUNCS_H__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* TODO:
* - handle automatic removal of unneeded elements
#define GST_CAT_DEFAULT gst_spider_debug
/* signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FACTORIES,
/* FILL ME TOO */
/* generic templates */
static GstStaticPadTemplate spider_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src_%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("src_%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
/* standard GObject stuff */
-static void gst_spider_class_init (GstSpiderClass *klass);
-static void gst_spider_init (GstSpider *spider);
-static void gst_spider_dispose (GObject *object);
+static void gst_spider_class_init (GstSpiderClass * klass);
+static void gst_spider_init (GstSpider * spider);
+static void gst_spider_dispose (GObject * object);
/* element class functions */
-static GstPad* gst_spider_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name);
-static void gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_spider_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static GstPad *gst_spider_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
+static void gst_spider_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_spider_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
/* link functions */
-static GstSpiderConnection * gst_spider_link_new (GstSpiderIdentity *src);
-static void gst_spider_link_destroy (GstSpiderConnection *conn);
-static void gst_spider_link_reset (GstSpiderConnection *conn, GstElement *to);
-static void gst_spider_link_add (GstSpiderConnection *conn, GstElement *element);
-static GstSpiderConnection * gst_spider_link_find (GstSpiderIdentity *src);
-static GstSpiderConnection * gst_spider_link_get (GstSpiderIdentity *src);
+static GstSpiderConnection *gst_spider_link_new (GstSpiderIdentity * src);
+static void gst_spider_link_destroy (GstSpiderConnection * conn);
+static void gst_spider_link_reset (GstSpiderConnection * conn, GstElement * to);
+static void gst_spider_link_add (GstSpiderConnection * conn,
+ GstElement * element);
+static GstSpiderConnection *gst_spider_link_find (GstSpiderIdentity * src);
+static GstSpiderConnection *gst_spider_link_get (GstSpiderIdentity * src);
/* autoplugging functions */
-static GstElement * gst_spider_find_element_to_plug (GstElement *src, GstElementFactory *fac, GstPadDirection dir);
-static GstPadLinkReturn gst_spider_plug (GstSpiderConnection *conn);
-static GstPadLinkReturn gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad);
+static GstElement *gst_spider_find_element_to_plug (GstElement * src,
+ GstElementFactory * fac, GstPadDirection dir);
+static GstPadLinkReturn gst_spider_plug (GstSpiderConnection * conn);
+static GstPadLinkReturn gst_spider_plug_from_srcpad (GstSpiderConnection * conn,
+ GstPad * srcpad);
/*static GstPadLinkReturn gst_spider_plug_peers (GstSpider *spider, GstPad *srcpad, GstPad *sinkpad); */
-static GstPadLinkReturn gst_spider_create_and_plug (GstSpiderConnection *conn, GList *plugpath);
+static GstPadLinkReturn gst_spider_create_and_plug (GstSpiderConnection * conn,
+ GList * plugpath);
/* random functions */
-static gchar * gst_spider_unused_elementname (GstBin *bin, const gchar *startwith);
+static gchar *gst_spider_unused_elementname (GstBin * bin,
+ const gchar * startwith);
/* debugging stuff
static void print_spider_contents (GstSpider *spider);
static void print_spider_link (GstSpiderConnection *conn); */
/* === variables === */
-static GstElementClass * parent_class = NULL;
+static GstElementClass *parent_class = NULL;
/* no signals yet
static guint gst_spider_signals[LAST_SIGNAL] = { 0 };*/
/* GObject and GStreamer init functions */
GType
-gst_spider_get_type(void)
+gst_spider_get_type (void)
{
static GType spider_type = 0;
if (!spider_type) {
static const GTypeInfo spider_info = {
- sizeof(GstSpiderClass),
+ sizeof (GstSpiderClass),
NULL,
NULL,
(GClassInitFunc) gst_spider_class_init,
NULL,
NULL,
- sizeof(GstSpider),
+ sizeof (GstSpider),
0,
- (GInstanceInitFunc)gst_spider_init,
+ (GInstanceInitFunc) gst_spider_init,
};
- spider_type = g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0);
+ spider_type =
+ g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0);
}
return spider_type;
}
static void
-gst_spider_class_init (GstSpiderClass *klass)
+gst_spider_class_init (GstSpiderClass * klass)
{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_BIN);
+ parent_class = g_type_class_ref (GST_TYPE_BIN);
/* properties */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FACTORIES,
- g_param_spec_pointer ("factories", "allowed factories", "allowed factories for autoplugging", G_PARAM_READWRITE));
+ g_param_spec_pointer ("factories", "allowed factories",
+ "allowed factories for autoplugging", G_PARAM_READWRITE));
gobject_class->set_property = gst_spider_set_property;
gobject_class->get_property = gst_spider_get_property;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_src_factory));
gst_element_class_set_details (gstelement_class, &gst_spider_details);
-
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_request_new_pad);
+
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_spider_request_new_pad);
}
-static void
-gst_spider_init (GstSpider *spider)
+static void
+gst_spider_init (GstSpider * spider)
{
/* use only elements which have sources and sinks and where the sinks have caps */
/* FIXME: How do we handle factories that are added after the spider was constructed? */
- spider->factories = gst_autoplug_factories_filters_with_sink_caps ((GList *)
- gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY));
+ spider->factories = gst_autoplug_factories_filters_with_sink_caps ((GList *)
+ gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY));
spider->links = NULL;
spider->sink_ident = gst_spider_identity_new_sink ("sink_ident");
gst_bin_add (GST_BIN (spider), GST_ELEMENT (spider->sink_ident));
- gst_element_add_ghost_pad (GST_ELEMENT(spider), spider->sink_ident->sink, "sink");
-
+ gst_element_add_ghost_pad (GST_ELEMENT (spider), spider->sink_ident->sink,
+ "sink");
+
}
static void
-gst_spider_dispose (GObject *object)
+gst_spider_dispose (GObject * object)
{
GstSpider *spider;
-
+
spider = GST_SPIDER (object);
g_list_free (spider->factories);
-
+
((GObjectClass *) parent_class)->dispose (object);
}
static GstPad *
-gst_spider_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+gst_spider_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
GstPad *returnpad;
gchar *padname;
GstSpiderIdentity *identity;
GstSpider *spider;
-
+
g_return_val_if_fail (templ != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
- g_return_val_if_fail (GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC, NULL);
-
+ g_return_val_if_fail (GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC,
+ NULL);
+
spider = GST_SPIDER (element);
-
+
/* create an identity object, so we have a pad */
- padname = gst_spider_unused_elementname ((GstBin *)spider, "src_");
+ padname = gst_spider_unused_elementname ((GstBin *) spider, "src_");
identity = gst_spider_identity_new_src (padname);
returnpad = identity->src;
-
+
/* FIXME: use the requested name for the pad */
- gst_object_replace ((GstObject **) &returnpad->padtemplate, (GstObject *) templ);
-
+ gst_object_replace ((GstObject **) & returnpad->padtemplate,
+ (GstObject *) templ);
+
gst_bin_add (GST_BIN (element), GST_ELEMENT (identity));
-
+
returnpad = gst_element_add_ghost_pad (element, returnpad, padname);
g_free (padname);
gst_spider_link_new (identity);
- GST_DEBUG ("successuflly created requested pad %s:%s", GST_DEBUG_PAD_NAME (returnpad));
-
+ GST_DEBUG ("successuflly created requested pad %s:%s",
+ GST_DEBUG_PAD_NAME (returnpad));
+
return returnpad;
}
static void
-gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_spider_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSpider *spider;
GList *list;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SPIDER (object));
switch (prop_id) {
case ARG_FACTORIES:
list = (GList *) g_value_get_pointer (value);
- while (list)
- {
+ while (list) {
g_return_if_fail (list->data != NULL);
g_return_if_fail (GST_IS_ELEMENT_FACTORY (list->data));
list = g_list_next (list);
}
}
static void
-gst_spider_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_spider_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSpider *spider;
/* it's not null if we got it, but it might not be ours */
- spider = GST_SPIDER(object);
+ spider = GST_SPIDER (object);
switch (prop_id) {
case ARG_FACTORIES:
break;
}
}
+
/* get a name for an element that isn't used yet */
static gchar *
-gst_spider_unused_elementname (GstBin *bin, const gchar *startwith)
+gst_spider_unused_elementname (GstBin * bin, const gchar * startwith)
{
- gchar * name = g_strdup_printf ("%s%d", startwith, 0);
+ gchar *name = g_strdup_printf ("%s%d", startwith, 0);
guint i;
-
- for (i = 0; gst_bin_get_by_name (bin, name) != NULL; )
- {
+
+ for (i = 0; gst_bin_get_by_name (bin, name) != NULL;) {
g_free (name);
name = g_strdup_printf ("%s%d", startwith, ++i);
}
-
+
return name;
}
static void
-gst_spider_link_sometimes (GstElement *src, GstPad *pad, GstSpiderConnection *conn)
+gst_spider_link_sometimes (GstElement * src, GstPad * pad,
+ GstSpiderConnection * conn)
{
gulong signal_id = conn->signal_id;
-
+
/* try to autoplug the elements */
if (gst_spider_plug_from_srcpad (conn, pad) != GST_PAD_LINK_REFUSED) {
- GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink));
+ GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback",
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink));
g_signal_handler_disconnect (src, signal_id);
signal_id = 0;
}
}
+
/* create a new link from those two elements */
static GstSpiderConnection *
-gst_spider_link_new (GstSpiderIdentity *src)
+gst_spider_link_new (GstSpiderIdentity * src)
{
GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (src));
-
+
GstSpiderConnection *conn = g_new0 (GstSpiderConnection, 1);
+
conn->src = src;
conn->path = NULL;
conn->current = (GstElement *) spider->sink_ident;
spider->links = g_list_prepend (spider->links, conn);
-
+
return conn;
}
static void
-gst_spider_link_destroy (GstSpiderConnection *conn)
+gst_spider_link_destroy (GstSpiderConnection * conn)
{
GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (conn->src));
+
/* reset link to unplugged */
gst_spider_link_reset (conn, (GstElement *) spider->sink_ident);
g_free (conn);
}
static void
-gst_spider_link_reset (GstSpiderConnection *conn, GstElement *to)
+gst_spider_link_reset (GstSpiderConnection * conn, GstElement * to)
{
GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (conn->src));
- GST_DEBUG ("resetting link from %s to %s, currently at %s to %s", GST_ELEMENT_NAME (spider->sink_ident),
- GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (to));
- while ((conn->path != NULL) && ((GstElement *) conn->path->data != to))
- {
+
+ GST_DEBUG ("resetting link from %s to %s, currently at %s to %s",
+ GST_ELEMENT_NAME (spider->sink_ident), GST_ELEMENT_NAME (conn->src),
+ GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (to));
+ while ((conn->path != NULL) && ((GstElement *) conn->path->data != to)) {
gst_object_unref ((GstObject *) conn->path->data);
conn->path = g_list_delete_link (conn->path, conn->path);
}
- if (conn->path == NULL)
- {
+ if (conn->path == NULL) {
conn->current = (GstElement *) spider->sink_ident;
} else {
conn->current = to;
}
}
+
/* add an element to the link */
static void
-gst_spider_link_add (GstSpiderConnection *conn, GstElement *element)
+gst_spider_link_add (GstSpiderConnection * conn, GstElement * element)
{
gst_object_ref ((GstObject *) element);
gst_object_sink ((GstObject *) element);
conn->path = g_list_prepend (conn->path, element);
conn->current = element;
}
+
/* find the link from those two elements */
static GstSpiderConnection *
-gst_spider_link_find (GstSpiderIdentity *src)
+gst_spider_link_find (GstSpiderIdentity * src)
{
GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (src);
GList *list = spider->links;
-
- while (list)
- {
+
+ while (list) {
GstSpiderConnection *conn = (GstSpiderConnection *) list->data;
- if (conn->src == src){
+
+ if (conn->src == src) {
return conn;
}
- list = g_list_next(list);
+ list = g_list_next (list);
}
return NULL;
}
+
/* get a new link from those two elements
* search first; if none is found, create a new one */
static GstSpiderConnection *
-gst_spider_link_get (GstSpiderIdentity *src)
+gst_spider_link_get (GstSpiderIdentity * src)
{
GstSpiderConnection *ret;
-
- if ((ret = gst_spider_link_find (src)) != NULL)
- {
+
+ if ((ret = gst_spider_link_find (src)) != NULL) {
return ret;
}
return gst_spider_link_new (src);
-}
-void
-gst_spider_identity_plug (GstSpiderIdentity *ident)
+}
+
+void
+gst_spider_identity_plug (GstSpiderIdentity * ident)
{
GstSpider *spider;
const GList *padlist;
GstPadDirection dir;
GstSpiderConnection *conn;
-
+
/* checks */
g_return_if_fail (ident != NULL);
g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident));
spider = GST_SPIDER (GST_ELEMENT_PARENT (ident));
g_assert (spider != NULL);
g_assert (GST_IS_SPIDER (spider));
-
+
/* return if we're already plugged */
- if (ident->plugged) return;
+ if (ident->plugged)
+ return;
/* check if there is at least one element factory that can handle the
identity's src caps */
{
GstCaps *src_caps = gst_pad_get_caps (ident->src);
- if (! gst_caps_is_empty (src_caps) && ! gst_caps_is_any (src_caps))
- {
+
+ if (!gst_caps_is_empty (src_caps) && !gst_caps_is_any (src_caps)) {
GList *factories;
GstPadTemplate *padtemp;
gboolean found = FALSE;
factories = spider->factories;
- while (factories)
- {
- if ((padtemp = gst_autoplug_can_connect_src (factories->data, src_caps)))
- {
- const GstCaps *caps = gst_pad_template_get_caps (padtemp);
- GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps);
- found = TRUE;
- }
- factories = factories->next;
+ while (factories) {
+ if ((padtemp =
+ gst_autoplug_can_connect_src (factories->data, src_caps))) {
+ const GstCaps *caps = gst_pad_template_get_caps (padtemp);
+
+ GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps);
+ found = TRUE;
+ }
+ factories = factories->next;
}
- if (!found)
- {
+ if (!found) {
const char *mime;
mime = gst_structure_get_name (gst_caps_get_structure (src_caps, 0));
- GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND,
- (_("There is no element present to handle the stream's mime type %s."), mime),
- (NULL));
+ GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND,
+ (_("There is no element present to handle the stream's mime type %s."), mime), (NULL));
gst_caps_free (src_caps);
return;
}
/* get the direction of our ident */
- if (GST_PAD_PEER (ident->sink))
- {
- if (GST_PAD_PEER (ident->src))
- {
+ if (GST_PAD_PEER (ident->sink)) {
+ if (GST_PAD_PEER (ident->src)) {
/* Hey, the ident is linked on both sides */
g_warning ("Trying to autoplug a linked element. Aborting...");
return;
dir = GST_PAD_SINK;
}
} else {
- if (GST_PAD_PEER (ident->src))
- {
+ if (GST_PAD_PEER (ident->src)) {
dir = GST_PAD_SRC;
} else {
/* the ident isn't linked on either side */
/* now iterate all possible pads and link when needed */
padlist = gst_element_get_pad_list (GST_ELEMENT (spider));
- while (padlist)
- {
+ while (padlist) {
GstPad *otherpad;
GstSpiderIdentity *peer;
otherpad = (GstPad *) GST_GPAD_REALPAD (padlist->data);
peer = (GstSpiderIdentity *) GST_PAD_PARENT (otherpad);
/* we only want to link to the other side */
- if (dir != GST_PAD_DIRECTION (otherpad))
- {
+ if (dir != GST_PAD_DIRECTION (otherpad)) {
/* we only link to plugged in elements */
- if (peer->plugged == TRUE)
- {
- /* plug in the right direction */
- if (dir == GST_PAD_SINK)
- {
+ if (peer->plugged == TRUE) {
+ /* plug in the right direction */
+ if (dir == GST_PAD_SINK) {
conn = gst_spider_link_get (peer);
- } else {
+ } else {
conn = gst_spider_link_get (ident);
- }
- if ((GstElement *) spider->sink_ident == conn->current)
- {
+ }
+ if ((GstElement *) spider->sink_ident == conn->current) {
gst_spider_plug (conn);
}
}
}
padlist = g_list_next (padlist);
}
-
- ident->plugged = TRUE;
+
+ ident->plugged = TRUE;
}
+
void
-gst_spider_identity_unplug (GstSpiderIdentity *ident)
+gst_spider_identity_unplug (GstSpiderIdentity * ident)
{
GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (ident);
GList *list = spider->links;
-
- while (list)
- {
+
+ while (list) {
GstSpiderConnection *conn = list->data;
GList *cur = list;
+
list = g_list_next (list);
- if (conn->src == ident)
- {
+ if (conn->src == ident) {
g_list_delete_link (spider->links, cur);
gst_spider_link_destroy (conn);
}
}
ident->plugged = FALSE;
}
+
/* links src to sink using the elementfactories in plugpath
* plugpath will be removed afterwards */
static GstPadLinkReturn
-gst_spider_create_and_plug (GstSpiderConnection *conn, GList *plugpath)
+gst_spider_create_and_plug (GstSpiderConnection * conn, GList * plugpath)
{
GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (conn->src);
GList *endelements = NULL, *templist = NULL;
GstElement *element;
-
+
/* exit if plugging is already done */
if ((GstElement *) conn->src == conn->current)
return GST_PAD_LINK_DONE;
-
+
/* try to shorten the list at the end and not duplicate link code */
- if (plugpath != NULL)
- {
+ if (plugpath != NULL) {
templist = g_list_last (plugpath);
element = (GstElement *) conn->src;
- while ((plugpath != NULL) && (element = gst_spider_find_element_to_plug (element, (GstElementFactory *) plugpath->data, GST_PAD_SINK)))
- {
+ while ((plugpath != NULL)
+ && (element =
+ gst_spider_find_element_to_plug (element,
+ (GstElementFactory *) plugpath->data, GST_PAD_SINK))) {
GList *cur = templist;
+
endelements = g_list_prepend (endelements, element);
templist = g_list_previous (templist);
- g_list_delete_link (cur, cur);
+ g_list_delete_link (cur, cur);
}
}
-
+
/* do the linking */
- while (conn->current != (GstElement *) (endelements == NULL ? conn->src : endelements->data))
- {
+ while (conn->current != (GstElement *) (endelements ==
+ NULL ? conn->src : endelements->data)) {
/* get sink element to plug, src is conn->current */
- if (plugpath == NULL)
- {
- element = (GstElement *) (endelements == NULL ? conn->src : endelements->data);
+ if (plugpath == NULL) {
+ element =
+ (GstElement *) (endelements == NULL ? conn->src : endelements->data);
} else {
- element = gst_element_factory_create ((GstElementFactory *) plugpath->data, NULL);
- GST_DEBUG ("Adding element %s of type %s and syncing state with autoplugger",
- GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data));
+ element =
+ gst_element_factory_create ((GstElementFactory *) plugpath->data,
+ NULL);
+ GST_DEBUG
+ ("Adding element %s of type %s and syncing state with autoplugger",
+ GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data));
gst_bin_add (GST_BIN (spider), element);
}
/* insert and link new element */
if (gst_element_link (conn->current, element)) {
- gst_element_sync_state_with_parent (element);
+ gst_element_sync_state_with_parent (element);
} else {
/* check if the src has SOMETIMES templates. If so, link a callback */
GList *templs = gst_element_get_pad_template_list (conn->current);
-
+
/* remove element that couldn't be linked, if it wasn't the endpoint */
if (element != (GstElement *) conn->src)
- gst_bin_remove (GST_BIN (spider), element);
-
+ gst_bin_remove (GST_BIN (spider), element);
+
while (templs) {
- GstPadTemplate *templ = (GstPadTemplate *) templs->data;
- if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
- {
- GST_DEBUG ("adding callback to link element %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
- conn->signal_id = g_signal_connect (G_OBJECT (conn->current), "new_pad",
- G_CALLBACK (gst_spider_link_sometimes), conn);
+ GstPadTemplate *templ = (GstPadTemplate *) templs->data;
+
+ if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC)
+ && (GST_PAD_TEMPLATE_PRESENCE (templ) == GST_PAD_SOMETIMES)) {
+ GST_DEBUG ("adding callback to link element %s to %s",
+ GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
+ conn->signal_id =
+ g_signal_connect (G_OBJECT (conn->current), "new_pad",
+ G_CALLBACK (gst_spider_link_sometimes), conn);
g_list_free (plugpath);
return GST_PAD_LINK_DELAYED;
- }
- templs = g_list_next (templs);
+ }
+ templs = g_list_next (templs);
}
- GST_DEBUG ("no chance to link element %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
+ GST_DEBUG ("no chance to link element %s to %s",
+ GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
g_list_free (plugpath);
return GST_PAD_LINK_REFUSED;
}
- GST_DEBUG ("added element %s and attached it to element %s", GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current));
+ GST_DEBUG ("added element %s and attached it to element %s",
+ GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current));
gst_spider_link_add (conn, element);
if (plugpath != NULL)
plugpath = g_list_delete_link (plugpath, plugpath);
}
-
+
/* ref all elements at the end */
- while (endelements)
- {
+ while (endelements) {
gst_spider_link_add (conn, endelements->data);
endelements = g_list_delete_link (endelements, endelements);
}
-
+
return GST_PAD_LINK_DONE;
}
+
/* checks, if src is already linked to an element from factory fac on direction dir */
static GstElement *
-gst_spider_find_element_to_plug (GstElement *src, GstElementFactory *fac, GstPadDirection dir)
+gst_spider_find_element_to_plug (GstElement * src, GstElementFactory * fac,
+ GstPadDirection dir)
{
GList *padlist = GST_ELEMENT_PADS (src);
-
- while (padlist)
- {
+
+ while (padlist) {
GstPad *pad = (GstPad *) GST_PAD_REALIZE (padlist->data);
+
/* is the pad on the right side and is it linked? */
- if ((GST_PAD_DIRECTION (pad) == dir) && (pad = (GstPad *) (GST_RPAD_PEER (pad))))
- {
+ if ((GST_PAD_DIRECTION (pad) == dir)
+ && (pad = (GstPad *) (GST_RPAD_PEER (pad)))) {
/* is the element the pad is linked to of the right type? */
GstElement *element = GST_PAD_PARENT (pad);
-
- if (G_TYPE_FROM_INSTANCE (element) == gst_element_factory_get_element_type (fac)) {
- return element;
+
+ if (G_TYPE_FROM_INSTANCE (element) ==
+ gst_element_factory_get_element_type (fac)) {
+ return element;
}
}
padlist = g_list_next (padlist);
}
-
+
return NULL;
}
+
/* try to establish the link */
static GstPadLinkReturn
-gst_spider_plug (GstSpiderConnection *conn)
+gst_spider_plug (GstSpiderConnection * conn)
{
GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (conn->src);
+
if ((GstElement *) conn->src == conn->current)
return GST_PAD_LINK_DONE;
if ((GstElement *) spider->sink_ident == conn->current)
return gst_spider_plug_from_srcpad (conn, spider->sink_ident->src);
- g_warning ("FIXME: autoplugging only possible from GstSpiderIdentity conn->sink yet (yep, that's technical)\n");
+ g_warning
+ ("FIXME: autoplugging only possible from GstSpiderIdentity conn->sink yet (yep, that's technical)\n");
return GST_PAD_LINK_REFUSED;
}
+
/* try to establish the link using this pad */
static GstPadLinkReturn
-gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad)
+gst_spider_plug_from_srcpad (GstSpiderConnection * conn, GstPad * srcpad)
{
GstElement *element;
GList *plugpath;
GstCaps *caps2;
g_assert ((GstElement *) GST_OBJECT_PARENT (srcpad) == conn->current);
- GST_DEBUG ("trying to plug from %s:%s to %s",
- GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (conn->src));
-
+ GST_DEBUG ("trying to plug from %s:%s to %s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (conn->src));
+
/* see if they match already */
if (gst_pad_link (srcpad, conn->src->sink)) {
- GST_DEBUG ("%s:%s and %s:%s can link directly",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink));
+ GST_DEBUG ("%s:%s and %s:%s can link directly",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink));
gst_pad_unlink (srcpad, conn->src->sink);
gst_spider_create_and_plug (conn, NULL);
return GST_PAD_LINK_OK;
}
-
+
/* find a path from src to sink */
caps1 = gst_pad_get_caps (srcpad);
caps2 = gst_pad_get_caps (conn->src->sink);
plugpath = gst_autoplug_sp (caps1, caps2, spider->factories);
gst_caps_free (caps1);
gst_caps_free (caps2);
-
+
/* prints out the path that was found for plugging */
/* g_print ("found path from %s to %s:\n", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
- templist = plugpath;
- while (templist)
- {
- g_print("%s\n", GST_OBJECT_NAME (templist->data));
- templist = g_list_next (templist);
- }*/
-
+ templist = plugpath;
+ while (templist)
+ {
+ g_print("%s\n", GST_OBJECT_NAME (templist->data));
+ templist = g_list_next (templist);
+ } */
+
/* if there is no way to plug: return */
if (plugpath == NULL) {
- GST_DEBUG ("no chance to plug from %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
+ GST_DEBUG ("no chance to plug from %s to %s",
+ GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
return GST_PAD_LINK_REFUSED;
}
GST_DEBUG ("found a link that needs %d elements", g_list_length (plugpath));
* plugging and alter the plugpath to represent the elements, that must be plugged
*/
element = conn->current;
- while ((plugpath != NULL) && (element = gst_spider_find_element_to_plug (element, (GstElementFactory *) plugpath->data, GST_PAD_SRC)))
- {
+ while ((plugpath != NULL)
+ && (element =
+ gst_spider_find_element_to_plug (element,
+ (GstElementFactory *) plugpath->data, GST_PAD_SRC))) {
gst_spider_link_add (conn, element);
plugpath = g_list_delete_link (plugpath, plugpath);
}
-
- GST_DEBUG ("%d elements must be inserted to establish the link", g_list_length (plugpath));
+
+ GST_DEBUG ("%d elements must be inserted to establish the link",
+ g_list_length (plugpath));
/* create the elements and plug them */
result = gst_spider_create_and_plug (conn, plugpath);
-
+
/* reset the "current" element */
- if (result == GST_PAD_LINK_REFUSED)
- {
- gst_spider_link_reset (conn, startelement);
+ if (result == GST_PAD_LINK_REFUSED) {
+ gst_spider_link_reset (conn, startelement);
}
-
- return result;
+
+ return result;
}
-GstElementDetails gst_spider_details = GST_ELEMENT_DETAILS (
- "Spider",
- "Generic",
- "Automatically link sinks and sources",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+GstElementDetails gst_spider_details = GST_ELEMENT_DETAILS ("Spider",
+ "Generic",
+ "Automatically link sinks and sources",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- GST_DEBUG_CATEGORY_INIT (gst_spider_debug, "spider", 0, "spider autoplugging element");
+ GST_DEBUG_CATEGORY_INIT (gst_spider_debug, "spider", 0,
+ "spider autoplugging element");
- if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY, GST_TYPE_SPIDER))
+ if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY,
+ GST_TYPE_SPIDER))
return FALSE;
- if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE, GST_TYPE_SPIDER_IDENTITY))
+ if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE,
+ GST_TYPE_SPIDER_IDENTITY))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstspider",
- "a 1:n autoplugger",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstspider",
+ "a 1:n autoplugger",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_SPIDER_H__
#define __GST_SPIDER_H__
#include <gst/gst.h>
#include "gstspideridentity.h"
-G_BEGIN_DECLS
-
-extern GstElementDetails gst_spider_details;
-GST_DEBUG_CATEGORY_EXTERN(gst_spider_debug);
+G_BEGIN_DECLS extern GstElementDetails gst_spider_details;
+
+GST_DEBUG_CATEGORY_EXTERN (gst_spider_debug);
/*
* Theory of operation:
* are refcounted once for every path.
* A GstSpider keeps a list of all GstSpiderConnections in it.
*/
-typedef struct {
+typedef struct
+{
GstSpiderIdentity *src;
/* dunno if the path should stay here or if its too much load.
* it's at least easier then always searching it */
#define GST_SPIDER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPIDER,GstSpider))
#define GST_SPIDER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPIDER,GstSpiderClass))
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPIDER,GstSpiderClass))
#define GST_IS_SPIDER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPIDER))
#define GST_IS_SPIDER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPIDER))
-
+
typedef struct _GstSpider GstSpider;
typedef struct _GstSpiderClass GstSpiderClass;
-struct _GstSpider {
- GstBin parent;
-
+struct _GstSpider
+{
+ GstBin parent;
+
GstSpiderIdentity *sink_ident;
- GList * factories; /* factories to use for plugging */
+ GList *factories; /* factories to use for plugging */
- GList * links; /* GStSpiderConnection list of all links */
+ GList *links; /* GStSpiderConnection list of all links */
};
-
-struct _GstSpiderClass {
+
+struct _GstSpiderClass
+{
GstBinClass parent_class;
};
/* default initialization stuff */
-GType gst_spider_get_type (void);
+GType gst_spider_get_type (void);
/* private link functions to be called by GstSpiderIdentity */
-void gst_spider_identity_plug (GstSpiderIdentity *ident);
-void gst_spider_identity_unplug (GstSpiderIdentity *ident);
+void gst_spider_identity_plug (GstSpiderIdentity * ident);
+void gst_spider_identity_unplug (GstSpiderIdentity * ident);
G_END_DECLS
-
#endif /* __GST_SPIDER_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_spider_identity_debug);
#define GST_CAT_DEFAULT gst_spider_identity_debug
-static GstElementDetails gst_spider_identity_details = GST_ELEMENT_DETAILS (
- "SpiderIdentity",
- "Generic",
- "Link between spider and outside elements",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+static GstElementDetails gst_spider_identity_details =
+GST_ELEMENT_DETAILS ("SpiderIdentity",
+ "Generic",
+ "Link between spider and outside elements",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* generic templates
* delete me when meging with spider.c
*/
-static GstStaticPadTemplate spider_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+static GstStaticPadTemplate spider_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate spider_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
/* SpiderIdentity signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
/* GObject stuff */
-static void gst_spider_identity_class_init (GstSpiderIdentityClass *klass);
-static void gst_spider_identity_init (GstSpiderIdentity *spider_identity);
+static void gst_spider_identity_class_init (GstSpiderIdentityClass * klass);
+static void gst_spider_identity_init (GstSpiderIdentity * spider_identity);
/* functions set in pads, elements and stuff */
-static void gst_spider_identity_chain (GstPad *pad, GstBuffer *buf);
-static GstElementStateReturn gst_spider_identity_change_state (GstElement *element);
-static GstPadLinkReturn gst_spider_identity_link (GstPad *pad, const GstCaps *caps);
-static GstCaps * gst_spider_identity_getcaps (GstPad *pad);
+static void gst_spider_identity_chain (GstPad * pad, GstBuffer * buf);
+static GstElementStateReturn gst_spider_identity_change_state (GstElement *
+ element);
+static GstPadLinkReturn gst_spider_identity_link (GstPad * pad,
+ const GstCaps * caps);
+static GstCaps *gst_spider_identity_getcaps (GstPad * pad);
+
/* loop functions */
-static void gst_spider_identity_dumb_loop (GstSpiderIdentity *ident);
-static void gst_spider_identity_src_loop (GstSpiderIdentity *ident);
-static void gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident);
+static void gst_spider_identity_dumb_loop (GstSpiderIdentity * ident);
+static void gst_spider_identity_src_loop (GstSpiderIdentity * ident);
+static void gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *
+ ident);
-static gboolean gst_spider_identity_handle_src_event (GstPad *pad, GstEvent *event);
+static gboolean gst_spider_identity_handle_src_event (GstPad * pad,
+ GstEvent * event);
/* other functions */
-static void gst_spider_identity_start_type_finding (GstSpiderIdentity *ident);
+static void gst_spider_identity_start_type_finding (GstSpiderIdentity * ident);
+
+static GstElementClass *parent_class = NULL;
-static GstElementClass * parent_class = NULL;
/* no signals
static guint gst_spider_identity_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_spider_identity_get_type (void)
+gst_spider_identity_get_type (void)
{
static GType spider_identity_type = 0;
if (!spider_identity_type) {
static const GTypeInfo spider_identity_info = {
- sizeof(GstSpiderIdentityClass), NULL,
+ sizeof (GstSpiderIdentityClass), NULL,
NULL,
- (GClassInitFunc)gst_spider_identity_class_init,
+ (GClassInitFunc) gst_spider_identity_class_init,
NULL,
NULL,
- sizeof(GstSpiderIdentity),
+ sizeof (GstSpiderIdentity),
0,
- (GInstanceInitFunc)gst_spider_identity_init,
+ (GInstanceInitFunc) gst_spider_identity_init,
};
- spider_identity_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity",
- &spider_identity_info, 0);
- GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity",
- 0, "spider autoplugging proxy element");
+ spider_identity_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity",
+ &spider_identity_info, 0);
+ GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", 0,
+ "spider autoplugging proxy element");
}
return spider_identity_type;
}
-static void
-gst_spider_identity_class_init (GstSpiderIdentityClass *klass)
+static void
+gst_spider_identity_class_init (GstSpiderIdentityClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
-
+
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
+
/* add our two pad templates */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_src_factory));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&spider_sink_factory));
- gst_element_class_set_details (gstelement_class, &gst_spider_identity_details);
-
- gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_spider_identity_change_state);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_identity_request_new_pad);
+ gst_element_class_set_details (gstelement_class,
+ &gst_spider_identity_details);
+
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_spider_identity_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_spider_identity_request_new_pad);
}
-static void
-gst_spider_identity_init (GstSpiderIdentity *ident)
+static void
+gst_spider_identity_init (GstSpiderIdentity * ident)
{
/* sink */
- ident->sink = gst_pad_new_from_template (
- gst_static_pad_template_get (&spider_sink_factory), "sink");
+ ident->sink =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&spider_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (ident), ident->sink);
- gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
- gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
+ gst_pad_set_link_function (ident->sink,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_link));
+ gst_pad_set_getcaps_function (ident->sink,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
/* src */
- ident->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&spider_src_factory), "src");
+ ident->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&spider_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (ident), ident->src);
- gst_pad_set_link_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
- gst_pad_set_getcaps_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
- gst_pad_set_event_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event));
+ gst_pad_set_link_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_link));
+ gst_pad_set_getcaps_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
+ gst_pad_set_event_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event));
/* variables */
ident->plugged = FALSE;
}
-static void
-gst_spider_identity_chain (GstPad *pad, GstBuffer *buf)
+static void
+gst_spider_identity_chain (GstPad * pad, GstBuffer * buf)
{
GstSpiderIdentity *ident;
-
- /*g_print ("chaining on pad %s:%s with buffer %p\n", GST_DEBUG_PAD_NAME (pad), buf);*/
+
+ /*g_print ("chaining on pad %s:%s with buffer %p\n", GST_DEBUG_PAD_NAME (pad), buf); */
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
- if (buf == NULL) return;
+ if (buf == NULL)
+ return;
ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buf)) {
/* start hack for current event stuff here */
/* check for unlinked elements and send them the EOS event, too */
- if (GST_EVENT_TYPE (GST_EVENT (buf)) == GST_EVENT_EOS)
- {
+ if (GST_EVENT_TYPE (GST_EVENT (buf)) == GST_EVENT_EOS) {
GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (ident);
GList *list = spider->links;
- while (list)
- {
+
+ while (list) {
GstSpiderConnection *conn = (GstSpiderConnection *) list->data;
+
list = g_list_next (list);
- if (conn->current != (GstElement *) conn->src) {
- GST_DEBUG ("sending EOS to unconnected element %s from %s",
- GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident));
- gst_pad_push (conn->src->src, GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS))));
- gst_element_set_eos (GST_ELEMENT (conn->src));
+ if (conn->current != (GstElement *) conn->src) {
+ GST_DEBUG ("sending EOS to unconnected element %s from %s",
+ GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident));
+ gst_pad_push (conn->src->src,
+ GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS))));
+ gst_element_set_eos (GST_ELEMENT (conn->src));
}
}
}
if ((ident->src != NULL) && (GST_PAD_PEER (ident->src) != NULL)) {
/* g_print("pushing buffer %p (refcount %d - buffersize %d) to pad %s:%s\n", buf, GST_BUFFER_REFCOUNT (buf), GST_BUFFER_SIZE (buf), GST_DEBUG_PAD_NAME (ident->src)); */
- GST_LOG ( "push %p %" G_GINT64_FORMAT, buf, GST_BUFFER_OFFSET (buf));
+ GST_LOG ("push %p %" G_GINT64_FORMAT, buf, GST_BUFFER_OFFSET (buf));
gst_pad_push (ident->src, GST_DATA (buf));
} else if (GST_IS_BUFFER (buf)) {
gst_buffer_unref (buf);
}
}
-GstSpiderIdentity*
-gst_spider_identity_new_src (gchar *name)
+GstSpiderIdentity *
+gst_spider_identity_new_src (gchar * name)
{
- GstSpiderIdentity *ret = (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
+ GstSpiderIdentity *ret =
+ (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
/* set the right functions */
- gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop));
-
+ gst_element_set_loop_function (GST_ELEMENT (ret),
+ (GstElementLoopFunction)
+ GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop));
+
return ret;
}
-GstSpiderIdentity*
-gst_spider_identity_new_sink (gchar *name)
+
+GstSpiderIdentity *
+gst_spider_identity_new_sink (gchar * name)
{
- GstSpiderIdentity *ret = (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
+ GstSpiderIdentity *ret =
+ (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
/* set the right functions */
- gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
+ gst_element_set_loop_function (GST_ELEMENT (ret),
+ (GstElementLoopFunction)
+ GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
return ret;
}
/* shamelessly stolen from gstqueue.c to get proxy links */
static GstPadLinkReturn
-gst_spider_identity_link (GstPad *pad, const GstCaps *caps)
+gst_spider_identity_link (GstPad * pad, const GstCaps * caps)
{
- GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
+ GstSpiderIdentity *spider_identity =
+ GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
GstPad *otherpad;
- if (pad == spider_identity->src)
+ if (pad == spider_identity->src)
otherpad = spider_identity->sink;
else
otherpad = spider_identity->src;
return gst_pad_try_set_caps (otherpad, caps);
}
-static GstCaps*
-gst_spider_identity_getcaps (GstPad *pad)
+static GstCaps *
+gst_spider_identity_getcaps (GstPad * pad)
{
GstSpiderIdentity *ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
GstPad *otherpad;
- if (pad == ident->src)
+ if (pad == ident->src)
otherpad = ident->sink;
else
otherpad = ident->src;
if (otherpad != NULL) {
if (GST_PAD_PEER (otherpad)) {
GstCaps *ret = gst_pad_get_allowed_caps (otherpad);
+
if (ident->caps) {
GstCaps *ret2 = gst_caps_intersect (ident->caps, ret);
+
gst_caps_free (ret);
ret = ret2;
}
return gst_caps_new_any ();
}
-GstPad*
-gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+GstPad *
+gst_spider_identity_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name)
{
GstSpiderIdentity *ident;
-
+
/*checks */
g_return_val_if_fail (templ != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
ident = GST_SPIDER_IDENTITY (element);
g_return_val_if_fail (ident != NULL, NULL);
g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), NULL);
-
- switch (GST_PAD_TEMPLATE_DIRECTION (templ))
- {
+
+ switch (GST_PAD_TEMPLATE_DIRECTION (templ)) {
case GST_PAD_SINK:
- if (ident->sink != NULL) break;
+ if (ident->sink != NULL)
+ break;
/* sink */
- GST_DEBUG ( "element %s requests new sink pad", GST_ELEMENT_NAME(ident));
+ GST_DEBUG ("element %s requests new sink pad", GST_ELEMENT_NAME (ident));
ident->sink = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (ident), ident->sink);
- gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
- gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
+ gst_pad_set_link_function (ident->sink,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_link));
+ gst_pad_set_getcaps_function (ident->sink,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
return ident->sink;
case GST_PAD_SRC:
/* src */
- if (ident->src != NULL) break;
- GST_DEBUG ( "element %s requests new src pad", GST_ELEMENT_NAME(ident));
+ if (ident->src != NULL)
+ break;
+ GST_DEBUG ("element %s requests new src pad", GST_ELEMENT_NAME (ident));
ident->src = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (ident), ident->src);
- gst_pad_set_link_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_link));
- gst_pad_set_getcaps_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
- gst_pad_set_event_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event));
+ gst_pad_set_link_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_link));
+ gst_pad_set_getcaps_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
+ gst_pad_set_event_function (ident->src,
+ GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event));
return ident->src;
default:
break;
}
-
- GST_DEBUG ( "element %s requested a new pad but none could be created", GST_ELEMENT_NAME(ident));
+
+ GST_DEBUG ("element %s requested a new pad but none could be created",
+ GST_ELEMENT_NAME (ident));
return NULL;
}
* ...
*/
static GstElementStateReturn
-gst_spider_identity_change_state (GstElement *element)
+gst_spider_identity_change_state (GstElement * element)
{
GstSpiderIdentity *ident;
GstSpider *spider;
GstElementStateReturn ret = GST_STATE_SUCCESS;
-
+
/* element check */
ident = GST_SPIDER_IDENTITY (element);
g_return_val_if_fail (ident != NULL, GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), GST_STATE_FAILURE);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
gst_caps_replace (&ident->caps, NULL);
spider = GST_SPIDER (GST_ELEMENT_PARENT (ident));
g_return_val_if_fail (spider != NULL, GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_SPIDER (spider), GST_STATE_FAILURE);
-
+
/* start typefinding or plugging */
- if ((GST_RPAD_PEER (ident->sink) != NULL) && (GST_RPAD_PEER (ident->src) == NULL))
- {
- GstCaps *caps = gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink));
- if (gst_caps_is_any (caps) || gst_caps_is_empty (caps))
- {
- gst_spider_identity_start_type_finding (ident);
+ if ((GST_RPAD_PEER (ident->sink) != NULL)
+ && (GST_RPAD_PEER (ident->src) == NULL)) {
+ GstCaps *caps =
+ gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink));
+ if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) {
+ gst_spider_identity_start_type_finding (ident);
gst_caps_free (caps);
- break;
- } else {
- gst_spider_identity_plug (ident);
- }
+ break;
+ } else {
+ gst_spider_identity_plug (ident);
+ }
gst_caps_free (caps);
}
/* autoplug on src */
- if ((GST_RPAD_PEER (ident->src) != NULL) && (GST_RPAD_PEER (ident->sink) == NULL))
- {
- gst_spider_identity_plug (ident);
+ if ((GST_RPAD_PEER (ident->src) != NULL)
+ && (GST_RPAD_PEER (ident->sink) == NULL)) {
+ gst_spider_identity_plug (ident);
}
default:
break;
}
-
- if ((ret != GST_STATE_FAILURE) && (GST_ELEMENT_CLASS (parent_class)->change_state))
+
+ if ((ret != GST_STATE_FAILURE)
+ && (GST_ELEMENT_CLASS (parent_class)->change_state))
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return ret;
}
static void
-gst_spider_identity_start_type_finding (GstSpiderIdentity *ident)
+gst_spider_identity_start_type_finding (GstSpiderIdentity * ident)
{
/* GstElement* typefind;
gchar *name;*/
gboolean restart = FALSE;
-
- GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME(ident));
- if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING)
- {
- gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), GST_STATE_PAUSED);
+
+ GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME (ident));
+ if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING) {
+ gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)),
+ GST_STATE_PAUSED);
restart = TRUE;
}
- gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding));
+ gst_element_set_loop_function (GST_ELEMENT (ident),
+ (GstElementLoopFunction)
+ GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding));
- if (restart)
- {
- gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), GST_STATE_PLAYING);
+ if (restart) {
+ gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)),
+ GST_STATE_PLAYING);
}
}
* we have to use a dumb one
*/
static void
-gst_spider_identity_dumb_loop (GstSpiderIdentity *ident)
+gst_spider_identity_dumb_loop (GstSpiderIdentity * ident)
{
GstBuffer *buf;
gst_spider_identity_chain (ident->sink, buf);
}
+
/* do nothing until we're linked - then disable yourself
*/
static void
-gst_spider_identity_src_loop (GstSpiderIdentity *ident)
+gst_spider_identity_src_loop (GstSpiderIdentity * ident)
{
/* checks - disable for speed */
g_return_if_fail (ident != NULL);
g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident));
-
+
/* we don't want a loop function if we're plugged */
- if (ident->sink && GST_PAD_PEER (ident->sink))
- {
- gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
+ if (ident->sink && GST_PAD_PEER (ident->sink)) {
+ gst_element_set_loop_function (GST_ELEMENT (ident),
+ (GstElementLoopFunction)
+ GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
gst_spider_identity_dumb_loop (ident);
return;
}
gst_element_interrupt (GST_ELEMENT (ident));
}
+
/* This loop function is only needed when typefinding.
*/
-typedef struct {
+typedef struct
+{
GstBuffer *buffer;
guint best_probability;
GstCaps *caps;
spider_find_peek (gpointer data, gint64 offset, guint size)
{
SpiderTypeFind *find = (SpiderTypeFind *) data;
- gint64 buffer_offset = GST_BUFFER_OFFSET_IS_VALID (find->buffer) ?
- GST_BUFFER_OFFSET (find->buffer) : 0;
-
- if (offset >= buffer_offset && offset + size <= buffer_offset + GST_BUFFER_SIZE (find->buffer)) {
- GST_LOG ("peek %"G_GINT64_FORMAT", %u successful", offset, size);
+ gint64 buffer_offset = GST_BUFFER_OFFSET_IS_VALID (find->buffer) ?
+ GST_BUFFER_OFFSET (find->buffer) : 0;
+
+ if (offset >= buffer_offset
+ && offset + size <= buffer_offset + GST_BUFFER_SIZE (find->buffer)) {
+ GST_LOG ("peek %" G_GINT64_FORMAT ", %u successful", offset, size);
return GST_BUFFER_DATA (find->buffer) + offset - buffer_offset;
} else {
- GST_LOG ("peek %"G_GINT64_FORMAT", %u failed", offset, size);
+ GST_LOG ("peek %" G_GINT64_FORMAT ", %u failed", offset, size);
return NULL;
}
}
static void
-spider_find_suggest (gpointer data, guint probability, const GstCaps *caps)
+spider_find_suggest (gpointer data, guint probability, const GstCaps * caps)
{
SpiderTypeFind *find = (SpiderTypeFind *) data;
}
}
static void
-gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
+gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity * ident)
{
GstData *data;
GstTypeFind gst_find;
gst_spider_identity_chain (ident->sink, GST_BUFFER (data));
return;
}
-
+
find.buffer = GST_BUFFER (data);
/* maybe there are already valid caps now? */
find.caps = gst_pad_get_allowed_caps (ident->sink);
gst_caps_free (find.caps);
find.caps = NULL;
}
-
+
/* now do the actual typefinding with the supplied buffer */
walk = type_list = gst_type_find_factory_get_list ();
-
+
find.best_probability = 0;
find.caps = NULL;
gst_find.data = &find;
while (walk) {
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
- GST_DEBUG ("trying typefind function %s", GST_PLUGIN_FEATURE_NAME (factory));
+ GST_DEBUG ("trying typefind function %s",
+ GST_PLUGIN_FEATURE_NAME (factory));
gst_type_find_factory_call_function (factory, &gst_find);
if (find.best_probability >= GST_TYPE_FIND_MAXIMUM)
goto plug;
end:
/* remove loop function */
- gst_element_set_loop_function (GST_ELEMENT (ident),
- (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
-
+ gst_element_set_loop_function (GST_ELEMENT (ident),
+ (GstElementLoopFunction)
+ GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
+
/* push the buffer */
gst_spider_identity_chain (ident->sink, find.buffer);
-
+
return;
plug:
- GST_INFO ("typefind function found caps");
+ GST_INFO ("typefind function found caps");
ident->caps = find.caps;
if (GST_PAD_IS_LINKED (ident->src)) {
GstPadLinkReturn ret;
ret = gst_pad_try_set_caps (ident->src, find.caps);
- if (GST_PAD_LINK_FAILED (ret)){
- g_critical("could not set caps on spideridentity src pad\n");
+ if (GST_PAD_LINK_FAILED (ret)) {
+ g_critical ("could not set caps on spideridentity src pad\n");
}
}
GST_LOG_OBJECT (ident, "spider starting caps: %" GST_PTR_FORMAT, find.caps);
}
static gboolean
-gst_spider_identity_handle_src_event (GstPad *pad, GstEvent *event)
+gst_spider_identity_handle_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
GstSpiderIdentity *ident;
- GST_DEBUG ( "spider_identity src_event");
+ GST_DEBUG ("spider_identity src_event");
ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SPIDER_IDENTITY \
(gst_spider_identity_get_type())
#define GST_SPIDER_IDENTITY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPIDER_IDENTITY))
#define GST_IS_SPIDER_IDENTITY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPIDER_IDENTITY))
-
typedef struct _GstSpiderIdentity GstSpiderIdentity;
typedef struct _GstSpiderIdentityClass GstSpiderIdentityClass;
-struct _GstSpiderIdentity {
+struct _GstSpiderIdentity
+{
GstElement element;
/* sink and source */
GstPad *sink;
GstPad *src;
-
+
/* plugged into autoplugger yet? */
gboolean plugged;
-
+
/* Caps from typefinding */
GstCaps *caps;
};
-struct _GstSpiderIdentityClass {
+struct _GstSpiderIdentityClass
+{
GstElementClass parent_class;
};
-GType gst_spider_identity_get_type (void);
+GType gst_spider_identity_get_type (void);
-GstSpiderIdentity* gst_spider_identity_new_sink (gchar *name);
-GstSpiderIdentity* gst_spider_identity_new_src (gchar *name);
-GstPad* gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name);
+GstSpiderIdentity *gst_spider_identity_new_sink (gchar * name);
+GstSpiderIdentity *gst_spider_identity_new_src (gchar * name);
+GstPad *gst_spider_identity_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
G_END_DECLS
-
#endif /* __GST_SPIDER_IDENTITY_H__ */
/* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir
*/
GList *
-gst_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates)
+gst_factories_at_most_templates (GList * factories, GstPadDirection dir,
+ guint maxtemplates)
{
GList *ret = NULL;
-
- while (factories)
- {
+
+ while (factories) {
guint count = 0;
GList *templs = ((GstElementFactory *) factories->data)->padtemplates;
- while (templs)
- {
- if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir)
- {
- count++;
+ while (templs) {
+ if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
+ count++;
}
if (count > maxtemplates)
- break;
+ break;
templs = g_list_next (templs);
}
if (count <= maxtemplates)
ret = g_list_prepend (ret, factories->data);
-
+
factories = g_list_next (factories);
}
return ret;
}
static void
-property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
+property_change_callback (GObject * object, GstObject * orig,
+ GParamSpec * pspec)
{
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
+ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0;
-
+
if (pspec->flags & G_PARAM_READABLE) {
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (G_OBJECT (orig), pspec->name, &value);
if (G_IS_PARAM_SPEC_STRING (pspec))
str = g_value_dup_string (&value);
str = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (&value));
else
str = g_strdup_value_contents (&value);
-
+
g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
g_free (str);
- g_value_unset(&value);
+ g_value_unset (&value);
} else {
g_warning ("Parameter not readable. What's up with that?");
}
}
static void
-error_callback (GObject *object, GstObject *orig, gchar *error)
+error_callback (GObject * object, GstObject * orig, gchar * error)
{
g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
}
* USAGE: spidertest <mediafile>
* If mediafile can be recognized, xvideo and oss audio output are tried.
*/
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *osssink, *videosink;
GList *facs;
-
+
if (argc < 2) {
- g_print("usage: %s <file>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <file>\n", argv[0]);
+ exit (-1);
}
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
/* create a new bin to hold the elements */
- bin = gst_pipeline_new("pipeline");
- g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback), NULL);
+ bin = gst_pipeline_new ("pipeline");
+ g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback),
+ NULL);
g_signal_connect (bin, "error", G_CALLBACK (error_callback), NULL);
-
+
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_object_set(G_OBJECT(filesrc),"location", argv[1], NULL);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
/* now it's time to get the decoder */
- decoder = gst_element_factory_make("spider", "spider");
+ decoder = gst_element_factory_make ("spider", "spider");
if (!decoder) {
g_print ("could not find plugin \"spider\"\n");
exit (-2);
}
-
+
/* only use decoding plugins */
g_object_get (decoder, "factories", &facs, NULL);
- facs = gst_factories_at_most_templates(facs, GST_PAD_SINK, 1);
+ facs = gst_factories_at_most_templates (facs, GST_PAD_SINK, 1);
g_object_set (decoder, "factories", facs, NULL);
/* create video and audio sink */
- osssink = gst_element_factory_make("osssink", "audio");
- videosink = gst_element_factory_make("xvideosink", "video");
+ osssink = gst_element_factory_make ("osssink", "audio");
+ videosink = gst_element_factory_make ("xvideosink", "video");
if ((!osssink) || (!videosink)) {
g_print ("could not create output plugins\n");
}
/* add objects to the main pipeline */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), decoder);
- gst_bin_add(GST_BIN(bin), osssink);
- gst_bin_add(GST_BIN(bin), videosink);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), decoder);
+ gst_bin_add (GST_BIN (bin), osssink);
+ gst_bin_add (GST_BIN (bin), videosink);
/* link objects */
- if (!(gst_element_link(filesrc, decoder) &&
- gst_element_link(decoder, osssink) &&
- gst_element_link(decoder, videosink)))
- {
+ if (!(gst_element_link (filesrc, decoder) &&
+ gst_element_link (decoder, osssink) &&
+ gst_element_link (decoder, videosink))) {
g_print ("the pipeline could not be linked\n");
exit (-4);
}
/* gst_bin_use_clock (GST_BIN (bin), gst_system_clock_obtain ());*/
/* start playing */
- gst_element_set_state(bin, GST_STATE_PLAYING);
+ gst_element_set_state (bin, GST_STATE_PLAYING);
- while (gst_bin_iterate(GST_BIN(bin)));
+ while (gst_bin_iterate (GST_BIN (bin)));
- exit(0);
+ exit (0);
}
-
#define COTHREAD_MAXTHREADS 16
#define COTHREAD_STACKSIZE (STACK_SIZE/COTHREAD_MAXTHREADS)
-static void cothread_destroy (cothread_state *cothread);
+static void cothread_destroy (cothread_state * cothread);
struct _cothread_context
{
- cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */
+ cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */
int ncothreads;
int current;
unsigned long stack_top;
cothread_context *ctx;
ctx = g_static_private_get (&_cothread_ctx_key);
- g_assert(ctx);
+ g_assert (ctx);
#ifdef COTHREAD_PARANOID
- g_assert (ctx->thread == g_thread_self());
+ g_assert (ctx->thread == g_thread_self ());
#endif
return ctx;
cothread_context_init (void)
{
char __csf;
- void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */
+ void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */
cothread_context *ctx;
/* if there already is a cotread context for this thread,
* just return it */
ctx = g_static_private_get (&_cothread_ctx_key);
if (ctx) {
- GST_CAT_INFO (GST_CAT_COTHREADS,
- "returning private _cothread_ctx_key %p", ctx);
+ GST_CAT_INFO (GST_CAT_COTHREADS,
+ "returning private _cothread_ctx_key %p", ctx);
return ctx;
}
ctx->ncothreads = 1;
ctx->current = 0;
ctx->data = g_hash_table_new (g_str_hash, g_str_equal);
- ctx->thread = g_thread_self();
+ ctx->thread = g_thread_self ();
GST_CAT_INFO (GST_CAT_COTHREADS, "initializing cothreads");
/* set this thread's context pointer */
- GST_CAT_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to %p in thread %p",
- ctx,g_thread_self());
+ GST_CAT_INFO (GST_CAT_COTHREADS,
+ "setting private _cothread_ctx_key to %p in thread %p", ctx,
+ g_thread_self ());
g_static_private_set (&_cothread_ctx_key, ctx, NULL);
- g_assert(ctx == cothread_get_current_context());
+ g_assert (ctx == cothread_get_current_context ());
/* clear the cothread data */
memset (ctx->cothreads, 0, sizeof (ctx->cothreads));
ctx->cothreads[0]->flags = COTHREAD_STARTED;
ctx->cothreads[0]->sp = (void *) current_stack_frame;
- GST_CAT_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p",
- ctx->cothreads[0], ctx->cothreads[0]->sp);
+ GST_CAT_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p",
+ ctx->cothreads[0], ctx->cothreads[0]->sp);
return ctx;
}
* Free the cothread context.
*/
void
-cothread_context_free (cothread_context *ctx)
+cothread_context_free (cothread_context * ctx)
{
gint i;
g_return_if_fail (ctx != NULL);
- g_assert (ctx->thread == g_thread_self());
+ g_assert (ctx->thread == g_thread_self ());
g_assert (ctx->current == 0);
GST_CAT_INFO (GST_CAT_COTHREADS, "free cothread context");
}
}
if (ctx->cothreads[0]) {
- g_free(ctx->cothreads[0]);
+ g_free (ctx->cothreads[0]);
ctx->cothreads[0] = NULL;
}
g_hash_table_destroy (ctx->data);
/* make sure we free the private key for cothread context */
- GST_CAT_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to NULL in thread %p",
- g_thread_self());
+ GST_CAT_INFO (GST_CAT_COTHREADS,
+ "setting private _cothread_ctx_key to NULL in thread %p",
+ g_thread_self ());
g_static_private_set (&_cothread_ctx_key, NULL, NULL);
g_free (ctx);
}
*
* Returns: the new cothread state or NULL on error
*/
-cothread_state*
-cothread_create (cothread_context *ctx)
+cothread_state *
+cothread_create (cothread_context * ctx)
{
cothread_state *cothread;
void *mmaped = 0;
g_return_val_if_fail (ctx != NULL, NULL);
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "manager sef %p, cothread self %p",
- ctx->thread, g_thread_self());
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "manager sef %p, cothread self %p",
+ ctx->thread, g_thread_self ());
if (ctx->ncothreads == COTHREAD_MAXTHREADS) {
/* this is pretty fatal */
if (ctx->cothreads[slot] == NULL)
break;
else if (ctx->cothreads[slot]->flags & COTHREAD_DESTROYED &&
- slot != ctx->current) {
+ slot != ctx->current) {
cothread_destroy (ctx->cothreads[slot]);
break;
}
/* cothread stack space of the thread is mapped in reverse, with cothread 0
* stack space at the top */
- cothread = (cothread_state *) (ctx->stack_top - (slot + 1) * COTHREAD_STACKSIZE);
+ cothread =
+ (cothread_state *) (ctx->stack_top - (slot + 1) * COTHREAD_STACKSIZE);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread pointer is %p", cothread);
#if 0
/* This tests to see whether or not we can grow down the stack */
{
unsigned long ptr;
- for(ptr=ctx->stack_top - 4096; ptr > (unsigned long)cothread; ptr -= 4096){
+
+ for (ptr = ctx->stack_top - 4096; ptr > (unsigned long) cothread;
+ ptr -= 4096) {
GST_CAT_DEBUG (GST_CAT_COTHREADS, "touching location 0x%08lx", ptr);
- *(volatile unsigned int *)ptr = *(volatile unsigned int *)ptr;
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *)ptr);
+ *(volatile unsigned int *) ptr = *(volatile unsigned int *) ptr;
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *) ptr);
}
}
#endif
#ifdef _SC_PAGESIZE
- page_size = sysconf(_SC_PAGESIZE);
+ page_size = sysconf (_SC_PAGESIZE);
#else
- page_size = getpagesize();
+ page_size = getpagesize ();
#endif
/* The mmap is necessary on Linux/i386, and possibly others, since the
* kernel is picky about when we can expand our stack. */
GST_CAT_DEBUG (GST_CAT_COTHREADS, "mmaping %p, size 0x%08x", cothread,
- COTHREAD_STACKSIZE);
+ COTHREAD_STACKSIZE);
/* Remap with a guard page. This decreases our stack size by 8 kB (for
* 4 kB pages) and also wastes almost 4 kB for the cothreads
* structure */
- munmap((void *)cothread, COTHREAD_STACKSIZE);
+ munmap ((void *) cothread, COTHREAD_STACKSIZE);
mmaped = mmap ((void *) cothread, page_size,
- PROT_READ | PROT_WRITE,
- MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
mmaped = mmap (((void *) cothread) + page_size * 2,
- COTHREAD_STACKSIZE - page_size * 2,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ COTHREAD_STACKSIZE - page_size * 2,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "coming out of mmap");
if (mmaped == MAP_FAILED) {
perror ("mmap'ing cothread stack space");
return NULL;
}
- if (mmaped != (void *)cothread + page_size * 2) {
+ if (mmaped != (void *) cothread + page_size * 2) {
g_warning ("could not mmap requested memory for cothread");
return NULL;
}
cothread->magic_number = COTHREAD_MAGIC_NUMBER;
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "create cothread %d with magic number 0x%x",
- slot, cothread->magic_number);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS,
+ "create cothread %d with magic number 0x%x", slot,
+ cothread->magic_number);
cothread->ctx = ctx;
cothread->cothreadnum = slot;
cothread->flags = 0;
cothread->priv = NULL;
cothread->sp = ((guchar *) cothread + COTHREAD_STACKSIZE);
cothread->stack_size = COTHREAD_STACKSIZE - page_size * 2;
- cothread->stack_base = (void *)cothread + 2 * page_size;
+ cothread->stack_base = (void *) cothread + 2 * page_size;
- GST_CAT_INFO (GST_CAT_COTHREADS,
- "created cothread #%d in slot %d: %p at sp:%p",
- ctx->ncothreads, slot, cothread, cothread->sp);
+ GST_CAT_INFO (GST_CAT_COTHREADS,
+ "created cothread #%d in slot %d: %p at sp:%p",
+ ctx->ncothreads, slot, cothread, cothread->sp);
ctx->cothreads[slot] = cothread;
ctx->ncothreads++;
* Free the given cothread state
*/
void
-cothread_free (cothread_state *cothread)
+cothread_free (cothread_state * cothread)
{
g_return_if_fail (cothread != NULL);
- GST_CAT_INFO (GST_CAT_COTHREADS, "flag cothread %d for destruction",
- cothread->cothreadnum);
+ GST_CAT_INFO (GST_CAT_COTHREADS, "flag cothread %d for destruction",
+ cothread->cothreadnum);
/* we simply flag the cothread for destruction here */
if (cothread)
}
static void
-cothread_destroy (cothread_state *cothread)
+cothread_destroy (cothread_state * cothread)
{
cothread_context *ctx;
gint cothreadnum;
cothreadnum = cothread->cothreadnum;
ctx = cothread->ctx;
- g_assert (ctx->thread == g_thread_self());
- g_assert (ctx == cothread_get_current_context());
+ g_assert (ctx->thread == g_thread_self ());
+ g_assert (ctx == cothread_get_current_context ());
- GST_CAT_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %d",
- cothreadnum, cothread, ctx->current);
+ GST_CAT_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %d",
+ cothreadnum, cothread, ctx->current);
/* cothread 0 needs to be destroyed specially */
- g_assert(cothreadnum != 0);
+ g_assert (cothreadnum != 0);
/* we have to unlock here because we might be switched out
* with the lock held */
cothread_unlock (cothread);
/* doing cleanups of the cothread create */
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "destroy cothread %d with magic number 0x%x",
- cothreadnum, cothread->magic_number);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS,
+ "destroy cothread %d with magic number 0x%x", cothreadnum,
+ cothread->magic_number);
g_assert (cothread->magic_number == COTHREAD_MAGIC_NUMBER);
g_assert (cothread->priv == NULL);
- memset(cothread,0,sizeof(*cothread));
+ memset (cothread, 0, sizeof (*cothread));
ctx->cothreads[cothreadnum] = NULL;
ctx->ncothreads--;
* Set the cothread function
*/
void
-cothread_setfunc (cothread_state* cothread, cothread_func func, int argc, char **argv)
+cothread_setfunc (cothread_state * cothread, cothread_func func, int argc,
+ char **argv)
{
cothread->func = func;
cothread->argc = argc;
* Stop the cothread and reset the stack and program counter.
*/
void
-cothread_stop (cothread_state* cothread)
+cothread_stop (cothread_state * cothread)
{
cothread->flags &= ~COTHREAD_STARTED;
}
*
* Returns: the #cothread_state of the main (0th) cothread.
*/
-cothread_state*
-cothread_main (cothread_context* ctx)
+cothread_state *
+cothread_main (cothread_context * ctx)
{
- g_assert (ctx->thread == g_thread_self());
+ g_assert (ctx->thread == g_thread_self ());
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "returning %p, the 0th cothread",
- ctx->cothreads[0]);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "returning %p, the 0th cothread",
+ ctx->cothreads[0]);
return ctx->cothreads[0];
}
*
* Returns: the #cothread_state of the main (0th) thread in the current GThread
*/
-cothread_state*
+cothread_state *
cothread_current_main (void)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
return ctx->cothreads[0];
}
*
* Returns: the #cothread_state of the current cothread
*/
-cothread_state*
+cothread_state *
cothread_current (void)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
return ctx->cothreads[ctx->current];
}
static void
cothread_stub (void)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
cothread_state *cothread = ctx->cothreads[ctx->current];
-#ifndef GST_DISABLE_GST_DEBUG
+
+#ifndef GST_DISABLE_GST_DEBUG
char __csf;
void *current_stack_frame = &__csf;
#endif
while (TRUE) {
cothread->func (cothread->argc, cothread->argv);
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited", ctx->current);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited",
+ ctx->current);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "sp=%p", current_stack_frame);
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,cothread_get_current_context());
- g_assert (ctx == cothread_get_current_context());
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,
+ cothread_get_current_context ());
+ g_assert (ctx == cothread_get_current_context ());
g_assert (ctx->current != 0);
*
* Returns: the current cothread id
*/
-int cothread_getcurrent (void) G_GNUC_NO_INSTRUMENT;
-
int
cothread_getcurrent (void)
+ G_GNUC_NO_INSTRUMENT;
+
+ int cothread_getcurrent (void)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
if (!ctx)
return -1;
* set private data for the cothread.
*/
void
-cothread_set_private (cothread_state *cothread, gpointer data)
+cothread_set_private (cothread_state * cothread, gpointer data)
{
cothread->priv = data;
}
* adds data to a cothread
*/
void
-cothread_context_set_data (cothread_state *cothread, gchar *key, gpointer data)
+cothread_context_set_data (cothread_state * cothread, gchar * key,
+ gpointer data)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
g_hash_table_insert (ctx->data, key, data);
}
* Returns: the private data of the cothread
*/
gpointer
-cothread_get_private (cothread_state *cothread)
+cothread_get_private (cothread_state * cothread)
{
return cothread->priv;
}
* Returns: the data associated with the key
*/
gpointer
-cothread_context_get_data (cothread_state *cothread, gchar *key)
+cothread_context_get_data (cothread_state * cothread, gchar * key)
{
- cothread_context *ctx = cothread_get_current_context();
+ cothread_context *ctx = cothread_get_current_context ();
return g_hash_table_lookup (ctx->data, key);
}
* Switches to the given cothread state
*/
void
-cothread_switch (cothread_state *cothread)
+cothread_switch (cothread_state * cothread)
{
cothread_context *ctx;
cothread_state *current;
ctx = cothread->ctx;
/* paranoia check to make sure we're in the right thread */
- g_assert (ctx->thread == g_thread_self());
+ g_assert (ctx->thread == g_thread_self ());
#ifdef COTHREAD_PARANOID
if (ctx == NULL)
/* find the number of the thread to switch to */
- GST_CAT_INFO (GST_CAT_COTHREAD_SWITCH,
- "switching from cothread #%d to cothread #%d",
- ctx->current, cothread->cothreadnum);
+ GST_CAT_INFO (GST_CAT_COTHREAD_SWITCH,
+ "switching from cothread #%d to cothread #%d",
+ ctx->current, cothread->cothreadnum);
ctx->current = cothread->cothreadnum;
/* save the current stack pointer, frame pointer, and pc */
#endif
enter = setjmp (current->jmp);
if (enter != 0) {
- GST_CAT_DEBUG (GST_CAT_COTHREADS,
- "enter cothread #%d %d sp=%p jmpbuf=%p",
- current->cothreadnum, enter, current->sp, current->jmp);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS,
+ "enter cothread #%d %d sp=%p jmpbuf=%p",
+ current->cothreadnum, enter, current->sp, current->jmp);
return;
}
- GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p",
- current->cothreadnum, enter, current->sp, current->jmp);
+ GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p",
+ current->cothreadnum, enter, current->sp, current->jmp);
enter = 1;
if (current->flags & COTHREAD_DESTROYED) {
GST_CAT_DEBUG (GST_CAT_COTHREADS, "via longjmp() jmpbuf %p", cothread->jmp);
/* switch to it */
longjmp (cothread->jmp, 1);
- }
- else {
+ } else {
#ifdef HAVE_MAKECONTEXT
ucontext_t ucp;
GST_CAT_DEBUG (GST_CAT_COTHREADS, "making context");
- g_assert (cothread != cothread_main(ctx));
+ g_assert (cothread != cothread_main (ctx));
getcontext (&ucp);
- ucp.uc_stack.ss_sp = (void *)cothread->stack_base;
+ ucp.uc_stack.ss_sp = (void *) cothread->stack_base;
ucp.uc_stack.ss_size = cothread->stack_size;
makecontext (&ucp, cothread_stub, 0);
setcontext (&ucp);
#else
- GST_ARCH_SETUP_STACK ((char*)cothread->sp);
+ GST_ARCH_SETUP_STACK ((char *) cothread->sp);
GST_ARCH_SET_SP (cothread->sp);
/* start it */
GST_ARCH_CALL (cothread_stub);
exit (2);
#endif /* COTHREAD_PARANOID */
selfswitch:
- g_warning ("cothread: trying to switch to same thread, legal but not necessary");
+ g_warning
+ ("cothread: trying to switch to same thread, legal but not necessary");
return;
}
* Locks the cothread state.
*/
void
-cothread_lock (cothread_state *cothread)
+cothread_lock (cothread_state * cothread)
{
}
* Returns: TRUE if the cothread could be locked.
*/
gboolean
-cothread_trylock (cothread_state *cothread)
+cothread_trylock (cothread_state * cothread)
{
return TRUE;
}
* Unlock the cothread state.
*/
void
-cothread_unlock (cothread_state *cothread)
+cothread_unlock (cothread_state * cothread)
{
}
#include <glib.h>
#include <setjmp.h>
-typedef struct _cothread_state cothread_state;
-typedef struct _cothread_context cothread_context;
+typedef struct _cothread_state cothread_state;
+typedef struct _cothread_context cothread_context;
-typedef int (*cothread_func) (int argc,char **argv);
+typedef int (*cothread_func) (int argc, char **argv);
#define COTHREAD_STARTED 0x01
#define COTHREAD_DESTROYED 0x02
-struct _cothread_state {
- cothread_context *ctx;
- int cothreadnum;
- gpointer priv;
+struct _cothread_state
+{
+ cothread_context *ctx;
+ int cothreadnum;
+ gpointer priv;
- cothread_func func;
- int argc;
- char **argv;
+ cothread_func func;
+ int argc;
+ char **argv;
- int flags;
- void *sp;
- jmp_buf jmp;
- void *stack_base;
- unsigned long stack_size;
+ int flags;
+ void *sp;
+ jmp_buf jmp;
+ void *stack_base;
+ unsigned long stack_size;
- int magic_number;
+ int magic_number;
};
-cothread_context* cothread_context_init (void);
-void cothread_context_free (cothread_context *ctx);
-void cothread_context_set_data (cothread_state *cothread,
- gchar *key, gpointer data);
-gpointer cothread_context_get_data (cothread_state *cothread, gchar *key);
+cothread_context *cothread_context_init (void);
+void cothread_context_free (cothread_context * ctx);
+void cothread_context_set_data (cothread_state * cothread,
+ gchar * key, gpointer data);
+gpointer cothread_context_get_data (cothread_state * cothread, gchar * key);
-cothread_state* cothread_create (cothread_context *ctx);
-void cothread_free (cothread_state *cothread);
-void cothread_setfunc (cothread_state *cothread, cothread_func func,
- int argc, char **argv);
-void cothread_stop (cothread_state *cothread);
+cothread_state *cothread_create (cothread_context * ctx);
+void cothread_free (cothread_state * cothread);
+void cothread_setfunc (cothread_state * cothread, cothread_func func,
+ int argc, char **argv);
+void cothread_stop (cothread_state * cothread);
-void cothread_switch (cothread_state *cothread);
-void cothread_set_private (cothread_state *cothread,
- gpointer data);
-gpointer cothread_get_private (cothread_state *cothread);
+void cothread_switch (cothread_state * cothread);
+void cothread_set_private (cothread_state * cothread, gpointer data);
+gpointer cothread_get_private (cothread_state * cothread);
-void cothread_lock (cothread_state *cothread);
-gboolean cothread_trylock (cothread_state *cothread);
-void cothread_unlock (cothread_state *cothread);
+void cothread_lock (cothread_state * cothread);
+gboolean cothread_trylock (cothread_state * cothread);
+void cothread_unlock (cothread_state * cothread);
-cothread_state* cothread_main (cothread_context *ctx);
-cothread_state* cothread_current_main (void);
-cothread_state* cothread_current (void);
+cothread_state *cothread_main (cothread_context * ctx);
+cothread_state *cothread_current_main (void);
+cothread_state *cothread_current (void);
#endif /* __COTHREAD_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_aggregator_debug);
#define GST_CAT_DEFAULT gst_aggregator_debug
-GstElementDetails gst_aggregator_details = GST_ELEMENT_DETAILS (
- "Aggregator pipe fitting",
- "Generic",
- "N-to-1 pipe fitting",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_aggregator_details =
+GST_ELEMENT_DETAILS ("Aggregator pipe fitting",
+ "Generic",
+ "N-to-1 pipe fitting",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Aggregator signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUM_PADS,
ARG_SILENT,
/* FILL ME */
};
-GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate aggregator_src_template =
+GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type())
static GType
{
static GType aggregator_sched_type = 0;
static GEnumValue aggregator_sched[] = {
- { AGGREGATOR_LOOP, "1", "Loop Based"},
- { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
- { AGGREGATOR_CHAIN, "4", "Chain Based"},
+ {AGGREGATOR_LOOP, "1", "Loop Based"},
+ {AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
+ {AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL},
};
if (!aggregator_sched_type) {
- aggregator_sched_type = g_enum_register_static ("GstAggregatorSched", aggregator_sched);
+ aggregator_sched_type =
+ g_enum_register_static ("GstAggregatorSched", aggregator_sched);
}
return aggregator_sched_type;
}
#define AGGREGATOR_IS_LOOP_BASED(ag) ((ag)->sched != AGGREGATOR_CHAIN)
-static GstPad* gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *temp, const
- gchar *unused);
-static void gst_aggregator_update_functions (GstAggregator *aggregator);
+static GstPad *gst_aggregator_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * unused);
+static void gst_aggregator_update_functions (GstAggregator * aggregator);
-static void gst_aggregator_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_aggregator_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_aggregator_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_aggregator_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_aggregator_chain (GstPad *pad, GstData *_data);
-static void gst_aggregator_loop (GstElement *element);
+static void gst_aggregator_chain (GstPad * pad, GstData * _data);
+static void gst_aggregator_loop (GstElement * element);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_aggregator_debug, "aggregator", 0, "aggregator element");
-GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
static void
gst_aggregator_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
static void
-gst_aggregator_class_init (GstAggregatorClass *klass)
+gst_aggregator_class_init (GstAggregatorClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
- g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED,
- g_param_spec_enum ("sched", "Scheduling", "The type of scheduling this element should use",
- GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("sched", "Scheduling",
+ "The type of scheduling this element should use",
+ GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "Last message", "The current state of the element",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last_message", "Last message",
+ "The current state of the element", NULL, G_PARAM_READABLE));
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad);
}
-static void
-gst_aggregator_init (GstAggregator *aggregator)
+static void
+gst_aggregator_init (GstAggregator * aggregator)
{
aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_getcaps_function (aggregator->srcpad, gst_pad_proxy_getcaps);
gst_aggregator_update_functions (aggregator);
}
-static GstPad*
-gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *sinkpad;
aggregator = GST_AGGREGATOR (element);
- name = g_strdup_printf ("sink%d",aggregator->numsinkpads);
-
+ name = g_strdup_printf ("sink%d", aggregator->numsinkpads);
+
sinkpad = gst_pad_new_from_template (templ, name);
g_free (name);
-
+
if (!AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_pad_set_chain_function (sinkpad, gst_aggregator_chain);
}
gst_pad_set_getcaps_function (sinkpad, gst_pad_proxy_getcaps);
gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad);
-
+
aggregator->sinkpads = g_list_prepend (aggregator->sinkpads, sinkpad);
aggregator->numsinkpads++;
-
+
return sinkpad;
}
static void
-gst_aggregator_update_functions (GstAggregator *aggregator)
+gst_aggregator_update_functions (GstAggregator * aggregator)
{
GList *pads;
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
- gst_element_set_loop_function (GST_ELEMENT (aggregator), GST_DEBUG_FUNCPTR (gst_aggregator_loop));
- }
- else {
+ gst_element_set_loop_function (GST_ELEMENT (aggregator),
+ GST_DEBUG_FUNCPTR (gst_aggregator_loop));
+ } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
}
pads = aggregator->sinkpads;
while (pads) {
GstPad *pad = GST_PAD (pads->data);
-
+
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_pad_set_get_function (pad, NULL);
- }
- else {
+ } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
}
pads = g_list_next (pads);
}
static void
-gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_aggregator_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAggregator *aggregator;
}
static void
-gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_aggregator_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAggregator *aggregator;
}
}
-static void
-gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug)
+static void
+gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf,
+ guchar * debug)
{
if (!aggregator->silent) {
g_free (aggregator->last_message);
- aggregator->last_message = g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
- G_GUINT64_FORMAT ")",
- debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ aggregator->last_message =
+ g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
+ G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (aggregator), "last_message");
}
gst_pad_push (aggregator->srcpad, GST_DATA (buf));
}
-static void
-gst_aggregator_loop (GstElement *element)
+static void
+gst_aggregator_loop (GstElement * element)
{
GstAggregator *aggregator;
GstBuffer *buf;
* active ones */
while (pads) {
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
/* we need to check is the pad is usable. IS_USABLE will check
* and that the peer pad is also enabled.
*/
if (GST_PAD_IS_USABLE (pad)) {
- buf = GST_BUFFER (gst_pad_pull (pad));
- debug = "loop";
+ buf = GST_BUFFER (gst_pad_pull (pad));
+ debug = "loop";
/* then push it forward */
- gst_aggregator_push (aggregator, pad, buf, debug);
+ gst_aggregator_push (aggregator, pad, buf, debug);
}
}
- }
- else {
+ } else {
if (aggregator->sched == AGGREGATOR_LOOP_SELECT) {
GstPad *pad;
buf = GST_BUFFER (gst_pad_pull (pad));
gst_aggregator_push (aggregator, pad, buf, debug);
- }
- else {
+ } else {
g_assert_not_reached ();
}
}
*
* Chain a buffer on a pad.
*/
-static void
-gst_aggregator_chain (GstPad *pad, GstData *_data)
+static void
+gst_aggregator_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstAggregator *aggregator;
gst_aggregator_push (aggregator, pad, buf, "chain");
}
-
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-
-typedef enum {
- AGGREGATOR_LOOP = 1,
+G_BEGIN_DECLS typedef enum
+{
+ AGGREGATOR_LOOP = 1,
AGGREGATOR_LOOP_SELECT,
AGGREGATOR_CHAIN
} GstAggregatorSchedType;
#define GST_IS_AGGREGATOR_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR))
-typedef struct _GstAggregator GstAggregator;
-typedef struct _GstAggregatorClass GstAggregatorClass;
+typedef struct _GstAggregator GstAggregator;
+typedef struct _GstAggregatorClass GstAggregatorClass;
-struct _GstAggregator {
+struct _GstAggregator
+{
GstElement element;
GstPad *srcpad;
gchar *last_message;
};
-struct _GstAggregatorClass {
+struct _GstAggregatorClass
+{
GstElementClass parent_class;
};
-GType gst_aggregator_get_type (void);
+GType gst_aggregator_get_type (void);
-gboolean gst_aggregator_factory_init (GstElementFactory *factory);
+gboolean gst_aggregator_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_AGGREGATOR_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_buffer_store_debug);
#define GST_CAT_DEFAULT gst_buffer_store_debug
-enum {
+enum
+{
CLEARED,
BUFFER_ADDED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
-static void gst_buffer_store_dispose (GObject * object);
+static void gst_buffer_store_dispose (GObject * object);
+
+static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store,
+ GstBuffer * buffer);
+static void gst_buffer_store_cleared_func (GstBufferStore * store);
-static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store,
- GstBuffer * buffer);
-static void gst_buffer_store_cleared_func (GstBufferStore * store);
-
static guint gst_buffer_store_signals[LAST_SIGNAL] = { 0 };
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_buffer_store_debug, "GstBufferStore", 0, "buffer store helper");
-GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, _do_init);
+GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT,
+ _do_init);
G_GNUC_UNUSED static void
-debug_buffers (GstBufferStore *store)
+debug_buffers (GstBufferStore * store)
{
GList *walk = store->buffers;
-
+
g_printerr ("BUFFERS in store:\n");
while (walk) {
- g_print ("%15"G_GUINT64_FORMAT" - %7u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data));
+ g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data),
+ GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk);
}
g_printerr ("\n");
}
+
static gboolean
-continue_accu (GSignalInvocationHint *ihint, GValue *return_accu,
- const GValue *handler_return, gpointer data)
+continue_accu (GSignalInvocationHint * ihint, GValue * return_accu,
+ const GValue * handler_return, gpointer data)
{
gboolean do_continue = g_value_get_boolean (handler_return);
+
g_value_set_boolean (return_accu, do_continue);
return do_continue;
{
}
static void
-gst_buffer_store_class_init (GstBufferStoreClass *store_class)
+gst_buffer_store_class_init (GstBufferStoreClass * store_class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (store_class);
gobject_class->dispose = gst_buffer_store_dispose;
-
- gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared",
- G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL,
- gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
- gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added",
- G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL,
- gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER);
+
+ gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared",
+ G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL,
+ gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added",
+ G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL,
+ gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER);
store_class->cleared = gst_buffer_store_cleared_func;
store_class->buffer_added = gst_buffer_store_add_buffer_func;
}
static void
-gst_buffer_store_init (GstBufferStore *store)
+gst_buffer_store_init (GstBufferStore * store)
{
store->buffers = NULL;
}
static void
-gst_buffer_store_dispose (GObject *object)
+gst_buffer_store_dispose (GObject * object)
{
GstBufferStore *store = GST_BUFFER_STORE (object);
parent_class->dispose (object);
}
+
static gboolean
-gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
+gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
{
g_assert (buffer != NULL);
-
+
if (!GST_BUFFER_OFFSET_IS_VALID (buffer) &&
- store->buffers &&
- GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
+ store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* we assumed valid offsets, but suddenly they are not anymore */
- GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort",
- buffer);
+ GST_DEBUG_OBJECT (store,
+ "attempting to add buffer %p with invalid offset to store with valid offset, abort",
+ buffer);
return FALSE;
- } else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
+ } else if (!store->buffers
+ || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* the starting buffer had an invalid offset, in that case we assume continuous buffers */
GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u",
- buffer, GST_BUFFER_SIZE (buffer));
+ buffer, GST_BUFFER_SIZE (buffer));
gst_data_ref (GST_DATA (buffer));
store->buffers = g_list_append (store->buffers, buffer);
return TRUE;
/* both list and buffer have valid offsets, we can really go wild */
GList *walk, *current_list = NULL;
GstBuffer *current;
-
+
g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer));
- GST_LOG_OBJECT (store, "attempting to add buffer %p with offset %"G_GUINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_LOG_OBJECT (store,
+ "attempting to add buffer %p with offset %" G_GUINT64_FORMAT
+ " and size %u", buffer, GST_BUFFER_OFFSET (buffer),
+ GST_BUFFER_SIZE (buffer));
/* we keep a sorted list of non-overlapping buffers */
walk = store->buffers;
while (walk) {
continue;
} else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) {
guint needed_size;
+
if (walk) {
- needed_size = MIN (GST_BUFFER_SIZE (buffer),
- GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
+ needed_size = MIN (GST_BUFFER_SIZE (buffer),
+ GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
} else {
needed_size = GST_BUFFER_SIZE (buffer);
}
if (needed_size < GST_BUFFER_SIZE (buffer)) {
/* need to create subbuffer to not have overlapping data */
GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size);
+
g_assert (sub);
buffer = sub;
} else {
gst_data_ref (GST_DATA (buffer));
}
/* replace current buffer with new one */
- GST_INFO_OBJECT (store, "replacing buffer %p with buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- current_list->data, buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_INFO_OBJECT (store,
+ "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT
+ " and size %u", current_list->data, buffer,
+ GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
gst_data_unref (GST_DATA (current_list->data));
current_list->data = buffer;
buffer = NULL;
}
} else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) {
GList *previous = g_list_previous (current_list);
- guint64 start_offset = previous ?
- GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_SIZE (previous->data) : 0;
+ guint64 start_offset = previous ?
+ GST_BUFFER_OFFSET (previous->data) +
+ GST_BUFFER_SIZE (previous->data) : 0;
if (start_offset == GST_BUFFER_OFFSET (current)) {
buffer = NULL;
} else {
/* we have data to insert */
if (start_offset > GST_BUFFER_OFFSET (buffer) ||
- GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (current)) {
+ GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) >
+ GST_BUFFER_OFFSET (current)) {
GstBuffer *sub;
/* need a subbuffer */
- start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
- start_offset - GST_BUFFER_OFFSET (buffer);
+ start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
+ start_offset - GST_BUFFER_OFFSET (buffer);
sub = gst_buffer_create_sub (buffer, start_offset,
- MIN (GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (buffer)));
+ MIN (GST_BUFFER_SIZE (buffer),
+ GST_BUFFER_OFFSET (current) - start_offset -
+ GST_BUFFER_OFFSET (buffer)));
g_assert (sub);
GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer);
buffer = sub;
} else {
gst_data_ref (GST_DATA (buffer));
}
- GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
- store->buffers = g_list_insert_before (store->buffers, current_list, buffer);
+ GST_INFO_OBJECT (store,
+ "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
+ buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ store->buffers =
+ g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL;
break;
}
}
if (buffer) {
gst_data_ref (GST_DATA (buffer));
- GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_INFO_OBJECT (store,
+ "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
+ buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
if (current_list) {
g_list_append (current_list, buffer);
} else {
}
}
static void
-gst_buffer_store_cleared_func (GstBufferStore *store)
+gst_buffer_store_cleared_func (GstBufferStore * store)
{
g_list_foreach (store->buffers, (GFunc) gst_data_unref, NULL);
g_list_free (store->buffers);
store->buffers = NULL;
}
+
/**
* gst_buffer_store_new:
*
{
return GST_BUFFER_STORE (g_object_new (GST_TYPE_BUFFER_STORE, NULL));
}
+
/**
* gst_buffer_store_clear:
* @store: a bufferstore
*/
/* FIXME: call this function _reset ? */
void
-gst_buffer_store_clear (GstBufferStore *store)
+gst_buffer_store_clear (GstBufferStore * store)
{
g_return_if_fail (GST_IS_BUFFER_STORE (store));
-
- g_signal_emit (store, gst_buffer_store_signals [CLEARED], 0, NULL);
+
+ g_signal_emit (store, gst_buffer_store_signals[CLEARED], 0, NULL);
}
+
/**
* gst_buffer_store_add_buffer:
* @store: a bufferstore
* Returns: TRUE, if the buffer was added, FALSE if an error occured.
*/
gboolean
-gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer)
+gst_buffer_store_add_buffer (GstBufferStore * store, GstBuffer * buffer)
{
gboolean ret;
-
+
g_return_val_if_fail (GST_IS_BUFFER_STORE (store), FALSE);
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
GST_BUFFER_OFFSET_IS_VALID (store->buffers->data) &&
!GST_BUFFER_OFFSET_IS_VALID (buffer))
return FALSE;
-
- g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret);
-
+
+ g_signal_emit (store, gst_buffer_store_signals[BUFFER_ADDED], 0, buffer,
+ &ret);
+
return ret;
}
+
/**
* gst_buffer_store_get_buffer:
* @store: a bufferstore
* available.
*/
GstBuffer *
-gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
+gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size)
{
GstBuffer *current;
GList *walk;
if (cur_offset > offset) {
/* #include <windows.h>
do_nothing_loop (); */
- } else if (cur_offset == offset &&
- GST_BUFFER_SIZE (current) == size) {
- GST_LOG_OBJECT (store, "found matching buffer %p for offset %"G_GUINT64_FORMAT" and size %u",
- current, offset, size);
+ } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) {
+ GST_LOG_OBJECT (store,
+ "found matching buffer %p for offset %" G_GUINT64_FORMAT
+ " and size %u", current, offset, size);
ret = current;
gst_data_ref (GST_DATA (ret));
- GST_LOG_OBJECT (store, "refcount %d",
- GST_DATA_REFCOUNT_VALUE(ret));
+ GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret));
break;
} else if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) {
ret = gst_buffer_create_sub (current, offset - cur_offset, size);
- GST_LOG_OBJECT (store, "created subbuffer %p from buffer %p for offset %llu and size %u",
- ret, current, offset, size);
+ GST_LOG_OBJECT (store,
+ "created subbuffer %p from buffer %p for offset %llu and size %u",
+ ret, current, offset, size);
break;
}
/* uh, the requested data spans some buffers */
ret = gst_buffer_new_and_alloc (size);
- GST_LOG_OBJECT (store, "created buffer %p for offset %"G_GUINT64_FORMAT
- " and size %u, will fill with data now",
- ret, offset, size);
+ GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT
+ " and size %u, will fill with data now", ret, offset, size);
data = GST_BUFFER_DATA (ret);
tmp = GST_BUFFER_SIZE (current) - offset + cur_offset;
memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp);
data += tmp;
size -= tmp;
while (size) {
- if (walk == NULL ||
- (have_offset &&
- GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) {
- GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and remaining size %u available, aborting",
- offset, size);
+ if (walk == NULL ||
+ (have_offset &&
+ GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) !=
+ GST_BUFFER_OFFSET (walk->data))) {
+ GST_DEBUG_OBJECT (store,
+ "not all data for offset %" G_GUINT64_FORMAT
+ " and remaining size %u available, aborting", offset, size);
gst_data_unref (GST_DATA (ret));
ret = NULL;
goto out;
}
}
out:
-
+
return ret;
}
+
/**
* gst_buffer_store_get_size:
* @store: a bufferstore
* offset.
*/
guint
-gst_buffer_store_get_size (GstBufferStore *store, guint64 offset)
+gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
{
GList *walk;
gboolean have_offset;
have_offset = FALSE;
}
while (walk) {
- if (have_offset && counting &&
- cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data)) {
+ if (have_offset && counting &&
+ cur_offset + GST_BUFFER_SIZE (current) !=
+ GST_BUFFER_OFFSET (walk->data)) {
break;
}
current = GST_BUFFER (walk->data);
cur_offset += GST_BUFFER_SIZE (current);
}
}
-
+
return ret;
}
#include <gst/gstmarshal.h>
G_BEGIN_DECLS
-
#define GST_TYPE_BUFFER_STORE (gst_buffer_store_get_type ())
#define GST_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_STORE, GstBufferStore))
#define GST_IS_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_STORE))
#define GST_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_STORE, GstBufferStoreClass))
#define GST_IS_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_STORE))
#define GST_BUFFER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_STORE, GstBufferStoreClass))
+typedef struct _GstBufferStore GstBufferStore;
+typedef struct _GstBufferStoreClass GstBufferStoreClass;
-typedef struct _GstBufferStore GstBufferStore;
-typedef struct _GstBufferStoreClass GstBufferStoreClass;
-
-struct _GstBufferStore {
- GObject object;
+struct _GstBufferStore
+{
+ GObject object;
- GList * buffers;
+ GList *buffers;
};
-struct _GstBufferStoreClass {
- GObjectClass parent_class;
+struct _GstBufferStoreClass
+{
+ GObjectClass parent_class;
/* signals */
- void (* cleared) (GstBufferStore * store);
- gboolean (* buffer_added) (GstBufferStore * store,
- GstBuffer * buffer);
+ void (*cleared) (GstBufferStore * store);
+ gboolean (*buffer_added) (GstBufferStore * store, GstBuffer * buffer);
};
-GType gst_buffer_store_get_type (void);
+GType gst_buffer_store_get_type (void);
-GstBufferStore * gst_buffer_store_new (void);
-void gst_buffer_store_clear (GstBufferStore * store);
+GstBufferStore *gst_buffer_store_new (void);
+void gst_buffer_store_clear (GstBufferStore * store);
-gboolean gst_buffer_store_add_buffer (GstBufferStore * store,
- GstBuffer * buffer);
+gboolean gst_buffer_store_add_buffer (GstBufferStore * store,
+ GstBuffer * buffer);
-GstBuffer * gst_buffer_store_get_buffer (GstBufferStore * store,
- guint64 offset,
- guint size);
-guint gst_buffer_store_get_size (GstBufferStore * store,
- guint64 offset);
+GstBuffer *gst_buffer_store_get_buffer (GstBufferStore * store,
+ guint64 offset, guint size);
+guint gst_buffer_store_get_size (GstBufferStore * store, guint64 offset);
G_END_DECLS
-
#endif /* __GST_BUFFER_STORE_H__ */
#include "gsttypefind.h"
-struct _elements_entry {
+struct _elements_entry
+{
gchar *name;
guint rank;
- GType (*type) (void);
+ GType (*type) (void);
};
-extern GType gst_filesrc_get_type(void);
+extern GType gst_filesrc_get_type (void);
extern GstElementDetails gst_filesrc_details;
static struct _elements_entry _elements[] = {
- { "aggregator", GST_RANK_NONE, gst_aggregator_get_type },
- { "fakesrc", GST_RANK_NONE, gst_fakesrc_get_type },
- { "fakesink", GST_RANK_NONE, gst_fakesink_get_type },
- { "fdsink", GST_RANK_NONE, gst_fdsink_get_type },
- { "fdsrc", GST_RANK_NONE, gst_fdsrc_get_type },
- { "filesrc", GST_RANK_NONE, gst_filesrc_get_type },
- { "filesink", GST_RANK_NONE, gst_filesink_get_type },
- { "identity", GST_RANK_NONE, gst_identity_get_type },
- { "md5sink", GST_RANK_NONE, gst_md5sink_get_type },
- { "multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type },
- { "pipefilter", GST_RANK_NONE, gst_pipefilter_get_type },
- { "shaper", GST_RANK_NONE, gst_shaper_get_type },
- { "statistics", GST_RANK_NONE, gst_statistics_get_type },
- { "tee", GST_RANK_NONE, gst_tee_get_type },
- { "typefind", GST_RANK_NONE, gst_type_find_element_get_type },
- { NULL, 0 },
+ {"aggregator", GST_RANK_NONE, gst_aggregator_get_type},
+ {"fakesrc", GST_RANK_NONE, gst_fakesrc_get_type},
+ {"fakesink", GST_RANK_NONE, gst_fakesink_get_type},
+ {"fdsink", GST_RANK_NONE, gst_fdsink_get_type},
+ {"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type},
+ {"filesrc", GST_RANK_NONE, gst_filesrc_get_type},
+ {"filesink", GST_RANK_NONE, gst_filesink_get_type},
+ {"identity", GST_RANK_NONE, gst_identity_get_type},
+ {"md5sink", GST_RANK_NONE, gst_md5sink_get_type},
+ {"multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type},
+ {"pipefilter", GST_RANK_NONE, gst_pipefilter_get_type},
+ {"shaper", GST_RANK_NONE, gst_shaper_get_type},
+ {"statistics", GST_RANK_NONE, gst_statistics_get_type},
+ {"tee", GST_RANK_NONE, gst_tee_get_type},
+ {"typefind", GST_RANK_NONE, gst_type_find_element_get_type},
+ {NULL, 0},
};
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
struct _elements_entry *my_elements = _elements;
-
- while ((*my_elements).name) {
- if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, ((*my_elements).type) ()))
+
+ while ((*my_elements).name) {
+ if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank,
+ ((*my_elements).type) ()))
return FALSE;
my_elements++;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstelements",
- "standard GStreamer elements",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstelements",
+ "standard GStreamer elements",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
GST_DEBUG_CATEGORY_STATIC (gst_fakesink_debug);
#define GST_CAT_DEFAULT gst_fakesink_debug
-GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS (
- "Fake Sink",
- "Sink",
- "Black hole for data",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ("Fake Sink",
+ "Sink",
+ "Black hole for data",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FakeSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_STATE_ERROR,
ARG_NUM_SINKS,
ARG_LAST_MESSAGE,
};
-GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type())
static GType
{
static GType fakesink_state_error_type = 0;
static GEnumValue fakesink_state_error[] = {
- { FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
- { FAKESINK_STATE_ERROR_NULL_READY, "1", "Fail state change from NULL to READY"},
- { FAKESINK_STATE_ERROR_READY_PAUSED, "2", "Fail state change from READY to PAUSED"},
- { FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", "Fail state change from PAUSED to PLAYING"},
- { FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", "Fail state change from PLAYING to PAUSED"},
- { FAKESINK_STATE_ERROR_PAUSED_READY , "5", "Fail state change from PAUSED to READY"},
- { FAKESINK_STATE_ERROR_READY_NULL , "6", "Fail state change from READY to NULL"},
+ {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
+ {FAKESINK_STATE_ERROR_NULL_READY, "1",
+ "Fail state change from NULL to READY"},
+ {FAKESINK_STATE_ERROR_READY_PAUSED, "2",
+ "Fail state change from READY to PAUSED"},
+ {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3",
+ "Fail state change from PAUSED to PLAYING"},
+ {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4",
+ "Fail state change from PLAYING to PAUSED"},
+ {FAKESINK_STATE_ERROR_PAUSED_READY, "5",
+ "Fail state change from PAUSED to READY"},
+ {FAKESINK_STATE_ERROR_READY_NULL, "6",
+ "Fail state change from READY to NULL"},
{0, NULL, NULL},
};
if (!fakesink_state_error_type) {
- fakesink_state_error_type = g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
+ fakesink_state_error_type =
+ g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
}
return fakesink_state_error_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fakesink_debug, "fakesink", 0, "fakesink element");
-GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fakesink_set_clock (GstElement *element, GstClock *clock);
-static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const
- gchar *unused);
+static void gst_fakesink_set_clock (GstElement * element, GstClock * clock);
+static GstPad *gst_fakesink_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
-static void gst_fakesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fakesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fakesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fakesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn
- gst_fakesink_change_state (GstElement *element);
+static GstElementStateReturn gst_fakesink_change_state (GstElement * element);
-static void gst_fakesink_chain (GstPad *pad, GstData *_data);
+static void gst_fakesink_chain (GstPad * pad, GstData * _data);
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
static void
gst_fakesink_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_set_details (gstelement_class, &gst_fakesink_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesink_sink_template));
}
static void
-gst_fakesink_class_init (GstFakeSinkClass *klass)
+gst_fakesink_class_init (GstFakeSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
- g_param_spec_int ("num_sinks", "Number of sinks", "The number of sinkpads",
- 1, G_MAXINT, 1, G_PARAM_READABLE));
+ g_param_spec_int ("num_sinks", "Number of sinks",
+ "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR,
- g_param_spec_enum ("state_error", "State Error", "Generate a state change error",
- GST_TYPE_FAKESINK_STATE_ERROR, FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
+ g_param_spec_enum ("state_error", "State Error",
+ "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR,
+ FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "Last Message", "The message describing current status",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last_message", "Last Message",
+ "The message describing current status", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
- g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
- g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
+ "Send a signal before unreffing the buffer", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent",
+ "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
- GST_TYPE_BUFFER, GST_TYPE_PAD);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
+ GST_TYPE_BUFFER, GST_TYPE_PAD);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad);
- gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesink_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad);
+ gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock);
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_fakesink_change_state);
}
-static void
-gst_fakesink_init (GstFakeSink *fakesink)
+static void
+gst_fakesink_init (GstFakeSink * fakesink)
{
GstPad *pad;
}
static void
-gst_fakesink_set_clock (GstElement *element, GstClock *clock)
-{
+gst_fakesink_set_clock (GstElement * element, GstClock * clock)
+{
GstFakeSink *sink;
sink = GST_FAKESINK (element);
sink->clock = clock;
-}
+}
-static GstPad*
-gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_fakesink_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *sinkpad;
sinkpad = gst_pad_new_from_template (templ, name);
g_free (name);
gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
-
+
gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad);
return sinkpad;
}
static void
-gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_fakesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFakeSink *sink;
}
}
-static void
-gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fakesink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFakeSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FAKESINK (object));
-
+
sink = GST_FAKESINK (object);
-
+
switch (prop_id) {
case ARG_NUM_SINKS:
g_value_set_int (value, GST_ELEMENT (sink)->numsinkpads);
}
}
-static void
-gst_fakesink_chain (GstPad *pad, GstData *_data)
+static void
+gst_fakesink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFakeSink *fakesink;
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
-
- if (!fakesink->silent) {
+
+ if (!fakesink->silent) {
g_free (fakesink->last_message);
- fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
- GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
-
+ fakesink->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
+ GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
+
g_object_notify (G_OBJECT (fakesink), "last_message");
}
-
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
- if (fakesink->sync && fakesink->clock) {
- gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
- gst_element_set_time (GST_ELEMENT (fakesink), value);
+ if (fakesink->sync && fakesink->clock) {
+ gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
+
+ gst_element_set_time (GST_ELEMENT (fakesink), value);
}
default:
gst_pad_event_default (pad, event);
- break;
+ break;
}
return;
}
- if (fakesink->sync && fakesink->clock) {
+ if (fakesink->sync && fakesink->clock) {
gst_element_wait (GST_ELEMENT (fakesink), GST_BUFFER_TIMESTAMP (buf));
}
- if (!fakesink->silent) {
+ if (!fakesink->silent) {
g_free (fakesink->last_message);
- fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
- G_GINT64_FORMAT ", duration: %"
- G_GINT64_FORMAT ", offset: %"
- G_GINT64_FORMAT ", flags: %d) %p",
- GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf),
- GST_BUFFER_TIMESTAMP (buf),
- GST_BUFFER_DURATION (buf),
- GST_BUFFER_OFFSET (buf),
- GST_BUFFER_FLAGS (buf), buf);
-
+ fakesink->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
+ G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %"
+ G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf),
+ GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf),
+ GST_BUFFER_FLAGS (buf), buf);
+
g_object_notify (G_OBJECT (fakesink), "last_message");
}
if (fakesink->signal_handoffs)
- g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
+ g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
+ buf, pad);
if (fakesink->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
static GstElementStateReturn
-gst_fakesink_change_state (GstElement *element)
+gst_fakesink_change_state (GstElement * element)
{
GstFakeSink *fakesink = GST_FAKESINK (element);
GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
return GST_STATE_FAILURE;
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FAKESINK \
(gst_fakesink_get_type())
#define GST_FAKESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FAKESINK))
#define GST_IS_FAKESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK))
-
-typedef enum {
+ typedef enum
+{
FAKESINK_STATE_ERROR_NONE = 0,
FAKESINK_STATE_ERROR_NULL_READY,
FAKESINK_STATE_ERROR_READY_PAUSED,
typedef struct _GstFakeSink GstFakeSink;
typedef struct _GstFakeSinkClass GstFakeSinkClass;
-struct _GstFakeSink {
- GstElement element;
+struct _GstFakeSink
+{
+ GstElement element;
- gboolean silent;
- gboolean dump;
- gboolean sync;
- gboolean signal_handoffs;
- GstClock *clock;
+ gboolean silent;
+ gboolean dump;
+ gboolean sync;
+ gboolean signal_handoffs;
+ GstClock *clock;
GstFakeSinkStateError state_error;
- gchar *last_message;
+ gchar *last_message;
};
-struct _GstFakeSinkClass {
+struct _GstFakeSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad);
+ void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad);
};
-GType gst_fakesink_get_type(void);
+GType gst_fakesink_get_type (void);
-gboolean gst_fakesink_factory_init (GstElementFactory *factory);
+gboolean gst_fakesink_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_FAKESINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fakesrc_debug);
#define GST_CAT_DEFAULT gst_fakesrc_debug
-GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS (
- "Fake Source",
- "Source",
- "Push empty (no data) buffers around",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ("Fake Source",
+ "Source",
+ "Push empty (no data) buffers around",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* FakeSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUM_SOURCES,
ARG_LOOP_BASED,
ARG_LAST_MESSAGE,
};
-GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
static GType
-gst_fakesrc_output_get_type (void)
+gst_fakesrc_output_get_type (void)
{
static GType fakesrc_output_type = 0;
static GEnumValue fakesrc_output[] = {
- { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
- { FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"},
- { FAKESRC_PING_PONG, "3", "Ping-Pong"},
- { FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"},
- { FAKESRC_RANDOM, "5", "Random"},
- { FAKESRC_PATTERN_LOOP, "6", "Patttern loop"},
- { FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"},
- { FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
+ {FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
+ {FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"},
+ {FAKESRC_PING_PONG, "3", "Ping-Pong"},
+ {FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"},
+ {FAKESRC_RANDOM, "5", "Random"},
+ {FAKESRC_PATTERN_LOOP, "6", "Patttern loop"},
+ {FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"},
+ {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
{0, NULL, NULL},
};
if (!fakesrc_output_type) {
- fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
+ fakesrc_output_type =
+ g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
}
return fakesrc_output_type;
}
#define GST_TYPE_FAKESRC_DATA (gst_fakesrc_data_get_type())
static GType
-gst_fakesrc_data_get_type (void)
+gst_fakesrc_data_get_type (void)
{
static GType fakesrc_data_type = 0;
static GEnumValue fakesrc_data[] = {
- { FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
- { FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
+ {FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
+ {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{0, NULL, NULL},
};
if (!fakesrc_data_type) {
#define GST_TYPE_FAKESRC_SIZETYPE (gst_fakesrc_sizetype_get_type())
static GType
-gst_fakesrc_sizetype_get_type (void)
+gst_fakesrc_sizetype_get_type (void)
{
static GType fakesrc_sizetype_type = 0;
static GEnumValue fakesrc_sizetype[] = {
- { FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
- { FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
- { FAKESRC_SIZETYPE_RANDOM, "3", "Random sized buffers (sizemin <= size <= sizemax)"},
+ {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
+ {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
+ {FAKESRC_SIZETYPE_RANDOM, "3",
+ "Random sized buffers (sizemin <= size <= sizemax)"},
{0, NULL, NULL},
};
if (!fakesrc_sizetype_type) {
- fakesrc_sizetype_type = g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
+ fakesrc_sizetype_type =
+ g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
}
return fakesrc_sizetype_type;
}
#define GST_TYPE_FAKESRC_FILLTYPE (gst_fakesrc_filltype_get_type())
static GType
-gst_fakesrc_filltype_get_type (void)
+gst_fakesrc_filltype_get_type (void)
{
static GType fakesrc_filltype_type = 0;
static GEnumValue fakesrc_filltype[] = {
- { FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"},
- { FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"},
- { FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
- { FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
- { FAKESRC_FILLTYPE_PATTERN_CONT, "5", "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
+ {FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"},
+ {FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"},
+ {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
+ {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
+ {FAKESRC_FILLTYPE_PATTERN_CONT, "5",
+ "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
{0, NULL, NULL},
};
if (!fakesrc_filltype_type) {
- fakesrc_filltype_type = g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
+ fakesrc_filltype_type =
+ g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
}
return fakesrc_filltype_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fakesrc_debug, "fakesrc", 0, "fakesrc element");
-GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ,const gchar *unused);
-static void gst_fakesrc_update_functions (GstFakeSrc *src);
-static void gst_fakesrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fakesrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static GstPad *gst_fakesrc_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
+static void gst_fakesrc_update_functions (GstFakeSrc * src);
+static void gst_fakesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fakesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fakesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_fakesrc_change_state (GstElement * element);
-static GstData* gst_fakesrc_get (GstPad *pad);
-static void gst_fakesrc_loop (GstElement *element);
+static GstData *gst_fakesrc_get (GstPad * pad);
+static void gst_fakesrc_loop (GstElement * element);
static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 };
static void
gst_fakesrc_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_set_details (gstelement_class, &gst_fakesrc_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesrc_src_template));
}
static void
-gst_fakesrc_class_init (GstFakeSrcClass *klass)
+gst_fakesrc_class_init (GstFakeSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
- g_param_spec_int ("num-sources", "num-sources", "Number of sources",
- 1, G_MAXINT, 1, G_PARAM_READABLE));
+ g_param_spec_int ("num-sources", "num-sources", "Number of sources",
+ 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
- g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("loop-based", "loop-based",
+ "Enable loop-based operation", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
- g_param_spec_enum ("output", "output", "Output method (currently unused)",
- GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
+ g_param_spec_enum ("output", "output", "Output method (currently unused)",
+ GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
- g_param_spec_enum ("data", "data", "Data allocation method",
- GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
+ g_param_spec_enum ("data", "data", "Data allocation method",
+ GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE,
- g_param_spec_enum ("sizetype", "sizetype", "How to determine buffer sizes",
- GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
+ g_param_spec_enum ("sizetype", "sizetype",
+ "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE,
+ FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
- g_param_spec_int ("sizemin","sizemin","Minimum buffer size",
- 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0,
+ G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
- g_param_spec_int ("sizemax","sizemax","Maximum buffer size",
- 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0,
+ G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
- g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation",
- 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
+ g_param_spec_int ("parentsize", "parentsize",
+ "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT,
+ DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
- g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
- GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
+ g_param_spec_enum ("filltype", "filltype",
+ "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE,
+ FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
- g_param_spec_string ("pattern", "pattern", "pattern",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("pattern", "pattern", "pattern", NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
- g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("num-buffers", "num-buffers",
+ "Number of buffers to output before sending EOS", G_MININT, G_MAXINT,
+ 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
- g_param_spec_boolean ("eos", "eos", "Send out the EOS event?",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "The last status message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message",
+ "The last status message", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent",
+ "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
- g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
+ "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
- GST_TYPE_BUFFER, GST_TYPE_PAD);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
+ GST_TYPE_BUFFER, GST_TYPE_PAD);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
}
-static void
-gst_fakesrc_init (GstFakeSrc *fakesrc)
+static void
+gst_fakesrc_init (GstFakeSrc * fakesrc)
{
GstPad *pad;
fakesrc->last_message = NULL;
}
-static GstPad*
-gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_fakesrc_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *srcpad;
}
static const GstFormat *
-gst_fakesrc_get_formats (GstPad *pad)
+gst_fakesrc_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_DEFAULT,
}
static const GstQueryType *
-gst_fakesrc_get_query_types (GstPad *pad)
+gst_fakesrc_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
}
static gboolean
-gst_fakesrc_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_fakesrc_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFakeSrc *src = GST_FAKESRC (GST_PAD_PARENT (pad));
break;
default:
return FALSE;
- }
+ }
return TRUE;
}
static const GstEventMask *
-gst_fakesrc_get_event_mask (GstPad *pad)
+gst_fakesrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP },
- { GST_EVENT_FLUSH, 0 },
- { 0, 0 },
+ {GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP},
+ {GST_EVENT_FLUSH, 0},
+ {0, 0},
};
return masks;
}
static gboolean
-gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
+gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
{
GstFakeSrc *src;
src->buffer_count = GST_EVENT_SEEK_OFFSET (event);
if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
- break;
+ break;
}
/* else we do a flush too */
case GST_EVENT_SEEK_SEGMENT:
src->segment_start = GST_EVENT_SEEK_OFFSET (event);
src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
src->buffer_count = src->segment_start;
- src->segment_loop = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
+ src->segment_loop =
+ GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
}
static void
-gst_fakesrc_update_functions (GstFakeSrc *src)
+gst_fakesrc_update_functions (GstFakeSrc * src)
{
GList *pads;
if (src->loop_based) {
- gst_element_set_loop_function (GST_ELEMENT (src), GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
- }
- else {
+ gst_element_set_loop_function (GST_ELEMENT (src),
+ GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
+ } else {
gst_element_set_loop_function (GST_ELEMENT (src), NULL);
}
if (src->loop_based) {
gst_pad_set_get_function (pad, NULL);
- }
- else {
+ } else {
gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get));
}
}
static void
-gst_fakesrc_alloc_parent (GstFakeSrc *src)
+gst_fakesrc_alloc_parent (GstFakeSrc * src)
{
GstBuffer *buf;
}
static void
-gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFakeSrc *src;
/* it's not null if we got it, but it might not be ours */
src = GST_FAKESRC (object);
-
+
switch (prop_id) {
case ARG_LOOP_BASED:
src->loop_based = g_value_get_boolean (value);
src->data = g_value_get_enum (value);
if (src->data == FAKESRC_DATA_SUBBUFFER) {
- if (!src->parent)
- gst_fakesrc_alloc_parent (src);
+ if (!src->parent)
+ gst_fakesrc_alloc_parent (src);
} else {
- if (src->parent) {
- gst_buffer_unref (src->parent);
- src->parent = NULL;
- }
+ if (src->parent) {
+ gst_buffer_unref (src->parent);
+ src->parent = NULL;
+ }
}
break;
case ARG_SIZETYPE:
break;
case ARG_EOS:
src->eos = g_value_get_boolean (value);
- GST_INFO ( "will EOS on next buffer");
+ GST_INFO ("will EOS on next buffer");
break;
case ARG_SILENT:
src->silent = g_value_get_boolean (value);
}
}
-static void
-gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fakesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFakeSrc *src;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FAKESRC (object));
-
+
src = GST_FAKESRC (object);
-
+
switch (prop_id) {
case ARG_NUM_SOURCES:
g_value_set_int (value, GST_ELEMENT (src)->numsrcpads);
}
static void
-gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf)
+gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
{
- if (GST_BUFFER_SIZE (buf) == 0)
+ if (GST_BUFFER_SIZE (buf) == 0)
return;
switch (src->filltype) {
guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) {
- *ptr++ = (gint8)((255.0)*rand()/(RAND_MAX));
+ *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX));
}
break;
}
}
}
-static GstBuffer*
-gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size)
+static GstBuffer *
+gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size)
{
GstBuffer *buf;
buf = gst_buffer_new ();
- GST_BUFFER_SIZE(buf) = size;
+ GST_BUFFER_SIZE (buf) = size;
- if (size != 0) {
+ if (size != 0) {
switch (src->filltype) {
case FAKESRC_FILLTYPE_NOTHING:
- GST_BUFFER_DATA(buf) = g_malloc (size);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc (size);
+ break;
case FAKESRC_FILLTYPE_NULL:
- GST_BUFFER_DATA(buf) = g_malloc0 (size);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc0 (size);
+ break;
case FAKESRC_FILLTYPE_RANDOM:
case FAKESRC_FILLTYPE_PATTERN:
case FAKESRC_FILLTYPE_PATTERN_CONT:
default:
- GST_BUFFER_DATA(buf) = g_malloc (size);
- gst_fakesrc_prepare_buffer (src, buf);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc (size);
+ gst_fakesrc_prepare_buffer (src, buf);
+ break;
}
}
}
static guint
-gst_fakesrc_get_size (GstFakeSrc *src)
+gst_fakesrc_get_size (GstFakeSrc * src)
{
guint size;
size = src->sizemax;
break;
case FAKESRC_SIZETYPE_RANDOM:
- size = src->sizemin + (guint8)(((gfloat)src->sizemax)*rand()/(RAND_MAX + (gfloat)src->sizemin));
+ size =
+ src->sizemin +
+ (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX +
+ (gfloat) src->sizemin));
break;
case FAKESRC_SIZETYPE_NULL:
default:
- size = 0;
+ size = 0;
break;
}
}
static GstBuffer *
-gst_fakesrc_create_buffer (GstFakeSrc *src)
+gst_fakesrc_create_buffer (GstFakeSrc * src)
{
GstBuffer *buf;
guint size;
size = gst_fakesrc_get_size (src);
if (size == 0)
- return gst_buffer_new();
+ return gst_buffer_new ();
switch (src->data) {
case FAKESRC_DATA_ALLOCATE:
}
/* see if it's large enough */
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
- buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
- src->parentoffset += size;
- }
- else {
+ buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
+ src->parentoffset += size;
+ } else {
/* the parent is useless now */
gst_buffer_unref (src->parent);
src->parent = NULL;
/* try again (this will allocate a new parent) */
- return gst_fakesrc_create_buffer (src);
+ return gst_fakesrc_create_buffer (src);
}
gst_fakesrc_prepare_buffer (src, buf);
break;
default:
g_warning ("fakesrc: dunno how to allocate buffers !");
- buf = gst_buffer_new();
+ buf = gst_buffer_new ();
break;
}
if (dump) {
}
static GstData *
-gst_fakesrc_get(GstPad *pad)
+gst_fakesrc_get (GstPad * pad)
{
GstFakeSrc *src;
GstBuffer *buf;
if (src->need_flush) {
src->need_flush = FALSE;
- return GST_DATA(gst_event_new (GST_EVENT_FLUSH));
+ return GST_DATA (gst_event_new (GST_EVENT_FLUSH));
}
if (src->buffer_count == src->segment_end) {
if (src->segment_loop) {
- return GST_DATA(gst_event_new (GST_EVENT_SEGMENT_DONE));
- }
- else {
+ return GST_DATA (gst_event_new (GST_EVENT_SEGMENT_DONE));
+ } else {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
}
if (src->rt_num_buffers == 0) {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
- }
- else {
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ } else {
if (src->rt_num_buffers > 0)
src->rt_num_buffers--;
}
if (src->eos) {
- GST_INFO ( "fakesrc is setting eos on pad");
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ GST_INFO ("fakesrc is setting eos on pad");
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
buf = gst_fakesrc_create_buffer (src);
if (!src->silent) {
g_free (src->last_message);
- src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
- G_GUINT64_FORMAT " ) %p",
- GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
+ src->last_message =
+ g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
+ G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (src), "last_message");
}
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
- buf, pad);
+ buf, pad);
GST_LOG_OBJECT (src, "post handoff emit");
}
* generate an empty buffer and push it to the next element.
*/
static void
-gst_fakesrc_loop(GstElement *element)
+gst_fakesrc_loop (GstElement * element)
{
GstFakeSrc *src;
const GList *pads;
- g_return_if_fail(element != NULL);
- g_return_if_fail(GST_IS_FAKESRC(element));
+ g_return_if_fail (element != NULL);
+ g_return_if_fail (GST_IS_FAKESRC (element));
src = GST_FAKESRC (element);
}
static GstElementStateReturn
-gst_fakesrc_change_state (GstElement *element)
+gst_fakesrc_change_state (GstElement * element)
{
GstFakeSrc *fakesrc;
break;
case GST_STATE_PAUSED_TO_READY:
if (fakesrc->parent) {
- gst_buffer_unref (fakesrc->parent);
- fakesrc->parent = NULL;
+ gst_buffer_unref (fakesrc->parent);
+ fakesrc->parent = NULL;
}
g_free (fakesrc->last_message);
fakesrc->last_message = NULL;
return GST_STATE_SUCCESS;
}
-
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
FAKESRC_FIRST_LAST_LOOP = 1,
FAKESRC_LAST_FIRST_LOOP,
FAKESRC_PING_PONG,
FAKESRC_GET_ALWAYS_SUCEEDS
} GstFakeSrcOutputType;
-typedef enum {
+typedef enum
+{
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
} GstFakeSrcDataType;
-typedef enum {
+typedef enum
+{
FAKESRC_SIZETYPE_NULL = 1,
FAKESRC_SIZETYPE_FIXED,
FAKESRC_SIZETYPE_RANDOM
} GstFakeSrcSizeType;
-typedef enum {
+typedef enum
+{
FAKESRC_FILLTYPE_NOTHING = 1,
FAKESRC_FILLTYPE_NULL,
FAKESRC_FILLTYPE_RANDOM,
typedef struct _GstFakeSrc GstFakeSrc;
typedef struct _GstFakeSrcClass GstFakeSrcClass;
-struct _GstFakeSrc {
- GstElement element;
+struct _GstFakeSrc
+{
+ GstElement element;
- gboolean loop_based;
- gboolean eos;
+ gboolean loop_based;
+ gboolean eos;
GstFakeSrcOutputType output;
- GstFakeSrcDataType data;
- GstFakeSrcSizeType sizetype;
- GstFakeSrcFillType filltype;
-
- guint sizemin;
- guint sizemax;
- GstBuffer *parent;
- guint parentsize;
- guint parentoffset;
- guint8 pattern_byte;
- gchar *pattern;
- GList *patternlist;
- gint64 segment_start;
- gint64 segment_end;
- gboolean segment_loop;
- gint num_buffers;
- gint rt_num_buffers; /* we are going to change this at runtime */
- guint64 buffer_count;
- gboolean silent;
- gboolean signal_handoffs;
- gboolean dump;
- gboolean need_flush;
-
- gchar *last_message;
+ GstFakeSrcDataType data;
+ GstFakeSrcSizeType sizetype;
+ GstFakeSrcFillType filltype;
+
+ guint sizemin;
+ guint sizemax;
+ GstBuffer *parent;
+ guint parentsize;
+ guint parentoffset;
+ guint8 pattern_byte;
+ gchar *pattern;
+ GList *patternlist;
+ gint64 segment_start;
+ gint64 segment_end;
+ gboolean segment_loop;
+ gint num_buffers;
+ gint rt_num_buffers; /* we are going to change this at runtime */
+ guint64 buffer_count;
+ gboolean silent;
+ gboolean signal_handoffs;
+ gboolean dump;
+ gboolean need_flush;
+
+ gchar *last_message;
};
-struct _GstFakeSrcClass {
+struct _GstFakeSrcClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad);
+ void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad);
};
-GType gst_fakesrc_get_type(void);
+GType gst_fakesrc_get_type (void);
-gboolean gst_fakesrc_factory_init (GstElementFactory *factory);
+gboolean gst_fakesrc_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_FAKESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fdsink_debug);
#define GST_CAT_DEFAULT gst_fdsink_debug
-GstElementDetails gst_fdsink_details = GST_ELEMENT_DETAILS (
- "Filedescriptor Sink",
- "Sink/File",
- "Write data to a file descriptor",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fdsink_details =
+GST_ELEMENT_DETAILS ("Filedescriptor Sink",
+ "Sink/File",
+ "Write data to a file descriptor",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FdSink signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FD
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fdsink_debug, "fdsink", 0, "fdsink element");
-GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fdsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fdsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fdsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_fdsink_chain (GstPad *pad,GstData *_data);
+static void gst_fdsink_chain (GstPad * pad, GstData * _data);
static void
gst_fdsink_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_fdsink_details);
}
static void
-gst_fdsink_class_init (GstFdSinkClass *klass)
+gst_fdsink_class_init (GstFdSinkClass * klass)
{
GObjectClass *gobject_class;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
- 0, G_MAXINT, 1, G_PARAM_READWRITE));
+ g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
+ 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property;
}
-static void
-gst_fdsink_init (GstFdSink *fdsink)
+static void
+gst_fdsink_init (GstFdSink * fdsink)
{
fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad);
fdsink->fd = 1;
}
-static void
-gst_fdsink_chain (GstPad *pad, GstData *_data)
+static void
+gst_fdsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFdSink *fdsink;
g_return_if_fail (buf != NULL);
fdsink = GST_FDSINK (gst_pad_get_parent (pad));
-
+
g_return_if_fail (fdsink->fd >= 0);
-
+
if (GST_BUFFER_DATA (buf)) {
- GST_DEBUG ("writing %d bytes to file descriptor %d",GST_BUFFER_SIZE (buf), fdsink->fd);
+ GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf),
+ fdsink->fd);
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
-
+
gst_buffer_unref (buf);
}
-static void
-gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_fdsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFdSink *fdsink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSINK (object));
-
+
fdsink = GST_FDSINK (object);
switch (prop_id) {
}
}
-static void
-gst_fdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fdsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFdSink *fdsink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSINK (object));
-
+
fdsink = GST_FDSINK (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FDSINK \
(gst_fdsink_get_type())
#define GST_FDSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSINK))
#define GST_IS_FDSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK))
-
typedef struct _GstFdSink GstFdSink;
typedef struct _GstFdSinkClass GstFdSinkClass;
-struct _GstFdSink {
+struct _GstFdSink
+{
GstElement element;
GstPad *sinkpad;
int fd;
};
-struct _GstFdSinkClass {
+struct _GstFdSinkClass
+{
GstElementClass parent_class;
};
-GType gst_fdsink_get_type(void);
+GType gst_fdsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_FDSINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fdsrc_debug);
#define GST_CAT_DEFAULT gst_fdsrc_debug
-GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS (
- "Disk Source",
- "Source/File",
- "Synchronous read from a file",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source",
+ "Source/File",
+ "Synchronous read from a file",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FdSrc signals and args */
-enum {
+enum
+{
SIGNAL_TIMEOUT,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FD,
ARG_BLOCKSIZE,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
-GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fdsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fdsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fdsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fdsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstData * gst_fdsrc_get (GstPad *pad);
+static GstData *gst_fdsrc_get (GstPad * pad);
static void
gst_fdsrc_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_fdsrc_details);
}
static void
-gst_fdsrc_class_init (GstFdSrcClass *klass)
+gst_fdsrc_class_init (GstFdSrcClass * klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
- g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
- 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("blocksize", "Block size",
+ "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT,
- g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
gst_fdsrc_signals[SIGNAL_TIMEOUT] =
- g_signal_new ("timeout", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_fdsrc_set_property;
gobject_class->get_property = gst_fdsrc_get_property;
}
-static void gst_fdsrc_init(GstFdSrc *fdsrc) {
+static void
+gst_fdsrc_init (GstFdSrc * fdsrc)
+{
fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
-
+
gst_pad_set_get_function (fdsrc->srcpad, gst_fdsrc_get);
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
}
-static void
-gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFdSrc *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
-
+
src = GST_FDSRC (object);
switch (prop_id) {
}
}
-static void
-gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fdsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFdSrc *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
-
+
src = GST_FDSRC (object);
switch (prop_id) {
}
static GstData *
-gst_fdsrc_get(GstPad *pad)
+gst_fdsrc_get (GstPad * pad)
{
GstFdSrc *src;
GstBuffer *buf;
FD_ZERO (&readfds);
FD_SET (src->fd, &readfds);
- if (src->timeout != 0)
- {
+ if (src->timeout != 0) {
GST_TIME_TO_TIMEVAL (src->timeout, t);
- }
- else
+ } else
tp = NULL;
- do
- {
+ do {
retval = select (1, &readfds, NULL, NULL, tp);
- } while (retval == -1 && errno == EINTR); /* retry if interrupted */
+ } while (retval == -1 && errno == EINTR); /* retry if interrupted */
- if (retval == -1)
- {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("select on file descriptor: %s.", g_strerror(errno)));
+ if (retval == -1) {
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("select on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- else if (retval == 0)
- {
+ } else if (retval == 0) {
g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0);
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
- do
- {
+ do {
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize);
- } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
+ } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
- if (readbytes > 0)
- {
+ if (readbytes > 0) {
GST_BUFFER_OFFSET (buf) = src->curoffset;
GST_BUFFER_SIZE (buf) = readbytes;
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
/* we're done, return the buffer */
return GST_DATA (buf);
- }
- else if (readbytes == 0)
- {
+ } else if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- else
- {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("read on file descriptor: %s.", g_strerror(errno)));
+ } else {
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("read on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FDSRC \
(gst_fdsrc_get_type())
#define GST_FDSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSRC))
#define GST_IS_FDSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC))
-
-
typedef struct _GstFdSrc GstFdSrc;
typedef struct _GstFdSrcClass GstFdSrcClass;
-struct _GstFdSrc {
+struct _GstFdSrc
+{
GstElement element;
/* pads */
GstPad *srcpad;
/* fd */
gint fd;
- gulong curoffset; /* current offset in file */
- gulong blocksize; /* bytes per read */
- guint64 timeout; /* read timeout, in nanoseconds */
-
- gulong seq; /* buffer sequence number */
+ gulong curoffset; /* current offset in file */
+ gulong blocksize; /* bytes per read */
+ guint64 timeout; /* read timeout, in nanoseconds */
+
+ gulong seq; /* buffer sequence number */
};
-struct _GstFdSrcClass {
+struct _GstFdSrcClass
+{
GstElementClass parent_class;
/* signals */
- void (*timeout) (GstElement *element);
+ void (*timeout) (GstElement * element);
};
-GType gst_fdsrc_get_type(void);
+GType gst_fdsrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_FDSRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_filesink_debug);
#define GST_CAT_DEFAULT gst_filesink_debug
-GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS (
- "File Sink",
- "Sink/File",
- "Write stream to a file",
- "Thomas <thomas@apestaart.org>"
-);
+GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ("File Sink",
+ "Sink/File",
+ "Write stream to a file",
+ "Thomas <thomas@apestaart.org>");
/* FileSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
static const GstFormat *
-gst_filesink_get_formats (GstPad *pad)
+gst_filesink_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_BYTES,
}
static const GstQueryType *
-gst_filesink_get_query_types (GstPad *pad)
+gst_filesink_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
return types;
}
-static void gst_filesink_dispose (GObject *object);
+static void gst_filesink_dispose (GObject * object);
+
+static void gst_filesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_filesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_filesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_filesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static gboolean gst_filesink_open_file (GstFileSink * sink);
+static void gst_filesink_close_file (GstFileSink * sink);
-static gboolean gst_filesink_open_file (GstFileSink *sink);
-static void gst_filesink_close_file (GstFileSink *sink);
+static gboolean gst_filesink_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_filesink_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+static void gst_filesink_chain (GstPad * pad, GstData * _data);
-static gboolean gst_filesink_handle_event (GstPad *pad, GstEvent *event);
-static gboolean gst_filesink_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-static void gst_filesink_chain (GstPad *pad,GstData *_data);
+static void gst_filesink_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
-static void gst_filesink_uri_handler_init (gpointer g_iface, gpointer iface_data);
-
-static GstElementStateReturn gst_filesink_change_state (GstElement *element);
+static GstElementStateReturn gst_filesink_change_state (GstElement * element);
static guint gst_filesink_signals[LAST_SIGNAL] = { 0 };
NULL,
NULL
};
- g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, &urihandler_info);
- GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, "filesink element");
+ g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER,
+ &urihandler_info);
+ GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0,
+ "filesink element");
}
-GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, _do_init);
-
+GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
+
static void
gst_filesink_base_init (gpointer g_class)
gst_element_class_set_details (gstelement_class, &gst_filesink_details);
}
static void
-gst_filesink_class_init (GstFileSinkClass *klass)
+gst_filesink_class_init (GstFileSinkClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
- g_param_spec_string ("location", "File Location", "Location of the file to write",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the file to write", NULL, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_filesink_set_property;
gobject_class->get_property = gst_filesink_get_property;
- gobject_class->dispose = gst_filesink_dispose;
+ gobject_class->dispose = gst_filesink_dispose;
}
-static void
-gst_filesink_init (GstFileSink *filesink)
+static void
+gst_filesink_init (GstFileSink * filesink)
{
GstPad *pad;
gst_element_add_pad (GST_ELEMENT (filesink), pad);
gst_pad_set_chain_function (pad, gst_filesink_chain);
- GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (GST_ELEMENT (filesink), GST_ELEMENT_EVENT_AWARE);
gst_pad_set_query_function (pad, gst_filesink_pad_query);
gst_pad_set_query_type_function (pad, gst_filesink_get_query_types);
filesink->file = NULL;
}
static void
-gst_filesink_dispose (GObject *object)
+gst_filesink_dispose (GObject * object)
{
GstFileSink *sink = GST_FILESINK (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
-
+
g_free (sink->uri);
sink->uri = NULL;
g_free (sink->filename);
sink->filename = NULL;
}
+
static gboolean
-gst_filesink_set_location (GstFileSink *sink, const gchar *location)
+gst_filesink_set_location (GstFileSink * sink, const gchar * location)
{
/* the element must be stopped or paused in order to do this */
if (GST_STATE (sink) > GST_STATE_PAUSED)
sink->filename = NULL;
sink->uri = NULL;
}
-
+
if (GST_STATE (sink) == GST_STATE_PAUSED)
gst_filesink_open_file (sink);
return TRUE;
}
static void
-gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_filesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFileSink *sink;
}
}
-static void
-gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_filesink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFileSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FILESINK (object));
-
+
sink = GST_FILESINK (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->filename);
}
static gboolean
-gst_filesink_open_file (GstFileSink *sink)
+gst_filesink_open_file (GstFileSink * sink)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN), FALSE);
/* open the file */
- if (sink->filename == NULL || sink->filename[0] == '\0')
- {
+ if (sink->filename == NULL || sink->filename[0] == '\0') {
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
- (_("No file name specified for writing.")), (NULL));
+ (_("No file name specified for writing.")), (NULL));
return FALSE;
}
sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), sink->filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open file \"%s\" for writing."), sink->filename),
+ GST_ERROR_SYSTEM);
return FALSE;
}
}
static void
-gst_filesink_close_file (GstFileSink *sink)
+gst_filesink_close_file (GstFileSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN));
- if (fclose (sink->file) != 0)
- {
+ if (fclose (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), sink->filename),
- GST_ERROR_SYSTEM);
- }
- else {
+ (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
+ } else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
}
}
static gboolean
-gst_filesink_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_filesink_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFileSink *sink = GST_FILESINK (GST_PAD_PARENT (pad));
case GST_QUERY_TOTAL:
switch (*format) {
case GST_FORMAT_BYTES:
- if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) {
- *value = sink->data_written; /* FIXME - doesn't the kernel provide
- such a function? */
- break;
- }
- default:
+ if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
+ *value = sink->data_written; /* FIXME - doesn't the kernel provide
+ such a function? */
+ break;
+ }
+ default:
return FALSE;
}
break;
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_BYTES:
- if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) {
- *value = ftell (sink->file);
- break;
- }
- default:
+ if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
+ *value = ftell (sink->file);
+ break;
+ }
+ default:
return FALSE;
}
break;
/* handle events (search) */
static gboolean
-gst_filesink_handle_event (GstPad *pad, GstEvent *event)
+gst_filesink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
GstFileSink *filesink;
filesink = GST_FILESINK (gst_pad_get_parent (pad));
- g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN),
- FALSE);
+ g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), FALSE);
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
case GST_EVENT_SEEK:
g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES,
- FALSE);
+ FALSE);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
- if (fflush (filesink->file))
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- GST_ERROR_SYSTEM);
-
- switch (GST_EVENT_SEEK_METHOD(event))
- {
- case GST_SEEK_METHOD_SET:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
- break;
- case GST_SEEK_METHOD_CUR:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
- break;
- case GST_SEEK_METHOD_END:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
- break;
- default:
- g_warning ("unknown seek method!");
- break;
+ if (fflush (filesink->file))
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ GST_ERROR_SYSTEM);
+
+ switch (GST_EVENT_SEEK_METHOD (event)) {
+ case GST_SEEK_METHOD_SET:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
+ break;
+ case GST_SEEK_METHOD_CUR:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
+ break;
+ case GST_SEEK_METHOD_END:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
+ break;
+ default:
+ g_warning ("unknown seek method!");
+ break;
}
break;
case GST_EVENT_DISCONTINUOUS:
{
gint64 offset;
-
+
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset))
- fseek (filesink->file, offset, SEEK_SET);
+ fseek (filesink->file, offset, SEEK_SET);
gst_event_unref (event);
break;
}
case GST_EVENT_FLUSH:
if (fflush (filesink->file)) {
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- GST_ERROR_SYSTEM);
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ GST_ERROR_SYSTEM);
}
break;
case GST_EVENT_EOS:
*
* take the buffer from the pad and write to file if it's open
*/
-static void
-gst_filesink_chain (GstPad *pad, GstData *_data)
+static void
+gst_filesink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFileSink *filesink;
filesink = GST_FILESINK (gst_pad_get_parent (pad));
- if (GST_IS_EVENT(buf))
- {
- gst_filesink_handle_event(pad, GST_EVENT(buf));
+ if (GST_IS_EVENT (buf)) {
+ gst_filesink_handle_event (pad, GST_EVENT (buf));
return;
}
- if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) {
guint bytes_written = 0, back_pending = 0;
- if (ftell(filesink->file) < filesink->data_written)
- back_pending = filesink->data_written - ftell(filesink->file);
+
+ if (ftell (filesink->file) < filesink->data_written)
+ back_pending = filesink->data_written - ftell (filesink->file);
while (bytes_written < GST_BUFFER_SIZE (buf)) {
size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
- GST_BUFFER_SIZE (buf) - bytes_written,
- filesink->file);
+ GST_BUFFER_SIZE (buf) - bytes_written,
+ filesink->file);
+
if (wrote <= 0) {
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- ("Only %d of %d bytes written: %s",
- bytes_written, GST_BUFFER_SIZE (buf),
- strerror (errno)));
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ ("Only %d of %d bytes written: %s",
+ bytes_written, GST_BUFFER_SIZE (buf), strerror (errno)));
break;
}
bytes_written += wrote;
gst_buffer_unref (buf);
g_signal_emit (G_OBJECT (filesink),
- gst_filesink_signals[SIGNAL_HANDOFF], 0,
- filesink);
+ gst_filesink_signals[SIGNAL_HANDOFF], 0, filesink);
}
static GstElementStateReturn
-gst_filesink_change_state (GstElement *element)
+gst_filesink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_FILESINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN))
- gst_filesink_close_file (GST_FILESINK (element));
+ gst_filesink_close_file (GST_FILESINK (element));
break;
case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) {
- if (!gst_filesink_open_file (GST_FILESINK (element)))
- return GST_STATE_FAILURE;
+ if (!gst_filesink_open_file (GST_FILESINK (element)))
+ return GST_STATE_FAILURE;
}
break;
}
return GST_URI_SINK;
}
static gchar **
-gst_filesink_uri_get_protocols(void)
+gst_filesink_uri_get_protocols (void)
{
- static gchar *protocols[] = {"file", NULL};
+ static gchar *protocols[] = { "file", NULL };
return protocols;
}
static const gchar *
-gst_filesink_uri_get_uri (GstURIHandler *handler)
+gst_filesink_uri_get_uri (GstURIHandler * handler)
{
GstFileSink *sink = GST_FILESINK (handler);
-
+
return sink->uri;
}
+
static gboolean
-gst_filesink_uri_set_uri (GstURIHandler *handler, const gchar *uri)
+gst_filesink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
gchar *protocol, *location;
gboolean ret;
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FILESINK \
(gst_filesink_get_type())
#define GST_FILESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESINK))
#define GST_IS_FILESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESINK))
-
typedef struct _GstFileSink GstFileSink;
typedef struct _GstFileSinkClass GstFileSinkClass;
-typedef enum {
- GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST,
+typedef enum
+{
+ GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSinkFlags;
-struct _GstFileSink {
+struct _GstFileSink
+{
GstElement element;
gchar *filename;
guint64 data_written;
};
-struct _GstFileSinkClass {
+struct _GstFileSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstPad *pad);
+ void (*handoff) (GstElement * element, GstPad * pad);
};
-GType gst_filesink_get_type(void);
+GType gst_filesink_get_type (void);
G_END_DECLS
-
#endif /* __GST_FILESINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_filesrc_debug);
#define GST_CAT_DEFAULT gst_filesrc_debug
-GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS (
- "File Source",
- "Source/File",
- "Read from arbitrary point in a file",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ("File Source",
+ "Source/File",
+ "Read from arbitrary point in a file",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
#define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024
/* FileSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_FD,
};
static const GstEventMask *
-gst_filesrc_get_event_mask (GstPad *pad)
+gst_filesrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
- GST_SEEK_METHOD_SET |
- GST_SEEK_METHOD_END |
- GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_FLUSH, 0 },
- { GST_EVENT_SIZE, 0 },
- { 0, 0 }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
+ GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_FLUSH, 0},
+ {GST_EVENT_SIZE, 0},
+ {0, 0}
};
return masks;
}
static const GstQueryType *
-gst_filesrc_get_query_types (GstPad *pad)
+gst_filesrc_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
}
static const GstFormat *
-gst_filesrc_get_formats (GstPad *pad)
+gst_filesrc_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_BYTES,
return formats;
}
-static void gst_filesrc_dispose (GObject *object);
+static void gst_filesrc_dispose (GObject * object);
-static void gst_filesrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_filesrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_filesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_filesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_filesrc_check_filesize (GstFileSrc *src);
-static GstData * gst_filesrc_get (GstPad *pad);
-static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event);
-static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
+static gboolean gst_filesrc_check_filesize (GstFileSrc * src);
+static GstData *gst_filesrc_get (GstPad * pad);
+static gboolean gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event);
+static gboolean gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
-static GstElementStateReturn gst_filesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_filesrc_change_state (GstElement * element);
-static void gst_filesrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
+static void gst_filesrc_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
static void
_do_init (GType filesrc_type)
NULL,
NULL
};
- g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, &urihandler_info);
+ g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER,
+ &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element");
}
-GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
-
+GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
+
static void
gst_filesrc_base_init (gpointer g_class)
{
gst_element_class_set_details (gstelement_class, &gst_filesrc_details);
}
static void
-gst_filesrc_class_init (GstFileSrcClass *klass)
+gst_filesrc_class_init (GstFileSrcClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
- gobject_class = (GObjectClass*)klass;
+ gobject_class = (GObjectClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("fd", "File-descriptor",
+ "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
- g_param_spec_string ("location", "File Location", "Location of the file to read",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the file to read", NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
- g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
- 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("blocksize", "Block size",
+ "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
- g_param_spec_ulong ("mmapsize", "mmap() Block Size",
- "Size in bytes of mmap()d regions",
- 0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("mmapsize", "mmap() Block Size",
+ "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
- g_param_spec_boolean ("touch", "Touch read data",
- "Touch data to force disk read",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("touch", "Touch read data",
+ "Touch data to force disk read", FALSE, G_PARAM_READWRITE));
- gobject_class->dispose = gst_filesrc_dispose;
- gobject_class->set_property = gst_filesrc_set_property;
- gobject_class->get_property = gst_filesrc_get_property;
+ gobject_class->dispose = gst_filesrc_dispose;
+ gobject_class->set_property = gst_filesrc_set_property;
+ gobject_class->get_property = gst_filesrc_get_property;
gstelement_class->change_state = gst_filesrc_change_state;
}
static void
-gst_filesrc_init (GstFileSrc *src)
+gst_filesrc_init (GstFileSrc * src)
{
src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (src->srcpad, gst_filesrc_get);
gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats);
gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
- src->pagesize = getpagesize();
+ src->pagesize = getpagesize ();
src->filename = NULL;
src->fd = 0;
src->touch = FALSE;
src->mapbuf = NULL;
- src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
+ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->seek_happened = FALSE;
}
static void
-gst_filesrc_dispose (GObject *object)
+gst_filesrc_dispose (GObject * object)
{
GstFileSrc *src;
}
static gboolean
-gst_filesrc_set_location (GstFileSrc *src, const gchar *location)
+gst_filesrc_set_location (GstFileSrc * src, const gchar * location)
{
/* the element must be stopped in order to do this */
- if (GST_STATE (src) != GST_STATE_READY &&
- GST_STATE (src) != GST_STATE_NULL)
+ if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL)
return FALSE;
- if (src->filename) g_free (src->filename);
- if (src->uri) g_free (src->uri);
+ if (src->filename)
+ g_free (src->filename);
+ if (src->uri)
+ g_free (src->uri);
/* clear the filename if we get a NULL (is that possible?) */
if (location == NULL) {
src->filename = NULL;
}
static void
-gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFileSrc *src;
break;
case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) {
- src->mapsize = g_value_get_ulong (value);
- g_object_notify (G_OBJECT (src), "mmapsize");
+ src->mapsize = g_value_get_ulong (value);
+ g_object_notify (G_OBJECT (src), "mmapsize");
} else {
- GST_INFO_OBJECT (src, "invalid mapsize, must be a multiple of pagesize, which is %d",
- src->pagesize);
+ GST_INFO_OBJECT (src,
+ "invalid mapsize, must be a multiple of pagesize, which is %d",
+ src->pagesize);
}
break;
case ARG_TOUCH:
}
static void
-gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_filesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFileSrc *src;
}
static void
-gst_filesrc_free_parent_mmap (GstBuffer *buf)
+gst_filesrc_free_parent_mmap (GstBuffer * buf)
{
- GST_LOG ("freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u",
+ GST_LOG ("freeing mmap()d buffer at %" G_GUINT64_FORMAT "+%u",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
#ifdef MADV_DONTNEED
munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
/* cast to unsigned long, since there's no gportable way to print
* guint64 as hex */
- GST_LOG ("unmapped region %08lx+%08lx at %p",
+ GST_LOG ("unmapped region %08lx+%08lx at %p",
(unsigned long) GST_BUFFER_OFFSET (buf),
- (unsigned long) GST_BUFFER_MAXSIZE (buf),
- GST_BUFFER_DATA (buf));
+ (unsigned long) GST_BUFFER_MAXSIZE (buf), GST_BUFFER_DATA (buf));
GST_BUFFER_DATA (buf) = NULL;
}
static GstBuffer *
-gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
+gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size)
{
GstBuffer *buf;
gint retval;
g_return_val_if_fail (offset >= 0, NULL);
- GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size);
+ GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",
+ offset, (unsigned long) size);
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), ("mmap call failed."));
return NULL;
- }
- else if (mmapregion == MAP_FAILED) {
+ } else if (mmapregion == MAP_FAILED) {
GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
- (unsigned long)size, src->fd, offset, strerror (errno));
+ (unsigned long) size, src->fd, offset, strerror (errno));
return NULL;
}
- GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
- (unsigned long)offset, (unsigned long)size, mmapregion);
+ GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
+ (unsigned long) offset, (unsigned long) size, mmapregion);
/* time to allocate a new mapbuf */
buf = gst_buffer_new ();
#ifdef MADV_SEQUENTIAL
/* madvise to tell the kernel what to do with it */
- retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
+ retval =
+ madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
#endif
/* fill in the rest of the fields */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
}
static GstBuffer *
-gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size)
+gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size)
{
size_t mapsize;
off_t mod, mapbase;
GstBuffer *ret;
mapbase = offset - mod;
- mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
+ mapsize =
+ ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
- map = gst_filesrc_map_region(src, mapbase, mapsize);
+ map = gst_filesrc_map_region (src, mapbase, mapsize);
if (map == NULL)
return NULL;
return ret;
}
- return gst_filesrc_map_region(src,offset,size);
+ return gst_filesrc_map_region (src, offset, size);
}
/**
* Push a new buffer from the filesrc at the current offset.
*/
static GstBuffer *
-gst_filesrc_get_mmap (GstFileSrc *src)
+gst_filesrc_get_mmap (GstFileSrc * src)
{
GstBuffer *buf = NULL;
size_t readsize, mapsize;
- off_t readend,mapstart,mapend;
+ off_t readend, mapstart, mapend;
int i;
/* calculate end pointers so we don't have to do so repeatedly later */
readsize = src->block_size;
- readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
+ readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
mapstart = GST_BUFFER_OFFSET (src->mapbuf);
mapsize = GST_BUFFER_SIZE (src->mapbuf);
- mapend = mapstart + mapsize; /* note this is the byte *after* the map */
+ mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) {
}
}
- GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx",
- (unsigned long)readsize, (unsigned long)readend,
- (unsigned long)mapstart, (unsigned long)mapend);
+ GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx",
+ (unsigned long) readsize, (unsigned long) readend,
+ (unsigned long) mapstart, (unsigned long) mapend);
/* if the start is past the mapstart */
if (src->curoffset >= mapstart) {
/* if the end is before the mapend, the buffer is in current mmap region... */
/* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) {
- GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
- src->curoffset, (int)readsize, mapstart, mapsize);
- buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
- readsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
+ src->curoffset, (int) readsize, mapstart, mapsize);
+ buf =
+ gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
+ readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset;
- /* if the start actually is within the current mmap region, map an overlap buffer */
+ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) {
- GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
- (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
+ (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
+ (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
- return NULL;
+ return NULL;
}
/* the only other option is that buffer is totally outside, which means we search for it */
- /* now we can assume that the start is *before* the current mmap region */
- /* if the readend is past mapstart, we have two options */
+ /* now we can assume that the start is *before* the current mmap region */
+ /* if the readend is past mapstart, we have two options */
} else if (readend >= mapstart) {
/* either the read buffer overlaps the start of the mmap region */
/* or the read buffer fully contains the current mmap region */
- /* either way, it's really not relevant, we just create a new region anyway*/
- GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
- (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
+ /* either way, it's really not relevant, we just create a new region anyway */
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
+ (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
+ (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
return NULL;
if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */
GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",
- src->curoffset,(int)readsize);
-
+ src->curoffset, (int) readsize);
+
/* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
- GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
- src->curoffset,(int)readsize,(int)src->mapsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
+ src->curoffset, (int) readsize, (int) src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
return NULL;
- /* otherwise we will create a new mmap region and set it to the default */
+ /* otherwise we will create a new mmap region and set it to the default */
} else {
size_t mapsize;
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
- GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
- src->curoffset, readsize, nextmap, src->mapsize);
+
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
+ src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */
- gst_buffer_unref(src->mapbuf);
+ gst_buffer_unref (src->mapbuf);
mapsize = src->mapsize;
/* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) {
GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d",
- readsize, (int)mapsize);
- mapsize <<=1;
+ readsize, (int) mapsize);
+ mapsize <<= 1;
}
/* create a new one */
src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize);
return NULL;
/* subbuffer it */
- buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, readsize);
- GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
+ buf =
+ gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap,
+ readsize);
+ GST_BUFFER_OFFSET (buf) =
+ GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
}
}
if (src->touch) {
volatile guchar *p = GST_BUFFER_DATA (buf), c;
- for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
+ for (i = 0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
c = p[i];
}
/* we're done, return the buffer */
g_assert (src->curoffset == GST_BUFFER_OFFSET (buf));
- src->curoffset += GST_BUFFER_SIZE(buf);
+ src->curoffset += GST_BUFFER_SIZE (buf);
return buf;
}
static GstBuffer *
-gst_filesrc_get_read (GstFileSrc *src)
+gst_filesrc_get_read (GstFileSrc * src)
{
GstBuffer *buf = NULL;
size_t readsize;
readsize = src->block_size;
if (src->curoffset + readsize > src->filelen) {
- if (!gst_filesrc_check_filesize (src) || src->curoffset + readsize > src->filelen) {
+ if (!gst_filesrc_check_filesize (src)
+ || src->curoffset + readsize > src->filelen) {
readsize = src->filelen - src->curoffset;
}
}
g_return_val_if_fail (buf != NULL, NULL);
ret = read (src->fd, GST_BUFFER_DATA (buf), readsize);
- if (ret < 0){
+ if (ret < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
return NULL;
}
if (ret < readsize) {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("unexpected end of file."));
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("unexpected end of file."));
return NULL;
}
}
static GstData *
-gst_filesrc_get (GstPad *pad)
+gst_filesrc_get (GstPad * pad)
{
GstFileSrc *src;
src->seek_happened = FALSE;
GST_DEBUG_OBJECT (src, "sending discont");
- event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
+ event =
+ gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
+ NULL);
return GST_DATA (event);
}
g_assert (src->curoffset <= src->filelen);
if (src->curoffset == src->filelen) {
if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) {
- GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT,
- src->curoffset, src->filelen);
+ GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
+ src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
}
- if (src->using_mmap){
+ if (src->using_mmap) {
return GST_DATA (gst_filesrc_get_mmap (src));
- }else{
+ } else {
return GST_DATA (gst_filesrc_get_read (src));
}
}
/* TRUE if the filesize of the file was updated */
static gboolean
-gst_filesrc_check_filesize (GstFileSrc *src)
+gst_filesrc_check_filesize (GstFileSrc * src)
{
struct stat stat_results;
-
- g_return_val_if_fail (GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
- fstat(src->fd, &stat_results);
- GST_DEBUG_OBJECT (src, "checked filesize on %s (was %"G_GUINT64_FORMAT", is %"G_GUINT64_FORMAT")",
- src->filename, src->filelen, (guint64) stat_results.st_size);
+ g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE);
+
+ fstat (src->fd, &stat_results);
+ GST_DEBUG_OBJECT (src,
+ "checked filesize on %s (was %" G_GUINT64_FORMAT ", is %" G_GUINT64_FORMAT
+ ")", src->filename, src->filelen, (guint64) stat_results.st_size);
if (src->filelen == (guint64) stat_results.st_size)
return FALSE;
src->filelen = stat_results.st_size;
return TRUE;
}
+
/* open the file and mmap it, necessary to go to READY state */
static gboolean
-gst_filesrc_open_file (GstFileSrc *src)
+gst_filesrc_open_file (GstFileSrc * src)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE);
- if (src->filename == NULL || src->filename[0] == '\0')
- {
+ if (src->filename == NULL || src->filename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
- (_("No file name specified for reading.")), (NULL));
+ (_("No file name specified for reading.")), (NULL));
return FALSE;
}
- GST_INFO_OBJECT (src, "opening file %s",src->filename);
+ GST_INFO_OBJECT (src, "opening file %s", src->filename);
/* open the file */
src->fd = open (src->filename, O_RDONLY);
- if (src->fd < 0)
- {
+ if (src->fd < 0) {
if (errno == ENOENT)
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL));
else
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open file \"%s\" for reading."), src->filename),
+ GST_ERROR_SYSTEM);
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
struct stat stat_results;
- fstat(src->fd, &stat_results);
+ fstat (src->fd, &stat_results);
- if (!S_ISREG(stat_results.st_mode)) {
+ if (!S_ISREG (stat_results.st_mode)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("File \"%s\" isn't a regular file."), src->filename),
- (NULL));
- close(src->fd);
+ (_("File \"%s\" isn't a regular file."), src->filename), (NULL));
+ close (src->fd);
return FALSE;
}
-
+
/* find the file length */
src->filelen = stat_results.st_size;
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
if (src->mapbuf == NULL) {
src->using_mmap = FALSE;
- }else{
+ } else {
src->using_mmap = TRUE;
}
/* unmap and close the file */
static void
-gst_filesrc_close_file (GstFileSrc *src)
+gst_filesrc_close_file (GstFileSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN));
static GstElementStateReturn
-gst_filesrc_change_state (GstElement *element)
+gst_filesrc_change_state (GstElement * element)
{
- GstFileSrc *src = GST_FILESRC(element);
+ GstFileSrc *src = GST_FILESRC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) {
- if (!gst_filesrc_open_file (GST_FILESRC (element)))
- return GST_STATE_FAILURE;
+ if (!gst_filesrc_open_file (GST_FILESRC (element)))
+ return GST_STATE_FAILURE;
}
break;
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN))
- gst_filesrc_close_file (GST_FILESRC (element));
+ gst_filesrc_close_file (GST_FILESRC (element));
src->seek_happened = TRUE;
break;
default:
}
static gboolean
-gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_BYTES:
- *value = src->curoffset;
- break;
+ *value = src->curoffset;
+ break;
case GST_FORMAT_PERCENT:
if (src->filelen == 0)
return FALSE;
- *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
- break;
- default:
+ *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
+ break;
+ default:
return FALSE;
}
break;
}
static gboolean
-gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
+gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
{
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
offset = GST_EVENT_SEEK_OFFSET (event);
switch (GST_EVENT_SEEK_METHOD (event)) {
- case GST_SEEK_METHOD_SET:
- if (offset > src->filelen && (!gst_filesrc_check_filesize (src) || offset > src->filelen)) {
- goto error;
+ case GST_SEEK_METHOD_SET:
+ if (offset > src->filelen && (!gst_filesrc_check_filesize (src)
+ || offset > src->filelen)) {
+ goto error;
}
- src->curoffset = offset;
- GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset = offset;
+ GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
- case GST_SEEK_METHOD_CUR:
- if (offset + src->curoffset > src->filelen)
- if (!gst_filesrc_check_filesize (src) || offset + src->curoffset > src->filelen)
+ case GST_SEEK_METHOD_CUR:
+ if (offset + src->curoffset > src->filelen)
+ if (!gst_filesrc_check_filesize (src)
+ || offset + src->curoffset > src->filelen)
goto error;
- src->curoffset += offset;
- GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset += offset;
+ GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
- case GST_SEEK_METHOD_END:
- if (ABS (offset) > src->filelen) {
- if (!gst_filesrc_check_filesize (src) || ABS (offset) > src->filelen)
+ case GST_SEEK_METHOD_END:
+ if (ABS (offset) > src->filelen) {
+ if (!gst_filesrc_check_filesize (src)
+ || ABS (offset) > src->filelen)
goto error;
goto error;
}
- src->curoffset = src->filelen - ABS (offset);
- GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset = src->filelen - ABS (offset);
+ GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
default:
- goto error;
+ goto error;
break;
}
src->seek_happened = TRUE;
- src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH;
+ src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
break;
}
case GST_EVENT_SIZE:
goto error;
}
src->block_size = GST_EVENT_SIZE_VALUE (event);
- g_object_notify (G_OBJECT (src), "blocksize");
+ g_object_notify (G_OBJECT (src), "blocksize");
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
return GST_URI_SRC;
}
static gchar **
-gst_filesrc_uri_get_protocols(void)
+gst_filesrc_uri_get_protocols (void)
{
- static gchar *protocols[] = {"file", NULL};
+ static gchar *protocols[] = { "file", NULL };
return protocols;
}
static const gchar *
-gst_filesrc_uri_get_uri (GstURIHandler *handler)
+gst_filesrc_uri_get_uri (GstURIHandler * handler)
{
GstFileSrc *src = GST_FILESRC (handler);
-
+
return src->uri;
}
+
static gboolean
-gst_filesrc_uri_set_uri (GstURIHandler *handler, const gchar *uri)
+gst_filesrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
gchar *protocol, *location;
gboolean ret;
#include <sys/types.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FILESRC \
(gst_filesrc_get_type())
#define GST_FILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FILESRC,GstFileSrc))
#define GST_FILESRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass))
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass))
#define GST_IS_FILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESRC))
#define GST_IS_FILESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESRC))
-
-typedef enum {
- GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+{
+ GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
GST_FILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSrcFlags;
typedef struct _GstFileSrc GstFileSrc;
typedef struct _GstFileSrcClass GstFileSrcClass;
-struct _GstFileSrc {
+struct _GstFileSrc
+{
GstElement element;
GstPad *srcpad;
- guint pagesize; /* system page size*/
-
- gchar *filename; /* filename */
- gchar *uri; /* caching the URI */
- gint fd; /* open file descriptor*/
- off_t filelen; /* what's the file length?*/
+ guint pagesize; /* system page size */
- off_t curoffset; /* current offset in file*/
- off_t block_size; /* bytes per read */
- gboolean touch; /* whether to touch every page */
+ gchar *filename; /* filename */
+ gchar *uri; /* caching the URI */
+ gint fd; /* open file descriptor */
+ off_t filelen; /* what's the file length? */
+
+ off_t curoffset; /* current offset in file */
+ off_t block_size; /* bytes per read */
+ gboolean touch; /* whether to touch every page */
gboolean using_mmap;
GstBuffer *mapbuf;
gboolean need_flush;
};
-struct _GstFileSrcClass {
+struct _GstFileSrcClass
+{
GstElementClass parent_class;
};
-GType gst_filesrc_get_type(void);
+GType gst_filesrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_FILESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_identity_debug);
#define GST_CAT_DEFAULT gst_identity_debug
-GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS (
- "Identity",
- "Generic",
- "Pass data without modification",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ("Identity",
+ "Generic",
+ "Pass data without modification",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Identity signals and args */
-enum {
+enum
+{
SIGNAL_HANDOFF,
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOOP_BASED,
ARG_SLEEP_TIME,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element");
-GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_identity_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_identity_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_identity_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_identity_chain (GstPad *pad, GstData *_data);
+static void gst_identity_chain (GstPad * pad, GstData * _data);
static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
gst_identity_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_identity_details);
}
-static void
-gst_identity_class_init (GstIdentityClass *klass)
+static void
+gst_identity_class_init (GstIdentityClass * klass)
{
GObjectClass *gobject_class;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
- g_param_spec_boolean ("loop-based", "Loop-based",
- "Set to TRUE to use loop-based rather than chain-based scheduling",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("loop-based", "Loop-based",
+ "Set to TRUE to use loop-based rather than chain-based scheduling",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME,
- g_param_spec_uint ("sleep-time", "Sleep time", "Microseconds to sleep between processing",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("sleep-time", "Sleep time",
+ "Microseconds to sleep between processing", 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE,
- g_param_spec_uint ("duplicate", "Duplicate Buffers", "Push the buffers N times",
- 0, G_MAXUINT, 1, G_PARAM_READWRITE));
+ g_param_spec_uint ("duplicate", "Duplicate Buffers",
+ "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
- g_param_spec_int ("error_after", "Error After", "Error after N buffers",
- G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_param_spec_int ("error_after", "Error After", "Error after N buffers",
+ G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
- g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped",
- 0.0, 1.0, 0.0, G_PARAM_READWRITE));
+ g_param_spec_float ("drop_probability", "Drop Probability",
+ "The Probability a buffer is dropped", 0.0, 1.0, 0.0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "last-message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message", "last-message", NULL,
+ G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean("dump", "Dump", "Dump buffer contents",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE,
+ G_PARAM_READWRITE));
gst_identity_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- GST_TYPE_BUFFER);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
-static void
-gst_identity_init (GstIdentity *identity)
+static void
+gst_identity_init (GstIdentity * identity)
{
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
- gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
+ gst_pad_set_chain_function (identity->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_link_function (identity->sinkpad, gst_pad_proxy_pad_link);
gst_pad_set_getcaps_function (identity->sinkpad, gst_pad_proxy_getcaps);
-
+
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
gst_pad_set_link_function (identity->srcpad, gst_pad_proxy_pad_link);
identity->srccaps = NULL;
}
-static void
-gst_identity_chain (GstPad *pad, GstData *_data)
+static void
+gst_identity_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstIdentity *identity;
if (identity->error_after == 0) {
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (identity, CORE, FAILED,
- (_("Failed after iterations as requested.")),
- (NULL));
+ (_("Failed after iterations as requested.")), (NULL));
return;
}
}
if (identity->drop_probability > 0.0) {
- if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) {
+ if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
if (identity->last_message != NULL) {
g_free (identity->last_message);
}
- identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
- G_GINT64_FORMAT ")",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ identity->last_message =
+ g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
+ G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message");
gst_buffer_unref (buf);
return;
for (i = identity->duplicate; i; i--) {
if (!identity->silent) {
g_free (identity->last_message);
- identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
- G_GINT64_FORMAT ")",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ identity->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
+ G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message");
}
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
- buf);
+ buf);
- if (i>1)
+ if (i > 1)
gst_buffer_ref (buf);
gst_pad_push (identity->srcpad, GST_DATA (buf));
}
}
-static void
-gst_identity_loop (GstElement *element)
+static void
+gst_identity_loop (GstElement * element)
{
GstIdentity *identity;
GstBuffer *buf;
g_return_if_fail (GST_IS_IDENTITY (element));
identity = GST_IDENTITY (element);
-
+
buf = GST_BUFFER (gst_pad_pull (identity->sinkpad));
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
if (GST_EVENT_IS_INTERRUPT (event)) {
gst_event_unref (event);
- }
- else {
+ } else {
gst_pad_event_default (identity->sinkpad, event);
}
- }
- else {
+ } else {
gst_identity_chain (identity->sinkpad, GST_DATA (buf));
}
}
-static void
-gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_identity_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstIdentity *identity;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_IDENTITY (object));
-
+
identity = GST_IDENTITY (object);
switch (prop_id) {
case ARG_LOOP_BASED:
identity->loop_based = g_value_get_boolean (value);
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);
+ 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;
case ARG_SLEEP_TIME:
}
}
-static void gst_identity_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstIdentity *identity;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_IDENTITY (object));
-
+
identity = GST_IDENTITY (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_IDENTITY \
(gst_identity_get_type())
#define GST_IDENTITY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IDENTITY))
#define GST_IS_IDENTITY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY))
-
typedef struct _GstIdentity GstIdentity;
typedef struct _GstIdentityClass GstIdentityClass;
-struct _GstIdentity {
- GstElement element;
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- gboolean loop_based;
- guint duplicate;
- gint error_after;
- gfloat drop_probability;
- guint sleep_time;
- gboolean silent;
- gboolean dump;
- gchar *last_message;
- GstCaps *srccaps;
+struct _GstIdentity
+{
+ GstElement element;
+
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ gboolean loop_based;
+ guint duplicate;
+ gint error_after;
+ gfloat drop_probability;
+ guint sleep_time;
+ gboolean silent;
+ gboolean dump;
+ gchar *last_message;
+ GstCaps *srccaps;
};
-struct _GstIdentityClass {
+struct _GstIdentityClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf);
+ void (*handoff) (GstElement * element, GstBuffer * buf);
};
-GType gst_identity_get_type(void);
+GType gst_identity_get_type (void);
G_END_DECLS
-
#endif /* __GST_IDENTITY_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_md5sink_debug);
#define GST_CAT_DEFAULT gst_md5sink_debug
-GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS (
- "MD5 Sink",
- "Sink",
- "compute MD5 for incoming data",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ("MD5 Sink",
+ "Sink",
+ "compute MD5 for incoming data",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* MD5Sink signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MD5,
/* FILL ME */
};
-GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_md5sink_debug, "md5sink", 0, "md5sink element");
-GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
/* GObject stuff */
/*static void gst_md5sink_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);*/
-static void gst_md5sink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_md5sink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_md5sink_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn gst_md5sink_change_state (GstElement *element);
+static void gst_md5sink_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_md5sink_change_state (GstElement * element);
/* MD5 stuff */
-static void md5_init_ctx (GstMD5Sink *ctx);
-static gpointer md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf);
-static gpointer md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf);
-static void md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx);
-static void md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx);
+static void md5_init_ctx (GstMD5Sink * ctx);
+static gpointer md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf);
+static gpointer md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf);
+static void md5_process_bytes (const void *buffer, size_t len,
+ GstMD5Sink * ctx);
+static void md5_process_block (const void *buffer, size_t len,
+ GstMD5Sink * ctx);
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
-static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/* MD5 functions */
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
static void
-md5_init_ctx (GstMD5Sink *ctx)
+md5_init_ctx (GstMD5Sink * ctx)
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
+
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
static gpointer
-md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf)
+md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf)
{
/* Take yet unprocessed bytes into account. */
guint32 bytes = ctx->buflen;
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(guint32 *) &ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3);
- *(guint32 *) &ctx->buffer[bytes + pad + 4] = GUINT32_TO_LE ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ *(guint32 *) & ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3);
+ *(guint32 *) & ctx->buffer[bytes + pad + 4] =
+ GUINT32_TO_LE ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
/* Process last bytes. */
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
return md5_read_ctx (ctx, resbuf);
}
+
/* Put result from CTX in first 16 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
static gpointer
-md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf)
+md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf)
{
((guint32 *) resbuf)[0] = GUINT32_TO_LE (ctx->A);
((guint32 *) resbuf)[1] = GUINT32_TO_LE (ctx->B);
}
static void
-md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx)
+md5_process_bytes (const void *buffer, size_t len, GstMD5Sink * ctx)
{
/*const void aligned_buffer = buffer; */
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
- if (ctx->buflen != 0)
- {
- size_t left_over = ctx->buflen;
- size_t add = 128 - left_over > len ? len : 128 - left_over;
-
- /* Only put full words in the buffer. */
- /* Forcing alignment here appears to be only an optimization.
- * The glibc source uses __alignof__, which seems to be a
- * gratuitous usage of a GCC extension, when sizeof() will
- * work fine. (And don't question the sanity of using
- * sizeof(guint32) instead of 4. */
- /* add -= add % __alignof__ (guint32); */
- add -= add % sizeof(guint32);
-
- memcpy (&ctx->buffer[left_over], buffer, add);
- ctx->buflen += add;
-
- if (ctx->buflen > 64)
- {
- md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
-
- ctx->buflen &= 63;
- /* The regions in the following copy operation cannot overlap. */
- memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
- ctx->buflen);
- }
-
- buffer = (const char *) buffer + add;
- len -= add;
+ if (ctx->buflen != 0) {
+ size_t left_over = ctx->buflen;
+ size_t add = 128 - left_over > len ? len : 128 - left_over;
+
+ /* Only put full words in the buffer. */
+ /* Forcing alignment here appears to be only an optimization.
+ * The glibc source uses __alignof__, which seems to be a
+ * gratuitous usage of a GCC extension, when sizeof() will
+ * work fine. (And don't question the sanity of using
+ * sizeof(guint32) instead of 4. */
+ /* add -= add % __alignof__ (guint32); */
+ add -= add % sizeof (guint32);
+
+ memcpy (&ctx->buffer[left_over], buffer, add);
+ ctx->buflen += add;
+
+ if (ctx->buflen > 64) {
+ md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen);
}
+ buffer = (const char *) buffer + add;
+ len -= add;
+ }
+
/* Process available complete blocks. */
- if (len > 64)
- {
- md5_process_block (buffer, len & ~63, ctx);
- buffer = (const char *) buffer + (len & ~63);
- len &= 63;
- }
+ if (len > 64) {
+ md5_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
/* Move remaining bytes in internal buffer. */
- if (len > 0)
- {
- size_t left_over = ctx->buflen;
-
- memcpy (&ctx->buffer[left_over], buffer, len);
- left_over += len;
- if (left_over >= 64)
- {
- md5_process_block (ctx->buffer, 64, ctx);
- left_over -= 64;
- memcpy (ctx->buffer, &ctx->buffer[64], left_over);
- }
- ctx->buflen = left_over;
+ if (len > 0) {
+ size_t left_over = ctx->buflen;
+
+ memcpy (&ctx->buffer[left_over], buffer, len);
+ left_over += len;
+ if (left_over >= 64) {
+ md5_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[64], left_over);
}
+ ctx->buflen = left_over;
+ }
}
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
static void
-md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx)
+md5_process_block (const void *buffer, size_t len, GstMD5Sink * ctx)
{
guint32 correct_words[16];
const guint32 *words = buffer;
/* Process all bytes in the buffer with 64 bytes in each round of
the loop. */
- while (words < endp)
- {
- guint32 *cwp = correct_words;
- guint32 A_save = A;
- guint32 B_save = B;
- guint32 C_save = C;
- guint32 D_save = D;
-
- /* First round: using the given function, the context and a constant
- the next context is computed. Because the algorithms processing
- unit is a 32-bit word and it is determined to work on words in
- little endian byte order we perhaps have to change the byte order
- before the computation. To reduce the work for the next steps
- we store the swapped words in the array CORRECT_WORDS. */
+ while (words < endp) {
+ guint32 *cwp = correct_words;
+ guint32 A_save = A;
+ guint32 B_save = B;
+ guint32 C_save = C;
+ guint32 D_save = D;
+
+ /* First round: using the given function, the context and a constant
+ the next context is computed. Because the algorithms processing
+ unit is a 32-bit word and it is determined to work on words in
+ little endian byte order we perhaps have to change the byte order
+ before the computation. To reduce the work for the next steps
+ we store the swapped words in the array CORRECT_WORDS. */
#define OP(a, b, c, d, s, T) \
do \
} \
while (0)
- /* It is unfortunate that C does not provide an operator for
- cyclic rotation. Hope the C compiler is smart enough. */
+ /* It is unfortunate that C does not provide an operator for
+ cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
- /* Before we start, one word to the strange constants.
- They are defined in RFC 1321 as
-
- T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
- */
-
- /* Round 1. */
- OP (A, B, C, D, 7, 0xd76aa478);
- OP (D, A, B, C, 12, 0xe8c7b756);
- OP (C, D, A, B, 17, 0x242070db);
- OP (B, C, D, A, 22, 0xc1bdceee);
- OP (A, B, C, D, 7, 0xf57c0faf);
- OP (D, A, B, C, 12, 0x4787c62a);
- OP (C, D, A, B, 17, 0xa8304613);
- OP (B, C, D, A, 22, 0xfd469501);
- OP (A, B, C, D, 7, 0x698098d8);
- OP (D, A, B, C, 12, 0x8b44f7af);
- OP (C, D, A, B, 17, 0xffff5bb1);
- OP (B, C, D, A, 22, 0x895cd7be);
- OP (A, B, C, D, 7, 0x6b901122);
- OP (D, A, B, C, 12, 0xfd987193);
- OP (C, D, A, B, 17, 0xa679438e);
- OP (B, C, D, A, 22, 0x49b40821);
-
- /* For the second to fourth round we have the possibly swapped words
- in CORRECT_WORDS. Redefine the macro to take an additional first
- argument specifying the function to use. */
+ /* Before we start, one word to the strange constants.
+ They are defined in RFC 1321 as
+
+ T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
+ */
+
+ /* Round 1. */
+ OP (A, B, C, D, 7, 0xd76aa478);
+ OP (D, A, B, C, 12, 0xe8c7b756);
+ OP (C, D, A, B, 17, 0x242070db);
+ OP (B, C, D, A, 22, 0xc1bdceee);
+ OP (A, B, C, D, 7, 0xf57c0faf);
+ OP (D, A, B, C, 12, 0x4787c62a);
+ OP (C, D, A, B, 17, 0xa8304613);
+ OP (B, C, D, A, 22, 0xfd469501);
+ OP (A, B, C, D, 7, 0x698098d8);
+ OP (D, A, B, C, 12, 0x8b44f7af);
+ OP (C, D, A, B, 17, 0xffff5bb1);
+ OP (B, C, D, A, 22, 0x895cd7be);
+ OP (A, B, C, D, 7, 0x6b901122);
+ OP (D, A, B, C, 12, 0xfd987193);
+ OP (C, D, A, B, 17, 0xa679438e);
+ OP (B, C, D, A, 22, 0x49b40821);
+
+ /* For the second to fourth round we have the possibly swapped words
+ in CORRECT_WORDS. Redefine the macro to take an additional first
+ argument specifying the function to use. */
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
} \
while (0)
- /* Round 2. */
- OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
- OP (FG, D, A, B, C, 6, 9, 0xc040b340);
- OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
- OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
- OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
- OP (FG, D, A, B, C, 10, 9, 0x02441453);
- OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
- OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
- OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
- OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
- OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
- OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
- OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
- OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
- OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
- OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
-
- /* Round 3. */
- OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
- OP (FH, D, A, B, C, 8, 11, 0x8771f681);
- OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
- OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
- OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
- OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
- OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
- OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
- OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
- OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
- OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
- OP (FH, B, C, D, A, 6, 23, 0x04881d05);
- OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
- OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
- OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
- OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
-
- /* Round 4. */
- OP (FI, A, B, C, D, 0, 6, 0xf4292244);
- OP (FI, D, A, B, C, 7, 10, 0x432aff97);
- OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
- OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
- OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
- OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
- OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
- OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
- OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
- OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
- OP (FI, C, D, A, B, 6, 15, 0xa3014314);
- OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
- OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
- OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
- OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
- OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
-
- /* Add the starting values of the context. */
- A += A_save;
- B += B_save;
- C += C_save;
- D += D_save;
- }
+ /* Round 2. */
+ OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, 0xc040b340);
+ OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
+ OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, 0x02441453);
+ OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
+ OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
+ OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
+
+ /* Round 3. */
+ OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, 0x8771f681);
+ OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
+ OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
+ OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
+ OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
+ OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
+ OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
+ OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
+ OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+
+ /* Round 4. */
+ OP (FI, A, B, C, D, 0, 6, 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, 0x432aff97);
+ OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
+ OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
+ OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
+ OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
+ OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
+ OP (FI, C, D, A, B, 6, 15, 0xa3014314);
+ OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
+ OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
+ OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
+ OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+
+ /* Add the starting values of the context. */
+ A += A_save;
+ B += B_save;
+ C += C_save;
+ D += D_save;
+ }
/* Put checksum in context given as argument. */
ctx->A = A;
gst_md5sink_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_md5sink_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&md5_sink_template));
}
static void
-gst_md5sink_class_init (GstMD5SinkClass *klass)
+gst_md5sink_class_init (GstMD5SinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_md5sink_get_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5,
- g_param_spec_string ("md5", "md5", "current value of the md5 sum",
- "", G_PARAM_READABLE));
+ g_param_spec_string ("md5", "md5", "current value of the md5 sum",
+ "", G_PARAM_READABLE));
- gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_md5sink_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state);
}
-static void
-gst_md5sink_init (GstMD5Sink *md5sink)
+static void
+gst_md5sink_init (GstMD5Sink * md5sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (gst_static_pad_template_get (
- &md5_sink_template), "sink");
+
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&md5_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (md5sink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain));
}
static GstElementStateReturn
-gst_md5sink_change_state (GstElement *element)
+gst_md5sink_change_state (GstElement * element)
{
GstMD5Sink *sink;
-
+
/* element check */
sink = GST_MD5SINK (element);
g_return_val_if_fail (GST_IS_MD5SINK (sink), GST_STATE_FAILURE);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
md5_init_ctx (sink);
default:
break;
}
-
+
if ((GST_ELEMENT_CLASS (parent_class)->change_state))
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
-static void
-gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMD5Sink *sink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_MD5SINK (object));
-
+
sink = GST_MD5SINK (object);
-
+
switch (prop_id) {
case ARG_MD5:
- {
- /* you could actually get a value for the current md5.
- * This is currently disabled.
- * md5_read_ctx (sink, sink->md5); */
- /* md5 is a guchar[16] */
- int i;
- guchar *md5string = g_malloc0 (33);
-
- for (i = 0; i < 16; ++i)
- sprintf (md5string + i * 2, "%02x", sink->md5[i]);
- g_value_set_string (value, md5string);
- g_free (md5string);
- }
+ {
+ /* you could actually get a value for the current md5.
+ * This is currently disabled.
+ * md5_read_ctx (sink, sink->md5); */
+ /* md5 is a guchar[16] */
+ int i;
+ guchar *md5string = g_malloc0 (33);
+
+ for (i = 0; i < 16; ++i)
+ sprintf (md5string + i * 2, "%02x", sink->md5[i]);
+ g_value_set_string (value, md5string);
+ g_free (md5string);
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
-static void
-gst_md5sink_chain (GstPad *pad, GstData *_data)
+static void
+gst_md5sink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMD5Sink *md5sink;
md5sink = GST_MD5SINK (gst_pad_get_parent (pad));
- if (GST_IS_BUFFER (buf))
- {
+ if (GST_IS_BUFFER (buf)) {
md5_process_bytes (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), md5sink);
}
-
+
gst_buffer_unref (buf);
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_MD5SINK \
(gst_md5sink_get_type())
#define GST_MD5SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MD5SINK))
#define GST_IS_MD5SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MD5SINK))
-
typedef struct _GstMD5Sink GstMD5Sink;
typedef struct _GstMD5SinkClass GstMD5SinkClass;
-struct _GstMD5Sink {
+struct _GstMD5Sink
+{
GstElement element;
/* md5 information */
guint32 total[2];
guint32 buflen;
gchar buffer[128];
-
+
/* latest md5 */
guchar md5[16];
-
+
};
-struct _GstMD5SinkClass {
+struct _GstMD5SinkClass
+{
GstElementClass parent_class;
};
-GType gst_md5sink_get_type (void);
+GType gst_md5sink_get_type (void);
-gboolean gst_md5sink_factory_init (GstElementFactory *factory);
+gboolean gst_md5sink_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_MD5SINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_multifilesrc_debug);
#define GST_CAT_DEFAULT gst_multifilesrc_debug
-GstElementDetails gst_multifilesrc_details = GST_ELEMENT_DETAILS (
- "Multi File Source",
- "Source/File",
- "Read from multiple files in order",
- "Dominic Ludlam <dom@openfx.org>"
-);
+GstElementDetails gst_multifilesrc_details =
+GST_ELEMENT_DETAILS ("Multi File Source",
+ "Source/File",
+ "Read from multiple files in order",
+ "Dominic Ludlam <dom@openfx.org>");
/* FileSrc signals and args */
-enum {
+enum
+{
NEW_FILE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATIONS
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_multifilesrc_debug, "multifilesrc", 0, "multifilesrc element");
-GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_multifilesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_multifilesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstData *gst_multifilesrc_get (GstPad * pad);
-static GstData * gst_multifilesrc_get (GstPad *pad);
/*static GstBuffer * gst_multifilesrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
-static GstElementStateReturn gst_multifilesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_multifilesrc_change_state (GstElement *
+ element);
-static gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad);
-static void gst_multifilesrc_close_file (GstMultiFileSrc *src);
+static gboolean gst_multifilesrc_open_file (GstMultiFileSrc * src,
+ GstPad * srcpad);
+static void gst_multifilesrc_close_file (GstMultiFileSrc * src);
static guint gst_multifilesrc_signals[LAST_SIGNAL] = { 0 };
gst_multifilesrc_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_multifilesrc_details);
}
static void
-gst_multifilesrc_class_init (GstMultiFileSrcClass *klass)
+gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gst_multifilesrc_signals[NEW_FILE] =
- g_signal_new ("new-file", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
- g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ g_signal_new ("new-file", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
- g_param_spec_pointer("locations","locations","locations",
- G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property;
}
static void
-gst_multifilesrc_init (GstMultiFileSrc *multifilesrc)
+gst_multifilesrc_init (GstMultiFileSrc * multifilesrc)
{
/* GST_FLAG_SET (filesrc, GST_SRC_); */
multifilesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
- gst_pad_set_get_function (multifilesrc->srcpad,gst_multifilesrc_get);
+ gst_pad_set_get_function (multifilesrc->srcpad, gst_multifilesrc_get);
/* gst_pad_set_getregion_function (multifilesrc->srcpad,gst_multifilesrc_get_region); */
gst_element_add_pad (GST_ELEMENT (multifilesrc), multifilesrc->srcpad);
}
static void
-gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_multifilesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMultiFileSrc *src;
/* clear the filename if we get a NULL */
if (g_value_get_pointer (value) == NULL) {
- gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
- src->listptr = NULL;
- /* otherwise set the new filenames */
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ src->listptr = NULL;
+ /* otherwise set the new filenames */
} else {
- src->listptr = g_value_get_pointer (value);
+ src->listptr = g_value_get_pointer (value);
}
break;
default:
}
static void
-gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMultiFileSrc *src;
* Push a new buffer from the filesrc at the current offset.
*/
static GstData *
-gst_multifilesrc_get (GstPad *pad)
+gst_multifilesrc_get (GstPad * pad)
{
GstMultiFileSrc *src;
GstBuffer *buf;
src = GST_MULTIFILESRC (gst_pad_get_parent (pad));
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN))
- gst_multifilesrc_close_file(src);
+ gst_multifilesrc_close_file (src);
if (!src->listptr) {
return GST_DATA (gst_event_new (GST_EVENT_EOS));
src->currentfilename = (gchar *) list->data;
src->listptr = src->listptr->next;
- if (!gst_multifilesrc_open_file(src, pad))
- return NULL;
+ if (!gst_multifilesrc_open_file (src, pad))
+ return NULL;
- /* emitted after the open, as the user may free the list and string from here*/
- g_signal_emit(G_OBJECT(src), gst_multifilesrc_signals[NEW_FILE], 0, list);
+ /* emitted after the open, as the user may free the list and string from here */
+ g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
}
/* open the file and mmap it, necessary to go to READY state */
-static
-gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad)
+static gboolean
+gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN), FALSE);
- if (src->currentfilename == NULL || src->currentfilename[0] == '\0')
- {
+ if (src->currentfilename == NULL || src->currentfilename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
- (_("No file name specified for reading.")), (NULL));
+ (_("No file name specified for reading.")), (NULL));
return FALSE;
}
/* open the file */
src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->currentfilename),
- GST_ERROR_SYSTEM);
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open file \"%s\" for reading."), src->currentfilename),
+ GST_ERROR_SYSTEM);
return FALSE;
} else {
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
+ madvise (src->map, src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
- ("mmap call failed."));
+ ("mmap call failed."));
return FALSE;
}
GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN);
/* unmap and close the file */
static void
-gst_multifilesrc_close_file (GstMultiFileSrc *src)
+gst_multifilesrc_close_file (GstMultiFileSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN));
}
static GstElementStateReturn
-gst_multifilesrc_change_state (GstElement *element)
+gst_multifilesrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_MULTIFILESRC (element), GST_STATE_FAILURE);
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_MULTIFILESRC \
(gst_multifilesrc_get_type())
#define GST_MULTIFILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFILESRC))
#define GST_IS_MULTIFILESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFILESRC))
+ typedef enum
+{
+ GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
-typedef enum {
- GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstMultiFileSrcFlags;
typedef struct _GstMultiFileSrc GstMultiFileSrc;
typedef struct _GstMultiFileSrcClass GstMultiFileSrcClass;
-struct _GstMultiFileSrc {
+struct _GstMultiFileSrc
+{
GstElement element;
/* pads */
GstPad *srcpad;
/* current file details */
- gchar *currentfilename;
+ gchar *currentfilename;
GSList *listptr;
/* mapping parameters */
gint fd;
- gulong size; /* how long is the file? */
- guchar *map; /* where the file is mapped to */
+ gulong size; /* how long is the file? */
+ guchar *map; /* where the file is mapped to */
gboolean new_seek;
};
-struct _GstMultiFileSrcClass {
+struct _GstMultiFileSrcClass
+{
GstElementClass parent_class;
- void (*new_file) (GstMultiFileSrc *multifilesrc, gchar *newfilename);
+ void (*new_file) (GstMultiFileSrc * multifilesrc, gchar * newfilename);
};
-GType gst_multifilesrc_get_type(void);
+GType gst_multifilesrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_MULTIFILESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_pipefilter_debug);
#define GST_CAT_DEFAULT gst_pipefilter_debug
-GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS (
- "Pipefilter",
- "Filter",
- "Interoperate with an external program using stdin and stdout",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ("Pipefilter",
+ "Filter",
+ "Interoperate with an external program using stdin and stdout",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* Pipefilter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_COMMAND
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_pipefilter_debug, "pipefilter", 0, "pipefilter element");
-GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_pipefilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_pipefilter_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstData* gst_pipefilter_get (GstPad *pad);
-static void gst_pipefilter_chain (GstPad *pad, GstData *_data);
-static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event);
+static GstData *gst_pipefilter_get (GstPad * pad);
+static void gst_pipefilter_chain (GstPad * pad, GstData * _data);
+static gboolean gst_pipefilter_handle_event (GstPad * pad, GstEvent * event);
-static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
+static GstElementStateReturn gst_pipefilter_change_state (GstElement * element);
static void
gst_pipefilter_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_pipefilter_details);
}
-static void
-gst_pipefilter_class_init (GstPipefilterClass *klass)
+static void
+gst_pipefilter_class_init (GstPipefilterClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- gobject_class->set_property = gst_pipefilter_set_property;
+ gobject_class->set_property = gst_pipefilter_set_property;
gobject_class->get_property = gst_pipefilter_get_property;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
- g_param_spec_string("command","command","command",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_pipefilter_change_state;
}
static void
-gst_pipefilter_init (GstPipefilter *pipefilter)
+gst_pipefilter_init (GstPipefilter * pipefilter)
{
GST_FLAG_SET (pipefilter, GST_ELEMENT_DECOUPLED);
}
static gboolean
-gst_pipefilter_handle_event (GstPad *pad, GstEvent *event)
+gst_pipefilter_handle_event (GstPad * pad, GstEvent * event)
{
GstPipefilter *pipefilter;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
if (close (pipefilter->fdin[1]) < 0)
- perror("close");
+ perror ("close");
if (close (pipefilter->fdout[0]) < 0)
- perror("close");
+ perror ("close");
break;
default:
break;
return TRUE;
}
-static GstData*
-gst_pipefilter_get (GstPad *pad)
+static GstData *
+gst_pipefilter_get (GstPad * pad)
{
GstPipefilter *pipefilter;
GstBuffer *newbuf;
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
- newbuf = gst_buffer_new();
- g_return_val_if_fail(newbuf, NULL);
+ newbuf = gst_buffer_new ();
+ g_return_val_if_fail (newbuf, NULL);
/* allocate the space for the buffer data */
- GST_BUFFER_DATA(newbuf) = g_malloc(pipefilter->bytes_per_read);
- g_return_val_if_fail(GST_BUFFER_DATA(newbuf) != NULL, NULL);
+ GST_BUFFER_DATA (newbuf) = g_malloc (pipefilter->bytes_per_read);
+ g_return_val_if_fail (GST_BUFFER_DATA (newbuf) != NULL, NULL);
/* read it in from the file */
GST_DEBUG ("attemting to read %ld bytes", pipefilter->bytes_per_read);
- readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read);
+ readbytes =
+ read (pipefilter->fdout[0], GST_BUFFER_DATA (newbuf),
+ pipefilter->bytes_per_read);
GST_DEBUG ("read %ld bytes", readbytes);
if (readbytes < 0) {
GST_ELEMENT_ERROR (pipefilter, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
}
- GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset;
- GST_BUFFER_SIZE(newbuf) = readbytes;
+ GST_BUFFER_OFFSET (newbuf) = pipefilter->curoffset;
+ GST_BUFFER_SIZE (newbuf) = readbytes;
pipefilter->curoffset += readbytes;
return GST_DATA (newbuf);
}
static void
-gst_pipefilter_chain (GstPad *pad,GstData *_data)
+gst_pipefilter_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf;
GstPipefilter *pipefilter;
guchar *data;
gulong size;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
if (GST_IS_EVENT (_data)) {
gst_pipefilter_handle_event (pad, GST_EVENT (_data));
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
buf = GST_BUFFER (_data);
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
GST_DEBUG ("attemting to write %ld bytes", size);
- writebytes = write(pipefilter->fdin[1],data,size);
+ writebytes = write (pipefilter->fdin[1], data, size);
GST_DEBUG ("written %ld bytes", writebytes);
if (writebytes < 0) {
GST_ELEMENT_ERROR (pipefilter, RESOURCE, WRITE, (NULL), GST_ERROR_SYSTEM);
return;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_pipefilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstPipefilter *pipefilter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_PIPEFILTER(object));
- pipefilter = GST_PIPEFILTER(object);
+ g_return_if_fail (GST_IS_PIPEFILTER (object));
+ pipefilter = GST_PIPEFILTER (object);
switch (prop_id) {
case ARG_COMMAND:
- pipefilter->orig_command = g_strdup(g_value_get_string (value));
- pipefilter->command = g_strsplit(g_value_get_string (value), " ", 0);
+ pipefilter->orig_command = g_strdup (g_value_get_string (value));
+ pipefilter->command = g_strsplit (g_value_get_string (value), " ", 0);
break;
default:
break;
}
static void
-gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_pipefilter_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstPipefilter *pipefilter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_PIPEFILTER(object));
- pipefilter = GST_PIPEFILTER(object);
+ g_return_if_fail (GST_IS_PIPEFILTER (object));
+ pipefilter = GST_PIPEFILTER (object);
switch (prop_id) {
case ARG_COMMAND:
/* open the file, necessary to go to RUNNING state */
static gboolean
-gst_pipefilter_open_file (GstPipefilter *src)
+gst_pipefilter_open_file (GstPipefilter * src)
{
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN), FALSE);
- pipe(src->fdin);
- pipe(src->fdout);
+ pipe (src->fdin);
+ pipe (src->fdout);
- if((src->childpid = fork()) == -1)
- {
+ if ((src->childpid = fork ()) == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- if(src->childpid == 0)
- {
- close(src->fdin[1]);
- close(src->fdout[0]);
+ if (src->childpid == 0) {
+ close (src->fdin[1]);
+ close (src->fdout[0]);
/* child */
- dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
- dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
- execvp(src->command[0], &src->command[0]);
+ dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */
+ dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
+ execvp (src->command[0], &src->command[0]);
/* will only be reached if execvp has an error */
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
return FALSE;
-
- }
- else {
- close(src->fdin[0]);
- close(src->fdout[1]);
+
+ } else {
+ close (src->fdin[0]);
+ close (src->fdout[1]);
}
-
- GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
+
+ GST_FLAG_SET (src, GST_PIPEFILTER_OPEN);
return TRUE;
}
/* close the file */
static void
-gst_pipefilter_close_file (GstPipefilter *src)
+gst_pipefilter_close_file (GstPipefilter * src)
{
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN));
/* close the file */
- close(src->fdout[0]);
- close(src->fdout[1]);
- close(src->fdin[0]);
- close(src->fdin[1]);
+ close (src->fdout[0]);
+ close (src->fdout[1]);
+ close (src->fdin[0]);
+ close (src->fdin[1]);
/* zero out a lot of our state */
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,GST_PIPEFILTER_OPEN);
+ GST_FLAG_UNSET (src, GST_PIPEFILTER_OPEN);
}
static GstElementStateReturn
-gst_pipefilter_change_state (GstElement *element)
+gst_pipefilter_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_PIPEFILTER(element), FALSE);
+ g_return_val_if_fail (GST_IS_PIPEFILTER (element), FALSE);
- /* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN))
- gst_pipefilter_close_file(GST_PIPEFILTER(element));
- /* otherwise (READY or higher) we need to open the file */
+ /* if going down into NULL state, close the file if it's open */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN))
+ gst_pipefilter_close_file (GST_PIPEFILTER (element));
+ /* otherwise (READY or higher) we need to open the file */
} else {
- if (!GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) {
- if (!gst_pipefilter_open_file(GST_PIPEFILTER(element)))
- return GST_STATE_FAILURE;
+ if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) {
+ if (!gst_pipefilter_open_file (GST_PIPEFILTER (element)))
+ return GST_STATE_FAILURE;
}
}
-
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_PIPEFILTER \
(gst_pipefilter_get_type())
#define GST_PIPEFILTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PIPEFILTER))
#define GST_IS_PIPEFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PIPEFILTER))
+ typedef enum
+{
+ GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST,
-typedef enum {
- GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstPipeFilterFlags;
typedef struct _GstPipefilter GstPipefilter;
typedef struct _GstPipefilterClass GstPipefilterClass;
-struct _GstPipefilter {
+struct _GstPipefilter
+{
GstElement element;
GstPad *sinkpad;
/* fd */
gint fdout[2];
gint fdin[2];
- pid_t childpid;
+ pid_t childpid;
- gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong curoffset; /* current offset in file */
+ gulong bytes_per_read; /* bytes per read */
- gulong seq; /* buffer sequence number */
+ gulong seq; /* buffer sequence number */
};
-struct _GstPipefilterClass {
+struct _GstPipefilterClass
+{
GstElementClass parent_class;
};
-GType gst_pipefilter_get_type(void);
+GType gst_pipefilter_get_type (void);
G_END_DECLS
-
#endif /* __GST_PIPEFILTER_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_shaper_debug);
#define GST_CAT_DEFAULT gst_shaper_debug
-GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS (
- "Shaper",
- "Generic",
- "Synchronizes streams on different pads",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ("Shaper",
+ "Generic",
+ "Synchronizes streams on different pads",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Shaper signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_POLICY,
ARG_SILENT,
typedef struct
{
- GstPad *sinkpad;
- GstPad *srcpad;
- GstBuffer *buffer;
+ GstPad *sinkpad;
+ GstPad *srcpad;
+ GstBuffer *buffer;
} GstShaperConnection;
-GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
-GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type())
static GType
{
static GType shaper_policy_type = 0;
static GEnumValue shaper_policy[] = {
- { SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"},
- { SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
+ {SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"},
+ {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
{0, NULL, NULL},
};
if (!shaper_policy_type) {
- shaper_policy_type = g_enum_register_static ("GstShaperPolicy", shaper_policy);
+ shaper_policy_type =
+ g_enum_register_static ("GstShaperPolicy", shaper_policy);
}
return shaper_policy_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_shaper_debug, "shaper", 0, "shaper element");
-GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_shaper_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_shaper_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_shaper_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_shaper_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstPad* gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused);
+static GstPad *gst_shaper_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
-static void gst_shaper_loop (GstElement *element);
+static void gst_shaper_loop (GstElement * element);
static void
gst_shaper_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_shaper_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_src_template));
gst_static_pad_template_get (&shaper_sink_template));
}
-static void
-gst_shaper_class_init (GstShaperClass *klass)
+static void
+gst_shaper_class_init (GstShaperClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY,
- g_param_spec_enum ("policy", "Policy", "Shaper policy",
- GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
+ g_param_spec_enum ("policy", "Policy", "Shaper policy",
+ GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "last-message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message", "last-message",
+ NULL, G_PARAM_READABLE));
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
}
-static GstCaps*
-gst_shaper_getcaps (GstPad *pad)
+static GstCaps *
+gst_shaper_getcaps (GstPad * pad)
{
GstPad *otherpad;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
if (GST_PAD_PEER (otherpad)) {
return gst_pad_get_caps (GST_PAD_PEER (otherpad));
}
}
-static GList*
-gst_shaper_get_internal_link (GstPad *pad)
+static GList *
+gst_shaper_get_internal_link (GstPad * pad)
{
GList *res = NULL;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
res = g_list_prepend (res, otherpad);
}
static GstPadLinkReturn
-gst_shaper_link (GstPad *pad, const GstCaps *caps)
+gst_shaper_link (GstPad * pad, const GstCaps * caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
return gst_pad_try_set_caps (otherpad, caps);
}
-static GstShaperConnection*
-gst_shaper_create_connection (GstShaper *shaper)
+static GstShaperConnection *
+gst_shaper_create_connection (GstShaper * shaper)
{
GstShaperConnection *connection;
gchar *padname;
connection = g_new0 (GstShaperConnection, 1);
padname = g_strdup_printf ("sink%d", shaper->nconnections);
- connection->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&shaper_sink_template), padname);
+ connection->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&shaper_sink_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps);
- gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link);
+ gst_pad_set_internal_link_function (connection->sinkpad,
+ gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->sinkpad, gst_shaper_link);
gst_pad_set_element_private (connection->sinkpad, connection);
gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad);
padname = g_strdup_printf ("src%d", shaper->nconnections);
- connection->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&shaper_src_template), padname);
+ connection->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&shaper_src_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps);
- gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link);
+ gst_pad_set_internal_link_function (connection->srcpad,
+ gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->srcpad, gst_shaper_link);
gst_pad_set_element_private (connection->srcpad, connection);
gst_element_add_pad (GST_ELEMENT (shaper), connection->srcpad);
return connection;
}
-static GstPad*
-gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_shaper_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
GstShaper *shaper = GST_SHAPER (element);
GstShaperConnection *connection;
return connection->sinkpad;
}
-static void
-gst_shaper_init (GstShaper *shaper)
+static void
+gst_shaper_init (GstShaper * shaper)
{
gst_element_set_loop_function (GST_ELEMENT (shaper), gst_shaper_loop);
shaper->last_message = NULL;
}
-static void
-gst_shaper_loop (GstElement *element)
+static void
+gst_shaper_loop (GstElement * element)
{
GstShaper *shaper;
GSList *connections;
gst_pad_push (connection->srcpad, GST_DATA (buffer));
switch (type) {
- /* on EOS we disable the pad so that we don't pull on
- * it again and never get more data */
- case GST_EVENT_EOS:
+ /* on EOS we disable the pad so that we don't pull on
+ * it again and never get more data */
+ case GST_EVENT_EOS:
gst_pad_set_active (connection->sinkpad, FALSE);
break;
default:
break;
}
- }
- else {
+ } else {
/* we store the buffer */
connection->buffer = buffer;
}
/* FIXME policy stuff goes here */
/* find connection with lowest timestamp */
if (min == NULL || (connection->buffer != NULL &&
- (GST_BUFFER_TIMESTAMP (connection->buffer) <
- GST_BUFFER_TIMESTAMP (min->buffer))))
- {
+ (GST_BUFFER_TIMESTAMP (connection->buffer) <
+ GST_BUFFER_TIMESTAMP (min->buffer)))) {
min = connection;
}
connections = g_slist_next (connections);
/* since we pushed a buffer, it's not EOS */
eos = FALSE;
}
-
+
if (eos) {
gst_element_set_eos (element);
}
}
-static void
-gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_shaper_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstShaper *shaper;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SHAPER (object));
-
+
shaper = GST_SHAPER (object);
switch (prop_id) {
}
}
-static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_shaper_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstShaper *shaper;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SHAPER (object));
-
+
shaper = GST_SHAPER (object);
switch (prop_id) {
break;
}
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_SHAPER \
(gst_shaper_get_type())
#define GST_SHAPER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHAPER))
#define GST_IS_SHAPER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SHAPER))
-
-typedef enum {
+ typedef enum
+{
SHAPER_POLICY_TIMESTAMPS = 1,
SHAPER_POLICY_BUFFERSIZE
} GstShaperPolicyType;
typedef struct _GstShaper GstShaper;
typedef struct _GstShaperClass GstShaperClass;
-struct _GstShaper {
- GstElement element;
+struct _GstShaper
+{
+ GstElement element;
- GSList *connections;
- gint nconnections;
+ GSList *connections;
+ gint nconnections;
- GstShaperPolicyType policy;
+ GstShaperPolicyType policy;
- gboolean silent;
- gchar *last_message;
+ gboolean silent;
+ gchar *last_message;
};
-struct _GstShaperClass {
+struct _GstShaperClass
+{
GstElementClass parent_class;
};
-GType gst_shaper_get_type (void);
-gboolean gst_shaper_factory_init (GstElementFactory *factory);
+GType gst_shaper_get_type (void);
+gboolean gst_shaper_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_SHAPER_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_statistics_debug);
#define GST_CAT_DEFAULT gst_statistics_debug
-GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS (
- "Statistics",
- "Generic",
- "Statistics on buffers/bytes/events",
- "David I. Lehn <dlehn@users.sourceforge.net>"
-);
+GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ("Statistics",
+ "Generic",
+ "Statistics on buffers/bytes/events",
+ "David I. Lehn <dlehn@users.sourceforge.net>");
/* Statistics signals and args */
-enum {
+enum
+{
SIGNAL_UPDATE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_BUFFERS,
ARG_BYTES,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_statistics_debug, "statistics", 0, "statistics element");
-GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_statistics_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_statistics_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_statistics_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_statistics_chain (GstPad *pad, GstData *_data);
-static void gst_statistics_reset (GstStatistics *statistics);
-static void gst_statistics_print (GstStatistics *statistics);
+static void gst_statistics_chain (GstPad * pad, GstData * _data);
+static void gst_statistics_reset (GstStatistics * statistics);
+static void gst_statistics_print (GstStatistics * statistics);
static guint gst_statistics_signals[LAST_SIGNAL] = { 0, };
gst_statistics_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_statistics_details);
}
-static void
-gst_statistics_class_init (GstStatisticsClass *klass)
+static void
+gst_statistics_class_init (GstStatisticsClass * klass)
{
GObjectClass *gobject_class;
-
+
gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS,
- g_param_spec_int64 ("buffers", "buffers", "total buffers count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_param_spec_int64 ("buffers", "buffers", "total buffers count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES,
- g_param_spec_int64 ("bytes", "bytes", "total bytes count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_param_spec_int64 ("bytes", "bytes", "total bytes count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS,
- g_param_spec_int64 ("events", "events", "total event count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFER_UPDATE_FREQ,
- g_param_spec_int64 ("buffer_update_freq", "buffer update freq", "buffer update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES_UPDATE_FREQ,
- g_param_spec_int64 ("bytes_update_freq", "bytes update freq", "bytes update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_UPDATE_FREQ,
- g_param_spec_int64 ("event_update_freq", "event update freq", "event update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_int64 ("events", "events", "total event count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq",
+ "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq",
+ "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq",
+ "event update freq", "event update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS,
- g_param_spec_boolean ("update_on_eos", "update on EOS", "update on EOS event",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("update_on_eos", "update on EOS",
+ "update on EOS event", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE,
- g_param_spec_boolean ("update", "update", "update",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("update", "update", "update", TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent", TRUE,
+ G_PARAM_READWRITE));
gst_statistics_signals[SIGNAL_UPDATE] =
- g_signal_new ("update", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
-static void
-gst_statistics_init (GstStatistics *statistics)
+static void
+gst_statistics_init (GstStatistics * statistics)
{
statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad);
- gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain));
-
+ gst_pad_set_chain_function (statistics->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_statistics_chain));
+
statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad);
statistics->timer = NULL;
statistics->last_timer = NULL;
- gst_statistics_reset(statistics);
+ gst_statistics_reset (statistics);
}
static void
-gst_statistics_reset (GstStatistics *statistics)
+gst_statistics_reset (GstStatistics * statistics)
{
g_return_if_fail (statistics != NULL);
g_return_if_fail (GST_IS_STATISTICS (statistics));
statistics->silent = FALSE;
if (!statistics->timer) {
- statistics->timer = g_timer_new();
+ statistics->timer = g_timer_new ();
}
if (!statistics->last_timer) {
- statistics->last_timer = g_timer_new();
+ statistics->last_timer = g_timer_new ();
}
}
static void
-print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, stats *final, double time)
+print_stats (gboolean first, const gchar * name, const gchar * type,
+ stats * base, stats * final, double time)
{
const gchar *header0 = "statistics";
const gchar *headerN = " ";
delta.bytes = final->bytes - base->bytes;
delta.events = final->events - base->events;
- g_print("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT
- " bytes:%" G_GINT64_FORMAT
- " events:%" G_GINT64_FORMAT "\n",
- first ? header0 : headerN,
- name, type, time,
- final->buffers,
- final->bytes,
- final->events);
- g_print("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n",
- headerN,
- name, type,
- delta.buffers/time,
- delta.bytes/time,
- delta.events/time,
- ((double)delta.bytes/(double)delta.buffers));
+ g_print ("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT
+ " bytes:%" G_GINT64_FORMAT
+ " events:%" G_GINT64_FORMAT "\n",
+ first ? header0 : headerN,
+ name, type, time, final->buffers, final->bytes, final->events);
+ g_print ("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n",
+ headerN,
+ name, type,
+ delta.buffers / time,
+ delta.bytes / time,
+ delta.events / time, ((double) delta.bytes / (double) delta.buffers));
}
static void
-gst_statistics_print (GstStatistics *statistics)
+gst_statistics_print (GstStatistics * statistics)
{
const gchar *name;
double elapsed;
g_return_if_fail (statistics != NULL);
g_return_if_fail (GST_IS_STATISTICS (statistics));
- name = gst_object_get_name(GST_OBJECT(statistics));
+ name = gst_object_get_name (GST_OBJECT (statistics));
if (!name) {
name = "";
}
- elapsed = g_timer_elapsed(statistics->timer, NULL);
- last_elapsed = g_timer_elapsed(statistics->last_timer, NULL);
+ elapsed = g_timer_elapsed (statistics->timer, NULL);
+ last_elapsed = g_timer_elapsed (statistics->last_timer, NULL);
- print_stats(1, name, "total", &zero_stats, &statistics->stats, elapsed);
- print_stats(0, name, "last", &statistics->last_stats, &statistics->stats, last_elapsed);
+ print_stats (1, name, "total", &zero_stats, &statistics->stats, elapsed);
+ print_stats (0, name, "last", &statistics->last_stats, &statistics->stats,
+ last_elapsed);
statistics->last_stats = statistics->stats;
- g_timer_reset(statistics->last_timer);
+ g_timer_reset (statistics->last_timer);
}
-static void
-gst_statistics_chain (GstPad *pad, GstData *_data)
+static void
+gst_statistics_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstStatistics *statistics;
statistics = GST_STATISTICS (gst_pad_get_parent (pad));
- if (GST_IS_EVENT(buf)) {
+ if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
+
statistics->stats.events += 1;
- if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
+ if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
gst_element_set_eos (GST_ELEMENT (statistics));
if (statistics->update_on_eos) {
- update = TRUE;
+ update = TRUE;
}
}
if (statistics->update_freq.events) {
statistics->update_count.events += 1;
if (statistics->update_count.events == statistics->update_freq.events) {
- statistics->update_count.events = 0;
- update = TRUE;
+ statistics->update_count.events = 0;
+ update = TRUE;
}
}
} else {
if (statistics->update_freq.buffers) {
statistics->update_count.buffers += 1;
if (statistics->update_count.buffers == statistics->update_freq.buffers) {
- statistics->update_count.buffers = 0;
- update = TRUE;
+ statistics->update_count.buffers = 0;
+ update = TRUE;
}
}
- statistics->stats.bytes += GST_BUFFER_SIZE(buf);
+ statistics->stats.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_freq.bytes) {
- statistics->update_count.bytes += GST_BUFFER_SIZE(buf);
+ statistics->update_count.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_count.bytes >= statistics->update_freq.bytes) {
- statistics->update_count.bytes = 0;
- update = TRUE;
+ statistics->update_count.bytes = 0;
+ update = TRUE;
}
}
}
if (update) {
if (statistics->update) {
GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics));
- g_signal_emit (G_OBJECT (statistics), gst_statistics_signals[SIGNAL_UPDATE], 0);
+ g_signal_emit (G_OBJECT (statistics),
+ gst_statistics_signals[SIGNAL_UPDATE], 0);
GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics));
}
if (!statistics->silent) {
- gst_statistics_print(statistics);
+ gst_statistics_print (statistics);
}
}
gst_pad_push (statistics->srcpad, GST_DATA (buf));
}
-static void
-gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_statistics_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstStatistics *statistics;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_STATISTICS (object));
-
+
statistics = GST_STATISTICS (object);
switch (prop_id) {
}
}
-static void gst_statistics_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_statistics_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstStatistics *statistics;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_STATISTICS (object));
-
+
statistics = GST_STATISTICS (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_STATISTICS \
(gst_statistics_get_type())
#define GST_STATISTICS(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATISTICS))
#define GST_IS_STATISTICS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATISTICS))
-
typedef struct _GstStatistics GstStatistics;
typedef struct _GstStatisticsClass GstStatisticsClass;
typedef struct _stats stats;
-struct _stats {
+struct _stats
+{
gint64 buffers;
gint64 bytes;
gint64 events;
};
-struct _GstStatistics {
+struct _GstStatistics
+{
GstElement element;
GstPad *sinkpad;
stats update_count;
stats update_freq;
- gboolean update_on_eos;
+ gboolean update_on_eos;
gboolean update;
gboolean silent;
};
-struct _GstStatisticsClass {
+struct _GstStatisticsClass
+{
GstElementClass parent_class;
/* signals */
- void (*update) (GstElement *element);
+ void (*update) (GstElement * element);
};
-GType gst_statistics_get_type(void);
+GType gst_statistics_get_type (void);
G_END_DECLS
-
#endif /* __GST_STATISTICS_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_tee_debug);
#define GST_CAT_DEFAULT gst_tee_debug
-GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS (
- "Tee pipe fitting",
- "Generic",
- "1-to-N pipe fitting",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ("Tee pipe fitting",
+ "Generic",
+ "1-to-N pipe fitting",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* Tee signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SILENT,
ARG_NUM_PADS,
/* FILL ME */
};
-GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_tee_debug, "tee", 0, "tee element");
GST_BOILERPLATE_FULL (GstTee, gst_tee, GstElement, GST_TYPE_ELEMENT, _do_init);
-static GstPad* gst_tee_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *unused);
+static GstPad *gst_tee_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * unused);
-static void gst_tee_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_tee_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_tee_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_tee_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_tee_chain (GstPad *pad, GstData *_data);
+static void gst_tee_chain (GstPad * pad, GstData * _data);
static void
gst_tee_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_tee_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
static void
-gst_tee_class_init (GstTeeClass *klass)
+gst_tee_class_init (GstTeeClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
- g_param_spec_int ("num_pads", "num_pads", "num_pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_pads", "num_pads", "num_pads",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "last_message", "last_message",
- NULL, G_PARAM_READABLE));
-
+ g_param_spec_string ("last_message", "last_message", "last_message",
+ NULL, G_PARAM_READABLE));
+
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_tee_request_new_pad);
}
-static void
-gst_tee_init (GstTee *tee)
+static void
+gst_tee_init (GstTee * tee)
{
tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
- gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
- gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_link_function (tee->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ gst_pad_set_getcaps_function (tee->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
tee->last_message = NULL;
}
/* helper compare function */
-gint name_pad_compare (gconstpointer a, gconstpointer b)
+gint
+name_pad_compare (gconstpointer a, gconstpointer b)
{
- GstPad* pad = (GstPad*) a;
+ GstPad *pad = (GstPad *) a;
gchar *name = (gchar *) b;
-
+
g_assert (GST_IS_PAD (pad));
- return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
+ return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
}
-static GstPad*
-gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *srcpad;
const GList *pads;
g_return_val_if_fail (GST_IS_TEE (element), NULL);
-
+
if (templ->direction != GST_PAD_SRC) {
g_warning ("gsttee: request new pad that is not a SRC pad\n");
return NULL;
/* try names in order and find one that's not in use atm */
pads = gst_element_get_pad_list (element);
-
+
name = NULL;
- while (!name)
- {
+ while (!name) {
name = g_strdup_printf ("src%d", i);
- if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL)
- {
+ if (g_list_find_custom ((GList *) pads, (gconstpointer) name,
+ name_pad_compare) != NULL) {
/* this name is taken, use the next one */
++i;
g_free (name);
tee->last_message = g_strdup_printf ("new pad %s", name);
g_object_notify (G_OBJECT (tee), "last_message");
}
-
+
srcpad = gst_pad_new_from_template (templ, name);
g_free (name);
- gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
- gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_link_function (srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ gst_pad_set_getcaps_function (srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (tee), srcpad);
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;
}
static void
-gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_tee_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstTee *tee;
}
static void
-gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tee_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstTee *tee;
*
* Chain a buffer on a pad.
*/
-static void
-gst_tee_chain (GstPad *pad, GstData *_data)
+static void
+gst_tee_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstTee *tee;
tee = GST_TEE (gst_pad_get_parent (pad));
gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1);
-
+
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
while (pads) {
GstPad *outpad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC)
if (!tee->silent) {
g_free (tee->last_message);
- tee->last_message = g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
- G_GUINT64_FORMAT ") %p",
- GST_DEBUG_PAD_NAME (outpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
+ tee->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
+ G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (tee), "last_message");
}
gst_buffer_unref (buf);
}
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_TEE \
(gst_tee_get_type())
#define GST_TEE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEE))
#define GST_IS_TEE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEE))
+typedef struct _GstTee GstTee;
+typedef struct _GstTeeClass GstTeeClass;
-typedef struct _GstTee GstTee;
-typedef struct _GstTeeClass GstTeeClass;
-
-struct _GstTee {
+struct _GstTee
+{
GstElement element;
GstPad *sinkpad;
gboolean silent;
- gchar *last_message;
+ gchar *last_message;
};
-struct _GstTeeClass {
+struct _GstTeeClass
+{
GstElementClass parent_class;
};
-GType gst_tee_get_type (void);
+GType gst_tee_get_type (void);
-gboolean gst_tee_factory_init (GstElementFactory *factory);
+gboolean gst_tee_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_TEE_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_type_find_element_debug);
#define GST_CAT_DEFAULT gst_type_find_element_debug
-GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
- "TypeFind",
- "Generic",
- "Finds the media type of a stream",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+GstElementDetails gst_type_find_element_details =
+GST_ELEMENT_DETAILS ("TypeFind",
+ "Generic",
+ "Finds the media type of a stream",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* generic templates */
-GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
-
-GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate type_find_element_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+GstStaticPadTemplate type_find_element_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
/* TypeFind signals and args */
-enum {
+enum
+{
HAVE_TYPE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_CAPS,
ARG_MINIMUM,
ARG_MAXIMUM
};
-enum {
- MODE_NORMAL, /* act as identity */
- MODE_TYPEFIND, /* do typefinding */
+enum
+{
+ MODE_NORMAL, /* act as identity */
+ MODE_TYPEFIND, /* do typefinding */
};
GST_DEBUG_CATEGORY_INIT (gst_type_find_element_debug, "typefind", \
GST_DEBUG_BG_YELLOW | GST_DEBUG_FG_GREEN, "type finding element");
-GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_type_find_element_dispose (GObject * object);
-static void gst_type_find_element_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_type_find_element_get_property (GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec);
+static void gst_type_find_element_dispose (GObject * object);
+static void gst_type_find_element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_type_find_element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-static const GstEventMask *
- gst_type_find_element_src_event_mask (GstPad * pad);
-static gboolean gst_type_find_element_src_event (GstPad * pad,
- GstEvent * event);
+static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad);
+static gboolean gst_type_find_element_src_event (GstPad * pad,
+ GstEvent * event);
-static void gst_type_find_element_chain (GstPad * sinkpad,
- GstData * data);
+static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data);
static GstElementStateReturn
- gst_type_find_element_change_state (GstElement * element);
+gst_type_find_element_change_state (GstElement * element);
static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 };
static void
-gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps)
+gst_type_find_element_have_type (GstTypeFindElement * typefind,
+ guint probability, const GstCaps * caps)
{
g_assert (typefind->caps == NULL);
g_assert (caps != NULL);
gst_type_find_element_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (gstelement_class, &gst_type_find_element_details);
+
+ gst_element_class_set_details (gstelement_class,
+ &gst_type_find_element_details);
}
static void
-gst_type_find_element_class_init (GstTypeFindElementClass *typefind_class)
+gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (typefind_class);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (typefind_class);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_type_find_element_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_type_find_element_get_property);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose);
typefind_class->have_type = gst_type_find_element_have_type;
g_object_class_install_property (gobject_class, ARG_CAPS,
- g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
- gst_caps_get_type(), G_PARAM_READABLE));
+ g_param_spec_boxed ("caps", _("caps"),
+ _("detected capabilities in stream"), gst_caps_get_type (),
+ G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
- g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
- GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
+ g_param_spec_uint ("minimum", _("minimum"),
+ "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM,
+ GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
- g_param_spec_uint ("maximum", _("maximum"), "probability to stop typefinding",
- GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE));
-
- gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type",
- G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
- gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
- G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
+ g_param_spec_uint ("maximum", _("maximum"),
+ "probability to stop typefinding", GST_TYPE_FIND_MINIMUM,
+ GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE));
+
+ gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type",
+ G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
+ gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
+ G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
static void
-gst_type_find_element_init (GstTypeFindElement *typefind)
+gst_type_find_element_init (GstTypeFindElement * typefind)
{
/* sinkpad */
- typefind->sink = gst_pad_new_from_template (
- gst_static_pad_template_get (&type_find_element_sink_template), "sink");
- gst_pad_set_chain_function (typefind->sink,
- gst_type_find_element_chain);
+ typefind->sink =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&type_find_element_sink_template), "sink");
+ gst_pad_set_chain_function (typefind->sink, gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
- typefind->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&type_find_element_src_template), "src");
+ typefind->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
- gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
+ gst_pad_set_event_mask_function (typefind->src,
+ gst_type_find_element_src_event_mask);
gst_pad_use_explicit_caps (typefind->src);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
GST_FLAG_SET (typefind, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_type_find_element_dispose (GObject *object)
+gst_type_find_element_dispose (GObject * object)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (object);
}
}
static void
-gst_type_find_element_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_type_find_element_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstTypeFindElement *typefind;
}
}
static void
-gst_type_find_element_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_type_find_element_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstTypeFindElement *typefind;
}
}
static const GstEventMask *
-gst_type_find_element_src_event_mask (GstPad *pad)
+gst_type_find_element_src_event_mask (GstPad * pad)
{
static const GstEventMask mask[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_SEEK,
+ GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END |
+ GST_SEEK_FLAG_FLUSH},
/* add more if you want, event masks suck and need to die anyway */
- { 0, }
+ {0,}
};
-
+
return mask;
}
-static gboolean
-gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
+
+static gboolean
+gst_type_find_element_src_event (GstPad * pad, GstEvent * event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
}
return gst_pad_event_default (pad, event);
}
-typedef struct {
- GstTypeFindFactory * factory;
- gint probability;
- GstCaps * caps;
- gint64 requested_offset;
- guint requested_size;
-
- GList * buffers;
- GstTypeFindElement * self;
+typedef struct
+{
+ GstTypeFindFactory *factory;
+ gint probability;
+ GstCaps *caps;
+ gint64 requested_offset;
+ guint requested_size;
+
+ GList *buffers;
+ GstTypeFindElement *self;
} TypeFindEntry;
static inline TypeFindEntry *
return g_new0 (TypeFindEntry, 1);
}
static void
-free_entry_buffers (TypeFindEntry *entry)
+free_entry_buffers (TypeFindEntry * entry)
{
g_list_foreach (entry->buffers, (GFunc) gst_data_unref, NULL);
g_list_free (entry->buffers);
entry->buffers = NULL;
}
static void
-free_entry (TypeFindEntry *entry)
+free_entry (TypeFindEntry * entry)
{
free_entry_buffers (entry);
-
+
if (entry->caps)
gst_caps_free (entry->caps);
g_free (entry);
}
static void
-start_typefinding (GstTypeFindElement *typefind)
+start_typefinding (GstTypeFindElement * typefind)
{
g_assert (typefind->caps == NULL);
g_assert (typefind->possibilities == NULL);
-
+
GST_DEBUG_OBJECT (typefind, "starting typefinding");
- typefind->mode = MODE_TYPEFIND;
- typefind->stream_length_available = TRUE;
- typefind->stream_length = 0;
+ typefind->mode = MODE_TYPEFIND;
+ typefind->stream_length_available = TRUE;
+ typefind->stream_length = 0;
}
static void
-stop_typefinding (GstTypeFindElement *typefind)
+stop_typefinding (GstTypeFindElement * typefind)
{
/* stop all typefinding and set mode back to normal */
- gboolean push_cached_buffers = gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING;
-
- GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
+ gboolean push_cached_buffers =
+ gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING;
+
+ GST_DEBUG_OBJECT (typefind, "stopping typefinding%s",
+ push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this should only happen on PAUSED => READY or EOS */
- GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
+ GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions",
+ g_list_length (typefind->possibilities));
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
GstBuffer *buffer;
guint size = gst_buffer_store_get_size (typefind->store, 0);
- if (size && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) {
+ if (size
+ && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) {
GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size);
gst_pad_push (typefind->src, GST_DATA (buffer));
} else {
size = 0;
}
GST_LOG_OBJECT (typefind, "seeking back to current position %u", size);
- if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink),
- gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, size))) {
- GST_WARNING_OBJECT (typefind, "could not seek to required position %u, hope for the best", size);
+ if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink),
+ gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES,
+ size))) {
+ GST_WARNING_OBJECT (typefind,
+ "could not seek to required position %u, hope for the best", size);
}
}
gst_buffer_store_clear (typefind->store);
}
+
static guint64
find_element_get_length (gpointer data)
{
TypeFindEntry *entry = (TypeFindEntry *) data;
GstTypeFindElement *typefind = entry->self;
GstFormat format = GST_FORMAT_BYTES;
-
+
if (!typefind->stream_length_available) {
- GST_LOG_OBJECT (entry->self, "'%s' called get_length () but we know it's not available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_LOG_OBJECT (entry->self,
+ "'%s' called get_length () but we know it's not available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0;
}
if (entry->self->stream_length == 0) {
- typefind->stream_length_available = gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
- &format, &entry->self->stream_length);
+ typefind->stream_length_available =
+ gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
+ &format, &entry->self->stream_length);
if (format != GST_FORMAT_BYTES)
typefind->stream_length_available = FALSE;
if (!typefind->stream_length_available) {
- GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () but it's not available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (entry->self,
+ "'%s' called get_length () but it's not available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0;
} else {
- GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () and it's %"G_GUINT64_FORMAT" bytes",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
+ GST_DEBUG_OBJECT (entry->self,
+ "'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
}
}
-
+
return entry->self->stream_length;
}
static void
-gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
+gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_EOS:
- /* this should only happen when we got all available data */
- entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
- if (entry && entry->probability >= typefind->min_probability) {
- GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
- }
- stop_typefinding (typefind);
- gst_pad_event_default (pad, event);
- break;
- default:
- gst_data_unref (GST_DATA (event));
- break;
+ case GST_EVENT_EOS:
+ /* this should only happen when we got all available data */
+ entry =
+ (TypeFindEntry *) typefind->possibilities ? typefind->
+ possibilities->data : NULL;
+ if (entry && entry->probability >= typefind->min_probability) {
+ GST_INFO_OBJECT (typefind,
+ "'%s' is the best typefind left after we got all data, using it now (probability %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
+ entry->probability, entry->caps);
+ }
+ stop_typefinding (typefind);
+ gst_pad_event_default (pad, event);
+ break;
+ default:
+ gst_data_unref (GST_DATA (event));
+ break;
}
} else {
gst_pad_event_default (pad, event);
{
GstBuffer *buf;
TypeFindEntry *entry = (TypeFindEntry *) data;
-
- GST_LOG_OBJECT (entry->self, "'%s' called peek (%"G_GINT64_FORMAT", %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size);
+
+ GST_LOG_OBJECT (entry->self, "'%s' called peek (%" G_GINT64_FORMAT ", %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size);
if (offset >= 0) {
buf = gst_buffer_store_get_buffer (entry->self->store, offset, size);
} else {
if (length == 0) {
buf = NULL;
} else {
- buf = gst_buffer_store_get_buffer (entry->self->store, length + offset, size);
+ buf =
+ gst_buffer_store_get_buffer (entry->self->store, length + offset,
+ size);
}
}
return GST_BUFFER_DATA (buf);
} else {
if (entry->requested_size == 0) {
- GST_LOG_OBJECT (entry->self, "setting requested peek (%"G_GINT64_FORMAT", %u) on '%s'",
- offset, size, GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_LOG_OBJECT (entry->self,
+ "setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset,
+ size, GST_PLUGIN_FEATURE_NAME (entry->factory));
entry->requested_offset = offset;
entry->requested_size = size;
}
}
}
static void
-find_suggest (gpointer data, guint probability, const GstCaps *caps)
+find_suggest (gpointer data, guint probability, const GstCaps * caps)
{
TypeFindEntry *entry = (TypeFindEntry *) data;
-
- GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")",
- GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
+
+ GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank;
}
static void
-gst_type_find_element_chain (GstPad *pad, GstData *data)
+gst_type_find_element_chain (GstPad * pad, GstData * data)
{
GstTypeFindElement *typefind;
GList *entries;
TypeFindEntry *entry;
GList *walk;
- GstTypeFind find = {find_peek, find_suggest, NULL, find_element_get_length };
+ GstTypeFind find = { find_peek, find_suggest, NULL, find_element_get_length };
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (GST_IS_EVENT (data)) {
case MODE_NORMAL:
gst_pad_push (typefind->src, data);
return;
- case MODE_TYPEFIND: {
+ case MODE_TYPEFIND:{
guint64 current_offset;
-
+
gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data));
- current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ?
- GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) :
+ current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ?
+ GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) :
gst_buffer_store_get_size (typefind->store, 0);
gst_data_unref (data);
if (typefind->possibilities == NULL) {
/* not yet started, get all typefinding functions into our "queue" */
GList *all_factories = gst_type_find_factory_get_list ();
- GST_INFO_OBJECT (typefind, "starting with %u typefinding functions",
- g_list_length ((GList *) all_factories));
-
+
+ GST_INFO_OBJECT (typefind, "starting with %u typefinding functions",
+ g_list_length ((GList *) all_factories));
+
all_factories = g_list_sort (all_factories, compare_type_find_factory);
walk = all_factories;
while (all_factories) {
entry = new_entry ();
-
+
entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data);
entry->self = typefind;
entry->probability = 0;
- typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
+ typefind->possibilities =
+ g_list_prepend (typefind->possibilities, entry);
all_factories = g_list_next (all_factories);
}
g_list_free (all_factories);
}
/* call every typefind function once */
walk = entries = typefind->possibilities;
- GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", g_list_length (entries));
+ GST_INFO_OBJECT (typefind, "iterating %u typefinding functions",
+ g_list_length (entries));
typefind->possibilities = NULL;
while (walk) {
find.data = entry = (TypeFindEntry *) walk->data;
gst_type_find_factory_call_function (entry->factory, &find);
free_entry_buffers (entry);
if (entry->probability == 0 && entry->requested_size == 0) {
- GST_DEBUG_OBJECT (typefind, "'%s' was removed - no chance of being the right plugin",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was removed - no chance of being the right plugin",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry);
} else if (entry->probability >= typefind->max_probability) {
/* wooha, got caps */
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
-
- GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
- GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
+
+ GST_INFO_OBJECT (typefind,
+ "'%s' returned %u/%u probability, using it NOW",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), probability,
+ typefind->max_probability);
while (walk) {
free_entry ((TypeFindEntry *) walk->data);
walk = g_list_next (walk);
walk = g_list_next (walk);
}
typefind->possibilities = NULL;
- g_list_free (typefind->possibilities);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
+ g_list_free (typefind->possibilities);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
+ probability, found_caps);
free_entry (entry);
} else {
- typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
+ typefind->possibilities =
+ g_list_prepend (typefind->possibilities, entry);
}
}
g_list_free (entries);
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
} else {
/* set up typefind element for next iteration */
- typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry);
-
+ typefind->possibilities =
+ g_list_sort (typefind->possibilities, compare_type_find_entry);
+
/* look for typefind functions that require data without seeking */
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data;
gint64 seek_offset;
GstEvent *event;
- seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
- find_element_get_length (entry) + entry->requested_offset;
- seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
- event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
+ seek_offset =
+ entry->requested_offset >
+ 0 ? entry->
+ requested_offset : find_element_get_length (entry) +
+ entry->requested_offset;
+ seek_offset +=
+ gst_buffer_store_get_size (typefind->store, seek_offset);
+ event =
+ gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET,
+ seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
- GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
- GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was reset - seeked to %" G_GINT64_FORMAT,
+ GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
- GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
- GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
+ GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}
walk = g_list_next (typefind->possibilities);
while (walk) {
GList *cur = walk;
+
entry = (TypeFindEntry *) walk->data;
walk = g_list_next (walk);
if (entry->requested_size == 0) {
- GST_DEBUG_OBJECT (typefind, "'%s' was removed - higher possibilities available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was removed - higher possibilities available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry);
- typefind->possibilities = g_list_delete_link (typefind->possibilities, cur);
+ typefind->possibilities =
+ g_list_delete_link (typefind->possibilities, cur);
}
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > typefind->min_probability) {
- GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
+ GST_INFO_OBJECT (typefind,
+ "'%s' is the only typefind left, using it now (probability %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
+ 0, entry->probability, entry->caps);
free_entry (entry);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
}
}
static GstElementStateReturn
-gst_type_find_element_change_state (GstElement *element)
+gst_type_find_element_change_state (GstElement * element)
{
GstTypeFindElement *typefind;
default:
break;
}
-
+
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
#include "gstbufferstore.h"
G_BEGIN_DECLS
-
-
-
#define GST_TYPE_TYPE_FIND_ELEMENT (gst_type_find_element_get_type ())
#define GST_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElement))
#define GST_IS_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_ELEMENT))
#define GST_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass))
#define GST_IS_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_ELEMENT))
#define GST_TYPE_FIND_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass))
+typedef struct _GstTypeFindElement GstTypeFindElement;
+typedef struct _GstTypeFindElementClass GstTypeFindElementClass;
-typedef struct _GstTypeFindElement GstTypeFindElement;
-typedef struct _GstTypeFindElementClass GstTypeFindElementClass;
+struct _GstTypeFindElement
+{
+ GstElement element;
-struct _GstTypeFindElement {
- GstElement element;
+ GstPad *sink;
+ GstPad *src;
- GstPad * sink;
- GstPad * src;
+ guint min_probability;
+ guint max_probability;
+ GstCaps *caps;
- guint min_probability;
- guint max_probability;
- GstCaps * caps;
+ guint mode;
+ GstBufferStore *store;
+ guint64 stream_length;
+ gboolean stream_length_available;
- guint mode;
- GstBufferStore * store;
- guint64 stream_length;
- gboolean stream_length_available;
-
- GList * possibilities;
+ GList *possibilities;
};
-struct _GstTypeFindElementClass {
- GstElementClass parent_class;
+struct _GstTypeFindElementClass
+{
+ GstElementClass parent_class;
/* signals */
- void (*have_type) (GstTypeFindElement *element,
- guint probability,
- const GstCaps * caps);
+ void (*have_type) (GstTypeFindElement * element,
+ guint probability, const GstCaps * caps);
};
GType gst_type_find_element_get_type (void);
G_END_DECLS
-
#endif /* __GST_TYPE_FIND_ELEMENT_H__ */
#ifndef __GST_I18N_APP_H__
#define __GST_I18N_APP_H__
-#include "gettext.h" /* included with gettext distribution and copied */
+#include "gettext.h" /* included with gettext distribution and copied */
/* we want to use shorthand _() for translating and N_() for marking */
#define _(String) gettext (String)
#ifndef __GST_I18N_LIB_H__
#define __GST_I18N_LIB_H__
-#include "gettext.h" /* included with gettext distribution and copied */
+#include "gettext.h" /* included with gettext distribution and copied */
#ifndef GETTEXT_PACKAGE
#error You must define GETTEXT_PACKAGE before including this header.
static gboolean _gst_enable_cpu_opt = TRUE;
static gboolean gst_initialized = FALSE;
+
/* this will be set in popt callbacks when a problem has been encountered */
static gboolean _gst_initialization_failure = FALSE;
extern gint _gst_trace_on;
extern GThreadFunctions gst_thread_dummy_functions;
-static void load_plugin_func (gpointer data, gpointer user_data);
-static void init_popt_callback (poptContext context,
- enum poptCallbackReason reason,
- const GstPoptOption *option,
- const char *arg, void *data);
-static gboolean init_pre (void);
-static gboolean init_post (void);
+static void load_plugin_func (gpointer data, gpointer user_data);
+static void init_popt_callback (poptContext context,
+ enum poptCallbackReason reason,
+ const GstPoptOption * option, const char *arg, void *data);
+static gboolean init_pre (void);
+static gboolean init_post (void);
static GSList *preload_plugins = NULL;
const gchar *g_log_domain_gstreamer = "GStreamer";
static void
-debug_log_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data)
+debug_log_handler (const gchar * log_domain,
+ GLogLevelFlags log_level, const gchar * message, gpointer user_data)
{
g_log_default_handler (log_domain, log_level, message, user_data);
/* FIXME: do we still need this ? fatal errors these days are all
/* g_on_error_query (NULL); */
}
-enum {
- ARG_VERSION=1,
+enum
+{
+ ARG_VERSION = 1,
ARG_FATAL_WARNINGS,
#ifndef GST_DISABLE_GST_DEBUG
ARG_DEBUG_LEVEL,
* the GST_SCHEDULER_DEFAULT_NAME define.
*/
static const GstPoptOption gstreamer_options[] = {
- {NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *) &init_popt_callback, 0, NULL, NULL},
+ {NULL, NUL, POPT_ARG_CALLBACK | POPT_CBFLAG_PRE | POPT_CBFLAG_POST,
+ (void *) &init_popt_callback, 0, NULL, NULL},
/* make sure we use our GETTEXT_PACKAGE as the domain for popt translations */
{NULL, NUL, POPT_ARG_INTL_DOMAIN, GETTEXT_PACKAGE, 0, NULL, NULL},
- {"gst-version", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, N_("Print the GStreamer version"), NULL},
- {"gst-fatal-warnings", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL},
+ {"gst-version", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, ARG_VERSION,
+ N_("Print the GStreamer version"), NULL},
+ {"gst-fatal-warnings", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL},
#ifndef GST_DISABLE_GST_DEBUG
- {"gst-debug-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL},
- {"gst-debug-level", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_LEVEL, N_("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"), N_("LEVEL")},
- {"gst-debug", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, N_("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), N_("LIST")},
- {"gst-debug-no-color", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL},
- {"gst-debug-disable", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_DISABLE, N_("Disable debugging")},
+ {"gst-debug-help", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL},
+ {"gst-debug-level", NUL, POPT_ARG_INT | POPT_ARGFLAG_STRIP, NULL,
+ ARG_DEBUG_LEVEL,
+ N_
+ ("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"),
+ N_("LEVEL")},
+ {"gst-debug", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG,
+ N_
+ ("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"),
+ N_("LIST")},
+ {"gst-debug-no-color", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL},
+ {"gst-debug-disable", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_DEBUG_DISABLE, N_("Disable debugging")},
#endif
- {"gst-disable-cpu-opt",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DISABLE_CPU_OPT,N_("Disable accelerated CPU instructions"), NULL},
- {"gst-plugin-spew", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL},
- {"gst-plugin-path", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_PATH, N_("path list for loading plugins (separated by '" G_SEARCHPATH_SEPARATOR_S "')"),N_("PATHS")},
- {"gst-plugin-load", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_LOAD, N_("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"), N_("PLUGINS")},
- {"gst-disable-segtrap",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_SEGTRAP_DISABLE,N_("Disable trapping of segmentation faults during plugin loading"), NULL},
- {"gst-scheduler", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_SCHEDULER, N_("Scheduler to use ('"GST_SCHEDULER_DEFAULT_NAME"' is the default)"), N_("SCHEDULER")},
- {"gst-registry", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_REGISTRY, N_("Registry to use") , N_("REGISTRY")},
+ {"gst-disable-cpu-opt", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_DISABLE_CPU_OPT, N_("Disable accelerated CPU instructions"), NULL},
+ {"gst-plugin-spew", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL},
+ {"gst-plugin-path", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ ARG_PLUGIN_PATH,
+ N_("path list for loading plugins (separated by '"
+ G_SEARCHPATH_SEPARATOR_S "')"), N_("PATHS")},
+ {"gst-plugin-load", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ ARG_PLUGIN_LOAD,
+ N_
+ ("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"),
+ N_("PLUGINS")},
+ {"gst-disable-segtrap", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
+ ARG_SEGTRAP_DISABLE,
+ N_("Disable trapping of segmentation faults during plugin loading"),
+ NULL},
+ {"gst-scheduler", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ ARG_SCHEDULER,
+ N_("Scheduler to use ('" GST_SCHEDULER_DEFAULT_NAME
+ "' is the default)"), N_("SCHEDULER")},
+ {"gst-registry", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ ARG_REGISTRY, N_("Registry to use"), N_("REGISTRY")},
POPT_TABLEEND
};
*/
void
gst_init_with_popt_table (int *argc, char **argv[],
- const GstPoptOption *popt_options)
+ const GstPoptOption * popt_options)
{
if (!gst_init_check_with_popt_table (argc, argv, popt_options)) {
g_print ("Could not initialize GStreamer !\n");
exit (1);
}
}
+
/**
* gst_init_check_with_popt_table:
* @argc: pointer to application's argc
*/
gboolean
gst_init_check_with_popt_table (int *argc, char **argv[],
- const GstPoptOption *popt_options)
+ const GstPoptOption * popt_options)
{
poptContext context;
gint nextopt;
GstPoptOption *options;
GstPoptOption options_with[] = {
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0, "Application options:", NULL},
+ {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:",
+ NULL},
+ {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0,
+ "GStreamer options:", NULL},
+ {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0,
+ "Application options:", NULL},
POPT_TABLEEND
};
GstPoptOption options_without[] = {
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
- {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL},
+ {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:",
+ NULL},
+ {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0,
+ "GStreamer options:", NULL},
POPT_TABLEEND
};
- if (gst_initialized)
- {
+ if (gst_initialized) {
GST_DEBUG ("already initialized gst");
return TRUE;
}
if (argc || argv)
g_warning ("gst_init: Only one of argc or argv was NULL");
- if (!init_pre ()) return FALSE;
- if (!init_post ()) return FALSE;
+ if (!init_pre ())
+ return FALSE;
+ if (!init_post ())
+ return FALSE;
gst_initialized = TRUE;
return TRUE;
}
} else {
options = options_with;
}
- context = poptGetContext ("GStreamer", *argc, (const char**)*argv,
- options, 0);
+ context = poptGetContext ("GStreamer", *argc, (const char **) *argv,
+ options, 0);
- while ((nextopt = poptGetNextOpt (context)) > 0)
- {
+ while ((nextopt = poptGetNextOpt (context)) > 0) {
/* we only check for failures here, actual work is done in callbacks */
- if (_gst_initialization_failure) return FALSE;
+ if (_gst_initialization_failure)
+ return FALSE;
}
if (nextopt != -1) {
g_print ("Error on option %s: %s.\nRun '%s --help' "
- "to see a full list of available command line options.\n",
- poptBadOption (context, 0),
- poptStrerror (nextopt),
- (*argv)[0]);
+ "to see a full list of available command line options.\n",
+ poptBadOption (context, 0), poptStrerror (nextopt), (*argv)[0]);
poptFreeContext (context);
return FALSE;
GstRegistry *registry = GST_REGISTRY (user_data);
GST_INFO ("Adding plugin path: \"%s\"", (gchar *) data);
- gst_registry_add_path (registry, (gchar *)data);
+ gst_registry_add_path (registry, (gchar *) data);
}
#endif
}
static void
-parse_debug_list (const gchar *list)
+parse_debug_list (const gchar * list)
{
gchar **split;
gchar **walk;
walk = split = g_strsplit (list, ",", 0);
while (walk[0]) {
- gchar **values = g_strsplit ( walk[0], ":", 2);
+ gchar **values = g_strsplit (walk[0], ":", 2);
+
if (values[0] && values[1]) {
gint level = 0;
+
g_strstrip (values[0]);
g_strstrip (values[1]);
level = strtol (values[1], NULL, 0);
if (level >= 0 && level < GST_LEVEL_COUNT) {
- GST_DEBUG ("setting debugging to level %d for name \"%s\"",
- level, values[0]);
- gst_debug_set_threshold_for_name (values[0], level);
+ GST_DEBUG ("setting debugging to level %d for name \"%s\"",
+ level, values[0]);
+ gst_debug_set_threshold_for_name (values[0], level);
}
}
g_strfreev (values);
}
static void
-split_and_iterate (const gchar *stringlist, gchar *separator, GFunc iterator, gpointer user_data)
+split_and_iterate (const gchar * stringlist, gchar * separator, GFunc iterator,
+ gpointer user_data)
{
gchar **strings;
gint j = 0;
while (strings[j]) {
iterator (strings[j], user_data);
if (++j == MAX_PATH_SPLIT) {
- lastlist = g_strdup (strings[j]);
- g_strfreev (strings);
- j=0;
- break;
+ lastlist = g_strdup (strings[j]);
+ g_strfreev (strings);
+ j = 0;
+ break;
}
}
}
g_thread_init (&gst_thread_dummy_functions);
}
/* we need threading to be enabled right here */
- _gst_debug_init();
+ _gst_debug_init ();
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
gchar *user_reg;
const gchar *homedir;
- _global_registry = gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE);
+ _global_registry =
+ gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE);
#ifdef PLUGINS_USE_BUILDDIR
/* location libgstelements.so */
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/elements");
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types");
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug");
- gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/schedulers");
+ gst_registry_add_path (_global_registry,
+ PLUGINS_BUILDDIR "/gst/schedulers");
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers");
#else
/* add the main (installed) library path */
gst_registry_add_path (_global_registry, PLUGINS_DIR);
#endif /* PLUGINS_USE_BUILDDIR */
- if (g_getenv ("GST_REGISTRY"))
- {
+ if (g_getenv ("GST_REGISTRY")) {
user_reg = g_strdup (g_getenv ("GST_REGISTRY"));
- }
- else
- {
+ } else {
homedir = g_get_home_dir ();
user_reg = g_strjoin ("/", homedir, LOCAL_REGISTRY_FILE, NULL);
}
}
static gboolean
-gst_register_core_elements (GstPlugin *plugin)
+gst_register_core_elements (GstPlugin * plugin)
{
/* register some standard builtin types */
- g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY, GST_TYPE_BIN));
- g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY, GST_TYPE_PIPELINE));
- g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY, GST_TYPE_THREAD));
- g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY, GST_TYPE_QUEUE));
+ g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY,
+ GST_TYPE_BIN));
+ g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY,
+ GST_TYPE_PIPELINE));
+ g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY,
+ GST_TYPE_THREAD));
+ g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY,
+ GST_TYPE_QUEUE));
return TRUE;
}
{
GLogLevelFlags llf;
const gchar *plugin_path;
+
#ifndef GST_DISABLE_TRACE
GstTrace *gst_trace;
#endif /* GST_DISABLE_TRACE */
g_log_set_handler (g_log_domain_gstreamer, llf, debug_log_handler, NULL);
GST_INFO ("Initializing GStreamer Core Library version %s %s",
- VERSION, _gst_use_threads ? "" : "(no threads)");
+ VERSION, _gst_use_threads ? "" : "(no threads)");
_gst_format_initialize ();
_gst_query_type_initialize ();
plugin_path = g_getenv ("GST_PLUGIN_PATH");
#ifndef GST_DISABLE_REGISTRY
- split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func, _global_registry);
+ split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func,
+ _global_registry);
#endif /* GST_DISABLE_REGISTRY */
/* register core plugins */
if (!_gst_registry_fixed) {
/* don't override command-line options */
if (g_getenv ("GST_REGISTRY")) {
- g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"), NULL);
+ g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"),
+ NULL);
_gst_registry_fixed = TRUE;
}
}
g_slist_free (preload_plugins);
preload_plugins = NULL;
}
-
#ifndef GST_DISABLE_TRACE
_gst_trace_on = 0;
if (_gst_trace_on) {
sort_by_category_name (gconstpointer a, gconstpointer b)
{
return strcmp (gst_debug_category_get_name ((GstDebugCategory *) a),
- gst_debug_category_get_name ((GstDebugCategory *) b));
+ gst_debug_category_get_name ((GstDebugCategory *) b));
}
static void
gst_debug_help (void)
walk2 = list2 = gst_registry_pool_plugin_list ();
while (walk2) {
GstPlugin *plugin = GST_PLUGIN (walk2->data);
+
walk2 = g_list_next (walk2);
if (!gst_plugin_is_loaded (plugin)) {
#ifndef GST_DISABLE_REGISTRY
if (GST_IS_REGISTRY (plugin->manager)) {
- GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s", plugin->desc.name);
- if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), plugin) != GST_REGISTRY_OK)
- GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed", plugin->desc.name);
+ GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s",
+ plugin->desc.name);
+ if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager),
+ plugin) != GST_REGISTRY_OK)
+ GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed",
+ plugin->desc.name);
}
#endif /* GST_DISABLE_REGISTRY */
}
if (gst_debug_is_colored ()) {
gchar *color = gst_debug_construct_term_color (cat->color);
+
g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n",
- color,
- gst_debug_category_get_name (cat),
- gst_debug_category_get_threshold (cat),
- gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
- color,
- gst_debug_category_get_description (cat));
+ color,
+ gst_debug_category_get_name (cat),
+ gst_debug_category_get_threshold (cat),
+ gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
+ color, gst_debug_category_get_description (cat));
g_free (color);
} else {
g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat),
- gst_debug_category_get_threshold (cat),
- gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
- gst_debug_category_get_description (cat));
+ gst_debug_category_get_threshold (cat),
+ gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
+ gst_debug_category_get_description (cat));
}
walk = g_slist_next (walk);
}
static void
init_popt_callback (poptContext context, enum poptCallbackReason reason,
- const GstPoptOption *option, const char *arg, void *data)
+ const GstPoptOption * option, const char *arg, void *data)
{
GLogLevelFlags fatal_mask;
if (gst_initialized)
return;
switch (reason) {
- case POPT_CALLBACK_REASON_PRE:
- if (!init_pre ()) _gst_initialization_failure = TRUE;
- break;
- case POPT_CALLBACK_REASON_OPTION:
- switch (option->val) {
- case ARG_VERSION:
- g_print ("GStreamer Core Library version %s\n", GST_VERSION);
- exit (0);
- case ARG_FATAL_WARNINGS:
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
+ case POPT_CALLBACK_REASON_PRE:
+ if (!init_pre ())
+ _gst_initialization_failure = TRUE;
break;
+ case POPT_CALLBACK_REASON_OPTION:
+ switch (option->val) {
+ case ARG_VERSION:
+ g_print ("GStreamer Core Library version %s\n", GST_VERSION);
+ exit (0);
+ case ARG_FATAL_WARNINGS:
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+ break;
#ifndef GST_DISABLE_GST_DEBUG
- case ARG_DEBUG_LEVEL: {
- gint tmp = 0;
- tmp = strtol (arg, NULL, 0);
- if (tmp >= 0 && tmp < GST_LEVEL_COUNT) {
- gst_debug_set_default_threshold (tmp);
- }
- break;
- }
- case ARG_DEBUG:
- parse_debug_list (arg);
- break;
- case ARG_DEBUG_NO_COLOR:
- gst_debug_set_colored (FALSE);
- break;
- case ARG_DEBUG_DISABLE:
- gst_debug_set_active (FALSE);
- break;
- case ARG_DEBUG_HELP:
- gst_debug_help ();
- exit (0);
+ case ARG_DEBUG_LEVEL:{
+ gint tmp = 0;
+
+ tmp = strtol (arg, NULL, 0);
+ if (tmp >= 0 && tmp < GST_LEVEL_COUNT) {
+ gst_debug_set_default_threshold (tmp);
+ }
+ break;
+ }
+ case ARG_DEBUG:
+ parse_debug_list (arg);
+ break;
+ case ARG_DEBUG_NO_COLOR:
+ gst_debug_set_colored (FALSE);
+ break;
+ case ARG_DEBUG_DISABLE:
+ gst_debug_set_active (FALSE);
+ break;
+ case ARG_DEBUG_HELP:
+ gst_debug_help ();
+ exit (0);
#endif
- case ARG_DISABLE_CPU_OPT:
- _gst_enable_cpu_opt = FALSE;
- break;
- case ARG_PLUGIN_SPEW:
- break;
- case ARG_PLUGIN_PATH:
+ case ARG_DISABLE_CPU_OPT:
+ _gst_enable_cpu_opt = FALSE;
+ break;
+ case ARG_PLUGIN_SPEW:
+ break;
+ case ARG_PLUGIN_PATH:
#ifndef GST_DISABLE_REGISTRY
- split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func, _user_registry);
+ split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func,
+ _user_registry);
#endif /* GST_DISABLE_REGISTRY */
- break;
- case ARG_PLUGIN_LOAD:
- split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL);
- break;
- case ARG_SEGTRAP_DISABLE:
- _gst_disable_segtrap = TRUE;
- break;
- case ARG_SCHEDULER:
- gst_scheduler_factory_set_default_name (arg);
- break;
- case ARG_REGISTRY:
+ break;
+ case ARG_PLUGIN_LOAD:
+ split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL);
+ break;
+ case ARG_SEGTRAP_DISABLE:
+ _gst_disable_segtrap = TRUE;
+ break;
+ case ARG_SCHEDULER:
+ gst_scheduler_factory_set_default_name (arg);
+ break;
+ case ARG_REGISTRY:
#ifndef GST_DISABLE_REGISTRY
- g_object_set (G_OBJECT (_user_registry), "location", arg, NULL);
- _gst_registry_fixed = TRUE;
+ g_object_set (G_OBJECT (_user_registry), "location", arg, NULL);
+ _gst_registry_fixed = TRUE;
#endif /* GST_DISABLE_REGISTRY */
+ break;
+ default:
+ g_warning ("option %d not recognized", option->val);
+ break;
+ }
break;
- default:
- g_warning ("option %d not recognized", option->val);
+ case POPT_CALLBACK_REASON_POST:
+ if (!init_post ())
+ _gst_initialization_failure = TRUE;
+ gst_initialized = TRUE;
break;
- }
- break;
- case POPT_CALLBACK_REASON_POST:
- if (!init_post ()) _gst_initialization_failure = TRUE;
- gst_initialized = TRUE;
- break;
}
}
g_error ("Quit more loops than there are");
else {
GMainLoop *loop = mainloops->data;
+
mainloops = g_slist_delete_link (mainloops, mainloops);
g_main_loop_quit (loop);
g_main_loop_unref (loop);
* Gets the version number of the GStreamer library.
*/
void
-gst_version (guint *major, guint *minor, guint *micro)
+gst_version (guint * major, guint * minor, guint * micro)
{
g_return_if_fail (major);
g_return_if_fail (minor);
#include <gst/gstcompat.h>
G_BEGIN_DECLS
-
/* make our own type for poptOption because the struct poptOption
* definition is iffy */
typedef struct poptOption GstPoptOption;
/* initialize GST */
-void gst_init (int *argc, char **argv[]);
-gboolean gst_init_check (int *argc, char **argv[]);
-void gst_init_with_popt_table (int *argc, char **argv[],
- const GstPoptOption
- *popt_options);
-gboolean gst_init_check_with_popt_table (int *argc, char **argv[],
- const GstPoptOption
- *popt_options);
+void gst_init (int *argc, char **argv[]);
+gboolean gst_init_check (int *argc, char **argv[]);
+void gst_init_with_popt_table (int *argc, char **argv[],
+ const GstPoptOption * popt_options);
+gboolean gst_init_check_with_popt_table (int *argc, char **argv[],
+ const GstPoptOption * popt_options);
-const GstPoptOption * gst_init_get_popt_table (void);
+const GstPoptOption *gst_init_get_popt_table (void);
-void gst_use_threads (gboolean use_threads);
-gboolean gst_has_threads (void);
+void gst_use_threads (gboolean use_threads);
+gboolean gst_has_threads (void);
-void gst_main (void);
-void gst_main_quit (void);
+void gst_main (void);
+void gst_main_quit (void);
G_END_DECLS
-
#include <gst/gstlog.h>
-
#endif /* __GST_H__ */
#define GST_ARCH_SET_SP(stackpointer) \
__asm__("lwz r1,%0" : : "m"(stackpointer))
-
+
#define GST_ARCH_CALL(target) \
__asm__( "mr r0,%0\n\t" \
"mtlr r0\n\t" \
"blrl" : : "r"(target) );
-
-struct minimal_ppc_stackframe {
- unsigned long back_chain;
- unsigned long LR_save;
- unsigned long unused1;
- unsigned long unused2;
+
+struct minimal_ppc_stackframe
+{
+ unsigned long back_chain;
+ unsigned long LR_save;
+ unsigned long unused1;
+ unsigned long unused2;
};
#define GST_ARCH_SETUP_STACK(sp) \
/* Need to get more information about the stackframe format
* and get the fields more correct. Check GDB sources maybe?
*/
-struct minimal_stackframe {
- unsigned long back_chain;
- unsigned long LR_save;
- unsigned long unused1;
- unsigned long unused2;
+struct minimal_stackframe
+{
+ unsigned long back_chain;
+ unsigned long LR_save;
+ unsigned long unused1;
+ unsigned long unused2;
};
#define GST_ARCH_SETUP_STACK(sp) \
/* assuming the stackframe is 16 bytes */
#define GST_ARCH_SETUP_STACK(sp) sp -= 4
-
+
/***** HP-PA *****/
#define GST_ARCH_CALL(target) \
__asm__( "basr 14,%0" : : "a"(target) );
-struct minimal_s390_stackframe {
- unsigned long back_chain;
- unsigned long reserved;
- unsigned long greg[14];
- double freg[4];
+struct minimal_s390_stackframe
+{
+ unsigned long back_chain;
+ unsigned long reserved;
+ unsigned long greg[14];
+ double freg[4];
};
#define GST_ARCH_SETUP_STACK(sp) \
#include "gstatomic.h"
#include "gstatomic_impl.h"
-
#include <glib.h>
-G_BEGIN_DECLS
-
-typedef volatile gint gst_vgint; /* gtk-doc volatile workaround */
+G_BEGIN_DECLS typedef volatile gint gst_vgint; /* gtk-doc volatile workaround */
typedef struct _GstAtomicInt GstAtomicInt;
-struct _GstAtomicInt {
- gst_vgint counter;
- GMutex *lock; /* for C fallback */
+struct _GstAtomicInt
+{
+ gst_vgint counter;
+ GMutex *lock; /* for C fallback */
};
-void gst_atomic_int_init (GstAtomicInt *aint, gint val);
-void gst_atomic_int_destroy (GstAtomicInt *aint);
-void gst_atomic_int_set (GstAtomicInt *aint, gint val);
-gint gst_atomic_int_read (GstAtomicInt *aint);
-void gst_atomic_int_add (GstAtomicInt *aint, gint val);
-void gst_atomic_int_inc (GstAtomicInt *aint);
-gboolean gst_atomic_int_dec_and_test (GstAtomicInt *aint);
+void gst_atomic_int_init (GstAtomicInt * aint, gint val);
+void gst_atomic_int_destroy (GstAtomicInt * aint);
+void gst_atomic_int_set (GstAtomicInt * aint, gint val);
+gint gst_atomic_int_read (GstAtomicInt * aint);
+void gst_atomic_int_add (GstAtomicInt * aint, gint val);
+void gst_atomic_int_inc (GstAtomicInt * aint);
+gboolean gst_atomic_int_dec_and_test (GstAtomicInt * aint);
G_END_DECLS
-
#endif /* __GST_ATOMIC_H__ */
#include "gstmacros.h"
G_BEGIN_DECLS
-
#if defined (GST_CAN_INLINE) || defined (__GST_ATOMIC_C__)
-
/***** Intel x86 *****/
#if defined (HAVE_CPU_I386) && defined(__GNUC__)
-
#ifdef GST_CONFIG_NO_SMP
#define SMP_LOCK ""
#else
#define SMP_LOCK "lock ; "
#endif
+ GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
-
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
- __asm__ __volatile__(
- SMP_LOCK "addl %1,%0"
- :"=m" (aint->counter)
+ __asm__ __volatile__ (SMP_LOCK "addl %1,%0":"=m" (aint->counter)
:"ir" (val), "m" (aint->counter));
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
- __asm__ __volatile__(
- SMP_LOCK "incl %0"
- :"=m" (aint->counter)
+ __asm__ __volatile__ (SMP_LOCK "incl %0":"=m" (aint->counter)
:"m" (aint->counter));
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
guchar res;
- __asm__ __volatile__(
- SMP_LOCK "decl %0; sete %1"
- :"=m" (aint->counter), "=qm" (res)
- :"m" (aint->counter) : "memory");
+ __asm__ __volatile__ (SMP_LOCK "decl %0; sete %1":"=m" (aint->counter),
+ "=qm" (res)
+ :"m" (aint->counter):"memory");
return res != 0;
}
/***** PowerPC *****/
#elif defined (HAVE_CPU_PPC) && defined(__GNUC__)
-
#ifdef GST_CONFIG_NO_SMP
#define SMP_SYNC ""
#define SMP_ISYNC
#define SMP_SYNC "\tsync\n"
#define SMP_ISYNC "\tisync\n"
#endif
-
/* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx.
* The old ATOMIC_SYNC_FIX covered some but not all of this.
*/
#else
#define PPC405_ERR77(ra,rb)
#endif
+ GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
-
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
int t;
- __asm__ __volatile__(
- "1: lwarx %0,0,%3\n"
- " add %0,%2,%0\n"
- PPC405_ERR77(0,%3)
- " stwcx. %0,0,%3 \n"
- " bne- 1b\n"
- : "=&r" (t), "=m" (aint->counter)
- : "r" (val), "r" (&aint->counter), "m" (aint->counter)
- : "cc");
+ __asm__ __volatile__ ("1: lwarx %0,0,%3\n"
+ " add %0,%2,%0\n" PPC405_ERR77 (0, %3)
+ " stwcx. %0,0,%3 \n"
+ " bne- 1b\n":"=&r" (t), "=m" (aint->counter)
+ :"r" (val), "r" (&aint->counter), "m" (aint->counter)
+ :"cc");
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
int t;
- __asm__ __volatile__(
- "1: lwarx %0,0,%2\n"
- " addic %0,%0,1\n"
- PPC405_ERR77(0,%2)
- " stwcx. %0,0,%2\n"
- " bne- 1b\n"
- : "=&r" (t), "=m" (aint->counter)
- : "r" (&aint->counter), "m" (aint->counter)
- : "cc");
+ __asm__ __volatile__ ("1: lwarx %0,0,%2\n"
+ " addic %0,%0,1\n" PPC405_ERR77 (0, %2)
+ " stwcx. %0,0,%2\n"
+ " bne- 1b\n":"=&r" (t), "=m" (aint->counter)
+ :"r" (&aint->counter), "m" (aint->counter)
+ :"cc");
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
int t;
- __asm__ __volatile__(
- "1: lwarx %0,0,%1\n"
- " addic %0,%0,-1\n"
- PPC405_ERR77(0,%1)
- " stwcx. %0,0,%1\n"
- " bne- 1b\n"
- SMP_ISYNC
- : "=&r" (t)
- : "r" (&aint->counter)
- : "cc", "memory");
+ __asm__ __volatile__ ("1: lwarx %0,0,%1\n"
+ " addic %0,%0,-1\n" PPC405_ERR77 (0, %1)
+ " stwcx. %0,0,%1\n" " bne- 1b\n" SMP_ISYNC:"=&r" (t)
+ :"r" (&aint->counter)
+ :"cc", "memory");
return t == 0;
}
/***** DEC[/Compaq/HP?/Intel?] Alpha *****/
#elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__)
+ GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
-
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
unsigned long temp;
- __asm__ __volatile__(
- "1: ldl_l %0,%1\n"
- " addl %0,%2,%0\n"
- " stl_c %0,%1\n"
- " beq %0,2f\n"
- ".subsection 2\n"
- "2: br 1b\n"
- ".previous"
- :"=&r" (temp), "=m" (aint->counter)
+ __asm__ __volatile__ ("1: ldl_l %0,%1\n"
+ " addl %0,%2,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ ".subsection 2\n"
+ "2: br 1b\n" ".previous":"=&r" (temp), "=m" (aint->counter)
:"Ir" (val), "m" (aint->counter));
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
gst_atomic_int_add (aint, 1);
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
long temp, result;
int val = 1;
- __asm__ __volatile__(
- "1: ldl_l %0,%1\n"
- " subl %0,%3,%2\n"
- " subl %0,%3,%0\n"
- " stl_c %0,%1\n"
- " beq %0,2f\n"
- " mb\n"
- ".subsection 2\n"
- "2: br 1b\n"
- ".previous"
- :"=&r" (temp), "=m" (aint->counter), "=&r" (result)
- :"Ir" (val), "m" (aint->counter) : "memory");
+ __asm__ __volatile__ ("1: ldl_l %0,%1\n"
+ " subl %0,%3,%2\n"
+ " subl %0,%3,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ " mb\n"
+ ".subsection 2\n"
+ "2: br 1b\n"
+ ".previous":"=&r" (temp), "=m" (aint->counter), "=&r" (result)
+ :"Ir" (val), "m" (aint->counter):"memory");
return result == 0;
}
/***** Sun SPARC *****/
#elif 0 && defined(HAVE_CPU_SPARC) && defined(__GNUC__)
/* allegedly broken again */
-
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
+ GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
#ifdef GST_CONFIG_NO_SMP
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
+GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
#else
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); }
+GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = (val << 8);
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = (val << 8);
+}
/*
* For SMP the trick is you embed the spin lock byte within
* 31 8 7 0
*/
GST_INLINE_FUNC gint
-gst_atomic_int_read (GstAtomicInt *aint)
-{
+gst_atomic_int_read (GstAtomicInt * aint)
+{
int ret = aint->counter;
while (ret & 0xff)
}
#endif /* GST_CONFIG_NO_SMP */
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
volatile int increment, *ptr;
int lock = 1;
ptr = &(aint->counter);
#if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2)
- __asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n"
- "\torcc %[lock], 0, %[ignore]\n"
- "\tbne 1b\n" /* go back until we have the lock */
- "\tld [%[ptr]], %[inc]\n"
- "\tsra %[inc], 8, %[inc]\n"
- "\tadd %[inc], %[val], %[inc]\n"
- "\tsll %[inc], 8, %[lock]\n"
- "\tst %[lock],[%[ptr]]\n" /* Release the lock */
- : [inc] "=&r" (increment), [lock] "=r" (lock),
- [ignore] "=&r" (ignore)
- : "0" (increment), [ptr] "r" (ptr), [val] "r" (val)
- );
+ __asm__ __volatile__ ("1: ldstub [%[ptr] + 3], %[lock]\n" "\torcc %[lock], 0, %[ignore]\n" "\tbne 1b\n" /* go back until we have the lock */
+ "\tld [%[ptr]], %[inc]\n" "\tsra %[inc], 8, %[inc]\n" "\tadd %[inc], %[val], %[inc]\n" "\tsll %[inc], 8, %[lock]\n" "\tst %[lock],[%[ptr]]\n" /* Release the lock */
+ :[inc] "=&r" (increment),[lock] "=r" (lock),[ignore] "=&r" (ignore)
+ :"0" (increment),[ptr] "r" (ptr),[val] "r" (val)
+ );
#else
- __asm__ __volatile__("1: ldstub [%4 + 3], %1\n"
- "\torcc %1, 0, %2\n"
- "\tbne 1b\n" /* go back until we have the lock */
- "\tld [%4], %0\n"
- "\tsra %0, 8, %0\n"
- "\tadd %0, %5, %0\n"
- "\tsll %0, 8, %1\n"
- "\tst %1,[%4]\n" /* Release the lock */
- : "=&r" (increment), "=r" (lock), "=&r" (ignore)
- : "0" (increment), "r" (ptr), "r" (val)
- );
+ __asm__ __volatile__ ("1: ldstub [%4 + 3], %1\n" "\torcc %1, 0, %2\n" "\tbne 1b\n" /* go back until we have the lock */
+ "\tld [%4], %0\n" "\tsra %0, 8, %0\n" "\tadd %0, %5, %0\n" "\tsll %0, 8, %1\n" "\tst %1,[%4]\n" /* Release the lock */
+ :"=&r" (increment), "=r" (lock), "=&r" (ignore)
+ :"0" (increment), "r" (ptr), "r" (val)
+ );
#endif
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
gst_atomic_int_add (aint, 1);
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
volatile int increment, *ptr;
int lock = 1;
ptr = &aint->counter;
#if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2)
- __asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n"
- "\torcc %[lock], 0, %[ignore]\n"
- "\tbne 1b\n" /* go back until we have the lock */
- "\tld [%[ptr]], %[inc]\n"
- "\tsra %[inc], 8, %[inc]\n"
- "\tsub %[inc], 1, %[inc]\n"
- "\tsll %[inc], 8, %[lock]\n"
- "\tst %[lock],[%[ptr]]\n" /* Release the lock */
- : [inc] "=&r" (increment), [lock] "=r" (lock),
- [ignore] "=&r" (ignore)
- : "0" (increment), [ptr] "r" (ptr)
- );
+ __asm__ __volatile__ ("1: ldstub [%[ptr] + 3], %[lock]\n" "\torcc %[lock], 0, %[ignore]\n" "\tbne 1b\n" /* go back until we have the lock */
+ "\tld [%[ptr]], %[inc]\n" "\tsra %[inc], 8, %[inc]\n" "\tsub %[inc], 1, %[inc]\n" "\tsll %[inc], 8, %[lock]\n" "\tst %[lock],[%[ptr]]\n" /* Release the lock */
+ :[inc] "=&r" (increment),[lock] "=r" (lock),[ignore] "=&r" (ignore)
+ :"0" (increment),[ptr] "r" (ptr)
+ );
#else
- __asm__ __volatile__("1: ldstub [%4 + 3], %1\n"
- "\torcc %1, 0, %2\n"
- "\tbne 1b\n" /* go back until we have the lock */
- "\tld [%4], %0\n"
- "\tsra %0, 8, %0\n"
- "\tsub %0, 1, %0\n"
- "\tsll %0, 8, %1\n"
- "\tst %1,[%4]\n" /* Release the lock */
- : "=&r" (increment), "=r" (lock), "=&r" (ignore)
- : "0" (increment), "r" (ptr)
- );
+ __asm__ __volatile__ ("1: ldstub [%4 + 3], %1\n" "\torcc %1, 0, %2\n" "\tbne 1b\n" /* go back until we have the lock */
+ "\tld [%4], %0\n" "\tsra %0, 8, %0\n" "\tsub %0, 1, %0\n" "\tsll %0, 8, %1\n" "\tst %1,[%4]\n" /* Release the lock */
+ :"=&r" (increment), "=r" (lock), "=&r" (ignore)
+ :"0" (increment), "r" (ptr)
+ );
#endif
return increment == 0;
/* This is disabled because the asm code is broken on most MIPS
* processors and doesn't generally compile. */
#elif defined(HAVE_CPU_MIPS) && defined(__GNUC__) && 0
-
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
+ GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
/* this only works on MIPS II and better */
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
unsigned long temp;
- __asm__ __volatile__(
- "1: ll %0, %1 # atomic_add\n"
- " addu %0, %2 \n"
- " sc %0, %1 \n"
- " beqz %0, 1b \n"
- : "=&r" (temp), "=m" (aint->counter)
- : "Ir" (val), "m" (aint->counter));
+ __asm__ __volatile__ ("1: ll %0, %1 # atomic_add\n"
+ " addu %0, %2 \n"
+ " sc %0, %1 \n"
+ " beqz %0, 1b \n":"=&r" (temp),
+ "=m" (aint->counter)
+ :"Ir" (val), "m" (aint->counter));
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
gst_atomic_int_add (aint, 1);
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
unsigned long temp, result;
int val = 1;
- __asm__ __volatile__(
- ".set push \n"
- ".set noreorder # atomic_sub_return\n"
- "1: ll %1, %2 \n"
- " subu %0, %1, %3 \n"
- " sc %0, %2 \n"
- " beqz %0, 1b \n"
- " subu %0, %1, %3 \n"
- ".set pop \n"
- : "=&r" (result), "=&r" (temp), "=m" (aint->counter)
- : "Ir" (val), "m" (aint->counter)
- : "memory");
+ __asm__ __volatile__ (".set push \n"
+ ".set noreorder # atomic_sub_return\n"
+ "1: ll %1, %2 \n"
+ " subu %0, %1, %3 \n"
+ " sc %0, %2 \n"
+ " beqz %0, 1b \n"
+ " subu %0, %1, %3 \n"
+ ".set pop \n":"=&r" (result),
+ "=&r" (temp), "=m" (aint->counter)
+ :"Ir" (val), "m" (aint->counter)
+ :"memory");
return result == 0;
}
/***** S/390 *****/
#elif defined(HAVE_CPU_S390) && defined(__GNUC__)
-typedef struct { volatile int counter; } atomic_t __attribute__ ((aligned (4)));
+ typedef struct
+{
+ volatile int counter;
+} atomic_t __attribute__ ((aligned (4)));
-GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
-GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
-GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
+GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC void
+gst_atomic_int_destroy (GstAtomicInt * aint)
+{
+}
+GST_INLINE_FUNC void
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
+{
+ aint->counter = val;
+}
+GST_INLINE_FUNC gint
+gst_atomic_int_read (GstAtomicInt * aint)
+{
+ return aint->counter;
+}
#define __CS_LOOP(old_val, new_val, ptr, op_val, op_string) \
__asm__ __volatile__(" l %0,0(%3)\n" \
"+m" (((atomic_t *)(ptr))->counter) \
: "a" (ptr), "d" (op_val) : "cc" );
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
int old_val, new_val;
- __CS_LOOP(old_val, new_val, aint, val, "ar");
+
+ __CS_LOOP (old_val, new_val, aint, val, "ar");
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
int old_val, new_val;
- __CS_LOOP(old_val, new_val, aint, 1, "ar");
+
+ __CS_LOOP (old_val, new_val, aint, 1, "ar");
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
int old_val, new_val;
- __CS_LOOP(old_val, new_val, aint, 1, "sr");
+
+ __CS_LOOP (old_val, new_val, aint, 1, "sr");
return new_val == 0;
}
-#else
+#else
#warning consider putting your architecture specific atomic implementations here
-
/*
* generic implementation
*/
-GST_INLINE_FUNC void
-gst_atomic_int_init (GstAtomicInt *aint, gint val)
+ GST_INLINE_FUNC void
+gst_atomic_int_init (GstAtomicInt * aint, gint val)
{
aint->counter = val;
aint->lock = g_mutex_new ();
}
GST_INLINE_FUNC void
-gst_atomic_int_destroy (GstAtomicInt *aint)
+gst_atomic_int_destroy (GstAtomicInt * aint)
{
g_mutex_free (aint->lock);
}
GST_INLINE_FUNC void
-gst_atomic_int_set (GstAtomicInt *aint, gint val)
+gst_atomic_int_set (GstAtomicInt * aint, gint val)
{
g_mutex_lock (aint->lock);
aint->counter = val;
}
GST_INLINE_FUNC gint
-gst_atomic_int_read (GstAtomicInt *aint)
+gst_atomic_int_read (GstAtomicInt * aint)
{
gint res;
return res;
}
-GST_INLINE_FUNC void
-gst_atomic_int_add (GstAtomicInt *aint, gint val)
+GST_INLINE_FUNC void
+gst_atomic_int_add (GstAtomicInt * aint, gint val)
{
g_mutex_lock (aint->lock);
aint->counter += val;
}
GST_INLINE_FUNC void
-gst_atomic_int_inc (GstAtomicInt *aint)
+gst_atomic_int_inc (GstAtomicInt * aint)
{
g_mutex_lock (aint->lock);
aint->counter++;
}
GST_INLINE_FUNC gboolean
-gst_atomic_int_dec_and_test (GstAtomicInt *aint)
+gst_atomic_int_dec_and_test (GstAtomicInt * aint)
{
gboolean res;
-
+
g_mutex_lock (aint->lock);
aint->counter--;
res = (aint->counter == 0);
return res;
}
-#endif
+#endif
/*
* common functions
- */
-GST_INLINE_FUNC GstAtomicInt*
+ */
+GST_INLINE_FUNC GstAtomicInt *
gst_atomic_int_new (gint val)
{
GstAtomicInt *aint;
}
GST_INLINE_FUNC void
-gst_atomic_int_free (GstAtomicInt *aint)
+gst_atomic_int_free (GstAtomicInt * aint)
{
gst_atomic_int_destroy (aint);
g_free (aint);
}
-#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)*/
+#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) */
G_END_DECLS
-
#endif /* __GST_ATOMIC_IMPL_H__ */
#include "gstscheduler.h"
#include "gstindex.h"
-static GstElementDetails gst_bin_details = GST_ELEMENT_DETAILS (
- "Generic bin",
- "Generic/Bin",
- "Simple container object",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_bin_details = GST_ELEMENT_DETAILS ("Generic bin",
+ "Generic/Bin",
+ "Simple container object",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
GType _gst_bin_type = 0;
-static gboolean _gst_boolean_did_something_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu, const GValue *handler_return, gpointer dummy);
+static gboolean _gst_boolean_did_something_accumulator (GSignalInvocationHint *
+ ihint, GValue * return_accu, const GValue * handler_return, gpointer dummy);
-static void gst_bin_dispose (GObject * object);
+static void gst_bin_dispose (GObject * object);
-static GstElementStateReturn gst_bin_change_state (GstElement *element);
-static GstElementStateReturn gst_bin_change_state_norecurse (GstBin *bin);
+static GstElementStateReturn gst_bin_change_state (GstElement * element);
+static GstElementStateReturn gst_bin_change_state_norecurse (GstBin * bin);
#ifndef GST_DISABLE_INDEX
-static void gst_bin_set_index (GstElement *element, GstIndex *index);
+static void gst_bin_set_index (GstElement * element, GstIndex * index);
#endif
-static void gst_bin_add_func (GstBin *bin, GstElement *element);
-static void gst_bin_remove_func (GstBin *bin, GstElement *element);
-static void gst_bin_child_state_change_func (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *child);
+static void gst_bin_add_func (GstBin * bin, GstElement * element);
+static void gst_bin_remove_func (GstBin * bin, GstElement * element);
+static void gst_bin_child_state_change_func (GstBin * bin,
+ GstElementState oldstate, GstElementState newstate, GstElement * child);
-static GstClock* gst_bin_get_clock_func (GstElement *element);
-static void gst_bin_set_clock_func (GstElement *element, GstClock *clock);
+static GstClock *gst_bin_get_clock_func (GstElement * element);
+static void gst_bin_set_clock_func (GstElement * element, GstClock * clock);
-static gboolean gst_bin_iterate_func (GstBin *bin);
+static gboolean gst_bin_iterate_func (GstBin * bin);
#ifndef GST_DISABLE_LOADSAVE
-static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent);
-static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self);
+static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent);
+static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self);
#endif
/* Bin signals and args */
enum
{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_bin_base_init (gpointer g_class);
-static void gst_bin_class_init (GstBinClass * klass);
-static void gst_bin_init (GstBin * bin);
+static void gst_bin_base_init (gpointer g_class);
+static void gst_bin_class_init (GstBinClass * klass);
+static void gst_bin_init (GstBin * bin);
static GstElementClass *parent_class = NULL;
static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
NULL
};
- _gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
+ _gst_bin_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
}
return _gst_bin_type;
}
gst_bin_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_bin_details);
}
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_bin_signals[ELEMENT_ADDED] =
- g_signal_new ("element-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstBinClass, element_added), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
+ g_signal_new ("element-added", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstBinClass, element_added), NULL,
+ NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
gst_bin_signals[ELEMENT_REMOVED] =
- g_signal_new ("element-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstBinClass, element_removed), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
+ g_signal_new ("element-removed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstBinClass, element_removed), NULL,
+ NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT);
gst_bin_signals[ITERATE] =
- g_signal_new ("iterate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstBinClass, iterate),
- _gst_boolean_did_something_accumulator, NULL,
- gst_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0);
+ g_signal_new ("iterate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstBinClass, iterate),
+ _gst_boolean_did_something_accumulator, NULL, gst_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose);
#ifndef GST_DISABLE_LOADSAVE
- gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself);
- gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_bin_restore_thyself);
+ gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself);
+ gstobject_class->restore_thyself =
+ GST_DEBUG_FUNCPTR (gst_bin_restore_thyself);
#endif
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state);
#ifndef GST_DISABLE_INDEX
- gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_bin_set_index);
+ gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_bin_set_index);
#endif
- klass->add_element = GST_DEBUG_FUNCPTR (gst_bin_add_func);
- klass->remove_element = GST_DEBUG_FUNCPTR (gst_bin_remove_func);
- klass->child_state_change = GST_DEBUG_FUNCPTR (gst_bin_child_state_change_func);
- klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
+ klass->add_element = GST_DEBUG_FUNCPTR (gst_bin_add_func);
+ klass->remove_element = GST_DEBUG_FUNCPTR (gst_bin_remove_func);
+ klass->child_state_change =
+ GST_DEBUG_FUNCPTR (gst_bin_child_state_change_func);
+ klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
}
static gboolean
-_gst_boolean_did_something_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu, const GValue *handler_return, gpointer dummy)
+_gst_boolean_did_something_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gboolean did_something;
return gst_element_factory_make ("bin", name);
}
-static GstClock*
-gst_bin_get_clock_func (GstElement *element)
+static GstClock *
+gst_bin_get_clock_func (GstElement * element)
{
- if (GST_ELEMENT_SCHED (element))
+ if (GST_ELEMENT_SCHED (element))
return gst_scheduler_get_clock (GST_ELEMENT_SCHED (element));
return NULL;
}
static void
-gst_bin_set_clock_func (GstElement *element, GstClock *clock)
+gst_bin_set_clock_func (GstElement * element, GstClock * clock)
{
- if (GST_ELEMENT_SCHED (element))
+ if (GST_ELEMENT_SCHED (element))
gst_scheduler_use_clock (GST_ELEMENT_SCHED (element), clock);
}
*
* Returns: the #GstClock of the bin
*/
-GstClock*
-gst_bin_get_clock (GstBin *bin)
+GstClock *
+gst_bin_get_clock (GstBin * bin)
{
g_return_val_if_fail (bin != NULL, NULL);
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
* force it to use no clock at all.
*/
void
-gst_bin_use_clock (GstBin *bin, GstClock *clock)
+gst_bin_use_clock (GstBin * bin, GstClock * clock)
{
g_return_if_fail (GST_IS_BIN (bin));
* Let the bin select a clock automatically.
*/
void
-gst_bin_auto_clock (GstBin *bin)
+gst_bin_auto_clock (GstBin * bin)
{
g_return_if_fail (GST_IS_BIN (bin));
- if (GST_ELEMENT_SCHED (bin))
+ if (GST_ELEMENT_SCHED (bin))
gst_scheduler_auto_clock (GST_ELEMENT_SCHED (bin));
}
#ifndef GST_DISABLE_INDEX
static void
-gst_bin_set_index (GstElement *element, GstIndex *index)
+gst_bin_set_index (GstElement * element, GstIndex * index)
{
GstBin *bin = GST_BIN (element);
-
+
g_return_if_fail (GST_IS_BIN (bin));
g_list_foreach (bin->children, (GFunc) gst_element_set_index, index);
#endif
static void
-gst_bin_set_element_sched (GstElement *element, GstScheduler *sched)
+gst_bin_set_element_sched (GstElement * element, GstScheduler * sched)
{
GST_CAT_LOG (GST_CAT_SCHEDULING, "setting element \"%s\" sched to %p",
- GST_ELEMENT_NAME (element), sched);
+ GST_ELEMENT_NAME (element), sched);
/* if it's actually a Bin */
if (GST_IS_BIN (element)) {
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
- "child is already a manager, not resetting sched");
+ "child is already a manager, not resetting sched");
if (GST_ELEMENT_SCHED (element))
- gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element));
+ gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element));
return;
}
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
- "setting child bin's scheduler to be the same as the parent's");
+ "setting child bin's scheduler to be the same as the parent's");
gst_scheduler_add_element (sched, element);
/* set the children's schedule */
- g_list_foreach (GST_BIN (element)->children, (GFunc) gst_bin_set_element_sched, sched);
+ g_list_foreach (GST_BIN (element)->children,
+ (GFunc) gst_bin_set_element_sched, sched);
}
/* otherwise, if it's just a regular old element */
else {
/* we only operate on real pads */
if (!GST_IS_REAL_PAD (pad))
- continue;
+ continue;
/* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) {
- if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
- GST_CAT_LOG (GST_CAT_SCHEDULING,
- "peer is in same scheduler, telling scheduler");
-
- if (GST_PAD_IS_SRC (pad))
- gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad));
- else
- gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad);
- }
+ if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
+ GST_CAT_LOG (GST_CAT_SCHEDULING,
+ "peer is in same scheduler, telling scheduler");
+
+ if (GST_PAD_IS_SRC (pad))
+ gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad));
+ else
+ gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad);
+ }
}
}
}
static void
-gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched)
+gst_bin_unset_element_sched (GstElement * element, GstScheduler * sched)
{
if (GST_ELEMENT_SCHED (element) == NULL) {
GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
return;
}
- GST_CAT_DEBUG (GST_CAT_SCHEDULING, "removing element \"%s\" from its sched %p",
- GST_ELEMENT_NAME (element), GST_ELEMENT_SCHED (element));
+ GST_CAT_DEBUG (GST_CAT_SCHEDULING,
+ "removing element \"%s\" from its sched %p", GST_ELEMENT_NAME (element),
+ GST_ELEMENT_SCHED (element));
/* if it's actually a Bin */
if (GST_IS_BIN (element)) {
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
- "child is already a manager, not unsetting sched");
+ "child is already a manager, not unsetting sched");
if (sched) {
- gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element));
+ gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element));
}
return;
}
/* for each child, remove them from their schedule */
- g_list_foreach (GST_BIN (element)->children, (GFunc) gst_bin_unset_element_sched, sched);
+ g_list_foreach (GST_BIN (element)->children,
+ (GFunc) gst_bin_unset_element_sched, sched);
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
}
/* we only operate on real pads */
if (!GST_IS_REAL_PAD (pad))
- continue;
+ continue;
/* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) {
- if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
- GST_CAT_LOG (GST_CAT_SCHEDULING, "peer is in same scheduler, telling scheduler");
-
- if (GST_PAD_IS_SRC (pad))
- gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad));
- else
- gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad);
- }
+ if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
+ GST_CAT_LOG (GST_CAT_SCHEDULING,
+ "peer is in same scheduler, telling scheduler");
+
+ if (GST_PAD_IS_SRC (pad))
+ gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad));
+ else
+ gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad);
+ }
}
}
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
* Add a list of elements to a bin. Uses #gst_bin_add.
*/
void
-gst_bin_add_many (GstBin *bin, GstElement *element_1, ...)
+gst_bin_add_many (GstBin * bin, GstElement * element_1, ...)
{
va_list args;
while (element_1) {
gst_bin_add (bin, element_1);
-
- element_1 = va_arg (args, GstElement*);
+
+ element_1 = va_arg (args, GstElement *);
}
va_end (args);
}
static void
-gst_bin_add_func (GstBin *bin, GstElement *element)
+gst_bin_add_func (GstBin * bin, GstElement * element)
{
gint state_idx = 0;
GstElementState state;
g_return_if_fail (GST_ELEMENT_PARENT (element) == NULL);
/* then check to see if the element's name is already taken in the bin */
- if (gst_object_check_uniqueness (bin->children,
- GST_ELEMENT_NAME (element)) == FALSE)
- {
+ if (gst_object_check_uniqueness (bin->children,
+ GST_ELEMENT_NAME (element)) == FALSE) {
g_warning ("Name %s is not unique in bin %s, not adding\n",
- GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
+ GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
return;
}
/* bump our internal state counter */
state = GST_STATE (element);
- while (state >>= 1) state_idx++;
+ while (state >>= 1)
+ state_idx++;
bin->child_states[state_idx]++;
/* now we have to deal with manager stuff
gst_bin_set_element_sched (element, sched);
}
- GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "added element \"%s\"",
- GST_OBJECT_NAME (element));
+ GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "added element \"%s\"",
+ GST_OBJECT_NAME (element));
g_signal_emit (G_OBJECT (bin), gst_bin_signals[ELEMENT_ADDED], 0, element);
}
* add a reference.
*/
void
-gst_bin_add (GstBin *bin, GstElement *element)
+gst_bin_add (GstBin * bin, GstElement * element)
{
GstBinClass *bclass;
-
+
g_return_if_fail (GST_IS_BIN (bin));
g_return_if_fail (GST_IS_ELEMENT (element));
GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "adding element \"%s\"",
- GST_OBJECT_NAME (element));
+ GST_OBJECT_NAME (element));
bclass = GST_BIN_GET_CLASS (bin);
if (bclass->add_element) {
bclass->add_element (bin, element);
- }
- else {
+ } else {
GST_ELEMENT_ERROR (bin, CORE, FAILED, (NULL),
- ("cannot add element %s to bin %s",
- GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)));
+ ("cannot add element %s to bin %s",
+ GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)));
}
}
static void
-gst_bin_remove_func (GstBin *bin, GstElement *element)
+gst_bin_remove_func (GstBin * bin, GstElement * element)
{
gint state_idx = 0;
GstElementState state;
/* the element must be in the bin's list of children */
if (g_list_find (bin->children, element) == NULL) {
g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element),
- GST_ELEMENT_NAME (bin));
+ GST_ELEMENT_NAME (bin));
return;
}
/* bump our internal state counter */
state = GST_STATE (element);
- while (state >>= 1) state_idx++;
+ while (state >>= 1)
+ state_idx++;
bin->child_states[state_idx]--;
- GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "removed child \"%s\"",
- GST_OBJECT_NAME (element));
+ GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "removed child \"%s\"",
+ GST_OBJECT_NAME (element));
/* ref as we're going to emit a signal */
gst_object_ref (GST_OBJECT (element));
* #gst_object_ref before removing it from the bin.
*/
void
-gst_bin_remove (GstBin *bin, GstElement *element)
+gst_bin_remove (GstBin * bin, GstElement * element)
{
GstBinClass *bclass;
GST_CAT_DEBUG (GST_CAT_PARENTAGE, "[%s]: trying to remove child %s",
- GST_ELEMENT_NAME (bin), GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (bin), GST_ELEMENT_NAME (element));
g_return_if_fail (GST_IS_BIN (bin));
g_return_if_fail (GST_IS_ELEMENT (element));
if (bclass->remove_element) {
bclass->remove_element (bin, element);
- }
- else {
+ } else {
g_warning ("cannot remove elements from bin %s\n", GST_ELEMENT_NAME (bin));
}
}
* Remove a list of elements from a bin. Uses #gst_bin_remove.
*/
void
-gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...)
+gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...)
{
va_list args;
while (element_1) {
gst_bin_remove (bin, element_1);
-
- element_1 = va_arg (args, GstElement*);
+
+ element_1 = va_arg (args, GstElement *);
}
va_end (args);
* of a child.
*/
void
-gst_bin_child_state_change (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *child)
+gst_bin_child_state_change (GstBin * bin, GstElementState oldstate,
+ GstElementState newstate, GstElement * child)
{
GstBinClass *bclass;
-
+
g_return_if_fail (GST_IS_BIN (bin));
g_return_if_fail (GST_IS_ELEMENT (child));
GST_CAT_LOG (GST_CAT_STATES, "child %s changed state in bin %s from %s to %s",
- GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin),
- gst_element_state_get_name (oldstate),
- gst_element_state_get_name (newstate));
+ GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin),
+ gst_element_state_get_name (oldstate),
+ gst_element_state_get_name (newstate));
bclass = GST_BIN_GET_CLASS (bin);
if (bclass->child_state_change) {
bclass->child_state_change (bin, oldstate, newstate, child);
- }
- else {
- g_warning ("cannot signal state change of child %s to bin %s\n",
- GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin));
+ } else {
+ g_warning ("cannot signal state change of child %s to bin %s\n",
+ GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin));
}
}
static void
-gst_bin_child_state_change_func (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *child)
+gst_bin_child_state_change_func (GstBin * bin, GstElementState oldstate,
+ GstElementState newstate, GstElement * child)
{
gint old_idx = 0, new_idx = 0, i;
- while (oldstate >>= 1) old_idx++;
- while (newstate >>= 1) new_idx++;
+ while (oldstate >>= 1)
+ old_idx++;
+ while (newstate >>= 1)
+ new_idx++;
GST_LOCK (bin);
bin->child_states[old_idx]--;
bin->child_states[new_idx]++;
-
+
for (i = GST_NUM_STATES - 1; i >= 0; i--) {
if (bin->child_states[i] != 0) {
gint state = (1 << i);
+
if (GST_STATE (bin) != state) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
- "highest child state is %s, changing bin state accordingly",
- gst_element_state_get_name (state));
+ "highest child state is %s, changing bin state accordingly",
+ gst_element_state_get_name (state));
GST_STATE_PENDING (bin) = state;
- GST_UNLOCK (bin);
+ GST_UNLOCK (bin);
gst_bin_change_state_norecurse (bin);
if (state != GST_STATE (bin)) {
- g_warning ("%s: state change in callback %d %d",
- GST_ELEMENT_NAME (bin),
- state, GST_STATE (bin));
+ g_warning ("%s: state change in callback %d %d",
+ GST_ELEMENT_NAME (bin), state, GST_STATE (bin));
}
return;
}
transition = GST_STATE_TRANSITION (element);
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "changing state of children from %s to %s",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (pending));
+ "changing state of children from %s to %s",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (pending));
if (pending == GST_STATE_VOID_PENDING)
return GST_STATE_SUCCESS;
- if (old_state == pending)
- {
- GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
- "old and pending state are both %s, returning",
- gst_element_state_get_name (pending));
+ if (old_state == pending) {
+ GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
+ "old and pending state are both %s, returning",
+ gst_element_state_get_name (pending));
return GST_STATE_SUCCESS;
}
old_child_state = GST_STATE (child);
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "changing state of child %s from current %s to pending %s",
- GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state),
- gst_element_state_get_name (pending));
+ "changing state of child %s from current %s to pending %s",
+ GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state),
+ gst_element_state_get_name (pending));
switch (gst_element_set_state (child, pending)) {
case GST_STATE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
- "child '%s' failed to go to state %d(%s)",
- GST_ELEMENT_NAME (child),
- pending, gst_element_state_get_name (pending));
+ "child '%s' failed to go to state %d(%s)",
+ GST_ELEMENT_NAME (child),
+ pending, gst_element_state_get_name (pending));
gst_element_set_state (child, old_child_state);
/* There was a check for elements being in the same scheduling group
break;
case GST_STATE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
- "child '%s' is changing state asynchronously",
- GST_ELEMENT_NAME (child));
+ "child '%s' is changing state asynchronously",
+ GST_ELEMENT_NAME (child));
have_async = TRUE;
break;
case GST_STATE_SUCCESS:
- GST_CAT_DEBUG (GST_CAT_STATES, "child '%s' changed state to %d(%s) successfully",
- GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending));
- break;
+ GST_CAT_DEBUG (GST_CAT_STATES,
+ "child '%s' changed state to %d(%s) successfully",
+ GST_ELEMENT_NAME (child), pending,
+ gst_element_state_get_name (pending));
+ break;
}
}
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "done changing bin's state from %s to %s, now in %s",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (pending),
- gst_element_state_get_name (GST_STATE (element)));
+ "done changing bin's state from %s to %s, now in %s",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (pending),
+ gst_element_state_get_name (GST_STATE (element)));
if (have_async)
ret = GST_STATE_ASYNC;
else {
if (parent_class->change_state) {
- ret = parent_class->change_state(element);
- }
- else
+ ret = parent_class->change_state (element);
+ } else
ret = GST_STATE_SUCCESS;
}
return ret;
ret = parent_class->change_state (GST_ELEMENT (bin));
return ret;
- }
- else
+ } else
return GST_STATE_FAILURE;
}
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
g_return_val_if_fail (name != NULL, NULL);
- GST_CAT_INFO (GST_CAT_PARENTAGE, "[%s]: looking up child element %s",
- GST_ELEMENT_NAME (bin), name);
+ GST_CAT_INFO (GST_CAT_PARENTAGE, "[%s]: looking up child element %s",
+ GST_ELEMENT_NAME (bin), name);
children = bin->children;
while (children) {
* Returns: An element inside the bin implementing the interface.
*/
GstElement *
-gst_bin_get_by_interface (GstBin *bin, GType interface)
+gst_bin_get_by_interface (GstBin * bin, GType interface)
{
GList *walk;
-
+
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
return GST_ELEMENT (walk->data);
if (GST_IS_BIN (walk->data)) {
GstElement *ret;
+
ret = gst_bin_get_by_interface (GST_BIN (walk->data), interface);
if (ret)
return ret;
* Returns: An element inside the bin implementing the interface.
*/
GList *
-gst_bin_get_all_by_interface (GstBin *bin, GType interface)
+gst_bin_get_all_by_interface (GstBin * bin, GType interface)
{
GList *walk, *ret = NULL;
-
+
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
if (G_TYPE_CHECK_INSTANCE_TYPE (walk->data, interface))
ret = g_list_prepend (ret, walk->data);
if (GST_IS_BIN (walk->data)) {
- ret = g_list_concat (ret,
+ ret = g_list_concat (ret,
gst_bin_get_all_by_interface (GST_BIN (walk->data), interface));
}
walk = g_list_next (walk);
}
- return ret;
+ return ret;
}
/**
* this function returns #GST_STATE_FAILURE.
*/
GstElementStateReturn
-gst_bin_sync_children_state (GstBin *bin)
+gst_bin_sync_children_state (GstBin * bin)
{
GList *children;
GstElement *element;
state = GST_STATE (bin);
children = bin->children;
- GST_CAT_INFO (GST_CAT_STATES, "syncing state of children with bin \"%s\"'s state %s",
- GST_ELEMENT_NAME (bin), gst_element_state_get_name (state));
+ GST_CAT_INFO (GST_CAT_STATES,
+ "syncing state of children with bin \"%s\"'s state %s",
+ GST_ELEMENT_NAME (bin), gst_element_state_get_name (state));
while (children) {
element = GST_ELEMENT (children->data);
children = children->next;
- if (GST_STATE(element) != state) {
+ if (GST_STATE (element) != state) {
switch (gst_element_set_state (element, state)) {
- case GST_STATE_SUCCESS:
- break;
- case GST_STATE_ASYNC:
- if (ret == GST_STATE_SUCCESS)
- ret = GST_STATE_ASYNC;
- break;
- case GST_STATE_FAILURE:
- ret = GST_STATE_FAILURE;
- default:
- /* make sure gst_element_set_state never returns this */
- g_assert_not_reached ();
+ case GST_STATE_SUCCESS:
+ break;
+ case GST_STATE_ASYNC:
+ if (ret == GST_STATE_SUCCESS)
+ ret = GST_STATE_ASYNC;
+ break;
+ case GST_STATE_FAILURE:
+ ret = GST_STATE_FAILURE;
+ default:
+ /* make sure gst_element_set_state never returns this */
+ g_assert_not_reached ();
}
}
}
return ret;
}
+
#ifndef GST_DISABLE_LOADSAVE
static xmlNodePtr
gst_bin_save_thyself (GstObject * object, xmlNodePtr parent)
childlist = xmlNewChild (parent, NULL, "children", NULL);
- GST_CAT_INFO (GST_CAT_XML, "[%s]: saving %d children",
- GST_ELEMENT_NAME (bin), bin->numchildren);
+ GST_CAT_INFO (GST_CAT_XML, "[%s]: saving %d children",
+ GST_ELEMENT_NAME (bin), bin->numchildren);
children = bin->children;
while (children) {
while (field) {
if (!strcmp (field->name, "children")) {
- GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children", GST_ELEMENT_NAME (object));
+ GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children",
+ GST_ELEMENT_NAME (object));
childlist = field->xmlChildrenNode;
while (childlist) {
if (!strcmp (childlist->name, "element")) {
- GstElement *element = gst_xml_make_element (childlist, GST_OBJECT (bin));
-
- /* it had to be parented to find the pads, now we ref and unparent so
- * we can add it to the bin */
- gst_object_ref (GST_OBJECT (element));
- gst_object_unparent (GST_OBJECT (element));
-
+ GstElement *element =
+ gst_xml_make_element (childlist, GST_OBJECT (bin));
+
+ /* it had to be parented to find the pads, now we ref and unparent so
+ * we can add it to the bin */
+ gst_object_ref (GST_OBJECT (element));
+ gst_object_unparent (GST_OBJECT (element));
+
gst_bin_add (bin, element);
}
childlist = childlist->next;
if (state == GST_SCHEDULER_STATE_RUNNING) {
return TRUE;
- }
- else if (state == GST_SCHEDULER_STATE_ERROR) {
+ } else if (state == GST_SCHEDULER_STATE_ERROR) {
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
}
- }
- else {
- g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n",
- GST_ELEMENT_NAME (bin));
+ } else {
+ g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n",
+ GST_ELEMENT_NAME (bin));
}
return FALSE;
* can be used to determine it the bin is in EOS.
*/
gboolean
-gst_bin_iterate (GstBin *bin)
+gst_bin_iterate (GstBin * bin)
{
gboolean running;
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, bin, "finished iteration");
if (!running) {
- if (GST_STATE (bin) == GST_STATE_PLAYING &&
+ if (GST_STATE (bin) == GST_STATE_PLAYING &&
GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) {
- GST_CAT_DEBUG (GST_CAT_DATAFLOW, "[%s]: polling for child shutdown after useless iteration",
- GST_ELEMENT_NAME (bin));
+ GST_CAT_DEBUG (GST_CAT_DATAFLOW,
+ "[%s]: polling for child shutdown after useless iteration",
+ GST_ELEMENT_NAME (bin));
g_usleep (1);
running = TRUE;
}
#include <gst/gstelement.h>
-G_BEGIN_DECLS
-
-extern GType _gst_bin_type;
+G_BEGIN_DECLS extern GType _gst_bin_type;
#define GST_TYPE_BIN (_gst_bin_type)
#define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
#define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
#define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
-typedef void (*GstBinPrePostIterateFunction) (GstBin *bin, gpointer user_data);
+typedef void (*GstBinPrePostIterateFunction) (GstBin * bin, gpointer user_data);
-typedef enum {
+typedef enum
+{
/* this bin is a manager of child elements, i.e. a pipeline or thread */
- GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST,
+ GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST,
/* this bin iterates itself */
GST_BIN_SELF_SCHEDULABLE,
GST_BIN_FLAG_FIXED_CLOCK,
/* padding */
- GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5
+ GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5
} GstBinFlags;
/*typedef struct _GstBin GstBin; */
/*typedef struct _GstBinClass GstBinClass; */
-struct _GstBin {
- GstElement element;
+struct _GstBin
+{
+ GstElement element;
/* our children */
- gint numchildren;
- GList *children;
+ gint numchildren;
+ GList *children;
GstElementState child_states[GST_NUM_STATES];
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstBinClass {
+struct _GstBinClass
+{
GstElementClass parent_class;
/* vtable */
- void (*add_element) (GstBin *bin, GstElement *element);
- void (*remove_element) (GstBin *bin, GstElement *element);
- void (*child_state_change) (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *element);
+ void (*add_element) (GstBin * bin, GstElement * element);
+ void (*remove_element) (GstBin * bin, GstElement * element);
+ void (*child_state_change) (GstBin * bin, GstElementState oldstate,
+ GstElementState newstate, GstElement * element);
/* run a full iteration of operation */
- gboolean (*iterate) (GstBin *bin);
+ gboolean (*iterate) (GstBin * bin);
/* signals */
- void (*element_added) (GstBin *bin, GstElement *child);
- void (*element_removed) (GstBin *bin, GstElement *child);
+ void (*element_added) (GstBin * bin, GstElement * child);
+ void (*element_removed) (GstBin * bin, GstElement * child);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_bin_get_type (void);
-GstElement* gst_bin_new (const gchar *name);
+GType gst_bin_get_type (void);
+GstElement *gst_bin_new (const gchar * name);
/* add and remove elements from the bin */
-void gst_bin_add (GstBin *bin, GstElement *element);
-void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...);
-void gst_bin_remove (GstBin *bin, GstElement *element);
-void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...);
+void gst_bin_add (GstBin * bin, GstElement * element);
+void gst_bin_add_many (GstBin * bin, GstElement * element_1, ...);
+void gst_bin_remove (GstBin * bin, GstElement * element);
+void gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...);
/* retrieve a single element or the list of children */
-GstElement* gst_bin_get_by_name (GstBin *bin, const gchar *name);
-GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin, const gchar *name);
-G_CONST_RETURN GList*
- gst_bin_get_list (GstBin *bin);
-GstElement* gst_bin_get_by_interface (GstBin *bin, GType interface);
-GList * gst_bin_get_all_by_interface (GstBin *bin, GType interface);
+GstElement *gst_bin_get_by_name (GstBin * bin, const gchar * name);
+GstElement *gst_bin_get_by_name_recurse_up (GstBin * bin, const gchar * name);
+G_CONST_RETURN GList *gst_bin_get_list (GstBin * bin);
+GstElement *gst_bin_get_by_interface (GstBin * bin, GType interface);
+GList *gst_bin_get_all_by_interface (GstBin * bin, GType interface);
-gboolean gst_bin_iterate (GstBin *bin);
+gboolean gst_bin_iterate (GstBin * bin);
-void gst_bin_use_clock (GstBin *bin, GstClock *clock);
-GstClock* gst_bin_get_clock (GstBin *bin);
-void gst_bin_auto_clock (GstBin *bin);
+void gst_bin_use_clock (GstBin * bin, GstClock * clock);
+GstClock *gst_bin_get_clock (GstBin * bin);
+void gst_bin_auto_clock (GstBin * bin);
-GstElementStateReturn gst_bin_sync_children_state (GstBin *bin);
+GstElementStateReturn gst_bin_sync_children_state (GstBin * bin);
/* internal */
/* one of our childs signaled a state change */
-void gst_bin_child_state_change (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *child);
+void gst_bin_child_state_change (GstBin * bin, GstElementState oldstate,
+ GstElementState newstate, GstElement * child);
-void gst_bin_set_pre_iterate_function (GstBin *bin,
- GstBinPrePostIterateFunction func,
- gpointer user_data);
-void gst_bin_set_post_iterate_function (GstBin *bin,
- GstBinPrePostIterateFunction func,
- gpointer user_data);
+void gst_bin_set_pre_iterate_function (GstBin * bin,
+ GstBinPrePostIterateFunction func, gpointer user_data);
+void gst_bin_set_post_iterate_function (GstBin * bin,
+ GstBinPrePostIterateFunction func, gpointer user_data);
G_END_DECLS
-
-
#endif /* __GST_BIN_H__ */
_gst_buffer_initialize (void)
{
_gst_buffer_type = g_boxed_type_register_static ("GstBuffer",
- (GBoxedCopyFunc) gst_data_copy,
- (GBoxedFreeFunc) gst_data_unref);
+ (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref);
#ifndef GST_DISABLE_TRACE
_gst_buffer_trace = gst_alloc_trace_register (GST_BUFFER_TRACE_NAME);
#endif
- chunk = gst_mem_chunk_new ("GstBufferChunk", sizeof (GstBuffer),
- sizeof (GstBuffer) * 200, 0);
+ chunk = gst_mem_chunk_new ("GstBufferChunk", sizeof (GstBuffer),
+ sizeof (GstBuffer) * 200, 0);
GST_CAT_LOG (GST_CAT_BUFFER, "Buffers are initialized now");
}
}
static void
-_gst_buffer_sub_free (GstBuffer *buffer)
+_gst_buffer_sub_free (GstBuffer * buffer)
{
gst_data_unref (GST_DATA (buffer->buffer_private));
GST_BUFFER_SIZE (buffer) = 0;
_GST_DATA_DISPOSE (GST_DATA (buffer));
-
+
gst_mem_chunk_free (chunk, GST_DATA (buffer));
#ifndef GST_DISABLE_TRACE
gst_alloc_trace_free (_gst_buffer_trace, buffer);
* unless the GST_BUFFER_DONTFREE flags was set or the buffer data is NULL.
*/
void
-gst_buffer_default_free (GstBuffer *buffer)
+gst_buffer_default_free (GstBuffer * buffer)
{
g_return_if_fail (buffer != NULL);
/* free our data */
if (GST_BUFFER_FREE_DATA_FUNC (buffer)) {
GST_BUFFER_FREE_DATA_FUNC (buffer) (buffer);
- } else if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE)) {
+ } else if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE)) {
g_free (GST_BUFFER_DATA (buffer));
}
* the other.
*/
void
-gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src)
+gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src)
{
g_return_if_fail (dest != NULL);
g_return_if_fail (src != NULL);
-
- GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src);
- GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src);
- GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src);
- GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src);
+
+ GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src);
+ GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src);
+ GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src);
+ GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src);
}
+
/**
* gst_buffer_default_copy:
* @buffer: a #GstBuffer to make a copy of.
*
* Returns: the new #GstBuffer.
*/
-GstBuffer*
-gst_buffer_default_copy (GstBuffer *buffer)
+GstBuffer *
+gst_buffer_default_copy (GstBuffer * buffer)
{
GstBuffer *copy;
gst_alloc_trace_new (_gst_buffer_trace, copy);
#endif
- _GST_DATA_INIT (GST_DATA (copy),
- _gst_buffer_type,
- 0,
- (GstDataFreeFunction) gst_buffer_default_free,
- (GstDataCopyFunction) gst_buffer_default_copy);
+ _GST_DATA_INIT (GST_DATA (copy),
+ _gst_buffer_type,
+ 0,
+ (GstDataFreeFunction) gst_buffer_default_free,
+ (GstDataCopyFunction) gst_buffer_default_copy);
/* we simply copy everything from our parent */
- GST_BUFFER_DATA (copy) = g_memdup (GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
- GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
- GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_DATA (copy) = g_memdup (GST_BUFFER_DATA (buffer),
+ GST_BUFFER_SIZE (buffer));
+ GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
+ GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer);
gst_buffer_stamp (copy, buffer);
GST_BUFFER_FREE_DATA_FUNC (copy) = NULL;
*
* Returns: the new #GstBuffer.
*/
-GstBuffer*
+GstBuffer *
gst_buffer_new (void)
{
GstBuffer *newbuf;
-
+
newbuf = gst_mem_chunk_alloc (chunk);
#ifndef GST_DISABLE_TRACE
gst_alloc_trace_new (_gst_buffer_trace, newbuf);
GST_CAT_LOG (GST_CAT_BUFFER, "new %p", newbuf);
- _GST_DATA_INIT (GST_DATA (newbuf),
- _gst_buffer_type,
- 0,
- (GstDataFreeFunction) gst_buffer_default_free,
- (GstDataCopyFunction) gst_buffer_default_copy);
-
- GST_BUFFER_DATA (newbuf) = NULL;
- GST_BUFFER_SIZE (newbuf) = 0;
- GST_BUFFER_MAXSIZE (newbuf) = GST_BUFFER_MAXSIZE_NONE;
- GST_BUFFER_TIMESTAMP (newbuf) = GST_CLOCK_TIME_NONE;
- GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE;
- GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE;
- GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_NONE;
+ _GST_DATA_INIT (GST_DATA (newbuf),
+ _gst_buffer_type,
+ 0,
+ (GstDataFreeFunction) gst_buffer_default_free,
+ (GstDataCopyFunction) gst_buffer_default_copy);
+
+ GST_BUFFER_DATA (newbuf) = NULL;
+ GST_BUFFER_SIZE (newbuf) = 0;
+ GST_BUFFER_MAXSIZE (newbuf) = GST_BUFFER_MAXSIZE_NONE;
+ GST_BUFFER_TIMESTAMP (newbuf) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE;
+ GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_FREE_DATA_FUNC (newbuf) = NULL;
GST_BUFFER_PRIVATE (newbuf) = NULL;
*
* Returns: the new #GstBuffer.
*/
-GstBuffer*
+GstBuffer *
gst_buffer_new_and_alloc (guint size)
{
GstBuffer *newbuf;
newbuf = gst_buffer_new ();
- GST_BUFFER_DATA (newbuf) = g_malloc (size);
- GST_BUFFER_SIZE (newbuf) = size;
+ GST_BUFFER_DATA (newbuf) = g_malloc (size);
+ GST_BUFFER_SIZE (newbuf) = size;
GST_BUFFER_MAXSIZE (newbuf) = size;
return newbuf;
*
* Returns: the new #GstBuffer, or NULL if there was an error.
*/
-GstBuffer*
-gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size)
+GstBuffer *
+gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size)
{
GstBuffer *buffer;
gpointer buffer_data;
-
+
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (GST_BUFFER_REFCOUNT_VALUE (parent) > 0, NULL);
g_return_val_if_fail (size > 0, NULL);
/* make sure nobody overwrites data in the new buffer
* by setting the READONLY flag */
- _GST_DATA_INIT (GST_DATA (buffer),
- _gst_buffer_type,
- GST_DATA_FLAG_SHIFT (GST_BUFFER_SUBBUFFER) |
- GST_DATA_FLAG_SHIFT (GST_DATA_READONLY),
- (GstDataFreeFunction) _gst_buffer_sub_free,
- (GstDataCopyFunction) gst_buffer_default_copy);
+ _GST_DATA_INIT (GST_DATA (buffer),
+ _gst_buffer_type,
+ GST_DATA_FLAG_SHIFT (GST_BUFFER_SUBBUFFER) |
+ GST_DATA_FLAG_SHIFT (GST_DATA_READONLY),
+ (GstDataFreeFunction) _gst_buffer_sub_free,
+ (GstDataCopyFunction) gst_buffer_default_copy);
/* set the right values in the child */
- GST_BUFFER_DATA (buffer) = buffer_data;
- GST_BUFFER_SIZE (buffer) = size;
- GST_BUFFER_MAXSIZE (buffer) = size;
+ GST_BUFFER_DATA (buffer) = buffer_data;
+ GST_BUFFER_SIZE (buffer) = size;
+ GST_BUFFER_MAXSIZE (buffer) = size;
GST_BUFFER_FREE_DATA_FUNC (buffer) = NULL;
GST_BUFFER_PRIVATE (buffer) = parent;
/* we can copy the timestamp and offset if the new buffer starts at
* offset 0 */
if (offset == 0) {
- GST_BUFFER_TIMESTAMP (buffer) = GST_BUFFER_TIMESTAMP (parent);
- GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET (parent);
- }
- else {
- GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
- GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
+ GST_BUFFER_TIMESTAMP (buffer) = GST_BUFFER_TIMESTAMP (parent);
+ GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET (parent);
+ } else {
+ GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
}
- GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
- GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
+ GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
if (GST_BUFFER_FLAG_IS_SET (parent, GST_BUFFER_DONTKEEP)) {
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTKEEP);
*
* Returns: the new #GstBuffer that's the concatenation of the source buffers.
*/
-GstBuffer*
-gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2)
+GstBuffer *
+gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2)
{
GstBuffer *result;
* FALSE if a copy would be required.
*/
gboolean
-gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2)
+gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2)
{
g_return_val_if_fail (buf1 != NULL && buf2 != NULL, FALSE);
g_return_val_if_fail (GST_BUFFER_REFCOUNT_VALUE (buf1) > 0, FALSE);
/* it's only fast if we have subbuffers of the same parent */
return ((GST_BUFFER_FLAG_IS_SET (buf1, GST_BUFFER_SUBBUFFER)) &&
- (GST_BUFFER_FLAG_IS_SET (buf2, GST_BUFFER_SUBBUFFER)) &&
- (buf1->buffer_private == buf2->buffer_private) &&
- ((buf1->data + buf1->size) == buf2->data));
+ (GST_BUFFER_FLAG_IS_SET (buf2, GST_BUFFER_SUBBUFFER)) &&
+ (buf1->buffer_private == buf2->buffer_private) &&
+ ((buf1->data + buf1->size) == buf2->data));
}
/**
*
* Returns: the new #GstBuffer that spans the two source buffers.
*/
-GstBuffer*
-gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len)
+GstBuffer *
+gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
+ guint32 len)
{
GstBuffer *newbuf;
/* if the two buffers have the same parent and are adjacent */
if (gst_buffer_is_span_fast (buf1, buf2)) {
GstBuffer *parent = GST_BUFFER (buf1->buffer_private);
+
/* we simply create a subbuffer of the common parent */
- newbuf = gst_buffer_create_sub (parent,
- buf1->data - parent->data + offset, len);
- }
- else {
- GST_CAT_DEBUG (GST_CAT_BUFFER, "slow path taken while spanning buffers %p and %p",
- buf1, buf2);
+ newbuf = gst_buffer_create_sub (parent,
+ buf1->data - parent->data + offset, len);
+ } else {
+ GST_CAT_DEBUG (GST_CAT_BUFFER,
+ "slow path taken while spanning buffers %p and %p", buf1, buf2);
/* otherwise we simply have to brute-force copy the buffers */
newbuf = gst_buffer_new_and_alloc (len);
/* copy the first buffer's data across */
memcpy (newbuf->data, buf1->data + offset, buf1->size - offset);
/* copy the second buffer's data across */
- memcpy (newbuf->data + (buf1->size - offset), buf2->data,
- len - (buf1->size - offset));
+ memcpy (newbuf->data + (buf1->size - offset), buf2->data,
+ len - (buf1->size - offset));
/* if the offset is 0, the new buffer has the same timestamp as buf1 */
if (offset == 0) {
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1);
if (GST_BUFFER_DURATION_IS_VALID (buf1) &&
GST_BUFFER_DURATION_IS_VALID (buf2)) {
/* add duration */
- GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) +
- GST_BUFFER_DURATION (buf2);
+ GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) +
+ GST_BUFFER_DURATION (buf2);
}
if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) {
/* add offset_end */
return newbuf;
}
-
#include <gst/gstdata.h>
#include <gst/gstclock.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS typedef struct _GstBuffer GstBuffer;
-typedef struct _GstBuffer GstBuffer;
-
-typedef void (*GstBufferFreeDataFunc) (GstBuffer *buffer);
+typedef void (*GstBufferFreeDataFunc) (GstBuffer * buffer);
#define GST_BUFFER_TRACE_NAME "GstBuffer"
#define GST_BUFFER_OFFSET_END_IS_VALID(buffer) (GST_BUFFER_OFFSET_END (buffer) != GST_BUFFER_OFFSET_NONE)
#define GST_BUFFER_MAXSIZE_IS_VALID(buffer) (GST_BUFFER_MAXSIZE (buffer) != GST_BUFFER_MAXSIZE_NONE)
-typedef enum {
- GST_BUFFER_READONLY = GST_DATA_READONLY,
- GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST,
+typedef enum
+{
+ GST_BUFFER_READONLY = GST_DATA_READONLY,
+ GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST,
GST_BUFFER_ORIGINAL,
GST_BUFFER_DONTFREE,
GST_BUFFER_KEY_UNIT,
GST_BUFFER_DONTKEEP,
- GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8
+ GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8
} GstBufferFlag;
-struct _GstBuffer {
- GstData data_type;
+struct _GstBuffer
+{
+ GstData data_type;
/* pointer to data and its size */
- guint8 *data; /* pointer to buffer data */
- guint size; /* size of buffer data */
- guint maxsize; /* max size of this buffer */
+ guint8 *data; /* pointer to buffer data */
+ guint size; /* size of buffer data */
+ guint maxsize; /* max size of this buffer */
/* timestamp */
- GstClockTime timestamp;
- GstClockTime duration;
+ GstClockTime timestamp;
+ GstClockTime duration;
/* media specific offset
* for video frames, this could be the number of frames,
* offset_end is the last offset contained in the buffer. The format specifies
* the meaning of both of them exactly.
*/
- guint64 offset;
- guint64 offset_end;
+ guint64 offset;
+ guint64 offset_end;
- GstBufferFreeDataFunc free_data;
- gpointer buffer_private;
+ GstBufferFreeDataFunc free_data;
+ gpointer buffer_private;
gpointer _gst_reserved[GST_PADDING];
};
/* allocation */
-GType gst_buffer_get_type (void);
-GstBuffer* gst_buffer_new (void);
-GstBuffer* gst_buffer_new_and_alloc (guint size);
+GType gst_buffer_get_type (void);
+GstBuffer *gst_buffer_new (void);
+GstBuffer *gst_buffer_new_and_alloc (guint size);
#define gst_buffer_set_data(buf, data, size) \
G_STMT_START { \
#define gst_buffer_ref_by_count(buf,c) GST_BUFFER (gst_data_ref_by_count (GST_DATA (buf), c))
#define gst_buffer_unref(buf) gst_data_unref (GST_DATA (buf))
/* copy buffer */
-void gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src);
+void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src);
+
#define gst_buffer_copy(buf) GST_BUFFER (gst_data_copy (GST_DATA (buf)))
#define gst_buffer_is_writable(buf) gst_data_is_writable (GST_DATA (buf))
#define gst_buffer_copy_on_write(buf) GST_BUFFER (gst_data_copy_on_write (GST_DATA (buf)))
/* creating a subbuffer */
-GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size);
+GstBuffer *gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size);
/* merge, span, or append two buffers, intelligently */
-GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2);
-gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
-GstBuffer* gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len);
+GstBuffer *gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2);
+gboolean gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2);
+GstBuffer *gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
+ guint32 len);
/* --- private --- */
-void _gst_buffer_initialize (void);
+void _gst_buffer_initialize (void);
-void gst_buffer_default_free (GstBuffer *buffer);
-GstBuffer* gst_buffer_default_copy (GstBuffer *buffer);
+void gst_buffer_default_free (GstBuffer * buffer);
+GstBuffer *gst_buffer_default_copy (GstBuffer * buffer);
G_END_DECLS
-
#endif /* __GST_BUFFER_H__ */
} G_STMT_END
-static void gst_caps_transform_to_string (const GValue *src_value,
- GValue *dest_value);
-static gboolean gst_caps_from_string_inplace (GstCaps *caps,
- const gchar *string);
-static GstCaps * gst_caps_copy_conditional (const GstCaps *src);
+static void gst_caps_transform_to_string (const GValue * src_value,
+ GValue * dest_value);
+static gboolean gst_caps_from_string_inplace (GstCaps * caps,
+ const gchar * string);
+static GstCaps *gst_caps_copy_conditional (const GstCaps * src);
GType
gst_caps_get_type (void)
{
static GType gst_caps_type = 0;
-
+
if (!gst_caps_type) {
gst_caps_type = g_boxed_type_register_static ("GstCaps",
- (GBoxedCopyFunc)gst_caps_copy_conditional,
- (GBoxedFreeFunc)gst_caps_free);
-
+ (GBoxedCopyFunc) gst_caps_copy_conditional,
+ (GBoxedFreeFunc) gst_caps_free);
+
g_value_register_transform_func (gst_caps_type,
- G_TYPE_STRING,
- gst_caps_transform_to_string);
+ G_TYPE_STRING, gst_caps_transform_to_string);
}
-
+
return gst_caps_type;
}
GstCaps *
gst_caps_new_empty (void)
{
- GstCaps *caps = g_new0(GstCaps, 1);
+ GstCaps *caps = g_new0 (GstCaps, 1);
caps->type = GST_TYPE_CAPS;
- caps->structs = g_ptr_array_new();
+ caps->structs = g_ptr_array_new ();
return caps;
}
GstCaps *
gst_caps_new_any (void)
{
- GstCaps *caps = g_new0(GstCaps, 1);
+ GstCaps *caps = g_new0 (GstCaps, 1);
caps->type = GST_TYPE_CAPS;
- caps->structs = g_ptr_array_new();
+ caps->structs = g_ptr_array_new ();
caps->flags = GST_CAPS_FLAGS_ANY;
return caps;
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_new_simple (const char *media_type,
- const char *fieldname,
- ...)
+gst_caps_new_simple (const char *media_type, const char *fieldname, ...)
{
GstCaps *caps;
GstStructure *structure;
va_list var_args;
- caps = g_new0(GstCaps, 1);
+ caps = g_new0 (GstCaps, 1);
caps->type = GST_TYPE_CAPS;
- caps->structs = g_ptr_array_new();
+ caps->structs = g_ptr_array_new ();
va_start (var_args, fieldname);
structure = gst_structure_new_valist (media_type, fieldname, var_args);
va_end (var_args);
gst_caps_append_structure (caps, structure);
-
+
return caps;
}
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_new_full (GstStructure *struct1, ...)
+gst_caps_new_full (GstStructure * struct1, ...)
{
GstCaps *caps;
va_list var_args;
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_new_full_valist (GstStructure *structure,
- va_list var_args)
+gst_caps_new_full_valist (GstStructure * structure, va_list var_args)
{
GstCaps *caps;
- caps = g_new0(GstCaps, 1);
+ caps = g_new0 (GstCaps, 1);
caps->type = GST_TYPE_CAPS;
- caps->structs = g_ptr_array_new();
+ caps->structs = g_ptr_array_new ();
- while(structure){
+ while (structure) {
gst_caps_append_structure (caps, structure);
structure = va_arg (var_args, GstStructure *);
}
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_copy (const GstCaps *caps)
+gst_caps_copy (const GstCaps * caps)
{
GstCaps *newcaps;
GstStructure *structure;
int i;
- g_return_val_if_fail(caps != NULL, NULL);
+ g_return_val_if_fail (caps != NULL, NULL);
- newcaps = g_new0(GstCaps, 1);
+ newcaps = g_new0 (GstCaps, 1);
newcaps->type = GST_TYPE_CAPS;
newcaps->flags = caps->flags;
- newcaps->structs = g_ptr_array_new();
+ newcaps->structs = g_ptr_array_new ();
- for(i=0;i<caps->structs->len;i++){
+ for (i = 0; i < caps->structs->len; i++) {
structure = gst_caps_get_structure (caps, i);
- gst_caps_append_structure (newcaps, gst_structure_copy(structure));
+ gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
return newcaps;
* values.
*/
void
-gst_caps_free (GstCaps *caps)
+gst_caps_free (GstCaps * caps)
{
GstStructure *structure;
int i;
-
- g_return_if_fail(caps != NULL);
- for(i=0;i<caps->structs->len;i++){
+ g_return_if_fail (caps != NULL);
+
+ for (i = 0; i < caps->structs->len; i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_free (structure);
}
- g_ptr_array_free(caps->structs, TRUE);
+ g_ptr_array_free (caps->structs, TRUE);
#ifdef USE_POISONING
- memset (caps, 0xff, sizeof(GstCaps));
+ memset (caps, 0xff, sizeof (GstCaps));
#endif
- g_free(caps);
+ g_free (caps);
}
/**
* Returns: the new #GstCaps
*/
const GstCaps *
-gst_static_caps_get (GstStaticCaps *static_caps)
+gst_static_caps_get (GstStaticCaps * static_caps)
{
- GstCaps *caps = (GstCaps *)static_caps;
+ GstCaps *caps = (GstCaps *) static_caps;
gboolean ret;
if (caps->type == 0) {
caps->type = GST_TYPE_CAPS;
- caps->structs = g_ptr_array_new();
+ caps->structs = g_ptr_array_new ();
ret = gst_caps_from_string_inplace (caps, static_caps->string);
if (!ret) {
* @caps2 is freed.
*/
void
-gst_caps_append (GstCaps *caps1,
- GstCaps *caps2)
+gst_caps_append (GstCaps * caps1, GstCaps * caps2)
{
GstStructure *structure;
int i;
#ifdef USE_POISONING
CAPS_POISON (caps2);
#endif
- for(i=0;i<caps2->structs->len;i++){
+ for (i = 0; i < caps2->structs->len; i++) {
structure = gst_caps_get_structure (caps2, i);
gst_caps_append_structure (caps1, structure);
}
- g_ptr_array_free(caps2->structs, TRUE);
+ g_ptr_array_free (caps2->structs, TRUE);
#ifdef USE_POISONING
- memset (caps2, 0xff, sizeof(GstCaps));
+ memset (caps2, 0xff, sizeof (GstCaps));
#endif
- g_free(caps2);
+ g_free (caps2);
}
/**
* becomes the owner of @structure.
*/
void
-gst_caps_append_structure (GstCaps *caps,
- GstStructure *structure)
+gst_caps_append_structure (GstCaps * caps, GstStructure * structure)
{
- g_return_if_fail(caps != NULL);
+ g_return_if_fail (caps != NULL);
- if (structure){
+ if (structure) {
#if 0
#ifdef USE_POISONING
STRUCTURE_POISON (structure);
* Returns:
*/
GstCaps *
-gst_caps_split_one (GstCaps *caps)
+gst_caps_split_one (GstCaps * caps)
{
/* FIXME */
g_critical ("unimplemented");
* Returns: the number of structures that @caps contains
*/
int
-gst_caps_get_size (const GstCaps *caps)
+gst_caps_get_size (const GstCaps * caps)
{
g_return_val_if_fail (caps != NULL, 0);
* Returns: a pointer to the #GstStructure corresponding to @index
*/
GstStructure *
-gst_caps_get_structure (const GstCaps *caps, int index)
+gst_caps_get_structure (const GstCaps * caps, int index)
{
g_return_val_if_fail (caps != NULL, NULL);
g_return_val_if_fail (index >= 0, NULL);
g_return_val_if_fail (index < caps->structs->len, NULL);
- return g_ptr_array_index(caps->structs, index);
+ return g_ptr_array_index (caps->structs, index);
}
/**
* Returns: the new @GstCaps
*/
GstCaps *
-gst_caps_copy_1 (const GstCaps *caps)
+gst_caps_copy_1 (const GstCaps * caps)
{
GstCaps *newcaps;
GstStructure *structure;
- g_return_val_if_fail(caps != NULL, NULL);
+ g_return_val_if_fail (caps != NULL, NULL);
- newcaps = g_new0(GstCaps, 1);
+ newcaps = g_new0 (GstCaps, 1);
newcaps->type = GST_TYPE_CAPS;
newcaps->flags = caps->flags;
- newcaps->structs = g_ptr_array_new();
+ newcaps->structs = g_ptr_array_new ();
- if (caps->structs->len > 0){
+ if (caps->structs->len > 0) {
structure = gst_caps_get_structure (caps, 0);
- gst_caps_append_structure (newcaps, gst_structure_copy(structure));
+ gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
return newcaps;
* manner as @gst_structure_set(), and be NULL-terminated.
*/
void
-gst_caps_set_simple (GstCaps *caps, char *field, ...)
+gst_caps_set_simple (GstCaps * caps, char *field, ...)
{
GstStructure *structure;
va_list var_args;
va_start (var_args, field);
gst_structure_set_valist (structure, field, var_args);
- va_end(var_args);
+ va_end (var_args);
}
/**
* manner as @gst_structure_set(), and be NULL-terminated.
*/
void
-gst_caps_set_simple_valist (GstCaps *caps,
- char *field,
- va_list varargs)
+gst_caps_set_simple_valist (GstCaps * caps, char *field, va_list varargs)
{
GstStructure *structure;
* Returns: TRUE if @caps represents any format.
*/
gboolean
-gst_caps_is_any (const GstCaps *caps)
+gst_caps_is_any (const GstCaps * caps)
{
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
return (caps->flags & GST_CAPS_FLAGS_ANY);
}
* Returns: TRUE if @caps represents no formats.
*/
gboolean
-gst_caps_is_empty (const GstCaps *caps)
+gst_caps_is_empty (const GstCaps * caps)
{
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
- if (caps->flags & GST_CAPS_FLAGS_ANY) return FALSE;
+ if (caps->flags & GST_CAPS_FLAGS_ANY)
+ return FALSE;
return (caps->structs == NULL) || (caps->structs->len == 0);
}
* Returns: TRUE if @caps contains more than one structure
*/
gboolean
-gst_caps_is_chained (const GstCaps *caps)
+gst_caps_is_chained (const GstCaps * caps)
{
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
return (caps->structs->len > 1);
}
static gboolean
-gst_caps_is_fixed_foreach (GQuark field_id,
- GValue *value,
- gpointer unused)
+gst_caps_is_fixed_foreach (GQuark field_id, GValue * value, gpointer unused)
{
GType type = G_VALUE_TYPE (value);
- if (G_TYPE_IS_FUNDAMENTAL (type)) return TRUE;
- if (type == GST_TYPE_FOURCC) return TRUE;
+
+ if (G_TYPE_IS_FUNDAMENTAL (type))
+ return TRUE;
+ if (type == GST_TYPE_FOURCC)
+ return TRUE;
return FALSE;
}
* Returns: TRUE if @caps is fixed
*/
gboolean
-gst_caps_is_fixed (const GstCaps *caps)
+gst_caps_is_fixed (const GstCaps * caps)
{
GstStructure *structure;
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
- if (caps->structs->len != 1) return FALSE;
+ if (caps->structs->len != 1)
+ return FALSE;
structure = gst_caps_get_structure (caps, 0);
}
static gboolean
-gst_structure_is_equal_foreach (GQuark field_id,
- GValue *val2,
- gpointer data)
+gst_structure_is_equal_foreach (GQuark field_id, GValue * val2, gpointer data)
{
GstStructure *struct1 = (GstStructure *) data;
const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
- if (val1 == NULL) return FALSE;
+ if (val1 == NULL)
+ return FALSE;
if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) {
return TRUE;
}
* Returns: TRUE if the arguments represent the same format
*/
gboolean
-gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2)
+gst_caps_is_equal_fixed (const GstCaps * caps1, const GstCaps * caps2)
{
GstStructure *struct1, *struct2;
- g_return_val_if_fail (gst_caps_is_fixed(caps1), FALSE);
- g_return_val_if_fail (gst_caps_is_fixed(caps2), FALSE);
+ g_return_val_if_fail (gst_caps_is_fixed (caps1), FALSE);
+ g_return_val_if_fail (gst_caps_is_fixed (caps2), FALSE);
struct1 = gst_caps_get_structure (caps1, 0);
struct2 = gst_caps_get_structure (caps2, 0);
}
return gst_structure_foreach (struct1, gst_structure_is_equal_foreach,
- struct2);
+ struct2);
}
static gboolean
-gst_structure_field_has_compatible (GQuark field_id,
- GValue *val2,
- gpointer data)
+gst_structure_field_has_compatible (GQuark field_id,
+ GValue * val2, gpointer data)
{
GValue dest = { 0 };
GstStructure *struct1 = (GstStructure *) data;
const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
- if (val1 == NULL) return FALSE;
+ if (val1 == NULL)
+ return FALSE;
if (gst_value_intersect (&dest, val1, val2)) {
g_value_unset (&dest);
return TRUE;
}
static gboolean
-gst_cap_is_always_compatible (const GstStructure *struct1,
- const GstStructure *struct2)
+gst_cap_is_always_compatible (const GstStructure * struct1,
+ const GstStructure * struct2)
{
- if(struct1->name != struct2->name){
+ if (struct1->name != struct2->name) {
return FALSE;
}
/* the reversed order is important */
- return gst_structure_foreach ((GstStructure *) struct2,
- gst_structure_field_has_compatible, (gpointer) struct1);
+ return gst_structure_foreach ((GstStructure *) struct2,
+ gst_structure_field_has_compatible, (gpointer) struct1);
}
static gboolean
-gst_caps_cap_is_always_compatible (const GstStructure *struct1,
- const GstCaps *caps2)
+gst_caps_cap_is_always_compatible (const GstStructure * struct1,
+ const GstCaps * caps2)
{
int i;
- for(i=0;i<caps2->structs->len;i++){
+ for (i = 0; i < caps2->structs->len; i++) {
GstStructure *struct2 = gst_caps_get_structure (caps2, i);
if (gst_cap_is_always_compatible (struct1, struct2)) {
* Returns: TRUE if @caps1 is a subset of @caps2.
*/
gboolean
-gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2)
+gst_caps_is_always_compatible (const GstCaps * caps1, const GstCaps * caps2)
{
int i;
/* FIXME: is this right ? */
g_return_val_if_fail (!gst_caps_is_empty (caps1), FALSE);
g_return_val_if_fail (!gst_caps_is_empty (caps2), FALSE);
-
+
if (gst_caps_is_any (caps2))
return TRUE;
if (gst_caps_is_any (caps1))
return FALSE;
-
- for(i=0;i<caps1->structs->len;i++) {
+
+ for (i = 0; i < caps1->structs->len; i++) {
GstStructure *struct1 = gst_caps_get_structure (caps1, i);
- if (gst_caps_cap_is_always_compatible(struct1, caps2) == FALSE){
+ if (gst_caps_cap_is_always_compatible (struct1, caps2) == FALSE) {
return FALSE;
}
return FALSE;
}
-typedef struct {
+typedef struct
+{
GstStructure *dest;
const GstStructure *intersect;
gboolean first_run;
} IntersectData;
static gboolean
-gst_caps_structure_intersect_field (GQuark id, GValue *val1, gpointer data)
+gst_caps_structure_intersect_field (GQuark id, GValue * val1, gpointer data)
{
IntersectData *idata = (IntersectData *) data;
GValue dest_value = { 0 };
return FALSE;
}
}
-
+
return TRUE;
}
static GstStructure *
-gst_caps_structure_intersect (const GstStructure *struct1,
- const GstStructure *struct2)
+gst_caps_structure_intersect (const GstStructure * struct1,
+ const GstStructure * struct2)
{
IntersectData data;
- g_return_val_if_fail(struct1 != NULL, NULL);
- g_return_val_if_fail(struct2 != NULL, NULL);
+ g_return_val_if_fail (struct1 != NULL, NULL);
+ g_return_val_if_fail (struct2 != NULL, NULL);
- if (struct1->name != struct2->name) return NULL;
+ if (struct1->name != struct2->name)
+ return NULL;
data.dest = gst_structure_id_empty_new (struct1->name);
data.intersect = struct2;
data.first_run = TRUE;
- if (!gst_structure_foreach ((GstStructure *) struct1,
- gst_caps_structure_intersect_field, &data))
+ if (!gst_structure_foreach ((GstStructure *) struct1,
+ gst_caps_structure_intersect_field, &data))
goto error;
-
+
data.intersect = struct1;
data.first_run = FALSE;
- if (!gst_structure_foreach ((GstStructure *) struct2,
- gst_caps_structure_intersect_field, &data))
+ if (!gst_structure_foreach ((GstStructure *) struct2,
+ gst_caps_structure_intersect_field, &data))
goto error;
return data.dest;
#if 0
static GstStructure *
-gst_caps_structure_union (const GstStructure *struct1,
- const GstStructure *struct2)
+gst_caps_structure_union (const GstStructure * struct1,
+ const GstStructure * struct2)
{
int i;
GstStructure *dest;
/* FIXME this doesn't actually work */
- if (struct1->name != struct2->name) return NULL;
+ if (struct1->name != struct2->name)
+ return NULL;
dest = gst_structure_id_empty_new (struct1->name);
- for(i=0;i<struct1->fields->len;i++){
+ for (i = 0; i < struct1->fields->len; i++) {
GValue dest_value = { 0 };
field1 = GST_STRUCTURE_FIELD (struct1, i);
continue;
} else {
if (gst_value_union (&dest_value, &field1->value, &field2->value)) {
- gst_structure_set_value (dest, g_quark_to_string(field1->name),
+ gst_structure_set_value (dest, g_quark_to_string (field1->name),
&dest_value);
} else {
ret = gst_value_compare (&field1->value, &field2->value);
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_intersect (const GstCaps *caps1,
- const GstCaps *caps2)
+gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
{
- int i,j;
+ int i, j;
GstStructure *struct1;
GstStructure *struct2;
GstCaps *dest;
+
#if 0
GstCaps *caps;
#endif
g_return_val_if_fail (caps1 != NULL, NULL);
g_return_val_if_fail (caps2 != NULL, NULL);
- if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)){
+ if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)) {
return gst_caps_new_empty ();
}
- if (gst_caps_is_any (caps1)) return gst_caps_copy (caps2);
- if (gst_caps_is_any (caps2)) return gst_caps_copy (caps1);
+ if (gst_caps_is_any (caps1))
+ return gst_caps_copy (caps2);
+ if (gst_caps_is_any (caps2))
+ return gst_caps_copy (caps1);
- dest = gst_caps_new_empty();
- for(i=0;i<caps1->structs->len;i++){
+ dest = gst_caps_new_empty ();
+ for (i = 0; i < caps1->structs->len; i++) {
struct1 = gst_caps_get_structure (caps1, i);
- for(j=0;j<caps2->structs->len;j++){
+ for (j = 0; j < caps2->structs->len; j++) {
GstStructure *istruct;
struct2 = gst_caps_get_structure (caps2, j);
istruct = gst_caps_structure_intersect (struct1, struct2);
- gst_caps_append_structure(dest, istruct);
+ gst_caps_append_structure (dest, istruct);
}
}
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_union (const GstCaps *caps1,
- const GstCaps *caps2)
+gst_caps_union (const GstCaps * caps1, const GstCaps * caps2)
{
GstCaps *dest1;
GstCaps *dest2;
return dest1;
}
-typedef struct _NormalizeForeach {
+typedef struct _NormalizeForeach
+{
GstCaps *caps;
GstStructure *structure;
} NormalizeForeach;
static gboolean
-gst_caps_normalize_foreach (GQuark field_id,
- GValue *value,
- gpointer ptr)
+gst_caps_normalize_foreach (GQuark field_id, GValue * value, gpointer ptr)
{
NormalizeForeach *nf = (NormalizeForeach *) ptr;
GValue val = { 0 };
int i;
if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
- for (i=1; i<gst_value_list_get_size (value); i++) {
+ for (i = 1; i < gst_value_list_get_size (value); i++) {
const GValue *v = gst_value_list_get_value (value, i);
GstStructure *structure = gst_structure_copy (nf->structure);
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_normalize (const GstCaps *caps)
+gst_caps_normalize (const GstCaps * caps)
{
NormalizeForeach nf;
GstCaps *newcaps;
int i;
- g_return_val_if_fail(caps != NULL, NULL);
+ g_return_val_if_fail (caps != NULL, NULL);
newcaps = gst_caps_copy (caps);
nf.caps = newcaps;
- for(i=0;i<newcaps->structs->len;i++){
+ for (i = 0; i < newcaps->structs->len; i++) {
nf.structure = gst_caps_get_structure (newcaps, i);
while (!gst_structure_foreach (nf.structure,
- gst_caps_normalize_foreach,
- &nf));
+ gst_caps_normalize_foreach, &nf));
}
return newcaps;
}
static gboolean
-simplify_foreach (GQuark field_id,
- GValue *value,
- gpointer user_data)
+simplify_foreach (GQuark field_id, GValue * value, gpointer user_data)
{
GstStructure *s2 = (GstStructure *) user_data;
const GValue *v2;
v2 = gst_structure_id_get_value (s2, field_id);
- if (v2 == NULL) return FALSE;
+ if (v2 == NULL)
+ return FALSE;
- if (gst_value_compare (value, v2) == GST_VALUE_EQUAL) return TRUE;
+ if (gst_value_compare (value, v2) == GST_VALUE_EQUAL)
+ return TRUE;
return FALSE;
}
static gboolean
-gst_caps_structure_simplify (GstStructure *struct1,
- const GstStructure *struct2)
+gst_caps_structure_simplify (GstStructure * struct1,
+ const GstStructure * struct2)
{
/* FIXME this is just a simple compare. Better would be to merge
* the two structures */
- if (struct1->name != struct2->name) return FALSE;
- if (struct1->fields->len != struct2->fields->len) return FALSE;
+ if (struct1->name != struct2->name)
+ return FALSE;
+ if (struct1->fields->len != struct2->fields->len)
+ return FALSE;
- return gst_structure_foreach (struct1, simplify_foreach, (void *)struct2);
+ return gst_structure_foreach (struct1, simplify_foreach, (void *) struct2);
}
/**
* Returns: the new #GstCaps
*/
GstCaps *
-gst_caps_simplify (const GstCaps *caps)
+gst_caps_simplify (const GstCaps * caps)
{
int i;
int j;
newcaps = gst_caps_new_empty ();
- for(i=0;i<gst_caps_get_size (caps);i++){
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- for(j=0;j<gst_caps_get_size (newcaps);j++){
+ for (j = 0; j < gst_caps_get_size (newcaps); j++) {
struct2 = gst_caps_get_structure (caps, i);
if (gst_caps_structure_simplify (struct2, structure)) {
- break;
+ break;
}
}
- if (j==gst_caps_get_size (newcaps)) {
- gst_caps_append_structure (newcaps, gst_structure_copy(structure));
+ if (j == gst_caps_get_size (newcaps)) {
+ gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
}
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr
-gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent)
+gst_caps_save_thyself (const GstCaps * caps, xmlNodePtr parent)
{
return 0;
* @newcaps.
*/
void
-gst_caps_replace (GstCaps **caps,
- GstCaps *newcaps)
+gst_caps_replace (GstCaps ** caps, GstCaps * newcaps)
{
-#if 0 /* disable this, since too many plugins rely on undefined behavior */
+#if 0 /* disable this, since too many plugins rely on undefined behavior */
#ifdef USE_POISONING
//if (newcaps) CAPS_POISON (newcaps);
#endif
#endif
- if (*caps) gst_caps_free(*caps);
+ if (*caps)
+ gst_caps_free (*caps);
*caps = newcaps;
}
* Returns: a string representing @caps
*/
gchar *
-gst_caps_to_string (const GstCaps *caps)
+gst_caps_to_string (const GstCaps * caps)
{
int i;
GstStructure *structure;
/* FIXME does this leak? */
if (caps == NULL) {
- return g_strdup("NULL");
+ return g_strdup ("NULL");
}
- if(gst_caps_is_any(caps)){
- return g_strdup("ANY");
+ if (gst_caps_is_any (caps)) {
+ return g_strdup ("ANY");
}
- if(gst_caps_is_empty(caps)){
- return g_strdup("EMPTY");
+ if (gst_caps_is_empty (caps)) {
+ return g_strdup ("EMPTY");
}
- s = g_string_new("");
+ s = g_string_new ("");
structure = gst_caps_get_structure (caps, 0);
- sstr = gst_structure_to_string(structure);
- g_string_append(s, sstr);
- g_free(sstr);
+ sstr = gst_structure_to_string (structure);
+ g_string_append (s, sstr);
+ g_free (sstr);
- for(i=1;i<caps->structs->len;i++){
+ for (i = 1; i < caps->structs->len; i++) {
structure = gst_caps_get_structure (caps, i);
- g_string_append(s, "; ");
- sstr = gst_structure_to_string(structure);
- g_string_append(s, sstr);
- g_free(sstr);
+ g_string_append (s, "; ");
+ sstr = gst_structure_to_string (structure);
+ g_string_append (s, sstr);
+ g_free (sstr);
}
- return g_string_free(s, FALSE);
+ return g_string_free (s, FALSE);
}
static gboolean
-gst_caps_from_string_inplace (GstCaps *caps,
- const gchar *string)
+gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
{
GstStructure *structure;
gchar *s;
- if (strcmp("ANY", string)==0) {
+ if (strcmp ("ANY", string) == 0) {
caps->flags = GST_CAPS_FLAGS_ANY;
return TRUE;
}
- if (strcmp("NONE", string)==0) {
+ if (strcmp ("NONE", string) == 0) {
return TRUE;
}
- structure = gst_structure_from_string(string, &s);
+ structure = gst_structure_from_string (string, &s);
if (structure == NULL) {
return FALSE;
}
while (*s == ';') {
s++;
- while (g_ascii_isspace(*s))s++;
- structure = gst_structure_from_string(s, &s);
+ while (g_ascii_isspace (*s))
+ s++;
+ structure = gst_structure_from_string (s, &s);
if (structure == NULL) {
return FALSE;
}
gst_caps_append_structure (caps, structure);
- while (g_ascii_isspace(*s))s++;
+ while (g_ascii_isspace (*s))
+ s++;
}
- if (*s != 0){
+ if (*s != 0) {
return FALSE;
}
* Returns: a new #GstCaps
*/
GstCaps *
-gst_caps_from_string (const gchar *string)
+gst_caps_from_string (const gchar * string)
{
GstCaps *caps;
- caps = gst_caps_new_empty();
+ caps = gst_caps_new_empty ();
if (gst_caps_from_string_inplace (caps, string)) {
return caps;
} else {
}
static void
-gst_caps_transform_to_string (const GValue *src_value,
- GValue *dest_value)
+gst_caps_transform_to_string (const GValue * src_value, GValue * dest_value)
{
g_return_if_fail (src_value != NULL);
g_return_if_fail (dest_value != NULL);
dest_value->data[0].v_pointer =
- gst_caps_to_string (src_value->data[0].v_pointer);
+ gst_caps_to_string (src_value->data[0].v_pointer);
}
static GstCaps *
-gst_caps_copy_conditional (const GstCaps *src)
+gst_caps_copy_conditional (const GstCaps * src)
{
if (src) {
return gst_caps_copy (src);
/* fixate utility functions */
gboolean
-gst_caps_structure_fixate_field_nearest_int (GstStructure *structure,
- const char *field_name,
- int target)
+gst_caps_structure_fixate_field_nearest_int (GstStructure * structure,
+ const char *field_name, int target)
{
const GValue *value;
- g_return_val_if_fail(gst_structure_has_field (structure, field_name), FALSE);
+ g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
value = gst_structure_get_value (structure, field_name);
return FALSE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
int x;
+
x = gst_value_get_int_range_min (value);
- if (target < x) target = x;
+ if (target < x)
+ target = x;
x = gst_value_get_int_range_max (value);
- if (target > x) target = x;
+ if (target > x)
+ target = x;
gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
return TRUE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
int best_index = -1;
n = gst_value_list_get_size (value);
- for(i=0;i<n;i++){
+ for (i = 0; i < n; i++) {
list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_INT) {
int x = g_value_get_int (list_value);
- if (best_index == -1 || (ABS(target-x) < ABS(best-x))) {
+
+ if (best_index == -1 || (ABS (target - x) < ABS (best - x))) {
best_index = i;
best = x;
}
}
}
- if(best_index != -1) {
+ if (best_index != -1) {
gst_structure_set (structure, field_name, G_TYPE_INT, best, NULL);
return TRUE;
}
}
gboolean
-gst_caps_structure_fixate_field_nearest_double (GstStructure *structure,
- const char *field_name,
- double target)
+gst_caps_structure_fixate_field_nearest_double (GstStructure * structure,
+ const char *field_name, double target)
{
const GValue *value;
- g_return_val_if_fail(gst_structure_has_field (structure, field_name), FALSE);
+ g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
value = gst_structure_get_value (structure, field_name);
return FALSE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_DOUBLE_RANGE) {
double x;
+
x = gst_value_get_double_range_min (value);
- if (target < x) target = x;
+ if (target < x)
+ target = x;
x = gst_value_get_double_range_max (value);
- if (target > x) target = x;
+ if (target > x)
+ target = x;
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, target, NULL);
return TRUE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
int best_index = -1;
n = gst_value_list_get_size (value);
- for(i=0;i<n;i++){
+ for (i = 0; i < n; i++) {
list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_DOUBLE) {
double x = g_value_get_double (list_value);
- if (best_index == -1 || (ABS(target-x) < ABS(best-x))) {
+
+ if (best_index == -1 || (ABS (target - x) < ABS (best - x))) {
best_index = i;
best = x;
}
}
}
- if(best_index != -1) {
+ if (best_index != -1) {
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, best, NULL);
return TRUE;
}
return FALSE;
}
-
#include <gst/gststructure.h>
G_BEGIN_DECLS
-
#define GST_TYPE_CAPS gst_caps_get_type()
#define GST_CAPS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_CAPS, GstCaps))
#define GST_IS_CAPS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_CAPS))
-
#define GST_CAPS_FLAGS_ANY (1 << 0)
-
#define GST_CAPS_ANY gst_caps_new_any()
#define GST_CAPS_NONE gst_caps_new_empty()
-
#define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
#define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
-
#define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1)
#define gst_caps_is_simple(caps) GST_CAPS_IS_SIMPLE(caps)
-
#ifndef GST_DISABLE_DEPRECATED
#define GST_DEBUG_CAPS(string, caps) \
GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps)
#endif
-
#define GST_STATIC_CAPS(string) \
{ \
/* caps */ { 0 }, \
/* string */ string, \
}
-
typedef struct _GstCaps GstCaps;
typedef struct _GstStaticCaps GstStaticCaps;
-struct _GstCaps {
+struct _GstCaps
+{
GType type;
guint16 flags;
GPtrArray *structs;
};
-struct _GstStaticCaps {
+struct _GstStaticCaps
+{
GstCaps caps;
const char *string;
};
-GType gst_caps_get_type (void) G_GNUC_CONST;
-GstCaps * gst_caps_new_empty (void);
-GstCaps * gst_caps_new_any (void);
-GstCaps * gst_caps_new_simple (const char *media_type,
- const char *fieldname,
- ...);
-GstCaps * gst_caps_new_full (GstStructure *struct1,
- ...);
-GstCaps * gst_caps_new_full_valist (GstStructure *structure,
- va_list var_args);
-GstCaps * gst_caps_copy (const GstCaps *caps);
-void gst_caps_free (GstCaps *caps);
-G_CONST_RETURN GstCaps * gst_static_caps_get (GstStaticCaps *caps);
+GType
+gst_caps_get_type (void)
+ G_GNUC_CONST;
+ GstCaps *gst_caps_new_empty (void);
+ GstCaps *gst_caps_new_any (void);
+ GstCaps *gst_caps_new_simple (const char *media_type,
+ const char *fieldname, ...);
+ GstCaps *gst_caps_new_full (GstStructure * struct1, ...);
+ GstCaps *gst_caps_new_full_valist (GstStructure * structure,
+ va_list var_args);
+ GstCaps *gst_caps_copy (const GstCaps * caps);
+ void gst_caps_free (GstCaps * caps);
+ G_CONST_RETURN GstCaps *gst_static_caps_get (GstStaticCaps * caps);
/* manipulation */
-void gst_caps_append (GstCaps *caps1,
- GstCaps *caps2);
-void gst_caps_append_structure (GstCaps *caps1,
- GstStructure *structure);
-GstCaps * gst_caps_split_one (GstCaps *caps);
-int gst_caps_get_size (const GstCaps *caps);
-GstStructure * gst_caps_get_structure (const GstCaps *caps,
- int index);
+ void gst_caps_append (GstCaps * caps1, GstCaps * caps2);
+ void gst_caps_append_structure (GstCaps * caps1, GstStructure * structure);
+ GstCaps *gst_caps_split_one (GstCaps * caps);
+ int gst_caps_get_size (const GstCaps * caps);
+ GstStructure *gst_caps_get_structure (const GstCaps * caps, int index);
+
#ifndef GST_DISABLE_DEPRECATED
-GstCaps * gst_caps_copy_1 (const GstCaps *caps);
+ GstCaps *gst_caps_copy_1 (const GstCaps * caps);
#endif
-void gst_caps_set_simple (GstCaps *caps,
- char *field, ...);
-void gst_caps_set_simple_valist (GstCaps *caps,
- char *field,
- va_list varargs);
+ void gst_caps_set_simple (GstCaps * caps, char *field, ...);
+ void gst_caps_set_simple_valist (GstCaps * caps,
+ char *field, va_list varargs);
/* tests */
-gboolean gst_caps_is_any (const GstCaps *caps);
-gboolean gst_caps_is_empty (const GstCaps *caps);
+ gboolean gst_caps_is_any (const GstCaps * caps);
+ gboolean gst_caps_is_empty (const GstCaps * caps);
+
#ifndef GST_DISABLE_DEPRECATED
-gboolean gst_caps_is_chained (const GstCaps *caps);
+ gboolean gst_caps_is_chained (const GstCaps * caps);
#endif
-gboolean gst_caps_is_fixed (const GstCaps *caps);
-gboolean gst_caps_is_equal_fixed (const GstCaps *caps1,
- const GstCaps *caps2);
-gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
- const GstCaps *caps2);
+ gboolean gst_caps_is_fixed (const GstCaps * caps);
+ gboolean gst_caps_is_equal_fixed (const GstCaps * caps1,
+ const GstCaps * caps2);
+ gboolean gst_caps_is_always_compatible (const GstCaps * caps1,
+ const GstCaps * caps2);
/* operations */
-GstCaps * gst_caps_intersect (const GstCaps *caps1,
- const GstCaps *caps2);
-GstCaps * gst_caps_union (const GstCaps *caps1,
- const GstCaps *caps2);
-GstCaps * gst_caps_normalize (const GstCaps *caps);
-GstCaps * gst_caps_simplify (const GstCaps *caps);
+ GstCaps *gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2);
+ GstCaps *gst_caps_union (const GstCaps * caps1, const GstCaps * caps2);
+ GstCaps *gst_caps_normalize (const GstCaps * caps);
+ GstCaps *gst_caps_simplify (const GstCaps * caps);
#ifndef GST_DISABLE_LOADSAVE
-xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
- xmlNodePtr parent);
-GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
+ xmlNodePtr gst_caps_save_thyself (const GstCaps * caps, xmlNodePtr parent);
+ GstCaps *gst_caps_load_thyself (xmlNodePtr parent);
#endif
/* utility */
-void gst_caps_replace (GstCaps **caps,
- GstCaps *newcaps);
-gchar * gst_caps_to_string (const GstCaps *caps);
-GstCaps * gst_caps_from_string (const gchar *string);
-
-gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure *structure,
- const char *field_name,
- int target);
-gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure *structure,
- const char *field_name,
- double target);
+ void gst_caps_replace (GstCaps ** caps, GstCaps * newcaps);
+ gchar *gst_caps_to_string (const GstCaps * caps);
+ GstCaps *gst_caps_from_string (const gchar * string);
-G_END_DECLS
+ gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure *
+ structure, const char *field_name, int target);
+ gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure *
+ structure, const char *field_name, double target);
+G_END_DECLS
#endif /* __GST_CAPS_H__ */
#define DEFAULT_EVENT_DIFF (GST_SECOND)
#define DEFAULT_MAX_DIFF (2 * GST_SECOND)
-enum {
+enum
+{
ARG_0,
ARG_STATS,
ARG_MAX_DIFF,
ARG_EVENT_DIFF
};
-static GstMemChunk *_gst_clock_entries_chunk;
+static GstMemChunk *_gst_clock_entries_chunk;
+
+void gst_clock_id_unlock (GstClockID id);
-void gst_clock_id_unlock (GstClockID id);
-
-static void gst_clock_class_init (GstClockClass *klass);
-static void gst_clock_init (GstClock *clock);
-static void gst_clock_dispose (GObject *object);
+static void gst_clock_class_init (GstClockClass * klass);
+static void gst_clock_init (GstClock * clock);
+static void gst_clock_dispose (GObject * object);
-static void gst_clock_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_clock_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec * pspec);
-static void gst_clock_update_stats (GstClock *clock);
+static void gst_clock_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_clock_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_clock_update_stats (GstClock * clock);
static GstObjectClass *parent_class = NULL;
+
/* static guint gst_clock_signals[LAST_SIGNAL] = { 0 }; */
static GstClockID
-gst_clock_entry_new (GstClock *clock, GstClockTime time,
- GstClockTime interval, GstClockEntryType type)
+gst_clock_entry_new (GstClock * clock, GstClockTime time,
+ GstClockTime interval, GstClockEntryType type)
{
GstClockEntry *entry;
* Returns: An id that can be used to request the time notification.
*/
GstClockID
-gst_clock_new_single_shot_id (GstClock *clock, GstClockTime time)
+gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time)
{
g_return_val_if_fail (GST_IS_CLOCK (clock), NULL);
- return gst_clock_entry_new (clock,
- time,
- GST_CLOCK_TIME_NONE,
- GST_CLOCK_ENTRY_SINGLE);
+ return gst_clock_entry_new (clock,
+ time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE);
}
/**
* Returns: An id that can be used to request the time notification.
*/
GstClockID
-gst_clock_new_periodic_id (GstClock *clock, GstClockTime start_time,
- GstClockTime interval)
+gst_clock_new_periodic_id (GstClock * clock, GstClockTime start_time,
+ GstClockTime interval)
{
g_return_val_if_fail (GST_IS_CLOCK (clock), NULL);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (start_time), NULL);
g_return_val_if_fail (interval != 0, NULL);
- return gst_clock_entry_new (clock,
- start_time,
- interval,
- GST_CLOCK_ENTRY_PERIODIC);
+ return gst_clock_entry_new (clock,
+ start_time, interval, GST_CLOCK_ENTRY_PERIODIC);
}
/**
{
g_return_val_if_fail (id != NULL, GST_CLOCK_TIME_NONE);
- return GST_CLOCK_ENTRY_TIME ((GstClockEntry *)id);
+ return GST_CLOCK_ENTRY_TIME ((GstClockEntry *) id);
}
* Returns: the result of the blocking wait.
*/
GstClockReturn
-gst_clock_id_wait (GstClockID id, GstClockTimeDiff *jitter)
+gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter)
{
GstClockEntry *entry;
GstClock *clock;
GstClockReturn res = GST_CLOCK_UNSUPPORTED;
GstClockTime requested;
GstClockClass *cclass;
-
+
g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR);
entry = (GstClockEntry *) id;
requested = GST_CLOCK_ENTRY_TIME (entry);
- if (! GST_CLOCK_TIME_IS_VALID (requested)) {
+ if (!GST_CLOCK_TIME_IS_VALID (requested)) {
GST_CAT_DEBUG (GST_CAT_CLOCK, "invalid time requested, returning _TIMEOUT");
return GST_CLOCK_TIMEOUT;
}
clock = GST_CLOCK_ENTRY_CLOCK (entry);
cclass = GST_CLOCK_GET_CLASS (clock);
-
+
if (cclass->wait) {
GstClockTime now;
-
+
GST_LOCK (clock);
clock->entries = g_list_prepend (clock->entries, entry);
GST_UNLOCK (clock);
*/
GstClockReturn
gst_clock_id_wait_async (GstClockID id,
- GstClockCallback func, gpointer user_data)
+ GstClockCallback func, gpointer user_data)
{
GstClockEntry *entry;
GstClock *clock;
GstClockReturn res = GST_CLOCK_UNSUPPORTED;
GstClockClass *cclass;
-
+
g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR);
g_return_val_if_fail (func != NULL, GST_CLOCK_ERROR);
entry = (GstClockEntry *) id;
clock = entry->clock;
- if (! GST_CLOCK_TIME_IS_VALID (GST_CLOCK_ENTRY_TIME (entry))) {
+ if (!GST_CLOCK_TIME_IS_VALID (GST_CLOCK_ENTRY_TIME (entry))) {
(func) (clock, GST_CLOCK_TIME_NONE, id, user_data);
return GST_CLOCK_TIMEOUT;
}
}
static void
-gst_clock_reschedule_func (GstClockEntry *entry)
+gst_clock_reschedule_func (GstClockEntry * entry)
{
entry->status = GST_CLOCK_ENTRY_OK;
-
- gst_clock_id_unlock ((GstClockID)entry);
+
+ gst_clock_id_unlock ((GstClockID) entry);
}
/**
GstClockEntry *entry;
GstClock *clock;
GstClockClass *cclass;
-
+
g_return_if_fail (id != NULL);
entry = (GstClockEntry *) id;
GstClockEntry *entry;
GstClock *clock;
GstClockClass *cclass;
-
+
g_return_if_fail (id != NULL);
entry = (GstClockEntry *) id;
(GInstanceInitFunc) gst_clock_init,
NULL
};
- clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock",
- &clock_info, G_TYPE_FLAG_ABSTRACT);
+ clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock",
+ &clock_info, G_TYPE_FLAG_ABSTRACT);
}
return clock_type;
}
static void
-gst_clock_class_init (GstClockClass *klass)
+gst_clock_class_init (GstClockClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
g_thread_init (NULL);
_gst_clock_entries_chunk = gst_mem_chunk_new ("GstClockEntries",
- sizeof (GstClockEntry), sizeof (GstClockEntry) * 32,
- G_ALLOC_AND_FREE);
+ sizeof (GstClockEntry), sizeof (GstClockEntry) * 32, G_ALLOC_AND_FREE);
#ifndef GST_DISABLE_TRACE
- _gst_clock_entry_trace = gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME);
+ _gst_clock_entry_trace =
+ gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME);
#endif
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_clock_dispose);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_clock_dispose);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_clock_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_clock_get_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATS,
- g_param_spec_boolean ("stats", "Stats", "Enable clock stats",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("stats", "Stats", "Enable clock stats",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DIFF,
- g_param_spec_int64 ("max-diff", "Max diff", "The maximum amount of time to wait in nanoseconds",
- 0, G_MAXINT64, DEFAULT_MAX_DIFF, G_PARAM_READWRITE));
+ g_param_spec_int64 ("max-diff", "Max diff",
+ "The maximum amount of time to wait in nanoseconds", 0, G_MAXINT64,
+ DEFAULT_MAX_DIFF, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_DIFF,
- g_param_spec_uint64 ("event-diff", "event diff",
- "The amount of time that may elapse until 2 events are treated as happening at different times",
- 0, G_MAXUINT64, DEFAULT_EVENT_DIFF, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_param_spec_uint64 ("event-diff", "event diff",
+ "The amount of time that may elapse until 2 events are treated as happening at different times",
+ 0, G_MAXUINT64, DEFAULT_EVENT_DIFF,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
-gst_clock_init (GstClock *clock)
+gst_clock_init (GstClock * clock)
{
clock->max_diff = DEFAULT_MAX_DIFF;
}
static void
-gst_clock_dispose (GObject *object)
+gst_clock_dispose (GObject * object)
{
GstClock *clock = GST_CLOCK (object);
* Returns: the new speed of the clock.
*/
gdouble
-gst_clock_set_speed (GstClock *clock, gdouble speed)
+gst_clock_set_speed (GstClock * clock, gdouble speed)
{
g_return_val_if_fail (GST_IS_CLOCK (clock), 0.0);
* Returns: the speed of the clock.
*/
gdouble
-gst_clock_get_speed (GstClock *clock)
+gst_clock_get_speed (GstClock * clock)
{
g_return_val_if_fail (GST_IS_CLOCK (clock), 0.0);
* Returns: the new resolution of the clock.
*/
guint64
-gst_clock_set_resolution (GstClock *clock, guint64 resolution)
+gst_clock_set_resolution (GstClock * clock, guint64 resolution)
{
GstClockClass *cclass;
cclass = GST_CLOCK_GET_CLASS (clock);
if (cclass->change_resolution)
- clock->resolution = cclass->change_resolution (clock, clock->resolution, resolution);
+ clock->resolution =
+ cclass->change_resolution (clock, clock->resolution, resolution);
return clock->resolution;
}
* Returns: the resolution of the clock in microseconds.
*/
guint64
-gst_clock_get_resolution (GstClock *clock)
+gst_clock_get_resolution (GstClock * clock)
{
GstClockClass *cclass;
* As soon as the clock is activated, the time will start ticking.
*/
void
-gst_clock_set_active (GstClock *clock, gboolean active)
+gst_clock_set_active (GstClock * clock, gboolean active)
{
g_return_if_fail (GST_IS_CLOCK (clock));
-
+
GST_ERROR_OBJECT (clock, "called deprecated function that does nothing now.");
return;
* Returns: TRUE if the clock is active.
*/
gboolean
-gst_clock_is_active (GstClock *clock)
+gst_clock_is_active (GstClock * clock)
{
g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE);
* Reset the clock to time 0.
*/
void
-gst_clock_reset (GstClock *clock)
+gst_clock_reset (GstClock * clock)
{
GstClockTime time = G_GINT64_CONSTANT (0);
GstClockClass *cclass;
GST_ERROR_OBJECT (clock, "called deprecated function.");
cclass = GST_CLOCK_GET_CLASS (clock);
-
+
if (cclass->get_internal_time) {
time = cclass->get_internal_time (clock);
}
* discontinuitity in the pipeline is honoured.
*/
gboolean
-gst_clock_handle_discont (GstClock *clock, guint64 time)
+gst_clock_handle_discont (GstClock * clock, guint64 time)
{
GST_ERROR_OBJECT (clock, "called deprecated function.");
* Returns: the time of the clock.
*/
GstClockTime
-gst_clock_get_time (GstClock *clock)
+gst_clock_get_time (GstClock * clock)
{
GstClockTime ret = G_GINT64_CONSTANT (0);
GstClockClass *cclass;
/* make sure the time is increasing, else return last_time */
if ((gint64) ret < (gint64) clock->last_time) {
ret = clock->last_time;
- }
- else {
+ } else {
clock->last_time = ret;
}
* Returns: the time of the event
*/
GstClockTime
-gst_clock_get_event_time (GstClock *clock)
+gst_clock_get_event_time (GstClock * clock)
{
GstClockTime time;
-
+
g_return_val_if_fail (GST_IS_CLOCK (clock), GST_CLOCK_TIME_NONE);
-
+
time = gst_clock_get_time (clock);
if (clock->last_event + clock->max_event_diff >= time) {
- GST_LOG_OBJECT (clock, "reporting last event time %"G_GUINT64_FORMAT,
+ GST_LOG_OBJECT (clock, "reporting last event time %" G_GUINT64_FORMAT,
clock->last_event);
} else {
- GST_LOG_OBJECT (clock, "reporting new event time %"G_GUINT64_FORMAT,
+ GST_LOG_OBJECT (clock, "reporting new event time %" G_GUINT64_FORMAT,
clock->last_event);
clock->last_event = time;
}
-
+
return clock->last_event;
}
* Returns: a clockid or NULL is no event is pending.
*/
GstClockID
-gst_clock_get_next_id (GstClock *clock)
+gst_clock_get_next_id (GstClock * clock)
{
GstClockEntry *entry = NULL;
}
static void
-gst_clock_update_stats (GstClock *clock)
+gst_clock_update_stats (GstClock * clock)
{
}
static void
-gst_clock_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_clock_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstClock *clock;
-
+
clock = GST_CLOCK (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
static void
-gst_clock_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec * pspec)
+gst_clock_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstClock *clock;
-
+
clock = GST_CLOCK (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
#include <gst/gstobject.h>
G_BEGIN_DECLS
-
/* --- standard type macros --- */
#define GST_TYPE_CLOCK (gst_clock_get_type ())
#define GST_CLOCK(clock) (G_TYPE_CHECK_INSTANCE_CAST ((clock), GST_TYPE_CLOCK, GstClock))
#define GST_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_CAST ((cclass), GST_TYPE_CLOCK, GstClockClass))
#define GST_IS_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_TYPE ((cclass), GST_TYPE_CLOCK))
#define GST_CLOCK_GET_CLASS(clock) (G_TYPE_INSTANCE_GET_CLASS ((clock), GST_TYPE_CLOCK, GstClockClass))
-
-typedef guint64 GstClockTime;
-typedef gint64 GstClockTimeDiff;
-typedef gpointer GstClockID;
+typedef guint64 GstClockTime;
+typedef gint64 GstClockTimeDiff;
+typedef gpointer GstClockID;
#define GST_CLOCK_TIME_NONE ((GstClockTime)-1)
#define GST_CLOCK_TIME_IS_VALID(time) ((time) != GST_CLOCK_TIME_NONE)
#define GST_CLOCK_ENTRY_TRACE_NAME "GstClockEntry"
-typedef struct _GstClockEntry GstClockEntry;
-typedef struct _GstClock GstClock;
-typedef struct _GstClockClass GstClockClass;
+typedef struct _GstClockEntry GstClockEntry;
+typedef struct _GstClock GstClock;
+typedef struct _GstClockClass GstClockClass;
/* --- prototype for async callbacks --- */
-typedef gboolean (*GstClockCallback) (GstClock *clock, GstClockTime time,
- GstClockID id, gpointer user_data);
+typedef gboolean (*GstClockCallback) (GstClock * clock, GstClockTime time,
+ GstClockID id, gpointer user_data);
-typedef enum {
+typedef enum
+{
/* --- protected --- */
GST_CLOCK_ENTRY_OK,
GST_CLOCK_ENTRY_EARLY,
GST_CLOCK_ENTRY_RESTART
} GstClockEntryStatus;
-typedef enum {
+typedef enum
+{
/* --- protected --- */
GST_CLOCK_ENTRY_SINGLE,
GST_CLOCK_ENTRY_PERIODIC
#define GST_CLOCK_ENTRY_INTERVAL(entry) ((entry)->interval)
#define GST_CLOCK_ENTRY_STATUS(entry) ((entry)->status)
-struct _GstClockEntry {
+struct _GstClockEntry
+{
/* --- protected --- */
- GstClock *clock;
- GstClockEntryType type;
- GstClockTime time;
- GstClockTime interval;
- GstClockEntryStatus status;
- GstClockCallback func;
- gpointer user_data;
+ GstClock *clock;
+ GstClockEntryType type;
+ GstClockTime time;
+ GstClockTime interval;
+ GstClockEntryStatus status;
+ GstClockCallback func;
+ gpointer user_data;
};
typedef enum
{
- GST_CLOCK_STOPPED = 0,
- GST_CLOCK_TIMEOUT = 1,
- GST_CLOCK_EARLY = 2,
- GST_CLOCK_ERROR = 3,
- GST_CLOCK_UNSUPPORTED = 4
+ GST_CLOCK_STOPPED = 0,
+ GST_CLOCK_TIMEOUT = 1,
+ GST_CLOCK_EARLY = 2,
+ GST_CLOCK_ERROR = 3,
+ GST_CLOCK_UNSUPPORTED = 4
} GstClockReturn;
typedef enum
{
- GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC = (1 << 1),
- GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC = (1 << 2),
- GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC = (1 << 3),
- GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC = (1 << 4),
- GST_CLOCK_FLAG_CAN_SET_RESOLUTION = (1 << 5),
- GST_CLOCK_FLAG_CAN_SET_SPEED = (1 << 6)
+ GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC = (1 << 1),
+ GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC = (1 << 2),
+ GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC = (1 << 3),
+ GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC = (1 << 4),
+ GST_CLOCK_FLAG_CAN_SET_RESOLUTION = (1 << 5),
+ GST_CLOCK_FLAG_CAN_SET_SPEED = (1 << 6)
} GstClockFlags;
#define GST_CLOCK_FLAGS(clock) (GST_CLOCK(clock)->flags)
-struct _GstClock {
- GstObject object;
+struct _GstClock
+{
+ GstObject object;
- GstClockFlags flags;
+ GstClockFlags flags;
/* --- protected --- */
- GstClockTime start_time;
- GstClockTime last_time;
- gint64 max_diff;
+ GstClockTime start_time;
+ GstClockTime last_time;
+ gint64 max_diff;
/* --- private --- */
- guint64 resolution;
- GList *entries;
- GMutex *active_mutex;
- GCond *active_cond;
- gboolean stats;
-
- GstClockTime last_event;
- GstClockTime max_event_diff;
-
+ guint64 resolution;
+ GList *entries;
+ GMutex *active_mutex;
+ GCond *active_cond;
+ gboolean stats;
+
+ GstClockTime last_event;
+ GstClockTime max_event_diff;
+
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstClockClass {
- GstObjectClass parent_class;
+struct _GstClockClass
+{
+ GstObjectClass parent_class;
/* vtable */
- gdouble (*change_speed) (GstClock *clock,
- gdouble oldspeed, gdouble newspeed);
- gdouble (*get_speed) (GstClock *clock);
- guint64 (*change_resolution) (GstClock *clock, guint64 old_resolution,
- guint64 new_resolution);
- guint64 (*get_resolution) (GstClock *clock);
+ gdouble (*change_speed) (GstClock * clock,
+ gdouble oldspeed, gdouble newspeed);
+ gdouble (*get_speed) (GstClock * clock);
+ guint64 (*change_resolution) (GstClock * clock, guint64 old_resolution,
+ guint64 new_resolution);
+ guint64 (*get_resolution) (GstClock * clock);
- GstClockTime (*get_internal_time) (GstClock *clock);
+ GstClockTime (*get_internal_time) (GstClock * clock);
/* waiting on an ID */
- GstClockEntryStatus (*wait) (GstClock *clock, GstClockEntry *entry);
- GstClockEntryStatus (*wait_async) (GstClock *clock, GstClockEntry *entry);
- void (*unschedule) (GstClock *clock, GstClockEntry *entry);
- void (*unlock) (GstClock *clock, GstClockEntry *entry);
+ GstClockEntryStatus (*wait) (GstClock * clock, GstClockEntry * entry);
+ GstClockEntryStatus (*wait_async) (GstClock * clock, GstClockEntry * entry);
+ void (*unschedule) (GstClock * clock, GstClockEntry * entry);
+ void (*unlock) (GstClock * clock, GstClockEntry * entry);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_clock_get_type (void);
+GType gst_clock_get_type (void);
-gdouble gst_clock_set_speed (GstClock *clock, gdouble speed);
-gdouble gst_clock_get_speed (GstClock *clock);
+gdouble gst_clock_set_speed (GstClock * clock, gdouble speed);
+gdouble gst_clock_get_speed (GstClock * clock);
-guint64 gst_clock_set_resolution (GstClock *clock, guint64 resolution);
-guint64 gst_clock_get_resolution (GstClock *clock);
+guint64 gst_clock_set_resolution (GstClock * clock, guint64 resolution);
+guint64 gst_clock_get_resolution (GstClock * clock);
-void gst_clock_set_active (GstClock *clock, gboolean active);
-gboolean gst_clock_is_active (GstClock *clock);
-void gst_clock_reset (GstClock *clock);
-gboolean gst_clock_handle_discont (GstClock *clock, guint64 time);
+void gst_clock_set_active (GstClock * clock, gboolean active);
+gboolean gst_clock_is_active (GstClock * clock);
+void gst_clock_reset (GstClock * clock);
+gboolean gst_clock_handle_discont (GstClock * clock, guint64 time);
-GstClockTime gst_clock_get_time (GstClock *clock);
-GstClockTime gst_clock_get_event_time (GstClock *clock);
+GstClockTime gst_clock_get_time (GstClock * clock);
+GstClockTime gst_clock_get_event_time (GstClock * clock);
-GstClockID gst_clock_get_next_id (GstClock *clock);
+GstClockID gst_clock_get_next_id (GstClock * clock);
/* creating IDs that can be used to get notifications */
-GstClockID gst_clock_new_single_shot_id (GstClock *clock,
- GstClockTime time);
-GstClockID gst_clock_new_periodic_id (GstClock *clock,
- GstClockTime start_time,
- GstClockTime interval);
+GstClockID gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time);
+GstClockID gst_clock_new_periodic_id (GstClock * clock,
+ GstClockTime start_time, GstClockTime interval);
/* operations on IDs */
-GstClockTime gst_clock_id_get_time (GstClockID id);
-GstClockReturn gst_clock_id_wait (GstClockID id,
- GstClockTimeDiff *jitter);
-GstClockReturn gst_clock_id_wait_async (GstClockID id,
- GstClockCallback func,
- gpointer user_data);
-void gst_clock_id_unschedule (GstClockID id);
-void gst_clock_id_unlock (GstClockID id);
-void gst_clock_id_free (GstClockID id);
+GstClockTime gst_clock_id_get_time (GstClockID id);
+GstClockReturn gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter);
+GstClockReturn gst_clock_id_wait_async (GstClockID id,
+ GstClockCallback func, gpointer user_data);
+void gst_clock_id_unschedule (GstClockID id);
+void gst_clock_id_unlock (GstClockID id);
+void gst_clock_id_free (GstClockID id);
G_END_DECLS
-
#endif /* __GST_CLOCK_H__ */
#define __GSTCOMPAT_H__
G_BEGIN_DECLS
-
#ifndef GST_DISABLE_DEPRECATED
/* 0.5.2 changes */
-
/* element functions */
#define gst_element_connect(a,b) gst_element_link(a,b)
#define gst_element_connect_pads(a,b,c,d) \
#define gst_element_connect_filtered(a,b,c) \
gst_element_link_filtered(a,b,c)
#define gst_element_disconnect(a,b) gst_element_unlink(a,b)
-
/* pad functions */
#define gst_pad_connect(a,b) gst_pad_link(a,b)
#define gst_pad_connect_filtered(a,b,c) gst_pad_link_filtered(a,b,c)
#define gst_pad_proxy_connect(a,b) gst_pad_proxy_link(a,b)
#define gst_pad_set_connect_function(a,b) \
gst_pad_set_link_function(a,b)
-
/* pad macros */
#define GST_PAD_IS_CONNECTED(a) GST_PAD_IS_LINKED(a)
-
/* pad enums */
#define GST_PAD_CONNECT_REFUSED GST_PAD_LINK_REFUSED
#define GST_PAD_CONNECT_DELAYED GST_PAD_LINK_DELAYED
#define GST_PAD_CONNECT_OK GST_PAD_LINK_OK
#define GST_PAD_CONNECT_DONE GST_PAD_LINK_DONE
-typedef GstPadLinkReturn GstPadConnectReturn;
+typedef GstPadLinkReturn GstPadConnectReturn;
/* pad function types */
-typedef GstPadLinkFunction GstPadConnectFunction;
+typedef GstPadLinkFunction GstPadConnectFunction;
/* probably not used */
/*
#endif /* not GST_DISABLE_DEPRECATED */
G_END_DECLS
-
#endif /* __GSTCOMPAT_H__ */
#ifdef HAVE_CPU_I386
#define _gst_cpu_initialize_arch _gst_cpu_initialize_i386
-void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, unsigned long *);
-gboolean _gst_cpu_initialize_i386 (gulong *flags, GString *featurelist);
+void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *,
+ unsigned long *);
+gboolean _gst_cpu_initialize_i386 (gulong * flags, GString * featurelist);
#else
#define _gst_cpu_initialize_arch _gst_cpu_initialize_none
-gboolean _gst_cpu_initialize_none (gulong *flags, GString *featurelist);
+gboolean _gst_cpu_initialize_none (gulong * flags, GString * featurelist);
#endif
{
GString *featurelist = g_string_new ("");
gulong flags = 0;
-
+
if (opt) {
if (!_gst_cpu_initialize_arch (&flags, featurelist))
g_string_append (featurelist, "NONE");
} else
g_string_append (featurelist, "(DISABLED)");
- GST_CAT_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags, featurelist->str);
+ GST_CAT_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags,
+ featurelist->str);
g_string_free (featurelist, TRUE);
}
gboolean
-_gst_cpu_initialize_none (gulong *flags, GString *featurelist)
+_gst_cpu_initialize_none (gulong * flags, GString * featurelist)
{
return FALSE;
}
#ifdef HAVE_CPU_I386
gboolean
-_gst_cpu_initialize_i386 (gulong *flags, GString *featurelist)
+_gst_cpu_initialize_i386 (gulong * flags, GString * featurelist)
{
gboolean AMD;
gulong eax = 0, ebx = 0, ecx = 0, edx = 0;
#ifndef __GST_CPU_H__
#define __GST_CPU_H__
-G_BEGIN_DECLS
-
-typedef enum {
- GST_CPU_FLAG_MMX = (1<<0),
- GST_CPU_FLAG_SSE = (1<<1),
- GST_CPU_FLAG_MMXEXT = (1<<2),
- GST_CPU_FLAG_3DNOW = (1<<3)
+G_BEGIN_DECLS typedef enum
+{
+ GST_CPU_FLAG_MMX = (1 << 0),
+ GST_CPU_FLAG_SSE = (1 << 1),
+ GST_CPU_FLAG_MMXEXT = (1 << 2),
+ GST_CPU_FLAG_3DNOW = (1 << 3)
} GstCPUFlags;
-void _gst_cpu_initialize (gboolean useopt);
+void _gst_cpu_initialize (gboolean useopt);
-GstCPUFlags gst_cpu_get_flags (void);
+GstCPUFlags gst_cpu_get_flags (void);
G_END_DECLS
-
#endif /* __GST_CPU_H__ */
gst_data_get_type (void)
{
static GType type = 0;
-
+
if (!type)
type = g_boxed_type_register_static ("GstData",
- (GBoxedCopyFunc) gst_data_copy,
- (GBoxedFreeFunc) gst_data_unref);
- return type;
+ (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref);
+ return type;
}
/**
* function will be called when this data is freed or copied respectively.
*/
void
-gst_data_init (GstData *data, GType type, guint16 flags, GstDataFreeFunction free, GstDataCopyFunction copy)
+gst_data_init (GstData * data, GType type, guint16 flags,
+ GstDataFreeFunction free, GstDataCopyFunction copy)
{
g_return_if_fail (data != NULL);
* the relevant GstData info.
*/
void
-gst_data_copy_into (const GstData *data, GstData *target)
+gst_data_copy_into (const GstData * data, GstData * target)
{
g_return_if_fail (data != NULL);
}
* mainly used by subclass implementors.
*/
void
-gst_data_dispose (GstData *data)
+gst_data_dispose (GstData * data)
{
g_return_if_fail (data != NULL);
* of the original buffer is not changed so you should unref it when you don't
* need it anymore.
*/
-GstData*
-gst_data_copy (const GstData *data)
+GstData *
+gst_data_copy (const GstData * data)
{
g_return_val_if_fail (data != NULL, NULL);
if (data->copy)
- return data->copy (data);
+ return data->copy (data);
return NULL;
}
* be copied before it can be modified safely.
*/
gboolean
-gst_data_is_writable (GstData *data)
+gst_data_is_writable (GstData * data)
{
gint refcount;
* is decreased when a copy is made, so you are not supposed to use it after a
* call to this function.
*/
-GstData*
-gst_data_copy_on_write (GstData *data)
+GstData *
+gst_data_copy_on_write (GstData * data)
{
gint refcount;
if (refcount == 1 && !GST_DATA_FLAG_IS_SET (data, GST_DATA_READONLY))
return GST_DATA (data);
-
+
if (data->copy) {
- GstData *copy = data->copy (data);
+ GstData *copy = data->copy (data);
+
gst_data_unref (data);
- return copy;
+ return copy;
}
return NULL;
*
* Returns: the data
*/
-GstData*
-gst_data_ref (GstData *data)
+GstData *
+gst_data_ref (GstData * data)
{
g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE(data) > 0, NULL);
+ g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0, NULL);
GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data,
- GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + 1);
-
+ GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + 1);
+
gst_atomic_int_inc (&data->refcount);
return data;
*
* Returns: the data
*/
-GstData*
-gst_data_ref_by_count (GstData *data, gint count)
+GstData *
+gst_data_ref_by_count (GstData * data, gint count)
{
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (count >= 0, NULL);
- g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE(data) > 0, NULL);
+ g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0, NULL);
GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data,
- GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + count);
+ GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + count);
gst_atomic_int_add (&data->refcount, count);
* data. When the data has been used by some plugin, it must unref()s it.
* Applications usually don't need to unref() anything.
*/
-void
-gst_data_unref (GstData *data)
+void
+gst_data_unref (GstData * data)
{
gint zero;
g_return_if_fail (data != NULL);
GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data,
- GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) - 1);
+ GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) - 1);
g_return_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0);
zero = gst_atomic_int_dec_and_test (&data->refcount);
/* if we ended up with the refcount at zero, free the data */
if (zero) {
- if (data->free)
- data->free (data);
+ if (data->free)
+ data->free (data);
}
}
#include <gst/gsttypes.h>
G_BEGIN_DECLS
-
/* type */
#define GST_DATA(data) ((GstData*)(data))
#define GST_DATA_TYPE(data) (GST_DATA(data)->type)
-
/* flags */
#define GST_DATA_FLAGS(data) (GST_DATA(data)->flags)
#define GST_DATA_FLAG_SHIFT(flag) (1<<(flag))
#define GST_DATA_FLAG_IS_SET(data,flag) (GST_DATA_FLAGS(data) & (1<<(flag)))
#define GST_DATA_FLAG_SET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) |= (1<<(flag))); }G_STMT_END
#define GST_DATA_FLAG_UNSET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) &= ~(1<<(flag))); }G_STMT_END
-
/* Macros for the GType */
#define GST_TYPE_DATA (gst_data_get_type ())
-
typedef struct _GstData GstData;
-typedef void (*GstDataFreeFunction) (GstData *data);
-typedef GstData* (*GstDataCopyFunction) (const GstData *data);
+typedef void (*GstDataFreeFunction) (GstData * data);
+typedef GstData *(*GstDataCopyFunction) (const GstData * data);
typedef enum
{
- GST_DATA_READONLY = 1,
+ GST_DATA_READONLY = 1,
/* insert more */
- GST_DATA_FLAG_LAST = 8
+ GST_DATA_FLAG_LAST = 8
} GstDataFlags;
/* refcount */
#define GST_DATA_FREE_FUNC(data) (GST_DATA(data)->free)
-struct _GstData {
- GType type;
+struct _GstData
+{
+ GType type;
/* refcounting */
- GstAtomicInt refcount;
+ GstAtomicInt refcount;
+
+ guint16 flags;
- guint16 flags;
-
/* utility function pointers, can override default */
- GstDataFreeFunction free; /* free the data */
- GstDataCopyFunction copy; /* copy the data */
+ GstDataFreeFunction free; /* free the data */
+ GstDataCopyFunction copy; /* copy the data */
gpointer _gst_reserved[GST_PADDING];
};
/* function used by subclasses only */
-void gst_data_init (GstData *data, GType type, guint16 flags,
- GstDataFreeFunction free,
- GstDataCopyFunction copy);
-void gst_data_dispose (GstData *data);
-void gst_data_copy_into (const GstData *data, GstData *target);
+void gst_data_init (GstData * data, GType type, guint16 flags,
+ GstDataFreeFunction free, GstDataCopyFunction copy);
+void gst_data_dispose (GstData * data);
+void gst_data_copy_into (const GstData * data, GstData * target);
/* basic operations on data */
-GstData* gst_data_copy (const GstData *data);
-gboolean gst_data_is_writable (GstData *data);
-GstData* gst_data_copy_on_write (GstData *data);
+GstData *gst_data_copy (const GstData * data);
+gboolean gst_data_is_writable (GstData * data);
+GstData *gst_data_copy_on_write (GstData * data);
/* reference counting */
-GstData* gst_data_ref (GstData* data);
-GstData* gst_data_ref_by_count (GstData* data, gint count);
-void gst_data_unref (GstData* data);
+GstData *gst_data_ref (GstData * data);
+GstData *gst_data_ref_by_count (GstData * data, gint count);
+void gst_data_unref (GstData * data);
/* GType for GstData */
-GType gst_data_get_type (void) G_GNUC_CONST;
+GType
+gst_data_get_type (void)
+ G_GNUC_CONST;
G_END_DECLS
-
#endif /* __GST_DATA_H__ */
G_STMT_START { \
gst_atomic_int_destroy (&(data)->refcount); \
} G_STMT_END;
-
#include "gst-i18n-lib.h"
/* Element signals and args */
-enum {
+enum
+{
STATE_CHANGE,
NEW_PAD,
PAD_REMOVED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-extern void __gst_element_details_clear (GstElementDetails *dp);
-extern void __gst_element_details_copy (GstElementDetails *dest,
- const GstElementDetails *src);
+extern void __gst_element_details_clear (GstElementDetails * dp);
+extern void __gst_element_details_copy (GstElementDetails * dest,
+ const GstElementDetails * src);
-static void gst_element_class_init (GstElementClass *klass);
-static void gst_element_init (GstElement *element);
-static void gst_element_base_class_init (gpointer g_class);
-static void gst_element_base_class_finalize (gpointer g_class);
+static void gst_element_class_init (GstElementClass * klass);
+static void gst_element_init (GstElement * element);
+static void gst_element_base_class_init (gpointer g_class);
+static void gst_element_base_class_finalize (gpointer g_class);
-static void gst_element_real_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_element_real_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
+static void gst_element_real_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_element_real_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_element_dispose (GObject *object);
+static void gst_element_dispose (GObject * object);
-static GstElementStateReturn gst_element_change_state (GstElement *element);
-static void gst_element_error_func (GstElement* element, GstElement *source, GError *error, gchar *debug);
-static void gst_element_found_tag_func (GstElement* element, GstElement *source, const GstTagList *tag_list);
+static GstElementStateReturn gst_element_change_state (GstElement * element);
+static void gst_element_error_func (GstElement * element, GstElement * source,
+ GError * error, gchar * debug);
+static void gst_element_found_tag_func (GstElement * element,
+ GstElement * source, const GstTagList * tag_list);
#ifndef GST_DISABLE_LOADSAVE
-static xmlNodePtr gst_element_save_thyself (GstObject *object, xmlNodePtr parent);
-static void gst_element_restore_thyself (GstObject *parent, xmlNodePtr self);
+static xmlNodePtr gst_element_save_thyself (GstObject * object,
+ xmlNodePtr parent);
+static void gst_element_restore_thyself (GstObject * parent, xmlNodePtr self);
#endif
GType _gst_element_type = 0;
static GstObjectClass *parent_class = NULL;
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
-GType gst_element_get_type (void)
+GType
+gst_element_get_type (void)
{
if (!_gst_element_type) {
static const GTypeInfo element_info = {
- sizeof(GstElementClass),
+ sizeof (GstElementClass),
gst_element_base_class_init,
gst_element_base_class_finalize,
- (GClassInitFunc)gst_element_class_init,
+ (GClassInitFunc) gst_element_class_init,
NULL,
NULL,
- sizeof(GstElement),
+ sizeof (GstElement),
0,
- (GInstanceInitFunc)gst_element_init,
+ (GInstanceInitFunc) gst_element_init,
NULL
};
- _gst_element_type = g_type_register_static(GST_TYPE_OBJECT, "GstElement",
- &element_info, G_TYPE_FLAG_ABSTRACT);
+ _gst_element_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement",
+ &element_info, G_TYPE_FLAG_ABSTRACT);
}
return _gst_element_type;
}
static void
-gst_element_class_init (GstElementClass *klass)
+gst_element_class_init (GstElementClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_OBJECT);
+ parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gst_element_signals[STATE_CHANGE] =
- g_signal_new ("state-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, state_change), NULL, NULL,
- gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
- G_TYPE_INT, G_TYPE_INT);
+ g_signal_new ("state-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstElementClass, state_change), NULL,
+ NULL, gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
gst_element_signals[NEW_PAD] =
- g_signal_new ("new-pad", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, new_pad), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
+ g_signal_new ("new-pad", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstElementClass, new_pad), NULL, NULL,
+ gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
gst_element_signals[PAD_REMOVED] =
- g_signal_new ("pad-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, pad_removed), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
+ g_signal_new ("pad-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstElementClass, pad_removed), NULL, NULL,
+ gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
gst_element_signals[ERROR] =
- g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL,
- gst_marshal_VOID__OBJECT_OBJECT_STRING, G_TYPE_NONE, 3,
- GST_TYPE_ELEMENT, GST_TYPE_G_ERROR,
- G_TYPE_STRING);
- gst_element_signals[EOS] =
- g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, eos), NULL, NULL,
- gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL,
+ gst_marshal_VOID__OBJECT_OBJECT_STRING, G_TYPE_NONE, 3, GST_TYPE_ELEMENT,
+ GST_TYPE_G_ERROR, G_TYPE_STRING);
+ gst_element_signals[EOS] =
+ g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstElementClass, eos), NULL, NULL,
+ gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_element_signals[FOUND_TAG] =
- g_signal_new ("found-tag", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstElementClass, found_tag), NULL, NULL,
- gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2,
- GST_TYPE_ELEMENT, GST_TYPE_TAG_LIST);
+ g_signal_new ("found-tag", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstElementClass, found_tag), NULL, NULL,
+ gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2, GST_TYPE_ELEMENT,
+ GST_TYPE_TAG_LIST);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_element_real_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_element_real_get_property);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_element_real_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_element_real_get_property);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_element_dispose);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_element_dispose);
#ifndef GST_DISABLE_LOADSAVE
- gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_element_save_thyself);
- gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_element_restore_thyself);
+ gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_element_save_thyself);
+ gstobject_class->restore_thyself =
+ GST_DEBUG_FUNCPTR (gst_element_restore_thyself);
#endif
- klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state);
- klass->error = GST_DEBUG_FUNCPTR (gst_element_error_func);
- klass->found_tag = GST_DEBUG_FUNCPTR (gst_element_found_tag_func);
- klass->numpadtemplates = 0;
+ klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state);
+ klass->error = GST_DEBUG_FUNCPTR (gst_element_error_func);
+ klass->found_tag = GST_DEBUG_FUNCPTR (gst_element_found_tag_func);
+ klass->numpadtemplates = 0;
- klass->elementfactory = NULL;
+ klass->elementfactory = NULL;
}
static void
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_element_real_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_element_real_get_property);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_element_real_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_element_real_get_property);
memset (&element_class->details, 0, sizeof (GstElementDetails));
element_class->padtemplates = NULL;
}
static void
-gst_element_init (GstElement *element)
+gst_element_init (GstElement * element)
{
element->current_state = GST_STATE_NULL;
element->pending_state = GST_STATE_VOID_PENDING;
}
static void
-gst_element_real_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_element_real_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstElementClass *oclass = GST_ELEMENT_GET_CLASS (object);
}
static void
-gst_element_real_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_element_real_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstElementClass *oclass = GST_ELEMENT_GET_CLASS (object);
* The default handler will simply print the error string using g_print.
*/
void
-gst_element_default_error (GObject *object, GstObject *source, GError *error, gchar *debug)
+gst_element_default_error (GObject * object, GstObject * source, GError * error,
+ gchar * debug)
{
gchar *name = gst_object_get_path_string (source);
g_free (name);
}
-typedef struct {
+typedef struct
+{
const GParamSpec *pspec;
GValue value;
} prop_value_t;
static void
-element_set_property (GstElement *element, const GParamSpec *pspec, const GValue *value)
+element_set_property (GstElement * element, const GParamSpec * pspec,
+ const GValue * value)
{
prop_value_t *prop_value = g_new0 (prop_value_t, 1);
}
static void
-element_get_property (GstElement *element, const GParamSpec *pspec, GValue *value)
+element_get_property (GstElement * element, const GParamSpec * pspec,
+ GValue * value)
{
g_mutex_lock (element->property_mutex);
- g_object_get_property ((GObject*)element, pspec->name, value);
+ g_object_get_property ((GObject *) element, pspec->name, value);
g_mutex_unlock (element->property_mutex);
}
static void
-gst_element_threadsafe_properties_pre_run (GstElement *element)
+gst_element_threadsafe_properties_pre_run (GstElement * element)
{
GST_DEBUG ("locking element %s", GST_OBJECT_NAME (element));
g_mutex_lock (element->property_mutex);
}
static void
-gst_element_threadsafe_properties_post_run (GstElement *element)
+gst_element_threadsafe_properties_post_run (GstElement * element)
{
GST_DEBUG ("unlocking element %s", GST_OBJECT_NAME (element));
g_mutex_unlock (element->property_mutex);
* threadsafe way.
*/
void
-gst_element_enable_threadsafe_properties (GstElement *element)
+gst_element_enable_threadsafe_properties (GstElement * element)
{
g_return_if_fail (GST_IS_ELEMENT (element));
-
+
GST_FLAG_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES);
element->pre_run_func = gst_element_threadsafe_properties_pre_run;
element->post_run_func = gst_element_threadsafe_properties_post_run;
* this element.
*/
void
-gst_element_disable_threadsafe_properties (GstElement *element)
+gst_element_disable_threadsafe_properties (GstElement * element)
{
g_return_if_fail (GST_IS_ELEMENT (element));
-
+
GST_FLAG_UNSET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES);
element->pre_run_func = NULL;
element->post_run_func = NULL;
* element.
*/
void
-gst_element_set_pending_properties (GstElement *element)
+gst_element_set_pending_properties (GstElement * element)
{
prop_value_t *prop_value;
while ((prop_value = g_async_queue_try_pop (element->prop_value_queue))) {
- g_object_set_property ((GObject*)element, prop_value->pspec->name, &prop_value->value);
+ g_object_set_property ((GObject *) element, prop_value->pspec->name,
+ &prop_value->value);
g_value_unset (&prop_value->value);
g_free (prop_value);
}
* they will be queued and set on the object when it is scheduled again.
*/
void
-gst_element_set (GstElement *element, const gchar *first_property_name, ...)
+gst_element_set (GstElement * element, const gchar * first_property_name, ...)
{
va_list var_args;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
-
+
va_start (var_args, first_property_name);
gst_element_set_valist (element, first_property_name, var_args);
va_end (var_args);
* the element will be locked before getting the given properties.
*/
void
-gst_element_get (GstElement *element, const gchar *first_property_name, ...)
+gst_element_get (GstElement * element, const gchar * first_property_name, ...)
{
va_list var_args;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
-
+
va_start (var_args, first_property_name);
gst_element_get_valist (element, first_property_name, var_args);
va_end (var_args);
* the property change will be put on the async queue.
*/
void
-gst_element_set_valist (GstElement *element, const gchar *first_property_name, va_list var_args)
+gst_element_set_valist (GstElement * element, const gchar * first_property_name,
+ va_list var_args)
{
const gchar *name;
GObject *object;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
-
+
object = (GObject *) element;
- GST_CAT_DEBUG (GST_CAT_PROPERTIES,
- "setting valist of properties starting with %s on element %s",
- first_property_name, gst_element_get_name (element));
+ GST_CAT_DEBUG (GST_CAT_PROPERTIES,
+ "setting valist of properties starting with %s on element %s",
+ first_property_name, gst_element_get_name (element));
if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) {
g_object_set_valist (object, first_property_name, var_args);
}
g_object_ref (object);
-
+
name = first_property_name;
- while (name)
- {
- GValue value = { 0, };
- GParamSpec *pspec;
- gchar *error = NULL;
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
-
- if (!pspec)
- {
- g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
- G_OBJECT_TYPE_NAME (object),
- name);
- break;
- }
- if (!(pspec->flags & G_PARAM_WRITABLE))
- {
- g_warning ("%s: property `%s' of object class `%s' is not writable",
- G_STRLOC,
- pspec->name,
- G_OBJECT_TYPE_NAME (object));
- break;
- }
-
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-
- G_VALUE_COLLECT (&value, var_args, 0, &error);
- if (error)
- {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
-
- /* we purposely leak the value here, it might not be
- * in a sane state if an error condition occoured
- */
- break;
- }
-
- element_set_property (element, pspec, &value);
- g_value_unset (&value);
-
- name = va_arg (var_args, gchar*);
+ while (name) {
+ GValue value = { 0, };
+ GParamSpec *pspec;
+ gchar *error = NULL;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
+
+ if (!pspec) {
+ g_warning ("%s: object class `%s' has no property named `%s'",
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
+ break;
+ }
+ if (!(pspec->flags & G_PARAM_WRITABLE)) {
+ g_warning ("%s: property `%s' of object class `%s' is not writable",
+ G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
+ break;
}
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
+ G_VALUE_COLLECT (&value, var_args, 0, &error);
+ if (error) {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+
+ /* we purposely leak the value here, it might not be
+ * in a sane state if an error condition occoured
+ */
+ break;
+ }
+
+ element_set_property (element, pspec, &value);
+ g_value_unset (&value);
+
+ name = va_arg (var_args, gchar *);
+ }
+
g_object_unref (object);
}
* the element will be locked before getting the given properties.
*/
void
-gst_element_get_valist (GstElement *element, const gchar *first_property_name, va_list var_args)
+gst_element_get_valist (GstElement * element, const gchar * first_property_name,
+ va_list var_args)
{
const gchar *name;
GObject *object;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
-
- object = (GObject*)element;
+
+ object = (GObject *) element;
if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) {
g_object_get_valist (object, first_property_name, var_args);
}
g_object_ref (object);
-
+
name = first_property_name;
-
- while (name)
- {
- GValue value = { 0, };
- GParamSpec *pspec;
- gchar *error;
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
-
- if (!pspec)
- {
- g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
- G_OBJECT_TYPE_NAME (object),
- name);
- break;
- }
- if (!(pspec->flags & G_PARAM_READABLE))
- {
- g_warning ("%s: property `%s' of object class `%s' is not readable",
- G_STRLOC,
- pspec->name,
- G_OBJECT_TYPE_NAME (object));
- break;
- }
-
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-
- element_get_property (element, pspec, &value);
-
- G_VALUE_LCOPY (&value, var_args, 0, &error);
- if (error)
- {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
- g_value_unset (&value);
- break;
- }
-
+
+ while (name) {
+ GValue value = { 0, };
+ GParamSpec *pspec;
+ gchar *error;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
+
+ if (!pspec) {
+ g_warning ("%s: object class `%s' has no property named `%s'",
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
+ break;
+ }
+ if (!(pspec->flags & G_PARAM_READABLE)) {
+ g_warning ("%s: property `%s' of object class `%s' is not readable",
+ G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
+ break;
+ }
+
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
+ element_get_property (element, pspec, &value);
+
+ G_VALUE_LCOPY (&value, var_args, 0, &error);
+ if (error) {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
g_value_unset (&value);
-
- name = va_arg (var_args, gchar*);
+ break;
}
-
+
+ g_value_unset (&value);
+
+ name = va_arg (var_args, gchar *);
+ }
+
g_object_unref (object);
}
* the property will be put on the async queue.
*/
void
-gst_element_set_property (GstElement *element, const gchar *property_name,
- const GValue *value)
+gst_element_set_property (GstElement * element, const gchar * property_name,
+ const GValue * value)
{
GParamSpec *pspec;
GObject *object;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (property_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
-
- object = (GObject*) element;
+
+ object = (GObject *) element;
GST_CAT_DEBUG (GST_CAT_PROPERTIES, "setting property %s on element %s",
- property_name, gst_element_get_name (element));
+ property_name, gst_element_get_name (element));
if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) {
g_object_set_property (object, property_name, value);
return;
}
g_object_ref (object);
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
- property_name);
-
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
+ property_name);
+
if (!pspec)
g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
- G_OBJECT_TYPE_NAME (object),
- property_name);
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name);
else
element_set_property (element, pspec, value);
-
+
g_object_unref (object);
}
-
+
/**
* gst_element_get_property:
* @element: a #GstElement to get properties of.
* the element will be locked before getting the given property.
*/
void
-gst_element_get_property (GstElement *element, const gchar *property_name, GValue *value)
+gst_element_get_property (GstElement * element, const gchar * property_name,
+ GValue * value)
{
GParamSpec *pspec;
GObject *object;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (property_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
-
- object = (GObject*)element;
+
+ object = (GObject *) element;
if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) {
g_object_get_property (object, property_name, value);
}
g_object_ref (object);
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property_name);
-
+
+ pspec =
+ g_object_class_find_property (G_OBJECT_GET_CLASS (object), property_name);
+
if (!pspec)
g_warning ("%s: object class `%s' has no property named `%s'",
- G_STRLOC,
- G_OBJECT_TYPE_NAME (object),
- property_name);
- else
- {
- GValue *prop_value, tmp_value = { 0, };
-
- /* auto-conversion of the callers value type
- */
- if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
- {
- g_value_reset (value);
- prop_value = value;
- }
- else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
- {
- g_warning ("can't retrieve property `%s' of type `%s' as value of type `%s'",
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
- G_VALUE_TYPE_NAME (value));
- g_object_unref (object);
- return;
- }
- else
- {
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- prop_value = &tmp_value;
- }
- element_get_property (element, pspec, prop_value);
- if (prop_value != value)
- {
- g_value_transform (prop_value, value);
- g_value_unset (&tmp_value);
- }
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name);
+ else {
+ GValue *prop_value, tmp_value = { 0, };
+
+ /* auto-conversion of the callers value type
+ */
+ if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec)) {
+ g_value_reset (value);
+ prop_value = value;
+ } else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec),
+ G_VALUE_TYPE (value))) {
+ g_warning
+ ("can't retrieve property `%s' of type `%s' as value of type `%s'",
+ pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ G_VALUE_TYPE_NAME (value));
+ g_object_unref (object);
+ return;
+ } else {
+ g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ prop_value = &tmp_value;
+ }
+ element_get_property (element, pspec, prop_value);
+ if (prop_value != value) {
+ g_value_transform (prop_value, value);
+ g_value_unset (&tmp_value);
}
-
+ }
+
g_object_unref (object);
}
-static GstPad*
-gst_element_request_pad (GstElement *element, GstPadTemplate *templ, const gchar* name)
+static GstPad *
+gst_element_request_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
GstPad *newpad = NULL;
GstElementClass *oclass;
oclass = GST_ELEMENT_GET_CLASS (element);
if (oclass->request_new_pad)
- newpad = (oclass->request_new_pad)(element, templ, name);
+ newpad = (oclass->request_new_pad) (element, templ, name);
return newpad;
}
* with gst_element_get_request_pad().
*/
void
-gst_element_release_request_pad (GstElement *element, GstPad *pad)
+gst_element_release_request_pad (GstElement * element, GstPad * pad)
{
GstElementClass *oclass;
* Returns: TRUE if the element requires a clock
*/
gboolean
-gst_element_requires_clock (GstElement *element)
+gst_element_requires_clock (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
* Returns: TRUE if the element provides a clock
*/
gboolean
-gst_element_provides_clock (GstElement *element)
+gst_element_provides_clock (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
* Sets the clock for the element.
*/
void
-gst_element_set_clock (GstElement *element, GstClock *clock)
+gst_element_set_clock (GstElement * element, GstClock * clock)
{
GstElementClass *oclass;
if (oclass->set_clock)
oclass->set_clock (element, clock);
- gst_object_replace ((GstObject **)&element->clock, (GstObject *)clock);
+ gst_object_replace ((GstObject **) & element->clock, (GstObject *) clock);
}
/**
*
* Returns: the #GstClock of the element.
*/
-GstClock*
-gst_element_get_clock (GstElement *element)
+GstClock *
+gst_element_get_clock (GstElement * element)
{
GstElementClass *oclass;
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
oclass = GST_ELEMENT_GET_CLASS (element);
-
+
if (oclass->get_clock)
return oclass->get_clock (element);
* Returns: the #GstClockReturn result of the wait operation.
*/
GstClockReturn
-gst_element_clock_wait (GstElement *element, GstClockID id, GstClockTimeDiff *jitter)
+gst_element_clock_wait (GstElement * element, GstClockID id,
+ GstClockTimeDiff * jitter)
{
GstClockReturn res;
if (GST_ELEMENT_SCHED (element)) {
GST_CAT_DEBUG (GST_CAT_CLOCK, "waiting on scheduler clock");
- res = gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id, jitter);
- }
- else {
+ res =
+ gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id,
+ jitter);
+ } else {
GST_CAT_DEBUG (GST_CAT_CLOCK, "no scheduler, returning GST_CLOCK_TIMEOUT");
res = GST_CLOCK_TIMEOUT;
}
return res;
}
+
#undef GST_CAT_DEFAULT
#define GST_CAT_DEFAULT GST_CAT_CLOCK
/**
* is no time available.
*/
GstClockTime
-gst_element_get_time (GstElement *element)
+gst_element_get_time (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE);
default:
g_assert_not_reached ();
return GST_CLOCK_TIME_NONE;
- }
+ }
}
/**
* Returns: TRUE on success
*/
gboolean
-gst_element_wait (GstElement *element, GstClockTime timestamp)
+gst_element_wait (GstElement * element, GstClockTime timestamp)
{
GstClockID id;
GstClockReturn ret;
-
+
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (GST_IS_CLOCK (element->clock), FALSE);
g_return_val_if_fail (element->current_state == GST_STATE_PLAYING, FALSE);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);
-
+
/* shortcut when we're already late... */
if (gst_element_get_time (element) >= timestamp) {
GST_INFO_OBJECT (element, "called gst_element_wait and was late");
return TRUE;
}
-
- id = gst_clock_new_single_shot_id (element->clock, element->base_time + timestamp);
+
+ id = gst_clock_new_single_shot_id (element->clock,
+ element->base_time + timestamp);
ret = gst_element_clock_wait (element, id, NULL);
gst_clock_id_free (id);
* more accurate.
*/
void
-gst_element_set_time (GstElement *element, GstClockTime time)
+gst_element_set_time (GstElement * element, GstClockTime time)
{
GstClockTime event_time;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (GST_IS_CLOCK (element->clock));
g_return_if_fail (element->current_state >= GST_STATE_PAUSED);
break;
case GST_STATE_PLAYING:
event_time = gst_clock_get_event_time (element->clock);
- GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element,
+ GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element,
"clock time %llu: setting element time to %llu", event_time, time);
element->base_time = event_time - time;
break;
* #GST_STATE_PLAYING. It is more accurate than gst_element_set_time().
*/
void
-gst_element_adjust_time (GstElement *element, GstClockTimeDiff diff)
+gst_element_adjust_time (GstElement * element, GstClockTimeDiff diff)
{
GstClockTime time;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (GST_IS_CLOCK (element->clock));
g_return_if_fail (element->current_state >= GST_STATE_PAUSED);
* Returns: TRUE if the element can be indexed.
*/
gboolean
-gst_element_is_indexable (GstElement *element)
+gst_element_is_indexable (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
* Set the specified GstIndex on the element.
*/
void
-gst_element_set_index (GstElement *element, GstIndex *index)
+gst_element_set_index (GstElement * element, GstIndex * index)
{
GstElementClass *oclass;
* Returns: a #GstIndex or NULL when no index was set on the
* element.
*/
-GstIndex*
-gst_element_get_index (GstElement *element)
+GstIndex *
+gst_element_get_index (GstElement * element)
{
GstElementClass *oclass;
* Returns: TRUE if the locks could be released.
*/
gboolean
-gst_element_release_locks (GstElement *element)
+gst_element_release_locks (GstElement * element)
{
GstElementClass *oclass;
if (oclass->release_locks)
return oclass->release_locks (element);
-
+
return TRUE;
}
* Pads are automatically activated when the element is in state PLAYING.
*/
void
-gst_element_add_pad (GstElement *element, GstPad *pad)
+gst_element_add_pad (GstElement * element, GstPad * pad)
{
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (GST_PAD_PARENT (pad) == NULL);
/* then check to see if there's already a pad by that name here */
- g_return_if_fail (gst_object_check_uniqueness (element->pads, GST_PAD_NAME(pad)) == TRUE);
+ g_return_if_fail (gst_object_check_uniqueness (element->pads,
+ GST_PAD_NAME (pad)) == TRUE);
GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, "adding pad '%s'",
- GST_STR_NULL (GST_OBJECT_NAME (pad)));
+ GST_STR_NULL (GST_OBJECT_NAME (pad)));
/* set the pad's parent */
gst_object_set_parent (GST_OBJECT (pad), GST_OBJECT (element));
element->numpads++;
switch (gst_pad_get_direction (pad)) {
- case GST_PAD_SRC:
- element->numsrcpads++;
- break;
- case GST_PAD_SINK:
- element->numsinkpads++;
- break;
- default:
- /* can happen for ghost pads */
- break;
+ case GST_PAD_SRC:
+ element->numsrcpads++;
+ break;
+ case GST_PAD_SINK:
+ element->numsinkpads++;
+ break;
+ default:
+ /* can happen for ghost pads */
+ break;
}
/* activate element when we are playing */
if (GST_STATE (element) == GST_STATE_PLAYING)
gst_pad_set_active (pad, TRUE);
-
+
/* emit the NEW_PAD signal */
g_signal_emit (G_OBJECT (element), gst_element_signals[NEW_PAD], 0, pad);
}
* Returns: the added ghost #GstPad, or NULL on error.
*/
GstPad *
-gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name)
+gst_element_add_ghost_pad (GstElement * element, GstPad * pad,
+ const gchar * name)
{
GstPad *ghostpad;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
/* then check to see if there's already a pad by that name here */
- g_return_val_if_fail (gst_object_check_uniqueness (element->pads, name) == TRUE, NULL);
+ g_return_val_if_fail (gst_object_check_uniqueness (element->pads,
+ name) == TRUE, NULL);
ghostpad = gst_ghost_pad_new (name, pad);
gst_element_add_pad (element, ghostpad);
-
+
return ghostpad;
}
* referenced elsewhere.
*/
void
-gst_element_remove_pad (GstElement *element, GstPad *pad)
+gst_element_remove_pad (GstElement * element, GstPad * pad)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
} else if (GST_IS_GHOST_PAD (pad)) {
g_object_set (pad, "real-pad", NULL, NULL);
}
-
+
/* remove it from the list */
element->pads = g_list_remove (element->pads, pad);
element->numpads--;
switch (gst_pad_get_direction (pad)) {
- case GST_PAD_SRC:
- element->numsrcpads--;
- break;
- case GST_PAD_SINK:
- element->numsinkpads--;
- break;
- default:
- /* can happen for ghost pads */
- break;
+ case GST_PAD_SRC:
+ element->numsrcpads--;
+ break;
+ case GST_PAD_SINK:
+ element->numsinkpads--;
+ break;
+ default:
+ /* can happen for ghost pads */
+ break;
}
g_signal_emit (G_OBJECT (element), gst_element_signals[PAD_REMOVED], 0, pad);
* instead.
*/
void
-gst_element_remove_ghost_pad (GstElement *element, GstPad *pad)
+gst_element_remove_ghost_pad (GstElement * element, GstPad * pad)
{
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (GST_IS_GHOST_PAD (pad));
g_warning ("gst_element_remove_ghost_pad is deprecated.\n"
- "Use gst_element_remove_pad instead.");
+ "Use gst_element_remove_pad instead.");
gst_element_remove_pad (element, pad);
}
*
* Returns: the #GstPad if found, otherwise %NULL.
*/
-GstPad*
-gst_element_get_pad (GstElement *element, const gchar *name)
+GstPad *
+gst_element_get_pad (GstElement * element, const gchar * name)
{
GstPad *pad;
g_return_val_if_fail (name != NULL, NULL);
pad = gst_element_get_static_pad (element, name);
- if (!pad)
+ if (!pad)
pad = gst_element_get_request_pad (element, name);
return pad;
* Returns: the requested #GstPad if found, otherwise NULL.
*/
GstPad *
-gst_element_get_static_pad (GstElement *element, const gchar *name)
+gst_element_get_static_pad (GstElement * element, const gchar * name)
{
GList *walk;
-
+
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);
walk = element->pads;
while (walk) {
GstPad *pad;
-
- pad = GST_PAD(walk->data);
- if (strcmp (GST_PAD_NAME(pad), name) == 0) {
- GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s", GST_DEBUG_PAD_NAME (pad));
+
+ pad = GST_PAD (walk->data);
+ if (strcmp (GST_PAD_NAME (pad), name) == 0) {
+ GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
return pad;
}
walk = g_list_next (walk);
}
- GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "no such pad '%s' in element \"%s\"", name, GST_OBJECT_NAME (element));
+ GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "no such pad '%s' in element \"%s\"",
+ name, GST_OBJECT_NAME (element));
return NULL;
}
*
* Returns: requested #GstPad if found, otherwise NULL.
*/
-GstPad*
-gst_element_get_request_pad (GstElement *element, const gchar *name)
+GstPad *
+gst_element_get_request_pad (GstElement * element, const gchar * name)
{
GstPadTemplate *templ = NULL;
GstPad *pad;
if (templ)
templ_found = TRUE;
} else {
- list = gst_element_get_pad_template_list(element);
+ list = gst_element_get_pad_template_list (element);
while (!templ_found && list) {
- templ = (GstPadTemplate*) list->data;
+ templ = (GstPadTemplate *) list->data;
if (templ->presence == GST_PAD_REQUEST) {
- /* Because of sanity checks in gst_pad_template_new(), we know that %s
- and %d, occurring at the end of the name_template, are the only
- possibilities. */
- GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, templ->name_template);
- if ((str = strchr (templ->name_template, '%')) &&
- strncmp (templ->name_template, name, str - templ->name_template) == 0 &&
- strlen (name) > str - templ->name_template) {
- data = name + (str - templ->name_template);
- if (*(str+1) == 'd') {
- /* it's an int */
- n = (gint) strtol (data, &endptr, 10);
- if (endptr && *endptr == '\0') {
- templ_found = TRUE;
- req_name = name;
- break;
- }
- } else {
- /* it's a string */
- templ_found = TRUE;
- req_name = name;
- break;
- }
- }
+ /* Because of sanity checks in gst_pad_template_new(), we know that %s
+ and %d, occurring at the end of the name_template, are the only
+ possibilities. */
+ GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name,
+ templ->name_template);
+ if ((str = strchr (templ->name_template, '%'))
+ && strncmp (templ->name_template, name,
+ str - templ->name_template) == 0
+ && strlen (name) > str - templ->name_template) {
+ data = name + (str - templ->name_template);
+ if (*(str + 1) == 'd') {
+ /* it's an int */
+ n = (gint) strtol (data, &endptr, 10);
+ if (endptr && *endptr == '\0') {
+ templ_found = TRUE;
+ req_name = name;
+ break;
+ }
+ } else {
+ /* it's a string */
+ templ_found = TRUE;
+ req_name = name;
+ break;
+ }
+ }
}
list = list->next;
}
}
-
+
if (!templ_found)
- return NULL;
-
+ return NULL;
+
pad = gst_element_request_pad (element, templ, req_name);
-
+
return pad;
}
*
* Returns: the #GList of pads.
*/
-const GList*
-gst_element_get_pad_list (GstElement *element)
+const GList *
+gst_element_get_pad_list (GstElement * element)
{
g_return_val_if_fail (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
* functions of classes.
*/
void
-gst_element_class_add_pad_template (GstElementClass *klass,
- GstPadTemplate *templ)
+gst_element_class_add_pad_template (GstElementClass * klass,
+ GstPadTemplate * templ)
{
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
g_return_if_fail (GST_IS_PAD_TEMPLATE (templ));
/* avoid registering pad templates with the same name */
- g_return_if_fail (gst_element_class_get_pad_template (klass, templ->name_template) == NULL);
-
+ g_return_if_fail (gst_element_class_get_pad_template (klass,
+ templ->name_template) == NULL);
+
klass->padtemplates = g_list_append (klass->padtemplates,
- gst_object_ref (GST_OBJECT (templ)));
+ gst_object_ref (GST_OBJECT (templ)));
klass->numpadtemplates++;
}
* Sets the detailed information for a #GstElementClass.
* <note>This function is for use in _base_init functions only.</note>
*/
-void
-gst_element_class_set_details (GstElementClass *klass, const GstElementDetails *details)
+void
+gst_element_class_set_details (GstElementClass * klass,
+ const GstElementDetails * details)
{
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
g_return_if_fail (GST_IS_ELEMENT_DETAILS (details));
-
+
__gst_element_details_copy (&klass->details, details);
}
*
* Returns: the #GList of padtemplates.
*/
-GList*
-gst_element_class_get_pad_template_list (GstElementClass *element_class)
+GList *
+gst_element_class_get_pad_template_list (GstElementClass * element_class)
{
g_return_val_if_fail (element_class != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT_CLASS (element_class), NULL);
* Returns: the #GstPadTemplate with the given name, or NULL if none was found.
* No unreferencing is necessary.
*/
-GstPadTemplate*
-gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name)
+GstPadTemplate *
+gst_element_class_get_pad_template (GstElementClass * element_class,
+ const gchar * name)
{
GList *padlist;
padlist = gst_element_class_get_pad_template_list (element_class);
while (padlist) {
- GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data;
+ GstPadTemplate *padtempl = (GstPadTemplate *) padlist->data;
if (strcmp (padtempl->name_template, name) == 0)
return padtempl;
*
* Returns: the #GList of padtemplates.
*/
-GList*
-gst_element_get_pad_template_list (GstElement *element)
+GList *
+gst_element_get_pad_template_list (GstElement * element)
{
g_return_val_if_fail (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
* Returns: the #GstPadTemplate with the given name, or NULL if none was found.
* No unreferencing is necessary.
*/
-GstPadTemplate*
-gst_element_get_pad_template (GstElement *element, const gchar *name)
+GstPadTemplate *
+gst_element_get_pad_template (GstElement * element, const gchar * name)
{
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);
return gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
- name);
+ name);
}
/**
* Returns: a compatible #GstPadTemplate, or NULL if none was found. No
* unreferencing is necessary.
*/
-GstPadTemplate*
-gst_element_get_compatible_pad_template (GstElement *element,
- GstPadTemplate *compattempl)
+GstPadTemplate *
+gst_element_get_compatible_pad_template (GstElement * element,
+ GstPadTemplate * compattempl)
{
GstPadTemplate *newtempl = NULL;
GList *padlist;
padlist = gst_element_get_pad_template_list (element);
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "Looking for a suitable pad template...");
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
+ "Looking for a suitable pad template...");
while (padlist) {
- GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data;
+ GstPadTemplate *padtempl = (GstPadTemplate *) padlist->data;
GstCaps *intersection;
/* Ignore name
* Check caps
*/
if (padtempl->direction != compattempl->direction) {
- GST_CAT_DEBUG (GST_CAT_CAPS, "compatible direction: found %s pad template \"%s\"",
- padtempl->direction == GST_PAD_SRC ? "src" : "sink",
- padtempl->name_template);
+ GST_CAT_DEBUG (GST_CAT_CAPS,
+ "compatible direction: found %s pad template \"%s\"",
+ padtempl->direction == GST_PAD_SRC ? "src" : "sink",
+ padtempl->name_template);
intersection = gst_caps_intersect (GST_PAD_TEMPLATE_CAPS (compattempl),
- GST_PAD_TEMPLATE_CAPS (padtempl));
+ GST_PAD_TEMPLATE_CAPS (padtempl));
- GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible", (intersection ? "" : "not "));
+ GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible",
+ (intersection ? "" : "not "));
if (!gst_caps_is_empty (intersection))
- newtempl = padtempl;
+ newtempl = padtempl;
gst_caps_free (intersection);
- if (newtempl) break;
+ if (newtempl)
+ break;
}
padlist = g_list_next (padlist);
*
* Returns: the #GstPad, or NULL if one could not be found or created.
*/
-static GstPad*
-gst_element_get_pad_from_template (GstElement *element, GstPadTemplate *templ)
+static GstPad *
+gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ)
{
GstPad *ret = NULL;
GstPadPresence presence;
-
+
/* If this function is ever exported, we need check the validity of `element'
* and `templ', and to make sure the template actually belongs to the
* element. */
presence = GST_PAD_TEMPLATE_PRESENCE (templ);
-
+
switch (presence) {
- case GST_PAD_ALWAYS:
- case GST_PAD_SOMETIMES:
- ret = gst_element_get_static_pad (element, templ->name_template);
- if (!ret && presence == GST_PAD_ALWAYS)
- g_warning ("Element %s has an ALWAYS template %s, but no pad of the same name",
- GST_OBJECT_NAME (element), templ->name_template);
- break;
-
- case GST_PAD_REQUEST:
- ret = gst_element_request_pad (element, templ, NULL);
- break;
- }
-
+ case GST_PAD_ALWAYS:
+ case GST_PAD_SOMETIMES:
+ ret = gst_element_get_static_pad (element, templ->name_template);
+ if (!ret && presence == GST_PAD_ALWAYS)
+ g_warning
+ ("Element %s has an ALWAYS template %s, but no pad of the same name",
+ GST_OBJECT_NAME (element), templ->name_template);
+ break;
+
+ case GST_PAD_REQUEST:
+ ret = gst_element_request_pad (element, templ, NULL);
+ break;
+ }
+
return ret;
}
*
* Returns: a #GstPad, or %NULL if one could not be found or created.
*/
-GstPad*
-gst_element_request_compatible_pad (GstElement *element, GstPadTemplate *templ)
+GstPad *
+gst_element_request_compatible_pad (GstElement * element,
+ GstPadTemplate * templ)
{
GstPadTemplate *templ_new;
GstPad *pad = NULL;
* Returns: the #GstPad to which a link can be made, or %NULL if one cannot be
* found.
*/
-GstPad*
-gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
- const GstCaps *filtercaps)
+GstPad *
+gst_element_get_compatible_pad_filtered (GstElement * element, GstPad * pad,
+ const GstCaps * filtercaps)
{
const GList *pads;
GstPadTemplate *templ;
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "finding pad in %s compatible with %s:%s",
- GST_ELEMENT_NAME (element), GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
+ "finding pad in %s compatible with %s:%s", GST_ELEMENT_NAME (element),
+ GST_DEBUG_PAD_NAME (pad));
/* let's use the real pad */
pad = (GstPad *) GST_PAD_REALIZE (pad);
pads = gst_element_get_pad_list (element);
while (pads) {
GstPad *current = GST_PAD (pads->data);
+
if (GST_PAD_PEER (current) == NULL &&
- gst_pad_can_link_filtered (pad, current, filtercaps)) {
+ gst_pad_can_link_filtered (pad, current, filtercaps)) {
return current;
}
pads = g_list_next (pads);
templcaps = gst_pad_get_caps (pad);
if (filtercaps != NULL) {
GstCaps *temp;
+
temp = gst_caps_intersect (filtercaps, templcaps);
gst_caps_free (templcaps);
templcaps = temp;
foundpad = gst_element_request_compatible_pad (element, templ);
gst_object_unref (GST_OBJECT (templ));
- if (foundpad) return foundpad;
+ if (foundpad)
+ return foundpad;
GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element,
- "Could not find a compatible pad to link to %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ "Could not find a compatible pad to link to %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
return NULL;
}
* Returns: the #GstPad to which a link can be made, or %NULL if one
* could not be found.
*/
-GstPad*
-gst_element_get_compatible_pad (GstElement *element, GstPad *pad)
+GstPad *
+gst_element_get_compatible_pad (GstElement * element, GstPad * pad)
{
return gst_element_get_compatible_pad_filtered (element, pad, NULL);
}
* Returns: TRUE if the pads could be linked, FALSE otherwise.
*/
gboolean
-gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname,
- const GstCaps *filtercaps)
+gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
+ GstElement * dest, const gchar * destpadname, const GstCaps * filtercaps)
{
const GList *srcpads, *destpads, *srctempls, *desttempls, *l;
GstPad *srcpad, *destpad;
g_return_val_if_fail (GST_IS_ELEMENT (src), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (dest), FALSE);
- GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "trying to link element %s:%s to element %s:%s",
- GST_ELEMENT_NAME (src), srcpadname ? srcpadname : "(any)",
- GST_ELEMENT_NAME (dest), destpadname ? destpadname : "(any)");
+ GST_CAT_INFO (GST_CAT_ELEMENT_PADS,
+ "trying to link element %s:%s to element %s:%s", GST_ELEMENT_NAME (src),
+ srcpadname ? srcpadname : "(any)", GST_ELEMENT_NAME (dest),
+ destpadname ? destpadname : "(any)");
/* now get the pads we're trying to link and a list of all remaining pads */
if (srcpadname) {
srcpad = gst_element_get_pad (src, srcpadname);
if (!srcpad) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_ELEMENT_NAME (src), srcpadname);
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
+ GST_ELEMENT_NAME (src), srcpadname);
return FALSE;
} else {
if (!(GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC)) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad", GST_DEBUG_PAD_NAME (srcpad));
- return FALSE;
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad",
+ GST_DEBUG_PAD_NAME (srcpad));
+ return FALSE;
}
if (GST_PAD_PEER (srcpad) != NULL) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_DEBUG_PAD_NAME (srcpad));
- return FALSE;
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked",
+ GST_DEBUG_PAD_NAME (srcpad));
+ return FALSE;
}
- }
+ }
srcpads = NULL;
} else {
srcpads = gst_element_get_pad_list (src);
if (destpadname) {
destpad = gst_element_get_pad (dest, destpadname);
if (!destpad) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_ELEMENT_NAME (dest), destpadname);
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
+ GST_ELEMENT_NAME (dest), destpadname);
return FALSE;
} else {
if (!(GST_PAD_DIRECTION (destpad) == GST_PAD_SINK)) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad", GST_DEBUG_PAD_NAME (destpad));
- return FALSE;
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad",
+ GST_DEBUG_PAD_NAME (destpad));
+ return FALSE;
}
if (GST_PAD_PEER (destpad) != NULL) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_DEBUG_PAD_NAME (destpad));
- return FALSE;
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked",
+ GST_DEBUG_PAD_NAME (destpad));
+ return FALSE;
}
}
destpads = NULL;
if (srcpad) {
/* loop through the allowed pads in the source, trying to find a
* compatible destination pad */
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "looping through allowed src and dest pads");
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
+ "looping through allowed src and dest pads");
do {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s",
- GST_DEBUG_PAD_NAME (srcpad));
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad));
if ((GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC) &&
- (GST_PAD_PEER (srcpad) == NULL)) {
- GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad,
- filtercaps);
- if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp));
- return TRUE;
- }
+ (GST_PAD_PEER (srcpad) == NULL)) {
+ GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad,
+ filtercaps);
+
+ if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) {
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp));
+ return TRUE;
+ }
}
/* find a better way for this mess */
if (srcpads) {
srcpads = g_list_next (srcpads);
- if (srcpads)
+ if (srcpads)
srcpad = (GstPad *) GST_PAD_REALIZE (srcpads->data);
}
} while (srcpads);
}
if (srcpadname) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s",
- GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest));
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest));
return FALSE;
}
- if (destpad) {
+ if (destpad) {
/* loop through the existing pads in the destination */
do {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s",
- GST_DEBUG_PAD_NAME (destpad));
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s",
+ GST_DEBUG_PAD_NAME (destpad));
if ((GST_PAD_DIRECTION (destpad) == GST_PAD_SINK) &&
- (GST_PAD_PEER (destpad) == NULL)) {
- GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad,
- filtercaps);
- if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
- GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad));
- return TRUE;
- }
+ (GST_PAD_PEER (destpad) == NULL)) {
+ GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad,
+ filtercaps);
+
+ if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) {
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
+ GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad));
+ return TRUE;
+ }
}
if (destpads) {
destpads = g_list_next (destpads);
- if (destpads)
+ if (destpads)
destpad = (GstPad *) GST_PAD_REALIZE (destpads->data);
}
} while (destpads);
}
if (destpadname) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s",
- GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad));
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s",
+ GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad));
return FALSE;
}
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
- "we might have request pads on both sides, checking...");
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
+ "we might have request pads on both sides, checking...");
srctempls = gst_element_get_pad_template_list (src);
desttempls = gst_element_get_pad_template_list (dest);
-
+
if (srctempls && desttempls) {
while (srctempls) {
- srctempl = (GstPadTemplate*) srctempls->data;
+ srctempl = (GstPadTemplate *) srctempls->data;
if (srctempl->presence == GST_PAD_REQUEST) {
- for (l=desttempls; l; l=l->next) {
- desttempl = (GstPadTemplate*) l->data;
- if (desttempl->presence == GST_PAD_REQUEST &&
+ for (l = desttempls; l; l = l->next) {
+ desttempl = (GstPadTemplate *) l->data;
+ if (desttempl->presence == GST_PAD_REQUEST &&
desttempl->direction != srctempl->direction) {
- if (gst_caps_is_always_compatible (gst_pad_template_get_caps (srctempl),
- gst_pad_template_get_caps (desttempl))) {
- srcpad = gst_element_get_request_pad (src,
- srctempl->name_template);
- destpad = gst_element_get_request_pad (dest,
- desttempl->name_template);
- if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
- "linked pad %s:%s to pad %s:%s",
- GST_DEBUG_PAD_NAME (srcpad),
- GST_DEBUG_PAD_NAME (destpad));
- return TRUE;
- }
- /* it failed, so we release the request pads */
- gst_element_release_request_pad (src, srcpad);
- gst_element_release_request_pad (dest, destpad);
- }
- }
- }
+ if (gst_caps_is_always_compatible (gst_pad_template_get_caps
+ (srctempl), gst_pad_template_get_caps (desttempl))) {
+ srcpad =
+ gst_element_get_request_pad (src, srctempl->name_template);
+ destpad =
+ gst_element_get_request_pad (dest, desttempl->name_template);
+ if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) {
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
+ "linked pad %s:%s to pad %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad));
+ return TRUE;
+ }
+ /* it failed, so we release the request pads */
+ gst_element_release_request_pad (src, srcpad);
+ gst_element_release_request_pad (dest, destpad);
+ }
+ }
+ }
}
srctempls = srctempls->next;
}
}
-
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s",
- GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest));
- return FALSE;
+
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s",
+ GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest));
+ return FALSE;
}
/**
* Returns: TRUE if the elements could be linked, FALSE otherwise.
*/
gboolean
-gst_element_link_filtered (GstElement *src, GstElement *dest,
- const GstCaps *filtercaps)
+gst_element_link_filtered (GstElement * src, GstElement * dest,
+ const GstCaps * filtercaps)
{
return gst_element_link_pads_filtered (src, NULL, dest, NULL, filtercaps);
}
* Returns: TRUE on success, FALSE otherwise.
*/
gboolean
-gst_element_link_many (GstElement *element_1, GstElement *element_2, ...)
+gst_element_link_many (GstElement * element_1, GstElement * element_2, ...)
{
va_list args;
g_return_val_if_fail (element_1 != NULL && element_2 != NULL, FALSE);
- g_return_val_if_fail (GST_IS_ELEMENT (element_1) &&
- GST_IS_ELEMENT (element_2), FALSE);
+ g_return_val_if_fail (GST_IS_ELEMENT (element_1) &&
+ GST_IS_ELEMENT (element_2), FALSE);
va_start (args, element_2);
while (element_2) {
if (!gst_element_link (element_1, element_2))
return FALSE;
-
+
element_1 = element_2;
- element_2 = va_arg (args, GstElement*);
+ element_2 = va_arg (args, GstElement *);
}
va_end (args);
-
+
return TRUE;
}
* Returns: TRUE if the elements could be linked, FALSE otherwise.
*/
gboolean
-gst_element_link (GstElement *src, GstElement *dest)
+gst_element_link (GstElement * src, GstElement * dest)
{
return gst_element_link_pads_filtered (src, NULL, dest, NULL, NULL);
}
* Returns: TRUE if the pads could be linked, FALSE otherwise.
*/
gboolean
-gst_element_link_pads (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname)
+gst_element_link_pads (GstElement * src, const gchar * srcpadname,
+ GstElement * dest, const gchar * destpadname)
{
- return gst_element_link_pads_filtered (src, srcpadname, dest, destpadname, NULL);
+ return gst_element_link_pads_filtered (src, srcpadname, dest, destpadname,
+ NULL);
}
/**
* Unlinks the two named pads of the source and destination elements.
*/
void
-gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname)
+gst_element_unlink_pads (GstElement * src, const gchar * srcpadname,
+ GstElement * dest, const gchar * destpadname)
{
- GstPad *srcpad,*destpad;
+ GstPad *srcpad, *destpad;
g_return_if_fail (src != NULL);
- g_return_if_fail (GST_IS_ELEMENT(src));
+ 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 (GST_IS_ELEMENT (dest));
g_return_if_fail (destpadname != NULL);
/* obtain the pads requested */
}
destpad = gst_element_get_pad (dest, destpadname);
if (srcpad == NULL) {
- GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"", destpadname);
+ GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"",
+ destpadname);
return;
}
/* we're satisified they can be unlinked, let's do it */
- gst_pad_unlink (srcpad,destpad);
+ gst_pad_unlink (srcpad, destpad);
}
/**
* Unlinks a series of elements. Uses gst_element_unlink().
*/
void
-gst_element_unlink_many (GstElement *element_1, GstElement *element_2, ...)
+gst_element_unlink_many (GstElement * element_1, GstElement * element_2, ...)
{
va_list args;
while (element_2) {
gst_element_unlink (element_1, element_2);
-
+
element_1 = element_2;
- element_2 = va_arg (args, GstElement*);
+ element_2 = va_arg (args, GstElement *);
}
va_end (args);
* of the sink element to which they are linked.
*/
void
-gst_element_unlink (GstElement *src, GstElement *dest)
+gst_element_unlink (GstElement * src, GstElement * dest)
{
const GList *srcpads;
GstPad *pad;
g_return_if_fail (GST_IS_ELEMENT (dest));
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "unlinking \"%s\" and \"%s\"",
- GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest));
+ GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest));
srcpads = gst_element_get_pad_list (src);
/* see if the pad is connected and is really a pad
* of dest */
- if (peerpad &&
- (GST_OBJECT_PARENT (peerpad) == (GstObject*) dest))
- {
- gst_pad_unlink (pad, peerpad);
+ if (peerpad && (GST_OBJECT_PARENT (peerpad) == (GstObject *) dest)) {
+ gst_pad_unlink (pad, peerpad);
}
}
}
static void
-gst_element_error_func (GstElement* element, GstElement *source,
- GError *error, gchar *debug)
+gst_element_error_func (GstElement * element, GstElement * source,
+ GError * error, gchar * debug)
{
/* tell the parent */
if (GST_OBJECT_PARENT (element)) {
- GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarding error \"%s\" from %s to %s",
- error->message, GST_ELEMENT_NAME (element),
- GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
+ GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM,
+ "forwarding error \"%s\" from %s to %s", error->message,
+ GST_ELEMENT_NAME (element),
+ GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
gst_object_ref (GST_OBJECT (element));
g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)),
- gst_element_signals[ERROR], 0, source, error, debug);
+ gst_element_signals[ERROR], 0, source, error, debug);
gst_object_unref (GST_OBJECT (element));
- GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s",
- error->message, GST_ELEMENT_NAME (element),
- GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
+ GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s",
+ error->message, GST_ELEMENT_NAME (element),
+ GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
}
}
-static GstPad*
-gst_element_get_random_pad (GstElement *element, GstPadDirection dir)
+static GstPad *
+gst_element_get_random_pad (GstElement * element, GstPadDirection dir)
{
GList *pads = element->pads;
+
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "getting a random pad");
while (pads) {
GstPad *pad = GST_PAD (pads->data);
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "checking pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
if (GST_PAD_DIRECTION (pad) == dir) {
if (GST_PAD_IS_LINKED (pad)) {
return pad;
+ } else {
+ GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked",
+ GST_DEBUG_PAD_NAME (pad));
}
- else {
- GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked",
- GST_DEBUG_PAD_NAME (pad));
- }
- }
- else {
+ } else {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is in wrong direction",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
}
pads = g_list_next (pads);
*
* Returns: An array of #GstEventMask elements.
*/
-const GstEventMask*
-gst_element_get_event_masks (GstElement *element)
+const GstEventMask *
+gst_element_get_event_masks (GstElement * element)
{
GstElementClass *oclass;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
-
+
oclass = GST_ELEMENT_GET_CLASS (element);
if (oclass->get_event_masks)
return oclass->get_event_masks (element);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
+
if (pad)
return gst_pad_get_event_masks (GST_PAD_PEER (pad));
}
* Returns: TRUE if the event was handled.
*/
gboolean
-gst_element_send_event (GstElement *element, GstEvent *event)
+gst_element_send_event (GstElement * element, GstEvent * event)
{
GstElementClass *oclass;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
oclass = GST_ELEMENT_GET_CLASS (element);
if (oclass->send_event)
return oclass->send_event (element, event);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
+
if (pad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "sending event to random pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
return gst_pad_send_event (GST_PAD_PEER (pad), event);
}
}
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "can't send event on element %s",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
return FALSE;
}
* Returns: TRUE if the event was handled.
*/
gboolean
-gst_element_seek (GstElement *element,
- GstSeekType seek_type,
- guint64 offset)
+gst_element_seek (GstElement * element, GstSeekType seek_type, guint64 offset)
{
GstEvent *event = gst_event_new_seek (seek_type, offset);
*
* Returns: An array of #GstQueryType elements.
*/
-const GstQueryType*
-gst_element_get_query_types (GstElement *element)
+const GstQueryType *
+gst_element_get_query_types (GstElement * element)
{
GstElementClass *oclass;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
-
+
oclass = GST_ELEMENT_GET_CLASS (element);
if (oclass->get_query_types)
return oclass->get_query_types (element);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
+
if (pad)
return gst_pad_get_query_types (GST_PAD_PEER (pad));
}
* Returns: TRUE if the query could be performed.
*/
gboolean
-gst_element_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_element_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstElementClass *oclass;
g_return_val_if_fail (value != NULL, FALSE);
oclass = GST_ELEMENT_GET_CLASS (element);
-
+
if (oclass->query)
return oclass->query (element, type, format, value);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SRC);
+
if (pad)
return gst_pad_query (pad, type, format, value);
pad = gst_element_get_random_pad (element, GST_PAD_SINK);
*
* Returns: An array of #GstFormat elements.
*/
-const GstFormat*
-gst_element_get_formats (GstElement *element)
+const GstFormat *
+gst_element_get_formats (GstElement * element)
{
GstElementClass *oclass;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
-
+
oclass = GST_ELEMENT_GET_CLASS (element);
if (oclass->get_formats)
return oclass->get_formats (element);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
+
if (pad)
return gst_pad_get_formats (GST_PAD_PEER (pad));
}
* Returns: TRUE if the conversion could be performed.
*/
gboolean
-gst_element_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_element_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
GstElementClass *oclass;
if (oclass->convert)
return oclass->convert (element,
- src_format, src_value,
- dest_format, dest_value);
+ src_format, src_value, dest_format, dest_value);
else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
+
if (pad)
- return gst_pad_convert (GST_PAD_PEER (pad),
- src_format, src_value,
- dest_format, dest_value);
+ return gst_pad_convert (GST_PAD_PEER (pad),
+ src_format, src_value, dest_format, dest_value);
}
return FALSE;
* Returns: a newly allocated string, or NULL if the format was NULL or ""
*/
gchar *
-_gst_element_error_printf (const gchar *format, ...)
+_gst_element_error_printf (const gchar * format, ...)
{
va_list args;
gchar *buffer;
- if (format == NULL) return NULL;
- if (format[0] == 0) return NULL;
+ if (format == NULL)
+ return NULL;
+ if (format[0] == 0)
+ return NULL;
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
* This function is used internally by elements.
* It results in the "error" signal.
*/
-void
-gst_element_error_full
-(GstElement *element, GQuark domain, gint code, gchar *message, gchar *debug,
- const gchar *file, const gchar *function, gint line)
+void gst_element_error_full
+ (GstElement * element, GQuark domain, gint code, gchar * message,
+ gchar * debug, const gchar * file, const gchar * function, gint line)
{
GError *error = NULL;
gchar *name;
g_return_if_fail (GST_IS_ELEMENT (element));
/* check if we send the given message or the default error message */
- if ((message == NULL) || (message[0] == 0))
- {
+ if ((message == NULL) || (message[0] == 0)) {
/* we got this message from g_strdup_printf (""); */
g_free (message);
sent_message = gst_error_get_message (domain, code);
- }
- else
+ } else
sent_message = message;
- if ((debug == NULL) || (debug[0] == 0))
- {
+ if ((debug == NULL) || (debug[0] == 0)) {
/* we got this debug from g_strdup_printf (""); */
g_free (debug);
debug = NULL;
}
-
+
/* create error message */
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signaling error in %s: %s",
- GST_ELEMENT_NAME (element),
- sent_message);
+ GST_ELEMENT_NAME (element), sent_message);
error = g_error_new (domain, code, sent_message);
/* if the element was already in error, stop now */
if (GST_FLAG_IS_SET (element, GST_ELEMENT_IN_ERROR)) {
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "recursive ERROR detected in %s",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
g_free (sent_message);
- if (debug) g_free (debug);
+ if (debug)
+ g_free (debug);
return;
}
name = gst_object_get_path_string (GST_OBJECT (element));
if (debug)
sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s",
- file, line, function, name,
- debug ? debug : "");
+ file, line, function, name, debug ? debug : "");
else
sent_debug = NULL;
g_free (debug);
g_free (name);
g_signal_emit (G_OBJECT (element), gst_element_signals[ERROR], 0, element,
- error, sent_debug);
+ error, sent_debug);
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signalled error in %s: %s",
- GST_ELEMENT_NAME (element),
- sent_message);
+ GST_ELEMENT_NAME (element), sent_message);
- /* tell the scheduler */
+ /* tell the scheduler */
if (element->sched) {
gst_scheduler_error (element->sched, element);
}
ret = gst_element_set_state (element, GST_STATE_PAUSED);
if (ret != GST_STATE_SUCCESS) {
g_warning ("could not PAUSE element \"%s\" after error, help!",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
}
}
* Returns: TRUE, if the element's state is locked.
*/
gboolean
-gst_element_is_locked_state (GstElement *element)
+gst_element_is_locked_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
return GST_FLAG_IS_SET (element, GST_ELEMENT_LOCKED_STATE) ? TRUE : FALSE;
}
+
/**
* gst_element_set_locked_state:
* @element: a #GstElement
* this element anymore.
*/
void
-gst_element_set_locked_state (GstElement *element, gboolean locked_state)
+gst_element_set_locked_state (GstElement * element, gboolean locked_state)
{
gboolean old;
return;
if (locked_state) {
- GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s",
- GST_ELEMENT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s",
+ GST_ELEMENT_NAME (element));
GST_FLAG_SET (element, GST_ELEMENT_LOCKED_STATE);
} else {
- GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s",
- GST_ELEMENT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s",
+ GST_ELEMENT_NAME (element));
GST_FLAG_UNSET (element, GST_ELEMENT_LOCKED_STATE);
}
}
+
/**
* gst_element_sync_state_with_parent:
* @element: a #GstElement.
* Returns: TRUE, if the element's state could be synced to the parent's state.
*/
gboolean
-gst_element_sync_state_with_parent (GstElement *element)
+gst_element_sync_state_with_parent (GstElement * element)
{
GstElement *parent;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
- parent = GST_ELEMENT (GST_ELEMENT_PARENT(element));
+ parent = GST_ELEMENT (GST_ELEMENT_PARENT (element));
g_return_val_if_fail (GST_IS_BIN (parent), FALSE);
-
- GST_CAT_DEBUG (GST_CAT_STATES, "syncing state of element %s (%s) to %s (%s)",
- GST_ELEMENT_NAME (element), gst_element_state_get_name (GST_STATE (element)),
- GST_ELEMENT_NAME (parent), gst_element_state_get_name (GST_STATE (parent)));
+
+ GST_CAT_DEBUG (GST_CAT_STATES, "syncing state of element %s (%s) to %s (%s)",
+ GST_ELEMENT_NAME (element),
+ gst_element_state_get_name (GST_STATE (element)),
+ GST_ELEMENT_NAME (parent),
+ gst_element_state_get_name (GST_STATE (parent)));
if (gst_element_set_state (element, GST_STATE (parent)) == GST_STATE_FAILURE) {
return FALSE;
}
return TRUE;
}
+
/**
* gst_element_get_state:
* @element: a #GstElement to get the state of.
* Returns: the #GstElementState of the element.
*/
GstElementState
-gst_element_get_state (GstElement *element)
+gst_element_get_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_VOID_PENDING);
* Waits and blocks until the element changed its state.
*/
void
-gst_element_wait_state_change (GstElement *element)
+gst_element_wait_state_change (GstElement * element)
{
g_mutex_lock (element->state_mutex);
g_cond_wait (element->state_cond, element->state_mutex);
* (using #GstElementStateReturn).
*/
GstElementStateReturn
-gst_element_set_state (GstElement *element, GstElementState state)
+gst_element_set_state (GstElement * element, GstElementState state)
{
GstElementClass *oclass;
GstElementState curpending;
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
/* start with the current state */
- curpending = GST_STATE(element);
+ curpending = GST_STATE (element);
- if (state == curpending)
- {
+ if (state == curpending) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "element is already in requested state %s",
- gst_element_state_get_name (state));
+ "element is already in requested state %s",
+ gst_element_state_get_name (state));
return (GST_STATE_SUCCESS);
}
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "setting state from %s to %s",
- gst_element_state_get_name (curpending),
- gst_element_state_get_name (state));
+ gst_element_state_get_name (curpending),
+ gst_element_state_get_name (state));
/* loop until the final requested state is set */
- while (GST_STATE (element) != state
+ while (GST_STATE (element) != state
&& GST_STATE (element) != GST_STATE_VOID_PENDING) {
/* move the curpending state in the correct direction */
- if (curpending < state)
+ if (curpending < state)
curpending <<= 1;
- else
+ else
curpending >>= 1;
/* set the pending state variable */
GST_STATE_PENDING (element) = curpending;
if (curpending != state) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "intermediate: setting state from %s to %s",
- gst_element_state_get_name (GST_STATE (element)),
- gst_element_state_get_name (curpending));
+ GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
+ "intermediate: setting state from %s to %s",
+ gst_element_state_get_name (GST_STATE (element)),
+ gst_element_state_get_name (curpending));
}
/* call the state change function so it can set the state */
switch (return_val) {
case GST_STATE_FAILURE:
- GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
- "have failed change_state return");
- goto exit;
+ GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+ "have failed change_state return");
+ goto exit;
case GST_STATE_ASYNC:
- GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
- "element will change state async");
- goto exit;
+ GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+ "element will change state async");
+ goto exit;
case GST_STATE_SUCCESS:
- /* Last thing we do is verify that a successful state change really
- * did change the state... */
- /* if it did not, this is an error - fix the element that does this */
+ /* Last thing we do is verify that a successful state change really
+ * did change the state... */
+ /* if it did not, this is an error - fix the element that does this */
if (GST_STATE (element) != curpending) {
g_warning ("element %s claimed state-change success,"
- "but state didn't change to %s. State is %s (%s pending), fix the element",
- GST_ELEMENT_NAME (element),
- gst_element_state_get_name (curpending),
- gst_element_state_get_name (GST_STATE (element)),
- gst_element_state_get_name (GST_STATE_PENDING (element)));
+ "but state didn't change to %s. State is %s (%s pending), fix the element",
+ GST_ELEMENT_NAME (element),
+ gst_element_state_get_name (curpending),
+ gst_element_state_get_name (GST_STATE (element)),
+ gst_element_state_get_name (GST_STATE_PENDING (element)));
return_val = GST_STATE_FAILURE;
- goto exit;
+ goto exit;
}
- break;
+ break;
default:
/* somebody added a GST_STATE_ and forgot to do stuff here ! */
g_assert_not_reached ();
}
static gboolean
-gst_element_negotiate_pads (GstElement *element)
+gst_element_negotiate_pads (GstElement * element)
{
GList *pads = GST_ELEMENT_PADS (element);
GstRealPad *srcpad;
pads = g_list_next (pads);
-
+
if (!GST_IS_REAL_PAD (pad))
continue;
GstRealPad *sinkpad;
GstElementState otherstate;
GstElement *parent;
-
+
sinkpad = GST_RPAD_PEER (GST_PAD_REALIZE (srcpad));
/* check the parent of the peer pad, if there is no parent do nothing */
parent = GST_PAD_PARENT (sinkpad);
- if (!parent)
+ if (!parent)
continue;
/* skips pads that were already negotiating */
if (GST_FLAG_IS_SET (sinkpad, GST_PAD_NEGOTIATING) ||
- GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING))
+ GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING))
continue;
otherstate = GST_STATE (parent);
/* swap pads if needed */
if (!GST_PAD_IS_SRC (srcpad)) {
- GstRealPad *temp;
+ GstRealPad *temp;
temp = srcpad;
srcpad = sinkpad;
/* only try to negotiate if the peer element is in PAUSED or higher too */
if (otherstate >= GST_STATE_READY) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
- "perform negotiate for %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad),
- GST_DEBUG_PAD_NAME (sinkpad));
- if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED)
+ GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
+ "perform negotiate for %s:%s and %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED)
return FALSE;
- }
- else {
- GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
- "not negotiating %s:%s and %s:%s, not in READY yet",
- GST_DEBUG_PAD_NAME (srcpad),
- GST_DEBUG_PAD_NAME (sinkpad));
+ } else {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
+ "not negotiating %s:%s and %s:%s, not in READY yet",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
}
}
}
}
static void
-gst_element_clear_pad_caps (GstElement *element)
+gst_element_clear_pad_caps (GstElement * element)
{
GList *pads = GST_ELEMENT_PADS (element);
GstPad *pad = GST_PAD (pads->data);
gst_pad_unnegotiate (pad);
- if (GST_IS_REAL_PAD (pad)){
+ if (GST_IS_REAL_PAD (pad)) {
gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL);
}
}
static void
-gst_element_pads_activate (GstElement *element, gboolean active)
+gst_element_pads_activate (GstElement * element, gboolean active)
{
GList *pads = element->pads;
while (pads) {
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
if (!GST_IS_REAL_PAD (pad))
}
static GstElementStateReturn
-gst_element_change_state (GstElement *element)
+gst_element_change_state (GstElement * element)
{
GstElementState old_state;
GstObject *parent;
old_pending = GST_STATE_PENDING (element);
old_transition = GST_STATE_TRANSITION (element);
- if (old_pending == GST_STATE_VOID_PENDING ||
+ if (old_pending == GST_STATE_VOID_PENDING ||
old_state == GST_STATE_PENDING (element)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
- "element is already in the %s state",
- gst_element_state_get_name (old_state));
+ "element is already in the %s state",
+ gst_element_state_get_name (old_state));
return GST_STATE_SUCCESS;
}
-
+
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
- "default handler sets state from %s to %s %04x",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (old_pending),
- old_transition);
+ "default handler sets state from %s to %s %04x",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (old_pending), old_transition);
/* we set the state change early for the negotiation functions */
GST_STATE (element) = old_pending;
case GST_STATE_PLAYING_TO_PAUSED:
if (element->clock) {
GstClockTime time = gst_clock_get_event_time (element->clock);
+
g_assert (time >= element->base_time);
element->base_time = time - element->base_time;
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %"
gst_element_pads_activate (element, TRUE);
if (element->clock) {
GstClockTime time = gst_clock_get_event_time (element->clock);
+
element->base_time = time - element->base_time;
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %"
G_GINT64_FORMAT, element->base_time);
}
break;
- /* if we are going to paused, we try to negotiate the pads */
+ /* if we are going to paused, we try to negotiate the pads */
case GST_STATE_READY_TO_PAUSED:
g_assert (element->base_time == 0);
- if (!gst_element_negotiate_pads (element))
- goto failure;
+ if (!gst_element_negotiate_pads (element))
+ goto failure;
break;
- /* going to the READY state clears all pad caps */
- /* FIXME: Why doesn't this happen on READY => NULL? -- Company */
+ /* going to the READY state clears all pad caps */
+ /* FIXME: Why doesn't this happen on READY => NULL? -- Company */
case GST_STATE_PAUSED_TO_READY:
element->base_time = 0;
gst_element_clear_pad_caps (element);
parent = GST_ELEMENT_PARENT (element);
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
- "signaling state change from %s to %s",
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (GST_STATE (element)));
+ "signaling state change from %s to %s",
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (GST_STATE (element)));
/* tell the scheduler if we have one */
if (element->sched) {
- if (gst_scheduler_state_transition (element->sched, element,
- old_transition) != GST_STATE_SUCCESS) {
- GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
- "scheduler could not change state");
+ if (gst_scheduler_state_transition (element->sched, element,
+ old_transition) != GST_STATE_SUCCESS) {
+ GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
+ "scheduler could not change state");
goto failure;
}
}
/* tell our parent about the state change */
if (parent && GST_IS_BIN (parent)) {
- gst_bin_child_state_change (GST_BIN (parent), old_state,
- GST_STATE (element), element);
+ gst_bin_child_state_change (GST_BIN (parent), old_state,
+ GST_STATE (element), element);
}
/* at this point the state of the element could have changed again */
g_signal_emit (G_OBJECT (element), gst_element_signals[STATE_CHANGE],
- 0, old_state, GST_STATE (element));
+ 0, old_state, GST_STATE (element));
/* signal the state change in case somebody is waiting for us */
g_mutex_lock (element->state_mutex);
*
* Returns: the #GstElementFactory used for creating this element.
*/
-GstElementFactory*
-gst_element_get_factory (GstElement *element)
+GstElementFactory *
+gst_element_get_factory (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
-
+
return GST_ELEMENT_GET_CLASS (element)->elementfactory;
}
static void
-gst_element_dispose (GObject *object)
+gst_element_dispose (GObject * object)
{
GstElement *element = GST_ELEMENT (object);
GList *pads;
/* first we break all our links with the ouside */
if (element->pads) {
GList *orig;
+
orig = pads = g_list_copy (element->pads);
while (pads) {
pad = GST_PAD (pads->data);
if (GST_PAD_PEER (pad)) {
- GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'",
- GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad)))));
- gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad)));
+ GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'",
+ GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad)))));
+ gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad)));
}
gst_element_remove_pad (element, pad);
g_mutex_free (element->property_mutex);
element->property_mutex = NULL;
- gst_object_replace ((GstObject **)&element->sched, NULL);
- gst_object_replace ((GstObject **)&element->clock, NULL);
+ gst_object_replace ((GstObject **) & element->sched, NULL);
+ gst_object_replace ((GstObject **) & element->clock, NULL);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
* Returns: the new #xmlNodePtr.
*/
static xmlNodePtr
-gst_element_save_thyself (GstObject *object,
- xmlNodePtr parent)
+gst_element_save_thyself (GstObject * object, xmlNodePtr parent)
{
GList *pads;
GstElementClass *oclass;
oclass = GST_ELEMENT_GET_CLASS (element);
- xmlNewChild(parent, NULL, "name", GST_ELEMENT_NAME(element));
+ xmlNewChild (parent, NULL, "name", GST_ELEMENT_NAME (element));
if (oclass->elementfactory != NULL) {
- GstElementFactory *factory = (GstElementFactory *)oclass->elementfactory;
+ GstElementFactory *factory = (GstElementFactory *) oclass->elementfactory;
- xmlNewChild (parent, NULL, "type",
- GST_PLUGIN_FEATURE (factory)->name);
+ xmlNewChild (parent, NULL, "type", GST_PLUGIN_FEATURE (factory)->name);
}
-/* FIXME: what is this? */
+/* FIXME: what is this? */
/* if (element->manager) */
/* xmlNewChild(parent, NULL, "manager", GST_ELEMENT_NAME(element->manager)); */
/* params */
specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &nspecs);
-
- for (i=0; i<nspecs; i++) {
+
+ for (i = 0; i < nspecs; i++) {
spec = specs[i];
if (spec->flags & G_PARAM_READABLE) {
xmlNodePtr param;
char *contents;
-
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (spec));
-
+
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (spec));
+
g_object_get_property (G_OBJECT (element), spec->name, &value);
param = xmlNewChild (parent, NULL, "param", NULL);
xmlNewChild (param, NULL, "name", spec->name);
-
+
if (G_IS_PARAM_SPEC_STRING (spec))
contents = g_value_dup_string (&value);
else if (G_IS_PARAM_SPEC_ENUM (spec))
contents = g_strdup_printf ("%d", g_value_get_enum (&value));
else if (G_IS_PARAM_SPEC_INT64 (spec))
contents = g_strdup_printf ("%" G_GINT64_FORMAT,
- g_value_get_int64 (&value));
+ g_value_get_int64 (&value));
else
contents = g_strdup_value_contents (&value);
-
+
xmlNewChild (param, NULL, "value", contents);
g_free (contents);
-
- g_value_unset(&value);
+
+ g_value_unset (&value);
}
}
while (pads) {
GstPad *pad = GST_PAD (pads->data);
+
/* figure out if it's a direct pad or a ghostpad */
if (GST_ELEMENT (GST_OBJECT_PARENT (pad)) == element) {
xmlNodePtr padtag = xmlNewChild (parent, NULL, "pad", NULL);
+
gst_object_save_thyself (GST_OBJECT (pad), padtag);
}
pads = g_list_next (pads);
}
static void
-gst_element_restore_thyself (GstObject *object, xmlNodePtr self)
+gst_element_restore_thyself (GstObject * object, xmlNodePtr self)
{
xmlNodePtr children;
GstElement *element;
xmlNodePtr child = children->xmlChildrenNode;
while (child) {
- if (!strcmp (child->name, "name")) {
- name = xmlNodeGetContent (child);
- }
- else if (!strcmp (child->name, "value")) {
- value = xmlNodeGetContent (child);
+ if (!strcmp (child->name, "name")) {
+ name = xmlNodeGetContent (child);
+ } else if (!strcmp (child->name, "value")) {
+ value = xmlNodeGetContent (child);
}
- child = child->next;
+ child = child->next;
}
/* FIXME: can this just be g_object_set ? */
gst_util_set_object_arg (G_OBJECT (element), name, value);
}
children = children->next;
}
-
+
/* pads */
children = self->xmlChildrenNode;
while (children) {
* give control to another element.
*/
void
-gst_element_yield (GstElement *element)
+gst_element_yield (GstElement * element)
{
if (GST_ELEMENT_SCHED (element)) {
gst_scheduler_yield (GST_ELEMENT_SCHED (element), element);
* function ASAP, depending on the scheduler implementation.
*/
gboolean
-gst_element_interrupt (GstElement *element)
+gst_element_interrupt (GstElement * element)
{
if (GST_ELEMENT_SCHED (element)) {
return gst_scheduler_interrupt (GST_ELEMENT_SCHED (element), element);
- }
- else
+ } else
return TRUE;
}
* writing a new bin subclass.
*/
void
-gst_element_set_scheduler (GstElement *element,
- GstScheduler *sched)
+gst_element_set_scheduler (GstElement * element, GstScheduler * sched)
{
g_return_if_fail (GST_IS_ELEMENT (element));
-
- GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", sched);
- gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (element), GST_OBJECT (sched));
+ GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p",
+ sched);
+
+ gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (element),
+ GST_OBJECT (sched));
}
/**
*
* Returns: the element's #GstScheduler.
*/
-GstScheduler*
-gst_element_get_scheduler (GstElement *element)
+GstScheduler *
+gst_element_get_scheduler (GstElement * element)
{
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
* a new loopfunc to be assigned, this should be no problem.
*/
void
-gst_element_set_loop_function (GstElement *element,
- GstElementLoopFunction loop)
+gst_element_set_loop_function (GstElement * element,
+ GstElementLoopFunction loop)
{
gboolean need_notify = FALSE;
-
+
g_return_if_fail (GST_IS_ELEMENT (element));
/* if the element changed from loop based to chain/get based
* or vice versa, we need to inform the scheduler about that */
if ((element->loopfunc == NULL && loop != NULL) ||
- (element->loopfunc != NULL && loop == NULL))
- {
+ (element->loopfunc != NULL && loop == NULL)) {
need_notify = TRUE;
}
-
+
/* set the loop function */
element->loopfunc = loop;
}
}
static inline void
-gst_element_emit_found_tag (GstElement* element, GstElement *source, const GstTagList *tag_list)
+gst_element_emit_found_tag (GstElement * element, GstElement * source,
+ const GstTagList * tag_list)
{
gst_object_ref (GST_OBJECT (element));
g_signal_emit (element, gst_element_signals[FOUND_TAG], 0, source, tag_list);
gst_object_unref (GST_OBJECT (element));
}
static void
-gst_element_found_tag_func (GstElement* element, GstElement *source, const GstTagList *tag_list)
+gst_element_found_tag_func (GstElement * element, GstElement * source,
+ const GstTagList * tag_list)
{
/* tell the parent */
if (GST_OBJECT_PARENT (element)) {
- GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s",
- GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
- gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)), source, tag_list);
- }
+ GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s",
+ GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
+ gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)),
+ source, tag_list);
+ }
}
+
/**
* gst_element_found_tags:
* @element: the element that found the tags
* not when you handle an event.
*/
void
-gst_element_found_tags (GstElement *element, const GstTagList *tag_list)
+gst_element_found_tags (GstElement * element, const GstTagList * tag_list)
{
gst_element_emit_found_tag (element, element, tag_list);
}
+
/**
* gst_element_found_tags_for_pad:
* @element: element that found the tag
* #GstPadGetFunction.</note>
*/
void
-gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstClockTime timestamp,
- GstTagList *list)
+gst_element_found_tags_for_pad (GstElement * element, GstPad * pad,
+ GstClockTime timestamp, GstTagList * list)
{
GstEvent *tag_event;
}
static inline void
-gst_element_set_eos_recursive (GstElement *element)
+gst_element_set_eos_recursive (GstElement * element)
{
/* this function is only called, when we were in PLAYING before. So every
parent that's PAUSED was PLAYING before. That means it has reached EOS. */
GstElement *parent;
- GST_CAT_DEBUG (GST_CAT_EVENT, "setting recursive EOS on %s",
- GST_OBJECT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_EVENT, "setting recursive EOS on %s",
+ GST_OBJECT_NAME (element));
g_signal_emit (G_OBJECT (element), gst_element_signals[EOS], 0);
if (!GST_OBJECT_PARENT (element))
return;
-
+
parent = GST_ELEMENT (GST_OBJECT_PARENT (element));
if (GST_STATE (parent) == GST_STATE_PAUSED)
gst_element_set_eos_recursive (parent);
}
+
/**
* gst_element_set_eos:
* @element: a #GstElement to set to the EOS state.
* Perform the actions needed to bring the element in the EOS state.
*/
void
-gst_element_set_eos (GstElement *element)
+gst_element_set_eos (GstElement * element)
{
g_return_if_fail (GST_IS_ELEMENT (element));
- GST_CAT_DEBUG (GST_CAT_EVENT, "setting EOS on element %s",
- GST_OBJECT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_EVENT, "setting EOS on element %s",
+ GST_OBJECT_NAME (element));
if (GST_STATE (element) == GST_STATE_PLAYING) {
gst_element_set_state (element, GST_STATE_PAUSED);
*
* Returns: a string with the name of the state.
*/
-const gchar*
-gst_element_state_get_name (GstElementState state)
+const gchar *
+gst_element_state_get_name (GstElementState state)
{
switch (state) {
#ifdef GST_DEBUG_COLOR
- case GST_STATE_VOID_PENDING: return "NONE_PENDING";break;
- case GST_STATE_NULL: return "\033[01;34mNULL\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;
+ case GST_STATE_VOID_PENDING:
+ return "NONE_PENDING";
+ break;
+ case GST_STATE_NULL:
+ return "\033[01;34mNULL\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;
default:
/* This is a memory leak */
return g_strdup_printf ("\033[01;35;41mUNKNOWN!\033[00m(%d)", state);
#else
- case GST_STATE_VOID_PENDING: return "NONE_PENDING";break;
- 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!";
+ case GST_STATE_VOID_PENDING:
+ return "NONE_PENDING";
+ break;
+ 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 "";
}
static void
-gst_element_populate_std_props (GObjectClass * klass, const gchar *prop_name,
- guint arg_id, GParamFlags flags)
+gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name,
+ guint arg_id, GParamFlags flags)
{
GQuark prop_id = g_quark_from_string (prop_name);
GParamSpec *pspec;
if (prop_id == fd_id) {
pspec = g_param_spec_int ("fd", "File-descriptor",
- "File-descriptor for the file being read",
- 0, G_MAXINT, 0, flags);
- }
- else if (prop_id == blocksize_id) {
+ "File-descriptor for the file being read", 0, G_MAXINT, 0, flags);
+ } else if (prop_id == blocksize_id) {
pspec = g_param_spec_ulong ("blocksize", "Block Size",
- "Block size to read per buffer",
- 0, G_MAXULONG, 4096, flags);
+ "Block size to read per buffer", 0, G_MAXULONG, 4096, flags);
- }
- else if (prop_id == bytesperread_id) {
+ } else if (prop_id == bytesperread_id) {
pspec = g_param_spec_int ("bytesperread", "Bytes per read",
- "Number of bytes to read per buffer",
- G_MININT, G_MAXINT, 0, flags);
+ "Number of bytes to read per buffer", G_MININT, G_MAXINT, 0, flags);
- }
- else if (prop_id == dump_id) {
- pspec = g_param_spec_boolean ("dump", "Dump",
- "Dump bytes to stdout",
- FALSE, flags);
+ } else if (prop_id == dump_id) {
+ pspec = g_param_spec_boolean ("dump", "Dump",
+ "Dump bytes to stdout", FALSE, flags);
- }
- else if (prop_id == filesize_id) {
+ } else if (prop_id == filesize_id) {
pspec = g_param_spec_int64 ("filesize", "File Size",
- "Size of the file being read",
- 0, G_MAXINT64, 0, flags);
+ "Size of the file being read", 0, G_MAXINT64, 0, flags);
- }
- else if (prop_id == mmapsize_id) {
+ } 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);
+ "Size in bytes of mmap()d regions", 0, G_MAXULONG, 4 * 1048576, flags);
- }
- else if (prop_id == location_id) {
+ } else if (prop_id == location_id) {
pspec = g_param_spec_string ("location", "File Location",
- "Location of the file to read",
- NULL, flags);
+ "Location of the file to read", NULL, flags);
- }
- else if (prop_id == offset_id) {
+ } else if (prop_id == offset_id) {
pspec = g_param_spec_int64 ("offset", "File Offset",
- "Byte offset of current read pointer",
- 0, G_MAXINT64, 0, flags);
+ "Byte offset of current read pointer", 0, G_MAXINT64, 0, flags);
- }
- else if (prop_id == silent_id) {
+ } else if (prop_id == silent_id) {
pspec = g_param_spec_boolean ("silent", "Silent", "Don't produce events",
- FALSE, flags);
+ FALSE, flags);
- }
- else if (prop_id == touch_id) {
+ } else if (prop_id == touch_id) {
pspec = g_param_spec_boolean ("touch", "Touch read data",
- "Touch data to force disk read before "
- "push ()", TRUE, flags);
- }
- else {
+ "Touch data to force disk read before " "push ()", TRUE, flags);
+ } else {
g_warning ("Unknown - 'standard' property '%s' id %d from klass %s",
- prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass)));
+ prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass)));
pspec = NULL;
}
* the flags determine readability / writeability.
**/
void
-gst_element_class_install_std_props (GstElementClass * klass,
- const gchar *first_name, ...)
+gst_element_class_install_std_props (GstElementClass * klass,
+ const gchar * first_name, ...)
{
const char *name;
int arg_id = va_arg (args, int);
int flags = va_arg (args, int);
- gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id, flags);
+ gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id,
+ flags);
name = va_arg (args, char *);
}
*
* Returns: the #GstBin, or NULL on failure.
**/
-GstBin*
-gst_element_get_managing_bin (GstElement *element)
+GstBin *
+gst_element_get_managing_bin (GstElement * element)
{
GstBin *bin;
while (bin && !GST_FLAG_IS_SET (GST_OBJECT (bin), GST_BIN_FLAG_MANAGER))
bin = GST_BIN (gst_object_get_parent (GST_OBJECT (bin)));
-
+
return bin;
}
#include <gst/gstindex.h>
#include <gst/gsttag.h>
-G_BEGIN_DECLS
-
-typedef struct _GstElementDetails GstElementDetails;
+G_BEGIN_DECLS typedef struct _GstElementDetails GstElementDetails;
/* FIXME: need translatable stuff in here (how handle in registry)? */
-struct _GstElementDetails {
- gchar *longname; /* long, english name */
- gchar *klass; /* type of element, as hierarchy */
- gchar *description; /* insights of one form or another */
- gchar *author; /* who wrote this thing? */
+struct _GstElementDetails
+{
+ gchar *longname; /* long, english name */
+ gchar *klass; /* type of element, as hierarchy */
+ gchar *description; /* insights of one form or another */
+ gchar *author; /* who wrote this thing? */
gpointer _gst_reserved[GST_PADDING];
};
+
#define GST_ELEMENT_DETAILS(longname,klass,description,author) \
{ longname, klass, description, author, GST_PADDING_INIT }
#define GST_IS_ELEMENT_DETAILS(details) ( \
#endif
#endif
-typedef enum {
+typedef enum
+{
/* element is complex (for some def.) and generally require a cothread */
- GST_ELEMENT_COMPLEX = GST_OBJECT_FLAG_LAST,
+ GST_ELEMENT_COMPLEX = GST_OBJECT_FLAG_LAST,
/* input and output pads aren't directly coupled to each other
examples: queues, multi-output async readers, etc. */
GST_ELEMENT_DECOUPLED,
GST_ELEMENT_IN_ERROR,
/* use some padding for future expansion */
- GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16
+ GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16
} GstElementFlags;
#define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_THREAD_SUGGESTED))
typedef struct _GstElementFactory GstElementFactory;
typedef struct _GstElementFactoryClass GstElementFactoryClass;
-typedef void (*GstElementLoopFunction) (GstElement *element);
-typedef void (*GstElementPreRunFunction) (GstElement *element);
-typedef void (*GstElementPostRunFunction) (GstElement *element);
+typedef void (*GstElementLoopFunction) (GstElement * element);
+typedef void (*GstElementPreRunFunction) (GstElement * element);
+typedef void (*GstElementPostRunFunction) (GstElement * element);
-struct _GstElement {
- GstObject object;
+struct _GstElement
+{
+ GstObject object;
/* element state and scheduling */
- guint8 current_state;
- guint8 pending_state;
+ guint8 current_state;
+ guint8 pending_state;
GstElementLoopFunction loopfunc;
- GstScheduler *sched;
- gpointer sched_private;
+ GstScheduler *sched;
+ gpointer sched_private;
/* allocated clock */
- GstClock *clock;
- GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
+ GstClock *clock;
+ GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
/* element pads */
- guint16 numpads;
- guint16 numsrcpads;
- guint16 numsinkpads;
- GList *pads;
+ guint16 numpads;
+ guint16 numsrcpads;
+ guint16 numsinkpads;
+ GList *pads;
- GMutex *state_mutex;
- GCond *state_cond;
+ GMutex *state_mutex;
+ GCond *state_cond;
- GstElementPreRunFunction pre_run_func;
+ GstElementPreRunFunction pre_run_func;
GstElementPostRunFunction post_run_func;
- GAsyncQueue *prop_value_queue;
- GMutex *property_mutex;
+ GAsyncQueue *prop_value_queue;
+ GMutex *property_mutex;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstElementClass {
- GstObjectClass parent_class;
+struct _GstElementClass
+{
+ GstObjectClass parent_class;
/* the element details */
- GstElementDetails details;
+ GstElementDetails details;
/* factory that the element was created from */
- GstElementFactory *elementfactory;
+ GstElementFactory *elementfactory;
/* templates for our pads */
- GList *padtemplates;
- gint numpadtemplates;
-
+ GList *padtemplates;
+ gint numpadtemplates;
+
/* signal callbacks */
- void (*state_change) (GstElement *element, GstElementState old, GstElementState state);
- void (*new_pad) (GstElement *element, GstPad *pad);
- void (*pad_removed) (GstElement *element, GstPad *pad);
- void (*error) (GstElement *element, GstElement *source, GError *error, gchar *debug);
- void (*eos) (GstElement *element);
- void (*found_tag) (GstElement *element, GstElement *source, const GstTagList *tag_list);
+ void (*state_change) (GstElement * element, GstElementState old,
+ GstElementState state);
+ void (*new_pad) (GstElement * element, GstPad * pad);
+ void (*pad_removed) (GstElement * element, GstPad * pad);
+ void (*error) (GstElement * element, GstElement * source, GError * error,
+ gchar * debug);
+ void (*eos) (GstElement * element);
+ void (*found_tag) (GstElement * element, GstElement * source,
+ const GstTagList * tag_list);
/* local pointers for get/set */
- void (*set_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
- void (*get_property) (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+ void (*set_property) (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec);
+ void (*get_property) (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec);
- /* vtable*/
- gboolean (*release_locks) (GstElement *element);
+ /* vtable */
+ gboolean (*release_locks) (GstElement * element);
/* query/convert/events functions */
- const GstEventMask* (*get_event_masks) (GstElement *element);
- gboolean (*send_event) (GstElement *element, GstEvent *event);
- const GstFormat* (*get_formats) (GstElement *element);
- gboolean (*convert) (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
- const GstQueryType* (*get_query_types) (GstElement *element);
- gboolean (*query) (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value);
+ const GstEventMask *(*get_event_masks) (GstElement * element);
+ gboolean (*send_event) (GstElement * element, GstEvent * event);
+ const GstFormat *(*get_formats) (GstElement * element);
+ gboolean (*convert) (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+ const GstQueryType *(*get_query_types) (GstElement * element);
+ gboolean (*query) (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value);
/* change the element state */
- GstElementStateReturn (*change_state) (GstElement *element);
+ GstElementStateReturn (*change_state) (GstElement * element);
/* request/release pads */
- GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name);
- void (*release_pad) (GstElement *element, GstPad *pad);
+ GstPad *(*request_new_pad) (GstElement * element, GstPadTemplate * templ,
+ const gchar * name);
+ void (*release_pad) (GstElement * element, GstPad * pad);
/* set/get clocks */
- GstClock* (*get_clock) (GstElement *element);
- void (*set_clock) (GstElement *element, GstClock *clock);
+ GstClock *(*get_clock) (GstElement * element);
+ void (*set_clock) (GstElement * element, GstClock * clock);
/* index */
- GstIndex* (*get_index) (GstElement *element);
- void (*set_index) (GstElement *element, GstIndex *index);
+ GstIndex *(*get_index) (GstElement * element);
+ void (*set_index) (GstElement * element, GstIndex * index);
- GstElementStateReturn (*set_state) (GstElement *element, GstElementState state);
+ GstElementStateReturn (*set_state) (GstElement * element,
+ GstElementState state);
gpointer _gst_reserved[GST_PADDING];
};
-void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
-void gst_element_class_install_std_props (GstElementClass *klass,
- const gchar *first_name, ...);
-void gst_element_class_set_details (GstElementClass *klass,
- const GstElementDetails *details);
+void gst_element_class_add_pad_template (GstElementClass * klass,
+ GstPadTemplate * templ);
+void gst_element_class_install_std_props (GstElementClass * klass,
+ const gchar * first_name, ...);
+void gst_element_class_set_details (GstElementClass * klass,
+ const GstElementDetails * details);
#define gst_element_default_deep_notify gst_object_default_deep_notify
-void gst_element_default_error (GObject *object, GstObject *orig, GError *error, gchar *debug);
+void gst_element_default_error (GObject * object, GstObject * orig,
+ GError * error, gchar * debug);
-GType gst_element_get_type (void);
-void gst_element_set_loop_function (GstElement *element,
- GstElementLoopFunction loop);
+GType gst_element_get_type (void);
+void gst_element_set_loop_function (GstElement * element,
+ GstElementLoopFunction loop);
#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT(elem))
#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT(elem),name)
#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT(elem),parent)
/* threadsafe versions of their g_object_* counterparts */
-void gst_element_set (GstElement *element, const gchar *first_property_name, ...);
-void gst_element_get (GstElement *element, const gchar *first_property_name, ...);
-void gst_element_set_valist (GstElement *element, const gchar *first_property_name,
- va_list var_args);
-void gst_element_get_valist (GstElement *element, const gchar *first_property_name,
- va_list var_args);
-void gst_element_set_property (GstElement *element, const gchar *property_name,
- const GValue *value);
-void gst_element_get_property (GstElement *element, const gchar *property_name,
- GValue *value);
-
-void gst_element_enable_threadsafe_properties (GstElement *element);
-void gst_element_disable_threadsafe_properties (GstElement *element);
-void gst_element_set_pending_properties (GstElement *element);
+void gst_element_set (GstElement * element, const gchar * first_property_name,
+ ...);
+void gst_element_get (GstElement * element, const gchar * first_property_name,
+ ...);
+void gst_element_set_valist (GstElement * element,
+ const gchar * first_property_name, va_list var_args);
+void gst_element_get_valist (GstElement * element,
+ const gchar * first_property_name, va_list var_args);
+void gst_element_set_property (GstElement * element,
+ const gchar * property_name, const GValue * value);
+void gst_element_get_property (GstElement * element,
+ const gchar * property_name, GValue * value);
+
+void gst_element_enable_threadsafe_properties (GstElement * element);
+void gst_element_disable_threadsafe_properties (GstElement * element);
+void gst_element_set_pending_properties (GstElement * element);
/* clocking */
-gboolean gst_element_requires_clock (GstElement *element);
-gboolean gst_element_provides_clock (GstElement *element);
-GstClock* gst_element_get_clock (GstElement *element);
-void gst_element_set_clock (GstElement *element, GstClock *clock);
-GstClockReturn gst_element_clock_wait (GstElement *element,
- GstClockID id, GstClockTimeDiff *jitter);
-GstClockTime gst_element_get_time (GstElement *element);
-gboolean gst_element_wait (GstElement *element, GstClockTime timestamp);
-void gst_element_set_time (GstElement *element, GstClockTime time);
-void gst_element_adjust_time (GstElement *element, GstClockTimeDiff diff);
-
+gboolean gst_element_requires_clock (GstElement * element);
+gboolean gst_element_provides_clock (GstElement * element);
+GstClock *gst_element_get_clock (GstElement * element);
+void gst_element_set_clock (GstElement * element, GstClock * clock);
+GstClockReturn gst_element_clock_wait (GstElement * element,
+ GstClockID id, GstClockTimeDiff * jitter);
+GstClockTime gst_element_get_time (GstElement * element);
+gboolean gst_element_wait (GstElement * element, GstClockTime timestamp);
+void gst_element_set_time (GstElement * element, GstClockTime time);
+void gst_element_adjust_time (GstElement * element, GstClockTimeDiff diff);
+
/* indexs */
-gboolean gst_element_is_indexable (GstElement *element);
-void gst_element_set_index (GstElement *element, GstIndex *index);
-GstIndex* gst_element_get_index (GstElement *element);
-
-
-gboolean gst_element_release_locks (GstElement *element);
-
-void gst_element_yield (GstElement *element);
-gboolean gst_element_interrupt (GstElement *element);
-void gst_element_set_scheduler (GstElement *element, GstScheduler *sched);
-GstScheduler* gst_element_get_scheduler (GstElement *element);
-
-void gst_element_add_pad (GstElement *element, GstPad *pad);
-void gst_element_remove_pad (GstElement *element, GstPad *pad);
-GstPad * gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name);
-void gst_element_remove_ghost_pad (GstElement *element, GstPad *pad);
-
-GstPad* gst_element_get_pad (GstElement *element, const gchar *name);
-GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name);
-GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name);
-void gst_element_release_request_pad (GstElement *element, GstPad *pad);
-
-G_CONST_RETURN GList*
- gst_element_get_pad_list (GstElement *element);
-GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad);
-GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad,
- const GstCaps *filtercaps);
-
-GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
-GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);
-GstPadTemplate* gst_element_get_pad_template (GstElement *element, const gchar *name);
-GList* gst_element_get_pad_template_list (GstElement *element);
-GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl);
-
-gboolean gst_element_link (GstElement *src, GstElement *dest);
-gboolean gst_element_link_many (GstElement *element_1,
- GstElement *element_2, ...);
-gboolean gst_element_link_filtered (GstElement *src, GstElement *dest,
- const GstCaps *filtercaps);
-void gst_element_unlink (GstElement *src, GstElement *dest);
-void gst_element_unlink_many (GstElement *element_1,
- GstElement *element_2, ...);
-
-gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname);
-gboolean gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname,
- const GstCaps *filtercaps);
-void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
- GstElement *dest, const gchar *destpadname);
-
-G_CONST_RETURN GstEventMask*
- gst_element_get_event_masks (GstElement *element);
-gboolean gst_element_send_event (GstElement *element, GstEvent *event);
-gboolean gst_element_seek (GstElement *element, GstSeekType seek_type,
- guint64 offset);
-G_CONST_RETURN GstQueryType*
- gst_element_get_query_types (GstElement *element);
-gboolean gst_element_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value);
-G_CONST_RETURN GstFormat*
- gst_element_get_formats (GstElement *element);
-gboolean gst_element_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-
-void gst_element_found_tags (GstElement *element, const GstTagList *tag_list);
-void gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstClockTime timestamp,
- GstTagList *list);
-
-void gst_element_set_eos (GstElement *element);
-
-gchar * _gst_element_error_printf (const gchar *format, ...);
-void gst_element_error_full (GstElement *element, GQuark domain, gint code,
- gchar *message, gchar *debug,
- const gchar *file, const gchar *function, gint line);
-
-gboolean gst_element_is_locked_state (GstElement *element);
-void gst_element_set_locked_state (GstElement *element, gboolean locked_state);
-gboolean gst_element_sync_state_with_parent (GstElement *element);
-
-GstElementState gst_element_get_state (GstElement *element);
-GstElementStateReturn gst_element_set_state (GstElement *element, GstElementState state);
-
-void gst_element_wait_state_change (GstElement *element);
-
-G_CONST_RETURN gchar* gst_element_state_get_name (GstElementState state);
-
-GstElementFactory* gst_element_get_factory (GstElement *element);
-
-GstBin* gst_element_get_managing_bin (GstElement *element);
+gboolean gst_element_is_indexable (GstElement * element);
+void gst_element_set_index (GstElement * element, GstIndex * index);
+GstIndex *gst_element_get_index (GstElement * element);
+
+
+gboolean gst_element_release_locks (GstElement * element);
+
+void gst_element_yield (GstElement * element);
+gboolean gst_element_interrupt (GstElement * element);
+void gst_element_set_scheduler (GstElement * element, GstScheduler * sched);
+GstScheduler *gst_element_get_scheduler (GstElement * element);
+
+void gst_element_add_pad (GstElement * element, GstPad * pad);
+void gst_element_remove_pad (GstElement * element, GstPad * pad);
+GstPad *gst_element_add_ghost_pad (GstElement * element, GstPad * pad,
+ const gchar * name);
+void gst_element_remove_ghost_pad (GstElement * element, GstPad * pad);
+
+GstPad *gst_element_get_pad (GstElement * element, const gchar * name);
+GstPad *gst_element_get_static_pad (GstElement * element, const gchar * name);
+GstPad *gst_element_get_request_pad (GstElement * element, const gchar * name);
+void gst_element_release_request_pad (GstElement * element, GstPad * pad);
+
+G_CONST_RETURN GList *gst_element_get_pad_list (GstElement * element);
+GstPad *gst_element_get_compatible_pad (GstElement * element, GstPad * pad);
+GstPad *gst_element_get_compatible_pad_filtered (GstElement * element,
+ GstPad * pad, const GstCaps * filtercaps);
+
+GstPadTemplate *gst_element_class_get_pad_template (GstElementClass *
+ element_class, const gchar * name);
+GList *gst_element_class_get_pad_template_list (GstElementClass *
+ element_class);
+GstPadTemplate *gst_element_get_pad_template (GstElement * element,
+ const gchar * name);
+GList *gst_element_get_pad_template_list (GstElement * element);
+GstPadTemplate *gst_element_get_compatible_pad_template (GstElement * element,
+ GstPadTemplate * compattempl);
+
+gboolean gst_element_link (GstElement * src, GstElement * dest);
+gboolean gst_element_link_many (GstElement * element_1,
+ GstElement * element_2, ...);
+gboolean gst_element_link_filtered (GstElement * src, GstElement * dest,
+ const GstCaps * filtercaps);
+void gst_element_unlink (GstElement * src, GstElement * dest);
+void gst_element_unlink_many (GstElement * element_1,
+ GstElement * element_2, ...);
+
+gboolean gst_element_link_pads (GstElement * src, const gchar * srcpadname,
+ GstElement * dest, const gchar * destpadname);
+gboolean gst_element_link_pads_filtered (GstElement * src,
+ const gchar * srcpadname, GstElement * dest, const gchar * destpadname,
+ const GstCaps * filtercaps);
+void gst_element_unlink_pads (GstElement * src, const gchar * srcpadname,
+ GstElement * dest, const gchar * destpadname);
+
+G_CONST_RETURN GstEventMask *gst_element_get_event_masks (GstElement * element);
+gboolean gst_element_send_event (GstElement * element, GstEvent * event);
+gboolean gst_element_seek (GstElement * element, GstSeekType seek_type,
+ guint64 offset);
+G_CONST_RETURN GstQueryType *gst_element_get_query_types (GstElement * element);
+gboolean gst_element_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value);
+G_CONST_RETURN GstFormat *gst_element_get_formats (GstElement * element);
+gboolean gst_element_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+
+void gst_element_found_tags (GstElement * element, const GstTagList * tag_list);
+void gst_element_found_tags_for_pad (GstElement * element, GstPad * pad,
+ GstClockTime timestamp, GstTagList * list);
+
+void gst_element_set_eos (GstElement * element);
+
+gchar *_gst_element_error_printf (const gchar * format, ...);
+void gst_element_error_full (GstElement * element, GQuark domain, gint code,
+ gchar * message, gchar * debug,
+ const gchar * file, const gchar * function, gint line);
+
+gboolean gst_element_is_locked_state (GstElement * element);
+void gst_element_set_locked_state (GstElement * element, gboolean locked_state);
+gboolean gst_element_sync_state_with_parent (GstElement * element);
+
+GstElementState gst_element_get_state (GstElement * element);
+GstElementStateReturn gst_element_set_state (GstElement * element,
+ GstElementState state);
+
+void gst_element_wait_state_change (GstElement * element);
+
+G_CONST_RETURN gchar *gst_element_state_get_name (GstElementState state);
+
+GstElementFactory *gst_element_get_factory (GstElement * element);
+
+GstBin *gst_element_get_managing_bin (GstElement * element);
/*
#define GST_IS_ELEMENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENT_FACTORY))
#define GST_IS_ELEMENT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT_FACTORY))
-struct _GstElementFactory {
- GstPluginFeature parent;
+struct _GstElementFactory
+{
+ GstPluginFeature parent;
- GType type; /* unique GType of element or 0 if not loaded */
+ GType type; /* unique GType of element or 0 if not loaded */
- GstElementDetails details;
+ GstElementDetails details;
- GList * padtemplates;
- guint numpadtemplates;
+ GList *padtemplates;
+ guint numpadtemplates;
/* URI interface stuff */
- guint uri_type;
- gchar ** uri_protocols;
-
- GList * interfaces; /* interfaces this element implements */
+ guint uri_type;
+ gchar **uri_protocols;
+
+ GList *interfaces; /* interfaces this element implements */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstElementFactoryClass {
+struct _GstElementFactoryClass
+{
GstPluginFeatureClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_element_factory_get_type (void);
-
-gboolean gst_element_register (GstPlugin *plugin,
- const gchar *elementname,
- guint rank,
- GType type);
-
-GstElementFactory * gst_element_factory_find (const gchar *name);
-GType gst_element_factory_get_element_type (GstElementFactory *factory);
-G_CONST_RETURN gchar * gst_element_factory_get_longname (GstElementFactory *factory);
-G_CONST_RETURN gchar * gst_element_factory_get_klass (GstElementFactory *factory);
-G_CONST_RETURN gchar * gst_element_factory_get_description (GstElementFactory *factory);
-G_CONST_RETURN gchar * gst_element_factory_get_author (GstElementFactory *factory);
-guint gst_element_factory_get_num_pad_templates (GstElementFactory *factory);
-G_CONST_RETURN GList * gst_element_factory_get_pad_templates (GstElementFactory *factory);
-guint gst_element_factory_get_uri_type (GstElementFactory *factory);
-gchar ** gst_element_factory_get_uri_protocols (GstElementFactory *factory);
-
-GstElement* gst_element_factory_create (GstElementFactory *factory,
- const gchar *name);
-GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name);
-
-gboolean gst_element_factory_can_src_caps (GstElementFactory *factory,
- const GstCaps *caps);
-gboolean gst_element_factory_can_sink_caps (GstElementFactory *factory,
- const GstCaps *caps);
-
-void __gst_element_factory_add_pad_template (GstElementFactory *elementfactory,
- GstPadTemplate *templ);
-void __gst_element_factory_add_interface (GstElementFactory *elementfactory,
- const gchar *interfacename);
+GType gst_element_factory_get_type (void);
+
+gboolean gst_element_register (GstPlugin * plugin,
+ const gchar * elementname, guint rank, GType type);
+
+GstElementFactory *gst_element_factory_find (const gchar * name);
+GType gst_element_factory_get_element_type (GstElementFactory * factory);
+G_CONST_RETURN gchar *gst_element_factory_get_longname (GstElementFactory *
+ factory);
+G_CONST_RETURN gchar *gst_element_factory_get_klass (GstElementFactory *
+ factory);
+G_CONST_RETURN gchar *gst_element_factory_get_description (GstElementFactory *
+ factory);
+G_CONST_RETURN gchar *gst_element_factory_get_author (GstElementFactory *
+ factory);
+guint gst_element_factory_get_num_pad_templates (GstElementFactory * factory);
+G_CONST_RETURN GList *gst_element_factory_get_pad_templates (GstElementFactory *
+ factory);
+guint gst_element_factory_get_uri_type (GstElementFactory * factory);
+gchar **gst_element_factory_get_uri_protocols (GstElementFactory * factory);
+
+GstElement *gst_element_factory_create (GstElementFactory * factory,
+ const gchar * name);
+GstElement *gst_element_factory_make (const gchar * factoryname,
+ const gchar * name);
+
+gboolean gst_element_factory_can_src_caps (GstElementFactory * factory,
+ const GstCaps * caps);
+gboolean gst_element_factory_can_sink_caps (GstElementFactory * factory,
+ const GstCaps * caps);
+
+void __gst_element_factory_add_pad_template (GstElementFactory * elementfactory,
+ GstPadTemplate * templ);
+void __gst_element_factory_add_interface (GstElementFactory * elementfactory,
+ const gchar * interfacename);
G_END_DECLS
-
-
#endif /* __GST_ELEMENT_H__ */
-
GST_DEBUG_CATEGORY_STATIC (element_factory_debug);
#define GST_CAT_DEFAULT element_factory_debug
-static void gst_element_factory_class_init (GstElementFactoryClass *klass);
-static void gst_element_factory_init (GstElementFactory *factory);
+static void gst_element_factory_class_init (GstElementFactoryClass * klass);
+static void gst_element_factory_init (GstElementFactory * factory);
-static void gst_element_factory_unload_thyself (GstPluginFeature *feature);
+static void gst_element_factory_unload_thyself (GstPluginFeature * feature);
static GstPluginFeatureClass *parent_class = NULL;
+
/* static guint gst_element_factory_signals[LAST_SIGNAL] = { 0 }; */
-GType
-gst_element_factory_get_type (void)
+GType
+gst_element_factory_get_type (void)
{
static GType elementfactory_type = 0;
(GClassInitFunc) gst_element_factory_class_init,
NULL,
NULL,
- sizeof(GstElementFactory),
+ sizeof (GstElementFactory),
0,
(GInstanceInitFunc) gst_element_factory_init,
NULL
};
- elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
- "GstElementFactory", &elementfactory_info, 0);
- GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- "element factories keep information about installed elements");
+ elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
+ "GstElementFactory", &elementfactory_info, 0);
+ GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
+ "element factories keep information about installed elements");
}
return elementfactory_type;
}
static void
-gst_element_factory_class_init (GstElementFactoryClass *klass)
+gst_element_factory_class_init (GstElementFactoryClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstPluginFeatureClass *gstpluginfeature_class;
- gobject_class = (GObjectClass*)klass;
- gstobject_class = (GstObjectClass*)klass;
- gstpluginfeature_class = (GstPluginFeatureClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstpluginfeature_class = (GstPluginFeatureClass *) klass;
parent_class = g_type_class_peek_parent (klass);
- gstpluginfeature_class->unload_thyself = GST_DEBUG_FUNCPTR (gst_element_factory_unload_thyself);
+ gstpluginfeature_class->unload_thyself =
+ GST_DEBUG_FUNCPTR (gst_element_factory_unload_thyself);
}
static void
-gst_element_factory_init (GstElementFactory *factory)
+gst_element_factory_init (GstElementFactory * factory)
{
factory->padtemplates = NULL;
factory->numpadtemplates = 0;
factory->interfaces = NULL;
}
+
/**
* gst_element_factory_find:
* @name: name of factory to find
*
* Returns: #GstElementFactory if found, NULL otherwise
*/
-GstElementFactory*
-gst_element_factory_find (const gchar *name)
+GstElementFactory *
+gst_element_factory_find (const gchar * name)
{
GstPluginFeature *feature;
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
feature = gst_registry_pool_find_feature (name, GST_TYPE_ELEMENT_FACTORY);
if (feature)
}
void
-__gst_element_details_clear (GstElementDetails *dp)
+__gst_element_details_clear (GstElementDetails * dp)
{
g_free (dp->longname);
dp->longname = NULL;
g_free (dp->author);
dp->author = NULL;
}
+
void
-__gst_element_details_set (GstElementDetails *dest, const GstElementDetails *src)
+__gst_element_details_set (GstElementDetails * dest,
+ const GstElementDetails * src)
{
dest->longname = g_strdup (src->longname);
dest->klass = g_strdup (src->klass);
dest->description = g_strdup (src->description);
dest->author = g_strdup (src->author);
}
+
void
-__gst_element_details_copy (GstElementDetails *dest, const GstElementDetails *src)
+__gst_element_details_copy (GstElementDetails * dest,
+ const GstElementDetails * src)
{
__gst_element_details_clear (dest);
__gst_element_details_set (dest, src);
}
static void
-gst_element_factory_cleanup (GstElementFactory *factory)
+gst_element_factory_cleanup (GstElementFactory * factory)
{
__gst_element_details_clear (&factory->details);
if (factory->type) {
g_strfreev (factory->uri_protocols);
factory->uri_protocols = NULL;
}
-
+
g_list_foreach (factory->interfaces, (GFunc) g_free, NULL);
g_list_free (factory->interfaces);
factory->interfaces = NULL;
}
+
/**
* gst_element_register:
* @plugin:
* Returns: TRUE, if the registering succeeded, FALSE on error
*/
gboolean
-gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType type)
+gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
+ GType type)
{
GstElementFactory *factory;
GType *interfaces;
if (!factory) {
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
- factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
+ factory =
+ GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
- GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type));
+ GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
+ g_type_name (type));
} else {
g_return_val_if_fail (factory->type == 0, FALSE);
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
gst_element_factory_cleanup (factory);
- GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s", g_type_name (type));
+ GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s",
+ g_type_name (type));
}
factory->type = type;
/* special stuff for URI handling */
if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) {
- GstURIHandlerInterface *iface = (GstURIHandlerInterface *)
- g_type_interface_peek (klass, GST_TYPE_URI_HANDLER);
+ GstURIHandlerInterface *iface = (GstURIHandlerInterface *)
+ g_type_interface_peek (klass, GST_TYPE_URI_HANDLER);
+
if (!iface || !iface->get_type || !iface->get_protocols)
goto error;
factory->uri_type = iface->get_type ();
__gst_element_factory_add_interface (factory, g_type_name (interfaces[i]));
}
g_free (interfaces);
-
+
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
gst_element_factory_cleanup (factory);
return FALSE;
}
+
/**
* gst_element_factory_create:
* @factory: factory to instantiate
*
* Returns: new #GstElement or NULL if the element couldn't be created
*/
-GstElement*
-gst_element_factory_create (GstElementFactory *factory,
- const gchar *name)
+GstElement *
+gst_element_factory_create (GstElementFactory * factory, const gchar * name)
{
GstElement *element;
GstElementClass *oclass;
if (name)
GST_INFO ("creating \"%s\" named \"%s\"", GST_PLUGIN_FEATURE_NAME (factory),
- GST_STR_NULL (name));
+ GST_STR_NULL (name));
else
GST_INFO ("creating \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
if (factory->type == 0) {
- g_critical ("Factory for `%s' has no type",
- GST_PLUGIN_FEATURE_NAME (factory));
- return NULL;
+ g_critical ("Factory for `%s' has no type",
+ GST_PLUGIN_FEATURE_NAME (factory));
+ return NULL;
}
- oclass = GST_ELEMENT_CLASS (g_type_class_ref (factory->type));
+ oclass = GST_ELEMENT_CLASS (g_type_class_ref (factory->type));
if (oclass->elementfactory == NULL)
oclass->elementfactory = factory;
return element;
}
+
/**
* gst_element_factory_make:
* @factoryname: a named factory to instantiate
*
* Returns: new #GstElement or NULL if unable to create element
*/
-GstElement*
-gst_element_factory_make (const gchar *factoryname, const gchar *name)
+GstElement *
+gst_element_factory_make (const gchar * factoryname, const gchar * name)
{
GstElementFactory *factory;
GstElement *element;
g_return_val_if_fail (factoryname != NULL, NULL);
- GST_LOG ("gstelementfactory: make \"%s\" \"%s\"",
- factoryname, GST_STR_NULL (name));
+ GST_LOG ("gstelementfactory: make \"%s\" \"%s\"",
+ factoryname, GST_STR_NULL (name));
/* gst_plugin_load_element_factory (factoryname); */
factory = gst_element_factory_find (factoryname);
if (factory == NULL) {
- GST_INFO ("no such element factory \"%s\"!",
- factoryname);
+ GST_INFO ("no such element factory \"%s\"!", factoryname);
return NULL;
}
element = gst_element_factory_create (factory, name);
return element;
}
+
void
-__gst_element_factory_add_pad_template (GstElementFactory *factory,
- GstPadTemplate *templ)
+__gst_element_factory_add_pad_template (GstElementFactory * factory,
+ GstPadTemplate * templ)
{
g_return_if_fail (factory != NULL);
g_return_if_fail (templ != NULL);
factory->padtemplates = g_list_append (factory->padtemplates, templ);
factory->numpadtemplates++;
}
+
/**
* gst_element_factory_get_element_type:
* @factory: factory to get managed #GType from
* Returns: the #GType for elements managed by this factory
*/
GType
-gst_element_factory_get_element_type (GstElementFactory *factory)
+gst_element_factory_get_element_type (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0);
return factory->type;
}
+
/**
* gst_element_factory_get_longname:
* @factory: a #GstElementFactory
* Returns: the longname
*/
G_CONST_RETURN gchar *
-gst_element_factory_get_longname (GstElementFactory *factory)
+gst_element_factory_get_longname (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->details.longname;
}
+
/**
* gst_element_factory_get_class:
* @factory: a #GstElementFactory
* Returns: the class
*/
G_CONST_RETURN gchar *
-gst_element_factory_get_klass (GstElementFactory *factory)
+gst_element_factory_get_klass (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->details.klass;
}
+
/**
* gst_element_factory_get_description:
* @factory: a #GstElementFactory
* Returns: the description
*/
G_CONST_RETURN gchar *
-gst_element_factory_get_description (GstElementFactory *factory)
+gst_element_factory_get_description (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->details.description;
}
+
/**
* gst_element_factory_get_author:
* @factory: a #GstElementFactory
* Returns: the author
*/
G_CONST_RETURN gchar *
-gst_element_factory_get_author (GstElementFactory *factory)
+gst_element_factory_get_author (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->details.author;
}
+
/**
* gst_element_factory_get_num_pad_templates:
* @factory: a #GstElementFactory
* Returns: the number of pad_templates
*/
guint
-gst_element_factory_get_num_pad_templates (GstElementFactory *factory)
+gst_element_factory_get_num_pad_templates (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0);
return factory->numpadtemplates;
}
+
/**
* __gst_element_factory_add_interface:
* @elementfactory: The elementfactory to add the interface to
* element.
*/
void
-__gst_element_factory_add_interface (GstElementFactory *elementfactory, const gchar *interfacename)
+__gst_element_factory_add_interface (GstElementFactory * elementfactory,
+ const gchar * interfacename)
{
g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory));
g_return_if_fail (interfacename != NULL);
- g_return_if_fail (interfacename[0] != '\0'); /* no empty string */
-
- elementfactory->interfaces = g_list_prepend (elementfactory->interfaces, g_strdup (interfacename));
+ g_return_if_fail (interfacename[0] != '\0'); /* no empty string */
+
+ elementfactory->interfaces =
+ g_list_prepend (elementfactory->interfaces, g_strdup (interfacename));
}
+
/**
* gst_element_factory_get_pad_templates:
* @factory: a #GstElementFactory
* Returns: the padtemplates
*/
G_CONST_RETURN GList *
-gst_element_factory_get_pad_templates (GstElementFactory *factory)
+gst_element_factory_get_pad_templates (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->padtemplates;
}
+
/**
* gst_element_factory_get_uri_type:
* @factory: a #GstElementFactory
* Returns: type of URIs this element supports
*/
guint
-gst_element_factory_get_uri_type (GstElementFactory *factory)
+gst_element_factory_get_uri_type (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), GST_URI_UNKNOWN);
return factory->uri_type;
}
+
/**
* gst_element_factory_get_uri_protocols:
* @factory: a #GstElementFactory
* Returns: the supported protocols or NULL
*/
gchar **
-gst_element_factory_get_uri_protocols (GstElementFactory *factory)
+gst_element_factory_get_uri_protocols (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->uri_protocols;
}
+
/**
* gst_element_factory_can_src_caps :
* @factory: factory to query
* Returns: true if it can src the capabilities
*/
gboolean
-gst_element_factory_can_src_caps (GstElementFactory *factory,
- const GstCaps *caps)
+gst_element_factory_can_src_caps (GstElementFactory * factory,
+ const GstCaps * caps)
{
GList *templates;
- g_return_val_if_fail(factory != NULL, FALSE);
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (factory != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->padtemplates;
while (templates) {
- GstPadTemplate *template = (GstPadTemplate *)templates->data;
+ GstPadTemplate *template = (GstPadTemplate *) templates->data;
if (template->direction == GST_PAD_SRC) {
- if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
+ if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template),
+ caps))
return TRUE;
}
templates = g_list_next (templates);
return FALSE;
}
+
/**
* gst_element_factory_can_sink_caps :
* @factory: factory to query
* Returns: true if it can sink the capabilities
*/
gboolean
-gst_element_factory_can_sink_caps (GstElementFactory *factory,
- const GstCaps *caps)
+gst_element_factory_can_sink_caps (GstElementFactory * factory,
+ const GstCaps * caps)
{
GList *templates;
- g_return_val_if_fail(factory != NULL, FALSE);
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (factory != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->padtemplates;
while (templates) {
- GstPadTemplate *template = (GstPadTemplate *)templates->data;
+ GstPadTemplate *template = (GstPadTemplate *) templates->data;
if (template->direction == GST_PAD_SINK) {
- if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
+ if (gst_caps_is_always_compatible (caps,
+ GST_PAD_TEMPLATE_CAPS (template)))
return TRUE;
}
templates = g_list_next (templates);
return FALSE;
}
static void
-gst_element_factory_unload_thyself (GstPluginFeature *feature)
+gst_element_factory_unload_thyself (GstPluginFeature * feature)
{
GstElementFactory *factory;
gst_g_error_get_type (void)
{
static GType type = 0;
-
+
if (!type)
type = g_boxed_type_register_static ("GstGError",
- (GBoxedCopyFunc) g_error_copy,
- (GBoxedFreeFunc) g_error_free);
- return type;
+ (GBoxedCopyFunc) g_error_copy, (GBoxedFreeFunc) g_error_free);
+ return type;
}
/* initialize the dynamic table of translated core errors */
-static gchar ** _gst_core_errors_init ()
+static gchar **
+_gst_core_errors_init ()
{
gchar **t = NULL;
t = g_new0 (gchar *, GST_CORE_ERROR_NUM_ERRORS);
TABLE (t, CORE, FAILED,
- N_("GStreamer encountered a general core library error."));
+ N_("GStreamer encountered a general core library error."));
TABLE (t, CORE, TOO_LAZY,
- N_("GStreamer developers were too lazy to assign an error code "
- "to this error. Please file a bug."));
+ N_("GStreamer developers were too lazy to assign an error code "
+ "to this error. Please file a bug."));
TABLE (t, CORE, NOT_IMPLEMENTED,
- N_("Internal GStreamer error: code not implemented. File a bug."));
+ N_("Internal GStreamer error: code not implemented. File a bug."));
TABLE (t, CORE, STATE_CHANGE,
- N_("Internal GStreamer error: state change failed. File a bug."));
+ N_("Internal GStreamer error: state change failed. File a bug."));
TABLE (t, CORE, PAD,
- N_("Internal GStreamer error: pad problem. File a bug."));
+ N_("Internal GStreamer error: pad problem. File a bug."));
TABLE (t, CORE, THREAD,
- N_("Internal GStreamer error: thread problem. File a bug."));
+ N_("Internal GStreamer error: thread problem. File a bug."));
TABLE (t, CORE, SCHEDULER,
- N_("Internal GStreamer error: scheduler problem. File a bug."));
+ N_("Internal GStreamer error: scheduler problem. File a bug."));
TABLE (t, CORE, NEGOTIATION,
- N_("Internal GStreamer error: negotiation problem. File a bug."));
+ N_("Internal GStreamer error: negotiation problem. File a bug."));
TABLE (t, CORE, EVENT,
- N_("Internal GStreamer error: event problem. File a bug."));
+ N_("Internal GStreamer error: event problem. File a bug."));
TABLE (t, CORE, SEEK,
- N_("Internal GStreamer error: seek problem. File a bug."));
+ N_("Internal GStreamer error: seek problem. File a bug."));
TABLE (t, CORE, CAPS,
- N_("Internal GStreamer error: caps problem. File a bug."));
+ N_("Internal GStreamer error: caps problem. File a bug."));
TABLE (t, CORE, TAG,
- N_("Internal GStreamer error: tag problem. File a bug."));
+ N_("Internal GStreamer error: tag problem. File a bug."));
return t;
}
/* initialize the dynamic table of translated library errors */
-static gchar ** _gst_library_errors_init ()
+static gchar **
+_gst_library_errors_init ()
{
gchar **t = NULL;
t = g_new0 (gchar *, GST_LIBRARY_ERROR_NUM_ERRORS);
TABLE (t, LIBRARY, FAILED,
- N_("GStreamer encountered a general supporting library error."));
+ N_("GStreamer encountered a general supporting library error."));
TABLE (t, LIBRARY, TOO_LAZY,
- N_("GStreamer developers were too lazy to assign an error code "
- "to this error. Please file a bug."));
- TABLE (t, LIBRARY, INIT,
- N_("Could not initialize supporting library."));
- TABLE (t, LIBRARY, SHUTDOWN,
- N_("Could not close supporting library."));
- TABLE (t, LIBRARY, SETTINGS,
- N_("Could not close supporting library."));
+ N_("GStreamer developers were too lazy to assign an error code "
+ "to this error. Please file a bug."));
+ TABLE (t, LIBRARY, INIT, N_("Could not initialize supporting library."));
+ TABLE (t, LIBRARY, SHUTDOWN, N_("Could not close supporting library."));
+ TABLE (t, LIBRARY, SETTINGS, N_("Could not close supporting library."));
return t;
}
/* initialize the dynamic table of translated resource errors */
-static gchar ** _gst_resource_errors_init ()
+static gchar **
+_gst_resource_errors_init ()
{
gchar **t = NULL;
t = g_new0 (gchar *, GST_RESOURCE_ERROR_NUM_ERRORS);
TABLE (t, RESOURCE, FAILED,
- N_("GStreamer encountered a general supporting library error."));
+ N_("GStreamer encountered a general supporting library error."));
TABLE (t, RESOURCE, TOO_LAZY,
- N_("GStreamer developers were too lazy to assign an error code "
- "to this error. Please file a bug."));
- TABLE (t, RESOURCE, NOT_FOUND,
- N_("Resource not found."));
- TABLE (t, RESOURCE, BUSY,
- N_("Resource busy or not available."));
- TABLE (t, RESOURCE, OPEN_READ,
- N_("Could not open resource for reading."));
- TABLE (t, RESOURCE, OPEN_WRITE,
- N_("Could not open resource for writing."));
+ N_("GStreamer developers were too lazy to assign an error code "
+ "to this error. Please file a bug."));
+ TABLE (t, RESOURCE, NOT_FOUND, N_("Resource not found."));
+ TABLE (t, RESOURCE, BUSY, N_("Resource busy or not available."));
+ TABLE (t, RESOURCE, OPEN_READ, N_("Could not open resource for reading."));
+ TABLE (t, RESOURCE, OPEN_WRITE, N_("Could not open resource for writing."));
TABLE (t, RESOURCE, OPEN_READ_WRITE,
- N_("Could not open resource for reading and writing."));
- TABLE (t, RESOURCE, CLOSE,
- N_("Could not close resource."));
- TABLE (t, RESOURCE, READ,
- N_("Could not read from resource."));
- TABLE (t, RESOURCE, WRITE,
- N_("Could not write to resource."));
- TABLE (t, RESOURCE, SEEK,
- N_("Could not perform seek on resource."));
- TABLE (t, RESOURCE, SYNC,
- N_("Could not synchronize on resource."));
+ N_("Could not open resource for reading and writing."));
+ TABLE (t, RESOURCE, CLOSE, N_("Could not close resource."));
+ TABLE (t, RESOURCE, READ, N_("Could not read from resource."));
+ TABLE (t, RESOURCE, WRITE, N_("Could not write to resource."));
+ TABLE (t, RESOURCE, SEEK, N_("Could not perform seek on resource."));
+ TABLE (t, RESOURCE, SYNC, N_("Could not synchronize on resource."));
TABLE (t, RESOURCE, SETTINGS,
- N_("Could not get/set settings from/on resource."));
+ N_("Could not get/set settings from/on resource."));
return t;
}
/* initialize the dynamic table of translated stream errors */
-static gchar ** _gst_stream_errors_init ()
+static gchar **
+_gst_stream_errors_init ()
{
gchar **t = NULL;
t = g_new0 (gchar *, GST_STREAM_ERROR_NUM_ERRORS);
TABLE (t, STREAM, FAILED,
- N_("GStreamer encountered a general supporting library error."));
+ N_("GStreamer encountered a general supporting library error."));
TABLE (t, STREAM, TOO_LAZY,
- N_("GStreamer developers were too lazy to assign an error code "
- "to this error. Please file a bug."));
+ N_("GStreamer developers were too lazy to assign an error code "
+ "to this error. Please file a bug."));
TABLE (t, STREAM, NOT_IMPLEMENTED,
- N_("Element doesn't implement handling of this stream. "
- "Please file a bug."));
- TABLE (t, STREAM, TYPE_NOT_FOUND,
- N_("Could not determine type of stream."));
+ N_("Element doesn't implement handling of this stream. "
+ "Please file a bug."));
+ TABLE (t, STREAM, TYPE_NOT_FOUND, N_("Could not determine type of stream."));
TABLE (t, STREAM, WRONG_TYPE,
- N_("The stream is of a different type than handled by this element."));
+ N_("The stream is of a different type than handled by this element."));
TABLE (t, STREAM, CODEC_NOT_FOUND,
- N_("There is no codec present that can handle the stream's type."));
- TABLE (t, STREAM, DECODE,
- N_("Could not decode stream."));
- TABLE (t, STREAM, ENCODE,
- N_("Could not encode stream."));
- TABLE (t, STREAM, DEMUX,
- N_("Could not demultiplex stream."));
- TABLE (t, STREAM, MUX,
- N_("Could not multiplex stream."));
- TABLE (t, STREAM, FORMAT,
- N_("Stream is of the wrong format."));
+ N_("There is no codec present that can handle the stream's type."));
+ TABLE (t, STREAM, DECODE, N_("Could not decode stream."));
+ TABLE (t, STREAM, ENCODE, N_("Could not encode stream."));
+ TABLE (t, STREAM, DEMUX, N_("Could not demultiplex stream."));
+ TABLE (t, STREAM, MUX, N_("Could not multiplex stream."));
+ TABLE (t, STREAM, FORMAT, N_("Stream is of the wrong format."));
return t;
}
QUARK_FUNC (core)
-QUARK_FUNC (library)
-QUARK_FUNC (resource)
-QUARK_FUNC (stream)
+ QUARK_FUNC (library)
+ QUARK_FUNC (resource)
+ QUARK_FUNC (stream)
/**
* gst_error_get_message:
* Returns: a newly allocated string describing the error message in the
* current locale.
*/
-
-gchar *
-gst_error_get_message (GQuark domain, gint code)
+ gchar *gst_error_get_message (GQuark domain, gint code)
{
static gchar **gst_core_errors = NULL;
static gchar **gst_library_errors = NULL;
gst_stream_errors = _gst_stream_errors_init ();
- if (domain == GST_CORE_ERROR) message = gst_core_errors [code];
- else if (domain == GST_LIBRARY_ERROR) message = gst_library_errors [code];
- else if (domain == GST_RESOURCE_ERROR) message = gst_resource_errors[code];
- else if (domain == GST_STREAM_ERROR) message = gst_stream_errors [code];
- else
- {
+ if (domain == GST_CORE_ERROR)
+ message = gst_core_errors[code];
+ else if (domain == GST_LIBRARY_ERROR)
+ message = gst_library_errors[code];
+ else if (domain == GST_RESOURCE_ERROR)
+ message = gst_resource_errors[code];
+ else if (domain == GST_STREAM_ERROR)
+ message = gst_stream_errors[code];
+ else {
g_warning ("No error messages for domain %s", g_quark_to_string (domain));
- return g_strdup_printf (_("No error message for domain %s."), g_quark_to_string (domain));
+ return g_strdup_printf (_("No error message for domain %s."),
+ g_quark_to_string (domain));
}
if (message)
return g_strdup (_(message));
else
- return g_strdup_printf (_("No standard error message for domain %s and code %d."),
- g_quark_to_string (domain), code);
+ return
+ g_strdup_printf (_
+ ("No standard error message for domain %s and code %d."),
+ g_quark_to_string (domain), code);
}
#define __GST_ERROR_H__
G_BEGIN_DECLS
-
/*
* we define FIXME error domains:
* GST_CORE_ERROR
*
* Check GError API docs for rationale for naming.
*/
-
/* Core errors are anything that can go wrong in or using
* the core GStreamer library */
/* FIXME: should we divide in numerical blocks so we can easily add
for example PAD errors later ? */
-typedef enum {
+ typedef enum
+{
GST_CORE_ERROR_FAILED = 1,
GST_CORE_ERROR_TOO_LAZY,
GST_CORE_ERROR_NOT_IMPLEMENTED,
/* Library errors are for errors from the library being used by elements
initializing, closing, ... */
-typedef enum {
+typedef enum
+{
GST_LIBRARY_ERROR_FAILED = 1,
GST_LIBRARY_ERROR_TOO_LAZY,
GST_LIBRARY_ERROR_INIT,
/* Resource errors are for anything external used by an element:
memory, files, network connections, process space, ...
They're typically used by source and sink elements */
-typedef enum {
+typedef enum
+{
GST_RESOURCE_ERROR_FAILED = 1,
GST_RESOURCE_ERROR_TOO_LAZY,
GST_RESOURCE_ERROR_NOT_FOUND,
/* Stream errors are for anything related to the stream being processed:
format errors, media type errors, ...
They're typically used by decoders, demuxers, converters, ... */
-typedef enum {
+typedef enum
+{
GST_STREAM_ERROR_FAILED = 1,
GST_STREAM_ERROR_TOO_LAZY,
GST_STREAM_ERROR_NOT_IMPLEMENTED,
#define GST_ERROR_SYSTEM ("system error: %s", g_strerror (errno))
-GType gst_g_error_get_type (void);
-gchar * gst_error_get_message (GQuark domain, gint code);
-GQuark gst_stream_error_quark (void);
-GQuark gst_core_error_quark (void);
-GQuark gst_resource_error_quark (void);
-GQuark gst_library_error_quark (void);
+GType gst_g_error_get_type (void);
+gchar *gst_error_get_message (GQuark domain, gint code);
+GQuark gst_stream_error_quark (void);
+GQuark gst_core_error_quark (void);
+GQuark gst_resource_error_quark (void);
+GQuark gst_library_error_quark (void);
G_END_DECLS
-
#endif /* __GST_ERROR_H__ */
-
-
{
/* register the type */
_gst_event_type = g_boxed_type_register_static ("GstEvent",
- (GBoxedCopyFunc) gst_data_copy,
- (GBoxedFreeFunc) gst_data_unref);
+ (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref);
#ifndef GST_DISABLE_TRACE
_event_trace = gst_alloc_trace_register (GST_EVENT_TRACE_NAME);
#endif
chunk = gst_mem_chunk_new ("GstEventChunk", sizeof (GstEvent),
- sizeof (GstEvent) * 50, 0);
+ sizeof (GstEvent) * 50, 0);
}
-static GstEvent*
-_gst_event_copy (GstEvent *event)
+static GstEvent *
+_gst_event_copy (GstEvent * event)
{
GstEvent *copy;
#endif
memcpy (copy, event, sizeof (GstEvent));
-
+
/* FIXME copy/ref additional fields */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG:
- copy->event_data.structure.structure = gst_tag_list_copy ((GstTagList *) event->event_data.structure.structure);
+ copy->event_data.structure.structure =
+ gst_tag_list_copy ((GstTagList *) event->event_data.structure.
+ structure);
break;
case GST_EVENT_NAVIGATION:
- copy->event_data.structure.structure = gst_structure_copy (event->event_data.structure.structure);
+ copy->event_data.structure.structure =
+ gst_structure_copy (event->event_data.structure.structure);
default:
break;
}
}
static void
-_gst_event_free (GstEvent* event)
+_gst_event_free (GstEvent * event)
{
GST_CAT_INFO (GST_CAT_EVENT, "freeing event %p", event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG:
if (GST_IS_TAG_LIST (event->event_data.structure.structure)) {
- gst_tag_list_free (event->event_data.structure.structure);
+ gst_tag_list_free (event->event_data.structure.structure);
} else {
g_warning ("tag event %p didn't contain a valid tag list!", event);
GST_ERROR ("tag event %p didn't contain a valid tag list!", event);
* Returns: TRUE if the eventmask is found inside the array
*/
gboolean
-gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask)
+gst_event_masks_contains (const GstEventMask * masks, GstEventMask * mask)
{
g_return_val_if_fail (mask != NULL, FALSE);
if (!masks)
return FALSE;
-
+
while (masks->type) {
if (masks->type == mask->type &&
- (masks->flags & mask->flags) == mask->flags)
+ (masks->flags & mask->flags) == mask->flags)
return TRUE;
masks++;
*
* Returns: A new event.
*/
-GstEvent*
+GstEvent *
gst_event_new (GstEventType type)
{
GstEvent *event;
GST_CAT_INFO (GST_CAT_EVENT, "creating new event %p %d", event, type);
_GST_DATA_INIT (GST_DATA (event),
- _gst_event_type,
- 0,
- (GstDataFreeFunction) _gst_event_free,
- (GstDataCopyFunction) _gst_event_copy);
+ _gst_event_type,
+ 0,
+ (GstDataFreeFunction) _gst_event_free,
+ (GstDataCopyFunction) _gst_event_copy);
GST_EVENT_TYPE (event) = type;
GST_EVENT_TIMESTAMP (event) = G_GINT64_CONSTANT (0);
*
* Returns: A new seek event.
*/
-GstEvent*
+GstEvent *
gst_event_new_seek (GstSeekType type, gint64 offset)
{
GstEvent *event;
*
* Returns: A new discontinuous event.
*/
-GstEvent*
-gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, va_list var_args)
+GstEvent *
+gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1,
+ va_list var_args)
{
GstEvent *event;
gint count = 0;
while (format1 != GST_FORMAT_UNDEFINED && count < 8) {
- GST_EVENT_DISCONT_OFFSET (event, count).format = format1 & GST_SEEK_FORMAT_MASK;
+ GST_EVENT_DISCONT_OFFSET (event, count).format =
+ format1 & GST_SEEK_FORMAT_MASK;
GST_EVENT_DISCONT_OFFSET (event, count).value = va_arg (var_args, gint64);
format1 = va_arg (var_args, GstFormat);
}
GST_EVENT_DISCONT_OFFSET_LEN (event) = count;
-
+
return event;
}
*
* Returns: A new discontinuous event.
*/
-GstEvent*
+GstEvent *
gst_event_new_discontinuous (gboolean new_media, GstFormat format1, ...)
{
va_list var_args;
* Returns: TRUE if the discont event caries the specified format/value pair.
*/
gboolean
-gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value)
+gst_event_discont_get_value (GstEvent * event, GstFormat format, gint64 * value)
{
gint i, n;
n = GST_EVENT_DISCONT_OFFSET_LEN (event);
for (i = 0; i < n; i++) {
- if (GST_EVENT_DISCONT_OFFSET(event,i).format == format) {
- *value = GST_EVENT_DISCONT_OFFSET(event,i).value;
+ if (GST_EVENT_DISCONT_OFFSET (event, i).format == format) {
+ *value = GST_EVENT_DISCONT_OFFSET (event, i).value;
return TRUE;
}
}
-
+
return FALSE;
}
*
* Returns: The new size event.
*/
-GstEvent*
+GstEvent *
gst_event_new_size (GstFormat format, gint64 value)
{
GstEvent *event;
GST_EVENT_SIZE_FORMAT (event) = format;
GST_EVENT_SIZE_VALUE (event) = value;
-
+
return event;
}
*
* Returns: A new segment seek event.
*/
-GstEvent*
+GstEvent *
gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop)
{
GstEvent *event;
#include <gst/gstobject.h>
#include <gst/gststructure.h>
-G_BEGIN_DECLS
-
-extern GType _gst_event_type;
-
-typedef enum {
- GST_EVENT_UNKNOWN = 0,
- GST_EVENT_EOS = 1,
- GST_EVENT_FLUSH = 2,
- GST_EVENT_EMPTY = 3,
- GST_EVENT_DISCONTINUOUS = 4,
- /*GST_EVENT_NEW_MEDIA = 5, <- removed */
- GST_EVENT_QOS = 6,
- GST_EVENT_SEEK = 7,
- GST_EVENT_SEEK_SEGMENT = 8,
- GST_EVENT_SEGMENT_DONE = 9,
- GST_EVENT_SIZE = 10,
- GST_EVENT_RATE = 11,
- GST_EVENT_FILLER = 12,
- GST_EVENT_TS_OFFSET = 13,
- GST_EVENT_INTERRUPT = 14,
- GST_EVENT_NAVIGATION = 15,
- GST_EVENT_TAG = 16
+G_BEGIN_DECLS extern GType _gst_event_type;
+
+typedef enum
+{
+ GST_EVENT_UNKNOWN = 0,
+ GST_EVENT_EOS = 1,
+ GST_EVENT_FLUSH = 2,
+ GST_EVENT_EMPTY = 3,
+ GST_EVENT_DISCONTINUOUS = 4,
+ /*GST_EVENT_NEW_MEDIA = 5, <- removed */
+ GST_EVENT_QOS = 6,
+ GST_EVENT_SEEK = 7,
+ GST_EVENT_SEEK_SEGMENT = 8,
+ GST_EVENT_SEGMENT_DONE = 9,
+ GST_EVENT_SIZE = 10,
+ GST_EVENT_RATE = 11,
+ GST_EVENT_FILLER = 12,
+ GST_EVENT_TS_OFFSET = 13,
+ GST_EVENT_INTERRUPT = 14,
+ GST_EVENT_NAVIGATION = 15,
+ GST_EVENT_TAG = 16
} GstEventType;
#define GST_EVENT_TRACE_NAME "GstEvent"
#define GST_SEEK_METHOD_MASK 0x000f0000
#define GST_SEEK_FLAGS_MASK 0xfff00000
-typedef enum {
- GST_EVENT_FLAG_NONE = 0,
+typedef enum
+{
+ GST_EVENT_FLAG_NONE = 0,
/* indicates negative rates are supported */
- GST_RATE_FLAG_NEGATIVE = (1 << 1)
+ GST_RATE_FLAG_NEGATIVE = (1 << 1)
} GstEventFlag;
typedef struct
{
- GstEventType type;
- GstEventFlag flags;
+ GstEventType type;
+ GstEventFlag flags;
} GstEventMask;
#ifndef GST_DISABLE_DEPRECATED
#endif
/* seek events, extends GstEventFlag */
-typedef enum {
+typedef enum
+{
/* | with some format */
/* | with one of these */
- GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
- GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
- GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
+ GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
+ GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
+ GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
/* | with optional seek flags */
/* seek flags */
- GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
- GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
- GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
- GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
-
+ GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
+ GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
+ GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
+ GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
+
} GstSeekType;
-typedef enum {
+typedef enum
+{
GST_SEEK_CERTAIN,
GST_SEEK_FUZZY
} GstSeekAccuracy;
typedef struct
{
- GstFormat format;
- gint64 value;
+ GstFormat format;
+ gint64 value;
} GstFormatValue;
#define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type)
#define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value)
-struct _GstEvent {
+struct _GstEvent
+{
GstData data;
- GstEventType type;
- guint64 timestamp;
- GstObject *src;
-
- union {
- struct {
- GstSeekType type;
- gint64 offset;
- gint64 endoffset;
- GstSeekAccuracy accuracy;
+ GstEventType type;
+ guint64 timestamp;
+ GstObject *src;
+
+ union
+ {
+ struct
+ {
+ GstSeekType type;
+ gint64 offset;
+ gint64 endoffset;
+ GstSeekAccuracy accuracy;
} seek;
- struct {
- GstFormatValue offsets[8];
- gint noffsets;
- gboolean new_media;
+ struct
+ {
+ GstFormatValue offsets[8];
+ gint noffsets;
+ gboolean new_media;
} discont;
- struct {
- GstFormat format;
- gint64 value;
+ struct
+ {
+ GstFormat format;
+ gint64 value;
} size;
- struct {
- gdouble value;
+ struct
+ {
+ gdouble value;
} rate;
- struct {
- GstStructure *structure;
+ struct
+ {
+ GstStructure *structure;
} structure;
} event_data;
gpointer _gst_reserved[GST_PADDING];
};
-void _gst_event_initialize (void);
-
-GType gst_event_get_type (void);
-GstEvent* gst_event_new (GstEventType type);
+void _gst_event_initialize (void);
+
+GType gst_event_get_type (void);
+GstEvent *gst_event_new (GstEventType type);
/* refcounting */
#define gst_event_ref(ev) GST_EVENT (gst_data_ref (GST_DATA (ev)))
/* copy buffer */
#define gst_event_copy(ev) GST_EVENT (gst_data_copy (GST_DATA (ev)))
-gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask);
+gboolean gst_event_masks_contains (const GstEventMask * masks,
+ GstEventMask * mask);
/* seek event */
-GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
+GstEvent *gst_event_new_seek (GstSeekType type, gint64 offset);
-GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop);
+GstEvent *gst_event_new_segment_seek (GstSeekType type, gint64 start,
+ gint64 stop);
/* size events */
-GstEvent* gst_event_new_size (GstFormat format, gint64 value);
+GstEvent *gst_event_new_size (GstFormat format, gint64 value);
/* discontinous event */
-GstEvent* gst_event_new_discontinuous (gboolean new_media,
- GstFormat format1, ...);
-GstEvent* gst_event_new_discontinuous_valist (gboolean new_media,
- GstFormat format1,
- va_list var_args);
-gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value);
+GstEvent *gst_event_new_discontinuous (gboolean new_media,
+ GstFormat format1, ...);
+GstEvent *gst_event_new_discontinuous_valist (gboolean new_media,
+ GstFormat format1, va_list var_args);
+gboolean gst_event_discont_get_value (GstEvent * event, GstFormat format,
+ gint64 * value);
#define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER)
#define gst_event_new_flush() gst_event_new(GST_EVENT_FLUSH)
G_END_DECLS
-
#endif /* __GST_EVENT_H__ */
#include <gst/gstfilter.h>
-GList*
-gst_filter_run (const GList *list, GstFilterFunc func, gboolean first, gpointer user_data)
+GList *
+gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
+ gpointer user_data)
{
const GList *walk = list;
GList *result = NULL;
gpointer data = walk->data;
walk = g_list_next (walk);
-
+
if (func)
res = func (data, user_data);
#include <glib.h>
G_BEGIN_DECLS
+ typedef gboolean (*GstFilterFunc) (gpointer obj, gpointer user_data);
-typedef gboolean (*GstFilterFunc) (gpointer obj, gpointer user_data);
-
-GList* gst_filter_run (const GList *list, GstFilterFunc func, gboolean first, gpointer user_data);
+GList *gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
+ gpointer user_data);
G_END_DECLS
-
#endif /* __GST_FILTER_H_ */
static GList *_gst_formats = NULL;
static GHashTable *_nick_to_format = NULL;
static GHashTable *_format_to_nick = NULL;
-static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */
+static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */
static GstFormatDefinition standard_definitions[] = {
- { GST_FORMAT_DEFAULT, "default", "Default format for the media type" },
- { GST_FORMAT_BYTES, "bytes", "Bytes" },
- { GST_FORMAT_TIME, "time", "Time" },
- { GST_FORMAT_BUFFERS, "buffers", "Buffers" },
- { GST_FORMAT_PERCENT, "percent", "Percent" },
- { 0, NULL, NULL }
+ {GST_FORMAT_DEFAULT, "default", "Default format for the media type"},
+ {GST_FORMAT_BYTES, "bytes", "Bytes"},
+ {GST_FORMAT_TIME, "time", "Time"},
+ {GST_FORMAT_BUFFERS, "buffers", "Buffers"},
+ {GST_FORMAT_PERCENT, "percent", "Percent"},
+ {0, NULL, NULL}
};
-void
+void
_gst_format_initialize (void)
{
GstFormatDefinition *standards = standard_definitions;
_nick_to_format = g_hash_table_new (g_str_hash, g_str_equal);
_format_to_nick = g_hash_table_new (NULL, NULL);
}
-
+
while (standards->nick) {
g_hash_table_insert (_nick_to_format, standards->nick, standards);
- g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value), standards);
+ g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value),
+ standards);
_gst_formats = g_list_append (_gst_formats, standards);
standards++;
* with the same nick.
*/
GstFormat
-gst_format_register (const gchar *nick, const gchar *description)
+gst_format_register (const gchar * nick, const gchar * description)
{
GstFormatDefinition *format;
GstFormat query;
-
+
g_return_val_if_fail (nick != NULL, 0);
g_return_val_if_fail (description != NULL, 0);
query = gst_format_get_by_nick (nick);
if (query != GST_FORMAT_UNDEFINED)
return query;
-
+
format = g_new0 (GstFormatDefinition, 1);
format->value = _n_values;
format->nick = g_strdup (nick);
format->description = g_strdup (description);
g_hash_table_insert (_nick_to_format, format->nick, format);
- g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (format->value), format);
+ g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (format->value),
+ format);
_gst_formats = g_list_append (_gst_formats, format);
_n_values++;
-
+
return format->value;
}
* if the format was not registered.
*/
GstFormat
-gst_format_get_by_nick (const gchar *nick)
+gst_format_get_by_nick (const gchar * nick)
{
GstFormatDefinition *format;
-
+
g_return_val_if_fail (nick != NULL, 0);
format = g_hash_table_lookup (_nick_to_format, nick);
-
+
if (format != NULL)
return format->value;
else
* Returns: TRUE if the format is found inside the array
*/
gboolean
-gst_formats_contains (const GstFormat *formats, GstFormat format)
+gst_formats_contains (const GstFormat * formats, GstFormat format)
{
if (!formats)
return FALSE;
*
* Returns: The #GstFormatDefinition for @format or NULL on failure.
*/
-const GstFormatDefinition*
+const GstFormatDefinition *
gst_format_get_details (GstFormat format)
{
return g_hash_table_lookup (_format_to_nick, GINT_TO_POINTER (format));
*
* Returns: A GList of #GstFormatDefinition.
*/
-const GList*
+const GList *
gst_format_get_definitions (void)
{
return _gst_formats;
#include <glib.h>
-G_BEGIN_DECLS
-
-typedef enum {
- GST_FORMAT_UNDEFINED = 0, /* must be first in list */
- GST_FORMAT_DEFAULT = 1, /* samples for audio, frames/fields for video */
- GST_FORMAT_BYTES = 2,
- GST_FORMAT_TIME = 3,
- GST_FORMAT_BUFFERS = 4,
- GST_FORMAT_PERCENT = 5
+G_BEGIN_DECLS typedef enum
+{
+ GST_FORMAT_UNDEFINED = 0, /* must be first in list */
+ GST_FORMAT_DEFAULT = 1, /* samples for audio, frames/fields for video */
+ GST_FORMAT_BYTES = 2,
+ GST_FORMAT_TIME = 3,
+ GST_FORMAT_BUFFERS = 4,
+ GST_FORMAT_PERCENT = 5
} GstFormat;
/* a percentage is always relative to 1000000 */
typedef struct _GstFormatDefinition GstFormatDefinition;
-struct _GstFormatDefinition
+struct _GstFormatDefinition
{
- GstFormat value;
- gchar *nick;
- gchar *description;
+ GstFormat value;
+ gchar *nick;
+ gchar *description;
};
#ifdef G_HAVE_ISO_VARARGS
}
#endif
-void _gst_format_initialize (void);
+void _gst_format_initialize (void);
/* register a new format */
-GstFormat gst_format_register (const gchar *nick,
- const gchar *description);
-GstFormat gst_format_get_by_nick (const gchar *nick);
+GstFormat gst_format_register (const gchar * nick, const gchar * description);
+GstFormat gst_format_get_by_nick (const gchar * nick);
/* check if a format is in an array of formats */
-gboolean gst_formats_contains (const GstFormat *formats, GstFormat format);
+gboolean gst_formats_contains (const GstFormat * formats, GstFormat format);
/* query for format details */
-G_CONST_RETURN GstFormatDefinition*
- gst_format_get_details (GstFormat format);
-G_CONST_RETURN GList*
- gst_format_get_definitions (void);
+G_CONST_RETURN GstFormatDefinition *gst_format_get_details (GstFormat format);
+G_CONST_RETURN GList *gst_format_get_definitions (void);
G_END_DECLS
-
#endif /* __GST_FORMAT_H__ */
#include "gstmarshal.h"
/* Index signals and args */
-enum {
+enum
+{
ENTRY_ADDED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_RESOLVER
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_index_class_init (GstIndexClass *klass);
-static void gst_index_init (GstIndex *index);
+static void gst_index_class_init (GstIndexClass * klass);
+static void gst_index_init (GstIndex * index);
-static void gst_index_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_index_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_index_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_index_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstIndexGroup* gst_index_group_new (guint groupnum);
+static GstIndexGroup *gst_index_group_new (guint groupnum);
-static gboolean gst_index_path_resolver (GstIndex *index, GstObject *writer,
- gchar **writer_string, gpointer data);
-static gboolean gst_index_gtype_resolver (GstIndex *index, GstObject *writer,
- gchar **writer_string, gpointer data);
-static void gst_index_add_entry (GstIndex *index, GstIndexEntry *entry);
+static gboolean gst_index_path_resolver (GstIndex * index, GstObject * writer,
+ gchar ** writer_string, gpointer data);
+static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
+ gchar ** writer_string, gpointer data);
+static void gst_index_add_entry (GstIndex * index, GstIndexEntry * entry);
static GstObject *parent_class = NULL;
static guint gst_index_signals[LAST_SIGNAL] = { 0 };
typedef struct
{
GstIndexResolverMethod method;
- GstIndexResolver resolver;
- gpointer user_data;
+ GstIndexResolver resolver;
+ gpointer user_data;
} ResolverEntry;
-static const ResolverEntry resolvers[] =
-{
- { GST_INDEX_RESOLVER_CUSTOM, NULL, NULL },
- { GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL },
- { GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL },
+static const ResolverEntry resolvers[] = {
+ {GST_INDEX_RESOLVER_CUSTOM, NULL, NULL},
+ {GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL},
+ {GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL},
};
#define GST_TYPE_INDEX_RESOLVER (gst_index_resolver_get_type())
{
static GType index_resolver_type = 0;
static GEnumValue index_resolver[] = {
- { GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", "Use a custom resolver"},
- { GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", "Resolve an object to its GType[.padname]"},
- { GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", "Resolve an object to its path in the pipeline"},
+ {GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM",
+ "Use a custom resolver"},
+ {GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE",
+ "Resolve an object to its GType[.padname]"},
+ {GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH",
+ "Resolve an object to its path in the pipeline"},
{0, NULL, NULL},
};
if (!index_resolver_type) {
- index_resolver_type = g_enum_register_static ("GstIndexResolver", index_resolver);
+ index_resolver_type =
+ g_enum_register_static ("GstIndexResolver", index_resolver);
}
return index_resolver_type;
}
if (!index_entry_type) {
index_entry_type = g_boxed_type_register_static ("GstIndexEntry",
- (GBoxedCopyFunc) gst_index_entry_copy,
- (GBoxedFreeFunc) gst_index_entry_free);
+ (GBoxedCopyFunc) gst_index_entry_copy,
+ (GBoxedFreeFunc) gst_index_entry_free);
}
return index_entry_type;
}
GType
-gst_index_get_type (void) {
+gst_index_get_type (void)
+{
static GType index_type = 0;
if (!index_type) {
static const GTypeInfo index_info = {
- sizeof(GstIndexClass),
+ sizeof (GstIndexClass),
NULL,
NULL,
- (GClassInitFunc)gst_index_class_init,
+ (GClassInitFunc) gst_index_class_init,
NULL,
NULL,
- sizeof(GstIndex),
+ sizeof (GstIndex),
1,
- (GInstanceInitFunc)gst_index_init,
+ (GInstanceInitFunc) gst_index_init,
NULL
};
- index_type = g_type_register_static(GST_TYPE_OBJECT, "GstIndex", &index_info, 0);
+ index_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstIndex", &index_info, 0);
}
return index_type;
}
static void
-gst_index_class_init (GstIndexClass *klass)
+gst_index_class_init (GstIndexClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_OBJECT);
+ parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gst_index_signals[ENTRY_ADDED] =
- g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL,
- gst_marshal_VOID__BOXED, G_TYPE_NONE, 1,
- GST_TYPE_INDEX_ENTRY);
+ g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL,
+ gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_index_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_index_get_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RESOLVER,
- g_param_spec_enum ("resolver", "Resolver", "Select a predefined object to string mapper",
- GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE));
+ g_param_spec_enum ("resolver", "Resolver",
+ "Select a predefined object to string mapper",
+ GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE));
}
static void
-gst_index_init (GstIndex *index)
+gst_index_init (GstIndex * index)
{
- index->curgroup = gst_index_group_new(0);
+ index->curgroup = gst_index_group_new (0);
index->maxgroup = 0;
- index->groups = g_list_prepend(NULL, index->curgroup);
+ index->groups = g_list_prepend (NULL, index->curgroup);
index->writers = g_hash_table_new (NULL, NULL);
index->last_id = 0;
GST_FLAG_SET (index, GST_INDEX_WRITABLE);
GST_FLAG_SET (index, GST_INDEX_READABLE);
-
- GST_DEBUG ( "created new index");
+
+ GST_DEBUG ("created new index");
}
static void
-gst_index_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_index_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstIndex *index;
}
static void
-gst_index_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_index_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstIndex *index;
}
static GstIndexGroup *
-gst_index_group_new(guint groupnum)
+gst_index_group_new (guint groupnum)
{
- GstIndexGroup *indexgroup = g_new(GstIndexGroup,1);
+ GstIndexGroup *indexgroup = g_new (GstIndexGroup, 1);
indexgroup->groupnum = groupnum;
indexgroup->entries = NULL;
indexgroup->certainty = GST_INDEX_UNKNOWN;
indexgroup->peergroup = -1;
- GST_DEBUG ( "created new index group %d",groupnum);
+ GST_DEBUG ("created new index group %d", groupnum);
return indexgroup;
}
*
* Returns: a new index object
*/
-GstIndex*
+GstIndex *
gst_index_new (void)
{
GstIndex *index;
* to it.
*/
void
-gst_index_commit (GstIndex *index, gint id)
+gst_index_commit (GstIndex * index, gint id)
{
GstIndexClass *iclass;
* Returns: the id of the current group.
*/
gint
-gst_index_get_group(GstIndex *index)
+gst_index_get_group (GstIndex * index)
{
return index->curgroup->groupnum;
}
* Returns: the id of the newly created group.
*/
gint
-gst_index_new_group(GstIndex *index)
+gst_index_new_group (GstIndex * index)
{
- index->curgroup = gst_index_group_new(++index->maxgroup);
- index->groups = g_list_append(index->groups,index->curgroup);
- GST_DEBUG ( "created new group %d in index",index->maxgroup);
+ index->curgroup = gst_index_group_new (++index->maxgroup);
+ index->groups = g_list_append (index->groups, index->curgroup);
+ GST_DEBUG ("created new group %d in index", index->maxgroup);
return index->maxgroup;
}
* did not exist.
*/
gboolean
-gst_index_set_group(GstIndex *index, gint groupnum)
+gst_index_set_group (GstIndex * index, gint groupnum)
{
GList *list;
GstIndexGroup *indexgroup;
/* else search for the proper group */
list = index->groups;
while (list) {
- indexgroup = (GstIndexGroup *)(list->data);
- list = g_list_next(list);
+ indexgroup = (GstIndexGroup *) (list->data);
+ list = g_list_next (list);
if (indexgroup->groupnum == groupnum) {
index->curgroup = indexgroup;
- GST_DEBUG ( "switched to index group %d", indexgroup->groupnum);
+ GST_DEBUG ("switched to index group %d", indexgroup->groupnum);
return TRUE;
}
}
/* couldn't find the group in question */
- GST_DEBUG ( "couldn't find index group %d",groupnum);
+ GST_DEBUG ("couldn't find index group %d", groupnum);
return FALSE;
}
* Set the certainty of the given index.
*/
void
-gst_index_set_certainty(GstIndex *index, GstIndexCertainty certainty)
+gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty)
{
index->curgroup->certainty = certainty;
}
* Returns: the certainty of the index.
*/
GstIndexCertainty
-gst_index_get_certainty(GstIndex *index)
+gst_index_get_certainty (GstIndex * index)
{
return index->curgroup->certainty;
}
* it can select what entries should be stored in the index.
*/
void
-gst_index_set_filter (GstIndex *index,
- GstIndexFilter filter, gpointer user_data)
+gst_index_set_filter (GstIndex * index,
+ GstIndexFilter filter, gpointer user_data)
{
g_return_if_fail (GST_IS_INDEX (index));
* ids to writer descriptions.
*/
void
-gst_index_set_resolver (GstIndex *index,
- GstIndexResolver resolver, gpointer user_data)
+gst_index_set_resolver (GstIndex * index,
+ GstIndexResolver resolver, gpointer user_data)
{
g_return_if_fail (GST_IS_INDEX (index));
* Copies an entry and returns the result.
*/
GstIndexEntry *
-gst_index_entry_copy (GstIndexEntry *entry)
+gst_index_entry_copy (GstIndexEntry * entry)
{
- return g_memdup(entry, sizeof(*entry));
+ return g_memdup (entry, sizeof (*entry));
}
/**
* Free the memory used by the given entry.
*/
void
-gst_index_entry_free (GstIndexEntry *entry)
+gst_index_entry_free (GstIndexEntry * entry)
{
g_free (entry);
}
*
* Returns: a pointer to the newly added entry in the index.
*/
-GstIndexEntry*
-gst_index_add_format (GstIndex *index, gint id, GstFormat format)
+GstIndexEntry *
+gst_index_add_format (GstIndex * index, gint id, GstFormat format)
{
GstIndexEntry *entry;
- const GstFormatDefinition* def;
+ const GstFormatDefinition *def;
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (format != 0, NULL);
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
-
+
entry = g_new0 (GstIndexEntry, 1);
entry->type = GST_INDEX_ENTRY_FORMAT;
entry->id = id;
*
* Returns: a pointer to the newly added entry in the index.
*/
-GstIndexEntry*
-gst_index_add_id (GstIndex *index, gint id, gchar *description)
+GstIndexEntry *
+gst_index_add_id (GstIndex * index, gint id, gchar * description)
{
GstIndexEntry *entry;
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (description != NULL, NULL);
-
+
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
-
+
entry = g_new0 (GstIndexEntry, 1);
entry->type = GST_INDEX_ENTRY_ID;
entry->id = id;
}
static gboolean
-gst_index_path_resolver (GstIndex *index, GstObject *writer,
- gchar **writer_string, gpointer data)
+gst_index_path_resolver (GstIndex * index, GstObject * writer,
+ gchar ** writer_string, gpointer data)
{
*writer_string = gst_object_get_path_string (writer);
}
static gboolean
-gst_index_gtype_resolver (GstIndex *index, GstObject *writer,
- gchar **writer_string, gpointer data)
+gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
+ gchar ** writer_string, gpointer data)
{
if (GST_IS_PAD (writer)) {
GstElement *element = gst_pad_get_parent (GST_PAD (writer));
- *writer_string = g_strdup_printf ("%s.%s",
- g_type_name (G_OBJECT_TYPE (element)),
- gst_object_get_name (writer));
- }
- else {
- *writer_string = g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer)));
+ *writer_string = g_strdup_printf ("%s.%s",
+ g_type_name (G_OBJECT_TYPE (element)), gst_object_get_name (writer));
+ } else {
+ *writer_string =
+ g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer)));
}
return TRUE;
*
* Returns: TRUE if the writer would be mapped to an id.
*/
-gboolean
-gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id)
+gboolean
+gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id)
{
gchar *writer_string = NULL;
GstIndexEntry *entry;
/* first try to get a previously cached id */
entry = g_hash_table_lookup (index->writers, writer);
- if (entry == NULL) {
+ if (entry == NULL) {
iclass = GST_INDEX_GET_CLASS (index);
if (index->resolver) {
gboolean res;
- res = index->resolver (index, writer, &writer_string, index->resolver_user_data);
- if (!res)
- return FALSE;
- }
- else {
+ res =
+ index->resolver (index, writer, &writer_string,
+ index->resolver_user_data);
+ if (!res)
+ return FALSE;
+ } else {
g_warning ("no resolver found");
return FALSE;
}
entry->data.id.description = writer_string;
}
g_hash_table_insert (index->writers, writer, entry);
- }
- else {
+ } else {
*id = entry->id;
}
}
static void
-gst_index_add_entry (GstIndex *index, GstIndexEntry *entry)
+gst_index_add_entry (GstIndex * index, GstIndexEntry * entry)
{
GstIndexClass *iclass;
*
* Returns: a pointer to the newly added entry in the index.
*/
-GstIndexEntry*
-gst_index_add_associationv (GstIndex *index, gint id, GstAssocFlags flags,
- int n, const GstIndexAssociation *list)
+GstIndexEntry *
+gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags,
+ int n, const GstIndexAssociation * list)
{
GstIndexEntry *entry;
g_return_val_if_fail (n > 0, NULL);
g_return_val_if_fail (list != NULL, NULL);
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
-
+
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
-
+
entry = g_malloc (sizeof (GstIndexEntry));
entry->type = GST_INDEX_ENTRY_ASSOCIATION;
entry->id = id;
entry->data.assoc.flags = flags;
- entry->data.assoc.assocs = g_memdup(list, sizeof (GstIndexAssociation) * n);
+ entry->data.assoc.assocs = g_memdup (list, sizeof (GstIndexAssociation) * n);
entry->data.assoc.nassocs = n;
gst_index_add_entry (index, entry);
*
* Returns: a pointer to the newly added entry in the index.
*/
-GstIndexEntry*
-gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags,
- GstFormat format, gint64 value, ...)
+GstIndexEntry *
+gst_index_add_association (GstIndex * index, gint id, GstAssocFlags flags,
+ GstFormat format, gint64 value, ...)
{
va_list args;
GstIndexEntry *entry;
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (format != 0, NULL);
-
+
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
-
- array = g_array_new(FALSE, FALSE, sizeof(GstIndexAssociation));
+
+ array = g_array_new (FALSE, FALSE, sizeof (GstIndexAssociation));
va_start (args, value);
*
* Returns: a pointer to the newly added entry in the index.
*/
-GstIndexEntry*
-gst_index_add_object (GstIndex *index, gint id, gchar *key,
- GType type, gpointer object)
+GstIndexEntry *
+gst_index_add_object (GstIndex * index, gint id, gchar * key,
+ GType type, gpointer object)
{
if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
return NULL;
-
+
return NULL;
}
static gint
-gst_index_compare_func (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
+gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data)
{
- return (gint)a - (gint)b;
+ return (gint) a - (gint) b;
}
/**
* Returns: the entry associated with the value or NULL if the
* value was not found.
*/
-GstIndexEntry*
-gst_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value)
+GstIndexEntry *
+gst_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value)
{
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
if (id == -1)
return NULL;
- return gst_index_get_assoc_entry_full (index, id, method, flags, format, value,
- gst_index_compare_func, NULL);
+ return gst_index_get_assoc_entry_full (index, id, method, flags, format,
+ value, gst_index_compare_func, NULL);
}
/**
* Returns: the entry associated with the value or NULL if the
* value was not found.
*/
-GstIndexEntry*
-gst_index_get_assoc_entry_full (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data)
+GstIndexEntry *
+gst_index_get_assoc_entry_full (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
{
GstIndexClass *iclass;
iclass = GST_INDEX_GET_CLASS (index);
if (iclass->get_assoc_entry)
- return iclass->get_assoc_entry (index, id, method, flags, format, value, func, user_data);
-
+ return iclass->get_assoc_entry (index, id, method, flags, format, value,
+ func, user_data);
+
return NULL;
}
* format.
*/
gboolean
-gst_index_entry_assoc_map (GstIndexEntry *entry,
- GstFormat format, gint64 *value)
+gst_index_entry_assoc_map (GstIndexEntry * entry,
+ GstFormat format, gint64 * value)
{
gint i;
g_return_val_if_fail (value != NULL, FALSE);
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
- if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) {
- *value = GST_INDEX_ASSOC_VALUE (entry, i);
- return TRUE;
- }
+ if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) {
+ *value = GST_INDEX_ASSOC_VALUE (entry, i);
+ return TRUE;
+ }
}
return FALSE;
}
-static void gst_index_factory_class_init (GstIndexFactoryClass *klass);
-static void gst_index_factory_init (GstIndexFactory *factory);
+static void gst_index_factory_class_init (GstIndexFactoryClass * klass);
+static void gst_index_factory_init (GstIndexFactory * factory);
static GstPluginFeatureClass *factory_parent_class = NULL;
+
/* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */
-GType
-gst_index_factory_get_type (void)
+GType
+gst_index_factory_get_type (void)
{
static GType indexfactory_type = 0;
(GClassInitFunc) gst_index_factory_class_init,
NULL,
NULL,
- sizeof(GstIndexFactory),
+ sizeof (GstIndexFactory),
0,
(GInstanceInitFunc) gst_index_factory_init,
NULL
};
- indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
- "GstIndexFactory", &indexfactory_info, 0);
+ indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
+ "GstIndexFactory", &indexfactory_info, 0);
}
return indexfactory_type;
}
static void
-gst_index_factory_class_init (GstIndexFactoryClass *klass)
+gst_index_factory_class_init (GstIndexFactoryClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstPluginFeatureClass *gstpluginfeature_class;
- gobject_class = (GObjectClass*)klass;
- gstobject_class = (GstObjectClass*)klass;
- gstpluginfeature_class = (GstPluginFeatureClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstpluginfeature_class = (GstPluginFeatureClass *) klass;
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
}
static void
-gst_index_factory_init (GstIndexFactory *factory)
+gst_index_factory_init (GstIndexFactory * factory)
{
}
*
* Returns: a new #GstIndexFactory.
*/
-GstIndexFactory*
-gst_index_factory_new (const gchar *name, const gchar *longdesc, GType type)
+GstIndexFactory *
+gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type)
{
GstIndexFactory *factory;
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
factory = gst_index_factory_find (name);
if (!factory) {
factory = GST_INDEX_FACTORY (g_object_new (GST_TYPE_INDEX_FACTORY, NULL));
* Removes the index from the global list.
*/
void
-gst_index_factory_destroy (GstIndexFactory *factory)
+gst_index_factory_destroy (GstIndexFactory * factory)
{
g_return_if_fail (factory != NULL);
*
* Returns: #GstIndexFactory if found, NULL otherwise
*/
-GstIndexFactory*
-gst_index_factory_find (const gchar *name)
+GstIndexFactory *
+gst_index_factory_find (const gchar * name)
{
GstPluginFeature *feature;
*
* Returns: A new #GstIndex instance.
*/
-GstIndex*
-gst_index_factory_create (GstIndexFactory *factory)
+GstIndex *
+gst_index_factory_create (GstIndexFactory * factory)
{
GstIndex *new = NULL;
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
g_return_val_if_fail (factory->type != 0, NULL);
- new = GST_INDEX (g_object_new(factory->type,NULL));
+ new = GST_INDEX (g_object_new (factory->type, NULL));
}
return new;
*
* Returns: A new #GstIndex instance.
*/
-GstIndex*
-gst_index_factory_make (const gchar *name)
+GstIndex *
+gst_index_factory_make (const gchar * name)
{
GstIndexFactory *factory;
#include <gst/gstpluginfeature.h>
G_BEGIN_DECLS
-
#define GST_TYPE_INDEX (gst_index_get_type ())
#define GST_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX, GstIndex))
#define GST_IS_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX))
#define GST_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX, GstIndexClass))
#define GST_IS_INDEX_CLASS(klass) (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX))
#define GST_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX, GstIndexClass))
-
#define GST_TYPE_INDEX_ENTRY (gst_index_entry_get_type())
-
typedef struct _GstIndexEntry GstIndexEntry;
typedef struct _GstIndexGroup GstIndexGroup;
typedef struct _GstIndex GstIndex;
typedef struct _GstIndexClass GstIndexClass;
-typedef enum {
+typedef enum
+{
GST_INDEX_UNKNOWN,
GST_INDEX_CERTAIN,
GST_INDEX_FUZZY
} GstIndexCertainty;
-typedef enum {
+typedef enum
+{
GST_INDEX_ENTRY_ID,
GST_INDEX_ENTRY_ASSOCIATION,
GST_INDEX_ENTRY_OBJECT,
GST_INDEX_ENTRY_FORMAT
} GstIndexEntryType;
-typedef enum {
+typedef enum
+{
GST_INDEX_LOOKUP_EXACT,
GST_INDEX_LOOKUP_BEFORE,
GST_INDEX_LOOKUP_AFTER
typedef struct _GstIndexAssociation GstIndexAssociation;
-struct _GstIndexAssociation {
- GstFormat format;
- gint64 value;
+struct _GstIndexAssociation
+{
+ GstFormat format;
+ gint64 value;
};
-typedef enum {
- GST_ASSOCIATION_FLAG_NONE = 0,
+typedef enum
+{
+ GST_ASSOCIATION_FLAG_NONE = 0,
GST_ASSOCIATION_FLAG_KEY_UNIT = (1 << 0),
/* new flags should start here */
- GST_ASSOCIATION_FLAG_LAST = (1 << 8)
+ GST_ASSOCIATION_FLAG_LAST = (1 << 8)
} GstAssocFlags;
#define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format)
#define GST_INDEX_ID_DESCRIPTION(entry) ((entry)->data.id.description)
-struct _GstIndexEntry {
- GstIndexEntryType type;
- gint id;
+struct _GstIndexEntry
+{
+ GstIndexEntryType type;
+ gint id;
- union {
- struct {
- gchar *description;
+ union
+ {
+ struct
+ {
+ gchar *description;
} id;
- struct {
- gint nassocs;
- GstIndexAssociation
- *assocs;
- GstAssocFlags flags;
+ struct
+ {
+ gint nassocs;
+ GstIndexAssociation * assocs;
+ GstAssocFlags flags;
} assoc;
- struct {
- gchar *key;
- GType type;
- gpointer object;
+ struct
+ {
+ gchar *key;
+ GType type;
+ gpointer object;
} object;
- struct {
- GstFormat format;
- gchar *key;
+ struct
+ {
+ GstFormat format;
+ gchar *key;
} format;
} data;
};
-struct _GstIndexGroup {
+struct _GstIndexGroup
+{
/* unique ID of group in index */
gint groupnum;
gint peergroup;
};
-typedef gboolean (*GstIndexFilter) (GstIndex *index,
- GstIndexEntry *entry);
+typedef gboolean (*GstIndexFilter) (GstIndex * index, GstIndexEntry * entry);
-typedef enum {
+typedef enum
+{
GST_INDEX_RESOLVER_CUSTOM,
GST_INDEX_RESOLVER_GTYPE,
GST_INDEX_RESOLVER_PATH
} GstIndexResolverMethod;
-typedef gboolean (*GstIndexResolver) (GstIndex *index,
- GstObject *writer,
- gchar **writer_string,
- gpointer user_data);
-typedef enum {
- GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST,
- GST_INDEX_READABLE,
+typedef gboolean (*GstIndexResolver) (GstIndex * index,
+ GstObject * writer, gchar ** writer_string, gpointer user_data);
+typedef enum
+{
+ GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST,
+ GST_INDEX_READABLE,
- GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
+ GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
} GstIndexFlags;
#define GST_INDEX_IS_READABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_READABLE))
#define GST_INDEX_IS_WRITABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_WRITABLE))
-struct _GstIndex {
- GstObject object;
+struct _GstIndex
+{
+ GstObject object;
- GList *groups;
- GstIndexGroup *curgroup;
- gint maxgroup;
+ GList *groups;
+ GstIndexGroup *curgroup;
+ gint maxgroup;
GstIndexResolverMethod method;
- GstIndexResolver resolver;
- gpointer resolver_user_data;
+ GstIndexResolver resolver;
+ gpointer resolver_user_data;
- GstIndexFilter filter;
- gpointer filter_user_data;
+ GstIndexFilter filter;
+ gpointer filter_user_data;
- GHashTable *writers;
- gint last_id;
+ GHashTable *writers;
+ gint last_id;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstIndexClass {
+struct _GstIndexClass
+{
GstObjectClass parent_class;
- gboolean (*get_writer_id) (GstIndex *index, gint *writer_id, gchar *writer_string);
+ gboolean (*get_writer_id) (GstIndex * index, gint * writer_id,
+ gchar * writer_string);
- void (*commit) (GstIndex *index, gint id);
+ void (*commit) (GstIndex * index, gint id);
/* abstract methods */
- void (*add_entry) (GstIndex *index, GstIndexEntry *entry);
+ void (*add_entry) (GstIndex * index, GstIndexEntry * entry);
- GstIndexEntry* (*get_assoc_entry) (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+ GstIndexEntry *(*get_assoc_entry) (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value,
+ GCompareDataFunc func, gpointer user_data);
/* signals */
- void (*entry_added) (GstIndex *index, GstIndexEntry *entry);
+ void (*entry_added) (GstIndex * index, GstIndexEntry * entry);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_index_get_type (void);
-GstIndex* gst_index_new (void);
-void gst_index_commit (GstIndex *index, gint id);
-
-gint gst_index_get_group (GstIndex *index);
-gint gst_index_new_group (GstIndex *index);
-gboolean gst_index_set_group (GstIndex *index, gint groupnum);
-
-void gst_index_set_certainty (GstIndex *index,
- GstIndexCertainty certainty);
-GstIndexCertainty gst_index_get_certainty (GstIndex *index);
-
-void gst_index_set_filter (GstIndex *index,
- GstIndexFilter filter, gpointer user_data);
-void gst_index_set_resolver (GstIndex *index,
- GstIndexResolver resolver, gpointer user_data);
-
-gboolean gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id);
-
-GstIndexEntry* gst_index_add_format (GstIndex *index, gint id, GstFormat format);
-GstIndexEntry* gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags,
- GstFormat format, gint64 value, ...);
-GstIndexEntry* gst_index_add_object (GstIndex *index, gint id, gchar *key,
- GType type, gpointer object);
-GstIndexEntry* gst_index_add_id (GstIndex *index, gint id,
- gchar *description);
-
-GstIndexEntry* gst_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value);
-GstIndexEntry* gst_index_get_assoc_entry_full (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+GType gst_index_get_type (void);
+GstIndex *gst_index_new (void);
+void gst_index_commit (GstIndex * index, gint id);
+
+gint gst_index_get_group (GstIndex * index);
+gint gst_index_new_group (GstIndex * index);
+gboolean gst_index_set_group (GstIndex * index, gint groupnum);
+
+void gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty);
+GstIndexCertainty gst_index_get_certainty (GstIndex * index);
+
+void gst_index_set_filter (GstIndex * index,
+ GstIndexFilter filter, gpointer user_data);
+void gst_index_set_resolver (GstIndex * index,
+ GstIndexResolver resolver, gpointer user_data);
+
+gboolean gst_index_get_writer_id (GstIndex * index, GstObject * writer,
+ gint * id);
+
+GstIndexEntry *gst_index_add_format (GstIndex * index, gint id,
+ GstFormat format);
+GstIndexEntry *gst_index_add_association (GstIndex * index, gint id,
+ GstAssocFlags flags, GstFormat format, gint64 value, ...);
+GstIndexEntry *gst_index_add_object (GstIndex * index, gint id, gchar * key,
+ GType type, gpointer object);
+GstIndexEntry *gst_index_add_id (GstIndex * index, gint id,
+ gchar * description);
+
+GstIndexEntry *gst_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value);
+GstIndexEntry *gst_index_get_assoc_entry_full (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
/* working with index entries */
GType gst_index_entry_get_type (void);
-GstIndexEntry * gst_index_entry_copy (GstIndexEntry *entry);
-void gst_index_entry_free (GstIndexEntry *entry);
-gboolean gst_index_entry_assoc_map (GstIndexEntry *entry,
- GstFormat format, gint64 *value);
+GstIndexEntry *gst_index_entry_copy (GstIndexEntry * entry);
+void gst_index_entry_free (GstIndexEntry * entry);
+gboolean gst_index_entry_assoc_map (GstIndexEntry * entry,
+ GstFormat format, gint64 * value);
/*
* creating indexs
*
typedef struct _GstIndexFactory GstIndexFactory;
typedef struct _GstIndexFactoryClass GstIndexFactoryClass;
-struct _GstIndexFactory {
+struct _GstIndexFactory
+{
GstPluginFeature feature;
-
- gchar *longdesc; /* long description of the index (well, don't overdo it..) */
- GType type; /* unique GType of the index */
+
+ gchar *longdesc; /* long description of the index (well, don't overdo it..) */
+ GType type; /* unique GType of the index */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstIndexFactoryClass {
- GstPluginFeatureClass parent;
+struct _GstIndexFactoryClass
+{
+ GstPluginFeatureClass parent;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_index_factory_get_type (void);
+GType gst_index_factory_get_type (void);
-GstIndexFactory* gst_index_factory_new (const gchar *name,
- const gchar *longdesc, GType type);
-void gst_index_factory_destroy (GstIndexFactory *factory);
+GstIndexFactory *gst_index_factory_new (const gchar * name,
+ const gchar * longdesc, GType type);
+void gst_index_factory_destroy (GstIndexFactory * factory);
-GstIndexFactory* gst_index_factory_find (const gchar *name);
+GstIndexFactory *gst_index_factory_find (const gchar * name);
-GstIndex* gst_index_factory_create (GstIndexFactory *factory);
-GstIndex* gst_index_factory_make (const gchar *name);
+GstIndex *gst_index_factory_create (GstIndexFactory * factory);
+GstIndex *gst_index_factory_make (const gchar * name);
G_END_DECLS
-
#endif /* __GST_INDEX_H__ */
#ifdef HAVE_PRINTF_EXTENSION
#include <printf.h>
#endif
-#include <stdio.h> /* fprintf */
+#include <stdio.h> /* fprintf */
#include <unistd.h>
-#include <string.h> /* G_VA_COPY */
+#include <string.h> /* G_VA_COPY */
#include "gstinfo.h"
#include "gstlog.h"
#include "gst_private.h"
#include "gstscheduler.h"
#include "gst_private.h"
-GST_DEBUG_CATEGORY_STATIC(GST_CAT_DEBUG);
+GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEBUG);
#if 0
#if defined __sgi__
#include <rld_interface.h>
-typedef struct DL_INFO {
- const char * dli_fname;
- void * dli_fbase;
- const char * dli_sname;
- void * dli_saddr;
- int dli_version;
- int dli_reserved1;
- long dli_reserved[4];
+typedef struct DL_INFO
+{
+ const char *dli_fname;
+ void *dli_fbase;
+ const char *dli_sname;
+ void *dli_saddr;
+ int dli_version;
+ int dli_reserved1;
+ long dli_reserved[4];
} Dl_info;
+
#define _RLD_DLADDR 14
-int dladdr(void *address, Dl_info *dl);
+int dladdr (void *address, Dl_info * dl);
-int dladdr(void *address, Dl_info *dl)
+int
+dladdr (void *address, Dl_info * dl)
{
void *v;
- v = _rld_new_interface(_RLD_DLADDR,address,dl);
- return (int)v;
+
+ v = _rld_new_interface (_RLD_DLADDR, address, dl);
+ return (int) v;
}
#endif /* __sgi__ */
#endif
extern gchar *_gst_progname;
-static void gst_debug_reset_threshold (gpointer category,
- gpointer unused);
-static void gst_debug_reset_all_thresholds (void);
+static void gst_debug_reset_threshold (gpointer category, gpointer unused);
+static void gst_debug_reset_all_thresholds (void);
#ifdef HAVE_PRINTF_EXTENSION
-static int _gst_info_printf_extension (FILE *stream, const struct printf_info *info,
- const void *const *args);
-static int _gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
- int *argtypes);
+static int _gst_info_printf_extension (FILE * stream,
+ const struct printf_info *info, const void *const *args);
+static int _gst_info_printf_extension_arginfo (const struct printf_info *info,
+ size_t n, int *argtypes);
#endif
-struct _GstDebugMessage {
- gchar * message;
- const gchar * format;
- va_list arguments;
+struct _GstDebugMessage
+{
+ gchar *message;
+ const gchar *format;
+ va_list arguments;
};
/* list of all name/level pairs from --gst-debug and GST_DEBUG */
static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT;
static GSList *__level_name = NULL;
-typedef struct {
- GPatternSpec * pat;
- GstDebugLevel level;
+typedef struct
+{
+ GPatternSpec *pat;
+ GstDebugLevel level;
} LevelNameEntry;
/* list of all categories */
static GSList *__categories = NULL;
/* all registered debug handlers */
-typedef struct {
- GstLogFunction func;
- gpointer user_data;
+typedef struct
+{
+ GstLogFunction func;
+ gpointer user_data;
} LogFuncEntry;
static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
static GSList *__log_functions = NULL;
* Initializes the debugging system.
* Normally you don't want to call this, because gst_init does it for you.
*/
-void _gst_debug_init (void)
+void
+_gst_debug_init (void)
{
gst_atomic_int_init (&__default_level, GST_LEVEL_DEFAULT);
gst_atomic_int_init (&__use_color, 1);
#endif
/* do NOT use a single debug function before this line has been run */
- GST_CAT_DEFAULT = _gst_debug_category_new ("default",
- GST_DEBUG_UNDERLINE,
- NULL);
- GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG",
- GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW,
- "debugging subsystem");
+ GST_CAT_DEFAULT = _gst_debug_category_new ("default",
+ GST_DEBUG_UNDERLINE, NULL);
+ GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, "debugging subsystem");
gst_debug_add_log_function (gst_debug_log_default, NULL);
/* FIXME: add descriptions here */
- GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT",
- GST_DEBUG_BOLD | GST_DEBUG_FG_RED,
- NULL);
- GST_CAT_COTHREADS = _gst_debug_category_new ("GST_COTHREADS",
- GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN,
- NULL);
+ GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL);
+ GST_CAT_COTHREADS = _gst_debug_category_new ("GST_COTHREADS",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL);
GST_CAT_COTHREAD_SWITCH = _gst_debug_category_new ("GST_COTHREAD_SWITCH",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN,
- NULL);
- GST_CAT_AUTOPLUG = _gst_debug_category_new ("GST_AUTOPLUG",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE,
- NULL);
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN, NULL);
+ GST_CAT_AUTOPLUG = _gst_debug_category_new ("GST_AUTOPLUG",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
GST_CAT_AUTOPLUG_ATTEMPT = _gst_debug_category_new ("GST_AUTOPLUG_ATTEMPT",
- GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN | GST_DEBUG_BG_BLUE,
- NULL);
- GST_CAT_PARENTAGE = _gst_debug_category_new ("GST_PARENTAGE",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_STATES = _gst_debug_category_new ("GST_STATES",
- GST_DEBUG_BOLD | GST_DEBUG_FG_RED,
- NULL);
- GST_CAT_PLANNING = _gst_debug_category_new ("GST_PLANNING",
- GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA,
- NULL);
- GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING",
- GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA,
- NULL);
- GST_CAT_DATAFLOW = _gst_debug_category_new ("GST_DATAFLOW",
- GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN,
- NULL);
- GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER",
- GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN,
- NULL);
- GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE,
- NULL);
- GST_CAT_CLOCK = _gst_debug_category_new ("GST_CLOCK",
- GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW,
- NULL);
- GST_CAT_ELEMENT_PADS = _gst_debug_category_new ("GST_ELEMENT_PADS",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_PADS = _gst_debug_category_new ("GST_PADS",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
+ GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN | GST_DEBUG_BG_BLUE, NULL);
+ GST_CAT_PARENTAGE = _gst_debug_category_new ("GST_PARENTAGE",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_STATES = _gst_debug_category_new ("GST_STATES",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL);
+ GST_CAT_PLANNING = _gst_debug_category_new ("GST_PLANNING",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL);
+ GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL);
+ GST_CAT_DATAFLOW = _gst_debug_category_new ("GST_DATAFLOW",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL);
+ GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL);
+ GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
+ GST_CAT_CLOCK = _gst_debug_category_new ("GST_CLOCK",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, NULL);
+ GST_CAT_ELEMENT_PADS = _gst_debug_category_new ("GST_ELEMENT_PADS",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_PADS = _gst_debug_category_new ("GST_PADS",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
GST_CAT_PLUGIN_LOADING = _gst_debug_category_new ("GST_PLUGIN_LOADING",
- GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN,
- NULL);
- GST_CAT_PLUGIN_INFO = _gst_debug_category_new ("GST_PLUGIN_INFO",
- GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN,
- NULL);
- GST_CAT_PROPERTIES = _gst_debug_category_new ("GST_PROPERTIES",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_BLUE,
- NULL);
- GST_CAT_THREAD = _gst_debug_category_new ("GST_THREAD",
- GST_DEBUG_BOLD | GST_DEBUG_FG_RED,
- NULL);
- GST_CAT_TYPES = _gst_debug_category_new ("GST_TYPES",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_XML = _gst_debug_category_new ("GST_XML",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_NEGOTIATION = _gst_debug_category_new ("GST_NEGOTIATION",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE,
- NULL);
- GST_CAT_REFCOUNTING = _gst_debug_category_new ("GST_REFCOUNTING",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_GREEN,
- NULL);
- GST_CAT_ERROR_SYSTEM = _gst_debug_category_new ("GST_ERROR_SYSTEM",
- GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_WHITE,
- NULL);
-
- GST_CAT_EVENT = _gst_debug_category_new ("GST_EVENT",
- GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
- NULL);
- GST_CAT_PARAMS = _gst_debug_category_new ("GST_PARAMS",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW,
- NULL);
- GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE",
- GST_DEBUG_BOLD,
- NULL);
- GST_CAT_SEEK = _gst_debug_category_new ("GST_SEEK",
- 0,
- "plugins reacting to seek events");
+ GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL);
+ GST_CAT_PLUGIN_INFO = _gst_debug_category_new ("GST_PLUGIN_INFO",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL);
+ GST_CAT_PROPERTIES = _gst_debug_category_new ("GST_PROPERTIES",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_BLUE, NULL);
+ GST_CAT_THREAD = _gst_debug_category_new ("GST_THREAD",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL);
+ GST_CAT_TYPES = _gst_debug_category_new ("GST_TYPES",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_XML = _gst_debug_category_new ("GST_XML",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_NEGOTIATION = _gst_debug_category_new ("GST_NEGOTIATION",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL);
+ GST_CAT_REFCOUNTING = _gst_debug_category_new ("GST_REFCOUNTING",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_GREEN, NULL);
+ GST_CAT_ERROR_SYSTEM = _gst_debug_category_new ("GST_ERROR_SYSTEM",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_WHITE, NULL);
+
+ GST_CAT_EVENT = _gst_debug_category_new ("GST_EVENT",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL);
+ GST_CAT_PARAMS = _gst_debug_category_new ("GST_PARAMS",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW, NULL);
+ GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE",
+ GST_DEBUG_BOLD, NULL);
+ GST_CAT_SEEK = _gst_debug_category_new ("GST_SEEK",
+ 0, "plugins reacting to seek events");
}
/* we can't do this further above, because we initialize the GST_CAT_DEFAULT struct */
*
* Logs the given message using the currently registered debugging handlers.
*/
-void gst_debug_log (GstDebugCategory *category, GstDebugLevel level,
- const gchar *file, const gchar *function, gint line,
- GObject *object, const gchar *format, ...)
+void
+gst_debug_log (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line,
+ GObject * object, const gchar * format, ...)
{
va_list var_args;
-
+
va_start (var_args, format);
- gst_debug_log_valist (category, level, file, function, line, object, format, var_args);
+ gst_debug_log_valist (category, level, file, function, line, object, format,
+ var_args);
va_end (var_args);
}
+
/**
* gst_debug_log_valist:
* @category: category to log
*
* Logs the given message using the currently registered debugging handlers.
*/
-void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
- const gchar *file, const gchar *function, gint line,
- GObject *object, const gchar *format, va_list args)
+void
+gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line,
+ GObject * object, const gchar * format, va_list args)
{
GstDebugMessage message;
LogFuncEntry *entry;
message.message = NULL;
message.format = format;
G_VA_COPY (message.arguments, args);
-
+
handler = __log_functions;
while (handler) {
entry = handler->data;
handler = g_slist_next (handler);
- entry->func (category, level, file, function, line, object, &message, entry->user_data);
+ entry->func (category, level, file, function, line, object, &message,
+ entry->user_data);
}
g_free (message.message);
va_end (message.arguments);
}
+
/**
* gst_debug_message_get:
* @message: a debug message
* in debug handlers to extract the message.
*/
const gchar *
-gst_debug_message_get (GstDebugMessage *message)
+gst_debug_message_get (GstDebugMessage * message)
{
if (message->message == NULL) {
message->message = g_strdup_vprintf (message->format, message->arguments);
static gchar *
gst_debug_print_object (gpointer ptr)
{
- GObject *object = (GObject *)ptr;
+ GObject *object = (GObject *) ptr;
#ifdef unused
/* This is a cute trick to detect unmapped memory, but is unportable,
{
int ret;
- ret = madvise ((void *)((unsigned long)ptr & (~0xfff)), 4096, 0);
+ ret = madvise ((void *) ((unsigned long) ptr & (~0xfff)), 4096, 0);
if (ret == -1 && errno == ENOMEM) {
buffer = g_strdup_printf ("%p (unmapped memory)", ptr);
}
if (object == NULL) {
return g_strdup ("(NULL)");
}
- if (*(GType *)ptr == GST_TYPE_CAPS) {
- return gst_caps_to_string ((GstCaps *)ptr);
+ if (*(GType *) ptr == GST_TYPE_CAPS) {
+ return gst_caps_to_string ((GstCaps *) ptr);
}
- if (*(GType *)ptr == GST_TYPE_STRUCTURE) {
- return gst_structure_to_string ((GstStructure *)ptr);
+ if (*(GType *) ptr == GST_TYPE_STRUCTURE) {
+ return gst_structure_to_string ((GstStructure *) ptr);
}
#ifdef USE_POISONING
- if (*(guint32 *)ptr == 0xffffffff) {
+ if (*(guint32 *) ptr == 0xffffffff) {
return g_strdup_printf ("<poisoned@%p>", ptr);
}
#endif
return g_strdup_printf ("<%s>", GST_OBJECT_NAME (object));
}
if (G_IS_OBJECT (object)) {
- return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME(object), object);
+ return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME (object), object);
}
return g_strdup_printf ("%p", ptr);
g_string_append_printf (color, ";3%1d", colorinfo & GST_DEBUG_FG_MASK);
}
if (colorinfo & GST_DEBUG_BG_MASK) {
- g_string_append_printf (color, ";4%1d", (colorinfo & GST_DEBUG_BG_MASK) >> 4);
+ g_string_append_printf (color, ";4%1d",
+ (colorinfo & GST_DEBUG_BG_MASK) >> 4);
}
g_string_append (color, "m");
g_string_free (color, FALSE);
return ret;
}
+
/**
* gst_debug_log_default:
* @category: category to log
* gst_debug_remove_log_function (gst_debug_log_default);
*/
void
-gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level,
- const gchar *file, const gchar *function, gint line,
- GObject *object, GstDebugMessage *message, gpointer unused)
+gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line,
+ GObject * object, GstDebugMessage * message, gpointer unused)
{
gchar *color;
gchar *clear;
gchar *obj;
gchar *pidcolor;
gint pid;
-
+
if (level > gst_debug_category_get_threshold (category))
return;
-
- pid = getpid();
+
+ pid = getpid ();
/* color info */
if (gst_debug_is_colored ()) {
- color = gst_debug_construct_term_color (gst_debug_category_get_color (category));
+ color =
+ gst_debug_construct_term_color (gst_debug_category_get_color
+ (category));
clear = "\033[00m";
pidcolor = g_strdup_printf ("\033[3%1dm", pid % 6 + 31);
} else {
obj = object ? gst_debug_print_object (object) : g_strdup ("");
- g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",
- gst_debug_level_get_name (level),
- color, gst_debug_category_get_name (category), clear,
- pidcolor, pid, clear,
- color, file, line, function, obj, clear,
- gst_debug_message_get (message));
+ g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n",
+ gst_debug_level_get_name (level),
+ color, gst_debug_category_get_name (category), clear,
+ pidcolor, pid, clear,
+ color, file, line, function, obj, clear, gst_debug_message_get (message));
g_free (color);
g_free (pidcolor);
g_free (obj);
}
+
/**
* gst_debug_level_get_name:
* @level: the level to get the name for
gst_debug_level_get_name (GstDebugLevel level)
{
switch (level) {
- case GST_LEVEL_NONE: return "";
- case GST_LEVEL_ERROR: return "ERROR";
- case GST_LEVEL_WARNING: return "WARN ";
- case GST_LEVEL_INFO: return "INFO ";
- case GST_LEVEL_DEBUG: return "DEBUG";
- case GST_LEVEL_LOG: return "LOG ";
+ case GST_LEVEL_NONE:
+ return "";
+ case GST_LEVEL_ERROR:
+ return "ERROR";
+ case GST_LEVEL_WARNING:
+ return "WARN ";
+ case GST_LEVEL_INFO:
+ return "INFO ";
+ case GST_LEVEL_DEBUG:
+ return "DEBUG";
+ case GST_LEVEL_LOG:
+ return "LOG ";
default:
g_warning ("invalid level specified for gst_debug_level_get_name");
return "";
}
}
+
/**
* gst_debug_add_log_function:
* @func: the function to use
g_static_mutex_unlock (&__log_func_mutex);
GST_DEBUG ("prepended log function %p (user data %p) to log functions",
- func, data);
+ func, data);
}
+
static gint
gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func)
{
gpointer entryfunc = ((LogFuncEntry *) entry)->func;
-
+
return (entryfunc < func) ? -1 : (entryfunc > func) ? 1 : 0;
}
+
static gint
gst_debug_compare_log_function_by_data (gconstpointer entry, gconstpointer data)
{
gpointer entrydata = ((LogFuncEntry *) entry)->user_data;
-
+
return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0;
}
+
static guint
gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
{
GSList *found;
GSList *new;
guint removals = 0;
+
g_static_mutex_lock (&__log_func_mutex);
new = __log_functions;
while ((found = g_slist_find_custom (new, data, func))) {
return removals;
}
+
/**
* gst_debug_remove_log_function:
* @func: the log function to remove
gst_debug_remove_log_function (GstLogFunction func)
{
guint removals;
-
+
g_return_val_if_fail (func != NULL, 0);
- removals = gst_debug_remove_with_compare_func (gst_debug_compare_log_function_by_func, func);
- GST_DEBUG ("removed log function %p %d times from log function list",
- func, removals);
+ removals =
+ gst_debug_remove_with_compare_func
+ (gst_debug_compare_log_function_by_func, func);
+ GST_DEBUG ("removed log function %p %d times from log function list", func,
+ removals);
return removals;
}
+
/**
* gst_debug_remove_log_function_by_data:
* @data: user data of the log function to remove
{
guint removals;
- removals = gst_debug_remove_with_compare_func (gst_debug_compare_log_function_by_data, data);
- GST_DEBUG ("removed %d log functions with user data %p from log function list",
- removals, data);
+ removals =
+ gst_debug_remove_with_compare_func
+ (gst_debug_compare_log_function_by_data, data);
+ GST_DEBUG
+ ("removed %d log functions with user data %p from log function list",
+ removals, data);
return removals;
}
+
/**
* gst_debug_set_colored:
* @colored: Whether to use colored output or not
{
gst_atomic_int_set (&__use_color, colored ? 1 : 0);
}
+
/**
* gst_debug_is_colored:
*
{
return gst_atomic_int_read (&__use_color) == 0 ? FALSE : TRUE;
}
+
/**
* gst_debug_set_active:
* @active: Whether to use debugging output or not
{
__gst_debug_enabled = active;
}
+
/**
* gst_debug_is_active:
*
{
return __gst_debug_enabled;
}
+
/**
* gst_debug_set_default_threshold:
* @level: level to set
gst_atomic_int_set (&__default_level, level);
gst_debug_reset_all_thresholds ();
}
+
/**
* gst_debug_get_default_threshold:
*
*/
GstDebugLevel
gst_debug_get_default_threshold (void)
-{
+{
return (GstDebugLevel) gst_atomic_int_read (&__default_level);
}
static void
{
GstDebugCategory *cat = (GstDebugCategory *) category;
GSList *walk;
-
+
g_static_mutex_lock (&__level_name_mutex);
walk = __level_name;
while (walk) {
LevelNameEntry *entry = walk->data;
+
walk = g_slist_next (walk);
if (g_pattern_match_string (entry->pat, cat->name)) {
GST_LOG ("category %s matches pattern %p - gets set to level %d",
- cat->name, entry->pat, entry->level);
+ cat->name, entry->pat, entry->level);
gst_debug_category_set_threshold (cat, entry->level);
goto exit;
}
if (g_pattern_match_string (entry->pat, cat->name)) {
GST_LOG ("category %s matches pattern %p - gets set to level %d",
- cat->name, entry->pat, entry->level);
+ cat->name, entry->pat, entry->level);
gst_debug_category_set_threshold (cat, entry->level);
}
}
+
/**
* gst_debug_set_threshold_for_name:
* @name: name of the categories to set
* level.
*/
void
-gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level)
+gst_debug_set_threshold_for_name (const gchar * name, GstDebugLevel level)
{
GPatternSpec *pat;
LevelNameEntry *entry;
-
+
g_return_if_fail (name != NULL);
pat = g_pattern_spec_new (name);
g_slist_foreach (__categories, for_each_threshold_by_entry, entry);
g_static_mutex_unlock (&__cat_mutex);
}
+
/**
* gst_debug_unset_threshold_for_name:
* @name: name of the categories to set
* Resets all categories with the given name back to the default level.
*/
void
-gst_debug_unset_threshold_for_name (const gchar *name)
+gst_debug_unset_threshold_for_name (const gchar * name)
{
GSList *walk;
GPatternSpec *pat;
-
+
g_return_if_fail (name != NULL);
pat = g_pattern_spec_new (name);
/* improve this if you want, it's mighty slow */
while (walk) {
LevelNameEntry *entry = walk->data;
+
if (g_pattern_spec_equal (entry->pat, pat)) {
__level_name = g_slist_remove_link (__level_name, walk);
g_pattern_spec_free (entry->pat);
g_pattern_spec_free (pat);
gst_debug_reset_all_thresholds ();
}
+
GstDebugCategory *
-_gst_debug_category_new (gchar *name, guint color, gchar *description)
+_gst_debug_category_new (gchar * name, guint color, gchar * description)
{
GstDebugCategory *cat;
-
+
g_return_val_if_fail (name != NULL, NULL);
cat = g_new (GstDebugCategory, 1);
return cat;
}
+
/**
* gst_debug_category_free:
* @category: #GstDebugCategory to free.
* Removes and frees the category and all associated resources.
*/
void
-gst_debug_category_free (GstDebugCategory *category)
+gst_debug_category_free (GstDebugCategory * category)
{
- if (category == NULL) return;
+ if (category == NULL)
+ return;
/* remove from category list */
g_static_mutex_lock (&__cat_mutex);
* </para></note>
*/
void
-gst_debug_category_set_threshold (GstDebugCategory *category, GstDebugLevel level)
+gst_debug_category_set_threshold (GstDebugCategory * category,
+ GstDebugLevel level)
{
g_return_if_fail (category != NULL);
* gst_debug_category_set_threshold().
*/
void
-gst_debug_category_reset_threshold (GstDebugCategory *category)
+gst_debug_category_reset_threshold (GstDebugCategory * category)
{
gst_debug_reset_threshold (category, NULL);
}
* Returns: the #GstDebugLevel that is used as threshold.
*/
GstDebugLevel
-gst_debug_category_get_threshold (GstDebugCategory *category)
+gst_debug_category_get_threshold (GstDebugCategory * category)
{
return gst_atomic_int_read (category->threshold);
}
* Returns: the name of the category.
*/
const gchar *
-gst_debug_category_get_name (GstDebugCategory *category)
+gst_debug_category_get_name (GstDebugCategory * category)
{
return category->name;
}
* Returns: the color of the category.
*/
guint
-gst_debug_category_get_color (GstDebugCategory *category)
+gst_debug_category_get_color (GstDebugCategory * category)
{
return category->color;
}
* Returns: the description of the category.
*/
const gchar *
-gst_debug_category_get_description (GstDebugCategory *category)
+gst_debug_category_get_description (GstDebugCategory * category)
{
return category->description;
}
+
/**
* gst_debug_get_all_categories:
*
ret = g_slist_copy (__categories);
g_static_mutex_unlock (&__cat_mutex);
- return ret;
+ return ret;
}
/*** FUNCTION POINTERS ********************************************************/
GHashTable *__gst_function_pointers = NULL;
-const gchar *_gst_debug_nameof_funcptr (void *ptr) G_GNUC_NO_INSTRUMENT;
-
-/* This function MUST NOT return NULL */
const gchar *
_gst_debug_nameof_funcptr (void *ptr)
+ G_GNUC_NO_INSTRUMENT;
+
+/* This function MUST NOT return NULL */
+ const gchar *_gst_debug_nameof_funcptr (void *ptr)
{
gchar *ptrname;
+
#ifdef HAVE_DLADDR
Dl_info dlinfo;
#endif
- if (__gst_function_pointers && (ptrname = g_hash_table_lookup(__gst_function_pointers,ptr))) {
+ if (__gst_function_pointers
+ && (ptrname = g_hash_table_lookup (__gst_function_pointers, ptr))) {
return ptrname;
}
/* we need to create an entry in the hash table for this one so we don't leak
* the name */
#ifdef HAVE_DLADDR
- if (dladdr(ptr,&dlinfo) && dlinfo.dli_sname) {
+ if (dladdr (ptr, &dlinfo) && dlinfo.dli_sname) {
gchar *name = g_strdup (dlinfo.dli_sname);
+
_gst_debug_register_funcptr (ptr, name);
return name;
} else
#endif
{
gchar *name = g_strdup_printf ("%p", ptr);
+
_gst_debug_register_funcptr (ptr, name);
return name;
}
}
void *
-_gst_debug_register_funcptr (void *ptr, gchar *ptrname)
+_gst_debug_register_funcptr (void *ptr, gchar * ptrname)
{
if (!__gst_function_pointers)
__gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal);
#ifdef HAVE_PRINTF_EXTENSION
static int
-_gst_info_printf_extension (FILE *stream, const struct printf_info *info,
+_gst_info_printf_extension (FILE * stream, const struct printf_info *info,
const void *const *args)
{
char *buffer;
void *ptr;
buffer = NULL;
- ptr = *(void **)args[0];
+ ptr = *(void **) args[0];
buffer = gst_debug_print_object (ptr);
len = fprintf (stream, "%*s", (info->left ? -info->width : info->width),
/* FIXME make this thread specific */
static GSList *stack_trace = NULL;
-void __cyg_profile_func_enter(void *this_fn,void *call_site) G_GNUC_NO_INSTRUMENT;
-void __cyg_profile_func_enter(void *this_fn,void *call_site)
+void
+__cyg_profile_func_enter (void *this_fn, void *call_site)
+ G_GNUC_NO_INSTRUMENT;
+ void __cyg_profile_func_enter (void *this_fn, void *call_site)
{
gchar *name = _gst_debug_nameof_funcptr (this_fn);
gchar *site = _gst_debug_nameof_funcptr (call_site);
-
- GST_CAT_DEBUG(GST_CAT_CALL_TRACE, "entering function %s from %s", name, site);
- stack_trace = g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)", this_fn, name, call_site, site));
+
+ GST_CAT_DEBUG (GST_CAT_CALL_TRACE, "entering function %s from %s", name,
+ site);
+ stack_trace =
+ g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)",
+ this_fn, name, call_site, site));
g_free (name);
g_free (site);
}
-void __cyg_profile_func_exit(void *this_fn,void *call_site) G_GNUC_NO_INSTRUMENT;
-void __cyg_profile_func_exit(void *this_fn,void *call_site)
+void
+__cyg_profile_func_exit (void *this_fn, void *call_site)
+ G_GNUC_NO_INSTRUMENT;
+ void __cyg_profile_func_exit (void *this_fn, void *call_site)
{
gchar *name = _gst_debug_nameof_funcptr (this_fn);
- GST_CAT_DEBUG(GST_CAT_CALL_TRACE, "leaving function %s", name);
+ GST_CAT_DEBUG (GST_CAT_CALL_TRACE, "leaving function %s", name);
g_free (stack_trace->data);
stack_trace = g_slist_delete_link (stack_trace, stack_trace);
g_free (name);
}
-void
+void
gst_debug_print_stack_trace (void)
{
GSList *walk = stack_trace;
}
}
#else
-void
+void
gst_debug_print_stack_trace (void)
{
/* nothing because it's compiled out */
#include <gst/gstconfig.h>
G_BEGIN_DECLS
-
/*
* GStreamer's debugging subsystem is an easy way to get information about what
* the application is doing.
* It is not meant for programming errors. Use GLibs methods (g_warning and so
* on for that.
*/
-
/* log levels */
-typedef enum {
+ typedef enum
+{
GST_LEVEL_NONE = 0,
GST_LEVEL_ERROR,
GST_LEVEL_WARNING,
* Background color codes:
* 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
*/
-typedef enum {
+typedef enum
+{
/* colors */
- GST_DEBUG_FG_BLACK = 0x0000,
- GST_DEBUG_FG_RED = 0x0001,
- GST_DEBUG_FG_GREEN = 0x0002,
- GST_DEBUG_FG_YELLOW = 0x0003,
- GST_DEBUG_FG_BLUE = 0x0004,
- GST_DEBUG_FG_MAGENTA = 0x0005,
- GST_DEBUG_FG_CYAN = 0x0006,
- GST_DEBUG_FG_WHITE = 0x0007,
+ GST_DEBUG_FG_BLACK = 0x0000,
+ GST_DEBUG_FG_RED = 0x0001,
+ GST_DEBUG_FG_GREEN = 0x0002,
+ GST_DEBUG_FG_YELLOW = 0x0003,
+ GST_DEBUG_FG_BLUE = 0x0004,
+ GST_DEBUG_FG_MAGENTA = 0x0005,
+ GST_DEBUG_FG_CYAN = 0x0006,
+ GST_DEBUG_FG_WHITE = 0x0007,
/* background colors */
- GST_DEBUG_BG_BLACK = 0x0000,
- GST_DEBUG_BG_RED = 0x0010,
- GST_DEBUG_BG_GREEN = 0x0020,
- GST_DEBUG_BG_YELLOW = 0x0030,
- GST_DEBUG_BG_BLUE = 0x0040,
- GST_DEBUG_BG_MAGENTA = 0x0050,
- GST_DEBUG_BG_CYAN = 0x0060,
- GST_DEBUG_BG_WHITE = 0x0070,
+ GST_DEBUG_BG_BLACK = 0x0000,
+ GST_DEBUG_BG_RED = 0x0010,
+ GST_DEBUG_BG_GREEN = 0x0020,
+ GST_DEBUG_BG_YELLOW = 0x0030,
+ GST_DEBUG_BG_BLUE = 0x0040,
+ GST_DEBUG_BG_MAGENTA = 0x0050,
+ GST_DEBUG_BG_CYAN = 0x0060,
+ GST_DEBUG_BG_WHITE = 0x0070,
/* other formats */
- GST_DEBUG_BOLD = 0x0100,
- GST_DEBUG_UNDERLINE = 0x0200
+ GST_DEBUG_BOLD = 0x0100,
+ GST_DEBUG_UNDERLINE = 0x0200
} GstDebugColorFlags;
#define GST_DEBUG_FG_MASK (0x000F)
#define GST_DEBUG_FORMAT_MASK (0xFF00)
typedef struct _GstDebugCategory GstDebugCategory;
-struct _GstDebugCategory {
- /*< private >*/
- GstAtomicInt * threshold;
- guint color; /* see defines above */
-
- const gchar * name;
- const gchar * description;
+struct _GstDebugCategory
+{
+ /*< private > */
+ GstAtomicInt *threshold;
+ guint color; /* see defines above */
+
+ const gchar *name;
+ const gchar *description;
};
/********** some convenience macros for debugging **********/
typedef struct _GstDebugMessage GstDebugMessage;
-typedef void (*GstLogFunction) (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- GstDebugMessage * message,
- gpointer data);
+typedef void (*GstLogFunction) (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line, GObject * object, GstDebugMessage * message, gpointer data);
/* Disable this subsystem if no varargs macro can be found.
Use a trick so the core builds the functions nonetheless if it wasn't
#ifndef __GST_DISABLE_GST_DEBUG
-void _gst_debug_init (void);
+void _gst_debug_init (void);
/* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which
* we use for GST_PTR_FORMAT. */
-void gst_debug_log (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- const gchar * format,
- ...) G_GNUC_NO_INSTRUMENT;
-void gst_debug_log_valist (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- const gchar * format,
- va_list args) G_GNUC_NO_INSTRUMENT;
-
-const gchar * gst_debug_message_get (GstDebugMessage * message);
-
-void gst_debug_log_default (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- GstDebugMessage * message,
- gpointer unused) G_GNUC_NO_INSTRUMENT;
-
-G_CONST_RETURN gchar *
- gst_debug_level_get_name (GstDebugLevel level);
-
-void gst_debug_add_log_function (GstLogFunction func,
- gpointer data);
-guint gst_debug_remove_log_function (GstLogFunction func);
-guint gst_debug_remove_log_function_by_data (gpointer data);
-
-void gst_debug_set_active (gboolean active);
-gboolean gst_debug_is_active (void);
-
-void gst_debug_set_colored (gboolean colored);
-gboolean gst_debug_is_colored (void);
-
-void gst_debug_set_default_threshold (GstDebugLevel level);
-GstDebugLevel gst_debug_get_default_threshold (void);
-void gst_debug_set_threshold_for_name (const gchar * name,
- GstDebugLevel level);
-void gst_debug_unset_threshold_for_name (const gchar * name);
+void
+gst_debug_log (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line, GObject * object, const gchar * format, ...)
+ G_GNUC_NO_INSTRUMENT;
+ void gst_debug_log_valist (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line,
+ GObject * object, const gchar * format, va_list args) G_GNUC_NO_INSTRUMENT;
+
+ const gchar *gst_debug_message_get (GstDebugMessage * message);
+
+ void gst_debug_log_default (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line,
+ GObject * object,
+ GstDebugMessage * message, gpointer unused) G_GNUC_NO_INSTRUMENT;
+
+ G_CONST_RETURN gchar *gst_debug_level_get_name (GstDebugLevel level);
+
+ void gst_debug_add_log_function (GstLogFunction func, gpointer data);
+ guint gst_debug_remove_log_function (GstLogFunction func);
+ guint gst_debug_remove_log_function_by_data (gpointer data);
+
+ void gst_debug_set_active (gboolean active);
+ gboolean gst_debug_is_active (void);
+
+ void gst_debug_set_colored (gboolean colored);
+ gboolean gst_debug_is_colored (void);
+
+ void gst_debug_set_default_threshold (GstDebugLevel level);
+ GstDebugLevel gst_debug_get_default_threshold (void);
+ void gst_debug_set_threshold_for_name (const gchar * name,
+ GstDebugLevel level);
+ void gst_debug_unset_threshold_for_name (const gchar * name);
/**
* GST_DEBUG_CATEGORY:
*/
#define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL
/* do not use this function, use the macros below */
-GstDebugCategory *_gst_debug_category_new (gchar * name,
- guint color,
- gchar * description);
+ GstDebugCategory *_gst_debug_category_new (gchar * name,
+ guint color, gchar * description);
/**
* GST_DEBUG_CATEGORY_INIT:
* @cat: the category to initialize.
cat = _gst_debug_category_new (name,color,description); \
}G_STMT_END
-void gst_debug_category_free (GstDebugCategory * category);
-void gst_debug_category_set_threshold (GstDebugCategory * category,
- GstDebugLevel level);
-void gst_debug_category_reset_threshold (GstDebugCategory * category);
-GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory * category);
-G_CONST_RETURN gchar *
- gst_debug_category_get_name (GstDebugCategory * category);
-guint gst_debug_category_get_color (GstDebugCategory * category);
-G_CONST_RETURN gchar *
- gst_debug_category_get_description (GstDebugCategory * category);
-GSList * gst_debug_get_all_categories (void);
+ void gst_debug_category_free (GstDebugCategory * category);
+ void gst_debug_category_set_threshold (GstDebugCategory * category,
+ GstDebugLevel level);
+ void gst_debug_category_reset_threshold (GstDebugCategory * category);
+ GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory *
+ category);
+ G_CONST_RETURN gchar *gst_debug_category_get_name (GstDebugCategory *
+ category);
+ guint gst_debug_category_get_color (GstDebugCategory * category);
+ G_CONST_RETURN gchar *gst_debug_category_get_description (GstDebugCategory
+ * category);
+ GSList *gst_debug_get_all_categories (void);
-gchar * gst_debug_construct_term_color (guint colorinfo);
+ gchar *gst_debug_construct_term_color (guint colorinfo);
-extern GstDebugCategory * GST_CAT_DEFAULT;
+ extern GstDebugCategory *GST_CAT_DEFAULT;
+
/* this symbol may not be used */
-extern gboolean __gst_debug_enabled;
+ extern gboolean __gst_debug_enabled;
+
#ifdef G_HAVE_ISO_VARARGS
#define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{ \
if (__gst_debug_enabled) { \
/********** function pointer stuff **********/
-void* _gst_debug_register_funcptr (void * ptr,
- gchar * ptrname);
-G_CONST_RETURN gchar*
- _gst_debug_nameof_funcptr (void * ptr);
+ void *_gst_debug_register_funcptr (void *ptr, gchar * ptrname);
+ G_CONST_RETURN gchar *_gst_debug_nameof_funcptr (void *ptr);
#define GST_DEBUG_FUNCPTR(ptr) (_gst_debug_register_funcptr((void *)(ptr), #ptr) , ptr)
#define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr)
# pragma GCC poison _gst_debug_category_new
#endif
-#define _gst_debug_init() /* NOP */
+#define _gst_debug_init() /* NOP */
-#define gst_debug_set_log_function(func,data) /* NOP */
-#define gst_debug_reset_log_function(void) /* NOP */
-#define gst_debug_set_default_threshold(level) /* NOP */
+#define gst_debug_set_log_function(func,data) /* NOP */
+#define gst_debug_reset_log_function(void) /* NOP */
+#define gst_debug_set_default_threshold(level) /* NOP */
#define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
-#define gst_debug_category_set_threshold_for_name(name, level) /* NOP */
-#define gst_debug_category_unset_threshold_for_name(name) /* NOP */
+#define gst_debug_category_set_threshold_for_name(name, level) /* NOP */
+#define gst_debug_category_unset_threshold_for_name(name) /* NOP */
#define gst_debug_level_get_name(level) ("NONE")
#define gst_debug_add_log_function(func,data) (FALSE)
#define gst_debug_remove_log_function(func) (0)
#define gst_debug_remove_log_function_by_data(data) (0)
-#define gst_debug_set_active(active) /* NOP */
+#define gst_debug_set_active(active) /* NOP */
#define gst_debug_is_active() (FALSE)
-#define gst_debug_set_colored(colored) /* NOP */
+#define gst_debug_set_colored(colored) /* NOP */
#define gst_debug_is_colored() (FALSE)
-#define gst_debug_set_default_threshold(level) /* NOP */
+#define gst_debug_set_default_threshold(level) /* NOP */
#define gst_debug_get_default_threshold() (GST_LEVEL_NONE)
#define gst_debug_set_threshold_for_name(name,level) /* NOP */
#define gst_debug_unset_threshold_for_name(name) /* NOP */
-#define GST_DEBUG_CATEGORY(var) /* NOP */
-#define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */
-#define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */
+#define GST_DEBUG_CATEGORY(var) /* NOP */
+#define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */
+#define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */
#define GST_DEBUG_CATEGORY_INIT(var,name,color,desc) /* NOP */
-#define gst_debug_category_free(category) /* NOP */
-#define gst_debug_category_set_threshold(category,level) /* NOP */
+#define gst_debug_category_free(category) /* NOP */
+#define gst_debug_category_set_threshold(category,level) /* NOP */
#define gst_debug_category_reset_threshold(category) /* NOP */
#define gst_debug_category_get_threshold(category) (GST_LEVEL_NONE)
#define gst_debug_category_get_name(cat) ("")
#ifdef G_HAVE_ISO_VARARGS
-#define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */
+#define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */
-#define GST_CAT_ERROR_OBJECT(...) /* NOP */
-#define GST_CAT_WARNING_OBJECT(...) /* NOP */
-#define GST_CAT_INFO_OBJECT(...) /* NOP */
-#define GST_CAT_DEBUG_OBJECT(...) /* NOP */
-#define GST_CAT_LOG_OBJECT(...) /* NOP */
+#define GST_CAT_ERROR_OBJECT(...) /* NOP */
+#define GST_CAT_WARNING_OBJECT(...) /* NOP */
+#define GST_CAT_INFO_OBJECT(...) /* NOP */
+#define GST_CAT_DEBUG_OBJECT(...) /* NOP */
+#define GST_CAT_LOG_OBJECT(...) /* NOP */
-#define GST_CAT_ERROR(...) /* NOP */
-#define GST_CAT_WARNING(...) /* NOP */
-#define GST_CAT_INFO(...) /* NOP */
-#define GST_CAT_DEBUG(...) /* NOP */
-#define GST_CAT_LOG(...) /* NOP */
+#define GST_CAT_ERROR(...) /* NOP */
+#define GST_CAT_WARNING(...) /* NOP */
+#define GST_CAT_INFO(...) /* NOP */
+#define GST_CAT_DEBUG(...) /* NOP */
+#define GST_CAT_LOG(...) /* NOP */
-#define GST_ERROR_OBJECT(...) /* NOP */
-#define GST_WARNING_OBJECT(...) /* NOP */
-#define GST_INFO_OBJECT(...) /* NOP */
-#define GST_DEBUG_OBJECT(...) /* NOP */
-#define GST_LOG_OBJECT(...) /* NOP */
+#define GST_ERROR_OBJECT(...) /* NOP */
+#define GST_WARNING_OBJECT(...) /* NOP */
+#define GST_INFO_OBJECT(...) /* NOP */
+#define GST_DEBUG_OBJECT(...) /* NOP */
+#define GST_LOG_OBJECT(...) /* NOP */
-#define GST_ERROR(...) /* NOP */
-#define GST_WARNING(...) /* NOP */
-#define GST_INFO(...) /* NOP */
-#define GST_DEBUG(...) /* NOP */
-#define GST_LOG(...) /* NOP */
+#define GST_ERROR(...) /* NOP */
+#define GST_WARNING(...) /* NOP */
+#define GST_INFO(...) /* NOP */
+#define GST_DEBUG(...) /* NOP */
+#define GST_LOG(...) /* NOP */
#ifdef GST_DEBUG_ENABLE_DEPRECATED
-#define GST_INFO_ELEMENT(cat,obj,...) /* NOP */
-#define GST_DEBUG_ELEMENT(cat,obj,...) /* NOP */
-#define GST_DEBUG_ENTER(...) /* NOP */
-#define GST_DEBUG_LEAVE(...) /* NOP */
-#define GST_INFO_ENTER(...) /* NOP */
-#define GST_INFO_LEAVE(...) /* NOP */
+#define GST_INFO_ELEMENT(cat,obj,...) /* NOP */
+#define GST_DEBUG_ELEMENT(cat,obj,...) /* NOP */
+#define GST_DEBUG_ENTER(...) /* NOP */
+#define GST_DEBUG_LEAVE(...) /* NOP */
+#define GST_INFO_ENTER(...) /* NOP */
+#define GST_INFO_LEAVE(...) /* NOP */
#endif /* GST_DEBUG_ENABLE_DEPRECATED */
#else /* !G_HAVE_ISO_VARARGS */
-#define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */
+#define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */
-#define GST_CAT_ERROR_OBJECT(args...) /* NOP */
-#define GST_CAT_WARNING_OBJECT(args...) /* NOP */
-#define GST_CAT_INFO_OBJECT(args...) /* NOP */
-#define GST_CAT_DEBUG_OBJECT(args...) /* NOP */
-#define GST_CAT_LOG_OBJECT(args...) /* NOP */
+#define GST_CAT_ERROR_OBJECT(args...) /* NOP */
+#define GST_CAT_WARNING_OBJECT(args...) /* NOP */
+#define GST_CAT_INFO_OBJECT(args...) /* NOP */
+#define GST_CAT_DEBUG_OBJECT(args...) /* NOP */
+#define GST_CAT_LOG_OBJECT(args...) /* NOP */
-#define GST_CAT_ERROR(args...) /* NOP */
-#define GST_CAT_WARNING(args...) /* NOP */
-#define GST_CAT_INFO(args...) /* NOP */
-#define GST_CAT_DEBUG(args...) /* NOP */
-#define GST_CAT_LOG(args...) /* NOP */
+#define GST_CAT_ERROR(args...) /* NOP */
+#define GST_CAT_WARNING(args...) /* NOP */
+#define GST_CAT_INFO(args...) /* NOP */
+#define GST_CAT_DEBUG(args...) /* NOP */
+#define GST_CAT_LOG(args...) /* NOP */
-#define GST_ERROR_OBJECT(args...) /* NOP */
-#define GST_WARNING_OBJECT(args...) /* NOP */
-#define GST_INFO_OBJECT(args...) /* NOP */
-#define GST_DEBUG_OBJECT(args...) /* NOP */
-#define GST_LOG_OBJECT(args...) /* NOP */
+#define GST_ERROR_OBJECT(args...) /* NOP */
+#define GST_WARNING_OBJECT(args...) /* NOP */
+#define GST_INFO_OBJECT(args...) /* NOP */
+#define GST_DEBUG_OBJECT(args...) /* NOP */
+#define GST_LOG_OBJECT(args...) /* NOP */
-#define GST_ERROR(args...) /* NOP */
-#define GST_WARNING(args...) /* NOP */
-#define GST_INFO(args...) /* NOP */
-#define GST_DEBUG(args...) /* NOP */
-#define GST_LOG(args...) /* NOP */
+#define GST_ERROR(args...) /* NOP */
+#define GST_WARNING(args...) /* NOP */
+#define GST_INFO(args...) /* NOP */
+#define GST_DEBUG(args...) /* NOP */
+#define GST_LOG(args...) /* NOP */
#ifdef GST_DEBUG_ENABLE_DEPRECATED
-#define GST_INFO_ELEMENT(cat,obj,args...) /* NOP */
-#define GST_DEBUG_ELEMENT(cat,obj,args...) /* NOP */
-#define GST_DEBUG_ENTER(args...) /* NOP */
-#define GST_DEBUG_LEAVE(args...) /* NOP */
-#define GST_INFO_ENTER(args...) /* NOP */
-#define GST_INFO_LEAVE(args...) /* NOP */
+#define GST_INFO_ELEMENT(cat,obj,args...) /* NOP */
+#define GST_DEBUG_ELEMENT(cat,obj,args...) /* NOP */
+#define GST_DEBUG_ENTER(args...) /* NOP */
+#define GST_DEBUG_LEAVE(args...) /* NOP */
+#define GST_INFO_ENTER(args...) /* NOP */
+#define GST_INFO_LEAVE(args...) /* NOP */
#endif /* GST_DEBUG_ENABLE_DEPRECATED */
#endif /* G_HAVE_ISO_VARARGS */
void gst_debug_print_stack_trace (void);
G_END_DECLS
-
#endif /* __GSTINFO_H__ */
#include "gstlog.h"
static void
-gst_implements_interface_class_init (GstImplementsInterfaceClass *ifklass);
+gst_implements_interface_class_init (GstImplementsInterfaceClass * ifklass);
static gboolean
-gst_implements_interface_supported_default (GstImplementsInterface *iface,
- GType iface_type);
+gst_implements_interface_supported_default (GstImplementsInterface * iface,
+ GType iface_type);
GType
gst_implements_interface_get_type (void)
};
gst_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstImplementsInterface",
- &gst_interface_info, 0);
+ "GstImplementsInterface", &gst_interface_info, 0);
- g_type_interface_add_prerequisite (gst_interface_type,
- GST_TYPE_ELEMENT);
+ g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT);
}
return gst_interface_type;
}
static void
-gst_implements_interface_class_init (GstImplementsInterfaceClass *klass)
+gst_implements_interface_class_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_implements_interface_supported_default;
}
static gboolean
-gst_implements_interface_supported_default (GstImplementsInterface *interface,
- GType iface_type)
+gst_implements_interface_supported_default (GstImplementsInterface * interface,
+ GType iface_type)
{
/* Well, if someone didn't set the virtual function,
* then something is clearly wrong. So big no-no here */
*/
gboolean
-gst_element_implements_interface (GstElement *element,
- GType iface_type)
+gst_element_implements_interface (GstElement * element, GType iface_type)
{
- if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element),
- iface_type)) {
+ if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element), iface_type)) {
GstImplementsInterface *iface;
GstImplementsInterfaceClass *ifclass;
iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element),
- iface_type, GstImplementsInterface);
+ iface_type, GstImplementsInterface);
ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface);
if (ifclass->supported != NULL &&
- ifclass->supported (iface, iface_type) == TRUE) {
+ ifclass->supported (iface, iface_type) == TRUE) {
return TRUE;
}
}
*/
gpointer
-gst_implements_interface_cast (gpointer from,
- GType iface_type)
+gst_implements_interface_cast (gpointer from, GType iface_type)
{
GstImplementsInterface *iface;
/* check cast, give warning+fail if it's invalid */
if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type,
- GstImplementsInterface))) {
+ GstImplementsInterface))) {
return NULL;
}
/* if we're an element, take care that this interface
* is actually implemented */
if (GST_IS_ELEMENT (from)) {
- g_return_val_if_fail (
- gst_element_implements_interface (GST_ELEMENT (from), iface_type),
- NULL);
+ g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from),
+ iface_type), NULL);
}
return iface;
*/
gboolean
-gst_implements_interface_check (gpointer from,
- GType type)
+gst_implements_interface_check (gpointer from, GType type)
{
GstImplementsInterface *iface;
#include <gst/gstelement.h>
G_BEGIN_DECLS
-
#define GST_TYPE_IMPLEMENTS_INTERFACE \
(gst_implements_interface_get_type ())
#define GST_IMPLEMENTS_INTERFACE(obj) \
#define GST_IMPLEMENTS_INTERFACE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_IMPLEMENTS_INTERFACE, \
GstImplementsInterfaceClass))
-
typedef struct _GstImplementsInterface GstImplementsInterface;
/* This small extra virtual function is here to provide an
* interface functionality on a per-instance basis rather
* than a per-class basis, which is the case for glib.
*/
-typedef struct _GstImplementsInterfaceClass {
+typedef struct _GstImplementsInterfaceClass
+{
GTypeInterface parent;
/* virtual functions */
- gboolean (* supported) (GstImplementsInterface *iface,
- GType iface_type);
+ gboolean (*supported) (GstImplementsInterface * iface, GType iface_type);
gpointer _gst_reserved[GST_PADDING];
} GstImplementsInterfaceClass;
#define GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE(obj, type) \
(gst_implements_interface_check ((obj), (type)))
-GType gst_implements_interface_get_type (void);
+GType gst_implements_interface_get_type (void);
/* wrapper functions to check for functionality implementation */
-gboolean gst_element_implements_interface (GstElement *element,
- GType iface_type);
-gpointer gst_implements_interface_cast (gpointer from,
- GType type);
-gboolean gst_implements_interface_check (gpointer from,
- GType type);
+gboolean gst_element_implements_interface (GstElement * element,
+ GType iface_type);
+gpointer gst_implements_interface_cast (gpointer from, GType type);
+gboolean gst_implements_interface_check (gpointer from, GType type);
G_END_DECLS
-
#endif /* __GST_IMPLEMENTS_INTERFACE_H__ */
#include <glib.h>
-G_BEGIN_DECLS
-
-extern const char *g_log_domain_gstreamer;
+G_BEGIN_DECLS extern const char *g_log_domain_gstreamer;
#ifdef G_HAVE_ISO_VARARGS
#endif
G_END_DECLS
-
#endif /* __GST_LOG_H__ */
#define __GST_MACROS_H__
G_BEGIN_DECLS
-
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
# define GST_GNUC_CONSTRUCTOR \
- __attribute__ ((constructor))
-#else /* !__GNUC__ */
+ __attribute__ ((constructor))
+#else /* !__GNUC__ */
# define GST_GNUC_CONSTRUCTOR
#endif /* !__GNUC__ */
-
#if defined (__GNUC__) && !defined (GST_IMPLEMENT_INLINES)
# define GST_INLINE_FUNC extern __inline__
# define GST_CAN_INLINE 1
#else
-# define GST_INLINE_FUNC extern
+# define GST_INLINE_FUNC extern
# undef GST_CAN_INLINE
#endif
-
-G_END_DECLS
-
+ G_END_DECLS
#endif /* __GST_MACROS_H__ */
-
-
struct _GstMemChunkElement
{
- GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */
- gpointer area; /* pointer to data areas */
+ GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */
+ gpointer area; /* pointer to data areas */
};
struct _GstMemChunk
{
- GstTrashStack stack;
+ GstTrashStack stack;
- gchar *name;
- gulong area_size;
- gulong chunk_size;
- gulong atom_size;
- gboolean cleanup;
+ gchar *name;
+ gulong area_size;
+ gulong chunk_size;
+ gulong atom_size;
+ gboolean cleanup;
};
/*******************************************************
*
*/
static gboolean
-populate (GstMemChunk *mem_chunk)
+populate (GstMemChunk * mem_chunk)
{
guint8 *area;
gint i;
if (mem_chunk->cleanup)
return FALSE;
-
+
area = (guint8 *) g_malloc0 (mem_chunk->area_size);
- for (i=0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) {
+ for (i = 0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) {
GST_MEM_CHUNK_AREA (area + i) = area;
gst_trash_stack_push (&mem_chunk->stack, area + i);
}
*
* Returns: a new #GstMemChunk
*/
-GstMemChunk*
-gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type)
+GstMemChunk *
+gst_mem_chunk_new (gchar * name, gint atom_size, gulong area_size, gint type)
{
GstMemChunk *mem_chunk;
mem_chunk = g_malloc (sizeof (GstMemChunk));
mem_chunk->chunk_size = atom_size + sizeof (GstMemChunkElement);
- area_size = (area_size/atom_size) * mem_chunk->chunk_size;
+ area_size = (area_size / atom_size) * mem_chunk->chunk_size;
mem_chunk->name = g_strdup (name);
mem_chunk->atom_size = atom_size;
* Free the memory allocated by the memchunk
*/
void
-gst_mem_chunk_destroy (GstMemChunk *mem_chunk)
+gst_mem_chunk_destroy (GstMemChunk * mem_chunk)
{
GHashTable *elements = g_hash_table_new (NULL, NULL);
gpointer data;
while (data) {
GstMemChunkElement *elem = GST_MEM_CHUNK_LINK (data);
- g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL);
-
+ g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL);
+
data = gst_mem_chunk_alloc (mem_chunk);
- }
+ }
g_hash_table_foreach_remove (elements, free_area, NULL);
g_hash_table_destroy (elements);
* Returns: a pointer to the allocated memory region.
*/
gpointer
-gst_mem_chunk_alloc (GstMemChunk *mem_chunk)
+gst_mem_chunk_alloc (GstMemChunk * mem_chunk)
{
GstMemChunkElement *chunk;
-
+
g_return_val_if_fail (mem_chunk != NULL, NULL);
again:
if (!chunk) {
if (populate (mem_chunk))
goto again;
- else
+ else
return NULL;
}
* Returns: a pointer to the allocated memory region.
*/
gpointer
-gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk)
+gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk)
{
gpointer mem = gst_mem_chunk_alloc (mem_chunk);
if (mem)
memset (mem, 0, mem_chunk->atom_size);
-
+
return mem;
}
* Free the memeory region allocated from the chunk.
*/
void
-gst_mem_chunk_free (GstMemChunk *mem_chunk, gpointer mem)
+gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem)
{
GstMemChunkElement *chunk;
-
+
g_return_if_fail (mem_chunk != NULL);
g_return_if_fail (mem != NULL);
#include <glib.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS typedef struct _GstMemChunk GstMemChunk;
-typedef struct _GstMemChunk GstMemChunk;
+GstMemChunk *gst_mem_chunk_new (gchar * name,
+ gint atom_size, gulong area_size, gint type);
-GstMemChunk* gst_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type);
+void gst_mem_chunk_destroy (GstMemChunk * mem_chunk);
-void gst_mem_chunk_destroy (GstMemChunk *mem_chunk);
-
-gpointer gst_mem_chunk_alloc (GstMemChunk *mem_chunk);
-gpointer gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk);
-void gst_mem_chunk_free (GstMemChunk *mem_chunk,
- gpointer mem);
+gpointer gst_mem_chunk_alloc (GstMemChunk * mem_chunk);
+gpointer gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk);
+void gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem);
G_END_DECLS
-
#endif /* __GST_MEM_CHUNK_H__ */
#endif
/* Object signals and args */
-enum {
+enum
+{
PARENT_SET,
PARENT_UNSET,
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NAME
- /* FILL ME */
+ /* FILL ME */
};
-enum {
+enum
+{
SO_OBJECT_LOADED,
SO_LAST_SIGNAL
};
GType _gst_object_type = 0;
static GHashTable *object_name_counts = NULL;
+
G_LOCK_DEFINE_STATIC (object_name_mutex);
typedef struct _GstSignalObject GstSignalObject;
typedef struct _GstSignalObjectClass GstSignalObjectClass;
-static GType gst_signal_object_get_type (void);
-static void gst_signal_object_class_init (GstSignalObjectClass *klass);
-static void gst_signal_object_init (GstSignalObject *object);
+static GType gst_signal_object_get_type (void);
+static void gst_signal_object_class_init (GstSignalObjectClass * klass);
+static void gst_signal_object_init (GstSignalObject * object);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
static guint gst_signal_object_signals[SO_LAST_SIGNAL] = { 0 };
#endif
-static void gst_object_class_init (GstObjectClass *klass);
-static void gst_object_init (GstObject *object);
+static void gst_object_class_init (GstObjectClass * klass);
+static void gst_object_init (GstObject * object);
+
#ifndef GST_DISABLE_TRACE
-static GObject * gst_object_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params);
+static GObject *gst_object_constructor (GType type,
+ guint n_construct_properties, GObjectConstructParam * construct_params);
#endif
-static void gst_object_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec);
-static void gst_object_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec);
-static void gst_object_dispatch_properties_changed (GObject *object,
- guint n_pspecs,
- GParamSpec **pspecs);
+static void gst_object_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_object_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_object_dispatch_properties_changed (GObject * object,
+ guint n_pspecs, GParamSpec ** pspecs);
-static void gst_object_dispose (GObject *object);
-static void gst_object_finalize (GObject *object);
+static void gst_object_dispose (GObject * object);
+static void gst_object_finalize (GObject * object);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
-static void gst_object_real_restore_thyself (GstObject *object, xmlNodePtr self);
+static void gst_object_real_restore_thyself (GstObject * object,
+ xmlNodePtr self);
#endif
static GObjectClass *parent_class = NULL;
(GInstanceInitFunc) gst_object_init,
NULL
};
- _gst_object_type = g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, G_TYPE_FLAG_ABSTRACT);
+ _gst_object_type =
+ g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info,
+ G_TYPE_FLAG_ABSTRACT);
}
return _gst_object_type;
}
static void
-gst_object_class_init (GstObjectClass *klass)
+gst_object_class_init (GstObjectClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME,
- g_param_spec_string ("name", "Name", "The name of the object",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("name", "Name", "The name of the object",
+ NULL, G_PARAM_READWRITE));
gst_object_signals[PARENT_SET] =
- g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstObjectClass, parent_set), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
+ g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstObjectClass, parent_set), NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
gst_object_signals[PARENT_UNSET] =
- g_signal_new ("parent-unset", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstObjectClass, parent_unset), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- G_TYPE_OBJECT);
+ g_signal_new ("parent-unset", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstObjectClass, parent_unset), NULL,
+ NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
/* FIXME This should be the GType of xmlNodePtr instead of G_TYPE_POINTER */
gst_object_signals[OBJECT_SAVED] =
- g_signal_new ("object-saved", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstObjectClass, object_saved), NULL, NULL,
- g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
+ g_signal_new ("object-saved", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstObjectClass, object_saved), NULL,
+ NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
+
klass->restore_thyself = gst_object_real_restore_thyself;
#endif
gst_object_signals[DEEP_NOTIFY] =
- g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (GstObjectClass, deep_notify), NULL, NULL,
- gst_marshal_VOID__OBJECT_PARAM, G_TYPE_NONE,
- 2, G_TYPE_OBJECT, G_TYPE_PARAM);
+ g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED |
+ G_SIGNAL_NO_HOOKS, G_STRUCT_OFFSET (GstObjectClass, deep_notify), NULL,
+ NULL, gst_marshal_VOID__OBJECT_PARAM, G_TYPE_NONE, 2, G_TYPE_OBJECT,
+ G_TYPE_PARAM);
klass->path_string_separator = "/";
/* see the comments at gst_object_dispatch_properties_changed */
gobject_class->dispatch_properties_changed
- = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed);
+ = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed);
gobject_class->dispose = gst_object_dispose;
gobject_class->finalize = gst_object_finalize;
}
static void
-gst_object_init (GstObject *object)
+gst_object_init (GstObject * object)
{
- object->lock = g_mutex_new();
+ object->lock = g_mutex_new ();
object->parent = NULL;
object->name = NULL;
#ifndef GST_DISABLE_TRACE
static GObject *
-gst_object_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params)
+gst_object_constructor (GType type, guint n_construct_properties,
+ GObjectConstructParam * construct_params)
{
const gchar *name;
GstAllocTrace *trace;
- GObject *obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_params);
+ GObject *obj =
+ G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties,
+ construct_params);
name = g_type_name (type);
trace = gst_alloc_trace_register (name);
}
gst_alloc_trace_new (trace, obj);
-
+
return obj;
}
#endif
*
* Returns: A pointer to the object
*/
-GstObject*
-gst_object_ref (GstObject *object)
+GstObject *
+gst_object_ref (GstObject * object)
{
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "ref %d->%d",
- G_OBJECT (object)->ref_count,
- G_OBJECT (object)->ref_count + 1);
+ G_OBJECT (object)->ref_count, G_OBJECT (object)->ref_count + 1);
g_object_ref (G_OBJECT (object));
return object;
* zero, destroy the object.
*/
void
-gst_object_unref (GstObject *object)
+gst_object_unref (GstObject * object)
{
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (G_OBJECT (object)->ref_count > 0);
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "unref %d->%d",
- G_OBJECT (object)->ref_count,
- G_OBJECT (object)->ref_count - 1);
+ G_OBJECT (object)->ref_count, G_OBJECT (object)->ref_count - 1);
g_object_unref (G_OBJECT (object));
}
* Use #gst_object_set_parent to have this done for you.
*/
void
-gst_object_sink (GstObject *object)
+gst_object_sink (GstObject * object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
* puts the newobj in *oldobj.
*/
void
-gst_object_replace (GstObject **oldobj, GstObject *newobj)
+gst_object_replace (GstObject ** oldobj, GstObject * newobj)
{
g_return_if_fail (oldobj != NULL);
g_return_if_fail (*oldobj == NULL || GST_IS_OBJECT (*oldobj));
g_return_if_fail (newobj == NULL || GST_IS_OBJECT (newobj));
-
- GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s %s",
- *oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)",
- newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)");
+
+ GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s %s",
+ *oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)",
+ newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)");
if (*oldobj != newobj) {
- if (newobj) gst_object_ref (newobj);
- if (*oldobj) gst_object_unref (*oldobj);
+ if (newobj)
+ gst_object_ref (newobj);
+ if (*oldobj)
+ gst_object_unref (*oldobj);
*oldobj = newobj;
}
}
static void
-gst_object_dispose (GObject *object)
+gst_object_dispose (GObject * object)
{
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose");
-
+
GST_FLAG_SET (GST_OBJECT (object), GST_DESTROYED);
GST_OBJECT_PARENT (object) = NULL;
/* finalize is called when the object has to free its resources */
static void
-gst_object_finalize (GObject *object)
+gst_object_finalize (GObject * object)
{
GstObject *gstobject = GST_OBJECT (object);
{
const gchar *name;
GstAllocTrace *trace;
-
+
name = g_type_name (G_OBJECT_TYPE (object));
trace = gst_alloc_trace_get (name);
g_assert (trace);
* top-level bin to catch property-change notifications for all contained
* elements. */
static void
-gst_object_dispatch_properties_changed (GObject *object,
- guint n_pspecs,
- GParamSpec **pspecs)
+gst_object_dispatch_properties_changed (GObject * object,
+ guint n_pspecs, GParamSpec ** pspecs)
{
GstObject *gst_object;
guint i;
/* do the standard dispatching */
- G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs);
+ G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs,
+ pspecs);
/* now let the parent dispatch those, too */
gst_object = GST_OBJECT_PARENT (object);
while (gst_object) {
/* need own category? */
for (i = 0; i < n_pspecs; i++) {
- GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)", GST_OBJECT_NAME (object),
- GST_OBJECT_NAME (gst_object), pspecs[i]->name);
- g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY], g_quark_from_string (pspecs[i]->name),
- (GstObject *) object, pspecs[i]);
+ GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)",
+ GST_OBJECT_NAME (object), GST_OBJECT_NAME (gst_object),
+ pspecs[i]->name);
+ g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY],
+ g_quark_from_string (pspecs[i]->name), (GstObject *) object,
+ pspecs[i]);
}
gst_object = GST_OBJECT_PARENT (gst_object);
* using g_print.
*/
void
-gst_object_default_deep_notify (GObject *object, GstObject *orig,
- GParamSpec *pspec, gchar **excluded_props)
+gst_object_default_deep_notify (GObject * object, GstObject * orig,
+ GParamSpec * pspec, gchar ** excluded_props)
{
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
+ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0;
gchar *name = NULL;
/* let's not print these out for excluded properties... */
while (excluded_props != NULL && *excluded_props != NULL) {
if (strcmp (pspec->name, *excluded_props) == 0)
- return;
+ return;
excluded_props++;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
if (G_IS_PARAM_SPEC_ENUM (pspec)) {
GEnumValue *enum_value;
- enum_value = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)),
- g_value_get_enum (&value));
+
+ enum_value =
+ g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)),
+ g_value_get_enum (&value));
str = g_strdup_printf ("%s (%d)", enum_value->value_nick,
- enum_value->value);
- }
- else {
+ enum_value->value);
+ } else {
str = g_strdup_value_contents (&value);
}
name = gst_object_get_path_string (orig);
g_value_unset (&value);
} else {
name = gst_object_get_path_string (orig);
- g_warning ("Parameter %s not readable in %s.",
- pspec->name, name);
+ g_warning ("Parameter %s not readable in %s.", pspec->name, name);
g_free (name);
}
}
static void
-gst_object_set_name_default (GstObject *object)
+gst_object_set_name_default (GstObject * object)
{
gint count;
gchar *name, *tmp;
const gchar *type_name;
-
+
type_name = G_OBJECT_TYPE_NAME (object);
/* to ensure guaranteed uniqueness across threads, only one thread
if (!object_name_counts) {
object_name_counts = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
+ g_free, NULL);
}
count = GPOINTER_TO_INT (g_hash_table_lookup (object_name_counts, type_name));
- g_hash_table_insert (object_name_counts, g_strdup (type_name),
- GINT_TO_POINTER (count + 1));
-
+ g_hash_table_insert (object_name_counts, g_strdup (type_name),
+ GINT_TO_POINTER (count + 1));
+
G_UNLOCK (object_name_mutex);
/* GstFooSink -> foosinkN */
tmp = g_strdup_printf ("%s%d", type_name, count);
name = g_ascii_strdown (tmp, strlen (tmp));
g_free (tmp);
-
+
gst_object_set_name (object, name);
g_free (name);
}
* name (if @name is NULL).
*/
void
-gst_object_set_name (GstObject *object, const gchar *name)
+gst_object_set_name (GstObject * object, const gchar * name)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
*
* Returns: name of the object
*/
-const gchar*
-gst_object_get_name (GstObject *object)
+const gchar *
+gst_object_get_name (GstObject * object)
{
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
* Causes the parent-set signal to be emitted.
*/
void
-gst_object_set_parent (GstObject *object, GstObject *parent)
+gst_object_set_parent (GstObject * object, GstObject * parent)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
*
* Returns: parent of the object
*/
-GstObject*
-gst_object_get_parent (GstObject *object)
+GstObject *
+gst_object_get_parent (GstObject * object)
{
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
* Clear the parent of @object, removing the associated reference.
*/
void
-gst_object_unparent (GstObject *object)
+gst_object_unparent (GstObject * object)
{
g_return_if_fail (object != NULL);
- g_return_if_fail (GST_IS_OBJECT(object));
+ g_return_if_fail (GST_IS_OBJECT (object));
if (object->parent == NULL)
return;
GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "unparent");
-
- g_signal_emit (G_OBJECT (object), gst_object_signals[PARENT_UNSET], 0, object->parent);
+
+ g_signal_emit (G_OBJECT (object), gst_object_signals[PARENT_UNSET], 0,
+ object->parent);
object->parent = NULL;
gst_object_unref (object);
* Returns: TRUE if the name does not appear in the list, FALSE if it does.
*/
gboolean
-gst_object_check_uniqueness (GList *list, const gchar *name)
+gst_object_check_uniqueness (GList * list, const gchar * name)
{
g_return_val_if_fail (name != NULL, FALSE);
GstObject *child = GST_OBJECT (list->data);
list = g_list_next (list);
-
- if (strcmp (GST_OBJECT_NAME (child), name) == 0)
+
+ if (strcmp (GST_OBJECT_NAME (child), name) == 0)
return FALSE;
}
* Returns: the new xmlNodePtr with the saved object
*/
xmlNodePtr
-gst_object_save_thyself (GstObject *object, xmlNodePtr parent)
+gst_object_save_thyself (GstObject * object, xmlNodePtr parent)
{
GstObjectClass *oclass;
if (oclass->save_thyself)
oclass->save_thyself (object, parent);
- g_signal_emit (G_OBJECT (object), gst_object_signals[OBJECT_SAVED], 0, parent);
+ g_signal_emit (G_OBJECT (object), gst_object_signals[OBJECT_SAVED], 0,
+ parent);
return parent;
}
* Restores the given object with the data from the parent XML node.
*/
void
-gst_object_restore_thyself (GstObject *object, xmlNodePtr self)
+gst_object_restore_thyself (GstObject * object, xmlNodePtr self)
{
GstObjectClass *oclass;
}
static void
-gst_object_real_restore_thyself (GstObject *object, xmlNodePtr self)
+gst_object_real_restore_thyself (GstObject * object, xmlNodePtr self)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (self != NULL);
-
- gst_class_signal_emit_by_name (object, "object_loaded", self);
+
+ gst_class_signal_emit_by_name (object, "object_loaded", self);
}
#endif /* GST_DISABLE_LOADSAVE_REGISTRY */
static void
-gst_object_set_property (GObject* object, guint prop_id,
- const GValue* value, GParamSpec* pspec)
+gst_object_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstObject *gstobject;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_OBJECT (object));
-
+
gstobject = GST_OBJECT (object);
switch (prop_id) {
}
static void
-gst_object_get_property (GObject* object, guint prop_id,
- GValue* value, GParamSpec* pspec)
+gst_object_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstObject *gstobject;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_OBJECT (object));
-
+
gstobject = GST_OBJECT (object);
switch (prop_id) {
case ARG_NAME:
- g_value_set_string (value, (gchar*)GST_OBJECT_NAME (gstobject));
+ g_value_set_string (value, (gchar *) GST_OBJECT_NAME (gstobject));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
*
* Returns: a string describing the path of the object
*/
-gchar*
-gst_object_get_path_string (GstObject *object)
+gchar *
+gst_object_get_path_string (GstObject * object)
{
GSList *parentage = NULL;
GSList *parents;
separator = oclass->path_string_separator;
free_component = FALSE;
} else {
- component = g_strdup_printf("%p",parents->data);
+ component = g_strdup_printf ("%p", parents->data);
separator = "/";
free_component = TRUE;
}
prevpath = path;
path = g_strjoin (separator, prevpath, component, NULL);
- g_free(prevpath);
+ g_free (prevpath);
if (free_component)
- g_free((gchar *)component);
+ g_free ((gchar *) component);
- parents = g_slist_next(parents);
+ parents = g_slist_next (parents);
}
g_slist_free (parentage);
-struct _GstSignalObject {
+struct _GstSignalObject
+{
GObject object;
};
-struct _GstSignalObjectClass {
- GObjectClass parent_class;
+struct _GstSignalObjectClass
+{
+ GObjectClass parent_class;
/* signals */
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
- void (*object_loaded) (GstSignalObject *object, GstObject *new, xmlNodePtr self);
-#endif /* GST_DISABLE_LOADSAVE_REGISTRY */
+ void (*object_loaded) (GstSignalObject * object, GstObject * new,
+ xmlNodePtr self);
+#endif /* GST_DISABLE_LOADSAVE_REGISTRY */
};
static GType
if (!signal_object_type) {
static const GTypeInfo signal_object_info = {
- sizeof(GstSignalObjectClass),
+ sizeof (GstSignalObjectClass),
NULL,
NULL,
- (GClassInitFunc)gst_signal_object_class_init,
+ (GClassInitFunc) gst_signal_object_class_init,
NULL,
NULL,
- sizeof(GstSignalObject),
+ sizeof (GstSignalObject),
16,
- (GInstanceInitFunc)gst_signal_object_init,
+ (GInstanceInitFunc) gst_signal_object_init,
NULL
};
- signal_object_type = g_type_register_static(G_TYPE_OBJECT, "GstSignalObject", &signal_object_info, 0);
+ signal_object_type =
+ g_type_register_static (G_TYPE_OBJECT, "GstSignalObject",
+ &signal_object_info, 0);
}
return signal_object_type;
}
static void
-gst_signal_object_class_init (GstSignalObjectClass *klass)
+gst_signal_object_class_init (GstSignalObjectClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
gst_signal_object_signals[SO_OBJECT_LOADED] =
- g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstSignalObjectClass, object_loaded), NULL, NULL,
- gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
- G_TYPE_OBJECT, G_TYPE_POINTER);
+ g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSignalObjectClass, object_loaded),
+ NULL, NULL, gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
+ G_TYPE_OBJECT, G_TYPE_POINTER);
#endif
}
static void
-gst_signal_object_init (GstSignalObject *object)
+gst_signal_object_init (GstSignalObject * object)
{
}
* Returns: the signal id.
*/
guint
-gst_class_signal_connect (GstObjectClass *klass,
- const gchar *name,
- gpointer func,
- gpointer func_data)
+gst_class_signal_connect (GstObjectClass * klass,
+ const gchar * name, gpointer func, gpointer func_data)
{
return g_signal_connect (klass->signal_object, name, func, func_data);
}
* emits the named class signal.
*/
void
-gst_class_signal_emit_by_name (GstObject *object,
- const gchar *name,
- xmlNodePtr self)
+gst_class_signal_emit_by_name (GstObject * object,
+ const gchar * name, xmlNodePtr self)
{
GstObjectClass *oclass;
#include <gst/gsttypes.h>
-G_BEGIN_DECLS
-
-extern GType _gst_object_type;
+G_BEGIN_DECLS extern GType _gst_object_type;
#define GST_TYPE_OBJECT (_gst_object_type)
#define GST_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OBJECT))
typedef enum
{
- GST_DESTROYED = 0,
+ GST_DESTROYED = 0,
GST_FLOATING,
- GST_OBJECT_FLAG_LAST = 4
+ GST_OBJECT_FLAG_LAST = 4
} GstObjectFlags;
-struct _GstObject {
- GObject object;
+struct _GstObject
+{
+ GObject object;
- gchar *name;
+ gchar *name;
/* locking for all sorts of things */
- GMutex *lock;
+ GMutex *lock;
/* this object's parent */
- GstObject *parent;
+ GstObject *parent;
- guint32 flags;
+ guint32 flags;
gpointer _gst_reserved[GST_PADDING];
};
/* signal_object is used to signal to the whole class */
-struct _GstObjectClass {
- GObjectClass parent_class;
+struct _GstObjectClass
+{
+ GObjectClass parent_class;
- gchar *path_string_separator;
- GObject *signal_object;
+ gchar *path_string_separator;
+ GObject *signal_object;
/* signals */
- void (*parent_set) (GstObject *object, GstObject *parent);
- void (*parent_unset) (GstObject *object, GstObject *parent);
- void (*object_saved) (GstObject *object, xmlNodePtr parent);
- void (*deep_notify) (GstObject *object, GstObject *orig, GParamSpec *pspec);
+ void (*parent_set) (GstObject * object, GstObject * parent);
+ void (*parent_unset) (GstObject * object, GstObject * parent);
+ void (*object_saved) (GstObject * object, xmlNodePtr parent);
+ void (*deep_notify) (GstObject * object, GstObject * orig,
+ GParamSpec * pspec);
/* functions go here */
- void (*destroy) (GstObject *object);
+ void (*destroy) (GstObject * object);
- xmlNodePtr (*save_thyself) (GstObject *object, xmlNodePtr parent);
- void (*restore_thyself) (GstObject *object, xmlNodePtr self);
+ xmlNodePtr (*save_thyself) (GstObject * object, xmlNodePtr parent);
+ void (*restore_thyself) (GstObject * object, xmlNodePtr self);
gpointer _gst_reserved[GST_PADDING];
};
/* normal GObject stuff */
-GType gst_object_get_type (void);
+GType gst_object_get_type (void);
/* name routines */
-void gst_object_set_name (GstObject *object, const gchar *name);
-G_CONST_RETURN gchar*
- gst_object_get_name (GstObject *object);
+void gst_object_set_name (GstObject * object, const gchar * name);
+G_CONST_RETURN gchar *gst_object_get_name (GstObject * object);
/* parentage routines */
-void gst_object_set_parent (GstObject *object, GstObject *parent);
-GstObject* gst_object_get_parent (GstObject *object);
-void gst_object_unparent (GstObject *object);
+void gst_object_set_parent (GstObject * object, GstObject * parent);
+GstObject *gst_object_get_parent (GstObject * object);
+void gst_object_unparent (GstObject * object);
-void gst_object_default_deep_notify (GObject *object, GstObject *orig,
- GParamSpec *pspec, gchar **excluded_props);
+void gst_object_default_deep_notify (GObject * object, GstObject * orig,
+ GParamSpec * pspec, gchar ** excluded_props);
-gboolean gst_object_check_uniqueness (GList *list, const gchar *name);
+gboolean gst_object_check_uniqueness (GList * list, const gchar * name);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
-xmlNodePtr gst_object_save_thyself (GstObject *object, xmlNodePtr parent);
-void gst_object_restore_thyself (GstObject *object, xmlNodePtr self);
+xmlNodePtr gst_object_save_thyself (GstObject * object, xmlNodePtr parent);
+void gst_object_restore_thyself (GstObject * object, xmlNodePtr self);
#else
#pragma GCC poison gst_object_save_thyself
#pragma GCC poison gst_object_restore_thyself
#endif
/* refcounting + life cycle */
-GstObject * gst_object_ref (GstObject *object);
-void gst_object_unref (GstObject *object);
-void gst_object_sink (GstObject *object);
+GstObject *gst_object_ref (GstObject * object);
+void gst_object_unref (GstObject * object);
+void gst_object_sink (GstObject * object);
/* replace object pointer */
-void gst_object_replace (GstObject **oldobj, GstObject *newobj);
+void gst_object_replace (GstObject ** oldobj, GstObject * newobj);
/* printing out the 'path' of the object */
-gchar * gst_object_get_path_string (GstObject *object);
+gchar *gst_object_get_path_string (GstObject * object);
-guint gst_class_signal_connect (GstObjectClass *klass,
- const gchar *name,
- gpointer func,
- gpointer func_data);
+guint gst_class_signal_connect (GstObjectClass * klass,
+ const gchar * name, gpointer func, gpointer func_data);
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
-void gst_class_signal_emit_by_name (GstObject *object,
- const gchar *name,
- xmlNodePtr self);
+void gst_class_signal_emit_by_name (GstObject * object,
+ const gchar * name, xmlNodePtr self);
#else
#pragma GCC poison gst_class_signal_emit_by_name
#endif
G_END_DECLS
-
#endif /* __GST_OBJECT_H__ */
-
#define GST_CAT_DEFAULT GST_CAT_PADS
-enum {
+enum
+{
TEMPL_PAD_CREATED,
/* FILL ME */
TEMPL_LAST_SIGNAL
GType _gst_pad_type = 0;
/***** Start with the base GstPad class *****/
-static void gst_pad_class_init (GstPadClass *klass);
-static void gst_pad_init (GstPad *pad);
-static void gst_pad_dispose (GObject *object);
+static void gst_pad_class_init (GstPadClass * klass);
+static void gst_pad_init (GstPad * pad);
+static void gst_pad_dispose (GObject * object);
-static void gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ);
-static GstCaps * _gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps);
+static void gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ);
+static GstCaps *_gst_pad_default_fixate_func (GstPad * pad,
+ const GstCaps * caps);
-static gboolean gst_pad_link_try (GstPadLink *link);
-static void gst_pad_link_free (GstPadLink *link);
+static gboolean gst_pad_link_try (GstPadLink * link);
+static void gst_pad_link_free (GstPadLink * link);
#ifndef GST_DISABLE_LOADSAVE
-static xmlNodePtr gst_pad_save_thyself (GstObject *object, xmlNodePtr parent);
+static xmlNodePtr gst_pad_save_thyself (GstObject * object, xmlNodePtr parent);
#endif
static GstObject *pad_parent_class = NULL;
GType
-gst_pad_get_type (void)
+gst_pad_get_type (void)
{
if (!_gst_pad_type) {
static const GTypeInfo pad_info = {
sizeof (GstPadClass), NULL, NULL,
(GClassInitFunc) gst_pad_class_init, NULL, NULL,
- sizeof (GstPad),
+ sizeof (GstPad),
32,
(GInstanceInitFunc) gst_pad_init, NULL
};
- _gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad",
- &pad_info, 0);
+ _gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad",
+ &pad_info, 0);
}
return _gst_pad_type;
}
static void
-gst_pad_class_init (GstPadClass *klass)
+gst_pad_class_init (GstPadClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
pad_parent_class = g_type_class_ref (GST_TYPE_OBJECT);
}
static void
-gst_pad_init (GstPad *pad)
+gst_pad_init (GstPad * pad)
{
/* all structs are initialized to NULL by glib */
}
static void
-gst_pad_dispose (GObject *object)
+gst_pad_dispose (GObject * object)
{
GstPad *pad = GST_PAD (object);
/***** Then do the Real Pad *****/
/* Pad signals and args */
-enum {
+enum
+{
REAL_LINKED,
REAL_UNLINKED,
REAL_FIXATE,
REAL_LAST_SIGNAL
};
-enum {
+enum
+{
REAL_ARG_0,
REAL_ARG_CAPS,
REAL_ARG_ACTIVE
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_real_pad_class_init (GstRealPadClass *klass);
-static void gst_real_pad_init (GstRealPad *pad);
-static void gst_real_pad_dispose (GObject *object);
+static void gst_real_pad_class_init (GstRealPadClass * klass);
+static void gst_real_pad_init (GstRealPad * pad);
+static void gst_real_pad_dispose (GObject * object);
-static gboolean _gst_real_pad_fixate_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu, const GValue *handler_return, gpointer dummy);
-static void gst_real_pad_set_property (GObject *object, guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_real_pad_get_property (GObject *object, guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static gboolean _gst_real_pad_fixate_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu, const GValue * handler_return, gpointer dummy);
+static void gst_real_pad_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_real_pad_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
GType _gst_real_pad_type = 0;
static guint gst_real_pad_signals[REAL_LAST_SIGNAL] = { 0 };
GType
-gst_real_pad_get_type (void) {
+gst_real_pad_get_type (void)
+{
if (!_gst_real_pad_type) {
static const GTypeInfo pad_info = {
sizeof (GstRealPadClass), NULL, NULL,
32,
(GInstanceInitFunc) gst_real_pad_init, NULL
};
- _gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad",
- &pad_info, 0);
+ _gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad",
+ &pad_info, 0);
}
return _gst_real_pad_type;
}
static void
-gst_real_pad_class_init (GstRealPadClass *klass)
+gst_real_pad_class_init (GstRealPadClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
real_pad_parent_class = g_type_class_ref (GST_TYPE_PAD);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_real_pad_dispose);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_real_pad_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_real_pad_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_real_pad_dispose);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_real_pad_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_real_pad_get_property);
gst_real_pad_signals[REAL_LINKED] =
- g_signal_new ("linked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstRealPadClass, linked), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GST_TYPE_PAD);
+ g_signal_new ("linked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstRealPadClass, linked), NULL, NULL,
+ gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD);
gst_real_pad_signals[REAL_UNLINKED] =
- g_signal_new ("unlinked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstRealPadClass, unlinked), NULL, NULL,
- gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GST_TYPE_PAD);
+ g_signal_new ("unlinked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstRealPadClass, unlinked), NULL, NULL,
+ gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD);
gst_real_pad_signals[REAL_FIXATE] =
- g_signal_new ("fixate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstRealPadClass, appfixatefunc),
- _gst_real_pad_fixate_accumulator, NULL,
- gst_marshal_BOXED__BOXED, GST_TYPE_CAPS, 1,
- GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
+ g_signal_new ("fixate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstRealPadClass, appfixatefunc),
+ _gst_real_pad_fixate_accumulator, NULL,
+ gst_marshal_BOXED__BOXED, GST_TYPE_CAPS, 1,
+ GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
/* gtk_object_add_arg_type ("GstRealPad::active", G_TYPE_BOOLEAN, */
/* GTK_ARG_READWRITE, REAL_ARG_ACTIVE); */
g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_ACTIVE,
- g_param_spec_boolean ("active", "Active", "Whether the pad is active.",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("active", "Active", "Whether the pad is active.",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_CAPS,
- g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad",
- GST_TYPE_CAPS, G_PARAM_READABLE));
+ g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad",
+ GST_TYPE_CAPS, G_PARAM_READABLE));
#ifndef GST_DISABLE_LOADSAVE
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_pad_save_thyself);
}
static gboolean
-_gst_real_pad_fixate_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu, const GValue *handler_return, gpointer dummy)
+_gst_real_pad_fixate_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
if (gst_value_get_caps (handler_return)) {
g_value_copy (handler_return, return_accu);
}
static void
-gst_real_pad_init (GstRealPad *pad)
+gst_real_pad_init (GstRealPad * pad)
{
pad->direction = GST_PAD_UNKNOWN;
pad->peer = NULL;
pad->linkfunc = NULL;
pad->getcapsfunc = NULL;
- pad->eventfunc = gst_pad_event_default;
- pad->convertfunc = gst_pad_convert_default;
- pad->queryfunc = gst_pad_query_default;
- pad->intlinkfunc = gst_pad_get_internal_links_default;
+ pad->eventfunc = gst_pad_event_default;
+ pad->convertfunc = gst_pad_convert_default;
+ pad->queryfunc = gst_pad_query_default;
+ pad->intlinkfunc = gst_pad_get_internal_links_default;
- pad->eventmaskfunc = gst_pad_get_event_masks_default;
- pad->formatsfunc = gst_pad_get_formats_default;
- pad->querytypefunc = gst_pad_get_query_types_default;
+ pad->eventmaskfunc = gst_pad_get_event_masks_default;
+ pad->formatsfunc = gst_pad_get_formats_default;
+ pad->querytypefunc = gst_pad_get_query_types_default;
GST_FLAG_SET (pad, GST_PAD_DISABLED);
GST_FLAG_UNSET (pad, GST_PAD_NEGOTIATING);
-
+
gst_probe_dispatcher_init (&pad->probedisp);
}
static void
-gst_real_pad_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_real_pad_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
g_return_if_fail (GST_IS_PAD (object));
}
static void
-gst_real_pad_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_real_pad_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
g_return_if_fail (GST_IS_PAD (object));
*
* Returns: a new #GstPad, or NULL in case of an error.
*/
-GstPad*
-gst_pad_custom_new (GType type, const gchar *name,
- GstPadDirection direction)
+GstPad *
+gst_pad_custom_new (GType type, const gchar * name, GstPadDirection direction)
{
GstRealPad *pad;
*
* Returns: a new #GstPad, or NULL in case of an error.
*/
-GstPad*
-gst_pad_new (const gchar *name,
- GstPadDirection direction)
+GstPad *
+gst_pad_new (const gchar * name, GstPadDirection direction)
{
return gst_pad_custom_new (gst_real_pad_get_type (), name, direction);
}
*
* Returns: a new #GstPad, or NULL in case of an error.
*/
-GstPad*
-gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ,
- const gchar *name)
+GstPad *
+gst_pad_custom_new_from_template (GType type, GstPadTemplate * templ,
+ const gchar * name)
{
GstPad *pad;
*
* Returns: a new #GstPad, or NULL in case of an error.
*/
-GstPad*
-gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name)
+GstPad *
+gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name)
{
- return gst_pad_custom_new_from_template (gst_real_pad_get_type (),
- templ, name);
+ return gst_pad_custom_new_from_template (gst_real_pad_get_type (),
+ templ, name);
}
/* FIXME 0.9: GST_PAD_UNKNOWN needs to die! */
* Returns: the #GstPadDirection of the pad.
*/
GstPadDirection
-gst_pad_get_direction (GstPad *pad)
+gst_pad_get_direction (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_UNKNOWN);
* Activates or deactivates the given pad.
*/
void
-gst_pad_set_active (GstPad *pad, gboolean active)
+gst_pad_set_active (GstPad * pad, gboolean active)
{
GstRealPad *realpad;
gboolean old;
realpad = GST_PAD_REALIZE (pad);
if (active) {
- GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s",
- GST_DEBUG_PAD_NAME (realpad));
+ GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s",
+ GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_UNSET (realpad, GST_PAD_DISABLED);
} else {
- GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s",
- GST_DEBUG_PAD_NAME (realpad));
+ GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s",
+ GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_SET (realpad, GST_PAD_DISABLED);
}
-
+
g_object_notify (G_OBJECT (realpad), "active");
}
* Returns: TRUE if the pad is active.
*/
gboolean
-gst_pad_is_active (GstPad *pad)
+gst_pad_is_active (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
* name will be assigned.
*/
void
-gst_pad_set_name (GstPad *pad, const gchar *name)
+gst_pad_set_name (GstPad * pad, const gchar * name)
{
g_return_if_fail (GST_IS_PAD (pad));
* Returns: the name of the pad. This is not a newly allocated pointer
* so you must not free it.
*/
-const gchar*
-gst_pad_get_name (GstPad *pad)
+const gchar *
+gst_pad_get_name (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
* Sets the given chain function for the pad. The chain function is called to
* process a #GstData input buffer.
*/
-void
-gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain)
+void
+gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK);
GST_RPAD_CHAINFUNC (pad) = chain;
GST_CAT_DEBUG (GST_CAT_PADS, "chainfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (chain));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (chain));
}
/**
* return %NULL.
*/
void
-gst_pad_set_get_function (GstPad *pad,
- GstPadGetFunction get)
+gst_pad_set_get_function (GstPad * pad, GstPadGetFunction get)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SRC);
GST_RPAD_GETFUNC (pad) = get;
-
+
GST_CAT_DEBUG (GST_CAT_PADS, "getfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (get));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (get));
}
/**
* Sets the given event handler for the pad.
*/
void
-gst_pad_set_event_function (GstPad *pad,
- GstPadEventFunction event)
+gst_pad_set_event_function (GstPad * pad, GstPadEventFunction event)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SRC);
GST_RPAD_EVENTFUNC (pad) = event;
GST_CAT_DEBUG (GST_CAT_PADS, "eventfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (event));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (event));
}
/**
* Sets the given event mask function for the pad.
*/
void
-gst_pad_set_event_mask_function (GstPad *pad,
- GstPadEventMaskFunction mask_func)
+gst_pad_set_event_mask_function (GstPad * pad,
+ GstPadEventMaskFunction mask_func)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_EVENTMASKFUNC (pad) = mask_func;
GST_CAT_DEBUG (GST_CAT_PADS, "eventmaskfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (mask_func));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (mask_func));
}
/**
* Returns: a zero-terminated array of #GstEventMask, or NULL if the pad does
* not have an event mask function.
*/
-const GstEventMask*
-gst_pad_get_event_masks (GstPad *pad)
+const GstEventMask *
+gst_pad_get_event_masks (GstPad * pad)
{
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
rpad = GST_PAD_REALIZE (pad);
}
static gboolean
-gst_pad_get_event_masks_dispatcher (GstPad *pad, const GstEventMask **data)
+gst_pad_get_event_masks_dispatcher (GstPad * pad, const GstEventMask ** data)
{
*data = gst_pad_get_event_masks (pad);
* Returns: a zero-terminated array of #GstEventMask, or NULL if none of the
* internally-linked pads have an event mask function.
*/
-const GstEventMask*
-gst_pad_get_event_masks_default (GstPad *pad)
+const GstEventMask *
+gst_pad_get_event_masks_default (GstPad * pad)
{
GstEventMask *result = NULL;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
- gst_pad_get_event_masks_dispatcher, &result);
+ gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
+ gst_pad_get_event_masks_dispatcher, &result);
return result;
}
* Sets the given convert function for the pad.
*/
void
-gst_pad_set_convert_function (GstPad *pad,
- GstPadConvertFunction convert)
+gst_pad_set_convert_function (GstPad * pad, GstPadConvertFunction convert)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_CONVERTFUNC (pad) = convert;
GST_CAT_DEBUG (GST_CAT_PADS, "convertfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (convert));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (convert));
}
/**
* Set the given query function for the pad.
*/
void
-gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query)
+gst_pad_set_query_function (GstPad * pad, GstPadQueryFunction query)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_QUERYFUNC (pad) = query;
GST_CAT_DEBUG (GST_CAT_PADS, "queryfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (query));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (query));
}
/**
* Set the given query type function for the pad.
*/
void
-gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func)
+gst_pad_set_query_type_function (GstPad * pad,
+ GstPadQueryTypeFunction type_func)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_QUERYTYPEFUNC (pad) = type_func;
GST_CAT_DEBUG (GST_CAT_PADS, "querytypefunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (type_func));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (type_func));
}
/**
*
* Returns: a zero-terminated array of #GstQueryType.
*/
-const GstQueryType*
-gst_pad_get_query_types (GstPad *pad)
+const GstQueryType *
+gst_pad_get_query_types (GstPad * pad)
{
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
rpad = GST_PAD_REALIZE (pad);
}
static gboolean
-gst_pad_get_query_types_dispatcher (GstPad *pad, const GstQueryType **data)
+gst_pad_get_query_types_dispatcher (GstPad * pad, const GstQueryType ** data)
{
*data = gst_pad_get_query_types (pad);
* Returns: an zero-terminated array of #GstQueryType, or NULL if none of the
* internally-linked pads has a query types function.
*/
-const GstQueryType*
-gst_pad_get_query_types_default (GstPad *pad)
+const GstQueryType *
+gst_pad_get_query_types_default (GstPad * pad)
{
GstQueryType *result = NULL;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
- gst_pad_get_query_types_dispatcher, &result);
+ gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
+ gst_pad_get_query_types_dispatcher, &result);
return result;
}
* Sets the given internal link function for the pad.
*/
void
-gst_pad_set_internal_link_function (GstPad *pad,
- GstPadIntLinkFunction intlink)
+gst_pad_set_internal_link_function (GstPad * pad, GstPadIntLinkFunction intlink)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_INTLINKFUNC (pad) = intlink;
GST_CAT_DEBUG (GST_CAT_PADS, "internal link for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (intlink));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (intlink));
}
/**
* Sets the given formats function for the pad.
*/
void
-gst_pad_set_formats_function (GstPad *pad, GstPadFormatsFunction formats)
+gst_pad_set_formats_function (GstPad * pad, GstPadFormatsFunction formats)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_FORMATSFUNC (pad) = formats;
GST_CAT_DEBUG (GST_CAT_PADS, "formats function for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (formats));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (formats));
}
/**
* on other pads.
*/
void
-gst_pad_set_link_function (GstPad *pad,
- GstPadLinkFunction link)
+gst_pad_set_link_function (GstPad * pad, GstPadLinkFunction link)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_LINKFUNC (pad) = link;
GST_CAT_DEBUG (GST_CAT_PADS, "linkfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link));
}
/**
* when the pad is unlinked.
*/
void
-gst_pad_set_unlink_function (GstPad *pad,
- GstPadUnlinkFunction unlink)
+gst_pad_set_unlink_function (GstPad * pad, GstPadUnlinkFunction unlink)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_UNLINKFUNC (pad) = unlink;
GST_CAT_DEBUG (GST_CAT_PADS, "unlinkfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink));
}
/**
* and only if the caps are still non-fixed.
*/
void
-gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate)
+gst_pad_set_fixate_function (GstPad * pad, GstPadFixateFunction fixate)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_FIXATEFUNC (pad) = fixate;
GST_CAT_DEBUG (GST_CAT_PADS, "fixatefunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (fixate));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (fixate));
}
/**
* Note that the return value from @getcaps is owned by the caller.
*/
void
-gst_pad_set_getcaps_function (GstPad *pad,
- GstPadGetCapsFunction getcaps)
+gst_pad_set_getcaps_function (GstPad * pad, GstPadGetCapsFunction getcaps)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
GST_RPAD_GETCAPSFUNC (pad) = getcaps;
GST_CAT_DEBUG (GST_CAT_PADS, "getcapsfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (getcaps));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (getcaps));
}
/**
* bufferalloc function can only be set on sinkpads.
*/
void
-gst_pad_set_bufferalloc_function (GstPad *pad,
- GstPadBufferAllocFunction bufalloc)
+gst_pad_set_bufferalloc_function (GstPad * pad,
+ GstPadBufferAllocFunction bufalloc)
{
g_return_if_fail (GST_IS_REAL_PAD (pad));
g_return_if_fail (GST_PAD_IS_SINK (pad));
GST_RPAD_BUFFERALLOCFUNC (pad) = bufalloc;
GST_CAT_DEBUG (GST_CAT_PADS, "bufferallocfunc for %s:%s set to %s",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufalloc));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufalloc));
}
/* FIXME 0.9: Do we actually want to allow the case where src and sink are
* both pads.
*/
void
-gst_pad_unlink (GstPad *srcpad,
- GstPad *sinkpad)
+gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad)
{
GstRealPad *realsrc, *realsink;
GstScheduler *src_sched, *sink_sched;
g_return_if_fail (GST_IS_PAD (sinkpad));
GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "unlinking %s:%s(%p) and %s:%s(%p)",
- GST_DEBUG_PAD_NAME (srcpad), srcpad,
- GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
+ GST_DEBUG_PAD_NAME (srcpad), srcpad,
+ GST_DEBUG_PAD_NAME (sinkpad), sinkpad);
realsrc = GST_PAD_REALIZE (srcpad);
realsink = GST_PAD_REALIZE (sinkpad);
realsink = temppad;
}
g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) &&
- (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK));
+ (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK));
if (GST_RPAD_UNLINKFUNC (realsrc)) {
GST_RPAD_UNLINKFUNC (realsrc) (GST_PAD (realsrc));
src_sched = gst_pad_get_scheduler (GST_PAD (realsrc));
sink_sched = gst_pad_get_scheduler (GST_PAD (realsink));
- if (GST_RPAD_LINK (realsrc)) gst_pad_link_free (GST_RPAD_LINK (realsrc));
+ if (GST_RPAD_LINK (realsrc))
+ gst_pad_link_free (GST_RPAD_LINK (realsrc));
/* first clear peers */
GST_RPAD_PEER (realsrc) = NULL;
/* now tell the scheduler */
if (src_sched && src_sched == sink_sched) {
- gst_scheduler_pad_unlink (src_sched,
- GST_PAD (realsrc),
- GST_PAD (realsink));
+ gst_scheduler_pad_unlink (src_sched, GST_PAD (realsrc), GST_PAD (realsink));
}
/* hold a reference, as they can go away in the signal handlers */
/* fire off a signal to each of the pads telling them
* that they've been unlinked */
- g_signal_emit (G_OBJECT (realsrc), gst_real_pad_signals[REAL_UNLINKED],
- 0, realsink);
- g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_UNLINKED],
- 0, realsrc);
+ g_signal_emit (G_OBJECT (realsrc), gst_real_pad_signals[REAL_UNLINKED],
+ 0, realsink);
+ g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_UNLINKED],
+ 0, realsrc);
GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "unlinked %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
gst_object_unref (GST_OBJECT (realsrc));
gst_object_unref (GST_OBJECT (realsink));
* Returns: TRUE if the pad is linked, FALSE otherwise.
*/
gboolean
-gst_pad_is_linked (GstPad *pad)
+gst_pad_is_linked (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
return GST_PAD_PEER (pad) != NULL;
}
-struct _GstPadLink {
+struct _GstPadLink
+{
GType type;
gboolean bla;
};
static gboolean
-gst_pad_check_schedulers (GstRealPad *realsrc, GstRealPad *realsink)
+gst_pad_check_schedulers (GstRealPad * realsrc, GstRealPad * realsink)
{
GstScheduler *src_sched, *sink_sched;
gint num_decoupled = 0;
gst_pad_link_new (void)
{
GstPadLink *link;
+
link = g_new0 (GstPadLink, 1);
link->sinknotify = TRUE;
link->srcnotify = TRUE;
}
static void
-gst_pad_link_free (GstPadLink *link)
-{
- if (link->srccaps) gst_caps_free (link->srccaps);
- if (link->sinkcaps) gst_caps_free (link->sinkcaps);
- if (link->filtercaps) gst_caps_free (link->filtercaps);
- if (link->caps) gst_caps_free (link->caps);
+gst_pad_link_free (GstPadLink * link)
+{
+ if (link->srccaps)
+ gst_caps_free (link->srccaps);
+ if (link->sinkcaps)
+ gst_caps_free (link->sinkcaps);
+ if (link->filtercaps)
+ gst_caps_free (link->filtercaps);
+ if (link->caps)
+ gst_caps_free (link->caps);
#ifdef USE_POISONING
- memset(link,0xff, sizeof(*link));
+ memset (link, 0xff, sizeof (*link));
#endif
g_free (link);
}
-static void gst_pad_link_intersect (GstPadLink *link)
+static void
+gst_pad_link_intersect (GstPadLink * link)
{
GstCaps *pad_intersection;
- if (link->caps) gst_caps_free (link->caps);
+ if (link->caps)
+ gst_caps_free (link->caps);
GST_DEBUG ("intersecting link from %s:%s to %s:%s",
GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad));
}
static gboolean
-gst_pad_link_ready_for_negotiation (GstPadLink *link)
+gst_pad_link_ready_for_negotiation (GstPadLink * link)
{
GstElement *parent;
parent = GST_PAD_PARENT (link->srcpad);
if (!parent || GST_STATE (parent) < GST_STATE_READY) {
GST_DEBUG ("parent %s of pad %s:%s is not READY",
- GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad));
return FALSE;
}
parent = GST_PAD_PARENT (link->sinkpad);
if (!parent || GST_STATE (parent) < GST_STATE_READY) {
GST_DEBUG ("parent %s of pad %s:%s is not READY",
- GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad));
return FALSE;
}
}
static void
-gst_pad_link_fixate (GstPadLink *link)
+gst_pad_link_fixate (GstPadLink * link)
{
GstCaps *caps;
GstCaps *newcaps;
caps = link->caps;
g_return_if_fail (caps != NULL);
- g_return_if_fail (!gst_caps_is_empty(caps));
+ g_return_if_fail (!gst_caps_is_empty (caps));
GST_DEBUG ("trying to fixate caps %" GST_PTR_FORMAT, caps);
while (!gst_caps_is_fixed (caps)) {
int i;
- for (i=0;i<5;i++){
+ for (i = 0; i < 5; i++) {
newcaps = NULL;
switch (i) {
case 0:
GST_DEBUG ("app sinkpad signal fixated to %" GST_PTR_FORMAT, newcaps);
break;
case 2:
- if (GST_RPAD_FIXATEFUNC(link->srcpad)) {
- newcaps = GST_RPAD_FIXATEFUNC(link->srcpad) (
- GST_PAD (link->srcpad), caps);
+ if (GST_RPAD_FIXATEFUNC (link->srcpad)) {
+ newcaps =
+ GST_RPAD_FIXATEFUNC (link->srcpad) (GST_PAD (link->srcpad),
+ caps);
GST_DEBUG ("srcpad %s:%s fixated to %" GST_PTR_FORMAT,
- GST_DEBUG_PAD_NAME (link->srcpad), newcaps);
- }
- else
+ GST_DEBUG_PAD_NAME (link->srcpad), newcaps);
+ } else
GST_DEBUG ("srcpad %s:%s doesn't have a fixate function",
- GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_DEBUG_PAD_NAME (link->srcpad));
break;
case 3:
- if (GST_RPAD_FIXATEFUNC(link->sinkpad)) {
- newcaps = GST_RPAD_FIXATEFUNC(link->sinkpad) (
- GST_PAD (link->sinkpad), caps);
+ if (GST_RPAD_FIXATEFUNC (link->sinkpad)) {
+ newcaps =
+ GST_RPAD_FIXATEFUNC (link->sinkpad) (GST_PAD (link->sinkpad),
+ caps);
GST_DEBUG ("sinkpad %s:%s fixated to %" GST_PTR_FORMAT,
- GST_DEBUG_PAD_NAME (link->sinkpad), newcaps);
- }
- else
+ GST_DEBUG_PAD_NAME (link->sinkpad), newcaps);
+ } else
GST_DEBUG ("sinkpad %s:%s doesn't have a fixate function",
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->sinkpad));
break;
case 4:
- newcaps = _gst_pad_default_fixate_func (
- GST_PAD(link->srcpad), caps);
- GST_DEBUG ("core fixated to %"GST_PTR_FORMAT, newcaps);
+ newcaps = _gst_pad_default_fixate_func (GST_PAD (link->srcpad), caps);
+ GST_DEBUG ("core fixated to %" GST_PTR_FORMAT, newcaps);
break;
}
if (newcaps) {
}
static GstPadLinkReturn
-gst_pad_link_call_link_functions (GstPadLink *link)
+gst_pad_link_call_link_functions (GstPadLink * link)
{
gboolean negotiating;
GstPadLinkReturn res;
- if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)){
+ if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)) {
GST_DEBUG ("calling link function on pad %s:%s",
- GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_DEBUG_PAD_NAME (link->srcpad));
negotiating = GST_FLAG_IS_SET (link->srcpad, GST_PAD_NEGOTIATING);
/* set the NEGOTIATING flag if not already done */
- if (!negotiating) GST_FLAG_SET (link->srcpad, GST_PAD_NEGOTIATING);
-
+ if (!negotiating)
+ GST_FLAG_SET (link->srcpad, GST_PAD_NEGOTIATING);
+
/* call the link function */
- res = GST_RPAD_LINKFUNC (link->srcpad) (GST_PAD (link->srcpad),
- link->caps);
+ res = GST_RPAD_LINKFUNC (link->srcpad) (GST_PAD (link->srcpad), link->caps);
/* unset again after negotiating only if we set it */
- if (!negotiating) GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING);
+ if (!negotiating)
+ GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING);
GST_DEBUG ("got reply %d from link function on pad %s:%s",
- res, GST_DEBUG_PAD_NAME (link->srcpad));
+ res, GST_DEBUG_PAD_NAME (link->srcpad));
if (GST_PAD_LINK_FAILED (res)) {
GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps",
- GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_DEBUG_PAD_NAME (link->srcpad));
return res;
}
}
- if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)){
+ if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)) {
GST_DEBUG ("calling link function on pad %s:%s",
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->sinkpad));
negotiating = GST_FLAG_IS_SET (link->sinkpad, GST_PAD_NEGOTIATING);
/* set the NEGOTIATING flag if not already done */
- if (!negotiating) GST_FLAG_SET (link->sinkpad, GST_PAD_NEGOTIATING);
-
+ if (!negotiating)
+ GST_FLAG_SET (link->sinkpad, GST_PAD_NEGOTIATING);
+
/* call the link function */
res = GST_RPAD_LINKFUNC (link->sinkpad) (GST_PAD (link->sinkpad),
- link->caps);
+ link->caps);
/* unset again after negotiating only if we set it */
- if (!negotiating) GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING);
+ if (!negotiating)
+ GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING);
GST_DEBUG ("got reply %d from link function on pad %s:%s",
- res, GST_DEBUG_PAD_NAME (link->sinkpad));
+ res, GST_DEBUG_PAD_NAME (link->sinkpad));
if (GST_PAD_LINK_FAILED (res)) {
GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps",
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->sinkpad));
return res;
}
}
}
static GstPadLinkReturn
-gst_pad_link_negotiate (GstPadLink *link)
+gst_pad_link_negotiate (GstPadLink * link)
{
GST_DEBUG ("negotiating link from pad %s:%s to pad %s:%s",
GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad));
* Returns: TRUE if the link succeeded, FALSE if not.
*/
static gboolean
-gst_pad_link_try (GstPadLink *link)
+gst_pad_link_try (GstPadLink * link)
{
GstPad *srcpad, *sinkpad;
GstPadLink *oldlink;
GstPadLinkReturn ret;
-
+
/* we use assertions here, because this function is static */
g_assert (link);
srcpad = link->srcpad;
g_assert (sinkpad);
oldlink = GST_RPAD_LINK (srcpad);
g_assert (oldlink == GST_RPAD_LINK (sinkpad));
-
- ret = gst_pad_link_negotiate (link);
+
+ ret = gst_pad_link_negotiate (link);
if (GST_PAD_LINK_FAILED (ret) && oldlink && oldlink->caps) {
oldlink->srcnotify = link->srcnotify;
oldlink->sinknotify = link->sinknotify;
gst_caps_replace (&link->caps, NULL);
}
- GST_RPAD_PEER (srcpad) = GST_REAL_PAD(link->sinkpad);
- GST_RPAD_PEER (sinkpad) = GST_REAL_PAD(link->srcpad);
+ GST_RPAD_PEER (srcpad) = GST_REAL_PAD (link->sinkpad);
+ GST_RPAD_PEER (sinkpad) = GST_REAL_PAD (link->srcpad);
if (oldlink)
gst_pad_link_free (oldlink);
GST_RPAD_LINK (srcpad) = link;
g_object_notify (G_OBJECT (srcpad), "caps");
g_object_notify (G_OBJECT (sinkpad), "caps");
}
-
+
return ret;
}
* when you just need success/failure information.
*/
GstPadLinkReturn
-gst_pad_renegotiate (GstPad *pad)
+gst_pad_renegotiate (GstPad * pad)
{
GstPadLink *link;
return GST_PAD_LINK_DELAYED;
}
- if (GST_REAL_PAD(pad)->link->filtercaps) {
- link->filtercaps = gst_caps_copy (GST_REAL_PAD(pad)->link->filtercaps);
+ if (GST_REAL_PAD (pad)->link->filtercaps) {
+ link->filtercaps = gst_caps_copy (GST_REAL_PAD (pad)->link->filtercaps);
}
link->srccaps = gst_pad_get_caps (link->srcpad);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
* when you just need success/failure information.
*/
GstPadLinkReturn
-gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
+gst_pad_try_set_caps (GstPad * pad, const GstCaps * caps)
{
GstPadLink *link;
GstPadLink *oldlink;
/* setting non-fixed caps on a pad is not allowed */
if (!gst_caps_is_fixed (caps)) {
- GST_CAT_INFO (GST_CAT_CAPS,
- "trying to set unfixed caps on pad %s:%s, not allowed",
- GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_INFO (GST_CAT_CAPS,
+ "trying to set unfixed caps on pad %s:%s, not allowed",
+ GST_DEBUG_PAD_NAME (pad));
g_warning ("trying to set non fixed caps on pad %s:%s, not allowed",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
GST_DEBUG ("unfixed caps %" GST_PTR_FORMAT, caps);
return GST_PAD_LINK_REFUSED;
g_return_val_if_fail (GST_PAD_LINK_SINK (pad), GST_PAD_LINK_REFUSED);
/* if the desired caps are already there, it's trivially ok */
- if (GST_PAD_CAPS (pad) && gst_caps_is_equal_fixed (caps,
- GST_PAD_CAPS (pad))) {
+ if (GST_PAD_CAPS (pad) && gst_caps_is_equal_fixed (caps, GST_PAD_CAPS (pad))) {
return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_DELAYED;
}
- oldlink = GST_REAL_PAD(pad)->link;
+ oldlink = GST_REAL_PAD (pad)->link;
if (oldlink && oldlink->filtercaps) {
link->filtercaps = gst_caps_copy (oldlink->filtercaps);
}
if (link->srcpad == pad) {
- link->srccaps = gst_caps_copy(caps);
+ link->srccaps = gst_caps_copy (caps);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
link->srcnotify = FALSE;
} else {
link->srccaps = gst_pad_get_caps (link->srcpad);
- link->sinkcaps = gst_caps_copy(caps);
+ link->sinkcaps = gst_caps_copy (caps);
link->sinknotify = FALSE;
}
* Returns: a #GstPadLinkReturn, like gst_pad_try_set_caps().
*/
GstPadLinkReturn
-gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps)
+gst_pad_try_set_caps_nonfixed (GstPad * pad, const GstCaps * caps)
{
GstPadLink *link;
GstPadLink *oldlink;
* with what we're setting, it's trivially OK. */
if (GST_PAD_CAPS (pad)) {
GstCaps *intersection;
+
intersection = gst_caps_intersect (caps, GST_PAD_CAPS (pad));
if (!gst_caps_is_empty (intersection)) {
gst_caps_free (intersection);
return GST_PAD_LINK_DELAYED;
}
- oldlink = GST_REAL_PAD(pad)->link;
+ oldlink = GST_REAL_PAD (pad)->link;
if (oldlink && oldlink->filtercaps) {
link->filtercaps = gst_caps_copy (oldlink->filtercaps);
}
if (link->srcpad == pad) {
- link->srccaps = gst_caps_copy(caps);
+ link->srccaps = gst_caps_copy (caps);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
link->srcnotify = FALSE;
} else {
link->srccaps = gst_pad_get_caps (link->srcpad);
- link->sinkcaps = gst_caps_copy(caps);
+ link->sinkcaps = gst_caps_copy (caps);
link->sinknotify = FALSE;
}
* Returns: TRUE if the pads can be linked, FALSE otherwise.
*/
gboolean
-gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad,
- const GstCaps *filtercaps)
+gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps)
{
GstRealPad *realsrc, *realsink;
GstPadLink *link;
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
/* now we need to deal with the real/ghost stuff */
realsrc = GST_PAD_REALIZE (srcpad);
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
+ GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
}
/* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_RPAD_PEER (realsrc) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (GST_RPAD_PEER (realsink) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed",
- GST_DEBUG_PAD_NAME (realsink));
+ GST_DEBUG_PAD_NAME (realsink));
return FALSE;
}
if (GST_PAD_PARENT (realsrc) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (GST_PAD_PARENT (realsink) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires "
- "exactly one decoupled element (such as queue)");
+ "exactly one decoupled element (such as queue)");
return FALSE;
}
-
+
g_return_val_if_fail (realsrc != NULL, GST_PAD_LINK_REFUSED);
g_return_val_if_fail (realsink != NULL, GST_PAD_LINK_REFUSED);
}
if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) {
- GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s is not a source pad, failed",
- GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_CAT_INFO (GST_CAT_PADS,
+ "Real src pad %s:%s is not a source pad, failed",
+ GST_DEBUG_PAD_NAME (link->srcpad));
gst_pad_link_free (link);
return FALSE;
- }
+ }
if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed",
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->sinkpad));
gst_pad_link_free (link);
return FALSE;
}
link->srccaps = gst_pad_get_caps (link->srcpad);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
- if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps);
+ if (filtercaps)
+ link->filtercaps = gst_caps_copy (filtercaps);
gst_pad_link_intersect (link);
if (gst_caps_is_empty (link->caps)) {
* Returns: TRUE if the pads can be linked, FALSE otherwise.
*/
gboolean
-gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad)
+gst_pad_can_link (GstPad * srcpad, GstPad * sinkpad)
{
return gst_pad_can_link_filtered (srcpad, sinkpad, NULL);
}
* Returns: TRUE if the pads have been linked, FALSE otherwise.
*/
gboolean
-gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad,
- const GstCaps *filtercaps)
+gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps)
{
GstRealPad *realsrc, *realsink;
GstScheduler *src_sched, *sink_sched;
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
/* now we need to deal with the real/ghost stuff */
realsrc = GST_PAD_REALIZE (srcpad);
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
+ GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
}
/* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_RPAD_PEER (realsrc) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (GST_RPAD_PEER (realsink) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed",
- GST_DEBUG_PAD_NAME (realsink));
+ GST_DEBUG_PAD_NAME (realsink));
return FALSE;
}
if (GST_PAD_PARENT (realsrc) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (GST_PAD_PARENT (realsink) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed",
- GST_DEBUG_PAD_NAME (realsrc));
+ GST_DEBUG_PAD_NAME (realsrc));
return FALSE;
}
if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires "
- "exactly one decoupled element (such as queue)");
+ "exactly one decoupled element (such as queue)");
return FALSE;
}
-
+
g_return_val_if_fail (realsrc != NULL, GST_PAD_LINK_REFUSED);
g_return_val_if_fail (realsink != NULL, GST_PAD_LINK_REFUSED);
}
if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) {
- GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s is not a source pad, failed",
- GST_DEBUG_PAD_NAME (link->srcpad));
+ GST_CAT_INFO (GST_CAT_PADS,
+ "Real src pad %s:%s is not a source pad, failed",
+ GST_DEBUG_PAD_NAME (link->srcpad));
gst_pad_link_free (link);
return FALSE;
- }
+ }
if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed",
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->sinkpad));
gst_pad_link_free (link);
return FALSE;
}
link->srccaps = gst_pad_get_caps (link->srcpad);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
- if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps);
+ if (filtercaps)
+ link->filtercaps = gst_caps_copy (filtercaps);
if (gst_pad_link_try (link) == GST_PAD_LINK_REFUSED)
return FALSE;
/* fire off a signal to each of the pads telling them
* that they've been linked */
- g_signal_emit (G_OBJECT (link->srcpad), gst_real_pad_signals[REAL_LINKED],
- 0, link->sinkpad);
- g_signal_emit (G_OBJECT (link->sinkpad), gst_real_pad_signals[REAL_LINKED],
- 0, link->srcpad);
+ g_signal_emit (G_OBJECT (link->srcpad), gst_real_pad_signals[REAL_LINKED],
+ 0, link->sinkpad);
+ g_signal_emit (G_OBJECT (link->sinkpad), gst_real_pad_signals[REAL_LINKED],
+ 0, link->srcpad);
src_sched = gst_pad_get_scheduler (GST_PAD (link->srcpad));
sink_sched = gst_pad_get_scheduler (GST_PAD (link->sinkpad));
/* now tell the scheduler */
if (src_sched && src_sched == sink_sched) {
- gst_scheduler_pad_link (src_sched,
- GST_PAD (link->srcpad), GST_PAD (link->sinkpad));
- }
- else {
- GST_CAT_INFO (GST_CAT_PADS, "not telling link to scheduler %s:%s and %s:%s, %p %p",
- GST_DEBUG_PAD_NAME (link->srcpad),
- GST_DEBUG_PAD_NAME (link->sinkpad),
- src_sched, sink_sched);
+ gst_scheduler_pad_link (src_sched,
+ GST_PAD (link->srcpad), GST_PAD (link->sinkpad));
+ } else {
+ GST_CAT_INFO (GST_CAT_PADS,
+ "not telling link to scheduler %s:%s and %s:%s, %p %p",
+ GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad),
+ src_sched, sink_sched);
}
GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful",
- GST_DEBUG_PAD_NAME (link->srcpad),
- GST_DEBUG_PAD_NAME (link->sinkpad));
+ GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad));
return TRUE;
}
* Returns: TRUE if the pad could be linked, FALSE otherwise.
*/
gboolean
-gst_pad_link (GstPad *srcpad, GstPad *sinkpad)
+gst_pad_link (GstPad * srcpad, GstPad * sinkpad)
{
return gst_pad_link_filtered (srcpad, sinkpad, NULL);
}
* instead.
*/
void
-gst_pad_set_parent (GstPad *pad, GstElement *parent)
+gst_pad_set_parent (GstPad * pad, GstElement * parent)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (GST_PAD_PARENT (pad) == NULL);
*
* Returns: the parent #GstElement.
*/
-GstElement*
-gst_pad_get_parent (GstPad *pad)
+GstElement *
+gst_pad_get_parent (GstPad * pad)
{
g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
}
static void
-gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ)
+gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ)
{
/* this function would need checks if it weren't static */
- gst_object_replace ((GstObject **) &pad->padtemplate, (GstObject *) templ);
-
+ gst_object_replace ((GstObject **) & pad->padtemplate, (GstObject *) templ);
+
if (templ)
- g_signal_emit (G_OBJECT (templ), gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
-}
+ g_signal_emit (G_OBJECT (templ),
+ gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
+}
/**
* gst_pad_get_pad_template:
* Returns: the #GstPadTemplate from which this pad was instantiated, or %NULL
* if this pad has no template.
*/
-GstPadTemplate*
-gst_pad_get_pad_template (GstPad *pad)
+GstPadTemplate *
+gst_pad_get_pad_template (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- return GST_PAD_PAD_TEMPLATE (pad);
+ return GST_PAD_PAD_TEMPLATE (pad);
}
* Returns: the #GstScheduler of the pad, or %NULL if there is no parent or the
* parent is not yet in a managing bin.
*/
-GstScheduler*
-gst_pad_get_scheduler (GstPad *pad)
+GstScheduler *
+gst_pad_get_scheduler (GstPad * pad)
{
GstScheduler *scheduler = NULL;
GstElement *parent;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
-
+
parent = gst_pad_get_parent (pad);
if (parent) {
if (GST_FLAG_IS_SET (parent, GST_ELEMENT_DECOUPLED)) {
GstRealPad *peer = GST_RPAD_PEER (pad);
if (peer) {
- scheduler = gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer)));
+ scheduler =
+ gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer)));
}
- }
- else {
+ } else {
scheduler = gst_element_get_scheduler (parent);
}
}
-
+
return scheduler;
}
*
* Returns: the parent #GstElement.
*/
-GstElement*
-gst_pad_get_real_parent (GstPad *pad)
+GstElement *
+gst_pad_get_real_parent (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
* 0.9.
*/
void
-gst_pad_add_ghost_pad (GstPad *pad,
- GstPad *ghostpad)
+gst_pad_add_ghost_pad (GstPad * pad, GstPad * ghostpad)
{
GstRealPad *realpad;
g_return_if_fail (GST_IS_GHOST_PAD (ghostpad));
/* if we're ghosting a ghost pad, drill down to find the real pad */
- realpad = (GstRealPad*)pad;
+ realpad = (GstRealPad *) pad;
while (GST_IS_GHOST_PAD (realpad))
realpad = GST_GPAD_REALPAD (realpad);
g_return_if_fail (GST_IS_REAL_PAD (realpad));
* Removes a ghost pad from a pad. Private, will be removed from the API in 0.9.
*/
void
-gst_pad_remove_ghost_pad (GstPad *pad,
- GstPad *ghostpad)
+gst_pad_remove_ghost_pad (GstPad * pad, GstPad * ghostpad)
{
GstRealPad *realpad;
*
* Returns: a #GList of ghost pads.
*/
-GList*
-gst_pad_get_ghost_pad_list (GstPad *pad)
+GList *
+gst_pad_get_ghost_pad_list (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- return GST_PAD_REALIZE(pad)->ghostpads;
+ return GST_PAD_REALIZE (pad)->ghostpads;
}
static gboolean
-_gst_pad_default_fixate_foreach (GQuark field_id, GValue *value,
- gpointer s)
+_gst_pad_default_fixate_foreach (GQuark field_id, GValue * value, gpointer s)
{
- GstStructure *structure = (GstStructure *)s;
+ GstStructure *structure = (GstStructure *) s;
GType type = G_VALUE_TYPE (value);
-
- if (G_TYPE_IS_FUNDAMENTAL (type) || type == GST_TYPE_FOURCC) return TRUE;
+
+ if (G_TYPE_IS_FUNDAMENTAL (type) || type == GST_TYPE_FOURCC)
+ return TRUE;
if (type == GST_TYPE_INT_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id),
- G_TYPE_INT, gst_value_get_int_range_min (value), NULL);
+ G_TYPE_INT, gst_value_get_int_range_min (value), NULL);
return FALSE;
}
if (type == GST_TYPE_DOUBLE_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id),
- G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL);
+ G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL);
return FALSE;
}
if (type == GST_TYPE_LIST) {
gst_structure_set_value (structure, g_quark_to_string (field_id),
- gst_value_list_get_value (value, 0));
+ gst_value_list_get_value (value, 0));
return FALSE;
}
- g_critical ("don't know how to fixate type %s", g_type_name(type));
+ g_critical ("don't know how to fixate type %s", g_type_name (type));
return TRUE;
}
static GstCaps *
-_gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps)
+_gst_pad_default_fixate_func (GstPad * pad, const GstCaps * caps)
{
- static GstStaticCaps octetcaps = GST_STATIC_CAPS (
- "application/octet-stream");
+ static GstStaticCaps octetcaps = GST_STATIC_CAPS ("application/octet-stream");
GstStructure *structure;
GstCaps *newcaps;
}
if (caps->structs->len > 1) {
- return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)), NULL);
+ return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps,
+ 0)), NULL);
}
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
- gst_structure_foreach (structure, _gst_pad_default_fixate_foreach,
- structure);
+ gst_structure_foreach (structure, _gst_pad_default_fixate_foreach, structure);
return newcaps;
}
* Returns: TRUE if the pads were succesfully negotiated, FALSE otherwise.
*/
gboolean
-gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad)
+gst_pad_perform_negotiate (GstPad * srcpad, GstPad * sinkpad)
{
return GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (srcpad));
}
static void
-gst_pad_link_unnegotiate (GstPadLink *link)
+gst_pad_link_unnegotiate (GstPadLink * link)
{
g_return_if_fail (link != NULL);
* needs renegotiation.
*/
void
-gst_pad_unnegotiate (GstPad *pad)
+gst_pad_unnegotiate (GstPad * pad)
{
GstPadLink *link;
g_return_if_fail (GST_IS_PAD (pad));
link = GST_RPAD_LINK (GST_PAD_REALIZE (pad));
- if (link)
+ if (link)
gst_pad_link_unnegotiate (link);
}
/* returning NULL indicates that the arguments are invalid */
-static GstPadLink*
-gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad,
- const GstCaps *filtercaps)
+static GstPadLink *
+gst_pad_link_prepare (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps)
{
GstRealPad *realsrc, *realsink;
GstPadLink *link;
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_DEBUG (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
+ GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
}
g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL);
if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires "
- "exactly one decoupled element (such as queue)");
+ "exactly one decoupled element (such as queue)");
return NULL;
}
-
+
if (GST_RPAD_DIRECTION (realsrc) == GST_RPAD_DIRECTION (realsink)) {
g_warning ("%s:%s and %s:%s are both %s pads, failed",
- GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink),
- GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink");
+ GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink),
+ GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink");
return NULL;
- }
+ }
link = gst_pad_link_new ();
link->srccaps = gst_pad_get_caps (link->srcpad);
link->sinkcaps = gst_pad_get_caps (link->sinkpad);
- if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps);
+ if (filtercaps)
+ link->filtercaps = gst_caps_copy (filtercaps);
return link;
}
* Returns: TRUE if the pads were succesfully renegotiated, FALSE otherwise.
*/
gboolean
-gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
- const GstCaps *filtercaps)
+gst_pad_try_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps)
{
GstPadLink *link;
-
+
GST_INFO ("trying to relink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT
- " with filtercaps %" GST_PTR_FORMAT, srcpad, sinkpad);
+ " with filtercaps %" GST_PTR_FORMAT, srcpad, sinkpad);
link = gst_pad_link_prepare (srcpad, sinkpad, filtercaps);
- if (!link) return FALSE;
-
- if (GST_RPAD_PEER (link->srcpad) != (GstRealPad*)link->sinkpad) {
+ if (!link)
+ return FALSE;
+
+ if (GST_RPAD_PEER (link->srcpad) != (GstRealPad *) link->sinkpad) {
g_warning ("Pads %s:%s and %s:%s were never linked",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
gst_pad_link_free (link);
return FALSE;
}
* Returns: TRUE if the pads were succesfully relinked, FALSE otherwise.
*/
gboolean
-gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad,
- const GstCaps *filtercaps)
+gst_pad_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps)
{
if (gst_pad_try_relink_filtered (srcpad, sinkpad, filtercaps))
return TRUE;
* Returns: the intersection of the other pads' allowed caps.
*/
GstCaps *
-gst_pad_proxy_getcaps (GstPad *pad)
+gst_pad_proxy_getcaps (GstPad * pad)
{
GstElement *element;
const GList *pads;
element = gst_pad_get_parent (pad);
pads = gst_element_get_pad_list (element);
-
+
caps = gst_caps_new_any ();
while (pads) {
GstPad *otherpad = GST_PAD (pads->data);
if (otherpad != pad) {
GstCaps *allowed = gst_pad_get_allowed_caps (otherpad);
+
temp = gst_caps_intersect (caps, allowed);
gst_caps_free (caps);
gst_caps_free (allowed);
* Returns: GST_PAD_LINK_OK if sucessful
*/
GstPadLinkReturn
-gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps)
+gst_pad_proxy_pad_link (GstPad * pad, const GstCaps * caps)
{
GstElement *element;
const GList *pads;
element = gst_pad_get_parent (pad);
pads = gst_element_get_pad_list (element);
-
+
while (pads) {
GstPad *otherpad = GST_PAD (pads->data);
if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
- return ret;
+ return ret;
}
}
pads = g_list_next (pads);
* Returns: a fixated caps, or NULL if caps cannot be fixed
*/
GstCaps *
-gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps)
+gst_pad_proxy_fixate (GstPad * pad, const GstCaps * caps)
{
GstElement *element;
const GList *pads;
othercaps = gst_pad_get_negotiated_caps (otherpad);
if (othercaps) {
- GstCaps *icaps;
- icaps = gst_caps_intersect (othercaps, caps);
- if (!gst_caps_is_empty (icaps)) {
- return icaps;
- } else {
- gst_caps_free (icaps);
- }
+ GstCaps *icaps;
+
+ icaps = gst_caps_intersect (othercaps, caps);
+ if (!gst_caps_is_empty (icaps)) {
+ return icaps;
+ } else {
+ gst_caps_free (icaps);
+ }
}
}
pads = g_list_next (pads);
}
-
+
return NULL;
}
* Returns: TRUE if the caps were set correctly, otherwise FALSE
*/
gboolean
-gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps)
+gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps)
{
GstPadLinkReturn link_ret;
return TRUE;
}
- gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), gst_caps_copy(caps));
-
+ gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), gst_caps_copy (caps));
+
if (!GST_PAD_IS_LINKED (pad)) {
GST_CAT_DEBUG (GST_CAT_PADS, "pad is not linked");
return TRUE;
link_ret = gst_pad_try_set_caps (pad, caps);
if (link_ret == GST_PAD_LINK_REFUSED) {
GST_ELEMENT_ERROR (gst_pad_get_parent (pad), CORE, PAD, (NULL),
- ("failed to negotiate (try_set_caps returned REFUSED)"));
+ ("failed to negotiate (try_set_caps returned REFUSED)"));
return FALSE;
}
}
static GstCaps *
-gst_pad_explicit_getcaps (GstPad *pad)
+gst_pad_explicit_getcaps (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
}
static GstPadLinkReturn
-gst_pad_explicit_link (GstPad *pad, const GstCaps *caps)
+gst_pad_explicit_link (GstPad * pad, const GstCaps * caps)
{
g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED);
g_return_val_if_fail (caps != NULL, GST_PAD_LINK_REFUSED);
* better in gstreamer-0.9.
*/
void
-gst_pad_use_explicit_caps (GstPad *pad)
+gst_pad_use_explicit_caps (GstPad * pad)
{
g_return_if_fail (GST_IS_PAD (pad));
* Returns: TRUE if the peer pad accepted the caps, FALSE otherwise.
*/
GstPadLinkReturn
-gst_pad_proxy_link (GstPad *pad, const GstCaps *caps)
+gst_pad_proxy_link (GstPad * pad, const GstCaps * caps)
{
return gst_pad_try_set_caps (pad, caps);
}
* Returns: TRUE if the pad has successfully negotiated caps.
*/
gboolean
-gst_pad_is_negotiated (GstPad *pad)
+gst_pad_is_negotiated (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
* negotiated.
*/
G_CONST_RETURN GstCaps *
-gst_pad_get_negotiated_caps (GstPad *pad)
+gst_pad_get_negotiated_caps (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
* Returns: the #GstCaps of this pad. This function returns a new caps, so use
* gst_caps_free to get rid of it.
*/
-GstCaps*
-gst_pad_get_caps (GstPad *pad)
+GstCaps *
+gst_pad_get_caps (GstPad * pad)
{
GstRealPad *realpad;
realpad = GST_PAD_REALIZE (pad);
GST_CAT_DEBUG (GST_CAT_CAPS, "get pad caps of %s:%s (%p)",
- GST_DEBUG_PAD_NAME (realpad), realpad);
+ GST_DEBUG_PAD_NAME (realpad), realpad);
if (GST_RPAD_GETCAPSFUNC (realpad)) {
GstCaps *caps;
if (caps == NULL) {
g_critical ("pad %s:%s returned NULL caps from getcaps function\n",
- GST_ELEMENT_NAME(GST_PAD_PARENT(GST_PAD (realpad))),
- GST_PAD_NAME(realpad));
+ GST_ELEMENT_NAME (GST_PAD_PARENT (GST_PAD (realpad))),
+ GST_PAD_NAME (realpad));
caps = gst_caps_new_any ();
}
const GstCaps *caps;
caps = GST_PAD_TEMPLATE_CAPS (templ);
- GST_CAT_DEBUG (GST_CAT_CAPS, "using pad template %p with caps %"GST_PTR_FORMAT,
- templ, caps);
+ GST_CAT_DEBUG (GST_CAT_CAPS,
+ "using pad template %p with caps %" GST_PTR_FORMAT, templ, caps);
#if 0
/* FIXME we should enable something like this someday, but this is
* a bit buggy */
if (!gst_caps_is_fixed (caps)) {
- g_warning("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n",
- GST_DEBUG_PAD_NAME (realpad), realpad);
+ g_warning
+ ("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n",
+ GST_DEBUG_PAD_NAME (realpad), realpad);
}
#endif
#if 0
/* FIXME enable */
- g_warning("pad %s:%s (%p) has no pad template\n",
+ g_warning ("pad %s:%s (%p) has no pad template\n",
GST_DEBUG_PAD_NAME (realpad), realpad);
#endif
- return gst_caps_new_any();
+ return gst_caps_new_any ();
}
/**
* Returns: the #GstCaps of this pad template. If you intend to keep a reference
* on the caps, make a copy (see gst_caps_copy ()).
*/
-const GstCaps*
-gst_pad_get_pad_template_caps (GstPad *pad)
+const GstCaps *
+gst_pad_get_pad_template_caps (GstPad * pad)
{
static GstStaticCaps anycaps = GST_STATIC_CAPS ("ANY");
+
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
if (GST_PAD_PAD_TEMPLATE (pad))
#if 0
/* FIXME this should be enabled some day */
/* wingo: why? mail the list during 0.9 when you find this :) */
- g_warning("pad %s:%s (%p) has no pad template\n",
+ g_warning ("pad %s:%s (%p) has no pad template\n",
GST_DEBUG_PAD_NAME (realpad), realpad);
#endif
- return gst_static_caps_get(&anycaps);
+ return gst_static_caps_get (&anycaps);
}
/* FIXME 0.9: This function should probably die, or at least be renamed to
* Returns: the #GstCaps of this pad template, or NULL if not found. If you
* intend to keep a reference on the caps, make a copy (see gst_caps_copy ()).
*/
-const GstCaps*
-gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name)
+const GstCaps *
+gst_pad_template_get_caps_by_name (GstPadTemplate * templ, const gchar * name)
{
GstCaps *caps;
g_return_val_if_fail (templ != NULL, NULL);
caps = GST_PAD_TEMPLATE_CAPS (templ);
- if (!caps)
+ if (!caps)
return NULL;
/* FIXME */
* checked, FALSE if the capabilities are not compatible.
*/
gboolean
-gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad)
+gst_pad_check_compatibility (GstPad * srcpad, GstPad * sinkpad)
{
g_return_val_if_fail (GST_IS_PAD (srcpad), FALSE);
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
if (GST_PAD_CAPS (srcpad) && GST_PAD_CAPS (sinkpad)) {
- if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad),
- GST_PAD_CAPS (sinkpad))) {
+ if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad),
+ GST_PAD_CAPS (sinkpad))) {
return FALSE;
- }
- else {
+ } else {
return TRUE;
}
- }
- else {
- GST_CAT_DEBUG (GST_CAT_PADS,
- "could not check capabilities of pads (%s:%s) and (%s:%s) %p %p",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad),
- GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad));
+ } else {
+ GST_CAT_DEBUG (GST_CAT_PADS,
+ "could not check capabilities of pads (%s:%s) and (%s:%s) %p %p",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad),
+ GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad));
return TRUE;
}
}
*
* Returns: the peer #GstPad.
*/
-GstPad*
-gst_pad_get_peer (GstPad *pad)
+GstPad *
+gst_pad_get_peer (GstPad * pad)
{
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
* Returns: the allowed #GstCaps of the pad link. Free the caps when
* you no longer need it.
*/
-GstCaps*
-gst_pad_get_allowed_caps (GstPad *pad)
+GstCaps *
+gst_pad_get_allowed_caps (GstPad * pad)
{
const GstCaps *mycaps;
GstCaps *caps;
g_return_val_if_fail (GST_IS_REAL_PAD (pad), NULL);
- GST_CAT_DEBUG (GST_CAT_PROPERTIES, "get allowed caps of %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_DEBUG (GST_CAT_PROPERTIES, "get allowed caps of %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
mycaps = gst_pad_get_pad_template_caps (pad);
if (GST_RPAD_PEER (pad) == NULL) {
* changed, and that a renegotiation is suggested.
*/
void
-gst_pad_caps_change_notify (GstPad *pad)
+gst_pad_caps_change_notify (GstPad * pad)
{
}
* on the console and returns FALSE otherwise.
*/
gboolean
-gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed)
+gst_pad_recover_caps_error (GstPad * pad, const GstCaps * allowed)
{
/* FIXME */
return FALSE;
*
* Returns: a new, empty #GstBuffer, or NULL if there is an error
*/
-GstBuffer*
-gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size)
+GstBuffer *
+gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size)
{
GstRealPad *peer;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
g_return_val_if_fail (GST_PAD_IS_SRC (pad), NULL);
-
+
peer = GST_RPAD_PEER (pad);
if (!peer)
- return gst_buffer_new_and_alloc(size);
+ return gst_buffer_new_and_alloc (size);
GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer",
GST_DEBUG_PAD_NAME (pad));
if (peer->bufferallocfunc) {
- GST_CAT_DEBUG (GST_CAT_PADS,
- "calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
- GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
- &peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad*) peer)));
+ GST_CAT_DEBUG (GST_CAT_PADS,
+ "calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
+ GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
+ &peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer)));
return (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
} else {
- return gst_buffer_new_and_alloc(size);
+ return gst_buffer_new_and_alloc (size);
}
}
static void
-gst_real_pad_dispose (GObject *object)
+gst_real_pad_dispose (GObject * object)
{
GstPad *pad = GST_PAD (object);
-
+
/* No linked pad can ever be disposed.
* It has to have a parent to be linked
* and a parent would hold a reference */
well... */
g_assert (GST_PAD_PEER (pad) == NULL);
- GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s", GST_DEBUG_PAD_NAME(pad));
+ GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s",
+ GST_DEBUG_PAD_NAME (pad));
/* we destroy the ghostpads, because they are nothing without the real pad */
if (GST_REAL_PAD (pad)->ghostpads) {
GstPad *ghostpad = GST_PAD (ghostpads->data);
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (ghostpad))) {
- GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad));
+ GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad));
- GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing ghost pad from element '%s'",
- GST_OBJECT_NAME (parent));
- gst_element_remove_pad (parent, ghostpad);
+ GST_CAT_DEBUG (GST_CAT_REFCOUNTING,
+ "removing ghost pad from element '%s'", GST_OBJECT_NAME (parent));
+ gst_element_remove_pad (parent, ghostpad);
} else {
- /* handle the case where we have some floating ghost pad that was never
- added to an element */
- g_object_set (ghostpad, "real-pad", NULL, NULL);
+ /* handle the case where we have some floating ghost pad that was never
+ added to an element */
+ g_object_set (ghostpad, "real-pad", NULL, NULL);
}
ghostpads = g_list_next (ghostpads);
}
g_list_free (orig);
/* as the ghost pads are removed, they remove themselves from ->ghostpads.
So it should be empty now. Let's assert that. */
- g_assert (GST_REAL_PAD(pad)->ghostpads == NULL);
+ g_assert (GST_REAL_PAD (pad)->ghostpads == NULL);
}
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad))) {
GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing pad from element '%s'",
- GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad)))));
-
+ GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad)))));
+
gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad);
}
-
+
if (GST_RPAD_EXPLICIT_CAPS (pad)) {
- GST_ERROR_OBJECT (pad, "still explicit caps %"GST_PTR_FORMAT" set", GST_RPAD_EXPLICIT_CAPS (pad));
+ GST_ERROR_OBJECT (pad, "still explicit caps %" GST_PTR_FORMAT " set",
+ GST_RPAD_EXPLICIT_CAPS (pad));
g_warning ("pad %p has still explicit caps set", pad);
gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL);
}
* in the element to a pad of an element up in the hierarchy.
*/
void
-gst_pad_load_and_link (xmlNodePtr self, GstObject *parent)
+gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
{
xmlNodePtr field = self->xmlChildrenNode;
GstPad *pad = NULL, *targetpad;
while (field) {
if (!strcmp (field->name, "name")) {
- pad = gst_element_get_pad (GST_ELEMENT (parent),
- xmlNodeGetContent (field));
- }
- else if (!strcmp(field->name, "peer")) {
+ pad = gst_element_get_pad (GST_ELEMENT (parent),
+ xmlNodeGetContent (field));
+ } else if (!strcmp (field->name, "peer")) {
peer = xmlNodeGetContent (field);
}
field = field->next;
}
g_return_if_fail (pad != NULL);
- if (peer == NULL) return;
+ if (peer == NULL)
+ return;
split = g_strsplit (peer, ".", 2);
if (split[0] == NULL || split[1] == NULL) {
- GST_CAT_DEBUG (GST_CAT_XML,
- "Could not parse peer '%s' for pad %s:%s, leaving unlinked",
- peer, GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_DEBUG (GST_CAT_XML,
+ "Could not parse peer '%s' for pad %s:%s, leaving unlinked",
+ peer, GST_DEBUG_PAD_NAME (pad));
return;
}
-
+
g_return_if_fail (split[0] != NULL);
g_return_if_fail (split[1] != NULL);
if (grandparent && GST_IS_BIN (grandparent)) {
target = gst_bin_get_by_name_recurse_up (GST_BIN (grandparent), split[0]);
- }
- else
+ } else
goto cleanup;
- if (target == NULL) goto cleanup;
+ if (target == NULL)
+ goto cleanup;
targetpad = gst_element_get_pad (target, split[1]);
- if (targetpad == NULL) goto cleanup;
+ if (targetpad == NULL)
+ goto cleanup;
gst_pad_link (pad, targetpad);
* Returns: the #xmlNodePtr representation of the pad.
*/
static xmlNodePtr
-gst_pad_save_thyself (GstObject *object, xmlNodePtr parent)
+gst_pad_save_thyself (GstObject * object, xmlNodePtr parent)
{
GstRealPad *realpad;
GstPad *peer;
xmlNewChild (parent, NULL, "name", GST_PAD_NAME (realpad));
if (GST_RPAD_PEER (realpad) != NULL) {
gchar *content;
-
+
peer = GST_PAD (GST_RPAD_PEER (realpad));
/* first check to see if the peer's parent's parent is the same */
/* we just save it off */
content = g_strdup_printf ("%s.%s",
- GST_OBJECT_NAME (GST_PAD_PARENT (peer)),
- GST_PAD_NAME (peer));
+ GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer));
xmlNewChild (parent, NULL, "peer", content);
g_free (content);
} else
* Returns: the #xmlNodePtr representation of the pad.
*/
xmlNodePtr
-gst_ghost_pad_save_thyself (GstPad *pad, xmlNodePtr parent)
+gst_ghost_pad_save_thyself (GstPad * pad, xmlNodePtr parent)
{
xmlNodePtr self;
* Pushes a buffer or an event to the peer of @pad. @pad must be linked. May
* only be called by @pad's parent.
*/
-void
-gst_pad_push (GstPad *pad, GstData *data)
+void
+gst_pad_push (GstPad * pad, GstData * data)
{
GstRealPad *peer;
if (!gst_probe_dispatcher_dispatch (&(GST_REAL_PAD (pad)->probedisp), &data))
return;
-
+
if (!GST_PAD_IS_LINKED (pad)) {
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "not pushing data %p as pad is unconnected", data);
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
+ "not pushing data %p as pad is unconnected", data);
gst_data_unref (data);
return;
- }
+ }
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "pushing");
peer = GST_RPAD_PEER (pad);
if (!peer) {
- g_warning ("push on pad %s:%s but it is unlinked",
- GST_DEBUG_PAD_NAME (pad));
- }
- else {
+ g_warning ("push on pad %s:%s but it is unlinked",
+ GST_DEBUG_PAD_NAME (pad));
+ } else {
if (!GST_IS_EVENT (data) && !GST_PAD_IS_ACTIVE (peer)) {
- g_warning ("push on peer of pad %s:%s but peer is not active",
- GST_DEBUG_PAD_NAME (pad));
+ g_warning ("push on peer of pad %s:%s but peer is not active",
+ GST_DEBUG_PAD_NAME (pad));
return;
}
if (peer->chainhandler) {
if (data) {
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
- "calling chainhandler &%s of peer pad %s:%s",
- GST_DEBUG_FUNCPTR_NAME (peer->chainhandler),
- GST_DEBUG_PAD_NAME (GST_PAD (peer)));
- if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
- return;
-
- (peer->chainhandler) (GST_PAD (peer), data);
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
+ "calling chainhandler &%s of peer pad %s:%s",
+ GST_DEBUG_FUNCPTR_NAME (peer->chainhandler),
+ GST_DEBUG_PAD_NAME (GST_PAD (peer)));
+ if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
+ return;
+
+ (peer->chainhandler) (GST_PAD (peer), data);
return;
- }
- else {
- g_warning ("trying to push a NULL buffer on pad %s:%s",
- GST_DEBUG_PAD_NAME (peer));
+ } else {
+ g_warning ("trying to push a NULL buffer on pad %s:%s",
+ GST_DEBUG_PAD_NAME (peer));
return;
}
- }
- else {
+ } else {
g_warning ("internal error: push on pad %s:%s but it has no chainhandler",
- GST_DEBUG_PAD_NAME (peer));
+ GST_DEBUG_PAD_NAME (peer));
}
}
/* clean up the mess here */
- if (data != NULL) gst_data_unref (data);
+ if (data != NULL)
+ gst_data_unref (data);
}
/**
*
* Returns: a new #GstData from the peer pad.
*/
-GstData*
-gst_pad_pull (GstPad *pad)
+GstData *
+gst_pad_pull (GstPad * pad)
{
GstRealPad *peer;
-
+
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "pulling");
g_return_val_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SINK,
- GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)));
+ GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)));
peer = GST_RPAD_PEER (pad);
if (!peer) {
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
- ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad)));
- }
- else {
-restart:
+ ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad)));
+ } else {
+ restart:
if (peer->gethandler) {
GstData *data;
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
- "calling gethandler %s of peer pad %s:%s",
- GST_DEBUG_FUNCPTR_NAME (peer->gethandler),
- GST_DEBUG_PAD_NAME (peer));
+ "calling gethandler %s of peer pad %s:%s",
+ GST_DEBUG_FUNCPTR_NAME (peer->gethandler), GST_DEBUG_PAD_NAME (peer));
data = (peer->gethandler) (GST_PAD (peer));
if (data) {
- if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
- goto restart;
- return data;
+ if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
+ goto restart;
+ return data;
}
/* no null buffers allowed */
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
- ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad)));
+ ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad)));
} else {
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
- ("pull on pad %s:%s but the peer pad %s:%s has no gethandler",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)));
+ ("pull on pad %s:%s but the peer pad %s:%s has no gethandler",
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)));
}
}
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
* Returns: the #GstPad that has a buffer available.
* Use #gst_pad_pull() to get the buffer.
*/
-GstPad*
-gst_pad_selectv (GList *padlist)
+GstPad *
+gst_pad_selectv (GList * padlist)
{
GstPad *pad;
- pad = gst_scheduler_pad_select (GST_PAD_PARENT (padlist->data)->sched,
- padlist);
+ pad = gst_scheduler_pad_select (GST_PAD_PARENT (padlist->data)->sched,
+ padlist);
return pad;
}
* Returns: the #GstPad that has a buffer available.
* Use #gst_pad_pull() to get the buffer.
*/
-GstPad*
-gst_pad_select (GstPad *pad, ...)
+GstPad *
+gst_pad_select (GstPad * pad, ...)
{
GstPad *result;
va_list var_args;
result = gst_pad_select_valist (pad, var_args);
va_end (var_args);
-
+
return result;
}
* Returns: the #GstPad that has a buffer available.
* Use #gst_pad_pull() to get the buffer.
*/
-GstPad*
-gst_pad_select_valist (GstPad *pad, va_list var_args)
+GstPad *
+gst_pad_select_valist (GstPad * pad, va_list var_args)
{
GstPad *result;
GList *padlist = NULL;
* templates
*
*/
-static void gst_pad_template_class_init (GstPadTemplateClass *klass);
-static void gst_pad_template_init (GstPadTemplate *templ);
-static void gst_pad_template_dispose (GObject *object);
+static void gst_pad_template_class_init (GstPadTemplateClass * klass);
+static void gst_pad_template_init (GstPadTemplate * templ);
+static void gst_pad_template_dispose (GObject * object);
GType
gst_pad_template_get_type (void)
32,
(GInstanceInitFunc) gst_pad_template_init, NULL
};
- padtemplate_type = g_type_register_static(GST_TYPE_OBJECT, "GstPadTemplate",
- &padtemplate_info, 0);
+ padtemplate_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate",
+ &padtemplate_info, 0);
}
return padtemplate_type;
}
static void
-gst_pad_template_class_init (GstPadTemplateClass *klass)
+gst_pad_template_class_init (GstPadTemplateClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
padtemplate_parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gst_pad_template_signals[TEMPL_PAD_CREATED] =
- g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstPadTemplateClass, pad_created),
- NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GST_TYPE_PAD);
+ g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPadTemplateClass, pad_created),
+ NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD);
gobject_class->dispose = gst_pad_template_dispose;
}
static void
-gst_pad_template_init (GstPadTemplate *templ)
+gst_pad_template_init (GstPadTemplate * templ)
{
}
static void
-gst_pad_template_dispose (GObject *object)
+gst_pad_template_dispose (GObject * object)
{
GstPadTemplate *templ = GST_PAD_TEMPLATE (object);
* naming.
*/
static gboolean
-name_is_valid (const gchar *name, GstPadPresence presence)
+name_is_valid (const gchar * name, GstPadPresence presence)
{
const gchar *str;
-
+
if (presence == GST_PAD_ALWAYS) {
if (strchr (name, '%')) {
g_warning ("invalid name template %s: conversion specifications are not"
- " allowed for GST_PAD_ALWAYS padtemplates", name);
+ " allowed for GST_PAD_ALWAYS padtemplates", name);
return FALSE;
}
} else if (presence == GST_PAD_REQUEST) {
if ((str = strchr (name, '%')) && strchr (str + 1, '%')) {
g_warning ("invalid name template %s: only one conversion specification"
- " allowed in GST_PAD_REQUEST padtemplate", name);
+ " allowed in GST_PAD_REQUEST padtemplate", name);
return FALSE;
}
- if (str && (*(str+1) != 's' && *(str+1) != 'd')) {
+ if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) {
g_warning ("invalid name template %s: conversion specification must be of"
- " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name);
+ " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name);
return FALSE;
}
- if (str && (*(str+2) != '\0')) {
+ if (str && (*(str + 2) != '\0')) {
g_warning ("invalid name template %s: conversion specification must"
- " appear at the end of the GST_PAD_REQUEST padtemplate name",
- name);
+ " appear at the end of the GST_PAD_REQUEST padtemplate name", name);
return FALSE;
}
}
-
+
return TRUE;
}
*
* Returns: a new #GstPadTemplate.
*/
-GstPadTemplate*
-gst_static_pad_template_get (GstStaticPadTemplate *pad_template)
+GstPadTemplate *
+gst_static_pad_template_get (GstStaticPadTemplate * pad_template)
{
GstPadTemplate *new;
return NULL;
new = g_object_new (gst_pad_template_get_type (),
- "name", pad_template->name_template,
- NULL);
+ "name", pad_template->name_template, NULL);
- GST_PAD_TEMPLATE_NAME_TEMPLATE (new) =
- g_strdup (pad_template->name_template);
+ GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (pad_template->name_template);
GST_PAD_TEMPLATE_DIRECTION (new) = pad_template->direction;
GST_PAD_TEMPLATE_PRESENCE (new) = pad_template->presence;
- GST_PAD_TEMPLATE_CAPS (new) = gst_caps_copy (
- gst_static_caps_get (&pad_template->static_caps));
+ GST_PAD_TEMPLATE_CAPS (new) =
+ gst_caps_copy (gst_static_caps_get (&pad_template->static_caps));
return new;
}
*
* Returns: a new #GstPadTemplate.
*/
-GstPadTemplate*
-gst_pad_template_new (const gchar *name_template,
- GstPadDirection direction, GstPadPresence presence,
- GstCaps *caps)
+GstPadTemplate *
+gst_pad_template_new (const gchar * name_template,
+ GstPadDirection direction, GstPadPresence presence, GstCaps * caps)
{
GstPadTemplate *new;
#ifdef USE_POISONING
if (caps) {
GstCaps *newcaps = gst_caps_copy (caps);
- gst_caps_free(caps);
+
+ gst_caps_free (caps);
caps = newcaps;
}
#endif
#endif
new = g_object_new (gst_pad_template_get_type (),
- "name", name_template,
- NULL);
+ "name", name_template, NULL);
GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template);
GST_PAD_TEMPLATE_DIRECTION (new) = direction;
* Returns: the #GstCaps of the pad template. If you need to keep a reference to
* the caps, make a copy (see gst_caps_copy ()).
*/
-const GstCaps*
-gst_pad_template_get_caps (GstPadTemplate *templ)
+const GstCaps *
+gst_pad_template_get_caps (GstPadTemplate * templ)
{
g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
* This function can only be used by the element that owns the pad.
*/
void
-gst_pad_set_element_private (GstPad *pad, gpointer priv)
+gst_pad_set_element_private (GstPad * pad, gpointer priv)
{
pad->element_private = priv;
}
* Returns: a #gpointer to the private data.
*/
gpointer
-gst_pad_get_element_private (GstPad *pad)
+gst_pad_get_element_private (GstPad * pad)
{
return pad->element_private;
}
/***** ghost pads *****/
GType _gst_ghost_pad_type = 0;
-static void gst_ghost_pad_class_init (GstGhostPadClass *klass);
-static void gst_ghost_pad_init (GstGhostPad *pad);
-static void gst_ghost_pad_dispose (GObject *object);
-static void gst_ghost_pad_get_property (GObject* object, guint prop_id,
- GValue* value, GParamSpec* pspec);
-static void gst_ghost_pad_set_property (GObject* object, guint prop_id,
- const GValue* value, GParamSpec* pspec);
+static void gst_ghost_pad_class_init (GstGhostPadClass * klass);
+static void gst_ghost_pad_init (GstGhostPad * pad);
+static void gst_ghost_pad_dispose (GObject * object);
+static void gst_ghost_pad_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_ghost_pad_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
static GstPad *ghost_pad_parent_class = NULL;
+
/* static guint gst_ghost_pad_signals[LAST_SIGNAL] = { 0 }; */
-enum
+enum
{
GPAD_ARG_0,
GPAD_ARG_REAL_PAD
- /* fill me */
+ /* fill me */
};
GType
-gst_ghost_pad_get_type (void)
+gst_ghost_pad_get_type (void)
{
if (!_gst_ghost_pad_type) {
static const GTypeInfo pad_info = {
(GInstanceInitFunc) gst_ghost_pad_init,
NULL
};
- _gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad",
- &pad_info, 0);
+ _gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad",
+ &pad_info, 0);
}
return _gst_ghost_pad_type;
}
static void
-gst_ghost_pad_class_init (GstGhostPadClass *klass)
+gst_ghost_pad_class_init (GstGhostPadClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
ghost_pad_parent_class = g_type_class_ref (GST_TYPE_PAD);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ghost_pad_get_property);
g_object_class_install_property (gobject_class, GPAD_ARG_REAL_PAD,
- g_param_spec_object ("real-pad", "Real pad", "The real pad for the ghost pad",
- GST_TYPE_PAD, G_PARAM_READWRITE));
+ g_param_spec_object ("real-pad", "Real pad",
+ "The real pad for the ghost pad", GST_TYPE_PAD, G_PARAM_READWRITE));
}
static void
-gst_ghost_pad_init (GstGhostPad *pad)
+gst_ghost_pad_init (GstGhostPad * pad)
{
/* zeroed by glib */
}
static void
-gst_ghost_pad_dispose (GObject *object)
+gst_ghost_pad_dispose (GObject * object)
{
g_object_set (object, "real-pad", NULL, NULL);
}
static void
-gst_ghost_pad_set_property (GObject* object, guint prop_id,
- const GValue* value, GParamSpec* pspec)
+gst_ghost_pad_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GstPad *ghostpad = (GstPad*)object;
- GstPad *oldrealpad = (GstPad*)GST_GPAD_REALPAD (ghostpad);
+ GstPad *ghostpad = (GstPad *) object;
+ GstPad *oldrealpad = (GstPad *) GST_GPAD_REALPAD (ghostpad);
GstPad *realpad = NULL;
-
+
switch (prop_id) {
case GPAD_ARG_REAL_PAD:
realpad = g_value_get_object (value);
-
+
if (oldrealpad) {
- if (realpad == oldrealpad)
- return;
- else
- gst_pad_remove_ghost_pad (oldrealpad, ghostpad);
+ if (realpad == oldrealpad)
+ return;
+ else
+ gst_pad_remove_ghost_pad (oldrealpad, ghostpad);
}
-
+
if (realpad)
- gst_pad_add_ghost_pad (realpad, ghostpad);
+ gst_pad_add_ghost_pad (realpad, ghostpad);
break;
default:
}
static void
-gst_ghost_pad_get_property (GObject* object, guint prop_id,
- GValue* value, GParamSpec* pspec)
+gst_ghost_pad_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
case GPAD_ARG_REAL_PAD:
*
* Returns: a new ghost #GstPad, or %NULL in case of an error.
*/
-GstPad*
-gst_ghost_pad_new (const gchar *name,
- GstPad *pad)
+GstPad *
+gst_ghost_pad_new (const gchar * name, GstPad * pad)
{
GstPad *gpad;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- gpad = g_object_new (GST_TYPE_GHOST_PAD,
- "name", name,
- "real-pad", pad,
- NULL);
+ gpad = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "real-pad", pad, NULL);
- GST_CAT_DEBUG (GST_CAT_PADS, "created ghost pad \"%s\" for pad %s:%s",
- GST_OBJECT_NAME (gpad),
- GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_DEBUG (GST_CAT_PADS, "created ghost pad \"%s\" for pad %s:%s",
+ GST_OBJECT_NAME (gpad), GST_DEBUG_PAD_NAME (pad));
return gpad;
}
*
* Returns: a newly allocated #GList of pads.
*/
-GList*
-gst_pad_get_internal_links_default (GstPad *pad)
+GList *
+gst_pad_get_internal_links_default (GstPad * pad)
{
GList *res = NULL;
GstElement *parent;
GList *parent_pads;
GstPadDirection direction;
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
rpad = GST_PAD_REALIZE (pad);
while (parent_pads) {
GstRealPad *parent_pad = GST_PAD_REALIZE (parent_pads->data);
-
+
if (parent_pad->direction != direction) {
res = g_list_prepend (res, parent_pad);
}
-
+
parent_pads = g_list_next (parent_pads);
}
*
* Returns: a newly allocated #GList of pads.
*/
-GList*
-gst_pad_get_internal_links (GstPad *pad)
+GList *
+gst_pad_get_internal_links (GstPad * pad)
{
GList *res = NULL;
GstRealPad *rpad;
}
-static gboolean
-gst_pad_event_default_dispatch (GstPad *pad, GstElement *element,
- GstEvent *event)
+static gboolean
+gst_pad_event_default_dispatch (GstPad * pad, GstElement * element,
+ GstEvent * event)
{
GList *orig, *pads;
- GST_INFO_OBJECT (pad, "Sending event %p to all internally linked pads", event);
+ GST_INFO_OBJECT (pad, "Sending event %p to all internally linked pads",
+ event);
orig = pads = gst_pad_get_internal_links (pad);
while (pads) {
GstPad *eventpad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
/* for all of the internally-linked pads that are actually linked */
if (GST_PAD_IS_LINKED (eventpad)) {
if (GST_PAD_DIRECTION (eventpad) == GST_PAD_SRC) {
/* increase the refcount */
- gst_event_ref (event);
- gst_pad_push (eventpad, GST_DATA (event));
- }
- else {
+ gst_event_ref (event);
+ gst_pad_push (eventpad, GST_DATA (event));
+ } else {
GstPad *peerpad = GST_PAD (GST_RPAD_PEER (eventpad));
/* we only send the event on one pad, multi-sinkpad elements
* should implement a handler */
- g_list_free (orig);
- return gst_pad_send_event (peerpad, event);
+ g_list_free (orig);
+ return gst_pad_send_event (peerpad, event);
}
}
}
*
* Returns: TRUE if the event was sent succesfully.
*/
-gboolean
-gst_pad_event_default (GstPad *pad, GstEvent *event)
+gboolean
+gst_pad_event_default (GstPad * pad, GstEvent * event)
{
GstElement *element;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
element = GST_PAD_PARENT (pad);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
{
guint64 time;
-
+
if (gst_element_requires_clock (element) && element->clock) {
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) {
- gst_element_set_time (element, time);
+ gst_element_set_time (element, time);
} else {
GstFormat format = GST_FORMAT_TIME;
guint i;
+
for (i = 0; i < event->event_data.discont.noffsets; i++) {
- if (gst_pad_convert (pad, event->event_data.discont.offsets[i].format,
- event->event_data.discont.offsets[i].value, &format, &time)) {
+ if (gst_pad_convert (pad,
+ event->event_data.discont.offsets[i].format,
+ event->event_data.discont.offsets[i].value, &format,
+ &time)) {
gst_element_set_time (element, time);
} else if (i == event->event_data.discont.noffsets) {
- g_warning ("can't adjust clock to new time when time not provided");
+ g_warning
+ ("can't adjust clock to new time when time not provided");
}
- }
+ }
}
}
}
* Returns: TRUE if one of the dispatcher functions returned TRUE.
*/
gboolean
-gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch,
- gpointer data)
+gst_pad_dispatcher (GstPad * pad, GstPadDispatcherFunction dispatch,
+ gpointer data)
{
gboolean res = FALSE;
GList *int_pads, *orig;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
g_return_val_if_fail (dispatch != NULL, FALSE);
if (int_peer) {
res = dispatch (GST_PAD (int_peer), data);
if (res)
- break;
+ break;
}
int_pads = g_list_next (int_pads);
}
g_list_free (orig);
-
+
return res;
}
* Returns: TRUE if the event was handled.
*/
gboolean
-gst_pad_send_event (GstPad *pad, GstEvent *event)
+gst_pad_send_event (GstPad * pad, GstEvent * event)
{
gboolean success = FALSE;
GstRealPad *rpad;
GST_EVENT_SRC (event) = gst_object_ref (GST_OBJECT (rpad));
GST_CAT_DEBUG (GST_CAT_EVENT, "have event %d on pad %s:%s",
- GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (rpad));
+ GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (rpad));
if (GST_RPAD_EVENTHANDLER (rpad))
success = GST_RPAD_EVENTHANDLER (rpad) (GST_PAD (rpad), event);
return success;
}
-typedef struct
+typedef struct
{
- GstFormat src_format;
- gint64 src_value;
- GstFormat *dest_format;
- gint64 *dest_value;
+ GstFormat src_format;
+ gint64 src_value;
+ GstFormat *dest_format;
+ gint64 *dest_value;
} GstPadConvertData;
static gboolean
-gst_pad_convert_dispatcher (GstPad *pad, GstPadConvertData *data)
+gst_pad_convert_dispatcher (GstPad * pad, GstPadConvertData * data)
{
- return gst_pad_convert (pad, data->src_format, data->src_value,
- data->dest_format, data->dest_value);
+ return gst_pad_convert (pad, data->src_format, data->src_value,
+ data->dest_format, data->dest_value);
}
/**
* Returns: TRUE if the conversion could be performed.
*/
gboolean
-gst_pad_convert_default (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_pad_convert_default (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
GstPadConvertData data;
data.dest_format = dest_format;
data.dest_value = dest_value;
- return gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
- gst_pad_convert_dispatcher, &data);
+ return gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
+ gst_pad_convert_dispatcher, &data);
}
/**
* Returns: TRUE if the conversion could be performed.
*/
gboolean
-gst_pad_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_pad_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
g_return_val_if_fail (dest_format != NULL, FALSE);
g_return_val_if_fail (dest_value != NULL, FALSE);
if (src_format == *dest_format) {
- *dest_value = src_value;
+ *dest_value = src_value;
return TRUE;
- }
+ }
rpad = GST_PAD_REALIZE (pad);
if (GST_RPAD_CONVERTFUNC (rpad)) {
- return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format,
- src_value, dest_format, dest_value);
+ return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format,
+ src_value, dest_format, dest_value);
}
return FALSE;
}
-typedef struct
+typedef struct
{
- GstQueryType type;
- GstFormat *format;
- gint64 *value;
+ GstQueryType type;
+ GstFormat *format;
+ gint64 *value;
} GstPadQueryData;
static gboolean
-gst_pad_query_dispatcher (GstPad *pad, GstPadQueryData *data)
+gst_pad_query_dispatcher (GstPad * pad, GstPadQueryData * data)
{
return gst_pad_query (pad, data->type, data->format, data->value);
}
* Returns: TRUE if the query could be performed.
*/
gboolean
-gst_pad_query_default (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_pad_query_default (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstPadQueryData data;
data.format = format;
data.value = value;
- return gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
- gst_pad_query_dispatcher, &data);
+ return gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
+ gst_pad_query_dispatcher, &data);
}
/**
* Returns: TRUE if the query could be performed.
*/
gboolean
-gst_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
g_return_val_if_fail (format != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
}
static gboolean
-gst_pad_get_formats_dispatcher (GstPad *pad, const GstFormat **data)
+gst_pad_get_formats_dispatcher (GstPad * pad, const GstFormat ** data)
{
*data = gst_pad_get_formats (pad);
*
* Returns: An array of GstFormats ended with a 0 value.
*/
-const GstFormat*
-gst_pad_get_formats_default (GstPad *pad)
+const GstFormat *
+gst_pad_get_formats_default (GstPad * pad)
{
GstFormat *result = NULL;
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
- gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
- gst_pad_get_formats_dispatcher, &result);
+ gst_pad_dispatcher (pad, (GstPadDispatcherFunction)
+ gst_pad_get_formats_dispatcher, &result);
return result;
}
*
* Returns: An array of GstFormats ended with a 0 value.
*/
-const GstFormat*
-gst_pad_get_formats (GstPad *pad)
+const GstFormat *
+gst_pad_get_formats (GstPad * pad)
{
GstRealPad *rpad;
-
+
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
rpad = GST_PAD_REALIZE (pad);
#include <gst/gstquery.h>
-G_BEGIN_DECLS
-
-extern GType _gst_pad_type;
+G_BEGIN_DECLS extern GType _gst_pad_type;
extern GType _gst_real_pad_type;
extern GType _gst_ghost_pad_type;
/*
* Pad base class
*/
-#define GST_TYPE_PAD (_gst_pad_type)
+#define GST_TYPE_PAD (_gst_pad_type)
#define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
#define GST_IS_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD || \
G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
typedef struct _GstRealPadClass GstRealPadClass;
typedef struct _GstGhostPad GstGhostPad;
typedef struct _GstGhostPadClass GstGhostPadClass;
+
/*typedef struct _GstPadTemplate GstPadTemplate;*/
/*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/
typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
typedef struct _GstPadLink GstPadLink;
-typedef enum {
+typedef enum
+{
GST_PAD_LINK_REFUSED = -1,
- GST_PAD_LINK_DELAYED = 0,
- GST_PAD_LINK_OK = 1,
- GST_PAD_LINK_DONE = 2
+ GST_PAD_LINK_DELAYED = 0,
+ GST_PAD_LINK_OK = 1,
+ GST_PAD_LINK_DONE = 2
} GstPadLinkReturn;
#define GST_PAD_LINK_FAILED(ret) (ret < GST_PAD_LINK_OK)
#endif
#endif
-
+
/* this defines the functions used to chain buffers
* pad is the sink pad (so the same chain function can be used for N pads)
* buf is the buffer being passed */
-typedef void (*GstPadChainFunction) (GstPad *pad,GstData *data);
-typedef GstData* (*GstPadGetFunction) (GstPad *pad);
-typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
-typedef gboolean (*GstPadConvertFunction) (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-typedef GList* (*GstPadIntLinkFunction) (GstPad *pad);
-typedef const GstFormat* (*GstPadFormatsFunction) (GstPad *pad);
-typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad);
-typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
-
-typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, const GstCaps *caps);
-typedef void (*GstPadUnlinkFunction) (GstPad *pad);
-typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
-typedef GstCaps* (*GstPadFixateFunction) (GstPad *pad, const GstCaps *caps);
-typedef GstBuffer* (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size);
-
-typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
-
-typedef enum {
+typedef void (*GstPadChainFunction) (GstPad * pad, GstData * data);
+typedef GstData *(*GstPadGetFunction) (GstPad * pad);
+typedef gboolean (*GstPadEventFunction) (GstPad * pad, GstEvent * event);
+typedef gboolean (*GstPadConvertFunction) (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+typedef gboolean (*GstPadQueryFunction) (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+typedef GList *(*GstPadIntLinkFunction) (GstPad * pad);
+typedef const GstFormat *(*GstPadFormatsFunction) (GstPad * pad);
+typedef const GstEventMask *(*GstPadEventMaskFunction) (GstPad * pad);
+typedef const GstQueryType *(*GstPadQueryTypeFunction) (GstPad * pad);
+
+typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad * pad,
+ const GstCaps * caps);
+typedef void (*GstPadUnlinkFunction) (GstPad * pad);
+typedef GstCaps *(*GstPadGetCapsFunction) (GstPad * pad);
+typedef GstCaps *(*GstPadFixateFunction) (GstPad * pad, const GstCaps * caps);
+typedef GstBuffer *(*GstPadBufferAllocFunction) (GstPad * pad, guint64 offset,
+ guint size);
+
+typedef gboolean (*GstPadDispatcherFunction) (GstPad * pad, gpointer data);
+
+typedef enum
+{
GST_PAD_UNKNOWN,
GST_PAD_SRC,
GST_PAD_SINK
} GstPadDirection;
-typedef enum {
- GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST,
+typedef enum
+{
+ GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST,
GST_PAD_NEGOTIATING,
- GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
+ GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
} GstPadFlags;
-struct _GstPad {
- GstObject object;
+struct _GstPad
+{
+ GstObject object;
- gpointer element_private;
+ gpointer element_private;
- GstPadTemplate *padtemplate; /* the template for this pad */
+ GstPadTemplate *padtemplate; /* the template for this pad */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstPadClass {
+struct _GstPadClass
+{
GstObjectClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstRealPad {
- GstPad pad;
+struct _GstRealPad
+{
+ GstPad pad;
/* the pad capabilities */
- GstCaps *caps;
- GstPadFixateFunction appfixatefunc;
- GstCaps *appfilter;
- GstPadGetCapsFunction getcapsfunc;
- GstPadFixateFunction fixatefunc;
-
- GstPadDirection direction;
+ GstCaps *caps;
+ GstPadFixateFunction appfixatefunc;
+ GstCaps *appfilter;
+ GstPadGetCapsFunction getcapsfunc;
+ GstPadFixateFunction fixatefunc;
+
+ GstPadDirection direction;
- GstPadLinkFunction linkfunc;
- GstPadUnlinkFunction unlinkfunc;
- GstRealPad *peer;
+ GstPadLinkFunction linkfunc;
+ GstPadUnlinkFunction unlinkfunc;
+ GstRealPad *peer;
- gpointer sched_private;
+ gpointer sched_private;
/* data transport functions */
- GstPadChainFunction chainfunc;
- GstPadChainFunction chainhandler;
- GstPadGetFunction getfunc;
- GstPadGetFunction gethandler;
- GstPadEventFunction eventfunc;
- GstPadEventFunction eventhandler;
- GstPadEventMaskFunction eventmaskfunc;
+ GstPadChainFunction chainfunc;
+ GstPadChainFunction chainhandler;
+ GstPadGetFunction getfunc;
+ GstPadGetFunction gethandler;
+ GstPadEventFunction eventfunc;
+ GstPadEventFunction eventhandler;
+ GstPadEventMaskFunction eventmaskfunc;
- GList *ghostpads;
+ GList *ghostpads;
/* query/convert/formats functions */
- GstPadConvertFunction convertfunc;
- GstPadQueryFunction queryfunc;
- GstPadFormatsFunction formatsfunc;
- GstPadQueryTypeFunction querytypefunc;
- GstPadIntLinkFunction intlinkfunc;
+ GstPadConvertFunction convertfunc;
+ GstPadQueryFunction queryfunc;
+ GstPadFormatsFunction formatsfunc;
+ GstPadQueryTypeFunction querytypefunc;
+ GstPadIntLinkFunction intlinkfunc;
- GstPadBufferAllocFunction bufferallocfunc;
+ GstPadBufferAllocFunction bufferallocfunc;
- GstProbeDispatcher probedisp;
+ GstProbeDispatcher probedisp;
- GstPadLink *link;
- GstCaps *explicit_caps;
+ GstPadLink *link;
+ GstCaps *explicit_caps;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstRealPadClass {
- GstPadClass parent_class;
+struct _GstRealPadClass
+{
+ GstPadClass parent_class;
/* signal callbacks */
- void (*caps_nego_failed) (GstPad *pad, GstCaps *caps);
+ void (*caps_nego_failed) (GstPad * pad, GstCaps * caps);
- void (*linked) (GstPad *pad, GstPad *peer);
- void (*unlinked) (GstPad *pad, GstPad *peer);
- GstPadFixateFunction appfixatefunc;
+ void (*linked) (GstPad * pad, GstPad * peer);
+ void (*unlinked) (GstPad * pad, GstPad * peer);
+ GstPadFixateFunction appfixatefunc;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstGhostPad {
+struct _GstGhostPad
+{
GstPad pad;
GstRealPad *realpad;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstGhostPadClass {
+struct _GstGhostPadClass
+{
GstPadClass parent_class;
gpointer _gst_reserved[GST_PADDING];
#define GST_IS_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
#define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
-typedef enum {
+typedef enum
+{
GST_PAD_ALWAYS,
GST_PAD_SOMETIMES,
GST_PAD_REQUEST
#define GST_PAD_TEMPLATE_PRESENCE(templ) (((GstPadTemplate *)(templ))->presence)
#define GST_PAD_TEMPLATE_CAPS(templ) (((GstPadTemplate *)(templ))->caps)
-typedef enum {
- GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST,
+typedef enum
+{
+ GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST,
- GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
+ GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
} GstPadTemplateFlags;
#define GST_PAD_TEMPLATE_IS_FIXED(templ) (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
-struct _GstPadTemplate {
- GstObject object;
+struct _GstPadTemplate
+{
+ GstObject object;
- gchar *name_template;
- GstPadDirection direction;
- GstPadPresence presence;
- GstCaps *caps;
+ gchar *name_template;
+ GstPadDirection direction;
+ GstPadPresence presence;
+ GstCaps *caps;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstPadTemplateClass {
- GstObjectClass parent_class;
+struct _GstPadTemplateClass
+{
+ GstObjectClass parent_class;
/* signal callbacks */
- void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
+ void (*pad_created) (GstPadTemplate * templ, GstPad * pad);
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstStaticPadTemplate {
- gchar *name_template;
- GstPadDirection direction;
- GstPadPresence presence;
- GstStaticCaps static_caps;
+struct _GstStaticPadTemplate
+{
+ gchar *name_template;
+ GstPadDirection direction;
+ GstPadPresence presence;
+ GstStaticCaps static_caps;
};
#define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
}
-GType gst_pad_get_type (void);
-GType gst_real_pad_get_type (void);
-GType gst_ghost_pad_get_type (void);
+GType gst_pad_get_type (void);
+GType gst_real_pad_get_type (void);
+GType gst_ghost_pad_get_type (void);
/* creating pads */
-GstPad* gst_pad_new (const gchar *name, GstPadDirection direction);
-GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name);
-GstPad* gst_pad_custom_new (GType type, const gchar *name, GstPadDirection direction);
-GstPad* gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ, const gchar *name);
+GstPad *gst_pad_new (const gchar * name, GstPadDirection direction);
+GstPad *gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name);
+GstPad *gst_pad_custom_new (GType type, const gchar * name,
+ GstPadDirection direction);
+GstPad *gst_pad_custom_new_from_template (GType type, GstPadTemplate * templ,
+ const gchar * name);
-void gst_pad_set_name (GstPad *pad, const gchar *name);
-G_CONST_RETURN gchar* gst_pad_get_name (GstPad *pad);
+void gst_pad_set_name (GstPad * pad, const gchar * name);
+G_CONST_RETURN gchar *gst_pad_get_name (GstPad * pad);
-GstPadDirection gst_pad_get_direction (GstPad *pad);
+GstPadDirection gst_pad_get_direction (GstPad * pad);
-void gst_pad_set_active (GstPad *pad, gboolean active);
-gboolean gst_pad_is_active (GstPad *pad);
+void gst_pad_set_active (GstPad * pad, gboolean active);
+gboolean gst_pad_is_active (GstPad * pad);
-void gst_pad_set_element_private (GstPad *pad, gpointer priv);
-gpointer gst_pad_get_element_private (GstPad *pad);
+void gst_pad_set_element_private (GstPad * pad, gpointer priv);
+gpointer gst_pad_get_element_private (GstPad * pad);
-void gst_pad_set_parent (GstPad *pad, GstElement *parent);
-GstElement* gst_pad_get_parent (GstPad *pad);
-GstElement* gst_pad_get_real_parent (GstPad *pad);
+void gst_pad_set_parent (GstPad * pad, GstElement * parent);
+GstElement *gst_pad_get_parent (GstPad * pad);
+GstElement *gst_pad_get_real_parent (GstPad * pad);
-GstScheduler* gst_pad_get_scheduler (GstPad *pad);
+GstScheduler *gst_pad_get_scheduler (GstPad * pad);
-void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad);
-void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad);
-GList* gst_pad_get_ghost_pad_list (GstPad *pad);
+void gst_pad_add_ghost_pad (GstPad * pad, GstPad * ghostpad);
+void gst_pad_remove_ghost_pad (GstPad * pad, GstPad * ghostpad);
+GList *gst_pad_get_ghost_pad_list (GstPad * pad);
-GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
+GstPadTemplate *gst_pad_get_pad_template (GstPad * pad);
-void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufferalloc);
-GstBuffer* gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size);
+void gst_pad_set_bufferalloc_function (GstPad * pad,
+ GstPadBufferAllocFunction bufferalloc);
+GstBuffer *gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size);
/* data passing setup functions */
-void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
-void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
-void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
-void gst_pad_set_event_mask_function (GstPad *pad, GstPadEventMaskFunction mask_func);
-G_CONST_RETURN GstEventMask*
- gst_pad_get_event_masks (GstPad *pad);
-G_CONST_RETURN GstEventMask*
- gst_pad_get_event_masks_default (GstPad *pad);
+void gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain);
+void gst_pad_set_get_function (GstPad * pad, GstPadGetFunction get);
+void gst_pad_set_event_function (GstPad * pad, GstPadEventFunction event);
+void gst_pad_set_event_mask_function (GstPad * pad,
+ GstPadEventMaskFunction mask_func);
+G_CONST_RETURN GstEventMask *gst_pad_get_event_masks (GstPad * pad);
+G_CONST_RETURN GstEventMask *gst_pad_get_event_masks_default (GstPad * pad);
/* pad links */
-void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
-gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
-gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
-void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
+void gst_pad_set_link_function (GstPad * pad, GstPadLinkFunction link);
+gboolean gst_pad_can_link (GstPad * srcpad, GstPad * sinkpad);
+gboolean gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps);
+void gst_pad_set_unlink_function (GstPad * pad, GstPadUnlinkFunction unlink);
-gboolean gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
-gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
-void gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
-gboolean gst_pad_is_linked (GstPad *pad);
+gboolean gst_pad_link (GstPad * srcpad, GstPad * sinkpad);
+gboolean gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps);
+void gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad);
+gboolean gst_pad_is_linked (GstPad * pad);
-GstPad* gst_pad_get_peer (GstPad *pad);
+GstPad *gst_pad_get_peer (GstPad * pad);
/* capsnego functions */
-G_CONST_RETURN GstCaps* gst_pad_get_negotiated_caps (GstPad *pad);
-gboolean gst_pad_is_negotiated (GstPad *pad);
-GstCaps* gst_pad_get_caps (GstPad *pad);
-G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
-GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps);
-GstPadLinkReturn gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps);
-gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
-
-void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
-void gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate);
-GstCaps * gst_pad_proxy_getcaps (GstPad *pad);
-GstPadLinkReturn gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps);
-GstCaps * gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps);
+G_CONST_RETURN GstCaps *gst_pad_get_negotiated_caps (GstPad * pad);
+gboolean gst_pad_is_negotiated (GstPad * pad);
+GstCaps *gst_pad_get_caps (GstPad * pad);
+G_CONST_RETURN GstCaps *gst_pad_get_pad_template_caps (GstPad * pad);
+GstPadLinkReturn gst_pad_try_set_caps (GstPad * pad, const GstCaps * caps);
+GstPadLinkReturn gst_pad_try_set_caps_nonfixed (GstPad * pad,
+ const GstCaps * caps);
+gboolean gst_pad_check_compatibility (GstPad * srcpad, GstPad * sinkpad);
+
+void gst_pad_set_getcaps_function (GstPad * pad, GstPadGetCapsFunction getcaps);
+void gst_pad_set_fixate_function (GstPad * pad, GstPadFixateFunction fixate);
+GstCaps *gst_pad_proxy_getcaps (GstPad * pad);
+GstPadLinkReturn gst_pad_proxy_pad_link (GstPad * pad, const GstCaps * caps);
+GstCaps *gst_pad_proxy_fixate (GstPad * pad, const GstCaps * caps);
+
#ifndef GST_DISABLE_DEPRECATED
-GstPadLinkReturn gst_pad_proxy_link (GstPad *pad, const GstCaps *caps);
+GstPadLinkReturn gst_pad_proxy_link (GstPad * pad, const GstCaps * caps);
#endif
-gboolean gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps);
-void gst_pad_use_explicit_caps (GstPad *pad);
-gboolean gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
+gboolean gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps);
+void gst_pad_use_explicit_caps (GstPad * pad);
+gboolean gst_pad_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps);
#ifndef GST_DISABLE_DEPRECATED
-gboolean gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad);
+gboolean gst_pad_perform_negotiate (GstPad * srcpad, GstPad * sinkpad);
#endif
-GstPadLinkReturn gst_pad_renegotiate (GstPad *pad);
-void gst_pad_unnegotiate (GstPad *pad);
-gboolean gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
-GstCaps* gst_pad_get_allowed_caps (GstPad *pad);
-void gst_pad_caps_change_notify (GstPad *pad);
+GstPadLinkReturn gst_pad_renegotiate (GstPad * pad);
+void gst_pad_unnegotiate (GstPad * pad);
+gboolean gst_pad_try_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
+ const GstCaps * filtercaps);
+GstCaps *gst_pad_get_allowed_caps (GstPad * pad);
+void gst_pad_caps_change_notify (GstPad * pad);
-gboolean gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed);
+gboolean gst_pad_recover_caps_error (GstPad * pad, const GstCaps * allowed);
/* data passing functions */
-void gst_pad_push (GstPad *pad, GstData *data);
-GstData* gst_pad_pull (GstPad *pad);
-gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
-gboolean gst_pad_event_default (GstPad *pad, GstEvent *event);
-GstPad* gst_pad_selectv (GList *padlist);
-GstPad* gst_pad_select (GstPad *pad, ...);
-GstPad* gst_pad_select_valist (GstPad *pad, va_list varargs);
+void gst_pad_push (GstPad * pad, GstData * data);
+GstData *gst_pad_pull (GstPad * pad);
+gboolean gst_pad_send_event (GstPad * pad, GstEvent * event);
+gboolean gst_pad_event_default (GstPad * pad, GstEvent * event);
+GstPad *gst_pad_selectv (GList * padlist);
+GstPad *gst_pad_select (GstPad * pad, ...);
+GstPad *gst_pad_select_valist (GstPad * pad, va_list varargs);
/* convert/query/format functions */
-void gst_pad_set_formats_function (GstPad *pad,
- GstPadFormatsFunction formats);
-G_CONST_RETURN GstFormat*
- gst_pad_get_formats (GstPad *pad);
-G_CONST_RETURN GstFormat*
- gst_pad_get_formats_default (GstPad *pad);
-
-void gst_pad_set_convert_function (GstPad *pad, GstPadConvertFunction convert);
-gboolean gst_pad_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-gboolean gst_pad_convert_default (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-
-void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
-void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func);
-G_CONST_RETURN GstQueryType*
- gst_pad_get_query_types (GstPad *pad);
-G_CONST_RETURN GstQueryType*
- gst_pad_get_query_types_default (GstPad *pad);
-gboolean gst_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-gboolean gst_pad_query_default (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-
-void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink);
-GList* gst_pad_get_internal_links (GstPad *pad);
-GList* gst_pad_get_internal_links_default (GstPad *pad);
-
+void gst_pad_set_formats_function (GstPad * pad, GstPadFormatsFunction formats);
+G_CONST_RETURN GstFormat *gst_pad_get_formats (GstPad * pad);
+G_CONST_RETURN GstFormat *gst_pad_get_formats_default (GstPad * pad);
+
+void gst_pad_set_convert_function (GstPad * pad, GstPadConvertFunction convert);
+gboolean gst_pad_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+gboolean gst_pad_convert_default (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+
+void gst_pad_set_query_function (GstPad * pad, GstPadQueryFunction query);
+void gst_pad_set_query_type_function (GstPad * pad,
+ GstPadQueryTypeFunction type_func);
+G_CONST_RETURN GstQueryType *gst_pad_get_query_types (GstPad * pad);
+G_CONST_RETURN GstQueryType *gst_pad_get_query_types_default (GstPad * pad);
+gboolean gst_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+gboolean gst_pad_query_default (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+
+void gst_pad_set_internal_link_function (GstPad * pad,
+ GstPadIntLinkFunction intlink);
+GList *gst_pad_get_internal_links (GstPad * pad);
+GList *gst_pad_get_internal_links_default (GstPad * pad);
+
/* misc helper functions */
-gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch,
- gpointer data);
+gboolean gst_pad_dispatcher (GstPad * pad, GstPadDispatcherFunction dispatch,
+ gpointer data);
#define gst_pad_add_probe(pad, probe) \
(gst_probe_dispatcher_add_probe (&(GST_REAL_PAD (pad)->probedisp), probe))
(gst_probe_dispatcher_remove_probe (&(GST_REAL_PAD (pad)->probedisp), probe))
#ifndef GST_DISABLE_LOADSAVE
-void gst_pad_load_and_link (xmlNodePtr self, GstObject *parent);
+void gst_pad_load_and_link (xmlNodePtr self, GstObject * parent);
#endif
/* ghostpads */
-GstPad* gst_ghost_pad_new (const gchar *name, GstPad *pad);
+GstPad *gst_ghost_pad_new (const gchar * name, GstPad * pad);
/* templates and factories */
-GType gst_pad_template_get_type (void);
+GType gst_pad_template_get_type (void);
-GstPadTemplate* gst_pad_template_new (const gchar *name_template,
- GstPadDirection direction, GstPadPresence presence,
- GstCaps *caps);
+GstPadTemplate *gst_pad_template_new (const gchar * name_template,
+ GstPadDirection direction, GstPadPresence presence, GstCaps * caps);
-GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *templ);
-const GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
-const GstCaps* gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name);
+GstPadTemplate *gst_static_pad_template_get (GstStaticPadTemplate * templ);
+const GstCaps *gst_pad_template_get_caps (GstPadTemplate * templ);
+const GstCaps *gst_pad_template_get_caps_by_name (GstPadTemplate * templ,
+ const gchar * name);
#ifndef GST_DISABLE_LOADSAVE
-xmlNodePtr gst_ghost_pad_save_thyself (GstPad *pad,
- xmlNodePtr parent);
+xmlNodePtr gst_ghost_pad_save_thyself (GstPad * pad, xmlNodePtr parent);
#endif
G_END_DECLS
-
-
#endif /* __GST_PAD_H__ */
extern GstElement *_gst_parse_launch (const gchar *, GError **);
-GQuark
+GQuark
gst_parse_error_quark (void)
{
static GQuark quark = 0;
+
if (!quark)
quark = g_quark_from_static_string ("gst_parse_error");
return quark;
}
-static gchar *_gst_parse_escape (const gchar *str)
+static gchar *
+_gst_parse_escape (const gchar * str)
{
GString *gstr = NULL;
-
+
g_return_val_if_fail (str != NULL, NULL);
-
+
gstr = g_string_sized_new (strlen (str));
-
+
while (*str) {
if (*str == ' ')
g_string_append_c (gstr, '\\');
g_string_append_c (gstr, *str);
str++;
}
-
+
return gstr->str;
}
+
/**
* gst_parse_launchv:
* @argv: null-terminated array of arguments
* Returns: a new element on success and NULL on failure.
*/
GstElement *
-gst_parse_launchv (const gchar **argv, GError **error)
+gst_parse_launchv (const gchar ** argv, GError ** error)
{
GstElement *element;
GString *str;
g_string_append (str, " ");
argvp++;
}
-
+
element = gst_parse_launch (str->str, error);
g_string_free (str, TRUE);
* a #GstPipeline ant that is returned.
*/
GstElement *
-gst_parse_launch (const gchar * pipeline_description, GError **error)
+gst_parse_launch (const gchar * pipeline_description, GError ** error)
{
GstElement *element;
static GStaticMutex flex_lock = G_STATIC_MUTEX_INIT;
g_return_val_if_fail (pipeline_description != NULL, NULL);
GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s",
- pipeline_description);
+ pipeline_description);
/* the need for the mutex will go away with flex 2.5.6 */
g_static_mutex_lock (&flex_lock);
#include <gst/gstbin.h>
G_BEGIN_DECLS
-
#ifndef GST_DISABLE_PARSE
+ GQuark gst_parse_error_quark (void);
-GQuark gst_parse_error_quark (void);
#define GST_PARSE_ERROR gst_parse_error_quark ()
typedef enum
} GstParseError;
-GstElement* gst_parse_launch (const gchar *pipeline_description, GError **error);
-GstElement* gst_parse_launchv (const gchar **argv, GError **error);
+GstElement *gst_parse_launch (const gchar * pipeline_description,
+ GError ** error);
+GstElement *gst_parse_launchv (const gchar ** argv, GError ** error);
#else /* GST_DISABLE_PARSE */
-
#pragma GCC poison gst_parse_launch
#pragma GCC poison gst_parse_launchv
-
#endif /* GST_DISABLE_PARSE */
-
-G_END_DECLS
-
+ G_END_DECLS
#endif /* __GST_PARSE_H__ */
#include "gstinfo.h"
#include "gstscheduler.h"
-static GstElementDetails gst_pipeline_details = GST_ELEMENT_DETAILS (
- "Pipeline object",
- "Generic/Bin",
- "Complete pipeline object",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_pipeline_details =
+GST_ELEMENT_DETAILS ("Pipeline object",
+ "Generic/Bin",
+ "Complete pipeline object",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Pipeline signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_pipeline_base_init (gpointer g_class);
-static void gst_pipeline_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_pipeline_init (GTypeInstance *instance,
- gpointer g_class);
+static void gst_pipeline_base_init (gpointer g_class);
+static void gst_pipeline_class_init (gpointer g_class, gpointer class_data);
+static void gst_pipeline_init (GTypeInstance * instance, gpointer g_class);
-static void gst_pipeline_dispose (GObject * object);
+static void gst_pipeline_dispose (GObject * object);
-static GstElementStateReturn gst_pipeline_change_state (GstElement * element);
+static GstElementStateReturn gst_pipeline_change_state (GstElement * element);
static GstBinClass *parent_class = NULL;
+
/* static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_pipeline_get_type (void) {
+gst_pipeline_get_type (void)
+{
static GType pipeline_type = 0;
if (!pipeline_type) {
static const GTypeInfo pipeline_info = {
- sizeof(GstPipelineClass),
+ sizeof (GstPipelineClass),
gst_pipeline_base_init,
NULL,
- (GClassInitFunc)gst_pipeline_class_init,
+ (GClassInitFunc) gst_pipeline_class_init,
NULL,
NULL,
- sizeof(GstPipeline),
+ sizeof (GstPipeline),
0,
gst_pipeline_init,
NULL
};
- pipeline_type = g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0);
+ pipeline_type =
+ g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0);
}
return pipeline_type;
}
gst_pipeline_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_pipeline_details);
}
parent_class = g_type_class_peek_parent (klass);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_pipeline_change_state);
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_pipeline_change_state);
}
static void
-gst_pipeline_init (GTypeInstance *instance, gpointer g_class)
+gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
{
GstScheduler *scheduler;
GstPipeline *pipeline = GST_PIPELINE (instance);
-
+
/* pipelines are managing bins */
GST_FLAG_SET (pipeline, GST_BIN_FLAG_MANAGER);
const gchar *name = gst_scheduler_factory_get_default_name ();
g_error ("Critical error: could not get scheduler \"%s\"\n"
- "Are you sure you have a registry ?\n"
- "Run gst-register as root if you haven't done so yet.", name);
+ "Are you sure you have a registry ?\n"
+ "Run gst-register as root if you haven't done so yet.", name);
}
}
static void
-gst_pipeline_dispose (GObject *object)
+gst_pipeline_dispose (GObject * object)
{
GstPipeline *pipeline = GST_PIPELINE (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
- gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (pipeline), NULL);
+ gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (pipeline), NULL);
}
/**
*
* Returns: newly created GstPipeline
*/
-GstElement*
-gst_pipeline_new (const gchar *name)
+GstElement *
+gst_pipeline_new (const gchar * name)
{
return gst_element_factory_make ("pipeline", name);
}
static GstElementStateReturn
-gst_pipeline_change_state (GstElement *element)
+gst_pipeline_change_state (GstElement * element)
{
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
* might not be in cothread 0 */
#if 0
if (GST_ELEMENT_SCHED (element)) {
- gst_scheduler_reset (GST_ELEMENT_SCHED (element));
+ gst_scheduler_reset (GST_ELEMENT_SCHED (element));
}
#endif
break;
return GST_STATE_SUCCESS;
}
-
#include <gst/gstbin.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PIPELINE (gst_pipeline_get_type ())
#define GST_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PIPELINE, GstPipeline))
#define GST_IS_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PIPELINE))
#define GST_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PIPELINE, GstPipelineClass))
#define GST_IS_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PIPELINE))
#define GST_PIPELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PIPELINE, GstPipelineClass))
-
typedef struct _GstPipeline GstPipeline;
typedef struct _GstPipelineClass GstPipelineClass;
-struct _GstPipeline {
- GstBin bin;
+struct _GstPipeline
+{
+ GstBin bin;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstPipelineClass {
+struct _GstPipelineClass
+{
GstBinClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_pipeline_get_type (void);
-GstElement* gst_pipeline_new (const gchar *name);
+GType gst_pipeline_get_type (void);
+GstElement *gst_pipeline_new (const gchar * name);
G_END_DECLS
-
#endif /* __GST_PIPELINE_H__ */
-
/* static variables for segfault handling of plugin loading */
static char *_gst_plugin_fault_handler_filename = NULL;
-extern gboolean *_gst_disable_segtrap; /* see gst.c */
+extern gboolean *_gst_disable_segtrap; /* see gst.c */
static gboolean *_gst_plugin_fault_handler_is_setup = FALSE;
/* list of valid licenses.
NULL
};
-static void gst_plugin_desc_copy (GstPluginDesc *dest,
- const GstPluginDesc *src);
+static void gst_plugin_desc_copy (GstPluginDesc * dest,
+ const GstPluginDesc * src);
-static GstPlugin * gst_plugin_register_func (GstPlugin *plugin,
- GModule *module,
- GstPluginDesc *desc);
+static GstPlugin *gst_plugin_register_func (GstPlugin * plugin,
+ GModule * module, GstPluginDesc * desc);
static GstPlugin *
-gst_plugin_copy (GstPlugin *plugin)
+gst_plugin_copy (GstPlugin * plugin)
{
- return g_memdup(plugin, sizeof(*plugin));
+ return g_memdup (plugin, sizeof (*plugin));
}
GType
if (plugin_type == 0) {
plugin_type = g_boxed_type_register_static ("GstPlugin",
- (GBoxedCopyFunc) gst_plugin_copy, g_free);
+ (GBoxedCopyFunc) gst_plugin_copy, g_free);
}
return plugin_type;
}
-GQuark
+GQuark
gst_plugin_error_quark (void)
{
static GQuark quark = 0;
+
if (!quark)
quark = g_quark_from_static_string ("gst_plugin_error");
return quark;
* When the main module is known, we can register the plugin right away.
* */
void
-_gst_plugin_register_static (GstPluginDesc *desc)
+_gst_plugin_register_static (GstPluginDesc * desc)
{
if (main_module == NULL) {
- if (GST_CAT_DEFAULT) GST_LOG ("queueing static plugin \"%s\" for loading later on", desc->name);
+ if (GST_CAT_DEFAULT)
+ GST_LOG ("queueing static plugin \"%s\" for loading later on",
+ desc->name);
_gst_plugin_static = g_list_prepend (_gst_plugin_static, desc);
- }
- else {
+ } else {
GstPlugin *plugin;
- if (GST_CAT_DEFAULT) GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name);
+ if (GST_CAT_DEFAULT)
+ GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name);
plugin = g_new0 (GstPlugin, 1);
if (gst_plugin_register_func (plugin, main_module, desc)) {
- if (GST_CAT_DEFAULT) GST_INFO ("loaded static plugin \"%s\"", desc->name);
+ if (GST_CAT_DEFAULT)
+ GST_INFO ("loaded static plugin \"%s\"", desc->name);
gst_registry_pool_add_plugin (plugin);
}
}
void
_gst_plugin_initialize (void)
{
- main_module = g_module_open (NULL, G_MODULE_BIND_LAZY);
+ main_module = g_module_open (NULL, G_MODULE_BIND_LAZY);
/* now register all static plugins */
- g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static, NULL);
+ g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static,
+ NULL);
}
/* this function could be extended to check if the plugin license matches the
* We'll wait for someone who's interested in it to code it :)
*/
static gboolean
-gst_plugin_check_license (const gchar *license)
+gst_plugin_check_license (const gchar * license)
{
gchar **check_license = valid_licenses;
g_assert (check_license);
-
+
while (*check_license) {
if (strcmp (license, *check_license) == 0)
return TRUE;
{
/* return NULL if the major and minor version numbers are not compatible */
/* with ours. */
- if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR)
+ if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR)
return FALSE;
return TRUE;
}
-static GstPlugin*
-gst_plugin_register_func (GstPlugin *plugin, GModule *module, GstPluginDesc *desc)
+static GstPlugin *
+gst_plugin_register_func (GstPlugin * plugin, GModule * module,
+ GstPluginDesc * desc)
{
g_assert (plugin->module == NULL);
if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
- if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has incompatible version, not loading",
- plugin->filename);
+ if (GST_CAT_DEFAULT)
+ GST_INFO ("plugin \"%s\" has incompatible version, not loading",
+ plugin->filename);
return FALSE;
}
- if (!desc->license || !desc->description || !desc->package ||
- !desc->origin) {
- if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading",
- plugin->filename);
+ if (!desc->license || !desc->description || !desc->package || !desc->origin) {
+ if (GST_CAT_DEFAULT)
+ GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading",
+ plugin->filename);
return FALSE;
}
-
+
if (!gst_plugin_check_license (desc->license)) {
- if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading",
- plugin->filename, desc->license);
+ if (GST_CAT_DEFAULT)
+ GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading",
+ plugin->filename, desc->license);
return FALSE;
}
-
+
gst_plugin_desc_copy (&plugin->desc, desc);
plugin->module = module;
if (!((desc->plugin_init) (plugin))) {
- if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" failed to initialise", plugin->filename);
+ if (GST_CAT_DEFAULT)
+ GST_INFO ("plugin \"%s\" failed to initialise", plugin->filename);
plugin->module = NULL;
return FALSE;
}
-
- if (GST_CAT_DEFAULT) GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename));
+
+ if (GST_CAT_DEFAULT)
+ GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename));
return plugin;
}
/* We need to restore the fault handler or we'll keep getting it */
_gst_plugin_fault_handler_restore ();
- switch (signum)
- {
+ switch (signum) {
case SIGSEGV:
g_print ("\nERROR: ");
g_print ("Caught a segmentation fault while loading plugin file:\n");
struct sigaction action;
/* if asked to leave segfaults alone, just return */
- if (_gst_disable_segtrap) return;
+ if (_gst_disable_segtrap)
+ return;
- if (_gst_plugin_fault_handler_is_setup) return;
+ if (_gst_plugin_fault_handler_is_setup)
+ return;
memset (&action, 0, sizeof (action));
action.sa_handler = _gst_plugin_fault_handler_sighandler;
sigaction (SIGSEGV, &action, NULL);
}
-static void
-_gst_plugin_fault_handler_setup ();
+static void _gst_plugin_fault_handler_setup ();
/**
* gst_plugin_load_file:
* Returns: a new GstPlugin or NULL, if an error occurred.
*/
GstPlugin *
-gst_plugin_load_file (const gchar *filename, GError **error)
+gst_plugin_load_file (const gchar * filename, GError ** error)
{
GstPlugin *plugin;
GModule *module;
g_return_val_if_fail (filename != NULL, NULL);
- GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", filename);
+ GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"",
+ filename);
if (g_module_supported () == FALSE) {
g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_MODULE,
- "Dynamic loading not supported");
+ GST_PLUGIN_ERROR,
+ GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported");
return NULL;
}
if (stat (filename, &file_status)) {
g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_MODULE,
- "Problem opening file %s\n",
- filename);
+ GST_PLUGIN_ERROR,
+ GST_PLUGIN_ERROR_MODULE, "Problem opening file %s\n", filename);
return NULL;
}
free_plugin = TRUE;
plugin = g_new0 (GstPlugin, 1);
plugin->filename = g_strdup (filename);
- GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, filename);
+ GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin,
+ filename);
} else {
free_plugin = FALSE;
if (gst_plugin_is_loaded (plugin)) {
if (strcmp (plugin->filename, filename) != 0) {
- GST_WARNING ("plugin %p from file \"%s\" with same name %s is already "
- "loaded, aborting loading of \"%s\"",
- plugin, plugin->filename, plugin->desc.name, filename);
- g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_NAME_MISMATCH,
- "already a plugin with name \"%s\" loaded",
- desc->name);
- if (free_plugin) g_free (plugin);
+ GST_WARNING
+ ("plugin %p from file \"%s\" with same name %s is already "
+ "loaded, aborting loading of \"%s\"", plugin, plugin->filename,
+ plugin->desc.name, filename);
+ g_set_error (error, GST_PLUGIN_ERROR,
+ GST_PLUGIN_ERROR_NAME_MISMATCH,
+ "already a plugin with name \"%s\" loaded", desc->name);
+ if (free_plugin)
+ g_free (plugin);
return NULL;
}
- GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", plugin, filename);
+ GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now",
+ plugin, filename);
return plugin;
}
}
- GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", plugin, filename);
+ GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...",
+ plugin, filename);
if (g_module_symbol (module, "plugin_init", &ptr)) {
- g_print ("plugin %p from file \"%s\" exports a symbol named plugin_init\n",
- plugin, plugin->filename);
- g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_NAME_MISMATCH,
- "plugin \"%s\" exports a symbol named plugin_init",
- desc->name);
+ g_print
+ ("plugin %p from file \"%s\" exports a symbol named plugin_init\n",
+ plugin, plugin->filename);
+ g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_NAME_MISMATCH,
+ "plugin \"%s\" exports a symbol named plugin_init", desc->name);
}
/* this is where we load the actual .so, so let's trap SIGSEGV */
_gst_plugin_fault_handler_filename = plugin->filename;
if (gst_plugin_register_func (plugin, module, desc)) {
- /* remove signal handler */
- _gst_plugin_fault_handler_restore ();
- _gst_plugin_fault_handler_filename = NULL;
- GST_INFO ("plugin \"%s\" loaded", plugin->filename);
- return plugin;
+ /* remove signal handler */
+ _gst_plugin_fault_handler_restore ();
+ _gst_plugin_fault_handler_filename = NULL;
+ GST_INFO ("plugin \"%s\" loaded", plugin->filename);
+ return plugin;
} else {
- /* remove signal handler */
- _gst_plugin_fault_handler_restore ();
- GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"", filename);
+ /* remove signal handler */
+ _gst_plugin_fault_handler_restore ();
+ GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"",
+ filename);
/* plugin == NULL */
- g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_MODULE,
- "gst_plugin_register_func failed for plugin \"%s\"",
- filename);
- if (free_plugin) g_free (plugin);
- return NULL;
+ g_set_error (error,
+ GST_PLUGIN_ERROR,
+ GST_PLUGIN_ERROR_MODULE,
+ "gst_plugin_register_func failed for plugin \"%s\"", filename);
+ if (free_plugin)
+ g_free (plugin);
+ return NULL;
}
} else {
GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_MODULE,
- "Could not find plugin entry point in \"%s\"",
- filename);
+ GST_PLUGIN_ERROR,
+ GST_PLUGIN_ERROR_MODULE,
+ "Could not find plugin entry point in \"%s\"", filename);
}
return NULL;
} else {
- GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename, g_module_error());
- g_set_error (error,
- GST_PLUGIN_ERROR,
- GST_PLUGIN_ERROR_MODULE,
- "Error loading plugin %s, reason: %s\n",
- filename, g_module_error());
+ GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename,
+ g_module_error ());
+ g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE,
+ "Error loading plugin %s, reason: %s\n", filename, g_module_error ());
return NULL;
}
}
static void
-gst_plugin_desc_copy (GstPluginDesc *dest, const GstPluginDesc *src)
+gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src)
{
dest->major_version = src->major_version;
dest->minor_version = src->minor_version;
g_free (dest->origin);
dest->origin = g_strdup (src->origin);
}
+
#if 0
/* unused */
static void
-gst_plugin_desc_free (GstPluginDesc *desc)
+gst_plugin_desc_free (GstPluginDesc * desc)
{
g_free (desc->name);
g_free (desc->description);
* Returns: whether or not the plugin unloaded
*/
gboolean
-gst_plugin_unload_plugin (GstPlugin *plugin)
+gst_plugin_unload_plugin (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, FALSE);
- if (!plugin->module)
+ if (!plugin->module)
return TRUE;
if (g_module_close (plugin->module)) {
plugin->module = NULL;
- GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded", plugin->filename);
+ GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded",
+ plugin->filename);
return TRUE;
- }
- else {
- GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"", plugin->filename);
+ } else {
+ GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"",
+ plugin->filename);
return FALSE;
}
}
*
* Returns: the name of the plugin
*/
-const gchar*
-gst_plugin_get_name (GstPlugin *plugin)
+const gchar *
+gst_plugin_get_name (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the long name of the plugin
*/
-G_CONST_RETURN gchar*
-gst_plugin_get_description (GstPlugin *plugin)
+G_CONST_RETURN gchar *
+gst_plugin_get_description (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
*
* Returns: the filename of the plugin
*/
-G_CONST_RETURN gchar*
-gst_plugin_get_filename (GstPlugin *plugin)
+G_CONST_RETURN gchar *
+gst_plugin_get_filename (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
return plugin->filename;
}
+
/**
* gst_plugin_get_license:
* @plugin: plugin to get the license of
*
* Returns: the license of the plugin
*/
-G_CONST_RETURN gchar*
-gst_plugin_get_license (GstPlugin *plugin)
+G_CONST_RETURN gchar *
+gst_plugin_get_license (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
return plugin->desc.license;
}
+
/**
* gst_plugin_get_package:
* @plugin: plugin to get the package of
*
* Returns: the package of the plugin
*/
-G_CONST_RETURN gchar*
-gst_plugin_get_package (GstPlugin *plugin)
+G_CONST_RETURN gchar *
+gst_plugin_get_package (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
return plugin->desc.package;
}
+
/**
* gst_plugin_get_origin:
* @plugin: plugin to get the origin of
*
* Returns: the origin of the plugin
*/
-G_CONST_RETURN gchar*
-gst_plugin_get_origin (GstPlugin *plugin)
+G_CONST_RETURN gchar *
+gst_plugin_get_origin (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
return plugin->desc.origin;
}
+
/**
* gst_plugin_get_module:
* @plugin: plugin to query
* loaded yet.
*/
GModule *
-gst_plugin_get_module (GstPlugin *plugin)
+gst_plugin_get_module (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, FALSE);
return plugin->module;
}
+
/**
* gst_plugin_is_loaded:
* @plugin: plugin to query
* Returns: TRUE is loaded, FALSE otherwise
*/
gboolean
-gst_plugin_is_loaded (GstPlugin *plugin)
+gst_plugin_is_loaded (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, FALSE);
*
* Returns: a GList of features, g_list_free after use.
*/
-GList*
-gst_plugin_feature_filter (GstPlugin *plugin,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data)
+GList *
+gst_plugin_feature_filter (GstPlugin * plugin,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
{
- return gst_filter_run (plugin->features, (GstFilterFunc) filter, first, user_data);
+ return gst_filter_run (plugin->features, (GstFilterFunc) filter, first,
+ user_data);
}
typedef struct
-{
+{
GstPluginFeatureFilter filter;
- gboolean first;
- gpointer user_data;
- GList *result;
+ gboolean first;
+ gpointer user_data;
+ GList *result;
} FeatureFilterData;
static gboolean
-_feature_filter (GstPlugin *plugin, gpointer user_data)
+_feature_filter (GstPlugin * plugin, gpointer user_data)
{
GList *result;
FeatureFilterData *data = (FeatureFilterData *) user_data;
- result = gst_plugin_feature_filter (plugin, data->filter, data->first, data->user_data);
+ result =
+ gst_plugin_feature_filter (plugin, data->filter, data->first,
+ data->user_data);
if (result) {
data->result = g_list_concat (data->result, result);
return TRUE;
*
* Returns: a GList of features, g_list_free after use.
*/
-GList*
-gst_plugin_list_feature_filter (GList *list,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data)
+GList *
+gst_plugin_list_feature_filter (GList * list,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
{
FeatureFilterData data;
GList *result;
* Returns: TRUE if the plugin is of the given name.
*/
gboolean
-gst_plugin_name_filter (GstPlugin *plugin, const gchar *name)
+gst_plugin_name_filter (GstPlugin * plugin, const gchar * name)
{
return (plugin->desc.name && !strcmp (plugin->desc.name, name));
}
*
* Returns: a GstPluginFeature or NULL if the feature was not found.
*/
-GstPluginFeature*
-gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type)
+GstPluginFeature *
+gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type)
{
GList *walk;
GstPluginFeature *result = NULL;
data.type = type;
data.name = name;
-
- walk = gst_filter_run (plugin->features,
- (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE,
- &data);
- if (walk)
+ walk = gst_filter_run (plugin->features,
+ (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, &data);
+
+ if (walk)
result = GST_PLUGIN_FEATURE (walk->data);
return result;
* See #gst_plugin_get_feature_list
*/
void
-gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature)
+gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature)
{
GstPluginFeature *oldfeature;
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
g_return_if_fail (feature != NULL);
- oldfeature = gst_plugin_find_feature (plugin,
- GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature));
+ oldfeature = gst_plugin_find_feature (plugin,
+ GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature));
if (!oldfeature) {
feature->manager = plugin;
*
* Returns: a GList of features, use g_list_free to free the list.
*/
-GList*
-gst_plugin_get_feature_list (GstPlugin *plugin)
+GList *
+gst_plugin_get_feature_list (GstPlugin * plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
* Returns: whether the plugin was loaded or not
*/
gboolean
-gst_plugin_load (const gchar *name)
+gst_plugin_load (const gchar * name)
{
GstPlugin *plugin;
GError *error = NULL;
* Returns: whether the library was loaded or not
*/
gboolean
-gst_library_load (const gchar *name)
+gst_library_load (const gchar * name)
{
gboolean res;
#include <gst/gstpluginfeature.h>
#include <gst/gstmacros.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS GQuark gst_plugin_error_quark (void);
-GQuark gst_plugin_error_quark (void);
#define GST_PLUGIN_ERROR gst_plugin_error_quark ()
typedef enum
#define GST_PLUGIN(plugin) ((GstPlugin *) (plugin))
-typedef struct _GstPlugin GstPlugin;
-typedef struct _GstPluginDesc GstPluginDesc;
+typedef struct _GstPlugin GstPlugin;
+typedef struct _GstPluginDesc GstPluginDesc;
/* Initialiser function: returns TRUE if plugin initialised successfully */
-typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
+typedef gboolean (*GstPluginInitFunc) (GstPlugin * plugin);
+
/* exiting function when plugin is unloaded */
-typedef void (*GstPluginExitFunc) (GstPlugin *plugin);
+typedef void (*GstPluginExitFunc) (GstPlugin * plugin);
-struct _GstPluginDesc {
- gint major_version; /* major version of core that plugin was compiled for */
- gint minor_version; /* minor version of core that plugin was compiled for */
- gchar *name; /* unique name of plugin */
- gchar *description; /* description of plugin */
+struct _GstPluginDesc
+{
+ gint major_version; /* major version of core that plugin was compiled for */
+ gint minor_version; /* minor version of core that plugin was compiled for */
+ gchar *name; /* unique name of plugin */
+ gchar *description; /* description of plugin */
GstPluginInitFunc plugin_init; /* pointer to plugin_init function */
GstPluginExitFunc plugin_exit; /* pointer to exiting function */
- gchar *version; /* version of the plugin */
- gchar *license; /* effective license of plugin */
- gchar *package; /* package plugin belongs to */
- gchar *origin; /* URL to provider of plugin */
-
+ gchar *version; /* version of the plugin */
+ gchar *license; /* effective license of plugin */
+ gchar *package; /* package plugin belongs to */
+ gchar *origin; /* URL to provider of plugin */
+
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstPlugin {
- GstPluginDesc desc;
+struct _GstPlugin
+{
+ GstPluginDesc desc;
- gchar * filename;
- GList * features; /* list of features provided */
- gint numfeatures;
+ gchar *filename;
+ GList *features; /* list of features provided */
+ gint numfeatures;
- gpointer manager; /* managing registry */
- GModule * module; /* contains the module if the plugin is loaded */
+ gpointer manager; /* managing registry */
+ GModule *module; /* contains the module if the plugin is loaded */
gpointer _gst_reserved[GST_PADDING];
};
GST_PADDING_INIT \
}; \
_gst_plugin_register_static (&plugin_desc_); \
-}
+}
#define GST_LICENSE_UNKNOWN "unknown"
/* function for filters */
-typedef gboolean (*GstPluginFilter) (GstPlugin *plugin,
- gpointer user_data);
+typedef gboolean (*GstPluginFilter) (GstPlugin * plugin, gpointer user_data);
#define GST_TYPE_PLUGIN (gst_plugin_get_type())
-GType gst_plugin_get_type (void);
-void _gst_plugin_initialize (void);
-void _gst_plugin_register_static (GstPluginDesc *desc);
-
-G_CONST_RETURN gchar* gst_plugin_get_name (GstPlugin *plugin);
-G_CONST_RETURN gchar* gst_plugin_get_description (GstPlugin *plugin);
-G_CONST_RETURN gchar* gst_plugin_get_filename (GstPlugin *plugin);
-G_CONST_RETURN gchar* gst_plugin_get_license (GstPlugin *plugin);
-G_CONST_RETURN gchar* gst_plugin_get_package (GstPlugin *plugin);
-G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin);
-GModule * gst_plugin_get_module (GstPlugin *plugin);
-gboolean gst_plugin_is_loaded (GstPlugin *plugin);
-
-GList* gst_plugin_feature_filter (GstPlugin *plugin,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data);
-GList* gst_plugin_list_feature_filter (GList *list,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data);
-gboolean gst_plugin_name_filter (GstPlugin *plugin, const gchar *name);
-
-GList* gst_plugin_get_feature_list (GstPlugin *plugin);
-GstPluginFeature* gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type);
-
-GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error);
-gboolean gst_plugin_unload_plugin (GstPlugin *plugin);
-
-void gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature);
+GType gst_plugin_get_type (void);
+void _gst_plugin_initialize (void);
+void _gst_plugin_register_static (GstPluginDesc * desc);
+
+G_CONST_RETURN gchar *gst_plugin_get_name (GstPlugin * plugin);
+G_CONST_RETURN gchar *gst_plugin_get_description (GstPlugin * plugin);
+G_CONST_RETURN gchar *gst_plugin_get_filename (GstPlugin * plugin);
+G_CONST_RETURN gchar *gst_plugin_get_license (GstPlugin * plugin);
+G_CONST_RETURN gchar *gst_plugin_get_package (GstPlugin * plugin);
+G_CONST_RETURN gchar *gst_plugin_get_origin (GstPlugin * plugin);
+GModule *gst_plugin_get_module (GstPlugin * plugin);
+gboolean gst_plugin_is_loaded (GstPlugin * plugin);
+
+GList *gst_plugin_feature_filter (GstPlugin * plugin,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data);
+GList *gst_plugin_list_feature_filter (GList * list,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data);
+gboolean gst_plugin_name_filter (GstPlugin * plugin, const gchar * name);
+
+GList *gst_plugin_get_feature_list (GstPlugin * plugin);
+GstPluginFeature *gst_plugin_find_feature (GstPlugin * plugin,
+ const gchar * name, GType type);
+
+GstPlugin *gst_plugin_load_file (const gchar * filename, GError ** error);
+gboolean gst_plugin_unload_plugin (GstPlugin * plugin);
+
+void gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature);
/* shortcuts to load from the registry pool */
-gboolean gst_plugin_load (const gchar *name);
-gboolean gst_library_load (const gchar *name);
+gboolean gst_plugin_load (const gchar * name);
+gboolean gst_library_load (const gchar * name);
G_END_DECLS
-
#endif /* __GST_PLUGIN_H__ */
#include <string.h>
-static void gst_plugin_feature_class_init (GstPluginFeatureClass *klass);
-static void gst_plugin_feature_init (GstPluginFeature *feature);
+static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
+static void gst_plugin_feature_init (GstPluginFeature * feature);
static GObjectClass *parent_class = NULL;
+
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
GType
(GInstanceInitFunc) gst_plugin_feature_init,
NULL
};
- plugin_feature_type = g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature",
- &plugin_feature_info, G_TYPE_FLAG_ABSTRACT);
+ plugin_feature_type =
+ g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature",
+ &plugin_feature_info, G_TYPE_FLAG_ABSTRACT);
}
return plugin_feature_type;
}
static void
-gst_plugin_feature_class_init (GstPluginFeatureClass *klass)
+gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
}
static void
-gst_plugin_feature_init (GstPluginFeature *feature)
+gst_plugin_feature_init (GstPluginFeature * feature)
{
feature->manager = NULL;
}
* Returns: a boolean indicating the feature is loaded.
*/
gboolean
-gst_plugin_feature_ensure_loaded (GstPluginFeature *feature)
+gst_plugin_feature_ensure_loaded (GstPluginFeature * feature)
{
GstPlugin *plugin;
-
+
g_return_val_if_fail (feature != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
plugin = (GstPlugin *) (feature->manager);
if (plugin && !gst_plugin_is_loaded (plugin)) {
-#ifndef GST_DISABLE_REGISTRY
+#ifndef GST_DISABLE_REGISTRY
if (GST_IS_REGISTRY (plugin->manager)) {
- GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING,
- "loading plugin %s for feature", plugin->desc.name);
+ GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING,
+ "loading plugin %s for feature", plugin->desc.name);
- if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), plugin) != GST_REGISTRY_OK)
+ if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager),
+ plugin) != GST_REGISTRY_OK)
return FALSE;
- }
- else
+ } else
#endif /* GST_DISABLE_REGISTRY */
return FALSE;
}
* in the plugin and will eventually unload the plugin
*/
void
-gst_plugin_feature_unload_thyself (GstPluginFeature *feature)
+gst_plugin_feature_unload_thyself (GstPluginFeature * feature)
{
- GstPluginFeatureClass *oclass;
+ GstPluginFeatureClass *oclass;
g_return_if_fail (feature != NULL);
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
-
+
oclass = GST_PLUGIN_FEATURE_GET_CLASS (feature);
if (oclass->unload_thyself)
}
gboolean
-gst_plugin_feature_type_name_filter (GstPluginFeature *feature,
- GstTypeNameData *data)
+gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
+ GstTypeNameData * data)
{
- return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
- (data->name == NULL || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
+ return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
+ (data->name == NULL
+ || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
}
+
/**
* gst_plugin_feature_set_rank:
* @feature: feature to rank
* the most appropriate feature.
*/
void
-gst_plugin_feature_set_rank (GstPluginFeature *feature, guint rank)
+gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
{
g_return_if_fail (feature != NULL);
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
feature->rank = rank;
}
+
/**
* gst_plugin_feature_set_name:
* @feature: a feature
* allowed.
*/
void
-gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name)
+gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
{
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
g_return_if_fail (name != NULL);
feature->name = g_strdup (name);
}
}
+
/**
* gst_plugin_feature_get rank:
* @feature: a feature
* Returns: The rank of the feature
*/
guint
-gst_plugin_feature_get_rank (GstPluginFeature *feature)
+gst_plugin_feature_get_rank (GstPluginFeature * feature)
{
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
-
+
return feature->rank;
}
+
/**
* gst_plugin_feature_get_name:
* @feature: a feature
* Returns: the name
*/
G_CONST_RETURN gchar *
-gst_plugin_feature_get_name (GstPluginFeature *feature)
+gst_plugin_feature_get_name (GstPluginFeature * feature)
{
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
-
+
return feature->name;
}
-
#include <gst/gsttypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PLUGIN_FEATURE (gst_plugin_feature_get_type())
#define GST_PLUGIN_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN_FEATURE, GstPluginFeature))
#define GST_IS_PLUGIN_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN_FEATURE))
#define GST_PLUGIN_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN_FEATURE, GstPluginFeatureClass))
#define GST_IS_PLUGIN_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN_FEATURE))
#define GST_PLUGIN_FEATURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN_FEATURE, GstPluginFeatureClass))
-
#define GST_PLUGIN_FEATURE_NAME(feature) (GST_PLUGIN_FEATURE (feature)->name)
-
typedef struct _GstPluginFeature GstPluginFeature;
typedef struct _GstPluginFeatureClass GstPluginFeatureClass;
-struct _GstPluginFeature {
- GObject object;
+struct _GstPluginFeature
+{
+ GObject object;
- /*< private >*/
- gchar *name;
- guint rank;
+ /*< private > */
+ gchar *name;
+ guint rank;
- gpointer manager;
+ gpointer manager;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstPluginFeatureClass {
- GObjectClass parent_class;
+struct _GstPluginFeatureClass
+{
+ GObjectClass parent_class;
- void (*unload_thyself) (GstPluginFeature *feature);
+ void (*unload_thyself) (GstPluginFeature * feature);
gpointer _gst_reserved[GST_PADDING];
};
-typedef struct {
- const gchar *name;
- GType type;
+typedef struct
+{
+ const gchar *name;
+ GType type;
} GstTypeNameData;
/* filter */
-typedef gboolean (*GstPluginFeatureFilter) (GstPluginFeature *feature,
- gpointer user_data);
+typedef gboolean (*GstPluginFeatureFilter) (GstPluginFeature * feature,
+ gpointer user_data);
/* normal GObject stuff */
-GType gst_plugin_feature_get_type (void);
+GType gst_plugin_feature_get_type (void);
-gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature);
-void gst_plugin_feature_unload_thyself (GstPluginFeature *feature);
+gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature * feature);
+void gst_plugin_feature_unload_thyself (GstPluginFeature * feature);
-gboolean gst_plugin_feature_type_name_filter (GstPluginFeature *feature,
- GstTypeNameData *data);
+gboolean gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
+ GstTypeNameData * data);
-void gst_plugin_feature_set_rank (GstPluginFeature *feature, guint rank);
-void gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name);
-guint gst_plugin_feature_get_rank (GstPluginFeature *feature);
-G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature *feature);
+void gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank);
+void gst_plugin_feature_set_name (GstPluginFeature * feature,
+ const gchar * name);
+guint gst_plugin_feature_get_rank (GstPluginFeature * feature);
+G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature * feature);
G_END_DECLS
-
-
#endif /* __GST_PLUGIN_FEATURE_H__ */
-
*
* Returns: a new #GstProbe.
*/
-GstProbe*
-gst_probe_new (gboolean single_shot,
- GstProbeCallback callback,
- gpointer user_data)
+GstProbe *
+gst_probe_new (gboolean single_shot,
+ GstProbeCallback callback, gpointer user_data)
{
GstProbe *probe;
probe = g_new0 (GstProbe, 1);
probe->single_shot = single_shot;
- probe->callback = callback;
- probe->user_data = user_data;
-
+ probe->callback = callback;
+ probe->user_data = user_data;
+
return probe;
}
* Free the memeory associated with the probe.
*/
void
-gst_probe_destroy (GstProbe *probe)
+gst_probe_destroy (GstProbe * probe)
{
g_return_if_fail (probe);
#ifdef USE_POISONING
- memset(probe, 0xff, sizeof(*probe));
+ memset (probe, 0xff, sizeof (*probe));
#endif
g_free (probe);
* Returns: the result of the probe callback function.
*/
gboolean
-gst_probe_perform (GstProbe *probe, GstData **data)
+gst_probe_perform (GstProbe * probe, GstData ** data)
{
gboolean res = TRUE;
g_return_val_if_fail (probe, res);
-
+
if (probe->callback)
res = probe->callback (probe, data, probe->user_data);
-
+
return res;
}
*
* Returns: a new probe dispatcher.
*/
-GstProbeDispatcher*
+GstProbeDispatcher *
gst_probe_dispatcher_new (void)
{
GstProbeDispatcher *disp;
-
+
disp = g_new0 (GstProbeDispatcher, 1);
gst_probe_dispatcher_init (disp);
-
+
return disp;
}
* Free the memory allocated by the probe dispatcher. All pending
* probes are removed first.
*/
-void
-gst_probe_dispatcher_destroy (GstProbeDispatcher *disp)
+void
+gst_probe_dispatcher_destroy (GstProbeDispatcher * disp)
{
g_return_if_fail (disp);
-
+
#ifdef USE_POISONING
- memset(disp, 0xff, sizeof(*disp));
+ memset (disp, 0xff, sizeof (*disp));
#endif
/* FIXME, free pending probes */
* dispatchers.
*/
void
-gst_probe_dispatcher_init (GstProbeDispatcher *disp)
+gst_probe_dispatcher_init (GstProbeDispatcher * disp)
{
g_return_if_fail (disp);
* Activate or deactivate the given dispatcher
* dispatchers.
*/
-void
-gst_probe_dispatcher_set_active (GstProbeDispatcher *disp, gboolean active)
+void
+gst_probe_dispatcher_set_active (GstProbeDispatcher * disp, gboolean active)
{
g_return_if_fail (disp);
* Adds the given probe to the dispatcher.
*/
void
-gst_probe_dispatcher_add_probe (GstProbeDispatcher *disp, GstProbe *probe)
+gst_probe_dispatcher_add_probe (GstProbeDispatcher * disp, GstProbe * probe)
{
g_return_if_fail (disp);
g_return_if_fail (probe);
-
+
disp->probes = g_slist_prepend (disp->probes, probe);
}
* Removes the given probe from the dispatcher.
*/
void
-gst_probe_dispatcher_remove_probe (GstProbeDispatcher *disp, GstProbe *probe)
+gst_probe_dispatcher_remove_probe (GstProbeDispatcher * disp, GstProbe * probe)
{
g_return_if_fail (disp);
g_return_if_fail (probe);
-
+
disp->probes = g_slist_remove (disp->probes, probe);
}
*
* Returns: TRUE if all callbacks returned TRUE.
*/
-gboolean
-gst_probe_dispatcher_dispatch (GstProbeDispatcher *disp, GstData **data)
+gboolean
+gst_probe_dispatcher_dispatch (GstProbeDispatcher * disp, GstData ** data)
{
GSList *walk;
gboolean res = TRUE;
walk = disp->probes;
while (walk) {
GstProbe *probe = (GstProbe *) walk->data;
+
walk = g_slist_next (walk);
res &= gst_probe_perform (probe, data);
#include <glib.h>
#include <gst/gstdata.h>
-G_BEGIN_DECLS
-
-typedef struct _GstProbe GstProbe;
+G_BEGIN_DECLS typedef struct _GstProbe GstProbe;
/* the callback should return FALSE if the data should be discarded */
-typedef gboolean (*GstProbeCallback) (GstProbe *probe,
- GstData **data,
- gpointer user_data);
-
-struct _GstProbe {
- gboolean single_shot;
-
- GstProbeCallback callback;
- gpointer user_data;
+typedef gboolean (*GstProbeCallback) (GstProbe * probe,
+ GstData ** data, gpointer user_data);
+
+struct _GstProbe
+{
+ gboolean single_shot;
+
+ GstProbeCallback callback;
+ gpointer user_data;
};
-GstProbe* gst_probe_new (gboolean single_shot,
- GstProbeCallback callback,
- gpointer user_data);
-void gst_probe_destroy (GstProbe *probe);
+GstProbe *gst_probe_new (gboolean single_shot,
+ GstProbeCallback callback, gpointer user_data);
+void gst_probe_destroy (GstProbe * probe);
-gboolean gst_probe_perform (GstProbe *probe, GstData **data);
+gboolean gst_probe_perform (GstProbe * probe, GstData ** data);
typedef struct _GstProbeDispatcher GstProbeDispatcher;
-struct _GstProbeDispatcher {
- gboolean active;
-
- GSList *probes;
+struct _GstProbeDispatcher
+{
+ gboolean active;
+
+ GSList *probes;
};
-GstProbeDispatcher* gst_probe_dispatcher_new (void);
-void gst_probe_dispatcher_destroy (GstProbeDispatcher *disp);
-void gst_probe_dispatcher_init (GstProbeDispatcher *disp);
+GstProbeDispatcher *gst_probe_dispatcher_new (void);
+void gst_probe_dispatcher_destroy (GstProbeDispatcher * disp);
+void gst_probe_dispatcher_init (GstProbeDispatcher * disp);
-void gst_probe_dispatcher_set_active (GstProbeDispatcher *disp, gboolean active);
-void gst_probe_dispatcher_add_probe (GstProbeDispatcher *disp, GstProbe *probe);
-void gst_probe_dispatcher_remove_probe (GstProbeDispatcher *disp, GstProbe *probe);
+void gst_probe_dispatcher_set_active (GstProbeDispatcher * disp,
+ gboolean active);
+void gst_probe_dispatcher_add_probe (GstProbeDispatcher * disp,
+ GstProbe * probe);
+void gst_probe_dispatcher_remove_probe (GstProbeDispatcher * disp,
+ GstProbe * probe);
-gboolean gst_probe_dispatcher_dispatch (GstProbeDispatcher *disp, GstData **data);
+gboolean gst_probe_dispatcher_dispatch (GstProbeDispatcher * disp,
+ GstData ** data);
G_END_DECLS
-
-
#endif /* __GST_PAD_H__ */
-
static GList *_gst_queries = NULL;
static GHashTable *_nick_to_query = NULL;
static GHashTable *_query_type_to_nick = NULL;
-static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */
+static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */
static GstQueryTypeDefinition standard_definitions[] = {
- { GST_QUERY_TOTAL, "total", "Total length" },
- { GST_QUERY_POSITION, "position", "Current Position" },
- { GST_QUERY_LATENCY, "latency", "Latency" },
- { GST_QUERY_JITTER, "jitter", "Jitter" },
- { GST_QUERY_START, "start", "Start position of stream" },
- { GST_QUERY_SEGMENT_END, "segment_end", "End position of the stream" },
- { GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1" },
- { 0, NULL, NULL }
+ {GST_QUERY_TOTAL, "total", "Total length"},
+ {GST_QUERY_POSITION, "position", "Current Position"},
+ {GST_QUERY_LATENCY, "latency", "Latency"},
+ {GST_QUERY_JITTER, "jitter", "Jitter"},
+ {GST_QUERY_START, "start", "Start position of stream"},
+ {GST_QUERY_SEGMENT_END, "segment_end", "End position of the stream"},
+ {GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1"},
+ {0, NULL, NULL}
};
-void
+void
_gst_query_type_initialize (void)
{
GstQueryTypeDefinition *standards = standard_definitions;
_nick_to_query = g_hash_table_new (g_str_hash, g_str_equal);
_query_type_to_nick = g_hash_table_new (NULL, NULL);
}
-
+
while (standards->nick) {
g_hash_table_insert (_nick_to_query, standards->nick, standards);
- g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (standards->value), standards);
+ g_hash_table_insert (_query_type_to_nick,
+ GINT_TO_POINTER (standards->value), standards);
_gst_queries = g_list_append (_gst_queries, standards);
standards++;
* with the same nick.
*/
GstQueryType
-gst_query_type_register (const gchar *nick, const gchar *description)
+gst_query_type_register (const gchar * nick, const gchar * description)
{
GstQueryTypeDefinition *query;
GstQueryType lookup;
-
+
g_return_val_if_fail (nick != NULL, 0);
g_return_val_if_fail (description != NULL, 0);
lookup = gst_query_type_get_by_nick (nick);
if (lookup != GST_QUERY_NONE)
return lookup;
-
+
query = g_new0 (GstQueryTypeDefinition, 1);
query->value = _n_values;
query->nick = g_strdup (nick);
query->description = g_strdup (description);
g_hash_table_insert (_nick_to_query, query->nick, query);
- g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value), query);
+ g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value),
+ query);
_gst_queries = g_list_append (_gst_queries, query);
_n_values++;
-
+
return query->value;
}
* if the query was not registered.
*/
GstQueryType
-gst_query_type_get_by_nick (const gchar *nick)
+gst_query_type_get_by_nick (const gchar * nick)
{
GstQueryTypeDefinition *query;
-
+
g_return_val_if_fail (nick != NULL, 0);
query = g_hash_table_lookup (_nick_to_query, nick);
-
+
if (query != NULL)
return query->value;
else
* Returns: TRUE if the query is found inside the array
*/
gboolean
-gst_query_types_contains (const GstQueryType *types, GstQueryType type)
+gst_query_types_contains (const GstQueryType * types, GstQueryType type)
{
if (!types)
return FALSE;
*
* Returns: The #GstQueryTypeDefinition for @query or NULL on failure.
*/
-const GstQueryTypeDefinition*
+const GstQueryTypeDefinition *
gst_query_type_get_details (GstQueryType type)
{
return g_hash_table_lookup (_query_type_to_nick, GINT_TO_POINTER (type));
*
* Returns: A GList of #GstQueryTypeDefinition.
*/
-const GList*
+const GList *
gst_query_type_get_definitions (void)
{
return _gst_queries;
#include <glib.h>
-G_BEGIN_DECLS
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
GST_QUERY_NONE = 0,
GST_QUERY_TOTAL,
GST_QUERY_POSITION,
struct _GstQueryTypeDefinition
{
- GstQueryType value;
- gchar *nick;
- gchar *description;
+ GstQueryType value;
+ gchar *nick;
+ gchar *description;
};
#ifdef G_HAVE_ISO_VARARGS
}
#endif
-void _gst_query_type_initialize (void);
+void _gst_query_type_initialize (void);
/* register a new query */
-GstQueryType gst_query_type_register (const gchar *nick,
- const gchar *description);
-GstQueryType gst_query_type_get_by_nick (const gchar *nick);
+GstQueryType gst_query_type_register (const gchar * nick,
+ const gchar * description);
+GstQueryType gst_query_type_get_by_nick (const gchar * nick);
/* check if a query is in an array of querys */
-gboolean gst_query_types_contains (const GstQueryType *types, GstQueryType type);
+gboolean gst_query_types_contains (const GstQueryType * types,
+ GstQueryType type);
/* query for query details */
-G_CONST_RETURN GstQueryTypeDefinition*
- gst_query_type_get_details (GstQueryType type);
-G_CONST_RETURN GList* gst_query_type_get_definitions (void);
+G_CONST_RETURN GstQueryTypeDefinition *gst_query_type_get_details (GstQueryType
+ type);
+G_CONST_RETURN GList *gst_query_type_get_definitions (void);
G_END_DECLS
-
#endif /* __GST_QUERY_H__ */
-
#include "gstinfo.h"
#include "gsterror.h"
-static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS (
- "Queue",
- "Generic",
- "Simple data queue",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue",
+ "Generic",
+ "Simple data queue",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Queue signals and args */
-enum {
+enum
+{
SIGNAL_UNDERRUN,
SIGNAL_RUNNING,
SIGNAL_OVERRUN,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FIXME: don't we have another way of doing this
* "Gstreamer format" (frame/byte/time) queries? */
ARG_LEAKY,
ARG_MAY_DEADLOCK,
ARG_BLOCK_TIMEOUT
- /* FILL ME */
+ /* FILL ME */
};
-typedef struct _GstQueueEventResponse {
+typedef struct _GstQueueEventResponse
+{
GstEvent *event;
gboolean ret, handled;
} GstQueueEventResponse;
-static void gst_queue_base_init (GstQueueClass *klass);
-static void gst_queue_class_init (GstQueueClass *klass);
-static void gst_queue_init (GstQueue *queue);
-static void gst_queue_dispose (GObject *object);
-
-static void gst_queue_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_queue_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gst_queue_chain (GstPad *pad,
- GstData *data);
-static GstData *gst_queue_get (GstPad *pad);
-
-static gboolean gst_queue_handle_src_event (GstPad *pad,
- GstEvent *event);
-
-static GstCaps *gst_queue_getcaps (GstPad *pad);
-static GstPadLinkReturn
- gst_queue_link (GstPad *pad,
- const GstCaps *caps);
-static void gst_queue_locked_flush (GstQueue *queue);
+static void gst_queue_base_init (GstQueueClass * klass);
+static void gst_queue_class_init (GstQueueClass * klass);
+static void gst_queue_init (GstQueue * queue);
+static void gst_queue_dispose (GObject * object);
+
+static void gst_queue_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_queue_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static void gst_queue_chain (GstPad * pad, GstData * data);
+static GstData *gst_queue_get (GstPad * pad);
+
+static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
+
+static GstCaps *gst_queue_getcaps (GstPad * pad);
+static GstPadLinkReturn gst_queue_link (GstPad * pad, const GstCaps * caps);
+static void gst_queue_locked_flush (GstQueue * queue);
+
+static GstElementStateReturn gst_queue_change_state (GstElement * element);
+static gboolean gst_queue_release_locks (GstElement * element);
-static GstElementStateReturn
- gst_queue_change_state (GstElement *element);
-static gboolean gst_queue_release_locks (GstElement *element);
-
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
static GType
{
static GType queue_leaky_type = 0;
static GEnumValue queue_leaky[] = {
- { GST_QUEUE_NO_LEAK, "0", "Not Leaky" },
- { GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream" },
- { GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream" },
- { 0, NULL, NULL },
+ {GST_QUEUE_NO_LEAK, "0", "Not Leaky"},
+ {GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream"},
+ {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"},
+ {0, NULL, NULL},
};
if (!queue_leaky_type) {
- queue_leaky_type = g_enum_register_static("GstQueueLeaky", queue_leaky);
+ queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
}
return queue_leaky_type;
}
static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
GType
-gst_queue_get_type (void)
+gst_queue_get_type (void)
{
static GType queue_type = 0;
};
queue_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstQueue", &queue_info, 0);
+ "GstQueue", &queue_info, 0);
}
return queue_type;
}
static void
-gst_queue_base_init (GstQueueClass *klass)
+gst_queue_base_init (GstQueueClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_queue_class_init (GstQueueClass *klass)
+gst_queue_class_init (GstQueueClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
/* signals */
gst_queue_signals[SIGNAL_UNDERRUN] =
- g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_queue_signals[SIGNAL_RUNNING] =
- g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_queue_signals[SIGNAL_OVERRUN] =
- g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/* properties */
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES,
- g_param_spec_uint ("current-level-bytes", "Current level (kB)",
- "Current amount of data in the queue (bytes)",
- 0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_param_spec_uint ("current-level-bytes", "Current level (kB)",
+ "Current amount of data in the queue (bytes)",
+ 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS,
- g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
- "Current number of buffers in the queue",
- 0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
+ "Current number of buffers in the queue",
+ 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME,
- g_param_spec_uint64 ("current-level-time", "Current level (ns)",
- "Current amount of data in the queue (in ns)",
- 0, G_MAXUINT64, 0, G_PARAM_READABLE));
+ g_param_spec_uint64 ("current-level-time", "Current level (ns)",
+ "Current amount of data in the queue (in ns)",
+ 0, G_MAXUINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES,
- g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
- "Max. amount of data in the queue (bytes, 0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
+ "Max. amount of data in the queue (bytes, 0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS,
- g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
- "Max. number of buffers in the queue (0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
+ "Max. number of buffers in the queue (0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME,
- g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
- "Max. amount of data in the queue (in ns, 0=disable)",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
+ "Max. amount of data in the queue (in ns, 0=disable)",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES,
- g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
- "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
+ "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS,
- g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
- "Min. number of buffers in the queue to allow reading (0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
+ "Min. number of buffers in the queue to allow reading (0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME,
- g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
- "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
+ "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_LEAKY,
- g_param_spec_enum ("leaky", "Leaky",
- "Where the queue leaks, if at all",
- GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
+ g_param_spec_enum ("leaky", "Leaky",
+ "Where the queue leaks, if at all",
+ GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK,
- g_param_spec_boolean ("may_deadlock", "May Deadlock",
- "The queue may deadlock if it's full and not PLAYING",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("may_deadlock", "May Deadlock",
+ "The queue may deadlock if it's full and not PLAYING",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT,
- g_param_spec_uint64 ("block_timeout", "Timeout for Block",
- "Nanoseconds until blocked queue times out and returns filler event. "
- "Value of -1 disables timeout",
- 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("block_timeout", "Timeout for Block",
+ "Nanoseconds until blocked queue times out and returns filler event. "
+ "Value of -1 disables timeout",
+ 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
/* set several parent class virtual functions */
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state);
gstelement_class->release_locks = GST_DEBUG_FUNCPTR (gst_queue_release_locks);
}
static void
-gst_queue_init (GstQueue *queue)
+gst_queue_init (GstQueue * queue)
{
/* scheduling on this kind of element is, well, interesting */
GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED);
GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE);
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
- gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain));
+ gst_pad_set_chain_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_chain));
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
- gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link));
- gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
+ gst_pad_set_link_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_link));
+ gst_pad_set_getcaps_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_getcaps));
gst_pad_set_active (queue->sinkpad, TRUE);
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_get));
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link));
- gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
- gst_pad_set_event_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
+ gst_pad_set_getcaps_function (queue->srcpad,
+ GST_DEBUG_FUNCPTR (gst_queue_getcaps));
+ gst_pad_set_event_function (queue->srcpad,
+ GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
gst_pad_set_active (queue->srcpad, TRUE);
- queue->cur_level.buffers = 0; /* no content */
- queue->cur_level.bytes = 0; /* no content */
- queue->cur_level.time = 0; /* no content */
- queue->max_size.buffers = 100; /* 100 buffers */
- queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
- queue->max_size.time = GST_SECOND; /* 1 s. */
- queue->min_threshold.buffers = 0; /* no threshold */
- queue->min_threshold.bytes = 0; /* no threshold */
- queue->min_threshold.time = 0; /* no threshold */
+ queue->cur_level.buffers = 0; /* no content */
+ queue->cur_level.bytes = 0; /* no content */
+ queue->cur_level.time = 0; /* no content */
+ queue->max_size.buffers = 100; /* 100 buffers */
+ queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
+ queue->max_size.time = GST_SECOND; /* 1 s. */
+ queue->min_threshold.buffers = 0; /* no threshold */
+ queue->min_threshold.bytes = 0; /* no threshold */
+ queue->min_threshold.time = 0; /* no threshold */
queue->leaky = GST_QUEUE_NO_LEAK;
queue->may_deadlock = TRUE;
queue->queue = g_queue_new ();
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue,
- "initialized queue's not_empty & not_full conditions");
+ "initialized queue's not_empty & not_full conditions");
}
static void
-gst_queue_dispose (GObject *object)
+gst_queue_dispose (GObject * object)
{
GstQueue *queue = GST_QUEUE (object);
while (!g_queue_is_empty (queue->queue)) {
GstData *data = g_queue_pop_head (queue->queue);
+
gst_data_unref (data);
}
g_queue_free (queue->queue);
g_cond_free (queue->event_done);
while (!g_queue_is_empty (queue->events)) {
GstEvent *event = g_queue_pop_head (queue->events);
+
gst_event_unref (event);
}
}
static GstCaps *
-gst_queue_getcaps (GstPad *pad)
+gst_queue_getcaps (GstPad * pad)
{
GstQueue *queue;
}
static GstPadLinkReturn
-gst_queue_link (GstPad *pad, const GstCaps *caps)
+gst_queue_link (GstPad * pad, const GstCaps * caps)
{
GstQueue *queue;
GstPadLinkReturn link_ret;
}
static void
-gst_queue_locked_flush (GstQueue *queue)
+gst_queue_locked_flush (GstQueue * queue)
{
while (!g_queue_is_empty (queue->queue)) {
GstData *data = g_queue_pop_head (queue->queue);
+
/* First loose the reference we added when putting that data in the queue */
gst_data_unref (data);
/* Then loose another reference because we are supposed to destroy that
}
static void
-gst_queue_handle_pending_events (GstQueue *queue)
+gst_queue_handle_pending_events (GstQueue * queue)
{
/* check for events to send upstream */
- while (!g_queue_is_empty (queue->events)){
+ while (!g_queue_is_empty (queue->events)) {
GstQueueEventResponse *er = g_queue_pop_head (queue->events);
+
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "sending event upstream");
er->ret = gst_pad_event_default (queue->srcpad, er->event);
er->handled = TRUE;
queue->queue->length)
static void
-gst_queue_chain (GstPad *pad,
- GstData *data)
+gst_queue_chain (GstPad * pad, GstData * data)
{
GstQueue *queue;
g_return_if_fail (data != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
-
+
restart:
/* we have to lock the queue since we span threads */
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", g_thread_self ());
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p",
+ g_thread_self ());
g_mutex_lock (queue->qlock);
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ());
/* assume don't need to flush this buffer when the queue is filled */
queue->flush = FALSE;
-
+
if (GST_IS_EVENT (data)) {
switch (GST_EVENT_TYPE (data)) {
case GST_EVENT_FLUSH:
- STATUS (queue, "received flush event");
- gst_queue_locked_flush (queue);
- STATUS (queue, "after flush");
+ STATUS (queue, "received flush event");
+ gst_queue_locked_flush (queue);
+ STATUS (queue, "after flush");
break;
case GST_EVENT_EOS:
STATUS (queue, "received EOS");
break;
default:
/* we put the event in the queue, we don't have to act ourselves */
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding event %p of type %d",
- data, GST_EVENT_TYPE (data));
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding event %p of type %d", data, GST_EVENT_TYPE (data));
break;
}
}
-
+
if (GST_IS_BUFFER (data))
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding buffer %p of size %d",
- data, GST_BUFFER_SIZE (data));
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
/* We make space available if we're "full" according to whatever
* the user defined as "full". Note that this only applies to buffers.
* We always handle events and they don't count in our statistics. */
if (GST_IS_BUFFER (data) &&
((queue->max_size.buffers > 0 &&
- queue->cur_level.buffers >= queue->max_size.buffers) ||
- (queue->max_size.bytes > 0 &&
- queue->cur_level.bytes >= queue->max_size.bytes) ||
- (queue->max_size.time > 0 &&
- queue->cur_level.time >= queue->max_size.time))) {
+ queue->cur_level.buffers >= queue->max_size.buffers) ||
+ (queue->max_size.bytes > 0 &&
+ queue->cur_level.bytes >= queue->max_size.bytes) ||
+ (queue->max_size.time > 0 &&
+ queue->cur_level.time >= queue->max_size.time))) {
g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
g_mutex_lock (queue->qlock);
/* how are we going to make space for this buffer? */
switch (queue->leaky) {
- /* leak current buffer */
+ /* leak current buffer */
case GST_QUEUE_LEAK_UPSTREAM:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue is full, leaking buffer on upstream end");
- /* now we can clean up and exit right away */
- g_mutex_unlock (queue->qlock);
- goto out_unref;
-
- /* leak first buffer in the queue */
- case GST_QUEUE_LEAK_DOWNSTREAM: {
- /* this is a bit hacky. We'll manually iterate the list
- * and find the first buffer from the head on. We'll
- * unref that and "fix up" the GQueue object... */
- GList *item;
- GstData *leak = NULL;
-
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue is full, leaking buffer on downstream end");
-
- for (item = queue->queue->head; item != NULL; item = item->next) {
- if (GST_IS_BUFFER (item->data)) {
- leak = item->data;
- break;
- }
- }
-
- /* if we didn't find anything, it means we have no buffers
- * in here. That cannot happen, since we had >= 1 bufs */
- g_assert (leak);
-
- /* Now remove it from the list, fixing up the GQueue
- * CHECKME: is a queue->head the first or the last item? */
- item = g_list_delete_link (queue->queue->head, item);
- queue->queue->head = g_list_first (item);
- queue->queue->tail = g_list_last (item);
- queue->queue->length--;
-
- /* and unref the data at the end. Twice, because we keep a ref
- * to make things read-only. Also keep our list uptodate. */
- queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
- queue->cur_level.buffers --;
- if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
- queue->cur_level.time -= GST_BUFFER_DURATION (data);
-
- gst_data_unref (data);
- gst_data_unref (data);
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue is full, leaking buffer on upstream end");
+ /* now we can clean up and exit right away */
+ g_mutex_unlock (queue->qlock);
+ goto out_unref;
+
+ /* leak first buffer in the queue */
+ case GST_QUEUE_LEAK_DOWNSTREAM:{
+ /* this is a bit hacky. We'll manually iterate the list
+ * and find the first buffer from the head on. We'll
+ * unref that and "fix up" the GQueue object... */
+ GList *item;
+ GstData *leak = NULL;
+
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue is full, leaking buffer on downstream end");
+
+ for (item = queue->queue->head; item != NULL; item = item->next) {
+ if (GST_IS_BUFFER (item->data)) {
+ leak = item->data;
+ break;
+ }
+ }
+
+ /* if we didn't find anything, it means we have no buffers
+ * in here. That cannot happen, since we had >= 1 bufs */
+ g_assert (leak);
+
+ /* Now remove it from the list, fixing up the GQueue
+ * CHECKME: is a queue->head the first or the last item? */
+ item = g_list_delete_link (queue->queue->head, item);
+ queue->queue->head = g_list_first (item);
+ queue->queue->tail = g_list_last (item);
+ queue->queue->length--;
+
+ /* and unref the data at the end. Twice, because we keep a ref
+ * to make things read-only. Also keep our list uptodate. */
+ queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
+ queue->cur_level.buffers--;
+ if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
+ queue->cur_level.time -= GST_BUFFER_DURATION (data);
+
+ gst_data_unref (data);
+ gst_data_unref (data);
+ break;
}
default:
- g_warning ("Unknown leaky type, using default");
- /* fall-through */
+ g_warning ("Unknown leaky type, using default");
+ /* fall-through */
- /* don't leak. Instead, wait for space to be available */
+ /* don't leak. Instead, wait for space to be available */
case GST_QUEUE_NO_LEAK:
- STATUS (queue, "pre-full wait");
-
- while ((queue->max_size.buffers > 0 &&
- queue->cur_level.buffers >= queue->max_size.buffers) ||
- (queue->max_size.bytes > 0 &&
- queue->cur_level.bytes >= queue->max_size.bytes) ||
- (queue->max_size.time > 0 &&
- queue->cur_level.time >= queue->max_size.time)) {
- /* if there's a pending state change for this queue
- * or its manager, switch back to iterator so bottom
- * half of state change executes */
- if (queue->interrupt) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
- g_mutex_unlock (queue->qlock);
- if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
- GST_ELEMENT (queue))) {
- goto out_unref;
- }
+ STATUS (queue, "pre-full wait");
+
+ while ((queue->max_size.buffers > 0 &&
+ queue->cur_level.buffers >= queue->max_size.buffers) ||
+ (queue->max_size.bytes > 0 &&
+ queue->cur_level.bytes >= queue->max_size.bytes) ||
+ (queue->max_size.time > 0 &&
+ queue->cur_level.time >= queue->max_size.time)) {
+ /* if there's a pending state change for this queue
+ * or its manager, switch back to iterator so bottom
+ * half of state change executes */
+ if (queue->interrupt) {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
+ g_mutex_unlock (queue->qlock);
+ if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
+ GST_ELEMENT (queue))) {
+ goto out_unref;
+ }
/* if we got here because we were unlocked after a
- * flush, we don't need to add the buffer to the
- * queue again */
+ * flush, we don't need to add the buffer to the
+ * queue again */
if (queue->flush) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "not adding pending buffer after flush");
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "not adding pending buffer after flush");
goto out_unref;
}
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding pending buffer after interrupt");
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding pending buffer after interrupt");
goto restart;
- }
+ }
- if (GST_STATE (queue) != GST_STATE_PLAYING) {
+ if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down. Try to
- * signal to resolve the error */
+ * signal to resolve the error */
if (!queue->may_deadlock) {
- g_mutex_unlock (queue->qlock);
- gst_data_unref (data);
- GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
- ("deadlock found, shutting down source pad elements"));
+ g_mutex_unlock (queue->qlock);
+ gst_data_unref (data);
+ GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
+ ("deadlock found, shutting down source pad elements"));
/* we don't go to out_unref here, since we want to
- * unref the buffer *before* calling GST_ELEMENT_ERROR */
+ * unref the buffer *before* calling GST_ELEMENT_ERROR */
return;
} else {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "%s: waiting for the app to restart "
- "source pad elements",
- GST_ELEMENT_NAME (queue));
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "%s: waiting for the app to restart "
+ "source pad elements", GST_ELEMENT_NAME (queue));
}
- }
-
- /* OK, we've got a serious issue here. Imagine the situation
- * where the puller (next element) is sending an event here,
- * so it cannot pull events from the queue, and we cannot
- * push data further because the queue is 'full' and therefore,
- * we wait here (and do not handle events): deadlock! to solve
- * that, we handle pending upstream events here, too. */
- gst_queue_handle_pending_events (queue);
-
- STATUS (queue, "waiting for item_del signal");
- g_cond_wait (queue->item_del, queue->qlock);
- STATUS (queue, "received item_del signal");
- }
-
- STATUS (queue, "post-full wait");
- g_mutex_unlock (queue->qlock);
- g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
- g_mutex_lock (queue->qlock);
- break;
+ }
+
+ /* OK, we've got a serious issue here. Imagine the situation
+ * where the puller (next element) is sending an event here,
+ * so it cannot pull events from the queue, and we cannot
+ * push data further because the queue is 'full' and therefore,
+ * we wait here (and do not handle events): deadlock! to solve
+ * that, we handle pending upstream events here, too. */
+ gst_queue_handle_pending_events (queue);
+
+ STATUS (queue, "waiting for item_del signal");
+ g_cond_wait (queue->item_del, queue->qlock);
+ STATUS (queue, "received item_del signal");
+ }
+
+ STATUS (queue, "post-full wait");
+ g_mutex_unlock (queue->qlock);
+ g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
+ g_mutex_lock (queue->qlock);
+ break;
}
}
}
static GstData *
-gst_queue_get (GstPad *pad)
+gst_queue_get (GstPad * pad)
{
GstQueue *queue;
GstData *data;
restart:
/* have to lock for thread-safety */
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "locking t:%p", g_thread_self ());
+ "locking t:%p", g_thread_self ());
g_mutex_lock (queue->qlock);
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "locked t:%p", g_thread_self ());
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ());
if (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 &&
- queue->cur_level.buffers < queue->min_threshold.buffers) ||
+ queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 &&
- queue->cur_level.bytes < queue->min_threshold.bytes) ||
+ queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 &&
- queue->cur_level.time < queue->min_threshold.time)) {
+ queue->cur_level.time < queue->min_threshold.time)) {
g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
g_mutex_lock (queue->qlock);
STATUS (queue, "pre-empty wait");
while (queue->queue->length == 0 ||
- (queue->min_threshold.buffers > 0 &&
- queue->cur_level.buffers < queue->min_threshold.buffers) ||
- (queue->min_threshold.bytes > 0 &&
- queue->cur_level.bytes < queue->min_threshold.bytes) ||
- (queue->min_threshold.time > 0 &&
- queue->cur_level.time < queue->min_threshold.time)) {
+ (queue->min_threshold.buffers > 0 &&
+ queue->cur_level.buffers < queue->min_threshold.buffers) ||
+ (queue->min_threshold.bytes > 0 &&
+ queue->cur_level.bytes < queue->min_threshold.bytes) ||
+ (queue->min_threshold.time > 0 &&
+ queue->cur_level.time < queue->min_threshold.time)) {
/* if there's a pending state change for this queue or its
* manager, switch back to iterator so bottom half of state
* change executes. */
if (queue->interrupt) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
- g_mutex_unlock (queue->qlock);
- if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
- GST_ELEMENT (queue)))
- return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
- goto restart;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
+ g_mutex_unlock (queue->qlock);
+ if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
+ GST_ELEMENT (queue)))
+ return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
+ goto restart;
}
if (GST_STATE (queue) != GST_STATE_PLAYING) {
- /* this means the other end is shut down */
- if (!queue->may_deadlock) {
- g_mutex_unlock (queue->qlock);
- GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
- ("deadlock found, shutting down sink pad elements"));
- goto restart;
- } else {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "%s: waiting for the app to restart "
- "source pad elements",
- GST_ELEMENT_NAME (queue));
- }
+ /* this means the other end is shut down */
+ if (!queue->may_deadlock) {
+ g_mutex_unlock (queue->qlock);
+ GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
+ ("deadlock found, shutting down sink pad elements"));
+ goto restart;
+ } else {
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "%s: waiting for the app to restart "
+ "source pad elements", GST_ELEMENT_NAME (queue));
+ }
}
STATUS (queue, "waiting for item_add");
-
+
if (queue->block_timeout != GST_CLOCK_TIME_NONE) {
- GTimeVal timeout;
- g_get_current_time (&timeout);
- g_time_val_add (&timeout, queue->block_timeout / 1000);
- if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)){
- g_mutex_unlock (queue->qlock);
+ GTimeVal timeout;
+
+ g_get_current_time (&timeout);
+ g_time_val_add (&timeout, queue->block_timeout / 1000);
+ if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) {
+ g_mutex_unlock (queue->qlock);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Sending filler event");
- return GST_DATA (gst_event_new_filler ());
- }
+ "Sending filler event");
+ return GST_DATA (gst_event_new_filler ());
+ }
} else {
- g_cond_wait (queue->item_add, queue->qlock);
+ g_cond_wait (queue->item_add, queue->qlock);
}
STATUS (queue, "got item_add signal");
}
/* There's something in the list now, whatever it is */
data = g_queue_pop_head (queue->queue);
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "retrieved data %p from queue", data);
-
+ "retrieved data %p from queue", data);
+
if (data == NULL)
return NULL;
* locked too so it'd cause a deadlock. */
if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data);
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue \"%s\" eos",
- GST_ELEMENT_NAME (queue));
- gst_element_set_eos (GST_ELEMENT (queue));
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue \"%s\" eos", GST_ELEMENT_NAME (queue));
+ gst_element_set_eos (GST_ELEMENT (queue));
+ break;
default:
- break;
+ break;
}
}
static gboolean
-gst_queue_handle_src_event (GstPad *pad,
- GstEvent *event)
+gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
{
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
gboolean res;
er.handled = FALSE;
g_queue_push_tail (queue->events, &er);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Preparing for loop for event handler");
+ "Preparing for loop for event handler");
/* see the chain function on why this is here - it prevents a deadlock */
g_cond_signal (queue->item_del);
while (!er.handled) {
GTimeVal timeout;
+
g_get_current_time (&timeout);
- g_time_val_add (&timeout, 500 * 1000); /* half a second */
+ g_time_val_add (&timeout, 500 * 1000); /* half a second */
if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) &&
- !er.handled) {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "timeout in upstream event handling");
- /* remove ourselves from the pending list. Since we're
- * locked, others cannot reference this anymore. */
- queue->queue->head = g_list_remove (queue->queue->head, &er);
- queue->queue->head = g_list_first (queue->queue->head);
- queue->queue->tail = g_list_last (queue->queue->head);
- queue->queue->length--;
- res = FALSE;
- goto handled;
+ !er.handled) {
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "timeout in upstream event handling");
+ /* remove ourselves from the pending list. Since we're
+ * locked, others cannot reference this anymore. */
+ queue->queue->head = g_list_remove (queue->queue->head, &er);
+ queue->queue->head = g_list_first (queue->queue->head);
+ queue->queue->tail = g_list_last (queue->queue->head);
+ queue->queue->length--;
+ res = FALSE;
+ goto handled;
}
}
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Event handled");
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled");
res = er.ret;
} else {
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "FLUSH event, flushing queue\n");
- gst_queue_locked_flush (queue);
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "FLUSH event, flushing queue\n");
+ gst_queue_locked_flush (queue);
+ break;
case GST_EVENT_SEEK:
- if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
- gst_queue_locked_flush (queue);
- }
+ if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
+ gst_queue_locked_flush (queue);
+ }
default:
- break;
+ break;
}
}
handled:
}
static gboolean
-gst_queue_release_locks (GstElement *element)
+gst_queue_release_locks (GstElement * element)
{
GstQueue *queue;
}
static GstElementStateReturn
-gst_queue_change_state (GstElement *element)
+gst_queue_change_state (GstElement * element)
{
GstQueue *queue;
GstElementStateReturn ret = GST_STATE_SUCCESS;
break;
case GST_STATE_PAUSED_TO_PLAYING:
if (!GST_PAD_IS_LINKED (queue->sinkpad)) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
- "queue %s is not linked",
- GST_ELEMENT_NAME (queue));
- /* FIXME can this be? */
- g_cond_signal (queue->item_add);
-
- ret = GST_STATE_FAILURE;
- goto error;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
+ "queue %s is not linked", GST_ELEMENT_NAME (queue));
+ /* FIXME can this be? */
+ g_cond_signal (queue->item_add);
+
+ ret = GST_STATE_FAILURE;
+ goto error;
} else {
- GstScheduler *src_sched, *sink_sched;
-
- src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
- sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
+ GstScheduler *src_sched, *sink_sched;
+
+ src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
+ sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
- if (src_sched == sink_sched) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
- "queue %s does not connect different schedulers",
- GST_ELEMENT_NAME (queue));
+ if (src_sched == sink_sched) {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
+ "queue %s does not connect different schedulers",
+ GST_ELEMENT_NAME (queue));
g_warning ("queue %s does not connect different schedulers",
- GST_ELEMENT_NAME (queue));
+ GST_ELEMENT_NAME (queue));
ret = GST_STATE_FAILURE;
goto error;
- }
+ }
}
queue->interrupt = FALSE;
break;
static void
-gst_queue_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_queue_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstQueue *queue = GST_QUEUE (object);
}
static void
-gst_queue_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_queue_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstQueue *queue = GST_QUEUE (object);
G_BEGIN_DECLS
-
#define GST_TYPE_QUEUE \
(gst_queue_get_type())
#define GST_QUEUE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE))
#define GST_IS_QUEUE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE))
-
-enum {
- GST_QUEUE_NO_LEAK = 0,
- GST_QUEUE_LEAK_UPSTREAM = 1,
- GST_QUEUE_LEAK_DOWNSTREAM = 2
+ enum
+{
+ GST_QUEUE_NO_LEAK = 0,
+ GST_QUEUE_LEAK_UPSTREAM = 1,
+ GST_QUEUE_LEAK_DOWNSTREAM = 2
};
typedef struct _GstQueue GstQueue;
typedef struct _GstQueueClass GstQueueClass;
-struct _GstQueue {
+struct _GstQueue
+{
GstElement element;
GstPad *sinkpad;
/* the queue of data we're keeping our grubby hands on */
GQueue *queue;
- struct {
- guint buffers; /* no. of buffers */
- guint bytes; /* no. of bytes */
- guint64 time; /* amount of time */
- } cur_level, /* currently in the queue */
- max_size, /* max. amount of data allowed in the queue */
- min_threshold; /* min. amount of data required to wake reader */
+ struct
+ {
+ guint buffers; /* no. of buffers */
+ guint bytes; /* no. of bytes */
+ guint64 time; /* amount of time */
+ } cur_level, /* currently in the queue */
+ max_size, /* max. amount of data allowed in the queue */
+ min_threshold; /* min. amount of data required to wake reader */
/* whether we leak data, and at which end */
gint leaky;
gboolean interrupt;
gboolean flush;
- GMutex *qlock; /* lock for queue (vs object lock) */
- GCond *item_add; /* signals buffers now available for reading */
- GCond *item_del; /* signals space now available for writing */
- GCond *event_done; /* upstream event signaller */
+ GMutex *qlock; /* lock for queue (vs object lock) */
+ GCond *item_add; /* signals buffers now available for reading */
+ GCond *item_del; /* signals space now available for writing */
+ GCond *event_done; /* upstream event signaller */
- GTimeVal *timeval; /* the timeout for the queue locking */
- GQueue *events; /* upstream events get decoupled here */
+ GTimeVal *timeval; /* the timeout for the queue locking */
+ GQueue *events; /* upstream events get decoupled here */
GstCaps *negotiated_caps;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstQueueClass {
+struct _GstQueueClass
+{
GstElementClass parent_class;
/* signals - 'running' is called from both sides
* which might make it sort of non-useful... */
- void (*underrun) (GstQueue *queue);
- void (*running) (GstQueue *queue);
- void (*overrun) (GstQueue *queue);
+ void (*underrun) (GstQueue * queue);
+ void (*running) (GstQueue * queue);
+ void (*overrun) (GstQueue * queue);
gpointer _gst_reserved[GST_PADDING];
};
GType gst_queue_get_type (void);
G_END_DECLS
-
-
#endif /* __GST_QUEUE_H__ */
#include "gstfilter.h"
/* Element signals and args */
-enum {
+enum
+{
PLUGIN_ADDED,
LAST_SIGNAL
};
-static void gst_registry_class_init (GstRegistryClass *klass);
-static void gst_registry_init (GstRegistry *registry);
+static void gst_registry_class_init (GstRegistryClass * klass);
+static void gst_registry_init (GstRegistry * registry);
static GObjectClass *parent_class = NULL;
-static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
+static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
GType
gst_registry_get_type (void)
NULL
};
registry_type = g_type_register_static (G_TYPE_OBJECT, "GstRegistry",
- ®istry_info, G_TYPE_FLAG_ABSTRACT);
+ ®istry_info, G_TYPE_FLAG_ABSTRACT);
}
return registry_type;
}
static void
-gst_registry_class_init (GstRegistryClass *klass)
+gst_registry_class_init (GstRegistryClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
gst_registry_signals[PLUGIN_ADDED] =
- g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL, NULL,
- gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
+ NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
gobject_class->dispose = NULL;
}
static void
-gst_registry_init (GstRegistry *registry)
+gst_registry_init (GstRegistry * registry)
{
registry->priority = 0;
registry->loaded = FALSE;
* Returns: TRUE on success.
*/
gboolean
-gst_registry_load (GstRegistry *registry)
+gst_registry_load (GstRegistry * registry)
{
GstRegistryClass *rclass;
* Returns: TRUE if loaded.
*/
gboolean
-gst_registry_is_loaded (GstRegistry *registry)
+gst_registry_is_loaded (GstRegistry * registry)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
* Returns: TRUE on success
*/
gboolean
-gst_registry_save (GstRegistry *registry)
+gst_registry_save (GstRegistry * registry)
{
GstRegistryClass *rclass;
* Returns: TRUE on success
*/
gboolean
-gst_registry_rebuild (GstRegistry *registry)
+gst_registry_rebuild (GstRegistry * registry)
{
GstRegistryClass *rclass;
* Returns: TRUE on success
*/
gboolean
-gst_registry_unload (GstRegistry *registry)
+gst_registry_unload (GstRegistry * registry)
{
GstRegistryClass *rclass;
* added, do nothing.
*/
void
-gst_registry_add_path (GstRegistry *registry, const gchar *path)
+gst_registry_add_path (GstRegistry * registry, const gchar * path)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
g_return_if_fail (path != NULL);
if (g_list_find_custom (registry->paths, path, (GCompareFunc) strcmp)) {
- g_warning ("path %s already added to registry", path);
+ g_warning ("path %s already added to registry", path);
return;
}
*
* Returns: A Glist of paths as strings. g_list_free after use.
*/
-GList*
-gst_registry_get_path_list (GstRegistry *registry)
+GList *
+gst_registry_get_path_list (GstRegistry * registry)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
* Clear the paths of the given registry
*/
void
-gst_registry_clear_paths (GstRegistry *registry)
+gst_registry_clear_paths (GstRegistry * registry)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
*
* Returns: TRUE on success.
*/
-gboolean
-gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin)
+gboolean
+gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
-
+
plugin->manager = registry;
registry->plugins = g_list_prepend (registry->plugins, plugin);
- g_signal_emit (G_OBJECT (registry), gst_registry_signals[PLUGIN_ADDED], 0, plugin);
+ g_signal_emit (G_OBJECT (registry), gst_registry_signals[PLUGIN_ADDED], 0,
+ plugin);
return TRUE;
}
* Remove the plugin from the registry.
*/
void
-gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin)
+gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
*
* Returns: a GList of plugins, g_list_free after use.
*/
-GList*
-gst_registry_plugin_filter (GstRegistry *registry,
- GstPluginFilter filter,
- gboolean first,
- gpointer user_data)
+GList *
+gst_registry_plugin_filter (GstRegistry * registry,
+ GstPluginFilter filter, gboolean first, gpointer user_data)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
- return gst_filter_run (registry->plugins, (GstFilterFunc) filter, first, user_data);
+ return gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
+ user_data);
}
/**
*
* Returns: a GList of plugin features, g_list_free after use.
*/
-GList*
-gst_registry_feature_filter (GstRegistry *registry,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data)
+GList *
+gst_registry_feature_filter (GstRegistry * registry,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
- return gst_plugin_list_feature_filter (registry->plugins, filter, first, user_data);
+ return gst_plugin_list_feature_filter (registry->plugins, filter, first,
+ user_data);
}
/**
*
* Returns: The plugin with the given name or NULL if the plugin was not found.
*/
-GstPlugin*
-gst_registry_find_plugin (GstRegistry *registry, const gchar *name)
+GstPlugin *
+gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
{
GList *walk;
GstPlugin *result = NULL;
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
g_return_val_if_fail (name != NULL, NULL);
- walk = gst_registry_plugin_filter (registry,
- (GstPluginFilter) gst_plugin_name_filter,
- TRUE,
- (gpointer) name);
- if (walk)
+ walk = gst_registry_plugin_filter (registry,
+ (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
+ if (walk)
result = GST_PLUGIN (walk->data);
g_list_free (walk);
* Returns: The pluginfeature with the given name and type or NULL
* if the plugin was not found.
*/
-GstPluginFeature*
-gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type)
+GstPluginFeature *
+gst_registry_find_feature (GstRegistry * registry, const gchar * name,
+ GType type)
{
GstPluginFeature *feature = NULL;
GList *walk;
data.name = name;
data.type = type;
- walk = gst_registry_feature_filter (registry,
- (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
- TRUE,
- &data);
+ walk = gst_registry_feature_filter (registry,
+ (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
+ TRUE, &data);
- if (walk)
+ if (walk)
feature = GST_PLUGIN_FEATURE (walk->data);
g_list_free (walk);
* Returns: a value indicating the result
*/
GstRegistryReturn
-gst_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin)
+gst_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin)
{
GstRegistryClass *rclass;
- g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR);
+ g_return_val_if_fail (GST_IS_REGISTRY (registry),
+ GST_REGISTRY_PLUGIN_LOAD_ERROR);
rclass = GST_REGISTRY_GET_CLASS (registry);
* Returns: a value indicating the result
*/
GstRegistryReturn
-gst_registry_unload_plugin (GstRegistry *registry, GstPlugin *plugin)
+gst_registry_unload_plugin (GstRegistry * registry, GstPlugin * plugin)
{
GstRegistryClass *rclass;
- g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR);
+ g_return_val_if_fail (GST_IS_REGISTRY (registry),
+ GST_REGISTRY_PLUGIN_LOAD_ERROR);
rclass = GST_REGISTRY_GET_CLASS (registry);
* Returns: a value indicating the result
*/
GstRegistryReturn
-gst_registry_update_plugin (GstRegistry *registry, GstPlugin *plugin)
+gst_registry_update_plugin (GstRegistry * registry, GstPlugin * plugin)
{
GstRegistryClass *rclass;
- g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR);
+ g_return_val_if_fail (GST_IS_REGISTRY (registry),
+ GST_REGISTRY_PLUGIN_LOAD_ERROR);
rclass = GST_REGISTRY_GET_CLASS (registry);
S_IRGRP | S_IWGRP | \
S_IROTH | S_IWOTH)
-G_BEGIN_DECLS
-
-typedef enum {
- GST_REGISTRY_OK = (0),
- GST_REGISTRY_LOAD_ERROR = (1 << 1),
- GST_REGISTRY_SAVE_ERROR = (1 << 2),
- GST_REGISTRY_PLUGIN_LOAD_ERROR = (1 << 3),
- GST_REGISTRY_PLUGIN_SIGNATURE_ERROR = (1 << 4)
+G_BEGIN_DECLS typedef enum
+{
+ GST_REGISTRY_OK = (0),
+ GST_REGISTRY_LOAD_ERROR = (1 << 1),
+ GST_REGISTRY_SAVE_ERROR = (1 << 2),
+ GST_REGISTRY_PLUGIN_LOAD_ERROR = (1 << 3),
+ GST_REGISTRY_PLUGIN_SIGNATURE_ERROR = (1 << 4)
} GstRegistryReturn;
-typedef enum {
- GST_REGISTRY_READABLE = (1 << 1),
- GST_REGISTRY_WRITABLE = (1 << 2),
- GST_REGISTRY_EXISTS = (1 << 3),
- GST_REGISTRY_REMOTE = (1 << 4),
- GST_REGISTRY_DELAYED_LOADING = (1 << 5)
+typedef enum
+{
+ GST_REGISTRY_READABLE = (1 << 1),
+ GST_REGISTRY_WRITABLE = (1 << 2),
+ GST_REGISTRY_EXISTS = (1 << 3),
+ GST_REGISTRY_REMOTE = (1 << 4),
+ GST_REGISTRY_DELAYED_LOADING = (1 << 5)
} GstRegistryFlags;
-
+
#define GST_TYPE_REGISTRY (gst_registry_get_type ())
#define GST_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REGISTRY, GstRegistry))
#define GST_IS_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REGISTRY))
typedef struct _GstRegistry GstRegistry;
typedef struct _GstRegistryClass GstRegistryClass;
-struct _GstRegistry {
- GObject object;
+struct _GstRegistry
+{
+ GObject object;
- gint priority;
+ gint priority;
GstRegistryFlags flags;
- gchar *name;
- gchar *details;
+ gchar *name;
+ gchar *details;
- gboolean loaded;
- GList *plugins;
+ gboolean loaded;
+ GList *plugins;
- GList *paths;
+ GList *paths;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstRegistryClass {
- GObjectClass parent_class;
+struct _GstRegistryClass
+{
+ GObjectClass parent_class;
/* vtable */
- gboolean (*load) (GstRegistry *registry);
- gboolean (*save) (GstRegistry *registry);
- gboolean (*rebuild) (GstRegistry *registry);
- gboolean (*unload) (GstRegistry *registry);
-
- GstRegistryReturn (*load_plugin) (GstRegistry *registry, GstPlugin *plugin);
- GstRegistryReturn (*unload_plugin) (GstRegistry *registry, GstPlugin *plugin);
- GstRegistryReturn (*update_plugin) (GstRegistry *registry, GstPlugin *plugin);
+ gboolean (*load) (GstRegistry * registry);
+ gboolean (*save) (GstRegistry * registry);
+ gboolean (*rebuild) (GstRegistry * registry);
+ gboolean (*unload) (GstRegistry * registry);
+
+ GstRegistryReturn (*load_plugin) (GstRegistry * registry,
+ GstPlugin * plugin);
+ GstRegistryReturn (*unload_plugin) (GstRegistry * registry,
+ GstPlugin * plugin);
+ GstRegistryReturn (*update_plugin) (GstRegistry * registry,
+ GstPlugin * plugin);
/* signals */
- void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin);
+ void (*plugin_added) (GstRegistry * registry, GstPlugin * plugin);
gpointer _gst_reserved[GST_PADDING];
};
/* normal GObject stuff */
-GType gst_registry_get_type (void);
-
-gboolean gst_registry_load (GstRegistry *registry);
-gboolean gst_registry_is_loaded (GstRegistry *registry);
-gboolean gst_registry_save (GstRegistry *registry);
-gboolean gst_registry_rebuild (GstRegistry *registry);
-gboolean gst_registry_unload (GstRegistry *registry);
-
-void gst_registry_add_path (GstRegistry *registry, const gchar *path);
-GList* gst_registry_get_path_list (GstRegistry *registry);
-void gst_registry_clear_paths (GstRegistry *registry);
-
-gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin);
-void gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin);
-
-GList* gst_registry_plugin_filter (GstRegistry *registry,
- GstPluginFilter filter,
- gboolean first,
- gpointer user_data);
-GList* gst_registry_feature_filter (GstRegistry *registry,
- GstPluginFeatureFilter filter,
- gboolean first,
- gpointer user_data);
-
-GstPlugin* gst_registry_find_plugin (GstRegistry *registry, const gchar *name);
-GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type);
-
-GstRegistryReturn gst_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin);
-GstRegistryReturn gst_registry_unload_plugin (GstRegistry *registry, GstPlugin *plugin);
-GstRegistryReturn gst_registry_update_plugin (GstRegistry *registry, GstPlugin *plugin);
+GType gst_registry_get_type (void);
+
+gboolean gst_registry_load (GstRegistry * registry);
+gboolean gst_registry_is_loaded (GstRegistry * registry);
+gboolean gst_registry_save (GstRegistry * registry);
+gboolean gst_registry_rebuild (GstRegistry * registry);
+gboolean gst_registry_unload (GstRegistry * registry);
+
+void gst_registry_add_path (GstRegistry * registry, const gchar * path);
+GList *gst_registry_get_path_list (GstRegistry * registry);
+void gst_registry_clear_paths (GstRegistry * registry);
+
+gboolean gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin);
+void gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin);
+
+GList *gst_registry_plugin_filter (GstRegistry * registry,
+ GstPluginFilter filter, gboolean first, gpointer user_data);
+GList *gst_registry_feature_filter (GstRegistry * registry,
+ GstPluginFeatureFilter filter, gboolean first, gpointer user_data);
+
+GstPlugin *gst_registry_find_plugin (GstRegistry * registry,
+ const gchar * name);
+GstPluginFeature *gst_registry_find_feature (GstRegistry * registry,
+ const gchar * name, GType type);
+
+GstRegistryReturn gst_registry_load_plugin (GstRegistry * registry,
+ GstPlugin * plugin);
+GstRegistryReturn gst_registry_unload_plugin (GstRegistry * registry,
+ GstPlugin * plugin);
+GstRegistryReturn gst_registry_update_plugin (GstRegistry * registry,
+ GstPlugin * plugin);
G_END_DECLS
-
#endif /* __GST_REGISTRY_H__ */
/* list of registries in the pool */
static GList *_gst_registry_pool = NULL;
+
/* list of plugins without a registry, like statically linked
* plugins */
static GList *_gst_registry_pool_plugins = NULL;
*
* Returns: a Glist of GstRegistries, g_list_free after use.
*/
-GList*
+GList *
gst_registry_pool_list (void)
{
return g_list_copy (_gst_registry_pool);
* Add the registry to the pool with the given priority.
*/
void
-gst_registry_pool_add (GstRegistry *registry, guint priority)
+gst_registry_pool_add (GstRegistry * registry, guint priority)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
registry->priority = priority;
- _gst_registry_pool = g_list_insert_sorted (_gst_registry_pool, registry, gst_registry_compare_func);
+ _gst_registry_pool =
+ g_list_insert_sorted (_gst_registry_pool, registry,
+ gst_registry_compare_func);
}
/**
* Remove the registry from the pool.
*/
void
-gst_registry_pool_remove (GstRegistry *registry)
+gst_registry_pool_remove (GstRegistry * registry)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
* Add the plugin to the global pool of plugins.
*/
void
-gst_registry_pool_add_plugin (GstPlugin *plugin)
+gst_registry_pool_add_plugin (GstPlugin * plugin)
{
- _gst_registry_pool_plugins = g_list_prepend (_gst_registry_pool_plugins, plugin);
+ _gst_registry_pool_plugins =
+ g_list_prepend (_gst_registry_pool_plugins, plugin);
}
#ifndef GST_DISABLE_REGISTRY
static void
-_registry_load_func (GstRegistry *registry, gpointer user_data)
+_registry_load_func (GstRegistry * registry, gpointer user_data)
{
if (!(registry->flags & GST_REGISTRY_DELAYED_LOADING)) {
gst_registry_load (registry);
*
* Returns: a GList of plugins, g_list_free after use.
*/
-GList*
+GList *
gst_registry_pool_plugin_list (void)
{
return gst_registry_pool_plugin_filter (NULL, FALSE, NULL);
*
* Returns: a GList of plugins, g_list_free after use.
*/
-GList*
-gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first, gpointer user_data)
+GList *
+gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first,
+ gpointer user_data)
{
GList *result = NULL;
GList *temp;
-
+
#ifndef GST_DISABLE_REGISTRY
GList *walk;
return temp;
result = g_list_concat (result, temp);
-
+
walk = g_list_next (walk);
}
#endif /* GST_DISABLE_REGISTRY */
- temp = gst_filter_run (_gst_registry_pool_plugins, (GstFilterFunc) filter, first, user_data);
+ temp =
+ gst_filter_run (_gst_registry_pool_plugins, (GstFilterFunc) filter, first,
+ user_data);
result = g_list_concat (result, temp);
*
* Returns: a GList of pluginfeatures, g_list_free after use.
*/
-GList*
+GList *
gst_registry_pool_feature_list (GType type)
{
GstTypeNameData data;
data.type = type;
return gst_registry_pool_feature_filter (
- (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
- FALSE,
- &data);
+ (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
+ FALSE, &data);
}
/**
*
* Returns: a GList of pluginfeatures, g_list_free after use.
*/
-GList*
-gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
+GList *
+gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first,
+ gpointer user_data)
{
GList *result = NULL;
GList *temp;
-
+
#ifndef GST_DISABLE_REGISTRY
GList *walk;
+
walk = _gst_registry_pool;
while (walk) {
return temp;
result = g_list_concat (result, temp);
-
+
walk = g_list_next (walk);
}
#endif /* GST_DISABLE_REGISTRY */
- temp = gst_plugin_list_feature_filter (_gst_registry_pool_plugins, filter, first, user_data);
+ temp =
+ gst_plugin_list_feature_filter (_gst_registry_pool_plugins, filter, first,
+ user_data);
result = g_list_concat (result, temp);
* Returns: The plugin with the given name or NULL if the plugin
* was not found.
*/
-GstPlugin*
-gst_registry_pool_find_plugin (const gchar *name)
+GstPlugin *
+gst_registry_pool_find_plugin (const gchar * name)
{
GstPlugin *result = NULL;
GList *walk;
g_return_val_if_fail (name != NULL, NULL);
-
- walk = gst_registry_pool_plugin_filter ((GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
+
+ walk =
+ gst_registry_pool_plugin_filter ((GstPluginFilter) gst_plugin_name_filter,
+ TRUE, (gpointer) name);
if (walk)
result = GST_PLUGIN (walk->data);
g_list_free (walk);
-
+
return result;
}
* Returns: A pluginfeature with the given name and type or NULL if the feature
* was not found.
*/
-GstPluginFeature*
-gst_registry_pool_find_feature (const gchar *name, GType type)
+GstPluginFeature *
+gst_registry_pool_find_feature (const gchar * name, GType type)
{
GstPluginFeature *result = NULL;
GList *walk;
data.type = type;
data.name = name;
- walk = gst_registry_pool_feature_filter ((GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
- TRUE, &data);
-
- if (walk)
+ walk =
+ gst_registry_pool_feature_filter ((GstPluginFeatureFilter)
+ gst_plugin_feature_type_name_filter, TRUE, &data);
+
+ if (walk)
result = GST_PLUGIN_FEATURE (walk->data);
g_list_free (walk);
*
* Returns: The registry with the flags.
*/
-GstRegistry*
+GstRegistry *
gst_registry_pool_get_prefered (GstRegistryFlags flags)
{
#ifndef GST_DISABLE_REGISTRY
if (registry->flags & flags)
return registry;
-
+
walk = g_list_next (walk);
}
#endif /* GST_DISABLE_REGISTRY */
#define __GST_REGISTRY_POOL_H__
G_BEGIN_DECLS
-
#include <gst/gstplugin.h>
#include <gst/gstregistry.h>
-
/* the pool of registries */
-GList* gst_registry_pool_list (void);
+ GList * gst_registry_pool_list (void);
-void gst_registry_pool_add (GstRegistry *registry, guint priority);
-void gst_registry_pool_remove (GstRegistry *registry);
+void gst_registry_pool_add (GstRegistry * registry, guint priority);
+void gst_registry_pool_remove (GstRegistry * registry);
-void gst_registry_pool_add_plugin (GstPlugin *plugin);
+void gst_registry_pool_add_plugin (GstPlugin * plugin);
-void gst_registry_pool_load_all (void);
+void gst_registry_pool_load_all (void);
/* query the plugins/features */
-GList* gst_registry_pool_plugin_filter (GstPluginFilter filter,
- gboolean first, gpointer user_data);
-GList* gst_registry_pool_feature_filter (GstPluginFeatureFilter filter,
- gboolean first, gpointer user_data);
+GList *gst_registry_pool_plugin_filter (GstPluginFilter filter,
+ gboolean first, gpointer user_data);
+GList *gst_registry_pool_feature_filter (GstPluginFeatureFilter filter,
+ gboolean first, gpointer user_data);
/* some predefined filters */
-GList* gst_registry_pool_plugin_list (void);
-GList* gst_registry_pool_feature_list (GType type);
+GList *gst_registry_pool_plugin_list (void);
+GList *gst_registry_pool_feature_list (GType type);
-GstPlugin* gst_registry_pool_find_plugin (const gchar *name);
-GstPluginFeature* gst_registry_pool_find_feature (const gchar *name, GType type);
+GstPlugin *gst_registry_pool_find_plugin (const gchar * name);
+GstPluginFeature *gst_registry_pool_find_feature (const gchar * name,
+ GType type);
-GstRegistry* gst_registry_pool_get_prefered (GstRegistryFlags flags);
+GstRegistry *gst_registry_pool_get_prefered (GstRegistryFlags flags);
G_END_DECLS
-
#endif /* __GST_REGISTRY_POOL_H__ */
#include "gstinfo.h"
#include "gstregistrypool.h"
-static void gst_scheduler_class_init (GstSchedulerClass *klass);
-static void gst_scheduler_init (GstScheduler *sched);
-static void gst_scheduler_dispose (GObject *object);
+static void gst_scheduler_class_init (GstSchedulerClass * klass);
+static void gst_scheduler_init (GstScheduler * sched);
+static void gst_scheduler_dispose (GObject * object);
static GstObjectClass *parent_class = NULL;
NULL
};
- _gst_scheduler_type = g_type_register_static (GST_TYPE_OBJECT, "GstScheduler",
- &scheduler_info, G_TYPE_FLAG_ABSTRACT);
+ _gst_scheduler_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstScheduler",
+ &scheduler_info, G_TYPE_FLAG_ABSTRACT);
}
return _gst_scheduler_type;
}
static void
-gst_scheduler_class_init (GstSchedulerClass *klass)
+gst_scheduler_class_init (GstSchedulerClass * klass)
{
GObjectClass *gobject_class;
-
- gobject_class = (GObjectClass*) klass;
-
+
+ gobject_class = (GObjectClass *) klass;
+
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_scheduler_dispose);
}
static void
-gst_scheduler_init (GstScheduler *sched)
+gst_scheduler_init (GstScheduler * sched)
{
sched->clock_providers = NULL;
sched->clock_receivers = NULL;
}
static void
-gst_scheduler_dispose (GObject *object)
+gst_scheduler_dispose (GObject * object)
{
GstScheduler *sched = GST_SCHEDULER (object);
/* thse lists should all be NULL */
- GST_DEBUG ( "scheduler %p dispose %p %p %p",
- object,
- sched->clock_providers,
- sched->clock_receivers,
- sched->schedulers);
+ GST_DEBUG ("scheduler %p dispose %p %p %p",
+ object,
+ sched->clock_providers, sched->clock_receivers, sched->schedulers);
- gst_object_replace ((GstObject **)&sched->current_clock, NULL);
- gst_object_replace ((GstObject **)&sched->clock, NULL);
+ gst_object_replace ((GstObject **) & sched->current_clock, NULL);
+ gst_object_replace ((GstObject **) & sched->clock, NULL);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
* Prepare the scheduler.
*/
void
-gst_scheduler_setup (GstScheduler *sched)
+gst_scheduler_setup (GstScheduler * sched)
{
GstSchedulerClass *sclass;
* Reset the schedulers.
*/
void
-gst_scheduler_reset (GstScheduler *sched)
+gst_scheduler_reset (GstScheduler * sched)
{
GstSchedulerClass *sclass;
* Links the srcpad to the given sinkpad.
*/
void
-gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
+gst_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad)
{
GstSchedulerClass *sclass;
* Unlinks the srcpad from the given sinkpad.
*/
void
-gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
+gst_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad)
{
GstSchedulerClass *sclass;
* Returns: the pad which received a buffer.
*/
GstPad *
-gst_scheduler_pad_select (GstScheduler *sched, GList *padlist)
+gst_scheduler_pad_select (GstScheduler * sched, GList * padlist)
{
GstSchedulerClass *sclass;
* Add an element to the scheduler.
*/
void
-gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
+gst_scheduler_add_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
/* if it's already in this scheduler, don't bother doing anything */
if (GST_ELEMENT_SCHED (element) == sched) {
- GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p",
- GST_ELEMENT_NAME (element), sched);
+ GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p",
+ GST_ELEMENT_NAME (element), sched);
return;
}
if (gst_element_provides_clock (element)) {
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_ELEMENT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s",
+ GST_ELEMENT_NAME (element));
}
if (gst_element_requires_clock (element)) {
sched->clock_receivers = g_list_prepend (sched->clock_receivers, element);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element));
+ GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s",
+ GST_ELEMENT_NAME (element));
}
gst_element_set_scheduler (element, sched);
* Remove an element from the scheduler.
*/
void
-gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
+gst_scheduler_remove_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
if (sclass->remove_element)
sclass->remove_element (sched, element);
- gst_element_set_scheduler (element, NULL);
+ gst_element_set_scheduler (element, NULL);
}
/**
* of the state transition.
*/
GstElementStateReturn
-gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition)
+gst_scheduler_state_transition (GstScheduler * sched, GstElement * element,
+ gint transition)
{
GstSchedulerClass *sclass;
switch (transition) {
case GST_STATE_READY_TO_PAUSED:
{
- GstClock *clock = gst_scheduler_get_clock (sched);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock,
- (clock ? GST_OBJECT_NAME (clock) : "nil"));
+ GstClock *clock = gst_scheduler_get_clock (sched);
+
+ GST_CAT_DEBUG (GST_CAT_CLOCK,
+ "scheduler READY to PAUSED clock is %p (%s)", clock,
+ (clock ? GST_OBJECT_NAME (clock) : "nil"));
gst_scheduler_set_clock (sched, clock);
- break;
+ break;
}
}
}
* from a loop based element to a chain based element.
*/
void
-gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element)
+gst_scheduler_scheduling_change (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
* Notifies the scheduler that it has to monitor this scheduler.
*/
void
-gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2)
+gst_scheduler_add_scheduler (GstScheduler * sched, GstScheduler * sched2)
{
GstSchedulerClass *sclass;
a Notifies the scheduler that it can stop monitoring this scheduler.
*/
void
-gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2)
+gst_scheduler_remove_scheduler (GstScheduler * sched, GstScheduler * sched2)
{
GstSchedulerClass *sclass;
* Acquire a lock on the given element in the given scheduler.
*/
void
-gst_scheduler_lock_element (GstScheduler *sched, GstElement *element)
+gst_scheduler_lock_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
* Release the lock on the given element in the given scheduler.
*/
void
-gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element)
+gst_scheduler_unlock_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
* Tell the scheduler an element was in error
*/
void
-gst_scheduler_error (GstScheduler *sched, GstElement *element)
+gst_scheduler_error (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
* if the scheduler can perform this action itself.
*/
gboolean
-gst_scheduler_yield (GstScheduler *sched, GstElement *element)
+gst_scheduler_yield (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
* function.
*/
gboolean
-gst_scheduler_interrupt (GstScheduler *sched, GstElement *element)
+gst_scheduler_interrupt (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
*
* Returns: a GstClock
*/
-GstClock*
-gst_scheduler_get_clock (GstScheduler *sched)
+GstClock *
+gst_scheduler_get_clock (GstScheduler * sched)
{
GstClock *clock = NULL;
-
+
/* if we have a fixed clock, use that one */
if (GST_FLAG_IS_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK)) {
- clock = sched->clock;
+ clock = sched->clock;
- GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
- (clock ? GST_OBJECT_NAME (clock) : "nil"));
- }
- else {
+ GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
+ (clock ? GST_OBJECT_NAME (clock) : "nil"));
+ } else {
GList *schedulers = sched->schedulers;
GList *providers = sched->clock_providers;
/* try to get a clock from one of the schedulers we manage first */
while (schedulers) {
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
-
+
clock = gst_scheduler_get_clock (scheduler);
if (clock)
- break;
+ break;
schedulers = g_list_next (schedulers);
}
clock = gst_system_clock_obtain ();
}
}
- GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, sched, "scheduler selected clock %p (%s)", clock,
- clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
+ GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, sched, "scheduler selected clock %p (%s)",
+ clock, clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
return clock;
}
* to this scheduler.
*/
void
-gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock)
+gst_scheduler_use_clock (GstScheduler * sched, GstClock * clock)
{
g_return_if_fail (sched != NULL);
g_return_if_fail (GST_IS_SCHEDULER (sched));
GST_FLAG_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
- gst_object_replace ((GstObject **)&sched->clock, (GstObject *)clock);
+ gst_object_replace ((GstObject **) & sched->clock, (GstObject *) clock);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
- (clock ? GST_OBJECT_NAME (clock) : "nil"));
+ GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
+ (clock ? GST_OBJECT_NAME (clock) : "nil"));
}
/**
* to all the elements managed by the scheduler.
*/
void
-gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock)
+gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock)
{
GList *receivers;
GList *schedulers;
receivers = sched->clock_receivers;
schedulers = sched->schedulers;
- gst_object_replace ((GstObject **)&sched->current_clock, (GstObject *)clock);
+ gst_object_replace ((GstObject **) & sched->current_clock,
+ (GstObject *) clock);
while (receivers) {
GstElement *element = GST_ELEMENT (receivers->data);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on element %s", clock,
- (clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element));
-
+ GST_CAT_DEBUG (GST_CAT_CLOCK,
+ "scheduler setting clock %p (%s) on element %s", clock,
+ (clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element));
+
gst_element_set_clock (element, clock);
receivers = g_list_next (receivers);
}
while (schedulers) {
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
- GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on scheduler %p", clock,
- (clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler);
+ GST_CAT_DEBUG (GST_CAT_CLOCK,
+ "scheduler setting clock %p (%s) on scheduler %p", clock,
+ (clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler);
gst_scheduler_set_clock (scheduler, clock);
schedulers = g_list_next (schedulers);
}
* Let the scheduler select a clock automatically.
*/
void
-gst_scheduler_auto_clock (GstScheduler *sched)
+gst_scheduler_auto_clock (GstScheduler * sched)
{
g_return_if_fail (sched != NULL);
g_return_if_fail (GST_IS_SCHEDULER (sched));
GST_FLAG_UNSET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
- gst_object_replace ((GstObject **)&sched->clock, NULL);
+ gst_object_replace ((GstObject **) & sched->clock, NULL);
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock");
}
-GstClockReturn gst_clock_id_wait (GstClockID id,
- GstClockTimeDiff *jitter);
+GstClockReturn gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter);
+
/**
* gst_scheduler_clock_wait:
* @sched: the scheduler
* Returns: the status of the operation
*/
GstClockReturn
-gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element,
- GstClockID id, GstClockTimeDiff *jitter)
+gst_scheduler_clock_wait (GstScheduler * sched, GstElement * element,
+ GstClockID id, GstClockTimeDiff * jitter)
{
GstSchedulerClass *sclass;
if (sclass->clock_wait)
return sclass->clock_wait (sched, element, id, jitter);
- else
+ else
return gst_clock_id_wait (id, jitter);
}
* Returns: a boolean indicating something usefull has happened.
*/
gboolean
-gst_scheduler_iterate (GstScheduler *sched)
+gst_scheduler_iterate (GstScheduler * sched)
{
GstSchedulerClass *sclass;
gboolean res = FALSE;
* Dump the state of the scheduler
*/
void
-gst_scheduler_show (GstScheduler *sched)
+gst_scheduler_show (GstScheduler * sched)
{
GstSchedulerClass *sclass;
* Factory stuff starts here
*
*/
-static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass);
-static void gst_scheduler_factory_init (GstSchedulerFactory *factory);
+static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass);
+static void gst_scheduler_factory_init (GstSchedulerFactory * factory);
static GstPluginFeatureClass *factory_parent_class = NULL;
+
/* static guint gst_scheduler_factory_signals[LAST_SIGNAL] = { 0 }; */
-GType
-gst_scheduler_factory_get_type (void)
+GType
+gst_scheduler_factory_get_type (void)
{
static GType schedulerfactory_type = 0;
(GClassInitFunc) gst_scheduler_factory_class_init,
NULL,
NULL,
- sizeof(GstSchedulerFactory),
+ sizeof (GstSchedulerFactory),
0,
(GInstanceInitFunc) gst_scheduler_factory_init,
NULL
};
- schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
- "GstSchedulerFactory", &schedulerfactory_info, 0);
+ schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
+ "GstSchedulerFactory", &schedulerfactory_info, 0);
}
return schedulerfactory_type;
}
static void
-gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass)
+gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstPluginFeatureClass *gstpluginfeature_class;
- gobject_class = (GObjectClass*)klass;
- gstobject_class = (GstObjectClass*)klass;
- gstpluginfeature_class = (GstPluginFeatureClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstpluginfeature_class = (GstPluginFeatureClass *) klass;
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
}
static void
-gst_scheduler_factory_init (GstSchedulerFactory *factory)
+gst_scheduler_factory_init (GstSchedulerFactory * factory)
{
}
-
+
/**
* gst_scheduler_factory_new:
*
* Returns: a new #GstSchedulerFactory.
*/
-GstSchedulerFactory*
-gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type)
+GstSchedulerFactory *
+gst_scheduler_factory_new (const gchar * name, const gchar * longdesc,
+ GType type)
{
GstSchedulerFactory *factory;
factory = gst_scheduler_factory_find (name);
if (!factory) {
- factory = GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL));
+ factory =
+ GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL));
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
- }
- else {
+ } else {
g_free (factory->longdesc);
}
* Removes the scheduler from the global list.
*/
void
-gst_scheduler_factory_destroy (GstSchedulerFactory *factory)
+gst_scheduler_factory_destroy (GstSchedulerFactory * factory)
{
g_return_if_fail (factory != NULL);
*
* Returns: #GstSchedulerFactory if found, NULL otherwise
*/
-GstSchedulerFactory*
-gst_scheduler_factory_find (const gchar *name)
+GstSchedulerFactory *
+gst_scheduler_factory_find (const gchar * name)
{
GstPluginFeature *feature;
*
* Returns: A new #GstScheduler instance with a reference count of %1.
*/
-GstScheduler*
-gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent)
+GstScheduler *
+gst_scheduler_factory_create (GstSchedulerFactory * factory,
+ GstElement * parent)
{
GstScheduler *sched = NULL;
*
* Returns: A new #GstScheduler instance with a reference count of %1.
*/
-GstScheduler*
-gst_scheduler_factory_make (const gchar *name, GstElement *parent)
+GstScheduler *
+gst_scheduler_factory_make (const gchar * name, GstElement * parent)
{
GstSchedulerFactory *factory;
const gchar *default_name = gst_scheduler_factory_get_default_name ();
if (name)
factory = gst_scheduler_factory_find (name);
- else
- {
+ else {
/* FIXME: do better error handling */
if (default_name == NULL)
g_error ("No default scheduler name - do you have a registry ?");
* Set the default schedulerfactory name.
*/
void
-gst_scheduler_factory_set_default_name (const gchar* name)
+gst_scheduler_factory_set_default_name (const gchar * name)
{
g_free (_default_name);
*
* Returns: the name of the default scheduler.
*/
-const gchar*
+const gchar *
gst_scheduler_factory_get_default_name (void)
{
return _default_name;
#include <gst/gstbin.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SCHEDULER (gst_scheduler_get_type ())
#define GST_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER, GstScheduler))
#define GST_IS_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER))
#define GST_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER,GstSchedulerClass))
#define GST_IS_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER))
#define GST_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER, GstSchedulerClass))
-
-typedef enum {
+ typedef enum
+{
/* this scheduler works with a fixed clock */
- GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST,
+ GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST,
/* padding */
- GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
+ GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
} GstSchedulerFlags;
#define GST_SCHEDULER_PARENT(sched) ((sched)->parent)
/*typedef struct _GstScheduler GstScheduler; */
/*typedef struct _GstSchedulerClass GstSchedulerClass; */
-typedef enum {
+typedef enum
+{
GST_SCHEDULER_STATE_NONE,
GST_SCHEDULER_STATE_RUNNING,
GST_SCHEDULER_STATE_STOPPED,
GST_SCHEDULER_STATE_ERROR
} GstSchedulerState;
-struct _GstScheduler {
- GstObject object;
+struct _GstScheduler
+{
+ GstObject object;
- GstElement *parent;
- GstScheduler *parent_sched;
+ GstElement *parent;
+ GstScheduler *parent_sched;
- GstSchedulerState state;
- GstClock *clock;
- GstClock *current_clock;
+ GstSchedulerState state;
+ GstClock *clock;
+ GstClock *current_clock;
- GList *clock_providers;
- GList *clock_receivers;
+ GList *clock_providers;
+ GList *clock_receivers;
- GList *schedulers;
+ GList *schedulers;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstSchedulerClass {
+struct _GstSchedulerClass
+{
GstObjectClass parent_class;
/* virtual methods */
- void (*setup) (GstScheduler *sched);
- void (*reset) (GstScheduler *sched);
- void (*add_element) (GstScheduler *sched, GstElement *element);
- void (*remove_element) (GstScheduler *sched, GstElement *element);
- void (*add_scheduler) (GstScheduler *sched, GstScheduler *sched2);
- void (*remove_scheduler) (GstScheduler *sched, GstScheduler *sched2);
- GstElementStateReturn (*state_transition) (GstScheduler *sched, GstElement *element, gint transition);
- void (*scheduling_change) (GstScheduler *sched, GstElement *element);
- void (*lock_element) (GstScheduler *sched, GstElement *element);
- void (*unlock_element) (GstScheduler *sched, GstElement *element);
- gboolean (*yield) (GstScheduler *sched, GstElement *element);
- gboolean (*interrupt) (GstScheduler *sched, GstElement *element);
- void (*error) (GstScheduler *sched, GstElement *element);
- void (*pad_link) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
- void (*pad_unlink) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
- void (*pad_select) (GstScheduler *sched, GList *padlist);
- GstClockReturn (*clock_wait) (GstScheduler *sched, GstElement *element,
- GstClockID id, GstClockTimeDiff *jitter);
- GstSchedulerState (*iterate) (GstScheduler *sched);
+ void (*setup) (GstScheduler * sched);
+ void (*reset) (GstScheduler * sched);
+ void (*add_element) (GstScheduler * sched, GstElement * element);
+ void (*remove_element) (GstScheduler * sched, GstElement * element);
+ void (*add_scheduler) (GstScheduler * sched, GstScheduler * sched2);
+ void (*remove_scheduler) (GstScheduler * sched, GstScheduler * sched2);
+ GstElementStateReturn (*state_transition) (GstScheduler * sched,
+ GstElement * element, gint transition);
+ void (*scheduling_change) (GstScheduler * sched, GstElement * element);
+ void (*lock_element) (GstScheduler * sched, GstElement * element);
+ void (*unlock_element) (GstScheduler * sched, GstElement * element);
+ gboolean (*yield) (GstScheduler * sched, GstElement * element);
+ gboolean (*interrupt) (GstScheduler * sched, GstElement * element);
+ void (*error) (GstScheduler * sched, GstElement * element);
+ void (*pad_link) (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad);
+ void (*pad_unlink) (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad);
+ void (*pad_select) (GstScheduler * sched, GList * padlist);
+ GstClockReturn (*clock_wait) (GstScheduler * sched, GstElement * element,
+ GstClockID id, GstClockTimeDiff * jitter);
+ GstSchedulerState (*iterate) (GstScheduler * sched);
/* for debugging */
- void (*show) (GstScheduler *sched);
+ void (*show) (GstScheduler * sched);
/* signals */
- void (*object_sync) (GstScheduler *sched, GstClock *clock, GstObject *object,
- GstClockID id);
+ void (*object_sync) (GstScheduler * sched, GstClock * clock,
+ GstObject * object, GstClockID id);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_scheduler_get_type (void);
-
-
-void gst_scheduler_setup (GstScheduler *sched);
-void gst_scheduler_reset (GstScheduler *sched);
-void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
-void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
-void gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2);
-void gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2);
-GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition);
-void gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element);
-void gst_scheduler_lock_element (GstScheduler *sched, GstElement *element);
-void gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element);
-gboolean gst_scheduler_yield (GstScheduler *sched, GstElement *element);
-gboolean gst_scheduler_interrupt (GstScheduler *sched, GstElement *element);
-void gst_scheduler_error (GstScheduler *sched, GstElement *element);
-void gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
-void gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
-GstPad* gst_scheduler_pad_select (GstScheduler *sched, GList *padlist);
-GstClockReturn gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element,
- GstClockID id, GstClockTimeDiff *jitter);
-gboolean gst_scheduler_iterate (GstScheduler *sched);
-
-void gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock);
-void gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock);
-GstClock* gst_scheduler_get_clock (GstScheduler *sched);
-void gst_scheduler_auto_clock (GstScheduler *sched);
-
-void gst_scheduler_show (GstScheduler *sched);
+GType gst_scheduler_get_type (void);
+
+
+void gst_scheduler_setup (GstScheduler * sched);
+void gst_scheduler_reset (GstScheduler * sched);
+void gst_scheduler_add_element (GstScheduler * sched, GstElement * element);
+void gst_scheduler_remove_element (GstScheduler * sched, GstElement * element);
+void gst_scheduler_add_scheduler (GstScheduler * sched, GstScheduler * sched2);
+void gst_scheduler_remove_scheduler (GstScheduler * sched,
+ GstScheduler * sched2);
+GstElementStateReturn gst_scheduler_state_transition (GstScheduler * sched,
+ GstElement * element, gint transition);
+void gst_scheduler_scheduling_change (GstScheduler * sched,
+ GstElement * element);
+void gst_scheduler_lock_element (GstScheduler * sched, GstElement * element);
+void gst_scheduler_unlock_element (GstScheduler * sched, GstElement * element);
+gboolean gst_scheduler_yield (GstScheduler * sched, GstElement * element);
+gboolean gst_scheduler_interrupt (GstScheduler * sched, GstElement * element);
+void gst_scheduler_error (GstScheduler * sched, GstElement * element);
+void gst_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad);
+void gst_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad);
+GstPad *gst_scheduler_pad_select (GstScheduler * sched, GList * padlist);
+GstClockReturn gst_scheduler_clock_wait (GstScheduler * sched,
+ GstElement * element, GstClockID id, GstClockTimeDiff * jitter);
+gboolean gst_scheduler_iterate (GstScheduler * sched);
+
+void gst_scheduler_use_clock (GstScheduler * sched, GstClock * clock);
+void gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock);
+GstClock *gst_scheduler_get_clock (GstScheduler * sched);
+void gst_scheduler_auto_clock (GstScheduler * sched);
+
+void gst_scheduler_show (GstScheduler * sched);
/*
* creating schedulers
typedef struct _GstSchedulerFactory GstSchedulerFactory;
typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass;
-struct _GstSchedulerFactory {
+struct _GstSchedulerFactory
+{
GstPluginFeature feature;
- gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */
- GType type; /* unique GType of the scheduler */
+ gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */
+ GType type; /* unique GType of the scheduler */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstSchedulerFactoryClass {
+struct _GstSchedulerFactoryClass
+{
GstPluginFeatureClass parent;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_scheduler_factory_get_type (void);
+GType gst_scheduler_factory_get_type (void);
-GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type);
-void gst_scheduler_factory_destroy (GstSchedulerFactory *factory);
+GstSchedulerFactory *gst_scheduler_factory_new (const gchar * name,
+ const gchar * longdesc, GType type);
+void gst_scheduler_factory_destroy (GstSchedulerFactory * factory);
-GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name);
+GstSchedulerFactory *gst_scheduler_factory_find (const gchar * name);
-GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent);
-GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent);
+GstScheduler *gst_scheduler_factory_create (GstSchedulerFactory * factory,
+ GstElement * parent);
+GstScheduler *gst_scheduler_factory_make (const gchar * name,
+ GstElement * parent);
-void gst_scheduler_factory_set_default_name (const gchar* name);
-G_CONST_RETURN gchar* gst_scheduler_factory_get_default_name (void);
+void gst_scheduler_factory_set_default_name (const gchar * name);
+G_CONST_RETURN gchar *gst_scheduler_factory_get_default_name (void);
G_END_DECLS
-
#endif /* __GST_SCHEDULER_H__ */
typedef struct _GstStructureField GstStructureField;
-struct _GstStructureField {
+struct _GstStructureField
+{
GQuark name;
GValue value;
};
#define GST_STRUCTURE_FIELD(structure, index) \
&g_array_index((structure)->fields, GstStructureField, (index))
-static void gst_structure_set_field (GstStructure *structure,
- GstStructureField *field);
-static GstStructureField * gst_structure_get_field (const GstStructure *structure,
- const gchar *fieldname);
-static GstStructureField * gst_structure_id_get_field (const GstStructure *structure,
- GQuark field);
-static void gst_structure_transform_to_string (const GValue *src_value,
- GValue *dest_value);
-static GstStructure * gst_structure_copy_conditional (const GstStructure *structure);
-static gboolean gst_structure_parse_value (gchar *str,
- gchar **after,
- GValue *value,
- GType default_type);
-static gboolean gst_structure_parse_simple_string (gchar *s,
- gchar **end);
+static void gst_structure_set_field (GstStructure * structure,
+ GstStructureField * field);
+static GstStructureField *gst_structure_get_field (const GstStructure *
+ structure, const gchar * fieldname);
+static GstStructureField *gst_structure_id_get_field (const GstStructure *
+ structure, GQuark field);
+static void gst_structure_transform_to_string (const GValue * src_value,
+ GValue * dest_value);
+static GstStructure *gst_structure_copy_conditional (const GstStructure *
+ structure);
+static gboolean gst_structure_parse_value (gchar * str, gchar ** after,
+ GValue * value, GType default_type);
+static gboolean gst_structure_parse_simple_string (gchar * s, gchar ** end);
GType
-gst_structure_get_type(void)
+gst_structure_get_type (void)
{
static GType gst_structure_type;
if (!gst_structure_type) {
- gst_structure_type = g_boxed_type_register_static("GstStructure",
- (GBoxedCopyFunc) gst_structure_copy_conditional,
- (GBoxedFreeFunc) gst_structure_free);
-
- g_value_register_transform_func(gst_structure_type, G_TYPE_STRING,
- gst_structure_transform_to_string);
+ gst_structure_type = g_boxed_type_register_static ("GstStructure",
+ (GBoxedCopyFunc) gst_structure_copy_conditional,
+ (GBoxedFreeFunc) gst_structure_free);
+
+ g_value_register_transform_func (gst_structure_type, G_TYPE_STRING,
+ gst_structure_transform_to_string);
}
-
+
return gst_structure_type;
}
{
GstStructure *structure;
- g_return_val_if_fail(quark != 0, NULL);
+ g_return_val_if_fail (quark != 0, NULL);
- structure = g_new0(GstStructure, 1);
+ structure = g_new0 (GstStructure, 1);
structure->name = quark;
- structure->fields = g_array_new(FALSE,TRUE,sizeof(GstStructureField));
+ structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField));
return structure;
}
* Returns: a new, empty #GstStructure
*/
GstStructure *
-gst_structure_empty_new (const gchar *name)
+gst_structure_empty_new (const gchar * name)
{
GstStructure *structure;
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- structure = g_new0(GstStructure, 1);
- structure->name = g_quark_from_string(name);
- structure->fields = g_array_new(FALSE,TRUE,sizeof(GstStructureField));
+ structure = g_new0 (GstStructure, 1);
+ structure->name = g_quark_from_string (name);
+ structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField));
return structure;
}
*
* Returns: a new #GstStructure
*/
-GstStructure *gst_structure_new(const gchar *name,
- const gchar *firstfield, ...)
+GstStructure *
+gst_structure_new (const gchar * name, const gchar * firstfield, ...)
{
GstStructure *structure;
va_list varargs;
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- va_start(varargs, firstfield);
+ va_start (varargs, firstfield);
- structure = gst_structure_new_valist(name,firstfield,varargs);
+ structure = gst_structure_new_valist (name, firstfield, varargs);
- va_end(varargs);
+ va_end (varargs);
return structure;
}
* Returns: a new #GstStructure
*/
GstStructure *
-gst_structure_new_valist (const gchar *name,
- const gchar *firstfield,
- va_list varargs)
+gst_structure_new_valist (const gchar * name,
+ const gchar * firstfield, va_list varargs)
{
GstStructure *structure;
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- structure = gst_structure_empty_new(name);
- gst_structure_set_valist(structure, firstfield, varargs);
+ structure = gst_structure_empty_new (name);
+ gst_structure_set_valist (structure, firstfield, varargs);
return structure;
}
* Returns: a new #GstStructure.
*/
GstStructure *
-gst_structure_copy (const GstStructure *structure)
+gst_structure_copy (const GstStructure * structure)
{
GstStructure *new_structure;
GstStructureField *field;
int i;
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- new_structure = gst_structure_empty_new(g_quark_to_string(structure->name));
+ new_structure = gst_structure_empty_new (g_quark_to_string (structure->name));
new_structure->name = structure->name;
- for(i=0;i<structure->fields->len;i++){
+ for (i = 0; i < structure->fields->len; i++) {
GstStructureField new_field = { 0 };
- field = GST_STRUCTURE_FIELD(structure, i);
+ field = GST_STRUCTURE_FIELD (structure, i);
new_field.name = field->name;
gst_value_init_and_copy (&new_field.value, &field->value);
- g_array_append_val(new_structure->fields, new_field);
+ g_array_append_val (new_structure->fields, new_field);
}
return new_structure;
* Frees a #GstStructure and all its fields and values.
*/
void
-gst_structure_free (GstStructure *structure)
+gst_structure_free (GstStructure * structure)
{
GstStructureField *field;
int i;
- g_return_if_fail(structure != NULL);
+ g_return_if_fail (structure != NULL);
- for(i=0;i<structure->fields->len;i++){
- field = GST_STRUCTURE_FIELD(structure, i);
+ for (i = 0; i < structure->fields->len; i++) {
+ field = GST_STRUCTURE_FIELD (structure, i);
- if(G_IS_VALUE(&field->value)){
- g_value_unset(&field->value);
+ if (G_IS_VALUE (&field->value)) {
+ g_value_unset (&field->value);
}
}
#ifdef USE_POISONING
- memset (structure, 0xff, sizeof(GstStructure));
+ memset (structure, 0xff, sizeof (GstStructure));
#endif
- g_free(structure);
+ g_free (structure);
}
/**
* Returns: the name of the structure.
*/
const gchar *
-gst_structure_get_name (const GstStructure *structure)
+gst_structure_get_name (const GstStructure * structure)
{
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- return g_quark_to_string(structure->name);
+ return g_quark_to_string (structure->name);
}
/**
* provided is copied before being used.
*/
void
-gst_structure_set_name (GstStructure *structure, const gchar *name)
+gst_structure_set_name (GstStructure * structure, const gchar * name)
{
- g_return_if_fail(structure != NULL);
- g_return_if_fail(name != NULL);
+ g_return_if_fail (structure != NULL);
+ g_return_if_fail (name != NULL);
- structure->name = g_quark_from_string(name);
+ structure->name = g_quark_from_string (name);
}
/**
* value is freed.
*/
void
-gst_structure_id_set_value(GstStructure *structure,
- GQuark field,
- const GValue *value)
+gst_structure_id_set_value (GstStructure * structure,
+ GQuark field, const GValue * value)
{
- GstStructureField gsfield = { 0, { 0, } };
+ GstStructureField gsfield = { 0, {0,} };
- g_return_if_fail(structure != NULL);
- g_return_if_fail(G_IS_VALUE(value));
+ g_return_if_fail (structure != NULL);
+ g_return_if_fail (G_IS_VALUE (value));
gsfield.name = field;
gst_value_init_and_copy (&gsfield.value, value);
- gst_structure_set_field(structure, &gsfield);
+ gst_structure_set_field (structure, &gsfield);
}
/**
* value is freed.
*/
void
-gst_structure_set_value(GstStructure *structure,
- const gchar *fieldname,
- const GValue *value)
+gst_structure_set_value (GstStructure * structure,
+ const gchar * fieldname, const GValue * value)
{
- g_return_if_fail(structure != NULL);
- g_return_if_fail(fieldname != NULL);
- g_return_if_fail(G_IS_VALUE(value));
+ g_return_if_fail (structure != NULL);
+ g_return_if_fail (fieldname != NULL);
+ g_return_if_fail (G_IS_VALUE (value));
- gst_structure_id_set_value(structure, g_quark_from_string(fieldname), value);
+ gst_structure_id_set_value (structure, g_quark_from_string (fieldname),
+ value);
}
/**
* (as a GType), value. The last variable argument should be NULL.
*/
void
-gst_structure_set(GstStructure *structure,
- const gchar *field, ...)
+gst_structure_set (GstStructure * structure, const gchar * field, ...)
{
va_list varargs;
- g_return_if_fail(structure != NULL);
+ g_return_if_fail (structure != NULL);
- va_start(varargs, field);
+ va_start (varargs, field);
- gst_structure_set_valist(structure,field,varargs);
+ gst_structure_set_valist (structure, field, varargs);
- va_end(varargs);
+ va_end (varargs);
}
/**
* va_list form of #gst_structure_set.
*/
void
-gst_structure_set_valist(GstStructure *structure,
- const gchar *fieldname,
- va_list varargs)
+gst_structure_set_valist (GstStructure * structure,
+ const gchar * fieldname, va_list varargs)
{
GType type;
int i;
double d;
char *s;
- g_return_if_fail(structure != NULL);
+ g_return_if_fail (structure != NULL);
- while(fieldname){
+ while (fieldname) {
GstStructureField field = { 0 };
- field.name = g_quark_from_string(fieldname);
+ field.name = g_quark_from_string (fieldname);
- type = va_arg (varargs, GType);
+ type = va_arg (varargs, GType);
- switch(type){
+ switch (type) {
case G_TYPE_INT:
- i = va_arg(varargs, int);
- g_value_init(&field.value, G_TYPE_INT);
- g_value_set_int(&field.value, i);
+ i = va_arg (varargs, int);
+
+ g_value_init (&field.value, G_TYPE_INT);
+ g_value_set_int (&field.value, i);
break;
case G_TYPE_DOUBLE:
- d = va_arg(varargs, double);
- g_value_init(&field.value, G_TYPE_DOUBLE);
- g_value_set_double(&field.value, d);
+ d = va_arg (varargs, double);
+
+ g_value_init (&field.value, G_TYPE_DOUBLE);
+ g_value_set_double (&field.value, d);
break;
case G_TYPE_BOOLEAN:
- i = va_arg(varargs, int);
- g_value_init(&field.value, G_TYPE_BOOLEAN);
- g_value_set_boolean(&field.value, i);
+ i = va_arg (varargs, int);
+
+ g_value_init (&field.value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&field.value, i);
break;
case G_TYPE_STRING:
- s = va_arg(varargs, char *);
- g_value_init(&field.value, G_TYPE_STRING);
- g_value_set_string(&field.value, s);
+ s = va_arg (varargs, char *);
+
+ g_value_init (&field.value, G_TYPE_STRING);
+ g_value_set_string (&field.value, s);
break;
default:
- if(type == GST_TYPE_FOURCC){
- i = va_arg(varargs, int);
- g_value_init(&field.value, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&field.value, i);
- } else if (type == GST_TYPE_INT_RANGE){
- int min, max;
- min = va_arg(varargs, int);
- max = va_arg(varargs, int);
- g_value_init(&field.value, GST_TYPE_INT_RANGE);
- gst_value_set_int_range(&field.value, min, max);
- } else if (type == GST_TYPE_DOUBLE_RANGE){
- double min, max;
- min = va_arg(varargs, double);
- max = va_arg(varargs, double);
- g_value_init(&field.value, GST_TYPE_DOUBLE_RANGE);
- gst_value_set_double_range(&field.value, min, max);
+ if (type == GST_TYPE_FOURCC) {
+ i = va_arg (varargs, int);
+
+ g_value_init (&field.value, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&field.value, i);
+ } else if (type == GST_TYPE_INT_RANGE) {
+ int min, max;
+ min = va_arg (varargs, int);
+ max = va_arg (varargs, int);
+
+ g_value_init (&field.value, GST_TYPE_INT_RANGE);
+ gst_value_set_int_range (&field.value, min, max);
+ } else if (type == GST_TYPE_DOUBLE_RANGE) {
+ double min, max;
+ min = va_arg (varargs, double);
+ max = va_arg (varargs, double);
+
+ g_value_init (&field.value, GST_TYPE_DOUBLE_RANGE);
+ gst_value_set_double_range (&field.value, min, max);
} else {
- g_critical("unimplemented vararg field type %d\n", (int)type);
- return;
+ g_critical ("unimplemented vararg field type %d\n", (int) type);
+ return;
}
break;
}
- gst_structure_set_field(structure, &field);
+ gst_structure_set_field (structure, &field);
fieldname = va_arg (varargs, gchar *);
}
* #gst_structure_set() is recommended instead of this one.
*/
static void
-gst_structure_set_field(GstStructure *structure,
- GstStructureField *field)
+gst_structure_set_field (GstStructure * structure, GstStructureField * field)
{
GstStructureField *f;
int i;
- for(i=0;i<structure->fields->len;i++){
- f = GST_STRUCTURE_FIELD(structure, i);
+ for (i = 0; i < structure->fields->len; i++) {
+ f = GST_STRUCTURE_FIELD (structure, i);
- if(f->name == field->name){
- g_value_unset(&f->value);
- memcpy(f,field,sizeof(GstStructureField));
+ if (f->name == field->name) {
+ g_value_unset (&f->value);
+ memcpy (f, field, sizeof (GstStructureField));
return;
}
}
- g_array_append_val(structure->fields, *field);
+ g_array_append_val (structure->fields, *field);
}
/* FIXME: is this private ? if so remove gtk-doc
* Returns: the #GstStructureField with the given ID
*/
static GstStructureField *
-gst_structure_id_get_field(const GstStructure *structure,
- GQuark field_id)
+gst_structure_id_get_field (const GstStructure * structure, GQuark field_id)
{
GstStructureField *field;
int i;
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- for(i=0;i<structure->fields->len;i++){
- field = GST_STRUCTURE_FIELD(structure, i);
+ for (i = 0; i < structure->fields->len; i++) {
+ field = GST_STRUCTURE_FIELD (structure, i);
- if(field->name == field_id) return field;
+ if (field->name == field_id)
+ return field;
}
return NULL;
* Returns: the #GstStructureField with the given name
*/
static GstStructureField *
-gst_structure_get_field(const GstStructure *structure,
- const gchar *fieldname)
+gst_structure_get_field (const GstStructure * structure,
+ const gchar * fieldname)
{
- g_return_val_if_fail(structure != NULL, NULL);
- g_return_val_if_fail(fieldname != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
+ g_return_val_if_fail (fieldname != NULL, NULL);
- return gst_structure_id_get_field(structure,
- g_quark_from_string(fieldname));
+ return gst_structure_id_get_field (structure,
+ g_quark_from_string (fieldname));
}
/**
* Returns: the #GValue corresponding to the field with the given name.
*/
const GValue *
-gst_structure_get_value(const GstStructure *structure,
- const gchar *fieldname)
+gst_structure_get_value (const GstStructure * structure,
+ const gchar * fieldname)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, NULL);
- g_return_val_if_fail(fieldname != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
+ g_return_val_if_fail (fieldname != NULL, NULL);
- field = gst_structure_get_field(structure, fieldname);
- if(field == NULL) return NULL;
+ field = gst_structure_get_field (structure, fieldname);
+ if (field == NULL)
+ return NULL;
return &field->value;
}
* identifier.
*/
const GValue *
-gst_structure_id_get_value(const GstStructure *structure, GQuark field)
+gst_structure_id_get_value (const GstStructure * structure, GQuark field)
{
GstStructureField *gsfield;
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- gsfield = gst_structure_id_get_field(structure, field);
- if(gsfield == NULL) return NULL;
+ gsfield = gst_structure_id_get_field (structure, field);
+ if (gsfield == NULL)
+ return NULL;
return &gsfield->value;
}
* name does not exist, the structure is unchanged.
*/
void
-gst_structure_remove_field(GstStructure *structure,
- const gchar *fieldname)
+gst_structure_remove_field (GstStructure * structure, const gchar * fieldname)
{
GstStructureField *field;
GQuark id;
int i;
- g_return_if_fail(structure != NULL);
- g_return_if_fail(fieldname != NULL);
+ g_return_if_fail (structure != NULL);
+ g_return_if_fail (fieldname != NULL);
- id = g_quark_from_string(fieldname);
+ id = g_quark_from_string (fieldname);
- for(i=0;i<structure->fields->len;i++){
- field = GST_STRUCTURE_FIELD(structure, i);
+ for (i = 0; i < structure->fields->len; i++) {
+ field = GST_STRUCTURE_FIELD (structure, i);
- if(field->name == id){
- if(G_IS_VALUE(&field->value)){
- g_value_unset(&field->value);
+ if (field->name == id) {
+ if (G_IS_VALUE (&field->value)) {
+ g_value_unset (&field->value);
}
- structure->fields = g_array_remove_index(structure->fields, i);
+ structure->fields = g_array_remove_index (structure->fields, i);
return;
}
}
* Removes the field with the given names. If a field does not exist, the
* argument is ignored.
*/
-void
-gst_structure_remove_fields(GstStructure *structure,
- const gchar *fieldname, ...)
+void
+gst_structure_remove_fields (GstStructure * structure,
+ const gchar * fieldname, ...)
{
va_list varargs;
g_return_if_fail (structure != NULL);
g_return_if_fail (fieldname != NULL);
- va_start(varargs, fieldname);
+ va_start (varargs, fieldname);
gst_structure_remove_fields_valist (structure, fieldname, varargs);
- va_end(varargs);
+ va_end (varargs);
}
/**
* Removes the field with the given names. If a field does not exist, the
* argument is ignored.
*/
-void
-gst_structure_remove_fields_valist (GstStructure *structure,
- const gchar *fieldname,
- va_list varargs)
+void
+gst_structure_remove_fields_valist (GstStructure * structure,
+ const gchar * fieldname, va_list varargs)
{
gchar *field = (gchar *) fieldname;
+
g_return_if_fail (structure != NULL);
g_return_if_fail (fieldname != NULL);
while (field) {
gst_structure_remove_field (structure, field);
- field = va_arg (varargs, char *);
+ field = va_arg (varargs, char *);
}
}
* Removes all fields in a GstStructure.
*/
void
-gst_structure_remove_all_fields (GstStructure *structure)
+gst_structure_remove_all_fields (GstStructure * structure)
{
GstStructureField *field;
int i;
- g_return_if_fail(structure != NULL);
+ g_return_if_fail (structure != NULL);
- for (i = structure->fields->len - 1; i >= 0; i-- ) {
- field = GST_STRUCTURE_FIELD(structure, i);
+ for (i = structure->fields->len - 1; i >= 0; i--) {
+ field = GST_STRUCTURE_FIELD (structure, i);
if (G_IS_VALUE (&field->value)) {
- g_value_unset(&field->value);
+ g_value_unset (&field->value);
}
structure->fields = g_array_remove_index (structure->fields, i);
}
* Returns: the #GValue of the field
*/
GType
-gst_structure_get_field_type (const GstStructure *structure,
- const gchar *fieldname)
+gst_structure_get_field_type (const GstStructure * structure,
+ const gchar * fieldname)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, G_TYPE_INVALID);
- g_return_val_if_fail(fieldname != NULL, G_TYPE_INVALID);
+ g_return_val_if_fail (structure != NULL, G_TYPE_INVALID);
+ g_return_val_if_fail (fieldname != NULL, G_TYPE_INVALID);
- field = gst_structure_get_field(structure, fieldname);
- if(field == NULL) return G_TYPE_INVALID;
+ field = gst_structure_get_field (structure, fieldname);
+ if (field == NULL)
+ return G_TYPE_INVALID;
- return G_VALUE_TYPE(&field->value);
+ return G_VALUE_TYPE (&field->value);
}
/**
* Returns: the number of fields in the structure
*/
gint
-gst_structure_n_fields (const GstStructure *structure)
+gst_structure_n_fields (const GstStructure * structure)
{
- g_return_val_if_fail(structure != NULL, 0);
+ g_return_val_if_fail (structure != NULL, 0);
return structure->fields->len;
}
* FALSE otherwise.
*/
gboolean
-gst_structure_foreach (GstStructure *structure,
- GstStructureForeachFunc func,
- gpointer user_data)
+gst_structure_foreach (GstStructure * structure,
+ GstStructureForeachFunc func, gpointer user_data)
{
int i;
GstStructureField *field;
gboolean ret;
- for(i=0;i<structure->fields->len;i++){
- field = GST_STRUCTURE_FIELD(structure, i);
+ for (i = 0; i < structure->fields->len; i++) {
+ field = GST_STRUCTURE_FIELD (structure, i);
ret = func (field->name, &field->value, user_data);
- if (!ret) return FALSE;
+ if (!ret)
+ return FALSE;
}
return TRUE;
* Returns: TRUE if the structure contains a field with the given name
*/
gboolean
-gst_structure_has_field(const GstStructure *structure,
- const gchar *fieldname)
+gst_structure_has_field (const GstStructure * structure,
+ const gchar * fieldname)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, 0);
- g_return_val_if_fail(fieldname != NULL, 0);
+ g_return_val_if_fail (structure != NULL, 0);
+ g_return_val_if_fail (fieldname != NULL, 0);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
return (field != NULL);
}
* Returns: TRUE if the structure contains a field with the given name and type
*/
gboolean
-gst_structure_has_field_typed(const GstStructure *structure, const gchar *fieldname,
- GType type)
+gst_structure_has_field_typed (const GstStructure * structure,
+ const gchar * fieldname, GType type)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, 0);
- g_return_val_if_fail(fieldname != NULL, 0);
+ g_return_val_if_fail (structure != NULL, 0);
+ g_return_val_if_fail (fieldname != NULL, 0);
- field = gst_structure_get_field(structure, fieldname);
- if(field == NULL) return FALSE;
+ field = gst_structure_get_field (structure, fieldname);
+ if (field == NULL)
+ return FALSE;
- return (G_VALUE_TYPE(&field->value) == type);
+ return (G_VALUE_TYPE (&field->value) == type);
}
* Returns: TRUE if the value could be set correctly
*/
gboolean
-gst_structure_get_boolean(const GstStructure *structure,
- const gchar *fieldname,
- gboolean *value)
+gst_structure_get_boolean (const GstStructure * structure,
+ const gchar * fieldname, gboolean * value)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, FALSE);
- g_return_val_if_fail(fieldname != NULL, FALSE);
+ g_return_val_if_fail (structure != NULL, FALSE);
+ g_return_val_if_fail (fieldname != NULL, FALSE);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
- if(field == NULL) return FALSE;
- if(!G_VALUE_HOLDS_BOOLEAN(&field->value))return FALSE;
+ if (field == NULL)
+ return FALSE;
+ if (!G_VALUE_HOLDS_BOOLEAN (&field->value))
+ return FALSE;
- *value = g_value_get_boolean(&field->value);
+ *value = g_value_get_boolean (&field->value);
return TRUE;
}
* Returns: TRUE if the value could be set correctly
*/
gboolean
-gst_structure_get_int(const GstStructure *structure,
- const gchar *fieldname,
- gint *value)
+gst_structure_get_int (const GstStructure * structure,
+ const gchar * fieldname, gint * value)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, FALSE);
- g_return_val_if_fail(fieldname != NULL, FALSE);
- g_return_val_if_fail(value != NULL, FALSE);
+ g_return_val_if_fail (structure != NULL, FALSE);
+ g_return_val_if_fail (fieldname != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
- if(field == NULL) return FALSE;
- if(!G_VALUE_HOLDS_INT(&field->value))return FALSE;
+ if (field == NULL)
+ return FALSE;
+ if (!G_VALUE_HOLDS_INT (&field->value))
+ return FALSE;
- *value = g_value_get_int(&field->value);
+ *value = g_value_get_int (&field->value);
return TRUE;
}
* Returns: TRUE if the value could be set correctly
*/
gboolean
-gst_structure_get_fourcc(const GstStructure *structure,
- const gchar *fieldname,
- guint32 *value)
+gst_structure_get_fourcc (const GstStructure * structure,
+ const gchar * fieldname, guint32 * value)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, FALSE);
- g_return_val_if_fail(fieldname != NULL, FALSE);
- g_return_val_if_fail(value != NULL, FALSE);
+ g_return_val_if_fail (structure != NULL, FALSE);
+ g_return_val_if_fail (fieldname != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
- if(field == NULL) return FALSE;
- if(!GST_VALUE_HOLDS_FOURCC(&field->value))return FALSE;
+ if (field == NULL)
+ return FALSE;
+ if (!GST_VALUE_HOLDS_FOURCC (&field->value))
+ return FALSE;
*value = gst_value_get_fourcc (&field->value);
* Returns: TRUE if the value could be set correctly
*/
gboolean
-gst_structure_get_double(const GstStructure *structure,
- const gchar *fieldname,
- gdouble *value)
+gst_structure_get_double (const GstStructure * structure,
+ const gchar * fieldname, gdouble * value)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, FALSE);
- g_return_val_if_fail(fieldname != NULL, FALSE);
- g_return_val_if_fail(value != NULL, FALSE);
+ g_return_val_if_fail (structure != NULL, FALSE);
+ g_return_val_if_fail (fieldname != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
- if(field == NULL) return FALSE;
- if(!G_VALUE_HOLDS_DOUBLE(&field->value))return FALSE;
+ if (field == NULL)
+ return FALSE;
+ if (!G_VALUE_HOLDS_DOUBLE (&field->value))
+ return FALSE;
- *value = g_value_get_double(&field->value);
+ *value = g_value_get_double (&field->value);
return TRUE;
}
* Returns: a pointer to the string
*/
const gchar *
-gst_structure_get_string (const GstStructure *structure,
- const gchar *fieldname)
+gst_structure_get_string (const GstStructure * structure,
+ const gchar * fieldname)
{
GstStructureField *field;
- g_return_val_if_fail(structure != NULL, NULL);
- g_return_val_if_fail(fieldname != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
+ g_return_val_if_fail (fieldname != NULL, NULL);
- field = gst_structure_get_field(structure, fieldname);
+ field = gst_structure_get_field (structure, fieldname);
- if(field == NULL) return FALSE;
- if(!G_VALUE_HOLDS_STRING(&field->value))return FALSE;
+ if (field == NULL)
+ return FALSE;
+ if (!G_VALUE_HOLDS_STRING (&field->value))
+ return FALSE;
- return g_value_get_string(&field->value);
+ return g_value_get_string (&field->value);
}
-typedef struct _GstStructureAbbreviation {
+typedef struct _GstStructureAbbreviation
+{
char *type_name;
GType type;
} GstStructureAbbreviation;
static GstStructureAbbreviation gst_structure_abbrs[] = {
- { "int", G_TYPE_INT },
- { "i", G_TYPE_INT },
- { "float", G_TYPE_FLOAT },
- { "f", G_TYPE_FLOAT },
- { "double", G_TYPE_DOUBLE },
- { "d", G_TYPE_DOUBLE },
-//{ "fourcc", GST_TYPE_FOURCC },
- { "boolean", G_TYPE_BOOLEAN },
- { "bool", G_TYPE_BOOLEAN },
- { "b", G_TYPE_BOOLEAN },
- { "string", G_TYPE_STRING },
- { "str", G_TYPE_STRING },
- { "s", G_TYPE_STRING }
+ {"int", G_TYPE_INT},
+ {"i", G_TYPE_INT},
+ {"float", G_TYPE_FLOAT},
+ {"f", G_TYPE_FLOAT},
+ {"double", G_TYPE_DOUBLE},
+ {"d", G_TYPE_DOUBLE},
+//{ "fourcc", GST_TYPE_FOURCC },
+ {"boolean", G_TYPE_BOOLEAN},
+ {"bool", G_TYPE_BOOLEAN},
+ {"b", G_TYPE_BOOLEAN},
+ {"string", G_TYPE_STRING},
+ {"str", G_TYPE_STRING},
+ {"s", G_TYPE_STRING}
};
static GType
{
int i;
- g_return_val_if_fail(type_name != NULL, G_TYPE_INVALID);
+ g_return_val_if_fail (type_name != NULL, G_TYPE_INVALID);
- for(i=0;i<G_N_ELEMENTS(gst_structure_abbrs);i++){
- if(strcmp(type_name,gst_structure_abbrs[i].type_name)==0){
+ for (i = 0; i < G_N_ELEMENTS (gst_structure_abbrs); i++) {
+ if (strcmp (type_name, gst_structure_abbrs[i].type_name) == 0) {
return gst_structure_abbrs[i].type;
}
}
/* FIXME shouldn't be a special case */
- if (strcmp (type_name,"fourcc") == 0 || strcmp (type_name, "4") == 0) {
+ if (strcmp (type_name, "fourcc") == 0 || strcmp (type_name, "4") == 0) {
return GST_TYPE_FOURCC;
}
{
int i;
- g_return_val_if_fail(type != G_TYPE_INVALID, NULL);
+ g_return_val_if_fail (type != G_TYPE_INVALID, NULL);
- for(i=0;i<G_N_ELEMENTS(gst_structure_abbrs);i++){
- if(type == gst_structure_abbrs[i].type){
+ for (i = 0; i < G_N_ELEMENTS (gst_structure_abbrs); i++) {
+ if (type == gst_structure_abbrs[i].type) {
return gst_structure_abbrs[i].type_name;
}
}
return "fourcc";
}
- return g_type_name(type);
+ return g_type_name (type);
}
#define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
* Returns: a pointer to string allocated by g_malloc()
*/
gchar *
-gst_structure_to_string (const GstStructure *structure)
+gst_structure_to_string (const GstStructure * structure)
{
GstStructureField *field;
GString *s;
int i;
-
+
/* NOTE: This function is potentially called by the debug system,
* so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
* should be careful to avoid recursion. This includes any functions
* called by gst_structure_to_string. In particular, calls should
* not use the GST_PTR_FORMAT extension. */
- g_return_val_if_fail(structure != NULL, NULL);
+ g_return_val_if_fail (structure != NULL, NULL);
- s = g_string_new("");
+ s = g_string_new ("");
/* FIXME this string may need to be escaped */
- g_string_append_printf(s, "%s", g_quark_to_string(structure->name));
- for(i=0;i<structure->fields->len;i++) {
+ g_string_append_printf (s, "%s", g_quark_to_string (structure->name));
+ for (i = 0; i < structure->fields->len; i++) {
char *t;
GType type;
- field = GST_STRUCTURE_FIELD(structure, i);
+ field = GST_STRUCTURE_FIELD (structure, i);
t = gst_value_serialize (&field->value);
type = G_VALUE_TYPE (&field->value);
if (type == GST_TYPE_LIST) {
GArray *array = g_value_peek_pointer (&field->value);
- if (array->len > 0){
- GValue *value = &g_array_index (array, GValue, 0);
+
+ if (array->len > 0) {
+ GValue *value = &g_array_index (array, GValue, 0);
type = G_VALUE_TYPE (value);
} else {
type = G_TYPE_INT;
}
- } else if (G_VALUE_TYPE(&field->value) == GST_TYPE_INT_RANGE) {
+ } else if (G_VALUE_TYPE (&field->value) == GST_TYPE_INT_RANGE) {
type = G_TYPE_INT;
- } else if (G_VALUE_TYPE(&field->value) == GST_TYPE_DOUBLE_RANGE) {
+ } else if (G_VALUE_TYPE (&field->value) == GST_TYPE_DOUBLE_RANGE) {
type = G_TYPE_DOUBLE;
}
- g_string_append_printf(s, ", %s=(%s)%s", g_quark_to_string(field->name),
- gst_structure_to_abbr(type), t);
- g_free(t);
+ g_string_append_printf (s, ", %s=(%s)%s", g_quark_to_string (field->name),
+ gst_structure_to_abbr (type), t);
+ g_free (t);
}
- return g_string_free(s, FALSE);
+ return g_string_free (s, FALSE);
}
/*
* THIS FUNCTION MODIFIES THE STRING AND DETECTS INSIDE A NONTERMINATED STRING
*/
static gboolean
-gst_structure_parse_string (gchar *s, gchar **end, gchar **next)
+gst_structure_parse_string (gchar * s, gchar ** end, gchar ** next)
{
gchar *w;
- if (*s == 0) return FALSE;
+ if (*s == 0)
+ return FALSE;
if (*s != '"') {
int ret;
w = s;
s++;
while (*s != '"') {
- if (*s == 0) return FALSE;
+ if (*s == 0)
+ return FALSE;
if (*s == '\\') {
s++;
}
static gboolean
-gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type)
+gst_structure_parse_range (gchar * s, gchar ** after, GValue * value,
+ GType type)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
gboolean ret;
- if (*s != '[') return FALSE;
+ if (*s != '[')
+ return FALSE;
s++;
- ret = gst_structure_parse_value(s, &s, &value1, type);
- if (ret == FALSE) return FALSE;
+ ret = gst_structure_parse_value (s, &s, &value1, type);
+ if (ret == FALSE)
+ return FALSE;
- while (g_ascii_isspace (*s)) s++;
-
- if (*s != ',') return FALSE;
+ while (g_ascii_isspace (*s))
+ s++;
+
+ if (*s != ',')
+ return FALSE;
s++;
- while (g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
- ret = gst_structure_parse_value(s, &s, &value2, type);
- if (ret == FALSE) return FALSE;
+ ret = gst_structure_parse_value (s, &s, &value2, type);
+ if (ret == FALSE)
+ return FALSE;
- while (g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
- if (*s != ']') return FALSE;
+ if (*s != ']')
+ return FALSE;
s++;
- if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2)) return FALSE;
-
+ if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2))
+ return FALSE;
+
if (G_VALUE_TYPE (&value1) == G_TYPE_DOUBLE) {
range_type = GST_TYPE_DOUBLE_RANGE;
} else if (G_VALUE_TYPE (&value1) == G_TYPE_INT) {
return FALSE;
}
- g_value_init(value, range_type);
+ g_value_init (value, range_type);
if (range_type == GST_TYPE_DOUBLE_RANGE) {
- gst_value_set_double_range(value, g_value_get_double(&value1),
- g_value_get_double(&value2));
+ gst_value_set_double_range (value, g_value_get_double (&value1),
+ g_value_get_double (&value2));
} else {
- gst_value_set_int_range(value, g_value_get_int(&value1),
- g_value_get_int(&value2));
+ gst_value_set_int_range (value, g_value_get_int (&value1),
+ g_value_get_int (&value2));
}
*after = s;
}
static gboolean
-gst_structure_parse_list (gchar *s, gchar **after, GValue *value, GType type)
+gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type)
{
GValue list_value = { 0 };
gboolean ret;
GArray *array;
- g_value_init(value, GST_TYPE_LIST);
+ g_value_init (value, GST_TYPE_LIST);
array = g_value_peek_pointer (value);
- if (*s != '{') return FALSE;
+ if (*s != '{')
+ return FALSE;
s++;
- while (g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
if (*s == '}') {
s++;
*after = s;
return TRUE;
}
- ret = gst_structure_parse_value(s, &s, &list_value, type);
- if (ret == FALSE) return FALSE;
-
+ ret = gst_structure_parse_value (s, &s, &list_value, type);
+ if (ret == FALSE)
+ return FALSE;
+
g_array_append_val (array, list_value);
- while (g_ascii_isspace (*s)) s++;
-
+ while (g_ascii_isspace (*s))
+ s++;
+
while (*s != '}') {
- if (*s != ',') return FALSE;
+ if (*s != ',')
+ return FALSE;
s++;
- while (g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
memset (&list_value, 0, sizeof (list_value));
- ret = gst_structure_parse_value(s, &s, &list_value, type);
- if (ret == FALSE) return FALSE;
+ ret = gst_structure_parse_value (s, &s, &list_value, type);
+ if (ret == FALSE)
+ return FALSE;
g_array_append_val (array, list_value);
- while (g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
}
s++;
}
static gboolean
-gst_structure_parse_simple_string (gchar *str, gchar **end)
+gst_structure_parse_simple_string (gchar * str, gchar ** end)
{
char *s = str;
- while(GST_ASCII_IS_STRING(*s)){
+ while (GST_ASCII_IS_STRING (*s)) {
s++;
}
}
static gboolean
-gst_structure_parse_field (gchar *str,
- gchar **after,
- GstStructureField *field)
+gst_structure_parse_field (gchar * str,
+ gchar ** after, GstStructureField * field)
{
gchar *name;
gchar *name_end;
s = str;
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
name = s;
- if (!gst_structure_parse_simple_string (s, &name_end)) return FALSE;
+ if (!gst_structure_parse_simple_string (s, &name_end))
+ return FALSE;
s = name_end;
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
- if (*s != '=') return FALSE;
+ if (*s != '=')
+ return FALSE;
s++;
c = *name_end;
}
static gboolean
-gst_structure_parse_value (gchar *str,
- gchar **after,
- GValue *value,
- GType default_type)
+gst_structure_parse_value (gchar * str,
+ gchar ** after, GValue * value, GType default_type)
{
gchar *type_name;
gchar *type_end;
s = str;
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
type_name = NULL;
if (*s == '(') {
type = G_TYPE_INVALID;
s++;
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
type_name = s;
- if (!gst_structure_parse_simple_string (s, &type_end)) return FALSE;
+ if (!gst_structure_parse_simple_string (s, &type_end))
+ return FALSE;
s = type_end;
- while(g_ascii_isspace (*s)) s++;
- if (*s != ')') return FALSE;
+ while (g_ascii_isspace (*s))
+ s++;
+ if (*s != ')')
+ return FALSE;
s++;
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
c = *type_end;
*type_end = 0;
- type = gst_structure_from_abbr(type_name);
+ type = gst_structure_from_abbr (type_name);
*type_end = c;
- if (type == G_TYPE_INVALID) return FALSE;
+ if (type == G_TYPE_INVALID)
+ return FALSE;
}
- while(g_ascii_isspace (*s)) s++;
+ while (g_ascii_isspace (*s))
+ s++;
if (*s == '[') {
ret = gst_structure_parse_range (s, &s, value, type);
} else if (*s == '{') {
ret = gst_structure_parse_list (s, &s, value, type);
} else {
value_s = s;
- if (!gst_structure_parse_string (s, &value_end, &s)) return FALSE;
+ if (!gst_structure_parse_string (s, &value_end, &s))
+ return FALSE;
c = *value_end;
*value_end = 0;
GType try_types[] = { G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING };
int i;
- for(i=0;i<3;i++) {
- g_value_init(value, try_types[i]);
+ for (i = 0; i < 3; i++) {
+ g_value_init (value, try_types[i]);
ret = gst_value_deserialize (value, value_s);
- if (ret) break;
- g_value_unset(value);
+ if (ret)
+ break;
+ g_value_unset (value);
}
} else {
- g_value_init(value, type);
+ g_value_init (value, type);
ret = gst_value_deserialize (value, value_s);
}
*value_end = c;
}
-
+
*after = s;
return ret;
* Returns: a new #GstStructure
*/
GstStructure *
-gst_structure_from_string (const gchar *string,
- gchar **end)
+gst_structure_from_string (const gchar * string, gchar ** end)
{
char *name;
char *copy;
GstStructure *structure = NULL;
GstStructureField field = { 0 };
- g_return_val_if_fail(string != NULL, NULL);
+ g_return_val_if_fail (string != NULL, NULL);
- copy = g_strdup(string);
+ copy = g_strdup (string);
r = copy;
name = r;
if (!gst_structure_parse_string (r, &w, &r))
goto error;
-
- while (g_ascii_isspace(*r)) r++;
- if(*r != 0 && *r != ';' && *r != ',') goto error;
+
+ while (g_ascii_isspace (*r))
+ r++;
+ if (*r != 0 && *r != ';' && *r != ',')
+ goto error;
save = *w;
*w = 0;
- structure = gst_structure_empty_new(name);
+ structure = gst_structure_empty_new (name);
*w = save;
- while (*r && (*r != ';')){
- if(*r != ',')
+ while (*r && (*r != ';')) {
+ if (*r != ',')
goto error;
r++;
- while (*r && g_ascii_isspace(*r)) r++;
+ while (*r && g_ascii_isspace (*r))
+ r++;
- memset(&field,0,sizeof(field));
+ memset (&field, 0, sizeof (field));
if (!gst_structure_parse_field (r, &r, &field))
goto error;
- gst_structure_set_field(structure, &field);
- while (*r && g_ascii_isspace(*r)) r++;
+ gst_structure_set_field (structure, &field);
+ while (*r && g_ascii_isspace (*r))
+ r++;
}
- if (end) *end = (char *)string + (r - copy);
+ if (end)
+ *end = (char *) string + (r - copy);
g_free (copy);
return structure;
}
static void
-gst_structure_transform_to_string(const GValue *src_value,
- GValue *dest_value)
+gst_structure_transform_to_string (const GValue * src_value,
+ GValue * dest_value)
{
- g_return_if_fail(src_value != NULL);
- g_return_if_fail(dest_value != NULL);
+ g_return_if_fail (src_value != NULL);
+ g_return_if_fail (dest_value != NULL);
dest_value->data[0].v_pointer =
- gst_structure_to_string (src_value->data[0].v_pointer);
+ gst_structure_to_string (src_value->data[0].v_pointer);
}
static GstStructure *
-gst_structure_copy_conditional (const GstStructure *structure)
+gst_structure_copy_conditional (const GstStructure * structure)
{
- if (structure) return gst_structure_copy (structure);
+ if (structure)
+ return gst_structure_copy (structure);
return NULL;
}
-
#include <glib-object.h>
G_BEGIN_DECLS
-
#define GST_TYPE_STRUCTURE (gst_structure_get_type ())
#define GST_STRUCTURE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_STRUCTURE, GstStructure))
#define GST_IS_STRUCTURE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_STRUCTURE))
-
typedef struct _GstStructure GstStructure;
-typedef gboolean (*GstStructureForeachFunc) (GQuark field_id,
- GValue * value,
- gpointer user_data);
+typedef gboolean (*GstStructureForeachFunc) (GQuark field_id,
+ GValue * value, gpointer user_data);
-struct _GstStructure {
+struct _GstStructure
+{
GType type;
GQuark name;
GArray *fields;
};
-GType gst_structure_get_type (void) G_GNUC_CONST;
-
-GstStructure * gst_structure_empty_new (const gchar * name);
-GstStructure * gst_structure_id_empty_new (GQuark quark);
-GstStructure * gst_structure_new (const gchar * name,
- const gchar * firstfield,
- ...);
-GstStructure * gst_structure_new_valist (const gchar * name,
- const gchar * firstfield,
- va_list varargs);
-GstStructure * gst_structure_copy (const GstStructure *structure);
-void gst_structure_free (GstStructure *structure);
-
-G_CONST_RETURN gchar * gst_structure_get_name (const GstStructure *structure);
-void gst_structure_set_name (GstStructure *structure,
- const gchar *name);
-
-void gst_structure_id_set_value (GstStructure *structure,
- GQuark field,
- const GValue *value);
-void gst_structure_set_value (GstStructure *structure,
- const gchar *fieldname,
- const GValue *value);
-void gst_structure_set (GstStructure *structure,
- const gchar *fieldname,
- ...);
-void gst_structure_set_valist (GstStructure *structure,
- const gchar *fieldname,
- va_list varargs);
-G_CONST_RETURN GValue * gst_structure_id_get_value (const GstStructure *structure,
- GQuark field);
-G_CONST_RETURN GValue * gst_structure_get_value (const GstStructure *structure,
- const gchar *fieldname);
-void gst_structure_remove_field (GstStructure *structure,
- const gchar *fieldname);
-void gst_structure_remove_fields (GstStructure *structure,
- const gchar *fieldname,
- ...);
-void gst_structure_remove_fields_valist (GstStructure *structure,
- const gchar *fieldname,
- va_list varargs);
-void gst_structure_remove_all_fields (GstStructure *structure);
-
-GType gst_structure_get_field_type (const GstStructure *structure,
- const gchar *fieldname);
-gboolean gst_structure_foreach (GstStructure *structure,
- GstStructureForeachFunc func,
- gpointer user_data);
-gint gst_structure_n_fields (const GstStructure *structure);
-gboolean gst_structure_has_field (const GstStructure *structure,
- const gchar *fieldname);
-gboolean gst_structure_has_field_typed (const GstStructure *structure,
- const gchar *fieldname,
- GType type);
+GType
+gst_structure_get_type (void)
+ G_GNUC_CONST;
+
+ GstStructure *gst_structure_empty_new (const gchar * name);
+ GstStructure *gst_structure_id_empty_new (GQuark quark);
+ GstStructure *gst_structure_new (const gchar * name,
+ const gchar * firstfield, ...);
+ GstStructure *gst_structure_new_valist (const gchar * name,
+ const gchar * firstfield, va_list varargs);
+ GstStructure *gst_structure_copy (const GstStructure * structure);
+ void gst_structure_free (GstStructure * structure);
+
+ G_CONST_RETURN gchar *gst_structure_get_name (const GstStructure *
+ structure);
+ void gst_structure_set_name (GstStructure * structure, const gchar * name);
+
+ void gst_structure_id_set_value (GstStructure * structure,
+ GQuark field, const GValue * value);
+ void gst_structure_set_value (GstStructure * structure,
+ const gchar * fieldname, const GValue * value);
+ void gst_structure_set (GstStructure * structure,
+ const gchar * fieldname, ...);
+ void gst_structure_set_valist (GstStructure * structure,
+ const gchar * fieldname, va_list varargs);
+ G_CONST_RETURN GValue *gst_structure_id_get_value (const GstStructure *
+ structure, GQuark field);
+ G_CONST_RETURN GValue *gst_structure_get_value (const GstStructure *
+ structure, const gchar * fieldname);
+ void gst_structure_remove_field (GstStructure * structure,
+ const gchar * fieldname);
+ void gst_structure_remove_fields (GstStructure * structure,
+ const gchar * fieldname, ...);
+ void gst_structure_remove_fields_valist (GstStructure * structure,
+ const gchar * fieldname, va_list varargs);
+ void gst_structure_remove_all_fields (GstStructure * structure);
+
+ GType gst_structure_get_field_type (const GstStructure * structure,
+ const gchar * fieldname);
+ gboolean gst_structure_foreach (GstStructure * structure,
+ GstStructureForeachFunc func, gpointer user_data);
+ gint gst_structure_n_fields (const GstStructure * structure);
+ gboolean gst_structure_has_field (const GstStructure * structure,
+ const gchar * fieldname);
+ gboolean gst_structure_has_field_typed (const GstStructure * structure,
+ const gchar * fieldname, GType type);
/* utility functions */
-gboolean gst_structure_get_boolean (const GstStructure *structure,
- const gchar *fieldname,
- gboolean *value);
-gboolean gst_structure_get_int (const GstStructure *structure,
- const gchar *fieldname,
- gint *value);
-gboolean gst_structure_get_fourcc (const GstStructure *structure,
- const gchar *fieldname,
- guint32 *value);
-gboolean gst_structure_get_double (const GstStructure *structure,
- const gchar *fieldname,
- gdouble *value);
-G_CONST_RETURN gchar * gst_structure_get_string (const GstStructure *structure,
- const gchar *fieldname);
-
-gchar * gst_structure_to_string (const GstStructure *structure);
-GstStructure * gst_structure_from_string (const gchar *string,
- gchar **end);
+ gboolean gst_structure_get_boolean (const GstStructure * structure,
+ const gchar * fieldname, gboolean * value);
+ gboolean gst_structure_get_int (const GstStructure * structure,
+ const gchar * fieldname, gint * value);
+ gboolean gst_structure_get_fourcc (const GstStructure * structure,
+ const gchar * fieldname, guint32 * value);
+ gboolean gst_structure_get_double (const GstStructure * structure,
+ const gchar * fieldname, gdouble * value);
+ G_CONST_RETURN gchar *gst_structure_get_string (const GstStructure *
+ structure, const gchar * fieldname);
+
+ gchar *gst_structure_to_string (const GstStructure * structure);
+ GstStructure *gst_structure_from_string (const gchar * string,
+ gchar ** end);
G_END_DECLS
-
#endif
-
static GstClock *_the_system_clock = NULL;
-static void gst_system_clock_class_init (GstSystemClockClass *klass);
-static void gst_system_clock_init (GstSystemClock *clock);
-static void gst_system_clock_dispose (GObject *object);
+static void gst_system_clock_class_init (GstSystemClockClass * klass);
+static void gst_system_clock_init (GstSystemClock * clock);
+static void gst_system_clock_dispose (GObject * object);
-static GstClockTime gst_system_clock_get_internal_time (GstClock *clock);
-static guint64 gst_system_clock_get_resolution (GstClock *clock);
-static GstClockEntryStatus gst_system_clock_wait (GstClock *clock, GstClockEntry *entry);
-static void gst_system_clock_unlock (GstClock *clock, GstClockEntry *entry);
+static GstClockTime gst_system_clock_get_internal_time (GstClock * clock);
+static guint64 gst_system_clock_get_resolution (GstClock * clock);
+static GstClockEntryStatus gst_system_clock_wait (GstClock * clock,
+ GstClockEntry * entry);
+static void gst_system_clock_unlock (GstClock * clock, GstClockEntry * entry);
static GStaticMutex _gst_sysclock_mutex = G_STATIC_MUTEX_INIT;
static GstClockClass *parent_class = NULL;
+
/* static guint gst_system_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
(GInstanceInitFunc) gst_system_clock_init,
NULL
};
- clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock",
- &clock_info, 0);
+ clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock",
+ &clock_info, 0);
}
return clock_type;
}
static void
-gst_system_clock_class_init (GstSystemClockClass *klass)
+gst_system_clock_class_init (GstSystemClockClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstClockClass *gstclock_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
- gstclock_class = (GstClockClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstclock_class = (GstClockClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_CLOCK);
- gobject_class->dispose = gst_system_clock_dispose;
+ gobject_class->dispose = gst_system_clock_dispose;
- gstclock_class->get_internal_time = gst_system_clock_get_internal_time;
- gstclock_class->get_resolution = gst_system_clock_get_resolution;
- gstclock_class->wait = gst_system_clock_wait;
- gstclock_class->unlock = gst_system_clock_unlock;
+ gstclock_class->get_internal_time = gst_system_clock_get_internal_time;
+ gstclock_class->get_resolution = gst_system_clock_get_resolution;
+ gstclock_class->wait = gst_system_clock_wait;
+ gstclock_class->unlock = gst_system_clock_unlock;
}
static void
-gst_system_clock_init (GstSystemClock *clock)
+gst_system_clock_init (GstSystemClock * clock)
{
- clock->mutex = g_mutex_new();
+ clock->mutex = g_mutex_new ();
clock->cond = g_cond_new ();
}
static void
-gst_system_clock_dispose (GObject *object)
+gst_system_clock_dispose (GObject * object)
{
GstClock *clock = (GstClock *) object;
GstSystemClock *sysclock = (GstSystemClock *) object;
*
* Returns: the default clock.
*/
-GstClock*
+GstClock *
gst_system_clock_obtain (void)
{
GstClock *clock = _the_system_clock;
g_static_mutex_unlock (&_gst_sysclock_mutex);
goto have_clock;
}
-
+
clock = GST_CLOCK (g_object_new (GST_TYPE_SYSTEM_CLOCK, NULL));
-
+
gst_object_set_name (GST_OBJECT (clock), "GstSystemClock");
gst_object_ref (GST_OBJECT (clock));
}
static GstClockTime
-gst_system_clock_get_internal_time (GstClock *clock)
+gst_system_clock_get_internal_time (GstClock * clock)
{
GTimeVal timeval;
g_get_current_time (&timeval);
-
+
return GST_TIMEVAL_TO_TIME (timeval);
}
static guint64
-gst_system_clock_get_resolution (GstClock *clock)
+gst_system_clock_get_resolution (GstClock * clock)
{
return 1 * GST_USECOND;
}
static GstClockEntryStatus
-gst_system_clock_wait (GstClock *clock, GstClockEntry *entry)
+gst_system_clock_wait (GstClock * clock, GstClockEntry * entry)
{
GstClockEntryStatus res;
GstClockTime current, target;
"s (max allowed is %" G_GINT64_FORMAT "s", -diff, clock->max_diff);
return GST_CLOCK_ENTRY_EARLY;
}
-
+
target = gst_system_clock_get_internal_time (clock) + diff;
GST_CAT_DEBUG (GST_CAT_CLOCK, "real_target %" G_GUINT64_FORMAT
- " target %" G_GUINT64_FORMAT
- " now %" G_GUINT64_FORMAT,
- target, GST_CLOCK_ENTRY_TIME (entry), current);
+ " target %" G_GUINT64_FORMAT
+ " now %" G_GUINT64_FORMAT, target, GST_CLOCK_ENTRY_TIME (entry), current);
- if (((gint64)target) > 0) {
+ if (((gint64) target) > 0) {
GTimeVal tv;
GST_TIME_TO_TIMEVAL (target, tv);
g_cond_timed_wait (sysclock->cond, sysclock->mutex, &tv);
g_mutex_unlock (sysclock->mutex);
res = entry->status;
- }
- else {
+ } else {
res = GST_CLOCK_ENTRY_EARLY;
}
return res;
}
static void
-gst_system_clock_unlock (GstClock *clock, GstClockEntry *entry)
+gst_system_clock_unlock (GstClock * clock, GstClockEntry * entry)
{
GstSystemClock *sysclock = GST_SYSTEM_CLOCK (clock);
#include <gst/gstclock.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SYSTEM_CLOCK (gst_system_clock_get_type ())
#define GST_SYSTEM_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SYSTEM_CLOCK, GstSystemClock))
#define GST_IS_SYSTEM_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SYSTEM_CLOCK))
#define GST_SYSTEM_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SYSTEM_CLOCK, GstSystemClockClass))
#define GST_IS_SYSTEM_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SYSTEM_CLOCK))
#define GST_SYSTEM_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SYSTEM_CLOCK, GstSystemClockClass))
-
-
typedef struct _GstSystemClock GstSystemClock;
typedef struct _GstSystemClockClass GstSystemClockClass;
-struct _GstSystemClock {
- GstClock clock;
+struct _GstSystemClock
+{
+ GstClock clock;
- GMutex * mutex;
- GCond * cond;
+ GMutex *mutex;
+ GCond *cond;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstSystemClockClass {
- GstClockClass parent_class;
+struct _GstSystemClockClass
+{
+ GstClockClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_system_clock_get_type (void);
+GType gst_system_clock_get_type (void);
-GstClock* gst_system_clock_obtain (void);
+GstClock *gst_system_clock_obtain (void);
G_END_DECLS
-
#endif /* __GST_SYSTEM_CLOCK_H__ */
#define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
-typedef struct {
- GType type; /* type the data is in */
+typedef struct
+{
+ GType type; /* type the data is in */
- gchar * nick; /* translated name */
- gchar * blurb; /* translated description of type */
+ gchar *nick; /* translated name */
+ gchar *blurb; /* translated description of type */
- GstTagMergeFunc merge_func; /* functions to merge the values */
- GstTagFlag flag; /* type of tag */
+ GstTagMergeFunc merge_func; /* functions to merge the values */
+ GstTagFlag flag; /* type of tag */
} GstTagInfo;
#define TAGLIST "taglist"
static GQuark gst_tag_list_quark;
static GMutex *__tag_mutex;
static GHashTable *__tags;
+
#define TAG_LOCK g_mutex_lock (__tag_mutex)
#define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
if (_gst_tag_list_type == 0) {
_gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
- (GBoxedCopyFunc) gst_tag_list_copy,
- (GBoxedFreeFunc) gst_tag_list_free);
+ (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
#if 0
- g_value_register_transform_func(_gst_tag_list_type, G_TYPE_STRING,
- _gst_structure_transform_to_string);
+ g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
+ _gst_structure_transform_to_string);
#endif
}
__tag_mutex = g_mutex_new ();
__tags = g_hash_table_new (g_direct_hash, g_direct_equal);
gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("title"),
- _("commonly used title"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("artist"),
- _("person(s) responsible for the recording"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("artist"),
+ _("person(s) responsible for the recording"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("album"),
- _("album containing this data"),
- gst_tag_merge_strings_with_comma);
- gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META,
- G_TYPE_UINT, /* FIXME: own data type for dates? */
- _("date"),
- _("date the data was created (in Julian calendar days)"),
- NULL);
+ G_TYPE_STRING,
+ _("album"),
+ _("album containing this data"), gst_tag_merge_strings_with_comma);
+ gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */
+ _("date"),
+ _("date the data was created (in Julian calendar days)"), NULL);
gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("genre"),
- _("genre this data belongs to"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("genre"),
+ _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("comment"),
- _("free text commenting the data"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("comment"),
+ _("free text commenting the data"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("track number"),
- _("track number inside a collection"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("track number"),
+ _("track number inside a collection"), gst_tag_merge_use_first);
gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("track count"),
- _("count of tracks inside collection this track belongs to"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("track count"),
+ _("count of tracks inside collection this track belongs to"),
+ gst_tag_merge_use_first);
gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("disc number"),
- _("disc number inside a collection"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("disc number"),
+ _("disc number inside a collection"), gst_tag_merge_use_first);
gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("disc count"),
- _("count of discs inside collection this disc belongs to"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("disc count"),
+ _("count of discs inside collection this disc belongs to"),
+ gst_tag_merge_use_first);
gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("location"),
- _("original location of file as a URI"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("location"),
+ _("original location of file as a URI"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("description"),
- _("short text describing the content of the data"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("description"),
+ _("short text describing the content of the data"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("version"),
- _("version of this data"),
- NULL);
+ G_TYPE_STRING, _("version"), _("version of this data"), NULL);
gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("ISRC"),
- _("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
- NULL);
- gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("organization"),
- _("organization"), /* FIXME */
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("ISRC"),
+ _
+ ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
+ NULL);
+ gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("copyright"),
- _("copyright notice of the data"),
- NULL);
+ G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("contact"),
- _("contact information"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("license"),
- _("license of data"),
- NULL);
+ G_TYPE_STRING, _("license"), _("license of data"), NULL);
gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("performer"),
- _("person(s) performing"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("performer"),
+ _("person(s) performing"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
- G_TYPE_UINT64,
- _("duration"),
- _("length in GStreamer time units (nanoseconds)"),
- NULL);
+ G_TYPE_UINT64,
+ _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("codec"),
- _("codec the data is stored in"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("codec"),
+ _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("video codec"),
- _("codec the video data is stored in"),
- NULL);
+ G_TYPE_STRING,
+ _("video codec"), _("codec the video data is stored in"), NULL);
gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("audio codec"),
- _("codec the audio data is stored in"),
- NULL);
+ G_TYPE_STRING,
+ _("audio codec"), _("codec the audio data is stored in"), NULL);
gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("bitrate"),
- _("exact or average bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("nominal bitrate"),
- _("nominal bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("minimum bitrate"),
- _("minimum bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("maximum bitrate"),
- _("maximum bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("encoder"),
- _("encoder used to encode this stream"),
- NULL);
+ G_TYPE_STRING,
+ _("encoder"), _("encoder used to encode this stream"), NULL);
gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("encoder version"),
- _("version of the encoder used to encode this stream"),
- NULL);
+ G_TYPE_UINT,
+ _("encoder version"),
+ _("version of the encoder used to encode this stream"), NULL);
gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("serial"),
- _("serial number of track"),
- NULL);
+ G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain track gain"),
- _("track gain in db"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain track peak"),
- _("peak of the track"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain album gain"),
- _("album gain in db"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain album peak"),
- _("peak of the album"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
}
+
/**
* gst_tag_merge_use_first:
* @dest: uninitialized GValue to store result in
* It creates a copy of the first value from the list.
*/
void
-gst_tag_merge_use_first (GValue *dest, const GValue *src)
+gst_tag_merge_use_first (GValue * dest, const GValue * src)
{
const GValue *ret = gst_value_list_get_value (src, 0);
g_value_init (dest, G_VALUE_TYPE (ret));
g_value_copy (ret, dest);
}
+
/**
* gst_tag_merge_strings_with_comma:
* @dest: uninitialized GValue to store result in
* as a G_TYPE_STRING or this function will fail.
*/
void
-gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src)
+gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
{
GString *str;
gint i, count;
for (i = 1; i < count; i++) {
/* seperator between two string */
str = g_string_append (str, _(", "));
- str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1)));
+ str =
+ g_string_append (str, g_value_get_string (gst_value_list_get_value (src,
+ 1)));
}
g_value_init (dest, G_TYPE_STRING);
gst_tag_lookup (GQuark entry)
{
GstTagInfo *ret;
-
+
TAG_LOCK;
ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry));
TAG_UNLOCK;
return ret;
}
+
/**
* gst_tag_register:
* @name: the name or identifier string
* This function takes ownership of all supplied variables.
*/
void
-gst_tag_register (gchar *name, GstTagFlag flag, GType type,
- gchar *nick, gchar *blurb, GstTagMergeFunc func)
+gst_tag_register (gchar * name, GstTagFlag flag, GType type,
+ gchar * nick, gchar * blurb, GstTagMergeFunc func)
{
GQuark key;
GstTagInfo *info;
g_return_if_fail (nick != NULL);
g_return_if_fail (blurb != NULL);
g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
-
+
key = g_quark_from_string (name);
info = gst_tag_lookup (key);
g_return_if_fail (info == NULL);
-
+
info = g_new (GstTagInfo, 1);
info->flag = flag;
info->type = type;
info->nick = nick;
info->blurb = blurb;
info->merge_func = func;
-
+
TAG_LOCK;
g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info);
TAG_UNLOCK;
}
+
/**
* gst_tag_exists:
* @tag: name of the tag
* Returns: TRUE if the type is already registered
*/
gboolean
-gst_tag_exists (const gchar *tag)
+gst_tag_exists (const gchar * tag)
{
g_return_val_if_fail (tag != NULL, FALSE);
-
+
return gst_tag_lookup (g_quark_from_string (tag)) != NULL;
}
+
/**
* gst_tag_get_type:
* @tag: the tag
* Returns: the #GType of this tag
*/
GType
-gst_tag_get_type (const gchar *tag)
+gst_tag_get_type (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, 0);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, 0);
-
+
return info->type;
}
+
/**
* gst_tag_get_nick
* @tag: the tag
* Returns: the human-readable name of this tag
*/
const gchar *
-gst_tag_get_nick (const gchar *tag)
+gst_tag_get_nick (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, NULL);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, NULL);
-
+
return info->nick;
}
+
/**
* gst_tag_get_description:
* @tag: the tag
* Return the human-readable description of this tag
*/
const gchar *
-gst_tag_get_description (const gchar *tag)
+gst_tag_get_description (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, NULL);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, NULL);
-
+
return info->blurb;
}
* Returns the flag of this tag.
*/
GstTagFlag
-gst_tag_get_flag (const gchar *tag)
+gst_tag_get_flag (const gchar * tag)
{
GstTagInfo *info;
* Returns: TRUE, if the given tag is fixed.
*/
gboolean
-gst_tag_is_fixed (const gchar *tag)
+gst_tag_is_fixed (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, FALSE);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, FALSE);
-
+
return info->merge_func == NULL;
}
+
/**
* gst_tag_list_new:
*
{
return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL));
}
+
/**
* gst_is_tag_list:
* @p: Object that might be a taglist
gboolean
gst_is_tag_list (gconstpointer p)
{
- g_return_val_if_fail (p != NULL, FALSE);
+ g_return_val_if_fail (p != NULL, FALSE);
return ((GstStructure *) p)->name == gst_tag_list_quark;
}
-typedef struct {
- GstStructure * list;
- GstTagMergeMode mode;
+typedef struct
+{
+ GstStructure *list;
+ GstTagMergeMode mode;
} GstTagCopyData;
static void
-gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value)
+gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
+ GQuark tag, GValue * value)
{
GstTagInfo *info = gst_tag_lookup (tag);
const GValue *value2;
-
+
g_assert (info != NULL);
- if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
+ if (info->merge_func
+ && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, };
switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL:
}
}
static gboolean
-gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data)
+gst_tag_list_copy_foreach (GQuark tag, GValue * value, gpointer user_data)
{
GstTagCopyData *copy = (GstTagCopyData *) user_data;
return TRUE;
}
+
/**
* gst_tag_list_insert:
* @into: list to merge into
* Inserts the tags of the second list into the first list using the given mode.
*/
void
-gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode mode)
+gst_tag_list_insert (GstTagList * into, const GstTagList * from,
+ GstTagMergeMode mode)
{
GstTagCopyData data;
-
+
g_return_if_fail (GST_IS_TAG_LIST (into));
g_return_if_fail (GST_IS_TAG_LIST (from));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
gst_structure_remove_all_fields (data.list);
}
- gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
+ gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
+ &data);
}
+
/**
* gst_tag_list_copy:
* @list: list to copy
* Returns: copy of the given list
*/
GstTagList *
-gst_tag_list_copy (const GstTagList *list)
+gst_tag_list_copy (const GstTagList * list)
{
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
-
+
return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
}
+
/**
* gst_tag_list_merge:
* @list1: first list to merge
* Returns: the new list
*/
GstTagList *
-gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMergeMode mode)
+gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
+ GstTagMergeMode mode)
{
g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
return ret;
}
}
+
/**
* gst_tag_list_free:
* @list: the list to free
* Frees the given list and all associated values.
*/
void
-gst_tag_list_free (GstTagList *list)
+gst_tag_list_free (GstTagList * list)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
gst_structure_free ((GstStructure *) list);
}
+
/**
* gst_tag_list_get_tag_size:
* @list: a taglist
* Returns: The number of tags stored
*/
guint
-gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag)
+gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
{
const GValue *value;
return gst_value_list_get_size (value);
}
+
/**
* gst_tag_list_add:
* @list: list to set tags in
* Sets the values for the given tags using the specified mode.
*/
void
-gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
+ ...)
{
va_list args;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
va_start (args, tag);
gst_tag_list_add_valist (list, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_list_add_values:
* @list: list to set tags in
* Sets the GValues for the given tags using the specified mode.
*/
void
-gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
va_start (args, tag);
gst_tag_list_add_valist_values (list, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_list_add_valist:
* @list: list to set tags in
* Sets the values for the given tags using the specified mode.
*/
void
-gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagInfo *info;
GQuark quark;
gchar *error = NULL;
-
+
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
while (tag != NULL) {
GValue value = { 0, };
quark = g_quark_from_string (tag);
tag = va_arg (var_args, gchar *);
}
}
+
/**
* gst_tag_list_add_valist_values:
* @list: list to set tags in
* Sets the GValues for the given tags using the specified mode.
*/
void
-gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagInfo *info;
GQuark quark;
-
+
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
while (tag != NULL) {
quark = g_quark_from_string (tag);
info = gst_tag_lookup (quark);
g_return_if_fail (info != NULL);
- gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *));
+ gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
+ GValue *));
tag = va_arg (var_args, gchar *);
}
}
+
/**
* gst_tag_list_remove_tag:
* @list: list to remove tag from
* Removes the goven tag from the taglist.
*/
void
-gst_tag_list_remove_tag (GstTagList *list, const gchar *tag)
+gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (tag != NULL);
gst_structure_remove_field ((GstStructure *) list, tag);
}
-typedef struct {
- GstTagForeachFunc func;
- GstTagList * tag_list;
- gpointer data;
+typedef struct
+{
+ GstTagForeachFunc func;
+ GstTagList *tag_list;
+ gpointer data;
} TagForeachData;
static int
-structure_foreach_wrapper (GQuark field_id,
- GValue *value, gpointer user_data)
+structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data)
{
TagForeachData *data = (TagForeachData *) user_data;
+
data->func (data->tag_list, g_quark_to_string (field_id), data->data);
return TRUE;
}
+
/**
* gst_tag_list_foreach:
* @list: list to iterate over
* is no tag, the function won't be called at all.
*/
void
-gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_data)
+gst_tag_list_foreach (GstTagList * list, GstTagForeachFunc func,
+ gpointer user_data)
{
TagForeachData data;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (func != NULL);
-
+
data.func = func;
data.tag_list = list;
data.data = user_data;
- gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
+ gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
+ &data);
}
/***** tag events *****/
* Returns: a new tag event
*/
GstEvent *
-gst_event_new_tag (GstTagList *list)
+gst_event_new_tag (GstTagList * list)
{
GstEvent *ret;
-
+
g_return_val_if_fail (list == NULL || GST_IS_TAG_LIST (list), NULL);
ret = gst_event_new (GST_EVENT_TAG);
if (!list)
list = gst_tag_list_new ();
ret->event_data.structure.structure = (GstStructure *) list;
-
+
return ret;
}
+
/**
* get_event_tag_get_list:
* @tag_event: a tagging #GstEvent
* Returns: The #GstTagList of the event
*/
GstTagList *
-gst_event_tag_get_list (GstEvent *tag_event)
+gst_event_tag_get_list (GstEvent * tag_event)
{
g_return_val_if_fail (GST_IS_EVENT (tag_event), NULL);
g_return_val_if_fail (GST_EVENT_TYPE (tag_event) == GST_EVENT_TAG, NULL);
* or the tag doesn't have as many entries
*/
G_CONST_RETURN GValue *
-gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint index)
+gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
+ guint index)
{
const GValue *value;
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
g_return_val_if_fail (tag != NULL, NULL);
-
+
value = gst_structure_get_value ((GstStructure *) list, tag);
- if (value == NULL) return NULL;
-
+ if (value == NULL)
+ return NULL;
+
if (GST_VALUE_HOLDS_LIST (value)) {
- if (index >= gst_value_list_get_size (value)) return NULL;
+ if (index >= gst_value_list_get_size (value))
+ return NULL;
return gst_value_list_get_value (value, index);
} else {
- if (index > 0) return NULL;
+ if (index > 0)
+ return NULL;
return value;
}
}
* given list.
*/
gboolean
-gst_tag_list_copy_value (GValue *dest, const GstTagList *list, const gchar *tag)
+gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
+ const gchar * tag)
{
const GValue *src;
-
+
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
g_return_val_if_fail (tag != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
-
+
src = gst_structure_get_value ((GstStructure *) list, tag);
- if (!src) return FALSE;
-
- if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
+ if (!src)
+ return FALSE;
+
+ if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag));
+
/* must be there or lists aren't allowed */
g_assert (info->merge_func);
info->merge_func (dest, src);
TAG_MERGE_FUNCS (float, gfloat)
TAG_MERGE_FUNCS (double, gdouble)
#undef COPY_FUNC
-
#define COPY_FUNC g_strdup
TAG_MERGE_FUNCS (string, gchar *)
#include <gst/gststructure.h>
#include <gst/gstevent.h>
-G_BEGIN_DECLS
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
GST_TAG_MERGE_UNDEFINED,
GST_TAG_MERGE_REPLACE_ALL,
GST_TAG_MERGE_REPLACE,
/* add more */
GST_TAG_MERGE_COUNT
} GstTagMergeMode;
+
#define GST_TAG_MODE_IS_VALID(mode) (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT))
-typedef enum {
+typedef enum
+{
GST_TAG_FLAG_UNDEFINED,
GST_TAG_FLAG_META,
GST_TAG_FLAG_ENCODED,
GST_TAG_FLAG_DECODED,
GST_TAG_FLAG_COUNT
} GstTagFlag;
+
#define GST_TAG_FLAG_IS_VALID(flag) (((flag) > GST_TAG_FLAG_UNDEFINED) && ((flag) < GST_TAG_FLAG_COUNT))
typedef GstStructure GstTagList;
+
#define GST_TAG_LIST(x) ((GstTagList *) (x))
#define GST_IS_TAG_LIST(x) (gst_is_tag_list (GST_TAG_LIST (x)))
#define GST_TYPE_TAG_LIST (gst_tag_list_get_type ())
-typedef void (* GstTagForeachFunc) (const GstTagList *list, const gchar *tag, gpointer user_data);
-typedef void (* GstTagMergeFunc) (GValue *dest, const GValue *src);
+typedef void (*GstTagForeachFunc) (const GstTagList * list, const gchar * tag,
+ gpointer user_data);
+typedef void (*GstTagMergeFunc) (GValue * dest, const GValue * src);
/* initialize tagging system */
-void _gst_tag_initialize (void);
-GType gst_tag_list_get_type (void);
+void _gst_tag_initialize (void);
+GType gst_tag_list_get_type (void);
-void gst_tag_register (gchar * name,
- GstTagFlag flag,
- GType type,
- gchar * nick,
- gchar * blurb,
- GstTagMergeFunc func);
+void gst_tag_register (gchar * name,
+ GstTagFlag flag,
+ GType type, gchar * nick, gchar * blurb, GstTagMergeFunc func);
/* some default merging functions */
-void gst_tag_merge_use_first (GValue * dest,
- const GValue * src);
-void gst_tag_merge_strings_with_comma (GValue * dest,
- const GValue * src);
+void gst_tag_merge_use_first (GValue * dest, const GValue * src);
+void gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src);
/* basic tag support */
-gboolean gst_tag_exists (const gchar * tag);
-GType gst_tag_get_type (const gchar * tag);
-G_CONST_RETURN gchar *
- gst_tag_get_nick (const gchar * tag);
-G_CONST_RETURN gchar *
- gst_tag_get_description (const gchar * tag);
-GstTagFlag gst_tag_get_flag (const gchar * tag);
-gboolean gst_tag_is_fixed (const gchar * tag);
+gboolean gst_tag_exists (const gchar * tag);
+GType gst_tag_get_type (const gchar * tag);
+G_CONST_RETURN gchar *gst_tag_get_nick (const gchar * tag);
+G_CONST_RETURN gchar *gst_tag_get_description (const gchar * tag);
+GstTagFlag gst_tag_get_flag (const gchar * tag);
+gboolean gst_tag_is_fixed (const gchar * tag);
/* tag lists */
-GstTagList * gst_tag_list_new (void);
-gboolean gst_is_tag_list (gconstpointer p);
-GstTagList * gst_tag_list_copy (const GstTagList * list);
-void gst_tag_list_insert (GstTagList * into,
- const GstTagList * from,
- GstTagMergeMode mode);
-GstTagList * gst_tag_list_merge (const GstTagList * list1,
- const GstTagList * list2,
- GstTagMergeMode mode);
-void gst_tag_list_free (GstTagList * list);
-guint gst_tag_list_get_tag_size (const GstTagList * list,
- const gchar * tag);
-void gst_tag_list_add (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
-void gst_tag_list_add_values (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
-void gst_tag_list_add_valist (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
-void gst_tag_list_add_valist_values (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
-void gst_tag_list_remove_tag (GstTagList * list,
- const gchar * tag);
-void gst_tag_list_foreach (GstTagList * list,
- GstTagForeachFunc func,
- gpointer user_data);
-
-G_CONST_RETURN GValue *
- gst_tag_list_get_value_index (const GstTagList * list,
- const gchar * tag,
- guint index);
-gboolean gst_tag_list_copy_value (GValue * dest,
- const GstTagList * list,
- const gchar * tag);
+GstTagList *gst_tag_list_new (void);
+gboolean gst_is_tag_list (gconstpointer p);
+GstTagList *gst_tag_list_copy (const GstTagList * list);
+void gst_tag_list_insert (GstTagList * into,
+ const GstTagList * from, GstTagMergeMode mode);
+GstTagList *gst_tag_list_merge (const GstTagList * list1,
+ const GstTagList * list2, GstTagMergeMode mode);
+void gst_tag_list_free (GstTagList * list);
+guint gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag);
+void gst_tag_list_add (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, ...);
+void gst_tag_list_add_values (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, ...);
+void gst_tag_list_add_valist (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
+void gst_tag_list_add_valist_values (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
+void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag);
+void gst_tag_list_foreach (GstTagList * list,
+ GstTagForeachFunc func, gpointer user_data);
+
+G_CONST_RETURN GValue *gst_tag_list_get_value_index (const GstTagList * list,
+ const gchar * tag, guint index);
+gboolean gst_tag_list_copy_value (GValue * dest,
+ const GstTagList * list, const gchar * tag);
/* simplifications (FIXME: do we want them?) */
-gboolean gst_tag_list_get_char (const GstTagList * list,
- const gchar * tag,
- gchar * value);
-gboolean gst_tag_list_get_char_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gchar * value);
-gboolean gst_tag_list_get_uchar (const GstTagList * list,
- const gchar * tag,
- guchar * value);
-gboolean gst_tag_list_get_uchar_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guchar * value);
-gboolean gst_tag_list_get_boolean (const GstTagList * list,
- const gchar * tag,
- gboolean * value);
-gboolean gst_tag_list_get_boolean_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gboolean * value);
-gboolean gst_tag_list_get_int (const GstTagList * list,
- const gchar * tag,
- gint * value);
-gboolean gst_tag_list_get_int_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gint * value);
-gboolean gst_tag_list_get_uint (const GstTagList * list,
- const gchar * tag,
- guint * value);
-gboolean gst_tag_list_get_uint_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guint * value);
-gboolean gst_tag_list_get_long (const GstTagList * list,
- const gchar * tag,
- glong * value);
-gboolean gst_tag_list_get_long_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- glong * value);
-gboolean gst_tag_list_get_ulong (const GstTagList * list,
- const gchar * tag,
- gulong * value);
-gboolean gst_tag_list_get_ulong_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gulong * value);
-gboolean gst_tag_list_get_int64 (const GstTagList * list,
- const gchar * tag,
- gint64 * value);
-gboolean gst_tag_list_get_int64_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gint64 * value);
-gboolean gst_tag_list_get_uint64 (const GstTagList * list,
- const gchar * tag,
- guint64 * value);
-gboolean gst_tag_list_get_uint64_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guint64 * value);
-gboolean gst_tag_list_get_float (const GstTagList * list,
- const gchar * tag,
- gfloat * value);
-gboolean gst_tag_list_get_float_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gfloat * value);
-gboolean gst_tag_list_get_double (const GstTagList * list,
- const gchar * tag,
- gdouble * value);
-gboolean gst_tag_list_get_double_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gdouble * value);
-gboolean gst_tag_list_get_string (const GstTagList * list,
- const gchar * tag,
- gchar ** value);
-gboolean gst_tag_list_get_string_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gchar ** value);
-gboolean gst_tag_list_get_pointer (const GstTagList * list,
- const gchar * tag,
- gpointer * value);
-gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gpointer * value);
+gboolean gst_tag_list_get_char (const GstTagList * list,
+ const gchar * tag, gchar * value);
+gboolean gst_tag_list_get_char_index (const GstTagList * list,
+ const gchar * tag, guint index, gchar * value);
+gboolean gst_tag_list_get_uchar (const GstTagList * list,
+ const gchar * tag, guchar * value);
+gboolean gst_tag_list_get_uchar_index (const GstTagList * list,
+ const gchar * tag, guint index, guchar * value);
+gboolean gst_tag_list_get_boolean (const GstTagList * list,
+ const gchar * tag, gboolean * value);
+gboolean gst_tag_list_get_boolean_index (const GstTagList * list,
+ const gchar * tag, guint index, gboolean * value);
+gboolean gst_tag_list_get_int (const GstTagList * list,
+ const gchar * tag, gint * value);
+gboolean gst_tag_list_get_int_index (const GstTagList * list,
+ const gchar * tag, guint index, gint * value);
+gboolean gst_tag_list_get_uint (const GstTagList * list,
+ const gchar * tag, guint * value);
+gboolean gst_tag_list_get_uint_index (const GstTagList * list,
+ const gchar * tag, guint index, guint * value);
+gboolean gst_tag_list_get_long (const GstTagList * list,
+ const gchar * tag, glong * value);
+gboolean gst_tag_list_get_long_index (const GstTagList * list,
+ const gchar * tag, guint index, glong * value);
+gboolean gst_tag_list_get_ulong (const GstTagList * list,
+ const gchar * tag, gulong * value);
+gboolean gst_tag_list_get_ulong_index (const GstTagList * list,
+ const gchar * tag, guint index, gulong * value);
+gboolean gst_tag_list_get_int64 (const GstTagList * list,
+ const gchar * tag, gint64 * value);
+gboolean gst_tag_list_get_int64_index (const GstTagList * list,
+ const gchar * tag, guint index, gint64 * value);
+gboolean gst_tag_list_get_uint64 (const GstTagList * list,
+ const gchar * tag, guint64 * value);
+gboolean gst_tag_list_get_uint64_index (const GstTagList * list,
+ const gchar * tag, guint index, guint64 * value);
+gboolean gst_tag_list_get_float (const GstTagList * list,
+ const gchar * tag, gfloat * value);
+gboolean gst_tag_list_get_float_index (const GstTagList * list,
+ const gchar * tag, guint index, gfloat * value);
+gboolean gst_tag_list_get_double (const GstTagList * list,
+ const gchar * tag, gdouble * value);
+gboolean gst_tag_list_get_double_index (const GstTagList * list,
+ const gchar * tag, guint index, gdouble * value);
+gboolean gst_tag_list_get_string (const GstTagList * list,
+ const gchar * tag, gchar ** value);
+gboolean gst_tag_list_get_string_index (const GstTagList * list,
+ const gchar * tag, guint index, gchar ** value);
+gboolean gst_tag_list_get_pointer (const GstTagList * list,
+ const gchar * tag, gpointer * value);
+gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
+ const gchar * tag, guint index, gpointer * value);
/* tag events */
-GstEvent * gst_event_new_tag (GstTagList * list);
-GstTagList * gst_event_tag_get_list (GstEvent * tag_event);
+GstEvent *gst_event_new_tag (GstTagList * list);
+GstTagList *gst_event_tag_get_list (GstEvent * tag_event);
/* GStreamer core tags (need to be discussed) */
#define GST_TAG_ALBUM_PEAK "replaygain-album-peak"
G_END_DECLS
-
#endif /* __GST_EVENT_H__ */
static GQuark gst_tag_key;
-typedef struct {
- GstTagMergeMode mode;
- GstTagList * list;
+typedef struct
+{
+ GstTagMergeMode mode;
+ GstTagList *list;
} GstTagData;
GType
gst_tag_setter_get_type (void)
{
static GType tag_setter_type = 0;
-
- if (! tag_setter_type) {
+
+ if (!tag_setter_type) {
static const GTypeInfo tag_setter_info = {
- sizeof (GstTagSetterIFace), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
+ sizeof (GstTagSetterIFace), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
0,
0,
NULL
};
-
- GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, "interfaces for tagging");
-
+
+ GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0,
+ "interfaces for tagging");
+
tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
- &tag_setter_info, 0);
-
+ &tag_setter_info, 0);
+
g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT);
gst_tag_key = g_quark_from_static_string ("GST_TAG_SETTER");
}
-
- return tag_setter_type;
+
+ return tag_setter_type;
}
static void
gst_tag_data_free (gpointer p)
g_free (data);
}
static GstTagData *
-gst_tag_setter_get_data (GstTagSetter *setter)
+gst_tag_setter_get_data (GstTagSetter * setter)
{
GstTagData *data;
data = g_new (GstTagData, 1);
data->list = NULL;
data->mode = GST_TAG_MERGE_KEEP;
- g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, gst_tag_data_free);
+ g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data,
+ gst_tag_data_free);
}
-
+
return data;
}
+
/**
* gst_tag_setter_merge:
* @setter: a #GstTagSetter
* Merges the given list into the setter's list using the given mode.
*/
void
-gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeMode mode)
+gst_tag_setter_merge (GstTagSetter * setter, const GstTagList * list,
+ GstTagMergeMode mode)
{
GstTagData *data;
gst_tag_list_merge (data->list, list, mode);
}
}
+
/**
* gst_tag_setter_add:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
gst_tag_setter_add_valist (setter, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_setter_add_values:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_setter_add_values (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
gst_tag_setter_add_valist_values (setter, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_setter_add_valist:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagData *data;
-
+
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
data = gst_tag_setter_get_data (setter);
if (!data->list)
data->list = gst_tag_list_new ();
-
+
gst_tag_list_add_valist (data->list, mode, tag, var_args);
}
+
/**
* gst_tag_setter_add_valist_values:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_setter_add_valist_values (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagData *data;
-
+
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
data = gst_tag_setter_get_data (setter);
if (!data->list)
data->list = gst_tag_list_new ();
-
+
gst_tag_list_add_valist_values (data->list, mode, tag, var_args);
}
+
/**
* gst_tag_setter_get_list:
* @setter: a #GstTagSetter
* Returns: a current snapshot of the taglist used in the setter
* or NULL if none is used.
*/
-const GstTagList *
-gst_tag_setter_get_list (GstTagSetter *setter)
+const GstTagList *
+gst_tag_setter_get_list (GstTagSetter * setter)
{
g_return_val_if_fail (GST_IS_TAG_SETTER (setter), NULL);
return gst_tag_setter_get_data (setter)->list;
}
+
/**
* gst_tag_setter_set_merge_mode:
* @setter: a #GstTagSetter
* the tags by this interface and discards tags from events.
*/
void
-gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode)
+gst_tag_setter_set_merge_mode (GstTagSetter * setter, GstTagMergeMode mode)
{
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
gst_tag_setter_get_data (setter)->mode = mode;
}
+
/**
* gst_tag_setter_get_merge_mode:
* @setter: a #GstTagSetter
* Returns: the merge mode used inside the element.
*/
GstTagMergeMode
-gst_tag_setter_get_merge_mode (GstTagSetter *setter)
+gst_tag_setter_get_merge_mode (GstTagSetter * setter)
{
g_return_val_if_fail (GST_IS_TAG_SETTER (setter), FALSE);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TAG_SETTER (gst_tag_setter_get_type ())
#define GST_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter))
#define GST_TAG_SETTER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter))
#define GST_IS_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TAG_SETTER))
#define GST_TAG_SETTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_TAG_SETTER, GstTagSetterIFace))
-
-typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */
-typedef struct _GstTagSetterIFace GstTagSetterIFace;
+typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */
+typedef struct _GstTagSetterIFace GstTagSetterIFace;
/* use an empty interface here to allow detection of elements using user-set
tags */
/* virtual table */
};
-GType gst_tag_setter_get_type (void) G_GNUC_CONST;
+GType
+gst_tag_setter_get_type (void)
+ G_GNUC_CONST;
-void gst_tag_setter_merge (GstTagSetter * setter,
- const GstTagList * list,
- GstTagMergeMode mode);
-void gst_tag_setter_add (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
+ void gst_tag_setter_merge (GstTagSetter * setter,
+ const GstTagList * list, GstTagMergeMode mode);
+ void gst_tag_setter_add (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, ...);
-void gst_tag_setter_add_values (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
+ void gst_tag_setter_add_values (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, ...);
-void gst_tag_setter_add_valist (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
+ void gst_tag_setter_add_valist (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
-void gst_tag_setter_add_valist_values(GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
+ void gst_tag_setter_add_valist_values (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
-G_CONST_RETURN GstTagList *
- gst_tag_setter_get_list (GstTagSetter * setter);
+ G_CONST_RETURN GstTagList *gst_tag_setter_get_list (GstTagSetter * setter);
-void gst_tag_setter_set_merge_mode (GstTagSetter * setter,
- GstTagMergeMode mode);
-GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter);
+ void gst_tag_setter_set_merge_mode (GstTagSetter * setter,
+ GstTagMergeMode mode);
+ GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter);
G_END_DECLS
-
#endif /* __GST_TAG_INTERFACE_H__ */
#define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
-typedef struct {
- GType type; /* type the data is in */
+typedef struct
+{
+ GType type; /* type the data is in */
- gchar * nick; /* translated name */
- gchar * blurb; /* translated description of type */
+ gchar *nick; /* translated name */
+ gchar *blurb; /* translated description of type */
- GstTagMergeFunc merge_func; /* functions to merge the values */
- GstTagFlag flag; /* type of tag */
+ GstTagMergeFunc merge_func; /* functions to merge the values */
+ GstTagFlag flag; /* type of tag */
} GstTagInfo;
#define TAGLIST "taglist"
static GQuark gst_tag_list_quark;
static GMutex *__tag_mutex;
static GHashTable *__tags;
+
#define TAG_LOCK g_mutex_lock (__tag_mutex)
#define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
if (_gst_tag_list_type == 0) {
_gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
- (GBoxedCopyFunc) gst_tag_list_copy,
- (GBoxedFreeFunc) gst_tag_list_free);
+ (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
#if 0
- g_value_register_transform_func(_gst_tag_list_type, G_TYPE_STRING,
- _gst_structure_transform_to_string);
+ g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
+ _gst_structure_transform_to_string);
#endif
}
__tag_mutex = g_mutex_new ();
__tags = g_hash_table_new (g_direct_hash, g_direct_equal);
gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("title"),
- _("commonly used title"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("artist"),
- _("person(s) responsible for the recording"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("artist"),
+ _("person(s) responsible for the recording"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("album"),
- _("album containing this data"),
- gst_tag_merge_strings_with_comma);
- gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META,
- G_TYPE_UINT, /* FIXME: own data type for dates? */
- _("date"),
- _("date the data was created (in Julian calendar days)"),
- NULL);
+ G_TYPE_STRING,
+ _("album"),
+ _("album containing this data"), gst_tag_merge_strings_with_comma);
+ gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */
+ _("date"),
+ _("date the data was created (in Julian calendar days)"), NULL);
gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("genre"),
- _("genre this data belongs to"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("genre"),
+ _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("comment"),
- _("free text commenting the data"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("comment"),
+ _("free text commenting the data"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("track number"),
- _("track number inside a collection"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("track number"),
+ _("track number inside a collection"), gst_tag_merge_use_first);
gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("track count"),
- _("count of tracks inside collection this track belongs to"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("track count"),
+ _("count of tracks inside collection this track belongs to"),
+ gst_tag_merge_use_first);
gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("disc number"),
- _("disc number inside a collection"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("disc number"),
+ _("disc number inside a collection"), gst_tag_merge_use_first);
gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
- G_TYPE_UINT,
- _("disc count"),
- _("count of discs inside collection this disc belongs to"),
- gst_tag_merge_use_first);
+ G_TYPE_UINT,
+ _("disc count"),
+ _("count of discs inside collection this disc belongs to"),
+ gst_tag_merge_use_first);
gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("location"),
- _("original location of file as a URI"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("location"),
+ _("original location of file as a URI"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("description"),
- _("short text describing the content of the data"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("description"),
+ _("short text describing the content of the data"),
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("version"),
- _("version of this data"),
- NULL);
+ G_TYPE_STRING, _("version"), _("version of this data"), NULL);
gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("ISRC"),
- _("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
- NULL);
- gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("organization"),
- _("organization"), /* FIXME */
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("ISRC"),
+ _
+ ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
+ NULL);
+ gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */
+ gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("copyright"),
- _("copyright notice of the data"),
- NULL);
+ G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("contact"),
- _("contact information"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("license"),
- _("license of data"),
- NULL);
+ G_TYPE_STRING, _("license"), _("license of data"), NULL);
gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
- G_TYPE_STRING,
- _("performer"),
- _("person(s) performing"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("performer"),
+ _("person(s) performing"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
- G_TYPE_UINT64,
- _("duration"),
- _("length in GStreamer time units (nanoseconds)"),
- NULL);
+ G_TYPE_UINT64,
+ _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("codec"),
- _("codec the data is stored in"),
- gst_tag_merge_strings_with_comma);
+ G_TYPE_STRING,
+ _("codec"),
+ _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("video codec"),
- _("codec the video data is stored in"),
- NULL);
+ G_TYPE_STRING,
+ _("video codec"), _("codec the video data is stored in"), NULL);
gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("audio codec"),
- _("codec the audio data is stored in"),
- NULL);
+ G_TYPE_STRING,
+ _("audio codec"), _("codec the audio data is stored in"), NULL);
gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("bitrate"),
- _("exact or average bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("nominal bitrate"),
- _("nominal bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("minimum bitrate"),
- _("minimum bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("maximum bitrate"),
- _("maximum bitrate in bits/s"),
- NULL);
+ G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
- G_TYPE_STRING,
- _("encoder"),
- _("encoder used to encode this stream"),
- NULL);
+ G_TYPE_STRING,
+ _("encoder"), _("encoder used to encode this stream"), NULL);
gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("encoder version"),
- _("version of the encoder used to encode this stream"),
- NULL);
+ G_TYPE_UINT,
+ _("encoder version"),
+ _("version of the encoder used to encode this stream"), NULL);
gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
- G_TYPE_UINT,
- _("serial"),
- _("serial number of track"),
- NULL);
+ G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain track gain"),
- _("track gain in db"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain track peak"),
- _("peak of the track"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain album gain"),
- _("album gain in db"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
- G_TYPE_DOUBLE,
- _("replaygain album peak"),
- _("peak of the album"),
- NULL);
+ G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
}
+
/**
* gst_tag_merge_use_first:
* @dest: uninitialized GValue to store result in
* It creates a copy of the first value from the list.
*/
void
-gst_tag_merge_use_first (GValue *dest, const GValue *src)
+gst_tag_merge_use_first (GValue * dest, const GValue * src)
{
const GValue *ret = gst_value_list_get_value (src, 0);
g_value_init (dest, G_VALUE_TYPE (ret));
g_value_copy (ret, dest);
}
+
/**
* gst_tag_merge_strings_with_comma:
* @dest: uninitialized GValue to store result in
* as a G_TYPE_STRING or this function will fail.
*/
void
-gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src)
+gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
{
GString *str;
gint i, count;
for (i = 1; i < count; i++) {
/* seperator between two string */
str = g_string_append (str, _(", "));
- str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1)));
+ str =
+ g_string_append (str, g_value_get_string (gst_value_list_get_value (src,
+ 1)));
}
g_value_init (dest, G_TYPE_STRING);
gst_tag_lookup (GQuark entry)
{
GstTagInfo *ret;
-
+
TAG_LOCK;
ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry));
TAG_UNLOCK;
return ret;
}
+
/**
* gst_tag_register:
* @name: the name or identifier string
* This function takes ownership of all supplied variables.
*/
void
-gst_tag_register (gchar *name, GstTagFlag flag, GType type,
- gchar *nick, gchar *blurb, GstTagMergeFunc func)
+gst_tag_register (gchar * name, GstTagFlag flag, GType type,
+ gchar * nick, gchar * blurb, GstTagMergeFunc func)
{
GQuark key;
GstTagInfo *info;
g_return_if_fail (nick != NULL);
g_return_if_fail (blurb != NULL);
g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
-
+
key = g_quark_from_string (name);
info = gst_tag_lookup (key);
g_return_if_fail (info == NULL);
-
+
info = g_new (GstTagInfo, 1);
info->flag = flag;
info->type = type;
info->nick = nick;
info->blurb = blurb;
info->merge_func = func;
-
+
TAG_LOCK;
g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info);
TAG_UNLOCK;
}
+
/**
* gst_tag_exists:
* @tag: name of the tag
* Returns: TRUE if the type is already registered
*/
gboolean
-gst_tag_exists (const gchar *tag)
+gst_tag_exists (const gchar * tag)
{
g_return_val_if_fail (tag != NULL, FALSE);
-
+
return gst_tag_lookup (g_quark_from_string (tag)) != NULL;
}
+
/**
* gst_tag_get_type:
* @tag: the tag
* Returns: the #GType of this tag
*/
GType
-gst_tag_get_type (const gchar *tag)
+gst_tag_get_type (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, 0);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, 0);
-
+
return info->type;
}
+
/**
* gst_tag_get_nick
* @tag: the tag
* Returns: the human-readable name of this tag
*/
const gchar *
-gst_tag_get_nick (const gchar *tag)
+gst_tag_get_nick (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, NULL);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, NULL);
-
+
return info->nick;
}
+
/**
* gst_tag_get_description:
* @tag: the tag
* Return the human-readable description of this tag
*/
const gchar *
-gst_tag_get_description (const gchar *tag)
+gst_tag_get_description (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, NULL);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, NULL);
-
+
return info->blurb;
}
* Returns the flag of this tag.
*/
GstTagFlag
-gst_tag_get_flag (const gchar *tag)
+gst_tag_get_flag (const gchar * tag)
{
GstTagInfo *info;
* Returns: TRUE, if the given tag is fixed.
*/
gboolean
-gst_tag_is_fixed (const gchar *tag)
+gst_tag_is_fixed (const gchar * tag)
{
GstTagInfo *info;
-
+
g_return_val_if_fail (tag != NULL, FALSE);
info = gst_tag_lookup (g_quark_from_string (tag));
g_return_val_if_fail (info != NULL, FALSE);
-
+
return info->merge_func == NULL;
}
+
/**
* gst_tag_list_new:
*
{
return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL));
}
+
/**
* gst_is_tag_list:
* @p: Object that might be a taglist
gboolean
gst_is_tag_list (gconstpointer p)
{
- g_return_val_if_fail (p != NULL, FALSE);
+ g_return_val_if_fail (p != NULL, FALSE);
return ((GstStructure *) p)->name == gst_tag_list_quark;
}
-typedef struct {
- GstStructure * list;
- GstTagMergeMode mode;
+typedef struct
+{
+ GstStructure *list;
+ GstTagMergeMode mode;
} GstTagCopyData;
static void
-gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value)
+gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
+ GQuark tag, GValue * value)
{
GstTagInfo *info = gst_tag_lookup (tag);
const GValue *value2;
-
+
g_assert (info != NULL);
- if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
+ if (info->merge_func
+ && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, };
switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL:
}
}
static gboolean
-gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data)
+gst_tag_list_copy_foreach (GQuark tag, GValue * value, gpointer user_data)
{
GstTagCopyData *copy = (GstTagCopyData *) user_data;
return TRUE;
}
+
/**
* gst_tag_list_insert:
* @into: list to merge into
* Inserts the tags of the second list into the first list using the given mode.
*/
void
-gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode mode)
+gst_tag_list_insert (GstTagList * into, const GstTagList * from,
+ GstTagMergeMode mode)
{
GstTagCopyData data;
-
+
g_return_if_fail (GST_IS_TAG_LIST (into));
g_return_if_fail (GST_IS_TAG_LIST (from));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
gst_structure_remove_all_fields (data.list);
}
- gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
+ gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
+ &data);
}
+
/**
* gst_tag_list_copy:
* @list: list to copy
* Returns: copy of the given list
*/
GstTagList *
-gst_tag_list_copy (const GstTagList *list)
+gst_tag_list_copy (const GstTagList * list)
{
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
-
+
return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
}
+
/**
* gst_tag_list_merge:
* @list1: first list to merge
* Returns: the new list
*/
GstTagList *
-gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMergeMode mode)
+gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
+ GstTagMergeMode mode)
{
g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
return ret;
}
}
+
/**
* gst_tag_list_free:
* @list: the list to free
* Frees the given list and all associated values.
*/
void
-gst_tag_list_free (GstTagList *list)
+gst_tag_list_free (GstTagList * list)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
gst_structure_free ((GstStructure *) list);
}
+
/**
* gst_tag_list_get_tag_size:
* @list: a taglist
* Returns: The number of tags stored
*/
guint
-gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag)
+gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
{
const GValue *value;
return gst_value_list_get_size (value);
}
+
/**
* gst_tag_list_add:
* @list: list to set tags in
* Sets the values for the given tags using the specified mode.
*/
void
-gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
+ ...)
{
va_list args;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
va_start (args, tag);
gst_tag_list_add_valist (list, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_list_add_values:
* @list: list to set tags in
* Sets the GValues for the given tags using the specified mode.
*/
void
-gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
va_start (args, tag);
gst_tag_list_add_valist_values (list, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_list_add_valist:
* @list: list to set tags in
* Sets the values for the given tags using the specified mode.
*/
void
-gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagInfo *info;
GQuark quark;
gchar *error = NULL;
-
+
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
while (tag != NULL) {
GValue value = { 0, };
quark = g_quark_from_string (tag);
tag = va_arg (var_args, gchar *);
}
}
+
/**
* gst_tag_list_add_valist_values:
* @list: list to set tags in
* Sets the GValues for the given tags using the specified mode.
*/
void
-gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagInfo *info;
GQuark quark;
-
+
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
g_return_if_fail (tag != NULL);
-
+
while (tag != NULL) {
quark = g_quark_from_string (tag);
info = gst_tag_lookup (quark);
g_return_if_fail (info != NULL);
- gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *));
+ gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
+ GValue *));
tag = va_arg (var_args, gchar *);
}
}
+
/**
* gst_tag_list_remove_tag:
* @list: list to remove tag from
* Removes the goven tag from the taglist.
*/
void
-gst_tag_list_remove_tag (GstTagList *list, const gchar *tag)
+gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
{
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (tag != NULL);
gst_structure_remove_field ((GstStructure *) list, tag);
}
-typedef struct {
- GstTagForeachFunc func;
- GstTagList * tag_list;
- gpointer data;
+typedef struct
+{
+ GstTagForeachFunc func;
+ GstTagList *tag_list;
+ gpointer data;
} TagForeachData;
static int
-structure_foreach_wrapper (GQuark field_id,
- GValue *value, gpointer user_data)
+structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data)
{
TagForeachData *data = (TagForeachData *) user_data;
+
data->func (data->tag_list, g_quark_to_string (field_id), data->data);
return TRUE;
}
+
/**
* gst_tag_list_foreach:
* @list: list to iterate over
* is no tag, the function won't be called at all.
*/
void
-gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_data)
+gst_tag_list_foreach (GstTagList * list, GstTagForeachFunc func,
+ gpointer user_data)
{
TagForeachData data;
g_return_if_fail (GST_IS_TAG_LIST (list));
g_return_if_fail (func != NULL);
-
+
data.func = func;
data.tag_list = list;
data.data = user_data;
- gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
+ gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
+ &data);
}
/***** tag events *****/
* Returns: a new tag event
*/
GstEvent *
-gst_event_new_tag (GstTagList *list)
+gst_event_new_tag (GstTagList * list)
{
GstEvent *ret;
-
+
g_return_val_if_fail (list == NULL || GST_IS_TAG_LIST (list), NULL);
ret = gst_event_new (GST_EVENT_TAG);
if (!list)
list = gst_tag_list_new ();
ret->event_data.structure.structure = (GstStructure *) list;
-
+
return ret;
}
+
/**
* get_event_tag_get_list:
* @tag_event: a tagging #GstEvent
* Returns: The #GstTagList of the event
*/
GstTagList *
-gst_event_tag_get_list (GstEvent *tag_event)
+gst_event_tag_get_list (GstEvent * tag_event)
{
g_return_val_if_fail (GST_IS_EVENT (tag_event), NULL);
g_return_val_if_fail (GST_EVENT_TYPE (tag_event) == GST_EVENT_TAG, NULL);
* or the tag doesn't have as many entries
*/
G_CONST_RETURN GValue *
-gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint index)
+gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
+ guint index)
{
const GValue *value;
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
g_return_val_if_fail (tag != NULL, NULL);
-
+
value = gst_structure_get_value ((GstStructure *) list, tag);
- if (value == NULL) return NULL;
-
+ if (value == NULL)
+ return NULL;
+
if (GST_VALUE_HOLDS_LIST (value)) {
- if (index >= gst_value_list_get_size (value)) return NULL;
+ if (index >= gst_value_list_get_size (value))
+ return NULL;
return gst_value_list_get_value (value, index);
} else {
- if (index > 0) return NULL;
+ if (index > 0)
+ return NULL;
return value;
}
}
* given list.
*/
gboolean
-gst_tag_list_copy_value (GValue *dest, const GstTagList *list, const gchar *tag)
+gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
+ const gchar * tag)
{
const GValue *src;
-
+
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
g_return_val_if_fail (tag != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
-
+
src = gst_structure_get_value ((GstStructure *) list, tag);
- if (!src) return FALSE;
-
- if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
+ if (!src)
+ return FALSE;
+
+ if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag));
+
/* must be there or lists aren't allowed */
g_assert (info->merge_func);
info->merge_func (dest, src);
TAG_MERGE_FUNCS (float, gfloat)
TAG_MERGE_FUNCS (double, gdouble)
#undef COPY_FUNC
-
#define COPY_FUNC g_strdup
TAG_MERGE_FUNCS (string, gchar *)
#include <gst/gststructure.h>
#include <gst/gstevent.h>
-G_BEGIN_DECLS
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
GST_TAG_MERGE_UNDEFINED,
GST_TAG_MERGE_REPLACE_ALL,
GST_TAG_MERGE_REPLACE,
/* add more */
GST_TAG_MERGE_COUNT
} GstTagMergeMode;
+
#define GST_TAG_MODE_IS_VALID(mode) (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT))
-typedef enum {
+typedef enum
+{
GST_TAG_FLAG_UNDEFINED,
GST_TAG_FLAG_META,
GST_TAG_FLAG_ENCODED,
GST_TAG_FLAG_DECODED,
GST_TAG_FLAG_COUNT
} GstTagFlag;
+
#define GST_TAG_FLAG_IS_VALID(flag) (((flag) > GST_TAG_FLAG_UNDEFINED) && ((flag) < GST_TAG_FLAG_COUNT))
typedef GstStructure GstTagList;
+
#define GST_TAG_LIST(x) ((GstTagList *) (x))
#define GST_IS_TAG_LIST(x) (gst_is_tag_list (GST_TAG_LIST (x)))
#define GST_TYPE_TAG_LIST (gst_tag_list_get_type ())
-typedef void (* GstTagForeachFunc) (const GstTagList *list, const gchar *tag, gpointer user_data);
-typedef void (* GstTagMergeFunc) (GValue *dest, const GValue *src);
+typedef void (*GstTagForeachFunc) (const GstTagList * list, const gchar * tag,
+ gpointer user_data);
+typedef void (*GstTagMergeFunc) (GValue * dest, const GValue * src);
/* initialize tagging system */
-void _gst_tag_initialize (void);
-GType gst_tag_list_get_type (void);
+void _gst_tag_initialize (void);
+GType gst_tag_list_get_type (void);
-void gst_tag_register (gchar * name,
- GstTagFlag flag,
- GType type,
- gchar * nick,
- gchar * blurb,
- GstTagMergeFunc func);
+void gst_tag_register (gchar * name,
+ GstTagFlag flag,
+ GType type, gchar * nick, gchar * blurb, GstTagMergeFunc func);
/* some default merging functions */
-void gst_tag_merge_use_first (GValue * dest,
- const GValue * src);
-void gst_tag_merge_strings_with_comma (GValue * dest,
- const GValue * src);
+void gst_tag_merge_use_first (GValue * dest, const GValue * src);
+void gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src);
/* basic tag support */
-gboolean gst_tag_exists (const gchar * tag);
-GType gst_tag_get_type (const gchar * tag);
-G_CONST_RETURN gchar *
- gst_tag_get_nick (const gchar * tag);
-G_CONST_RETURN gchar *
- gst_tag_get_description (const gchar * tag);
-GstTagFlag gst_tag_get_flag (const gchar * tag);
-gboolean gst_tag_is_fixed (const gchar * tag);
+gboolean gst_tag_exists (const gchar * tag);
+GType gst_tag_get_type (const gchar * tag);
+G_CONST_RETURN gchar *gst_tag_get_nick (const gchar * tag);
+G_CONST_RETURN gchar *gst_tag_get_description (const gchar * tag);
+GstTagFlag gst_tag_get_flag (const gchar * tag);
+gboolean gst_tag_is_fixed (const gchar * tag);
/* tag lists */
-GstTagList * gst_tag_list_new (void);
-gboolean gst_is_tag_list (gconstpointer p);
-GstTagList * gst_tag_list_copy (const GstTagList * list);
-void gst_tag_list_insert (GstTagList * into,
- const GstTagList * from,
- GstTagMergeMode mode);
-GstTagList * gst_tag_list_merge (const GstTagList * list1,
- const GstTagList * list2,
- GstTagMergeMode mode);
-void gst_tag_list_free (GstTagList * list);
-guint gst_tag_list_get_tag_size (const GstTagList * list,
- const gchar * tag);
-void gst_tag_list_add (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
-void gst_tag_list_add_values (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
-void gst_tag_list_add_valist (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
-void gst_tag_list_add_valist_values (GstTagList * list,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
-void gst_tag_list_remove_tag (GstTagList * list,
- const gchar * tag);
-void gst_tag_list_foreach (GstTagList * list,
- GstTagForeachFunc func,
- gpointer user_data);
-
-G_CONST_RETURN GValue *
- gst_tag_list_get_value_index (const GstTagList * list,
- const gchar * tag,
- guint index);
-gboolean gst_tag_list_copy_value (GValue * dest,
- const GstTagList * list,
- const gchar * tag);
+GstTagList *gst_tag_list_new (void);
+gboolean gst_is_tag_list (gconstpointer p);
+GstTagList *gst_tag_list_copy (const GstTagList * list);
+void gst_tag_list_insert (GstTagList * into,
+ const GstTagList * from, GstTagMergeMode mode);
+GstTagList *gst_tag_list_merge (const GstTagList * list1,
+ const GstTagList * list2, GstTagMergeMode mode);
+void gst_tag_list_free (GstTagList * list);
+guint gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag);
+void gst_tag_list_add (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, ...);
+void gst_tag_list_add_values (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, ...);
+void gst_tag_list_add_valist (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
+void gst_tag_list_add_valist_values (GstTagList * list,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
+void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag);
+void gst_tag_list_foreach (GstTagList * list,
+ GstTagForeachFunc func, gpointer user_data);
+
+G_CONST_RETURN GValue *gst_tag_list_get_value_index (const GstTagList * list,
+ const gchar * tag, guint index);
+gboolean gst_tag_list_copy_value (GValue * dest,
+ const GstTagList * list, const gchar * tag);
/* simplifications (FIXME: do we want them?) */
-gboolean gst_tag_list_get_char (const GstTagList * list,
- const gchar * tag,
- gchar * value);
-gboolean gst_tag_list_get_char_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gchar * value);
-gboolean gst_tag_list_get_uchar (const GstTagList * list,
- const gchar * tag,
- guchar * value);
-gboolean gst_tag_list_get_uchar_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guchar * value);
-gboolean gst_tag_list_get_boolean (const GstTagList * list,
- const gchar * tag,
- gboolean * value);
-gboolean gst_tag_list_get_boolean_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gboolean * value);
-gboolean gst_tag_list_get_int (const GstTagList * list,
- const gchar * tag,
- gint * value);
-gboolean gst_tag_list_get_int_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gint * value);
-gboolean gst_tag_list_get_uint (const GstTagList * list,
- const gchar * tag,
- guint * value);
-gboolean gst_tag_list_get_uint_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guint * value);
-gboolean gst_tag_list_get_long (const GstTagList * list,
- const gchar * tag,
- glong * value);
-gboolean gst_tag_list_get_long_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- glong * value);
-gboolean gst_tag_list_get_ulong (const GstTagList * list,
- const gchar * tag,
- gulong * value);
-gboolean gst_tag_list_get_ulong_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gulong * value);
-gboolean gst_tag_list_get_int64 (const GstTagList * list,
- const gchar * tag,
- gint64 * value);
-gboolean gst_tag_list_get_int64_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gint64 * value);
-gboolean gst_tag_list_get_uint64 (const GstTagList * list,
- const gchar * tag,
- guint64 * value);
-gboolean gst_tag_list_get_uint64_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- guint64 * value);
-gboolean gst_tag_list_get_float (const GstTagList * list,
- const gchar * tag,
- gfloat * value);
-gboolean gst_tag_list_get_float_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gfloat * value);
-gboolean gst_tag_list_get_double (const GstTagList * list,
- const gchar * tag,
- gdouble * value);
-gboolean gst_tag_list_get_double_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gdouble * value);
-gboolean gst_tag_list_get_string (const GstTagList * list,
- const gchar * tag,
- gchar ** value);
-gboolean gst_tag_list_get_string_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gchar ** value);
-gboolean gst_tag_list_get_pointer (const GstTagList * list,
- const gchar * tag,
- gpointer * value);
-gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
- const gchar * tag,
- guint index,
- gpointer * value);
+gboolean gst_tag_list_get_char (const GstTagList * list,
+ const gchar * tag, gchar * value);
+gboolean gst_tag_list_get_char_index (const GstTagList * list,
+ const gchar * tag, guint index, gchar * value);
+gboolean gst_tag_list_get_uchar (const GstTagList * list,
+ const gchar * tag, guchar * value);
+gboolean gst_tag_list_get_uchar_index (const GstTagList * list,
+ const gchar * tag, guint index, guchar * value);
+gboolean gst_tag_list_get_boolean (const GstTagList * list,
+ const gchar * tag, gboolean * value);
+gboolean gst_tag_list_get_boolean_index (const GstTagList * list,
+ const gchar * tag, guint index, gboolean * value);
+gboolean gst_tag_list_get_int (const GstTagList * list,
+ const gchar * tag, gint * value);
+gboolean gst_tag_list_get_int_index (const GstTagList * list,
+ const gchar * tag, guint index, gint * value);
+gboolean gst_tag_list_get_uint (const GstTagList * list,
+ const gchar * tag, guint * value);
+gboolean gst_tag_list_get_uint_index (const GstTagList * list,
+ const gchar * tag, guint index, guint * value);
+gboolean gst_tag_list_get_long (const GstTagList * list,
+ const gchar * tag, glong * value);
+gboolean gst_tag_list_get_long_index (const GstTagList * list,
+ const gchar * tag, guint index, glong * value);
+gboolean gst_tag_list_get_ulong (const GstTagList * list,
+ const gchar * tag, gulong * value);
+gboolean gst_tag_list_get_ulong_index (const GstTagList * list,
+ const gchar * tag, guint index, gulong * value);
+gboolean gst_tag_list_get_int64 (const GstTagList * list,
+ const gchar * tag, gint64 * value);
+gboolean gst_tag_list_get_int64_index (const GstTagList * list,
+ const gchar * tag, guint index, gint64 * value);
+gboolean gst_tag_list_get_uint64 (const GstTagList * list,
+ const gchar * tag, guint64 * value);
+gboolean gst_tag_list_get_uint64_index (const GstTagList * list,
+ const gchar * tag, guint index, guint64 * value);
+gboolean gst_tag_list_get_float (const GstTagList * list,
+ const gchar * tag, gfloat * value);
+gboolean gst_tag_list_get_float_index (const GstTagList * list,
+ const gchar * tag, guint index, gfloat * value);
+gboolean gst_tag_list_get_double (const GstTagList * list,
+ const gchar * tag, gdouble * value);
+gboolean gst_tag_list_get_double_index (const GstTagList * list,
+ const gchar * tag, guint index, gdouble * value);
+gboolean gst_tag_list_get_string (const GstTagList * list,
+ const gchar * tag, gchar ** value);
+gboolean gst_tag_list_get_string_index (const GstTagList * list,
+ const gchar * tag, guint index, gchar ** value);
+gboolean gst_tag_list_get_pointer (const GstTagList * list,
+ const gchar * tag, gpointer * value);
+gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
+ const gchar * tag, guint index, gpointer * value);
/* tag events */
-GstEvent * gst_event_new_tag (GstTagList * list);
-GstTagList * gst_event_tag_get_list (GstEvent * tag_event);
+GstEvent *gst_event_new_tag (GstTagList * list);
+GstTagList *gst_event_tag_get_list (GstEvent * tag_event);
/* GStreamer core tags (need to be discussed) */
#define GST_TAG_ALBUM_PEAK "replaygain-album-peak"
G_END_DECLS
-
#endif /* __GST_EVENT_H__ */
static GQuark gst_tag_key;
-typedef struct {
- GstTagMergeMode mode;
- GstTagList * list;
+typedef struct
+{
+ GstTagMergeMode mode;
+ GstTagList *list;
} GstTagData;
GType
gst_tag_setter_get_type (void)
{
static GType tag_setter_type = 0;
-
- if (! tag_setter_type) {
+
+ if (!tag_setter_type) {
static const GTypeInfo tag_setter_info = {
- sizeof (GstTagSetterIFace), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
+ sizeof (GstTagSetterIFace), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
0,
0,
NULL
};
-
- GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, "interfaces for tagging");
-
+
+ GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0,
+ "interfaces for tagging");
+
tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
- &tag_setter_info, 0);
-
+ &tag_setter_info, 0);
+
g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT);
gst_tag_key = g_quark_from_static_string ("GST_TAG_SETTER");
}
-
- return tag_setter_type;
+
+ return tag_setter_type;
}
static void
gst_tag_data_free (gpointer p)
g_free (data);
}
static GstTagData *
-gst_tag_setter_get_data (GstTagSetter *setter)
+gst_tag_setter_get_data (GstTagSetter * setter)
{
GstTagData *data;
data = g_new (GstTagData, 1);
data->list = NULL;
data->mode = GST_TAG_MERGE_KEEP;
- g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, gst_tag_data_free);
+ g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data,
+ gst_tag_data_free);
}
-
+
return data;
}
+
/**
* gst_tag_setter_merge:
* @setter: a #GstTagSetter
* Merges the given list into the setter's list using the given mode.
*/
void
-gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeMode mode)
+gst_tag_setter_merge (GstTagSetter * setter, const GstTagList * list,
+ GstTagMergeMode mode)
{
GstTagData *data;
gst_tag_list_merge (data->list, list, mode);
}
}
+
/**
* gst_tag_setter_add:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
gst_tag_setter_add_valist (setter, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_setter_add_values:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...)
+gst_tag_setter_add_values (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, ...)
{
va_list args;
gst_tag_setter_add_valist_values (setter, mode, tag, args);
va_end (args);
}
+
/**
* gst_tag_setter_add_valist:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagData *data;
-
+
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
data = gst_tag_setter_get_data (setter);
if (!data->list)
data->list = gst_tag_list_new ();
-
+
gst_tag_list_add_valist (data->list, mode, tag, var_args);
}
+
/**
* gst_tag_setter_add_valist_values:
* @setter: a #GstTagSetter
* The list must be terminated with GST_TAG_INVALID.
*/
void
-gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args)
+gst_tag_setter_add_valist_values (GstTagSetter * setter, GstTagMergeMode mode,
+ const gchar * tag, va_list var_args)
{
GstTagData *data;
-
+
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
data = gst_tag_setter_get_data (setter);
if (!data->list)
data->list = gst_tag_list_new ();
-
+
gst_tag_list_add_valist_values (data->list, mode, tag, var_args);
}
+
/**
* gst_tag_setter_get_list:
* @setter: a #GstTagSetter
* Returns: a current snapshot of the taglist used in the setter
* or NULL if none is used.
*/
-const GstTagList *
-gst_tag_setter_get_list (GstTagSetter *setter)
+const GstTagList *
+gst_tag_setter_get_list (GstTagSetter * setter)
{
g_return_val_if_fail (GST_IS_TAG_SETTER (setter), NULL);
return gst_tag_setter_get_data (setter)->list;
}
+
/**
* gst_tag_setter_set_merge_mode:
* @setter: a #GstTagSetter
* the tags by this interface and discards tags from events.
*/
void
-gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode)
+gst_tag_setter_set_merge_mode (GstTagSetter * setter, GstTagMergeMode mode)
{
g_return_if_fail (GST_IS_TAG_SETTER (setter));
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
gst_tag_setter_get_data (setter)->mode = mode;
}
+
/**
* gst_tag_setter_get_merge_mode:
* @setter: a #GstTagSetter
* Returns: the merge mode used inside the element.
*/
GstTagMergeMode
-gst_tag_setter_get_merge_mode (GstTagSetter *setter)
+gst_tag_setter_get_merge_mode (GstTagSetter * setter)
{
g_return_val_if_fail (GST_IS_TAG_SETTER (setter), FALSE);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TAG_SETTER (gst_tag_setter_get_type ())
#define GST_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter))
#define GST_TAG_SETTER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter))
#define GST_IS_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TAG_SETTER))
#define GST_TAG_SETTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_TAG_SETTER, GstTagSetterIFace))
-
-typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */
-typedef struct _GstTagSetterIFace GstTagSetterIFace;
+typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */
+typedef struct _GstTagSetterIFace GstTagSetterIFace;
/* use an empty interface here to allow detection of elements using user-set
tags */
/* virtual table */
};
-GType gst_tag_setter_get_type (void) G_GNUC_CONST;
+GType
+gst_tag_setter_get_type (void)
+ G_GNUC_CONST;
-void gst_tag_setter_merge (GstTagSetter * setter,
- const GstTagList * list,
- GstTagMergeMode mode);
-void gst_tag_setter_add (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
+ void gst_tag_setter_merge (GstTagSetter * setter,
+ const GstTagList * list, GstTagMergeMode mode);
+ void gst_tag_setter_add (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, ...);
-void gst_tag_setter_add_values (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- ...);
+ void gst_tag_setter_add_values (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, ...);
-void gst_tag_setter_add_valist (GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
+ void gst_tag_setter_add_valist (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
-void gst_tag_setter_add_valist_values(GstTagSetter * setter,
- GstTagMergeMode mode,
- const gchar * tag,
- va_list var_args);
+ void gst_tag_setter_add_valist_values (GstTagSetter * setter,
+ GstTagMergeMode mode, const gchar * tag, va_list var_args);
-G_CONST_RETURN GstTagList *
- gst_tag_setter_get_list (GstTagSetter * setter);
+ G_CONST_RETURN GstTagList *gst_tag_setter_get_list (GstTagSetter * setter);
-void gst_tag_setter_set_merge_mode (GstTagSetter * setter,
- GstTagMergeMode mode);
-GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter);
+ void gst_tag_setter_set_merge_mode (GstTagSetter * setter,
+ GstTagMergeMode mode);
+ GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter);
G_END_DECLS
-
#endif /* __GST_TAG_INTERFACE_H__ */
#define GST_CAT_DEFAULT GST_CAT_THREAD
#define STACK_SIZE 0x200000
-static GstElementDetails gst_thread_details = GST_ELEMENT_DETAILS (
- "Threaded container",
- "Generic/Bin",
- "Container that creates/manages a thread",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Benjamin Otte <in7y118@informatik.uni-hamburg.de"
-);
+static GstElementDetails gst_thread_details =
+GST_ELEMENT_DETAILS ("Threaded container",
+ "Generic/Bin",
+ "Container that creates/manages a thread",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Benjamin Otte <in7y118@informatik.uni-hamburg.de");
/* Thread signals and args */
-enum {
+enum
+{
SHUTDOWN,
/* FILL ME */
LAST_SIGNAL
};
-enum {
- SPINUP=0,
+enum
+{
+ SPINUP = 0,
STATECHANGE,
STARTUP
};
-enum {
+enum
+{
ARG_0,
ARG_PRIORITY
};
-static void gst_thread_base_init (gpointer g_class);
-static void gst_thread_class_init (gpointer g_class, gpointer class_data);
-static void gst_thread_init (GTypeInstance *instance, gpointer g_class);
+static void gst_thread_base_init (gpointer g_class);
+static void gst_thread_class_init (gpointer g_class, gpointer class_data);
+static void gst_thread_init (GTypeInstance * instance, gpointer g_class);
-static void gst_thread_dispose (GObject *object);
+static void gst_thread_dispose (GObject * object);
-static void gst_thread_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_thread_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static GstElementStateReturn gst_thread_change_state (GstElement *element);
-static void gst_thread_child_state_change (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *element);
+static void gst_thread_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_thread_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_thread_change_state (GstElement * element);
+static void gst_thread_child_state_change (GstBin * bin,
+ GstElementState oldstate, GstElementState newstate, GstElement * element);
-static void gst_thread_catch (GstThread *thread);
-static void gst_thread_release (GstThread *thread);
+static void gst_thread_catch (GstThread * thread);
+static void gst_thread_release (GstThread * thread);
#ifndef GST_DISABLE_LOADSAVE
-static xmlNodePtr gst_thread_save_thyself (GstObject *object,
- xmlNodePtr parent);
-static void gst_thread_restore_thyself (GstObject *object,
- xmlNodePtr self);
+static xmlNodePtr gst_thread_save_thyself (GstObject * object,
+ xmlNodePtr parent);
+static void gst_thread_restore_thyself (GstObject * object, xmlNodePtr self);
#endif
-static void * gst_thread_main_loop (void *arg);
+static void *gst_thread_main_loop (void *arg);
#define GST_TYPE_THREAD_PRIORITY (gst_thread_priority_get_type())
static GType
-gst_thread_priority_get_type(void)
+gst_thread_priority_get_type (void)
{
static GType thread_priority_type = 0;
- static GEnumValue thread_priority[] =
- {
- { G_THREAD_PRIORITY_LOW, "LOW", "Low Priority Scheduling" },
- { G_THREAD_PRIORITY_NORMAL, "NORMAL", "Normal Scheduling" },
- { G_THREAD_PRIORITY_HIGH, "HIGH", "High Priority Scheduling" },
- { G_THREAD_PRIORITY_URGENT, "URGENT", "Urgent Scheduling" },
- { 0, NULL, NULL },
+ static GEnumValue thread_priority[] = {
+ {G_THREAD_PRIORITY_LOW, "LOW", "Low Priority Scheduling"},
+ {G_THREAD_PRIORITY_NORMAL, "NORMAL", "Normal Scheduling"},
+ {G_THREAD_PRIORITY_HIGH, "HIGH", "High Priority Scheduling"},
+ {G_THREAD_PRIORITY_URGENT, "URGENT", "Urgent Scheduling"},
+ {0, NULL, NULL},
};
if (!thread_priority_type) {
- thread_priority_type = g_enum_register_static("GstThreadPriority", thread_priority);
+ thread_priority_type =
+ g_enum_register_static ("GstThreadPriority", thread_priority);
}
return thread_priority_type;
}
GPrivate *gst_thread_current;
GType
-gst_thread_get_type(void) {
+gst_thread_get_type (void)
+{
static GType thread_type = 0;
if (!thread_type) {
static const GTypeInfo thread_info = {
sizeof (GstThreadClass),
- gst_thread_base_init,
+ gst_thread_base_init,
+ NULL,
+ gst_thread_class_init,
NULL,
- gst_thread_class_init,
- NULL,
NULL,
sizeof (GstThread),
4,
NULL
};
thread_type = g_type_register_static (GST_TYPE_BIN, "GstThread",
- &thread_info, 0);
+ &thread_info, 0);
}
return thread_type;
}
gst_element_class_set_details (gstelement_class, &gst_thread_details);
}
-static void do_nothing (gpointer hi) {}
+static void
+do_nothing (gpointer hi)
+{
+}
static void
gst_thread_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
+
#ifndef GST_DISABLE_LOADSAVE
GstObjectClass *gstobject_class = GST_OBJECT_CLASS (g_class);
#endif
parent_class = g_type_class_peek_parent (g_class);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PRIORITY,
- g_param_spec_enum ("priority", "Scheduling Policy", "The scheduling priority of the thread",
- GST_TYPE_THREAD_PRIORITY, G_THREAD_PRIORITY_NORMAL, G_PARAM_READWRITE));
+ g_param_spec_enum ("priority", "Scheduling Policy",
+ "The scheduling priority of the thread", GST_TYPE_THREAD_PRIORITY,
+ G_THREAD_PRIORITY_NORMAL, G_PARAM_READWRITE));
gst_thread_signals[SHUTDOWN] =
- g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstThreadClass, shutdown), NULL, NULL,
- gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstThreadClass, shutdown), NULL, NULL,
+ gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
- gobject_class->dispose = gst_thread_dispose;
+ gobject_class->dispose = gst_thread_dispose;
#ifndef GST_DISABLE_LOADSAVE
- gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself);
- gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_thread_restore_thyself);
+ gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself);
+ gstobject_class->restore_thyself =
+ GST_DEBUG_FUNCPTR (gst_thread_restore_thyself);
#endif
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_thread_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_thread_get_property);
- gstbin_class->child_state_change = GST_DEBUG_FUNCPTR (gst_thread_child_state_change);
+ gstbin_class->child_state_change =
+ GST_DEBUG_FUNCPTR (gst_thread_child_state_change);
}
static void
-gst_thread_init (GTypeInstance *instance, gpointer g_class)
+gst_thread_init (GTypeInstance * instance, gpointer g_class)
{
GstScheduler *scheduler;
GstThread *thread = GST_THREAD (instance);
thread->lock = g_mutex_new ();
thread->cond = g_cond_new ();
- thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */
+ thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */
thread->priority = G_THREAD_PRIORITY_NORMAL;
}
static void
-gst_thread_dispose (GObject *object)
+gst_thread_dispose (GObject * object)
{
GstThread *thread = GST_THREAD (object);
g_mutex_free (thread->lock);
g_cond_free (thread->cond);
- gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (thread), NULL);
+ gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (thread), NULL);
}
/**
* change the thread's priority
*/
void
-gst_thread_set_priority (GstThread *thread, GThreadPriority priority)
+gst_thread_set_priority (GstThread * thread, GThreadPriority priority)
{
g_return_if_fail (GST_IS_THREAD (thread));
}
static void
-gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_thread_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstThread *thread;
}
static void
-gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_thread_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstThread *thread;
*
* Returns: The new thread
*/
-GstElement*
-gst_thread_new (const gchar *name)
+GstElement *
+gst_thread_new (const gchar * name)
{
return gst_element_factory_make ("thread", name);
}
}
static inline void
-gst_thread_release_children_locks (GstThread *thread)
+gst_thread_release_children_locks (GstThread * thread)
{
GstRealPad *peer = NULL;
GstElement *peerelement;
GList *pads;
g_assert (element);
- GST_DEBUG_OBJECT (thread, "waking element \"%s\"", GST_ELEMENT_NAME (element));
+ GST_DEBUG_OBJECT (thread, "waking element \"%s\"",
+ GST_ELEMENT_NAME (element));
elements = g_list_next (elements);
if (!gst_element_release_locks (element))
- g_warning ("element %s could not release locks", GST_ELEMENT_NAME (element));
+ g_warning ("element %s could not release locks",
+ GST_ELEMENT_NAME (element));
pads = GST_ELEMENT_PADS (element);
while (pads) {
if (GST_PAD_PEER (pads->data)) {
- peer = GST_REAL_PAD (GST_PAD_PEER (pads->data));
+ peer = GST_REAL_PAD (GST_PAD_PEER (pads->data));
pads = g_list_next (pads);
} else {
pads = g_list_next (pads);
}
if (!peer)
- continue;
+ continue;
peerelement = GST_PAD_PARENT (peer);
if (!peerelement)
- continue; /* FIXME: deal with case where there's no peer */
+ continue; /* FIXME: deal with case where there's no peer */
if (GST_ELEMENT_SCHED (peerelement) != GST_ELEMENT_SCHED (thread)) {
- GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary", GST_ELEMENT_NAME (element));
- GST_LOG_OBJECT (thread, "waking element \"%s\"", GST_ELEMENT_NAME (peerelement));
- if (!gst_element_release_locks (peerelement))
- g_warning ("element %s could not release locks", GST_ELEMENT_NAME (peerelement));
+ GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary",
+ GST_ELEMENT_NAME (element));
+ GST_LOG_OBJECT (thread, "waking element \"%s\"",
+ GST_ELEMENT_NAME (peerelement));
+ if (!gst_element_release_locks (peerelement))
+ g_warning ("element %s could not release locks",
+ GST_ELEMENT_NAME (peerelement));
}
}
}
}
+
/* stops the main thread, if there is one and grabs the thread's mutex */
static void
-gst_thread_catch (GstThread *thread)
+gst_thread_catch (GstThread * thread)
{
gboolean wait;
- if (thread == gst_thread_get_current()) {
+
+ if (thread == gst_thread_get_current ()) {
/* we're trying to catch ourself */
if (!GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) {
g_mutex_lock (thread->lock);
wait = !GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING);
while (!wait) {
GTimeVal tv;
+
GST_LOG_OBJECT (thread, "catching thread...");
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
g_cond_signal (thread->cond);
gst_thread_release_children_locks (thread);
g_get_current_time (&tv);
- g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */
+ g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */
wait = g_cond_timed_wait (thread->cond, thread->lock, &tv);
}
GST_LOG_OBJECT (thread, "caught thread");
}
static void
-gst_thread_release (GstThread *thread)
+gst_thread_release (GstThread * thread)
{
- if (thread != gst_thread_get_current()) {
+ if (thread != gst_thread_get_current ()) {
g_cond_signal (thread->cond);
g_mutex_unlock (thread->lock);
}
}
static GstElementStateReturn
-gst_thread_change_state (GstElement *element)
+gst_thread_change_state (GstElement * element)
{
GstThread *thread;
GstElementStateReturn ret;
thread = GST_THREAD (element);
GST_DEBUG_OBJECT (element, "changing state from %s to %s",
- gst_element_state_get_name (GST_STATE (element)),
- gst_element_state_get_name (GST_STATE_PENDING (element)));
+ gst_element_state_get_name (GST_STATE (element)),
+ gst_element_state_get_name (GST_STATE_PENDING (element)));
gst_thread_catch (thread);
case GST_STATE_NULL_TO_READY:
/* create the thread */
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
- thread->thread_id = g_thread_create_full(gst_thread_main_loop,
- thread, STACK_SIZE, FALSE, TRUE, thread->priority,
- NULL);
- if (!thread->thread_id){
- GST_ERROR_OBJECT (element, "g_thread_create_full failed");
- goto error_out;
+ thread->thread_id = g_thread_create_full (gst_thread_main_loop,
+ thread, STACK_SIZE, FALSE, TRUE, thread->priority, NULL);
+ if (!thread->thread_id) {
+ GST_ERROR_OBJECT (element, "g_thread_create_full failed");
+ goto error_out;
}
GST_LOG_OBJECT (element, "GThread created");
{
/* FIXME: recurse into sub-bins */
GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread));
+
while (elements) {
- gst_element_enable_threadsafe_properties ((GstElement*)elements->data);
- elements = g_list_next (elements);
+ gst_element_enable_threadsafe_properties ((GstElement *) elements->
+ data);
+ elements = g_list_next (elements);
}
/* reset self to spinning */
- if (thread == gst_thread_get_current())
- GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
+ if (thread == gst_thread_get_current ())
+ GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
break;
}
case GST_STATE_PLAYING_TO_PAUSED:
{
GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread));
+
while (elements) {
- gst_element_disable_threadsafe_properties ((GstElement*)elements->data);
- elements = g_list_next (elements);
+ gst_element_disable_threadsafe_properties ((GstElement *) elements->
+ data);
+ elements = g_list_next (elements);
}
break;
}
GST_LOG_OBJECT (thread, "destroying GThread %p", thread->thread_id);
GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
thread->thread_id = NULL;
- if (thread == gst_thread_get_current()) {
- /* or should we continue? */
- g_warning ("Thread %s is destroying itself. Function call will not return!", GST_ELEMENT_NAME (thread));
- gst_scheduler_reset (GST_ELEMENT_SCHED (thread));
-
- /* unlock and signal - we are out */
- gst_thread_release (thread);
+ if (thread == gst_thread_get_current ()) {
+ /* or should we continue? */
+ g_warning
+ ("Thread %s is destroying itself. Function call will not return!",
+ GST_ELEMENT_NAME (thread));
+ gst_scheduler_reset (GST_ELEMENT_SCHED (thread));
- GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self());
+ /* unlock and signal - we are out */
+ gst_thread_release (thread);
- g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
+ GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self ());
- g_thread_exit (NULL);
+ g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
+
+ g_thread_exit (NULL);
}
/* now wait for the thread to destroy itself */
g_cond_signal (thread->cond);
/* it should be dead now */
break;
default:
- GST_ERROR_OBJECT (element, "unhandled state change! %x",
- GST_STATE_TRANSITION (element));
- g_warning ("thread %s: UNHANDLED STATE CHANGE! %x",
- GST_STR_NULL (GST_OBJECT_NAME (element)), GST_STATE_TRANSITION (element));
+ GST_ERROR_OBJECT (element, "unhandled state change! %x",
+ GST_STATE_TRANSITION (element));
+ g_warning ("thread %s: UNHANDLED STATE CHANGE! %x",
+ GST_STR_NULL (GST_OBJECT_NAME (element)),
+ GST_STATE_TRANSITION (element));
/* FIXME: not doable with current threading mess:
- g_assert_not_reached ();
- */
+ g_assert_not_reached ();
+ */
break;
}
gst_thread_release (thread);
return ret;
-
+
error_out:
GST_CAT_DEBUG (GST_CAT_STATES, "changing state from %s to %s failed for %s",
- gst_element_state_get_name (GST_STATE (element)),
- gst_element_state_get_name (GST_STATE_PENDING (element)),
- GST_ELEMENT_NAME (element));
+ gst_element_state_get_name (GST_STATE (element)),
+ gst_element_state_get_name (GST_STATE_PENDING (element)),
+ GST_ELEMENT_NAME (element));
gst_thread_release (thread);
return GST_STATE_FAILURE;
}
spinning (via gst_thread_catch) - then we change the state. After that the
thread may spin on. */
static void
-gst_thread_child_state_change (GstBin *bin, GstElementState oldstate,
- GstElementState newstate, GstElement *element)
+gst_thread_child_state_change (GstBin * bin, GstElementState oldstate,
+ GstElementState newstate, GstElement * element)
{
GST_LOG_OBJECT (bin, "(from thread %s) child %s changed state from %s to %s",
- gst_thread_get_current() ? GST_ELEMENT_NAME (gst_thread_get_current()) : "(none)",
- GST_ELEMENT_NAME (element), gst_element_state_get_name (oldstate),
- gst_element_state_get_name (newstate));
+ gst_thread_get_current ()? GST_ELEMENT_NAME (gst_thread_get_current ()) :
+ "(none)", GST_ELEMENT_NAME (element),
+ gst_element_state_get_name (oldstate),
+ gst_element_state_get_name (newstate));
if (parent_class->child_state_change)
parent_class->child_state_change (bin, oldstate, newstate, element);
/* We'll wake up the main thread now. Note that we can't lock the thread here,
if (newstate == GST_STATE_PLAYING)
g_cond_signal (GST_THREAD (bin)->cond);
}
+
/**
* gst_thread_main_loop:
* @arg: the thread to start
status = TRUE;
GST_LOG_OBJECT (thread, "starting to iterate");
while (status && GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
- g_mutex_unlock (thread->lock);
- status = gst_bin_iterate (GST_BIN (thread));
- if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) {
+ g_mutex_unlock (thread->lock);
+ status = gst_bin_iterate (GST_BIN (thread));
+ if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) {
GST_FLAG_UNSET (thread, GST_THREAD_MUTEX_LOCKED);
} else {
- g_mutex_lock (thread->lock);
+ g_mutex_lock (thread->lock);
}
}
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
/* unlock and signal - we are out */
-
- GST_LOG_OBJECT (thread, "Thread %p exits main loop", g_thread_self());
+
+ GST_LOG_OBJECT (thread, "Thread %p exits main loop", g_thread_self ());
g_cond_signal (thread->cond);
g_mutex_unlock (thread->lock);
/* don't assume the GstThread object exists anymore now */
#ifndef GST_DISABLE_LOADSAVE
static xmlNodePtr
-gst_thread_save_thyself (GstObject *object,
- xmlNodePtr self)
+gst_thread_save_thyself (GstObject * object, xmlNodePtr self)
{
if (GST_OBJECT_CLASS (parent_class)->save_thyself)
GST_OBJECT_CLASS (parent_class)->save_thyself (object, self);
}
static void
-gst_thread_restore_thyself (GstObject *object,
- xmlNodePtr self)
+gst_thread_restore_thyself (GstObject * object, xmlNodePtr self)
{
GST_LOG_OBJECT (object, "restoring");
#include <gst/gstbin.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS extern GPrivate *gst_thread_current;
-extern GPrivate *gst_thread_current;
-
-typedef enum {
- GST_THREAD_STATE_SPINNING = GST_BIN_FLAG_LAST,
+typedef enum
+{
+ GST_THREAD_STATE_SPINNING = GST_BIN_FLAG_LAST,
GST_THREAD_STATE_REAPING,
/* when iterating with mutex locked (special cases)
may only be set by thread itself */
GST_THREAD_MUTEX_LOCKED,
/* padding */
- GST_THREAD_FLAG_LAST = GST_BIN_FLAG_LAST + 4
+ GST_THREAD_FLAG_LAST = GST_BIN_FLAG_LAST + 4
} GstThreadState;
#define GST_TYPE_THREAD (gst_thread_get_type())
#define GST_IS_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_THREAD))
#define GST_THREAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_THREAD, GstThreadClass))
-typedef struct _GstThread GstThread;
-typedef struct _GstThreadClass GstThreadClass;
+typedef struct _GstThread GstThread;
+typedef struct _GstThreadClass GstThreadClass;
-struct _GstThread {
- GstBin bin;
+struct _GstThread
+{
+ GstBin bin;
- GThread *thread_id; /* id of the thread, if any */
+ GThread *thread_id; /* id of the thread, if any */
GThreadPriority priority;
- GMutex *lock; /* thread lock/condititon pairs */
- GCond *cond; /* used to control the thread */
+ GMutex *lock; /* thread lock/condititon pairs */
+ GCond *cond; /* used to control the thread */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstThreadClass {
+struct _GstThreadClass
+{
GstBinClass parent_class;
/* signals */
- void (*shutdown) (GstThread *thread);
+ void (*shutdown) (GstThread * thread);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_thread_get_type (void);
+GType gst_thread_get_type (void);
-GstElement* gst_thread_new (const gchar *name);
+GstElement *gst_thread_new (const gchar * name);
-void gst_thread_set_priority (GstThread *thread, GThreadPriority priority);
-GstThread * gst_thread_get_current (void);
+void gst_thread_set_priority (GstThread * thread, GThreadPriority priority);
+GstThread *gst_thread_get_current (void);
G_END_DECLS
-
-
#endif /* __GST_THREAD_H__ */
#include "gstlog.h"
static GMutex *mutex = NULL;
-static GCond *cond = NULL;
+static GCond *cond = NULL;
-static GMutex*
-gst_mutex_new_dummy_impl (void)
+static GMutex *
+gst_mutex_new_dummy_impl (void)
{
if (!mutex)
mutex = g_malloc (8);
return mutex;
}
-static void gst_mutex_dummy_impl (GMutex *mutex) { /* NOP */ }
+static void
+gst_mutex_dummy_impl (GMutex * mutex)
+{ /* NOP */
+}
static gboolean
-gst_mutex_trylock_dummy_impl (GMutex *mutex)
+gst_mutex_trylock_dummy_impl (GMutex * mutex)
{
return TRUE;
}
-static GCond*
-gst_cond_new_dummy_impl (void)
+static GCond *
+gst_cond_new_dummy_impl (void)
{
if (!cond)
cond = g_malloc (8);
}
static void
-gst_cond_dummy_impl (GCond *cond) { /* NOP */ }
+gst_cond_dummy_impl (GCond * cond)
+{ /* NOP */
+}
static gboolean
-gst_cond_timed_wait_dummy_impl (GCond *cond, GMutex *mutex, GTimeVal *end_time)
+gst_cond_timed_wait_dummy_impl (GCond * cond, GMutex * mutex,
+ GTimeVal * end_time)
{
struct timeval tvtarget;
GTimeVal tvnow;
guint64 now, target;
gint64 diff;
-
+
target = end_time->tv_sec * 1000000 + end_time->tv_usec;
g_get_current_time (&tvnow);
tvtarget.tv_usec = diff % 1000000;
tvtarget.tv_sec = diff / 1000000;
- select(0, NULL, NULL, NULL, &tvtarget);
+ select (0, NULL, NULL, NULL, &tvtarget);
}
-
+
return TRUE;
}
-static GPrivate*
+static GPrivate *
gst_private_new_dummy_impl (GDestroyNotify destructor)
{
gpointer data;
}
static gpointer
-gst_private_get_dummy_impl (GPrivate *private_key)
+gst_private_get_dummy_impl (GPrivate * private_key)
{
gpointer *data = (gpointer) private_key;
-
+
return *data;
}
static void
-gst_private_set_dummy_impl (GPrivate *private_key, gpointer data)
+gst_private_set_dummy_impl (GPrivate * private_key, gpointer data)
{
- *((gpointer*)private_key) = data;
+ *((gpointer *) private_key) = data;
}
static void
-gst_thread_create_dummy_impl (GThreadFunc func, gpointer data, gulong stack_size,
- gboolean joinable, gboolean bound, GThreadPriority priority,
- gpointer thread, GError **error)
+gst_thread_create_dummy_impl (GThreadFunc func, gpointer data,
+ gulong stack_size, gboolean joinable, gboolean bound,
+ GThreadPriority priority, gpointer thread, GError ** error)
{
g_warning ("GStreamer configured to not use threads");
}
static void
-gst_thread_dummy_impl (void) { /* NOP */ }
+gst_thread_dummy_impl (void)
+{ /* NOP */
+}
static void
-gst_thread_dummy_impl_1 (gpointer thread) { /* NOP */ }
+gst_thread_dummy_impl_1 (gpointer thread)
+{ /* NOP */
+}
static void
-gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority) { /* NOP */ }
+gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority)
+{ /* NOP */
+}
static gboolean
gst_thread_equal_dummy_impl (gpointer thread1, gpointer thread2)
return (thread1 == thread2);
}
-GThreadFunctions
-gst_thread_dummy_functions =
-{
- gst_mutex_new_dummy_impl,
- (void (*)(GMutex *)) gst_mutex_dummy_impl,
- gst_mutex_trylock_dummy_impl,
- (void (*)(GMutex *)) gst_mutex_dummy_impl,
- gst_mutex_dummy_impl,
- gst_cond_new_dummy_impl,
- (void (*)(GCond *)) gst_cond_dummy_impl,
- (void (*)(GCond *)) gst_cond_dummy_impl,
- (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl,
- gst_cond_timed_wait_dummy_impl,
- gst_cond_dummy_impl,
- gst_private_new_dummy_impl,
- gst_private_get_dummy_impl,
- gst_private_set_dummy_impl,
- gst_thread_create_dummy_impl,
- gst_thread_dummy_impl,
- gst_thread_dummy_impl_1,
- gst_thread_dummy_impl,
- gst_thread_set_priority_dummy_impl,
- gst_thread_dummy_impl_1,
- gst_thread_equal_dummy_impl
-};
-
+GThreadFunctions gst_thread_dummy_functions = {
+gst_mutex_new_dummy_impl,
+ (void (*)(GMutex *)) gst_mutex_dummy_impl,
+ gst_mutex_trylock_dummy_impl,
+ (void (*)(GMutex *)) gst_mutex_dummy_impl,
+ gst_mutex_dummy_impl,
+ gst_cond_new_dummy_impl,
+ (void (*)(GCond *)) gst_cond_dummy_impl,
+ (void (*)(GCond *)) gst_cond_dummy_impl,
+ (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl,
+ gst_cond_timed_wait_dummy_impl,
+ gst_cond_dummy_impl,
+ gst_private_new_dummy_impl,
+ gst_private_get_dummy_impl,
+ gst_private_set_dummy_impl,
+ gst_thread_create_dummy_impl,
+ gst_thread_dummy_impl,
+ gst_thread_dummy_impl_1,
+ gst_thread_dummy_impl,
+ gst_thread_set_priority_dummy_impl,
+ gst_thread_dummy_impl_1, gst_thread_equal_dummy_impl};
#include "gstlog.h"
#include "gsttrace.h"
-static
+static
#ifdef __inline__
-__inline__
+ __inline__
#endif
-void
+ void
read_tsc (gint64 * dst)
{
#ifdef HAVE_RDTSC
g_return_val_if_fail (trace != NULL, NULL);
trace->filename = g_strdup (filename);
g_print ("opening '%s'\n", trace->filename);
- trace->fd = open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ trace->fd =
+ open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
perror ("opening trace file");
g_return_val_if_fail (trace->fd > 0, NULL);
trace->buf = g_malloc (size * sizeof (GstTraceEntry));
gst_trace_text_flush (GstTrace * trace)
{
int i;
+
#define STRSIZE (20 + 1 + 10 + 1 + 10 + 1 + 112 + 1 + 1)
char str[STRSIZE];
for (i = 0; i < trace->bufoffset; i++) {
snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n",
- trace->buf[i].timestamp,
- trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message);
+ trace->buf[i].timestamp,
+ trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message);
write (trace->fd, str, strlen (str));
}
trace->bufoffset = 0;
/* global flags */
static GstAllocTraceFlags _gst_trace_flags = 0;
+
/* list of registered tracers */
static GList *_gst_alloc_tracers = NULL;
*
* Returns: A handle to a GstAllocTrace.
*/
-GstAllocTrace*
-_gst_alloc_trace_register (const gchar *name)
+GstAllocTrace *
+_gst_alloc_trace_register (const gchar * name)
{
GstAllocTrace *trace;
*
* Returns: a GList of GstAllocTrace objects.
*/
-const GList*
+const GList *
gst_alloc_trace_list (void)
{
return _gst_alloc_tracers;
{
GList *walk = _gst_alloc_tracers;
int num = 0;
-
+
while (walk) {
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
gst_alloc_trace_print_all (void)
{
GList *walk = _gst_alloc_tracers;
-
+
while (walk) {
GstAllocTrace *trace = (GstAllocTrace *) walk->data;
* Returns: a GstAllocTrace with the given name or NULL when
* no alloc tracer was registered with that name.
*/
-GstAllocTrace*
-gst_alloc_trace_get (const gchar *name)
+GstAllocTrace *
+gst_alloc_trace_get (const gchar * name)
{
GList *walk = _gst_alloc_tracers;
* Print the status of the given GstAllocTrace.
*/
void
-gst_alloc_trace_print (const GstAllocTrace *trace)
+gst_alloc_trace_print (const GstAllocTrace * trace)
{
GSList *mem_live;
if (!mem_live) {
g_print (", no live memory");
- }
- else {
+ } else {
g_print (", dumping live memory: ");
while (mem_live) {
- g_print ("%p ", mem_live->data);
- mem_live = g_slist_next (mem_live);
+ g_print ("%p ", mem_live->data);
+ mem_live = g_slist_next (mem_live);
}
g_print ("\ntotal %d", g_slist_length (trace->mem_live));
}
* Enable the given features on the given GstAllocTrace object.
*/
void
-gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags)
+gst_alloc_trace_set_flags (GstAllocTrace * trace, GstAllocTraceFlags flags)
{
g_return_if_fail (trace != NULL);
#include <glib.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS typedef struct _GstTrace GstTrace;
+typedef struct _GstTraceEntry GstTraceEntry;
-typedef struct _GstTrace GstTrace;
-typedef struct _GstTraceEntry GstTraceEntry;
-
-struct _GstTrace {
+struct _GstTrace
+{
/* where this trace is going */
gchar *filename;
int fd;
gint bufoffset;
};
-struct _GstTraceEntry {
+struct _GstTraceEntry
+{
gint64 timestamp;
guint32 sequence;
guint32 data;
-GstTrace* gst_trace_new (gchar *filename, gint size);
+GstTrace *gst_trace_new (gchar * filename, gint size);
+
+void gst_trace_destroy (GstTrace * trace);
+void gst_trace_flush (GstTrace * trace);
+void gst_trace_text_flush (GstTrace * trace);
-void gst_trace_destroy (GstTrace *trace);
-void gst_trace_flush (GstTrace *trace);
-void gst_trace_text_flush (GstTrace *trace);
#define gst_trace_get_size(trace) ((trace)->bufsize)
#define gst_trace_get_offset(trace) ((trace)->bufoffset)
#define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset)
-void gst_trace_set_default (GstTrace *trace);
+void gst_trace_set_default (GstTrace * trace);
-void _gst_trace_add_entry (GstTrace *trace, guint32 seq,
- guint32 data, gchar *msg);
+void _gst_trace_add_entry (GstTrace * trace, guint32 seq,
+ guint32 data, gchar * msg);
-void gst_trace_read_tsc (gint64 *dst);
+void gst_trace_read_tsc (gint64 * dst);
typedef enum
{
- GST_ALLOC_TRACE_LIVE = (1 << 0),
- GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
+ GST_ALLOC_TRACE_LIVE = (1 << 0),
+ GST_ALLOC_TRACE_MEM_LIVE = (1 << 1)
} GstAllocTraceFlags;
-typedef struct _GstAllocTrace GstAllocTrace;
+typedef struct _GstAllocTrace GstAllocTrace;
-struct _GstAllocTrace {
- gchar *name;
- gint flags;
+struct _GstAllocTrace
+{
+ gchar *name;
+ gint flags;
- gint live;
- GSList *mem_live;
+ gint live;
+ GSList *mem_live;
};
-gboolean gst_alloc_trace_available (void);
-G_CONST_RETURN GList* gst_alloc_trace_list (void);
-GstAllocTrace* _gst_alloc_trace_register (const gchar *name);
+gboolean gst_alloc_trace_available (void);
+G_CONST_RETURN GList *gst_alloc_trace_list (void);
+GstAllocTrace *_gst_alloc_trace_register (const gchar * name);
-int gst_alloc_trace_live_all (void);
-void gst_alloc_trace_print_all (void);
-void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags);
+int gst_alloc_trace_live_all (void);
+void gst_alloc_trace_print_all (void);
+void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags);
-GstAllocTrace* gst_alloc_trace_get (const gchar *name);
-void gst_alloc_trace_print (const GstAllocTrace *trace);
-void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags);
+GstAllocTrace *gst_alloc_trace_get (const gchar * name);
+void gst_alloc_trace_print (const GstAllocTrace * trace);
+void gst_alloc_trace_set_flags (GstAllocTrace * trace,
+ GstAllocTraceFlags flags);
#ifndef GST_DISABLE_ALLOC_TRACE
#ifndef GST_DISABLE_TRACE
extern gint _gst_trace_on;
+
#define gst_trace_add_entry(trace,seq,data,msg) \
if (_gst_trace_on) { \
_gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \
#else /* GST_DISABLE_TRACE */
-#pragma GCC poison gst_trace_new
+#pragma GCC poison gst_trace_new
#pragma GCC poison gst_trace_destroy
#pragma GCC poison gst_trace_flush
#pragma GCC poison gst_trace_text_flush
#pragma GCC poison gst_trace_add_entry
#define gst_alloc_trace_register(name)
-#define gst_alloc_trace_new(trace, mem)
+#define gst_alloc_trace_new(trace, mem)
#define gst_alloc_trace_free(trace, mem)
#define gst_alloc_trace_available() (FALSE)
#define gst_alloc_trace_list() (NULL)
#define _gst_alloc_trace_register(name) (NULL)
-
-#define gst_alloc_trace_print_all()
+
+#define gst_alloc_trace_print_all()
#define gst_alloc_trace_set_flags_all(flags)
-
+
#define gst_alloc_trace_get(name) (NULL)
#define gst_alloc_trace_print(trace)
#define gst_alloc_trace_set_flags(trace,flags)
#endif /* GST_DISABLE_TRACE */
G_END_DECLS
-
#endif /* __GST_TRACE_H__ */
#define __GST_TRASH_STACK_C__
#include "gsttrashstack.h"
-
#include <glib.h>
#include "gstmacros.h"
-G_BEGIN_DECLS
-
-typedef struct _GstTrashStack GstTrashStack;
+G_BEGIN_DECLS typedef struct _GstTrashStack GstTrashStack;
typedef struct _GstTrashStackElement GstTrashStackElement;
-struct _GstTrashStackElement {
+struct _GstTrashStackElement
+{
GstTrashStackElement *next;
};
-typedef volatile gpointer gst_vgpointer;/* gtk-doc volatile workaround */
-typedef volatile gulong gst_vgulong; /* gtk-doc volatile workaround */
-
-struct _GstTrashStack {
- gst_vgpointer head;
- gst_vgulong count; /* for the ABA problem */
- GMutex *lock; /* lock for C fallback */
+typedef volatile gpointer gst_vgpointer; /* gtk-doc volatile workaround */
+typedef volatile gulong gst_vgulong; /* gtk-doc volatile workaround */
+
+struct _GstTrashStack
+{
+ gst_vgpointer head;
+ gst_vgulong count; /* for the ABA problem */
+ GMutex *lock; /* lock for C fallback */
};
-GST_INLINE_FUNC GstTrashStack* gst_trash_stack_new (void);
-GST_INLINE_FUNC void gst_trash_stack_init (GstTrashStack *stack);
-GST_INLINE_FUNC void gst_trash_stack_destroy (GstTrashStack *stack);
-GST_INLINE_FUNC void gst_trash_stack_free (GstTrashStack *stack);
+GST_INLINE_FUNC GstTrashStack *gst_trash_stack_new (void);
+GST_INLINE_FUNC void gst_trash_stack_init (GstTrashStack * stack);
+GST_INLINE_FUNC void gst_trash_stack_destroy (GstTrashStack * stack);
+GST_INLINE_FUNC void gst_trash_stack_free (GstTrashStack * stack);
-GST_INLINE_FUNC void gst_trash_stack_push (GstTrashStack *stack, gpointer mem);
-GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack *stack);
+GST_INLINE_FUNC void gst_trash_stack_push (GstTrashStack * stack, gpointer mem);
+GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack * stack);
#if defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)
-#if defined (USE_FAST_STACK_TRASH) && defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
+#if defined (USE_FAST_STACK_TRASH) && defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
#ifdef GST_CONFIG_NO_SMP
#define SMP_LOCK ""
* intel ia32 optimized lockfree implementations
*/
GST_INLINE_FUNC void
-gst_trash_stack_init (GstTrashStack *stack)
+gst_trash_stack_init (GstTrashStack * stack)
{
stack->head = NULL;
stack->count = 0;
}
GST_INLINE_FUNC void
-gst_trash_stack_destroy (GstTrashStack *stack)
+gst_trash_stack_destroy (GstTrashStack * stack)
{
}
GST_INLINE_FUNC void
-gst_trash_stack_push (GstTrashStack *stack, gpointer mem)
+gst_trash_stack_push (GstTrashStack * stack, gpointer mem)
{
- __asm__ __volatile__ (
- "1: \n\t"
- " movl %2, (%1); \n\t" /* mem->next == stack->head */
- SMP_LOCK "cmpxchg %1, %0; \n\t" /* if head unchanged, move mem into it */
- " jnz 1b; \n" /* head changed, retry */
- :
- : "m" (*stack),
- "r" (mem),
- "a" (stack->head)
- );
+ __asm__ __volatile__ ("1: \n\t" " movl %2, (%1); \n\t" /* mem->next == stack->head */
+ SMP_LOCK "cmpxchg %1, %0; \n\t" /* if head unchanged, move mem into it */
+ " jnz 1b; \n" /* head changed, retry */
+ ::"m" (*stack), "r" (mem), "a" (stack->head)
+ );
}
GST_INLINE_FUNC gpointer
-gst_trash_stack_pop (GstTrashStack *stack)
+gst_trash_stack_pop (GstTrashStack * stack)
{
GstTrashStackElement *head;
* into place. This is usually solved using a counter which makes it highly
* inlikely that we manage to grab the wrong head->next value.
*/
- __asm__ __volatile__ (
- " testl %%eax, %%eax; \n\t" /* if (head == NULL) return */
- " jz 20f; \n\t"
- "10: \n\t"
- " movl (%%eax), %%ebx; \n\t" /* take value pointed to by head (head->next) */
- " movl %%edx, %%ecx; \n\t" /* take counter */
- " incl %%ecx; \n\t" /* and increment */
- SMP_LOCK "cmpxchg8b %1; \n\t" /* if eax:edx == *stack, move ebx:ecx to *stack,
+ __asm__ __volatile__ (" testl %%eax, %%eax; \n\t" /* if (head == NULL) return */
+ " jz 20f; \n\t" "10: \n\t" " movl (%%eax), %%ebx; \n\t" /* take value pointed to by head (head->next) */
+ " movl %%edx, %%ecx; \n\t" /* take counter */
+ " incl %%ecx; \n\t" /* and increment */
+ SMP_LOCK "cmpxchg8b %1; \n\t" /* if eax:edx == *stack, move ebx:ecx to *stack,
* else *stack is moved into eax:edx again... */
- " jnz 10b; \n\t" /* ... and we retry */
- "20: \n"
- : "=a" (head)
- : "m" (*stack),
- "a" (stack->head),
- "d" (stack->count)
- : "ecx", "ebx"
- );
+ " jnz 10b; \n\t" /* ... and we retry */
+ "20: \n":"=a" (head)
+ :"m" (*stack), "a" (stack->head), "d" (stack->count)
+ :"ecx", "ebx");
return head;
}
* generic implementation
*/
GST_INLINE_FUNC void
-gst_trash_stack_init (GstTrashStack *stack)
+gst_trash_stack_init (GstTrashStack * stack)
{
stack->head = NULL;
- stack->lock = g_mutex_new();
+ stack->lock = g_mutex_new ();
}
GST_INLINE_FUNC void
-gst_trash_stack_destroy (GstTrashStack *stack)
+gst_trash_stack_destroy (GstTrashStack * stack)
{
g_mutex_free (stack->lock);
}
GST_INLINE_FUNC void
-gst_trash_stack_push (GstTrashStack *stack, gpointer mem)
+gst_trash_stack_push (GstTrashStack * stack, gpointer mem)
{
GstTrashStackElement *elem = (GstTrashStackElement *) mem;
}
GST_INLINE_FUNC gpointer
-gst_trash_stack_pop (GstTrashStack *stack)
+gst_trash_stack_pop (GstTrashStack * stack)
{
GstTrashStackElement *head;
-
+
g_mutex_lock (stack->lock);
head = (GstTrashStackElement *) stack->head;
if (head)
/*
* common functions
*/
-GST_INLINE_FUNC GstTrashStack*
+GST_INLINE_FUNC GstTrashStack *
gst_trash_stack_new (void)
{
GstTrashStack *stack;
}
GST_INLINE_FUNC void
-gst_trash_stack_free (GstTrashStack *stack)
+gst_trash_stack_free (GstTrashStack * stack)
{
gst_trash_stack_destroy (stack);
g_free (stack);
}
-#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)*/
+#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) */
G_END_DECLS
-
#endif /* __GST_TRASH_STACK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_type_find_debug);
#define GST_CAT_DEFAULT gst_type_find_debug
-static void gst_type_find_factory_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_type_find_factory_init (GTypeInstance * instance,
- gpointer g_class);
-static void gst_type_find_factory_dispose (GObject * object);
+static void gst_type_find_factory_class_init (gpointer g_class,
+ gpointer class_data);
+static void gst_type_find_factory_init (GTypeInstance * instance,
+ gpointer g_class);
+static void gst_type_find_factory_dispose (GObject * object);
-static void gst_type_find_factory_unload_thyself (GstPluginFeature * feature);
+static void gst_type_find_factory_unload_thyself (GstPluginFeature * feature);
-static void gst_type_find_load_plugin (GstTypeFind * find,
- gpointer data);
+static void gst_type_find_load_plugin (GstTypeFind * find, gpointer data);
static GstPluginFeatureClass *parent_class = NULL;
gst_type_find_factory_get_type (void)
{
static GType typefind_type = 0;
-
+
if (!typefind_type) {
static const GTypeInfo typefind_info = {
sizeof (GstTypeFindFactoryClass),
NULL
};
typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
- "GstTypeFindFactory",
- &typefind_info, 0);
- GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND",
- GST_DEBUG_FG_GREEN, "typefinding subsystem");
+ "GstTypeFindFactory", &typefind_info, 0);
+ GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND",
+ GST_DEBUG_FG_GREEN, "typefinding subsystem");
}
return typefind_type;
static void
gst_type_find_factory_class_init (gpointer g_class, gpointer class_data)
{
- GstPluginFeatureClass *gstpluginfeature_class = GST_PLUGIN_FEATURE_CLASS (g_class);
+ GstPluginFeatureClass *gstpluginfeature_class =
+ GST_PLUGIN_FEATURE_CLASS (g_class);
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
-
+
parent_class = g_type_class_peek_parent (g_class);
-
+
object_class->dispose = gst_type_find_factory_dispose;
-
- gstpluginfeature_class->unload_thyself = GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself);
+
+ gstpluginfeature_class->unload_thyself =
+ GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself);
}
static void
-gst_type_find_factory_init (GTypeInstance *instance, gpointer g_class)
+gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
{
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
factory->function = gst_type_find_load_plugin;
}
static void
-gst_type_find_factory_dispose (GObject *object)
+gst_type_find_factory_dispose (GObject * object)
{
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object);
}
}
static void
-gst_type_find_factory_unload_thyself (GstPluginFeature *feature)
+gst_type_find_factory_unload_thyself (GstPluginFeature * feature)
{
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
factory->user_data = factory;
}
static void
-gst_type_find_load_plugin (GstTypeFind *find, gpointer data)
+gst_type_find_load_plugin (GstTypeFind * find, gpointer data)
{
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (data);
- GST_DEBUG_OBJECT (factory, "need to load typefind function %s", GST_PLUGIN_FEATURE_NAME (factory));
-
+ GST_DEBUG_OBJECT (factory, "need to load typefind function %s",
+ GST_PLUGIN_FEATURE_NAME (factory));
+
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
if (factory->function == gst_type_find_load_plugin) {
/* looks like we didn't get a real typefind function */
- g_warning ("could not load valid typefind function for feature '%s'\n", GST_PLUGIN_FEATURE_NAME (factory));
+ g_warning ("could not load valid typefind function for feature '%s'\n",
+ GST_PLUGIN_FEATURE_NAME (factory));
} else {
g_assert (factory->function);
gst_type_find_factory_call_function (factory, find);
}
}
}
+
/**
* gst_type_find_factory_get_list:
*
{
return gst_registry_pool_feature_list (GST_TYPE_TYPE_FIND_FACTORY);
}
+
/**
* gst_type_find_factory_get_caps:
* @factory: a factory
* Returns: the #GstCaps associated with this factory
*/
const GstCaps *
-gst_type_find_factory_get_caps (const GstTypeFindFactory *factory)
+gst_type_find_factory_get_caps (const GstTypeFindFactory * factory)
{
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
return factory->caps;
}
+
/**
* gst_type_find_factory_get_extensions:
* @factory: a factory
* Returns: a NULL-terminated array of extensions associated with this factory
*/
gchar **
-gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory)
+gst_type_find_factory_get_extensions (const GstTypeFindFactory * factory)
{
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
return factory->extensions;
}
+
/**
* gst_type_find_factory_call_function:
* @factory: a factory
* Calls the typefinding function associated with this factory.
*/
void
-gst_type_find_factory_call_function (const GstTypeFindFactory *factory, GstTypeFind *find)
+gst_type_find_factory_call_function (const GstTypeFindFactory * factory,
+ GstTypeFind * find)
{
g_return_if_fail (GST_IS_TYPE_FIND_FACTORY (factory));
g_return_if_fail (find != NULL);
factory->function (find, factory->user_data);
}
+
/**
* gst_type_find_register:
* @plugin: the GstPlugin to register with
* Returns: TRUE on success, FALSE otherwise
*/
gboolean
-gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank,
- GstTypeFindFunction func, gchar **extensions,
- const GstCaps *possible_caps, gpointer data)
+gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
+ GstTypeFindFunction func, gchar ** extensions,
+ const GstCaps * possible_caps, gpointer data)
{
GstTypeFindFactory *factory;
-
+
g_return_val_if_fail (plugin != NULL, FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (func != NULL, FALSE);
GST_INFO ("registering typefind function for %s", name);
- factory = GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name, GST_TYPE_TYPE_FIND_FACTORY));
+ factory =
+ GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name,
+ GST_TYPE_TYPE_FIND_FACTORY));
if (!factory) {
factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
g_strfreev (factory->extensions);
factory->extensions = g_strdupv (extensions);
- gst_caps_replace (&factory->caps, gst_caps_copy(possible_caps));
+ gst_caps_replace (&factory->caps, gst_caps_copy (possible_caps));
factory->function = func;
factory->user_data = data;
* Returns: the requested data or NULL if that data is not available.
*/
guint8 *
-gst_type_find_peek (GstTypeFind *find, gint64 offset, guint size)
+gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
{
g_return_val_if_fail (find->peek != NULL, NULL);
return find->peek (find->data, offset, size);
}
+
/**
* gst_type_find_suggest:
* @find: the find object the function was called with
* It is up to the caller of the typefind function to interpret these values.
*/
void
-gst_type_find_suggest (GstTypeFind *find, guint probability, const GstCaps *caps)
+gst_type_find_suggest (GstTypeFind * find, guint probability,
+ const GstCaps * caps)
{
g_return_if_fail (find->suggest != NULL);
g_return_if_fail (probability <= 100);
find->suggest (find->data, probability, caps);
}
+
/**
* gst_type_find_get_length:
* @find: the find object the function was called with
* Returns: the length of the data stream or 0 if it is not available.
*/
guint64
-gst_type_find_get_length (GstTypeFind *find)
+gst_type_find_get_length (GstTypeFind * find)
{
if (find->get_length == NULL)
return 0;
- return find->get_length(find->data);
+ return find->get_length (find->data);
}
-
#include <gst/gsttypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TYPE_FIND_FACTORY (gst_type_find_factory_get_type())
#define GST_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactory))
#define GST_IS_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_FACTORY))
#define GST_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
#define GST_IS_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_FACTORY))
#define GST_TYPE_FIND_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
-
typedef struct _GstTypeFind GstTypeFind;
typedef struct _GstTypeFindFactory GstTypeFindFactory;
typedef struct _GstTypeFindFactoryClass GstTypeFindFactoryClass;
-typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer data);
+typedef void (*GstTypeFindFunction) (GstTypeFind * find, gpointer data);
-typedef enum {
+typedef enum
+{
GST_TYPE_FIND_MINIMUM = 1,
GST_TYPE_FIND_POSSIBLE = 50,
GST_TYPE_FIND_LIKELY = 80,
GST_TYPE_FIND_MAXIMUM = 100,
} GstTypeFindProbability;
-struct _GstTypeFind {
+struct _GstTypeFind
+{
/* private to the caller of the typefind function */
- guint8 * (* peek) (gpointer data,
- gint64 offset,
- guint size);
- void (* suggest) (gpointer data,
- guint probability,
- const GstCaps * caps);
-
- gpointer data;
-
+ guint8 *(*peek) (gpointer data, gint64 offset, guint size);
+ void (*suggest) (gpointer data, guint probability, const GstCaps * caps);
+
+ gpointer data;
+
/* optional */
- guint64 (* get_length) (gpointer data);
+ guint64 (*get_length) (gpointer data);
/* <private> */
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstTypeFindFactory {
- GstPluginFeature feature;
+struct _GstTypeFindFactory
+{
+ GstPluginFeature feature;
/* <private> */
- GstTypeFindFunction function;
- gchar ** extensions;
- GstCaps * caps; /* FIXME: not yet saved in registry */
-
- gpointer user_data;
-
+ GstTypeFindFunction function;
+ gchar **extensions;
+ GstCaps *caps; /* FIXME: not yet saved in registry */
+
+ gpointer user_data;
+
gpointer _gst_reserved[GST_PADDING];
};
-
-struct _GstTypeFindFactoryClass {
- GstPluginFeatureClass parent;
+
+struct _GstTypeFindFactoryClass
+{
+ GstPluginFeatureClass parent;
/* <private> */
-
+
gpointer _gst_reserved[GST_PADDING];
};
/* typefind function interface */
-guint8 * gst_type_find_peek (GstTypeFind * find,
- gint64 offset,
- guint size);
-void gst_type_find_suggest (GstTypeFind * find,
- guint probability,
- const GstCaps * caps);
-guint64 gst_type_find_get_length (GstTypeFind * find);
+guint8 *gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size);
+void gst_type_find_suggest (GstTypeFind * find,
+ guint probability, const GstCaps * caps);
+guint64 gst_type_find_get_length (GstTypeFind * find);
/* registration interface */
-gboolean gst_type_find_register (GstPlugin * plugin,
- const gchar * name,
- guint rank,
- GstTypeFindFunction func,
- gchar ** extensions,
- const GstCaps * possible_caps,
- gpointer data);
+gboolean gst_type_find_register (GstPlugin * plugin,
+ const gchar * name,
+ guint rank,
+ GstTypeFindFunction func,
+ gchar ** extensions, const GstCaps * possible_caps, gpointer data);
/* typefinding interface */
-GType gst_type_find_factory_get_type (void);
-
-GList * gst_type_find_factory_get_list (void);
+GType gst_type_find_factory_get_type (void);
-gchar ** gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory);
-const GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory);
-void gst_type_find_factory_call_function (const GstTypeFindFactory *factory,
- GstTypeFind *find);
+GList *gst_type_find_factory_get_list (void);
+gchar **gst_type_find_factory_get_extensions (const GstTypeFindFactory *
+ factory);
+const GstCaps *gst_type_find_factory_get_caps (const GstTypeFindFactory *
+ factory);
+void gst_type_find_factory_call_function (const GstTypeFindFactory * factory,
+ GstTypeFind * find);
-G_END_DECLS
+G_END_DECLS
#endif /* __GST_TYPE_FIND_H__ */
#include <glib.h>
-G_BEGIN_DECLS
-
-typedef struct _GstObject GstObject;
+G_BEGIN_DECLS typedef struct _GstObject GstObject;
typedef struct _GstObjectClass GstObjectClass;
typedef struct _GstPad GstPad;
typedef struct _GstPadClass GstPadClass;
typedef struct _GstSchedulerClass GstSchedulerClass;
typedef struct _GstEvent GstEvent;
-typedef enum {
- GST_STATE_VOID_PENDING = 0,
- GST_STATE_NULL = (1 << 0),
- GST_STATE_READY = (1 << 1),
- GST_STATE_PAUSED = (1 << 2),
- GST_STATE_PLAYING = (1 << 3)
+typedef enum
+{
+ GST_STATE_VOID_PENDING = 0,
+ GST_STATE_NULL = (1 << 0),
+ GST_STATE_READY = (1 << 1),
+ GST_STATE_PAUSED = (1 << 2),
+ GST_STATE_PLAYING = (1 << 3)
} GstElementState;
-typedef enum {
- GST_STATE_FAILURE = 0,
- GST_STATE_SUCCESS = 1,
- GST_STATE_ASYNC = 2
+typedef enum
+{
+ GST_STATE_FAILURE = 0,
+ GST_STATE_SUCCESS = 1,
+ GST_STATE_ASYNC = 2
} GstElementStateReturn;
-typedef enum {
+typedef enum
+{
GST_RESULT_OK,
GST_RESULT_NOK,
GST_RESULT_NOT_IMPL
#define GST_PADDING_INIT { 0 }
G_END_DECLS
-
#endif /* __GST_TYPES_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_uri_handler_debug);
#define GST_CAT_DEFAULT gst_uri_handler_debug
-static void gst_uri_handler_base_init (gpointer g_class);
+static void gst_uri_handler_base_init (gpointer g_class);
GType
gst_uri_handler_get_type (void)
NULL
};
urihandler_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstURIHandler", &urihandler_info, 0);
+ "GstURIHandler", &urihandler_info, 0);
- GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD, "handling of URIs");
+ GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD,
+ "handling of URIs");
}
return urihandler_type;
}
if (!initialized) {
g_signal_new ("new-uri", GST_TYPE_URI_HANDLER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL,
- gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
+ G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL,
+ gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
initialized = TRUE;
}
}
static void
-gst_uri_protocol_check_internal (const gchar *uri, gchar **endptr)
+gst_uri_protocol_check_internal (const gchar * uri, gchar ** endptr)
{
gchar *check = (gchar *) uri;
-
+
g_assert (uri != NULL);
g_assert (endptr != NULL);
if (g_ascii_isalpha (*check)) {
check++;
- while (g_ascii_isalnum (*check)) check++;
+ while (g_ascii_isalnum (*check))
+ check++;
}
*endptr = check;
}
+
/**
* gst_uri_protocol_is_valid:
* @protocol: string to check
* Returns: TRUE if the string is a valid protocol identifier
*/
gboolean
-gst_uri_protocol_is_valid (const gchar *protocol)
+gst_uri_protocol_is_valid (const gchar * protocol)
{
gchar *endptr;
-
+
g_return_val_if_fail (protocol != NULL, FALSE);
-
+
gst_uri_protocol_check_internal (protocol, &endptr);
return *endptr == '\0' && endptr != protocol;
}
+
/**
* gst_uri_is_valid:
* @protocol: string to check
* Returns: TRUE if the string is a valid URI
*/
gboolean
-gst_uri_is_valid (const gchar *uri)
+gst_uri_is_valid (const gchar * uri)
{
gchar *endptr;
-
+
g_return_val_if_fail (uri != NULL, FALSE);
-
+
gst_uri_protocol_check_internal (uri, &endptr);
- return (*endptr == ':' &&
- *(endptr + 1) == '/' &&
- *(endptr + 2) == '/');
+ return (*endptr == ':' && *(endptr + 1) == '/' && *(endptr + 2) == '/');
}
+
/**
* gst_uri_get_protocol:
* @uri: URI to get protocol from
* Returns: The protocol for this URI.
*/
gchar *
-gst_uri_get_protocol (const gchar *uri)
+gst_uri_get_protocol (const gchar * uri)
{
gchar *colon;
-
+
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
return g_strndup (uri, colon - uri);
}
+
/**
* gst_uri_get_location:
* @uri: URI to get the location from
* Returns: The location for this URI.
*/
gchar *
-gst_uri_get_location (const gchar *uri)
+gst_uri_get_location (const gchar * uri)
{
gchar *colon;
-
+
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
return g_strdup (colon + 3);
}
+
/**
* gst_uri_construct:
* @protocol: protocol for URI
* Returns: a new string for this URI
*/
gchar *
-gst_uri_construct (const gchar *protocol, const gchar *location)
+gst_uri_construct (const gchar * protocol, const gchar * location)
{
g_return_val_if_fail (gst_uri_protocol_is_valid (protocol), NULL);
g_return_val_if_fail (location != NULL, NULL);
return g_strdup_printf ("%s://%s", protocol, location);
}
-typedef struct{
- GstURIType type;
- gchar * protocol;
+typedef struct
+{
+ GstURIType type;
+ gchar *protocol;
} SearchEntry;
static gboolean
-search_by_entry (GstPluginFeature *feature, gpointer search_entry)
+search_by_entry (GstPluginFeature * feature, gpointer search_entry)
{
gchar **protocols;
GstElementFactory *factory;
if (gst_element_factory_get_uri_type (factory) != entry->type)
return FALSE;
-
+
protocols = gst_element_factory_get_uri_protocols (factory);
/* must be set when uri type is valid */
g_assert (protocols);
}
return FALSE;
}
+
static gint
sort_by_rank (gconstpointer a, gconstpointer b)
{
GstPluginFeature *first = GST_PLUGIN_FEATURE (a);
GstPluginFeature *second = GST_PLUGIN_FEATURE (b);
- return gst_plugin_feature_get_rank (second) - gst_plugin_feature_get_rank (first);
+ return gst_plugin_feature_get_rank (second) -
+ gst_plugin_feature_get_rank (first);
}
+
/**
* gst_element_make_from_uri:
* @type: wether to create a source or a sink
* Returns: a new element or NULL if none could be created
*/
GstElement *
-gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar *elementname)
+gst_element_make_from_uri (const GstURIType type, const gchar * uri,
+ const gchar * elementname)
{
GList *possibilities, *walk;
SearchEntry entry;
entry.type = type;
entry.protocol = gst_uri_get_protocol (uri);
- possibilities = gst_registry_pool_feature_filter (search_by_entry, FALSE, &entry);
+ possibilities =
+ gst_registry_pool_feature_filter (search_by_entry, FALSE, &entry);
g_free (entry.protocol);
if (!possibilities) {
- GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source", uri);
+ GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source",
+ uri);
return NULL;
}
-
+
possibilities = g_list_sort (possibilities, sort_by_rank);
walk = possibilities;
while (walk) {
- if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data),
- elementname)) != NULL) {
+ if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data),
+ elementname)) != NULL) {
GstURIHandler *handler = GST_URI_HANDLER (ret);
+
if (gst_uri_handler_set_uri (handler, uri))
break;
g_object_unref (ret);
}
g_list_free (possibilities);
- GST_LOG_OBJECT (ret, "created %s for URL '%s'", type == GST_URI_SINK ? "sink" : "source", uri);
+ GST_LOG_OBJECT (ret, "created %s for URL '%s'",
+ type == GST_URI_SINK ? "sink" : "source", uri);
return ret;
}
+
/**
* gst_uri_handler_get_uri_type:
* @handler: Handler to query type of
* Returns: the type of the URI handler
*/
guint
-gst_uri_handler_get_uri_type (GstURIHandler *handler)
+gst_uri_handler_get_uri_type (GstURIHandler * handler)
{
GstURIHandlerInterface *iface;
guint ret;
-
+
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), GST_URI_UNKNOWN);
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
return ret;
}
+
/**
* gst_uri_handler_get_protocols:
* @handler: Handler to get protocols for
* Returns: the supported protocols
*/
gchar **
-gst_uri_handler_get_protocols (GstURIHandler *handler)
+gst_uri_handler_get_protocols (GstURIHandler * handler)
{
GstURIHandlerInterface *iface;
gchar **ret;
-
+
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL);
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
return ret;
}
+
/**
* gst_uri_handler_get_uri:
* @handler: handler to query URI of
* Returns: the URI
*/
G_CONST_RETURN gchar *
-gst_uri_handler_get_uri (GstURIHandler *handler)
+gst_uri_handler_get_uri (GstURIHandler * handler)
{
GstURIHandlerInterface *iface;
const gchar *ret;
-
+
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL);
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
ret = iface->get_uri (handler);
if (ret != NULL)
g_return_val_if_fail (gst_uri_is_valid (ret), NULL);
-
+
return ret;
}
+
/**
* gst_uri_handler_set_uri:
* @handler: handler to set URI of
* Returns: TRUE, if the URI was set successfully
*/
gboolean
-gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri)
+gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstURIHandlerInterface *iface;
-
+
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
g_return_val_if_fail (iface->set_uri != NULL, FALSE);
return iface->set_uri (handler, uri);
}
+
/**
* gst_uri_handler_new_uri:
* @handler: handler with a new URI
* This function should only be called by URI handlers themselves.
*/
void
-gst_uri_handler_new_uri (GstURIHandler *handler, const gchar *uri)
+gst_uri_handler_new_uri (GstURIHandler * handler, const gchar * uri)
{
g_return_if_fail (GST_IS_URI_HANDLER (handler));
#include <gst/gstelement.h>
#include <gst/gstpluginfeature.h>
-G_BEGIN_DECLS
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
GST_URI_UNKNOWN,
GST_URI_SINK,
GST_URI_SRC
typedef struct _GstURIHandler GstURIHandler;
typedef struct _GstURIHandlerInterface GstURIHandlerInterface;
-struct _GstURIHandlerInterface {
- GTypeInterface parent;
+struct _GstURIHandlerInterface
+{
+ GTypeInterface parent;
/* signals */
- void (* new_uri) (GstURIHandler * handler,
- const gchar * uri);
+ void (*new_uri) (GstURIHandler * handler, const gchar * uri);
/* idea for the future ?
- gboolean (* require_password) (GstURIHandler * handler,
- gchar ** username,
- gchar ** password);
+ gboolean (* require_password) (GstURIHandler * handler,
+ gchar ** username,
+ gchar ** password);
*/
/* vtable */
/* querying capabilities */
- GstURIType (* get_type) (void);
- gchar ** (* get_protocols) (void);
+ GstURIType (*get_type) (void);
+ gchar **(*get_protocols) (void);
/* using the interface */
- G_CONST_RETURN gchar *(* get_uri) (GstURIHandler * handler);
- gboolean (* set_uri) (GstURIHandler * handler,
- const gchar * uri);
-
+ G_CONST_RETURN gchar *(*get_uri) (GstURIHandler * handler);
+ gboolean (*set_uri) (GstURIHandler * handler, const gchar * uri);
+
/* we might want to add functions here to query features, someone with gnome-vfs knowledge go ahead */
gpointer _gst_reserved[GST_PADDING];
/* general URI functions */
-gboolean gst_uri_protocol_is_valid (const gchar * protocol);
-gboolean gst_uri_is_valid (const gchar * uri);
-gchar * gst_uri_get_protocol (const gchar * uri);
-gchar * gst_uri_get_location (const gchar * uri);
-gchar * gst_uri_construct (const gchar * protocol,
- const gchar * location);
+gboolean gst_uri_protocol_is_valid (const gchar * protocol);
+gboolean gst_uri_is_valid (const gchar * uri);
+gchar *gst_uri_get_protocol (const gchar * uri);
+gchar *gst_uri_get_location (const gchar * uri);
+gchar *gst_uri_construct (const gchar * protocol, const gchar * location);
-GstElement * gst_element_make_from_uri (const GstURIType type,
- const gchar * uri,
- const gchar * elementname);
+GstElement *gst_element_make_from_uri (const GstURIType type,
+ const gchar * uri, const gchar * elementname);
/* accessing the interface */
-GType gst_uri_handler_get_type (void);
+GType gst_uri_handler_get_type (void);
-guint gst_uri_handler_get_uri_type (GstURIHandler * handler);
-gchar ** gst_uri_handler_get_protocols (GstURIHandler * handler);
-G_CONST_RETURN gchar * gst_uri_handler_get_uri (GstURIHandler * handler);
-gboolean gst_uri_handler_set_uri (GstURIHandler * handler,
- const gchar * uri);
-void gst_uri_handler_new_uri (GstURIHandler * handler,
- const gchar * uri);
+guint gst_uri_handler_get_uri_type (GstURIHandler * handler);
+gchar **gst_uri_handler_get_protocols (GstURIHandler * handler);
+G_CONST_RETURN gchar *gst_uri_handler_get_uri (GstURIHandler * handler);
+gboolean gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri);
+void gst_uri_handler_new_uri (GstURIHandler * handler, const gchar * uri);
G_END_DECLS
-
#endif /* __GST_URI_H__ */
#include <glib.h>
G_BEGIN_DECLS
-
/* a static type for making uri element properties */
#define GST_TYPE_URI (gst_uri_get_uri_type())
-GType gst_uri_get_uri_type (void);
+ GType gst_uri_get_uri_type (void);
G_END_DECLS
-
#endif /* __GST_URI_TYPE_H */
* Dumps the memory block into a hex representation. Useful for debugging.
*/
void
-gst_util_dump_mem (guchar *mem, guint size)
+gst_util_dump_mem (guchar * mem, guint size)
{
guint i, j;
GString *string = g_string_sized_new (50);
while (i < size) {
if (g_ascii_isprint (mem[i]))
g_string_append_printf (chars, "%c", mem[i]);
- else
+ else
g_string_append_printf (chars, ".");
g_string_append_printf (string, "%02x ", mem[i]);
i++;
if (j == 16 || i == size) {
- g_print ("%08x (%p): %-48.48s %-16.16s\n", i-j, mem+i-j, string->str, chars->str);
+ g_print ("%08x (%p): %-48.48s %-16.16s\n", i - j, mem + i - j,
+ string->str, chars->str);
g_string_set_size (string, 0);
g_string_set_size (chars, 0);
j = 0;
* sets the value with it.
*/
void
-gst_util_set_value_from_string(GValue *value, const gchar *value_str)
+gst_util_set_value_from_string (GValue * value, const gchar * value_str)
{
- g_return_if_fail(value != NULL);
- g_return_if_fail(value_str != NULL);
-
- GST_CAT_DEBUG (GST_CAT_PARAMS, "parsing '%s' to type %s", value_str, g_type_name(G_VALUE_TYPE(value)));
-
- switch (G_VALUE_TYPE(value)) {
- case G_TYPE_STRING:
- g_value_set_string(value, g_strdup(value_str));
- break;
- case G_TYPE_ENUM:
- case G_TYPE_INT: {
- gint i;
- sscanf (value_str, "%d", &i);
- g_value_set_int(value, i);
- break;
- }
- case G_TYPE_UINT: {
- guint i;
- sscanf (value_str, "%u", &i);
- g_value_set_uint(value, i);
- break;
- }
- case G_TYPE_LONG: {
- glong i;
- sscanf (value_str, "%ld", &i);
- g_value_set_long(value, i);
- break;
- }
- case G_TYPE_ULONG: {
- gulong i;
- sscanf (value_str, "%lu", &i);
- g_value_set_ulong(value, i);
- break;
- }
- case G_TYPE_BOOLEAN: {
- gboolean i = FALSE;
- if (!strncmp ("true", value_str, 4)) i = TRUE;
- g_value_set_boolean(value, i);
- break;
- }
- case G_TYPE_CHAR: {
- gchar i;
- sscanf (value_str, "%c", &i);
- g_value_set_char(value, i);
- break;
- }
- case G_TYPE_UCHAR: {
- guchar i;
- sscanf (value_str, "%c", &i);
- g_value_set_uchar(value, i);
- break;
- }
- case G_TYPE_FLOAT: {
- gfloat i;
- sscanf (value_str, "%f", &i);
- g_value_set_float(value, i);
- break;
- }
- case G_TYPE_DOUBLE: {
- gfloat i;
- sscanf (value_str, "%g", &i);
- g_value_set_double(value, (gdouble)i);
- break;
- }
- default:
- break;
- }
+ g_return_if_fail (value != NULL);
+ g_return_if_fail (value_str != NULL);
+
+ GST_CAT_DEBUG (GST_CAT_PARAMS, "parsing '%s' to type %s", value_str,
+ g_type_name (G_VALUE_TYPE (value)));
+
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_STRING:
+ g_value_set_string (value, g_strdup (value_str));
+ break;
+ case G_TYPE_ENUM:
+ case G_TYPE_INT:{
+ gint i;
+
+ sscanf (value_str, "%d", &i);
+ g_value_set_int (value, i);
+ break;
+ }
+ case G_TYPE_UINT:{
+ guint i;
+
+ sscanf (value_str, "%u", &i);
+ g_value_set_uint (value, i);
+ break;
+ }
+ case G_TYPE_LONG:{
+ glong i;
+
+ sscanf (value_str, "%ld", &i);
+ g_value_set_long (value, i);
+ break;
+ }
+ case G_TYPE_ULONG:{
+ gulong i;
+
+ sscanf (value_str, "%lu", &i);
+ g_value_set_ulong (value, i);
+ break;
+ }
+ case G_TYPE_BOOLEAN:{
+ gboolean i = FALSE;
+
+ if (!strncmp ("true", value_str, 4))
+ i = TRUE;
+ g_value_set_boolean (value, i);
+ break;
+ }
+ case G_TYPE_CHAR:{
+ gchar i;
+
+ sscanf (value_str, "%c", &i);
+ g_value_set_char (value, i);
+ break;
+ }
+ case G_TYPE_UCHAR:{
+ guchar i;
+
+ sscanf (value_str, "%c", &i);
+ g_value_set_uchar (value, i);
+ break;
+ }
+ case G_TYPE_FLOAT:{
+ gfloat i;
+
+ sscanf (value_str, "%f", &i);
+ g_value_set_float (value, i);
+ break;
+ }
+ case G_TYPE_DOUBLE:{
+ gfloat i;
+
+ sscanf (value_str, "%g", &i);
+ g_value_set_double (value, (gdouble) i);
+ break;
+ }
+ default:
+ break;
+ }
}
/**
* sets the argument with it.
*/
void
-gst_util_set_object_arg (GObject * object, const gchar * name, const gchar * value)
+gst_util_set_object_arg (GObject * object, const gchar * name,
+ const gchar * value)
{
if (name && value) {
GParamSpec *paramspec;
- paramspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
+ paramspec =
+ g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
if (!paramspec) {
return;
}
- GST_DEBUG ( "paramspec->flags is %d, paramspec->value_type is %d",
- paramspec->flags, (gint) paramspec->value_type);
+ GST_DEBUG ("paramspec->flags is %d, paramspec->value_type is %d",
+ paramspec->flags, (gint) paramspec->value_type);
if (paramspec->flags & G_PARAM_WRITABLE) {
switch (paramspec->value_type) {
sscanf (value, "%d", &i);
g_object_set (G_OBJECT (object), name, i, NULL);
- }
- else if (paramspec->value_type == GST_TYPE_URI) {
+ } else if (paramspec->value_type == GST_TYPE_URI) {
g_object_set (G_OBJECT (object), name, value, NULL);
}
break;
if (!caps) {
string_append_indent (buf, indent);
- g_string_printf (buf, "%s:%s has no capabilities", GST_DEBUG_PAD_NAME (pad));
- }
- else {
+ g_string_printf (buf, "%s:%s has no capabilities",
+ GST_DEBUG_PAD_NAME (pad));
+ } else {
char *s;
- s = gst_caps_to_string(caps);
- g_string_append(buf, s);
- g_free(s);
+ s = gst_caps_to_string (caps);
+ g_string_append (buf, s);
+ g_free (s);
}
}
gst_print_element_args (GString * buf, gint indent, GstElement * element)
{
guint width;
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
+ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0;
GParamSpec *spec, **specs, **walk;
specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), NULL);
-
+
width = 0;
for (walk = specs; *walk; walk++) {
spec = *walk;
for (walk = specs; *walk; walk++) {
spec = *walk;
-
+
if (spec->flags & G_PARAM_READABLE) {
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (spec));
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (spec));
g_object_get_property (G_OBJECT (element), spec->name, &value);
str = g_strdup_value_contents (&value);
- g_value_unset(&value);
+ g_value_unset (&value);
} else {
str = g_strdup ("Parameter not readable.");
}
string_append_indent (buf, 2 + width - strlen (spec->name));
g_string_append (buf, str);
g_string_append_c (buf, '\n');
-
+
g_free (str);
}
#include <gst/gstelement.h>
G_BEGIN_DECLS
+ void gst_util_set_value_from_string (GValue * value,
+ const gchar * value_str);
+void gst_util_set_object_arg (GObject * object, const gchar * name,
+ const gchar * value);
-void gst_util_set_value_from_string (GValue *value, const gchar *value_str);
-void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value);
-
-void gst_util_dump_mem (guchar *mem, guint size);
+void gst_util_dump_mem (guchar * mem, guint size);
-void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
-void gst_print_element_args (GString *buf, gint indent, GstElement *element);
+void gst_print_pad_caps (GString * buf, gint indent, GstPad * pad);
+void gst_print_element_args (GString * buf, gint indent, GstElement * element);
/* Macros for defining classes. Ideas taken from Bonobo, which took theirs
G_END_DECLS
-
#endif /* __GST_UTILS_H__ */
typedef struct _GstValueUnionInfo GstValueUnionInfo;
-struct _GstValueUnionInfo {
+struct _GstValueUnionInfo
+{
GType type1;
GType type2;
GstValueUnionFunc func;
};
typedef struct _GstValueIntersectInfo GstValueIntersectInfo;
-struct _GstValueIntersectInfo {
+struct _GstValueIntersectInfo
+{
GType type1;
GType type2;
GstValueIntersectFunc func;
/* list */
static void
-gst_value_init_list (GValue *value)
+gst_value_init_list (GValue * value)
{
- value->data[0].v_pointer = g_array_new (FALSE, TRUE, sizeof(GValue));
+ value->data[0].v_pointer = g_array_new (FALSE, TRUE, sizeof (GValue));
}
static GArray *
-gst_value_list_array_copy (const GArray *src)
+gst_value_list_array_copy (const GArray * src)
{
GArray *dest;
gint i;
-
- dest = g_array_sized_new (FALSE, TRUE, sizeof(GValue), src->len);
+
+ dest = g_array_sized_new (FALSE, TRUE, sizeof (GValue), src->len);
g_array_set_size (dest, src->len);
for (i = 0; i < src->len; i++) {
- gst_value_init_and_copy (&g_array_index(dest, GValue, i),
- &g_array_index(src, GValue, i));
+ gst_value_init_and_copy (&g_array_index (dest, GValue, i),
+ &g_array_index (src, GValue, i));
}
return dest;
}
static void
-gst_value_copy_list (const GValue *src_value, GValue *dest_value)
+gst_value_copy_list (const GValue * src_value, GValue * dest_value)
{
- dest_value->data[0].v_pointer = gst_value_list_array_copy ((GArray *) src_value->data[0].v_pointer);
+ dest_value->data[0].v_pointer =
+ gst_value_list_array_copy ((GArray *) src_value->data[0].v_pointer);
}
static void
-gst_value_free_list (GValue *value)
+gst_value_free_list (GValue * value)
{
gint i;
GArray *src = (GArray *) value->data[0].v_pointer;
-
+
if ((value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) == 0) {
for (i = 0; i < src->len; i++) {
- g_value_unset (&g_array_index(src, GValue, i));
+ g_value_unset (&g_array_index (src, GValue, i));
}
g_array_free (src, TRUE);
}
}
static gpointer
-gst_value_list_peek_pointer (const GValue *value)
+gst_value_list_peek_pointer (const GValue * value)
{
return value->data[0].v_pointer;
}
static gchar *
-gst_value_collect_list (GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_collect_list (GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
value->data[0].v_pointer = collect_values[0].v_pointer;
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
} else {
- value->data[0].v_pointer = gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer);
+ value->data[0].v_pointer =
+ gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer);
}
return NULL;
}
static gchar *
-gst_value_lcopy_list (const GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_lcopy_list (const GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
GArray **dest = collect_values[0].v_pointer;
+
if (!dest)
return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
- if (!value->data[0].v_pointer)
+ if (!value->data[0].v_pointer)
return g_strdup_printf ("invalid value given for `%s'",
G_VALUE_TYPE_NAME (value));
if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
* gst_value_list_prepend_value:
*
*/
-void
-gst_value_list_prepend_value (GValue *value, const GValue *prepend_value)
+void
+gst_value_list_prepend_value (GValue * value, const GValue * prepend_value)
{
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
* gst_value_list_append_value:
*
*/
-void
-gst_value_list_append_value (GValue *value, const GValue *append_value)
+void
+gst_value_list_append_value (GValue * value, const GValue * append_value)
{
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
* gst_value_list_get_size:
*
*/
-guint
-gst_value_list_get_size (const GValue *value)
+guint
+gst_value_list_get_size (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), 0);
*
*/
const GValue *
-gst_value_list_get_value (const GValue *value, guint index)
+gst_value_list_get_value (const GValue * value, guint index)
{
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), NULL);
g_return_val_if_fail (index < gst_value_list_get_size (value), NULL);
- return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer, GValue, index);
+ return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer,
+ GValue, index);
}
/**
* initialized to the type GST_TYPE_LIST.
*/
void
-gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2)
+gst_value_list_concat (GValue * dest, const GValue * value1,
+ const GValue * value2)
{
guint i, value1_length, value2_length;
GArray *array;
g_return_if_fail (G_VALUE_TYPE (dest) == 0);
g_return_if_fail (G_IS_VALUE (value1));
g_return_if_fail (G_IS_VALUE (value2));
-
- value1_length = (GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1);
- value2_length = (GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1);
+
+ value1_length =
+ (GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1);
+ value2_length =
+ (GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1);
g_value_init (dest, GST_TYPE_LIST);
array = (GArray *) dest->data[0].v_pointer;
g_array_set_size (array, value1_length + value2_length);
-
+
if (GST_VALUE_HOLDS_LIST (value1)) {
for (i = 0; i < value1_length; i++) {
- gst_value_init_and_copy (&g_array_index(array, GValue, i),
- gst_value_list_get_value (value1, i));
+ gst_value_init_and_copy (&g_array_index (array, GValue, i),
+ gst_value_list_get_value (value1, i));
}
} else {
- gst_value_init_and_copy (&g_array_index(array, GValue, 0), value1);
+ gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1);
}
-
+
if (GST_VALUE_HOLDS_LIST (value2)) {
for (i = 0; i < value2_length; i++) {
- gst_value_init_and_copy (&g_array_index(array, GValue, i + value1_length),
- gst_value_list_get_value (value2, i));
+ gst_value_init_and_copy (&g_array_index (array, GValue,
+ i + value1_length), gst_value_list_get_value (value2, i));
}
} else {
- gst_value_init_and_copy (&g_array_index(array, GValue, value1_length),
- value2);
+ gst_value_init_and_copy (&g_array_index (array, GValue, value1_length),
+ value2);
}
}
static void
-gst_value_transform_list_string (const GValue *src_value,
- GValue *dest_value)
+gst_value_transform_list_string (const GValue * src_value, GValue * dest_value)
{
GValue *list_value;
GArray *array;
array = src_value->data[0].v_pointer;
- s = g_string_new("{ ");
- for(i=0;i<array->len;i++){
- list_value = &g_array_index(array, GValue, i);
+ s = g_string_new ("{ ");
+ for (i = 0; i < array->len; i++) {
+ list_value = &g_array_index (array, GValue, i);
if (i != 0) {
g_string_append (s, ", ");
}
static int
-gst_value_compare_list (const GValue *value1, const GValue *value2)
+gst_value_compare_list (const GValue * value1, const GValue * value2)
{
- int i,j;
+ int i, j;
GArray *array1 = value1->data[0].v_pointer;
GArray *array2 = value2->data[0].v_pointer;
GValue *v1;
GValue *v2;
- if (array1->len != array2->len) return GST_VALUE_UNORDERED;
+ if (array1->len != array2->len)
+ return GST_VALUE_UNORDERED;
- for(i=0;i<array1->len;i++){
+ for (i = 0; i < array1->len; i++) {
v1 = &g_array_index (array1, GValue, i);
- for(j=0;j<array1->len;j++){
+ for (j = 0; j < array1->len; j++) {
v2 = &g_array_index (array2, GValue, j);
- if (gst_value_compare(v1, v2) == GST_VALUE_EQUAL) break;
+ if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL)
+ break;
}
- if (j==array1->len) {
+ if (j == array1->len) {
return GST_VALUE_UNORDERED;
}
}
}
static char *
-gst_value_serialize_list (const GValue *value)
+gst_value_serialize_list (const GValue * value)
{
int i;
GArray *array = value->data[0].v_pointer;
GValue *v;
gchar *s_val;
- s = g_string_new("{ ");
- for(i=0;i<array->len;i++){
+ s = g_string_new ("{ ");
+ for (i = 0; i < array->len; i++) {
v = &g_array_index (array, GValue, i);
s_val = gst_value_serialize (v);
g_string_append (s, s_val);
g_free (s_val);
- if (i<array->len - 1) {
+ if (i < array->len - 1) {
g_string_append (s, ", ");
}
}
}
static gboolean
-gst_value_deserialize_list (GValue *dest, const char *s)
+gst_value_deserialize_list (GValue * dest, const char *s)
{
- g_warning("unimplemented");
+ g_warning ("unimplemented");
return FALSE;
}
/*************************************/
/* fourcc */
-static void
-gst_value_init_fourcc (GValue *value)
+static void
+gst_value_init_fourcc (GValue * value)
{
value->data[0].v_int = 0;
}
static void
-gst_value_copy_fourcc (const GValue *src_value, GValue *dest_value)
+gst_value_copy_fourcc (const GValue * src_value, GValue * dest_value)
{
dest_value->data[0].v_int = src_value->data[0].v_int;
}
static gchar *
-gst_value_collect_fourcc (GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_collect_fourcc (GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
value->data[0].v_int = collect_values[0].v_int;
}
static gchar *
-gst_value_lcopy_fourcc (const GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_lcopy_fourcc (const GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
guint32 *fourcc_p = collect_values[0].v_pointer;
*
*/
void
-gst_value_set_fourcc (GValue *value, guint32 fourcc)
+gst_value_set_fourcc (GValue * value, guint32 fourcc)
{
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
*
*/
guint32
-gst_value_get_fourcc (const GValue *value)
+gst_value_get_fourcc (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
}
static void
-gst_value_transform_fourcc_string (const GValue *src_value,
- GValue *dest_value)
+gst_value_transform_fourcc_string (const GValue * src_value,
+ GValue * dest_value)
{
guint32 fourcc = src_value->data[0].v_int;
- if (g_ascii_isprint ((fourcc>>0) & 0xff) &&
- g_ascii_isprint ((fourcc>>8) & 0xff) &&
- g_ascii_isprint ((fourcc>>16) & 0xff) &&
- g_ascii_isprint ((fourcc>>24) & 0xff)){
- dest_value->data[0].v_pointer = g_strdup_printf(
- GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc));
+ if (g_ascii_isprint ((fourcc >> 0) & 0xff) &&
+ g_ascii_isprint ((fourcc >> 8) & 0xff) &&
+ g_ascii_isprint ((fourcc >> 16) & 0xff) &&
+ g_ascii_isprint ((fourcc >> 24) & 0xff)) {
+ dest_value->data[0].v_pointer =
+ g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
} else {
- dest_value->data[0].v_pointer = g_strdup_printf("0x%08x", fourcc);
+ dest_value->data[0].v_pointer = g_strdup_printf ("0x%08x", fourcc);
}
}
static int
-gst_value_compare_fourcc (const GValue *value1, const GValue *value2)
+gst_value_compare_fourcc (const GValue * value1, const GValue * value2)
{
- if (value2->data[0].v_int == value1->data[0].v_int) return GST_VALUE_EQUAL;
+ if (value2->data[0].v_int == value1->data[0].v_int)
+ return GST_VALUE_EQUAL;
return GST_VALUE_UNORDERED;
}
static char *
-gst_value_serialize_fourcc (const GValue *value)
+gst_value_serialize_fourcc (const GValue * value)
{
guint32 fourcc = value->data[0].v_int;
- if (g_ascii_isalnum ((fourcc>>0) & 0xff) &&
- g_ascii_isalnum ((fourcc>>8) & 0xff) &&
- g_ascii_isalnum ((fourcc>>16) & 0xff) &&
- g_ascii_isalnum ((fourcc>>24) & 0xff)){
- return g_strdup_printf(GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc));
+ if (g_ascii_isalnum ((fourcc >> 0) & 0xff) &&
+ g_ascii_isalnum ((fourcc >> 8) & 0xff) &&
+ g_ascii_isalnum ((fourcc >> 16) & 0xff) &&
+ g_ascii_isalnum ((fourcc >> 24) & 0xff)) {
+ return g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
} else {
- return g_strdup_printf("0x%08x", fourcc);
+ return g_strdup_printf ("0x%08x", fourcc);
}
}
static gboolean
-gst_value_deserialize_fourcc (GValue *dest, const char *s)
+gst_value_deserialize_fourcc (GValue * dest, const char *s)
{
gboolean ret = FALSE;
guint32 fourcc = 0;
char *end;
- if (strlen(s) == 4) {
- fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]);
+ if (strlen (s) == 4) {
+ fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
ret = TRUE;
} else if (g_ascii_isdigit (*s)) {
fourcc = strtoul (s, &end, 0);
/*************************************/
/* int range */
-static void
-gst_value_init_int_range (GValue *value)
+static void
+gst_value_init_int_range (GValue * value)
{
value->data[0].v_int = 0;
value->data[1].v_int = 0;
}
static void
-gst_value_copy_int_range (const GValue *src_value, GValue *dest_value)
+gst_value_copy_int_range (const GValue * src_value, GValue * dest_value)
{
dest_value->data[0].v_int = src_value->data[0].v_int;
dest_value->data[1].v_int = src_value->data[1].v_int;
}
static gchar *
-gst_value_collect_int_range (GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_collect_int_range (GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
/* FIXME */
value->data[0].v_int = collect_values[0].v_int;
}
static gchar *
-gst_value_lcopy_int_range (const GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_lcopy_int_range (const GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
guint32 *int_range_start = collect_values[0].v_pointer;
guint32 *int_range_end = collect_values[1].v_pointer;
*
*/
void
-gst_value_set_int_range (GValue *value, int start, int end)
+gst_value_set_int_range (GValue * value, int start, int end)
{
g_return_if_fail (GST_VALUE_HOLDS_INT_RANGE (value));
*
*/
int
-gst_value_get_int_range_min (const GValue *value)
+gst_value_get_int_range_min (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
*
*/
int
-gst_value_get_int_range_max (const GValue *value)
+gst_value_get_int_range_max (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0);
}
static void
-gst_value_transform_int_range_string (const GValue *src_value,
- GValue *dest_value)
+gst_value_transform_int_range_string (const GValue * src_value,
+ GValue * dest_value)
{
- dest_value->data[0].v_pointer = g_strdup_printf("[%d,%d]",
- (int)src_value->data[0].v_int, (int)src_value->data[1].v_int);
+ dest_value->data[0].v_pointer = g_strdup_printf ("[%d,%d]",
+ (int) src_value->data[0].v_int, (int) src_value->data[1].v_int);
}
static int
-gst_value_compare_int_range (const GValue *value1, const GValue *value2)
+gst_value_compare_int_range (const GValue * value1, const GValue * value2)
{
if (value2->data[0].v_int == value1->data[0].v_int &&
- value2->data[0].v_int == value1->data[0].v_int) return GST_VALUE_EQUAL;
+ value2->data[0].v_int == value1->data[0].v_int)
+ return GST_VALUE_EQUAL;
return GST_VALUE_UNORDERED;
}
static char *
-gst_value_serialize_int_range (const GValue *value)
+gst_value_serialize_int_range (const GValue * value)
{
return g_strdup_printf ("[ %d, %d ]", value->data[0].v_int,
value->data[1].v_int);
}
static gboolean
-gst_value_deserialize_int_range (GValue *dest, const char *s)
+gst_value_deserialize_int_range (GValue * dest, const char *s)
{
- g_warning("unimplemented");
+ g_warning ("unimplemented");
return FALSE;
}
/*************************************/
/* double range */
-static void
-gst_value_init_double_range (GValue *value)
+static void
+gst_value_init_double_range (GValue * value)
{
value->data[0].v_double = 0;
value->data[1].v_double = 0;
}
static void
-gst_value_copy_double_range (const GValue *src_value, GValue *dest_value)
+gst_value_copy_double_range (const GValue * src_value, GValue * dest_value)
{
dest_value->data[0].v_double = src_value->data[0].v_double;
dest_value->data[1].v_double = src_value->data[1].v_double;
}
static gchar *
-gst_value_collect_double_range (GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_collect_double_range (GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
value->data[0].v_double = collect_values[0].v_double;
value->data[1].v_double = collect_values[1].v_double;
}
static gchar *
-gst_value_lcopy_double_range (const GValue *value, guint n_collect_values,
- GTypeCValue *collect_values, guint collect_flags)
+gst_value_lcopy_double_range (const GValue * value, guint n_collect_values,
+ GTypeCValue * collect_values, guint collect_flags)
{
gdouble *double_range_start = collect_values[0].v_pointer;
gdouble *double_range_end = collect_values[1].v_pointer;
*
*/
void
-gst_value_set_double_range (GValue *value, double start, double end)
+gst_value_set_double_range (GValue * value, double start, double end)
{
g_return_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value));
*
*/
double
-gst_value_get_double_range_min (const GValue *value)
+gst_value_get_double_range_min (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0);
*
*/
double
-gst_value_get_double_range_max (const GValue *value)
+gst_value_get_double_range_max (const GValue * value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0);
}
static void
-gst_value_transform_double_range_string (const GValue *src_value,
- GValue *dest_value)
+gst_value_transform_double_range_string (const GValue * src_value,
+ GValue * dest_value)
{
- char s1[G_ASCII_DTOSTR_BUF_SIZE],s2[G_ASCII_DTOSTR_BUF_SIZE];
+ char s1[G_ASCII_DTOSTR_BUF_SIZE], s2[G_ASCII_DTOSTR_BUF_SIZE];
- dest_value->data[0].v_pointer = g_strdup_printf("[%s,%s]",
+ dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]",
g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE,
- src_value->data[0].v_double),
+ src_value->data[0].v_double),
g_ascii_dtostr (s2, G_ASCII_DTOSTR_BUF_SIZE,
- src_value->data[1].v_double));
+ src_value->data[1].v_double));
}
static int
-gst_value_compare_double_range (const GValue *value1, const GValue *value2)
+gst_value_compare_double_range (const GValue * value1, const GValue * value2)
{
if (value2->data[0].v_double == value1->data[0].v_double &&
value2->data[0].v_double == value1->data[0].v_double)
}
static char *
-gst_value_serialize_double_range (const GValue *value)
+gst_value_serialize_double_range (const GValue * value)
{
char d1[G_ASCII_DTOSTR_BUF_SIZE];
char d2[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr(d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
- g_ascii_dtostr(d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double);
+
+ g_ascii_dtostr (d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
+ g_ascii_dtostr (d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double);
return g_strdup_printf ("[ %s, %s ]", d1, d2);
}
static gboolean
-gst_value_deserialize_double_range (GValue *dest, const char *s)
+gst_value_deserialize_double_range (GValue * dest, const char *s)
{
- g_warning("unimplemented");
+ g_warning ("unimplemented");
return FALSE;
}
*
*/
void
-gst_value_set_caps (GValue *value, const GstCaps *caps)
+gst_value_set_caps (GValue * value, const GstCaps * caps)
{
g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS);
*
*/
const GstCaps *
-gst_value_get_caps (const GValue *value)
+gst_value_get_caps (const GValue * value)
{
g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS, NULL);
/* boolean */
static int
-gst_value_compare_boolean (const GValue *value1, const GValue *value2)
+gst_value_compare_boolean (const GValue * value1, const GValue * value2)
{
- if ((value1->data[0].v_int!=0) == (value2->data[0].v_int!=0))
+ if ((value1->data[0].v_int != 0) == (value2->data[0].v_int != 0))
return GST_VALUE_EQUAL;
return GST_VALUE_UNORDERED;
}
static char *
-gst_value_serialize_boolean (const GValue *value)
+gst_value_serialize_boolean (const GValue * value)
{
if (value->data[0].v_int) {
return g_strdup ("true");
}
static gboolean
-gst_value_deserialize_boolean (GValue *dest, const char *s)
+gst_value_deserialize_boolean (GValue * dest, const char *s)
{
gboolean ret = FALSE;
if (g_ascii_strcasecmp (s, "true") == 0 ||
g_ascii_strcasecmp (s, "yes") == 0 ||
- g_ascii_strcasecmp (s, "t") == 0 ||
- strcmp (s, "1") == 0) {
+ g_ascii_strcasecmp (s, "t") == 0 || strcmp (s, "1") == 0) {
g_value_set_boolean (dest, TRUE);
ret = TRUE;
} else if (g_ascii_strcasecmp (s, "false") == 0 ||
g_ascii_strcasecmp (s, "no") == 0 ||
- g_ascii_strcasecmp (s, "f") == 0 ||
- strcmp (s, "0") == 0) {
+ g_ascii_strcasecmp (s, "f") == 0 || strcmp (s, "0") == 0) {
g_value_set_boolean (dest, FALSE);
ret = TRUE;
}
-
+
return ret;
}
/* int */
static int
-gst_value_compare_int (const GValue *value1, const GValue *value2)
+gst_value_compare_int (const GValue * value1, const GValue * value2)
{
if (value1->data[0].v_int > value2->data[0].v_int)
return GST_VALUE_GREATER_THAN;
}
static char *
-gst_value_serialize_int (const GValue *value)
+gst_value_serialize_int (const GValue * value)
{
return g_strdup_printf ("%d", value->data[0].v_int);
}
int i;
if (s[0] == '-') {
- i = - (int) strtoul (s + 1, end, base);
+ i = -(int) strtoul (s + 1, end, base);
} else {
i = strtoul (s, end, base);
}
}
static gboolean
-gst_value_deserialize_int (GValue *dest, const char *s)
+gst_value_deserialize_int (GValue * dest, const char *s)
{
int x;
char *end;
/* double */
static int
-gst_value_compare_double (const GValue *value1, const GValue *value2)
+gst_value_compare_double (const GValue * value1, const GValue * value2)
{
if (value1->data[0].v_double > value2->data[0].v_double)
return GST_VALUE_GREATER_THAN;
}
static char *
-gst_value_serialize_double (const GValue *value)
+gst_value_serialize_double (const GValue * value)
{
char d[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr(d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
+
+ g_ascii_dtostr (d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
return g_strdup (d);
}
static gboolean
-gst_value_deserialize_double (GValue *dest, const char *s)
+gst_value_deserialize_double (GValue * dest, const char *s)
{
double x;
gboolean ret = FALSE;
/* string */
static int
-gst_value_compare_string (const GValue *value1, const GValue *value2)
+gst_value_compare_string (const GValue * value1, const GValue * value2)
{
- int x = strcmp(value1->data[0].v_pointer, value2->data[0].v_pointer);
- if(x<0) return GST_VALUE_LESS_THAN;
- if(x>0) return GST_VALUE_GREATER_THAN;
+ int x = strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
+
+ if (x < 0)
+ return GST_VALUE_LESS_THAN;
+ if (x > 0)
+ return GST_VALUE_GREATER_THAN;
return GST_VALUE_EQUAL;
}
len = 0;
t = s;
while (*t) {
- if(GST_ASCII_IS_STRING(*t)) {
+ if (GST_ASCII_IS_STRING (*t)) {
len++;
- } else if(*t < 0x20 || *t >= 0x7f) {
+ } else if (*t < 0x20 || *t >= 0x7f) {
wrap = TRUE;
len += 4;
} else {
t++;
}
- if (!wrap) return strdup (s);
+ if (!wrap)
+ return strdup (s);
- e = d = g_malloc(len + 3);
+ e = d = g_malloc (len + 3);
*e++ = '\"';
t = s;
while (*t) {
- if(GST_ASCII_IS_STRING(*t)) {
+ if (GST_ASCII_IS_STRING (*t)) {
*e++ = *t++;
- } else if(*t < 0x20 || *t >= 0x7f) {
+ } else if (*t < 0x20 || *t >= 0x7f) {
*e++ = '\\';
- *e++ = '0' + ((*t)>>6);
- *e++ = '0' + (((*t)>>3)&0x7);
- *e++ = '0' + ((*t++)&0x7);
+ *e++ = '0' + ((*t) >> 6);
+ *e++ = '0' + (((*t) >> 3) & 0x7);
+ *e++ = '0' + ((*t++) & 0x7);
} else {
*e++ = '\\';
*e++ = *t++;
}
static char *
-gst_value_serialize_string (const GValue *value)
+gst_value_serialize_string (const GValue * value)
{
return gst_string_wrap (value->data[0].v_pointer);
}
static gboolean
-gst_value_deserialize_string (GValue *dest, const char *s)
+gst_value_deserialize_string (GValue * dest, const char *s)
{
g_value_set_string (dest, s);
/* intersection */
static gboolean
-gst_value_intersect_int_int_range (GValue *dest, const GValue *src1,
- const GValue *src2)
+gst_value_intersect_int_int_range (GValue * dest, const GValue * src1,
+ const GValue * src2)
{
- g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_INT, FALSE);
- g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_INT, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE);
if (src2->data[0].v_int <= src1->data[0].v_int &&
- src2->data[1].v_int >= src1->data[0].v_int){
+ src2->data[1].v_int >= src1->data[0].v_int) {
gst_value_init_and_copy (dest, src1);
return TRUE;
}
}
static gboolean
-gst_value_intersect_int_range_int_range (GValue *dest, const GValue *src1,
- const GValue *src2)
+gst_value_intersect_int_range_int_range (GValue * dest, const GValue * src1,
+ const GValue * src2)
{
int min;
int max;
- g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_INT_RANGE, FALSE);
- g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_INT_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE);
- min = MAX(src1->data[0].v_int, src2->data[0].v_int);
- max = MIN(src1->data[1].v_int, src2->data[1].v_int);
+ min = MAX (src1->data[0].v_int, src2->data[0].v_int);
+ max = MIN (src1->data[1].v_int, src2->data[1].v_int);
- if(min < max){
- g_value_init(dest, GST_TYPE_INT_RANGE);
- gst_value_set_int_range(dest, min, max);
+ if (min < max) {
+ g_value_init (dest, GST_TYPE_INT_RANGE);
+ gst_value_set_int_range (dest, min, max);
return TRUE;
}
- if(min == max){
- g_value_init(dest, G_TYPE_INT);
- g_value_set_int(dest, min);
+ if (min == max) {
+ g_value_init (dest, G_TYPE_INT);
+ g_value_set_int (dest, min);
return TRUE;
}
}
static gboolean
-gst_value_intersect_double_double_range (GValue *dest, const GValue *src1,
- const GValue *src2)
+gst_value_intersect_double_double_range (GValue * dest, const GValue * src1,
+ const GValue * src2)
{
- g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_DOUBLE, FALSE);
- g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_DOUBLE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
if (src2->data[0].v_double <= src1->data[0].v_double &&
- src2->data[1].v_double >= src1->data[0].v_double){
+ src2->data[1].v_double >= src1->data[0].v_double) {
gst_value_init_and_copy (dest, src1);
return TRUE;
}
}
static gboolean
-gst_value_intersect_double_range_double_range (GValue *dest, const GValue *src1,
- const GValue *src2)
+gst_value_intersect_double_range_double_range (GValue * dest,
+ const GValue * src1, const GValue * src2)
{
double min;
double max;
- g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_DOUBLE_RANGE, FALSE);
- g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_DOUBLE_RANGE, FALSE);
+ g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE);
- min = MAX(src1->data[0].v_double, src2->data[0].v_double);
- max = MIN(src1->data[1].v_double, src2->data[1].v_double);
+ min = MAX (src1->data[0].v_double, src2->data[0].v_double);
+ max = MIN (src1->data[1].v_double, src2->data[1].v_double);
- if(min < max){
- g_value_init(dest, GST_TYPE_DOUBLE_RANGE);
- gst_value_set_double_range(dest, min, max);
+ if (min < max) {
+ g_value_init (dest, GST_TYPE_DOUBLE_RANGE);
+ gst_value_set_double_range (dest, min, max);
return TRUE;
}
- if(min == max){
- g_value_init(dest, G_TYPE_DOUBLE);
- g_value_set_int(dest, min);
+ if (min == max) {
+ g_value_init (dest, G_TYPE_DOUBLE);
+ g_value_set_int (dest, min);
return TRUE;
}
}
static gboolean
-gst_value_intersect_list (GValue *dest, const GValue *value1, const GValue *value2)
+gst_value_intersect_list (GValue * dest, const GValue * value1,
+ const GValue * value2)
{
guint i, size;
GValue intersection = { 0, };
gboolean ret = FALSE;
-
+
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value1), FALSE);
size = gst_value_list_get_size (value1);
} else if (GST_VALUE_HOLDS_LIST (dest)) {
gst_value_list_append_value (dest, &intersection);
} else {
- GValue temp = {0, };
+ GValue temp = { 0, };
gst_value_init_and_copy (&temp, dest);
g_value_unset (dest);
*
*/
gboolean
-gst_value_can_compare (const GValue *value1, const GValue *value2)
+gst_value_can_compare (const GValue * value1, const GValue * value2)
{
GstValueTable *table;
int i;
- if(G_VALUE_TYPE(value1) != G_VALUE_TYPE(value2))return FALSE;
- for(i=0;i<gst_value_table->len;i++){
- table = &g_array_index(gst_value_table, GstValueTable, i);
- if(table->type == G_VALUE_TYPE(value1) &&
- table->compare) return TRUE;
+ if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
+ return FALSE;
+ for (i = 0; i < gst_value_table->len; i++) {
+ table = &g_array_index (gst_value_table, GstValueTable, i);
+ if (table->type == G_VALUE_TYPE (value1) && table->compare)
+ return TRUE;
}
return FALSE;
*
*/
int
-gst_value_compare (const GValue *value1, const GValue *value2)
+gst_value_compare (const GValue * value1, const GValue * value2)
{
GstValueTable *table;
int i;
- if (G_VALUE_TYPE(value1) != G_VALUE_TYPE(value2)) return GST_VALUE_UNORDERED;
+ if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
+ return GST_VALUE_UNORDERED;
- for(i=0;i<gst_value_table->len;i++){
- table = &g_array_index(gst_value_table, GstValueTable, i);
- if(table->type != G_VALUE_TYPE(value1) ||
- table->compare == NULL) continue;
+ for (i = 0; i < gst_value_table->len; i++) {
+ table = &g_array_index (gst_value_table, GstValueTable, i);
+ if (table->type != G_VALUE_TYPE (value1) || table->compare == NULL)
+ continue;
- return table->compare(value1, value2);
+ return table->compare (value1, value2);
}
- g_critical("unable to compare values of type %s\n",
+ g_critical ("unable to compare values of type %s\n",
g_type_name (G_VALUE_TYPE (value1)));
return GST_VALUE_UNORDERED;
}
*
*/
gboolean
-gst_value_can_union (const GValue *value1, const GValue *value2)
+gst_value_can_union (const GValue * value1, const GValue * value2)
{
GstValueUnionInfo *union_info;
int i;
- for(i=0;i<gst_value_union_funcs->len;i++){
- union_info = &g_array_index(gst_value_union_funcs, GstValueUnionInfo, i);
- if(union_info->type1 == G_VALUE_TYPE(value1) &&
- union_info->type2 == G_VALUE_TYPE(value2)) return TRUE;
+ for (i = 0; i < gst_value_union_funcs->len; i++) {
+ union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
+ if (union_info->type1 == G_VALUE_TYPE (value1) &&
+ union_info->type2 == G_VALUE_TYPE (value2))
+ return TRUE;
}
return FALSE;
*
*/
gboolean
-gst_value_union (GValue *dest, const GValue *value1, const GValue *value2)
+gst_value_union (GValue * dest, const GValue * value1, const GValue * value2)
{
GstValueUnionInfo *union_info;
int i;
- for(i=0;i<gst_value_union_funcs->len;i++){
- union_info = &g_array_index(gst_value_union_funcs, GstValueUnionInfo, i);
- if(union_info->type1 == G_VALUE_TYPE(value1) &&
- union_info->type2 == G_VALUE_TYPE(value2)) {
- return union_info->func(dest, value1, value2);
+ for (i = 0; i < gst_value_union_funcs->len; i++) {
+ union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
+ if (union_info->type1 == G_VALUE_TYPE (value1) &&
+ union_info->type2 == G_VALUE_TYPE (value2)) {
+ return union_info->func (dest, value1, value2);
}
}
-
+
gst_value_list_concat (dest, value1, value2);
return TRUE;
}
union_info.type2 = type2;
union_info.func = func;
- g_array_append_val(gst_value_union_funcs, union_info);
+ g_array_append_val (gst_value_union_funcs, union_info);
}
/* intersection */
*
*/
gboolean
-gst_value_can_intersect (const GValue *value1, const GValue *value2)
+gst_value_can_intersect (const GValue * value1, const GValue * value2)
{
GstValueIntersectInfo *intersect_info;
int i;
/* special cases */
- if (GST_VALUE_HOLDS_LIST (value1) ||
- GST_VALUE_HOLDS_LIST (value2))
+ if (GST_VALUE_HOLDS_LIST (value1) || GST_VALUE_HOLDS_LIST (value2))
return TRUE;
- for(i=0;i<gst_value_intersect_funcs->len;i++){
- intersect_info = &g_array_index(gst_value_intersect_funcs,
+ for (i = 0; i < gst_value_intersect_funcs->len; i++) {
+ intersect_info = &g_array_index (gst_value_intersect_funcs,
GstValueIntersectInfo, i);
- if(intersect_info->type1 == G_VALUE_TYPE(value1) &&
- intersect_info->type2 == G_VALUE_TYPE(value2)) return TRUE;
+ if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
+ intersect_info->type2 == G_VALUE_TYPE (value2))
+ return TRUE;
}
return gst_value_can_compare (value1, value2);
*
*/
gboolean
-gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2)
+gst_value_intersect (GValue * dest, const GValue * value1,
+ const GValue * value2)
{
GstValueIntersectInfo *intersect_info;
int i;
return gst_value_intersect_list (dest, value1, value2);
if (GST_VALUE_HOLDS_LIST (value2))
return gst_value_intersect_list (dest, value2, value1);
-
- for(i=0;i<gst_value_intersect_funcs->len;i++){
- intersect_info = &g_array_index(gst_value_intersect_funcs,
+
+ for (i = 0; i < gst_value_intersect_funcs->len; i++) {
+ intersect_info = &g_array_index (gst_value_intersect_funcs,
GstValueIntersectInfo, i);
- if(intersect_info->type1 == G_VALUE_TYPE(value1) &&
- intersect_info->type2 == G_VALUE_TYPE(value2)) {
- ret = intersect_info->func(dest, value1, value2);
+ if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
+ intersect_info->type2 == G_VALUE_TYPE (value2)) {
+ ret = intersect_info->func (dest, value1, value2);
return ret;
}
- if(intersect_info->type1 == G_VALUE_TYPE(value2) &&
- intersect_info->type2 == G_VALUE_TYPE(value1)) {
- ret = intersect_info->func(dest, value2, value1);
+ if (intersect_info->type1 == G_VALUE_TYPE (value2) &&
+ intersect_info->type2 == G_VALUE_TYPE (value1)) {
+ ret = intersect_info->func (dest, value2, value1);
return ret;
}
}
- if(gst_value_compare(value1, value2) == GST_VALUE_EQUAL){
+ if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL) {
gst_value_init_and_copy (dest, value1);
ret = TRUE;
}
intersect_info.type2 = type2;
intersect_info.func = func;
- g_array_append_val(gst_value_intersect_funcs, intersect_info);
+ g_array_append_val (gst_value_intersect_funcs, intersect_info);
}
/**
*
*/
void
-gst_value_register (const GstValueTable *table)
+gst_value_register (const GstValueTable * table)
{
- g_array_append_val(gst_value_table, *table);
+ g_array_append_val (gst_value_table, *table);
}
/**
*
*/
void
-gst_value_init_and_copy (GValue *dest, const GValue *src)
+gst_value_init_and_copy (GValue * dest, const GValue * src)
{
- g_value_init (dest, G_VALUE_TYPE(src));
+ g_value_init (dest, G_VALUE_TYPE (src));
g_value_copy (src, dest);
}
*
*/
gchar *
-gst_value_serialize (const GValue *value)
+gst_value_serialize (const GValue * value)
{
int i;
GValue s_val = { 0 };
GstValueTable *table;
char *s;
- for(i=0;i<gst_value_table->len;i++){
- table = &g_array_index(gst_value_table, GstValueTable, i);
- if(table->type != G_VALUE_TYPE(value) ||
- table->serialize == NULL) continue;
+ for (i = 0; i < gst_value_table->len; i++) {
+ table = &g_array_index (gst_value_table, GstValueTable, i);
+ if (table->type != G_VALUE_TYPE (value) || table->serialize == NULL)
+ continue;
- return table->serialize(value);
+ return table->serialize (value);
}
g_value_init (&s_val, G_TYPE_STRING);
*
*/
gboolean
-gst_value_deserialize (GValue *dest, const gchar *src)
+gst_value_deserialize (GValue * dest, const gchar * src)
{
GstValueTable *table;
int i;
- for(i=0;i<gst_value_table->len;i++){
- table = &g_array_index(gst_value_table, GstValueTable, i);
- if(table->type != G_VALUE_TYPE(dest) ||
- table->deserialize == NULL) continue;
+ for (i = 0; i < gst_value_table->len; i++) {
+ table = &g_array_index (gst_value_table, GstValueTable, i);
+ if (table->type != G_VALUE_TYPE (dest) || table->deserialize == NULL)
+ continue;
- return table->deserialize(dest, src);
+ return table->deserialize (dest, src);
}
return FALSE;
};
//const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
- gst_value_table = g_array_new(FALSE, FALSE, sizeof(GstValueTable));
- gst_value_union_funcs = g_array_new(FALSE, FALSE,
- sizeof(GstValueUnionInfo));
- gst_value_intersect_funcs = g_array_new(FALSE, FALSE,
- sizeof(GstValueIntersectInfo));
+ gst_value_table = g_array_new (FALSE, FALSE, sizeof (GstValueTable));
+ gst_value_union_funcs = g_array_new (FALSE, FALSE,
+ sizeof (GstValueUnionInfo));
+ gst_value_intersect_funcs = g_array_new (FALSE, FALSE,
+ sizeof (GstValueIntersectInfo));
{
static const GTypeValueTable value_table = {
gst_value_deserialize_fourcc,
};
info.value_table = &value_table;
- gst_type_fourcc = g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0);
+ gst_type_fourcc =
+ g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0);
gst_value.type = gst_type_fourcc;
gst_value_register (&gst_value);
}
gst_value_deserialize_int_range,
};
info.value_table = &value_table;
- gst_type_int_range = g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0);
+ gst_type_int_range =
+ g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0);
gst_value.type = gst_type_int_range;
gst_value_register (&gst_value);
}
gst_value_deserialize_double_range,
};
info.value_table = &value_table;
- gst_type_double_range = g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0);
+ gst_type_double_range =
+ g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0);
gst_value.type = gst_type_double_range;
gst_value_register (&gst_value);
}
-
+
{
static const GTypeValueTable value_table = {
gst_value_init_list,
gst_value_deserialize_list,
};
info.value_table = &value_table;
- gst_type_list = g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0);
+ gst_type_list =
+ g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0);
gst_value.type = gst_type_list;
gst_value_register (&gst_value);
}
gst_value_intersect_int_range_int_range);
gst_value_register_intersect_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE,
gst_value_intersect_double_double_range);
- gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE, GST_TYPE_DOUBLE_RANGE,
- gst_value_intersect_double_range_double_range);
+ gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE,
+ GST_TYPE_DOUBLE_RANGE, gst_value_intersect_double_range_double_range);
}
-
-
#include <gst/gstcaps.h>
G_BEGIN_DECLS
-
-typedef int (* GstValueCompareFunc) (const GValue *value1,
- const GValue *value2);
-typedef char * (* GstValueSerializeFunc) (const GValue *value1);
-typedef gboolean (* GstValueDeserializeFunc) (GValue *dest, const char *s);
-typedef int (* GstValueUnionFunc) (GValue *dest, const GValue *value1,
- const GValue *value2);
-typedef int (* GstValueIntersectFunc) (GValue *dest, const GValue *value1,
- const GValue *value2);
+ typedef int (*GstValueCompareFunc) (const GValue * value1,
+ const GValue * value2);
+typedef char *(*GstValueSerializeFunc) (const GValue * value1);
+typedef gboolean (*GstValueDeserializeFunc) (GValue * dest, const char *s);
+typedef int (*GstValueUnionFunc) (GValue * dest, const GValue * value1,
+ const GValue * value2);
+typedef int (*GstValueIntersectFunc) (GValue * dest, const GValue * value1,
+ const GValue * value2);
typedef struct _GstValueTable GstValueTable;
-struct _GstValueTable {
+struct _GstValueTable
+{
GType type;
GstValueCompareFunc compare;
GstValueSerializeFunc serialize;
GstValueDeserializeFunc deserialize;
- void *_gst_reserved [GST_PADDING];
+ void *_gst_reserved[GST_PADDING];
};
/* list */
-void gst_value_list_prepend_value (GValue *value, const GValue *prepend_value);
-void gst_value_list_append_value (GValue *value, const GValue *append_value);
-guint gst_value_list_get_size (const GValue *value);
-G_CONST_RETURN GValue *gst_value_list_get_value (const GValue *value, guint index);
-void gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2);
+void gst_value_list_prepend_value (GValue * value,
+ const GValue * prepend_value);
+void gst_value_list_append_value (GValue * value, const GValue * append_value);
+guint gst_value_list_get_size (const GValue * value);
+G_CONST_RETURN GValue *gst_value_list_get_value (const GValue * value,
+ guint index);
+void gst_value_list_concat (GValue * dest, const GValue * value1,
+ const GValue * value2);
/* fourcc */
-void gst_value_set_fourcc (GValue *value, guint32 fourcc);
-guint32 gst_value_get_fourcc (const GValue *value);
+void gst_value_set_fourcc (GValue * value, guint32 fourcc);
+guint32 gst_value_get_fourcc (const GValue * value);
/* int range */
-void gst_value_set_int_range (GValue *value, int start, int end);
-int gst_value_get_int_range_min (const GValue *value);
-int gst_value_get_int_range_max (const GValue *value);
+void gst_value_set_int_range (GValue * value, int start, int end);
+int gst_value_get_int_range_min (const GValue * value);
+int gst_value_get_int_range_max (const GValue * value);
/* double range */
-void gst_value_set_double_range (GValue *value, double start, double end);
-double gst_value_get_double_range_min (const GValue *value);
-double gst_value_get_double_range_max (const GValue *value);
+void gst_value_set_double_range (GValue * value, double start, double end);
+double gst_value_get_double_range_min (const GValue * value);
+double gst_value_get_double_range_max (const GValue * value);
/* caps */
-G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue *value);
-void gst_value_set_caps (GValue *value, const GstCaps *caps);
+G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue * value);
+void gst_value_set_caps (GValue * value, const GstCaps * caps);
/* compare */
-gboolean gst_value_can_compare (const GValue *value1, const GValue *value2);
-int gst_value_compare (const GValue *value1, const GValue *value2);
+gboolean gst_value_can_compare (const GValue * value1, const GValue * value2);
+int gst_value_compare (const GValue * value1, const GValue * value2);
/* union */
-gboolean gst_value_can_union (const GValue *value1, const GValue *value2);
-gboolean gst_value_union (GValue *dest, const GValue *value1, const GValue *value2);
-void gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func);
+gboolean gst_value_can_union (const GValue * value1, const GValue * value2);
+gboolean gst_value_union (GValue * dest, const GValue * value1,
+ const GValue * value2);
+void gst_value_register_union_func (GType type1, GType type2,
+ GstValueUnionFunc func);
/* intersection */
-gboolean gst_value_can_intersect (const GValue *value1, const GValue *value2);
-gboolean gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2);
-void gst_value_register_intersect_func (GType type1, GType type2, GstValueIntersectFunc func);
+gboolean gst_value_can_intersect (const GValue * value1, const GValue * value2);
+gboolean gst_value_intersect (GValue * dest, const GValue * value1,
+ const GValue * value2);
+void gst_value_register_intersect_func (GType type1, GType type2,
+ GstValueIntersectFunc func);
/* */
-void gst_value_register (const GstValueTable *table);
-void gst_value_init_and_copy (GValue *dest, const GValue *src);
+void gst_value_register (const GstValueTable * table);
+void gst_value_init_and_copy (GValue * dest, const GValue * src);
void _gst_value_initialize (void);
-gchar * gst_value_serialize (const GValue *value);
-gboolean gst_value_deserialize (GValue *dest, const gchar *src);
+gchar *gst_value_serialize (const GValue * value);
+gboolean gst_value_deserialize (GValue * dest, const gchar * src);
G_END_DECLS
-
#endif
-
-
#include "gstinfo.h"
#include "gstbin.h"
-enum {
+enum
+{
OBJECT_LOADED,
LAST_SIGNAL
};
-static void gst_xml_class_init (GstXMLClass *klass);
-static void gst_xml_init (GstXML *xml);
+static void gst_xml_class_init (GstXMLClass * klass);
+static void gst_xml_init (GstXML * xml);
-static void gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data);
+static void gst_xml_object_loaded (GstObject * private, GstObject * object,
+ xmlNodePtr self, gpointer data);
static GstObjectClass *parent_class = NULL;
static guint gst_xml_signals[LAST_SIGNAL] = { 0 };
GType
-gst_xml_get_type(void)
+gst_xml_get_type (void)
{
static GType xml_type = 0;
if (!xml_type) {
static const GTypeInfo xml_info = {
- sizeof(GstXMLClass),
+ sizeof (GstXMLClass),
NULL,
NULL,
- (GClassInitFunc)gst_xml_class_init,
+ (GClassInitFunc) gst_xml_class_init,
NULL,
NULL,
- sizeof(GstXML),
+ sizeof (GstXML),
0,
- (GInstanceInitFunc)gst_xml_init,
+ (GInstanceInitFunc) gst_xml_init,
NULL
};
xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0);
}
static void
-gst_xml_class_init (GstXMLClass *klass)
+gst_xml_class_init (GstXMLClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass *)klass;
+ gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
/* FIXME G_TYPE_POINTER should be GType of xmlNodePtr */
gst_xml_signals[OBJECT_LOADED] =
- g_signal_new ("object-loaded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL, NULL,
- gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
- GST_TYPE_OBJECT, G_TYPE_POINTER);
+ g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL,
+ NULL, gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, GST_TYPE_OBJECT,
+ G_TYPE_POINTER);
}
static void
-gst_xml_init(GstXML *xml)
+gst_xml_init (GstXML * xml)
{
xml->topelements = NULL;
}
*
* Returns: a pointer to a new GstXML object.
*/
-GstXML*
+GstXML *
gst_xml_new (void)
{
- return GST_XML (g_object_new(GST_TYPE_XML,NULL));
+ return GST_XML (g_object_new (GST_TYPE_XML, NULL));
}
/**
* Returns: a pointer to an XML document
*/
xmlDocPtr
-gst_xml_write (GstElement *element)
+gst_xml_write (GstElement * element)
{
xmlDocPtr doc;
xmlNodePtr elementnode;
doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "gstreamer", NULL);
-
- gst_ns = xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst");
-
+
+ gst_ns =
+ xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst");
+
elementnode = xmlNewChild (doc->xmlRootNode, gst_ns, "element", NULL);
gst_object_save_thyself (GST_OBJECT (element), elementnode);
* Returns: number of bytes written on success, -1 otherwise.
*/
gint
-gst_xml_write_file (GstElement *element, FILE *out)
+gst_xml_write_file (GstElement * element, FILE * out)
{
xmlDocPtr cur;
+
#ifdef HAVE_LIBXML2
xmlOutputBufferPtr buf;
#endif
- const char * encoding;
+ const char *encoding;
xmlCharEncodingHandlerPtr handler = NULL;
int indent;
gboolean ret;
-
+
cur = gst_xml_write (element);
- if (!cur) return -1;
-
+ if (!cur)
+ return -1;
+
#ifdef HAVE_LIBXML2
encoding = (const char *) cur->encoding;
-
+
if (encoding != NULL) {
xmlCharEncoding enc;
-
+
enc = xmlParseCharEncoding (encoding);
-
+
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
xmlGenericError (xmlGenericErrorContext,
- "xmlDocDump: document not in UTF8\n");
+ "xmlDocDump: document not in UTF8\n");
return -1;
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler (encoding);
if (handler == NULL) {
- xmlFree ((char *) cur->encoding);
- cur->encoding = NULL;
+ xmlFree ((char *) cur->encoding);
+ cur->encoding = NULL;
}
}
}
-
+
buf = xmlOutputBufferCreateFile (out, handler);
-
+
indent = xmlIndentTreeOutput;
xmlIndentTreeOutput = 1;
- ret = xmlSaveFormatFileTo(buf, cur, NULL, 1);
+ ret = xmlSaveFormatFileTo (buf, cur, NULL, 1);
xmlIndentTreeOutput = indent;
#else
/* apparently this doesn't return anything in libxml1 */
xmlDocDump (out, cur);
ret = 1;
#endif
-
+
return ret;
}
* Returns: TRUE on success, FALSE otherwise
*/
gboolean
-gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root)
+gst_xml_parse_doc (GstXML * xml, xmlDocPtr doc, const guchar * root)
{
xmlNodePtr field, cur;
xmlNsPtr ns;
- cur = xmlDocGetRootElement(doc);
+ cur = xmlDocGetRootElement (doc);
if (cur == NULL) {
- g_warning("gstxml: empty document\n");
- return FALSE ;
+ g_warning ("gstxml: empty document\n");
+ return FALSE;
}
- ns = xmlSearchNsByHref(doc, cur, "http://gstreamer.net/gst-core/1.0/");
+ ns = xmlSearchNsByHref (doc, cur, "http://gstreamer.net/gst-core/1.0/");
if (ns == NULL) {
- g_warning("gstxml: document of wrong type, core namespace not found\n");
+ g_warning ("gstxml: document of wrong type, core namespace not found\n");
return FALSE;
}
- if (strcmp(cur->name, "gstreamer")) {
- g_warning("gstxml: XML file is in wrong format\n");
+ if (strcmp (cur->name, "gstreamer")) {
+ g_warning ("gstxml: XML file is in wrong format\n");
return FALSE;
}
- gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS(xml)),
- "object_loaded", gst_xml_object_loaded, xml);
+ gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (xml)),
+ "object_loaded", gst_xml_object_loaded, xml);
xml->ns = ns;
field = cur->xmlChildrenNode;
while (field) {
- if (!strcmp(field->name, "element") && (field->ns == xml->ns)) {
+ if (!strcmp (field->name, "element") && (field->ns == xml->ns)) {
GstElement *element;
element = gst_xml_make_element (field, NULL);
* Returns: TRUE on success, FALSE otherwise
*/
gboolean
-gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root)
+gst_xml_parse_file (GstXML * xml, const guchar * fname, const guchar * root)
{
xmlDocPtr doc;
- g_return_val_if_fail(fname != NULL, FALSE);
+ g_return_val_if_fail (fname != NULL, FALSE);
- doc = xmlParseFile(fname);
+ doc = xmlParseFile (fname);
if (!doc) {
- g_warning("gstxml: XML file \"%s\" could not be read\n", fname);
+ g_warning ("gstxml: XML file \"%s\" could not be read\n", fname);
return FALSE;
}
* Returns: TRUE on success
*/
gboolean
-gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root)
+gst_xml_parse_memory (GstXML * xml, guchar * buffer, guint size,
+ const gchar * root)
{
xmlDocPtr doc;
- g_return_val_if_fail(buffer != NULL, FALSE);
+ g_return_val_if_fail (buffer != NULL, FALSE);
doc = xmlParseMemory (buffer, size);
}
static void
-gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data)
+gst_xml_object_loaded (GstObject * private, GstObject * object, xmlNodePtr self,
+ gpointer data)
{
GstXML *xml = GST_XML (data);
- /* FIXME check that this element was created from the same xmlDocPtr...*/
- g_signal_emit (G_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], 0, object, self);
+ /* FIXME check that this element was created from the same xmlDocPtr... */
+ g_signal_emit (G_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], 0, object,
+ self);
}
/**
*
* Returns: a GList of elements
*/
-GList*
-gst_xml_get_topelements (GstXML *xml)
+GList *
+gst_xml_get_topelements (GstXML * xml)
{
g_return_val_if_fail (xml != NULL, NULL);
*
* Returns: a pointer to a new GstElement
*/
-GstElement*
-gst_xml_get_element (GstXML *xml, const guchar *name)
+GstElement *
+gst_xml_get_element (GstXML * xml, const guchar * name)
{
GstElement *element;
GList *topelements;
- g_return_val_if_fail(xml != NULL, NULL);
- g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail (xml != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
GST_DEBUG ("gstxml: getting element \"%s\"", name);
GST_DEBUG ("gstxml: getting element \"%s\"", name);
if (!strcmp (GST_ELEMENT_NAME (top), name)) {
return top;
- }
- else {
+ } else {
if (GST_IS_BIN (top)) {
- element = gst_bin_get_by_name (GST_BIN (top), name);
+ element = gst_bin_get_by_name (GST_BIN (top), name);
if (element)
- return element;
+ return element;
}
}
topelements = g_list_next (topelements);
*
* Returns: the new element
*/
-GstElement*
-gst_xml_make_element (xmlNodePtr cur, GstObject *parent)
+GstElement *
+gst_xml_make_element (xmlNodePtr cur, GstObject * parent)
{
xmlNodePtr children = cur->xmlChildrenNode;
GstElement *element;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (type != NULL, NULL);
- GST_CAT_INFO (GST_CAT_XML,"loading \"%s\" of type \"%s\"", name, type);
+ GST_CAT_INFO (GST_CAT_XML, "loading \"%s\" of type \"%s\"", name, type);
element = gst_element_factory_make (type, name);
/* will go through the hierarchy to link to their peers */
if (parent)
gst_object_set_parent (GST_OBJECT (element), parent);
-
+
gst_object_restore_thyself (GST_OBJECT (element), cur);
-
+
return element;
}
#include <gst/gstelement.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XML (gst_xml_get_type ())
#define GST_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XML, GstXML))
#define GST_IS_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XML))
#define GST_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_XML, GstXMLClass))
#define GST_IS_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_XML))
-
#define GST_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XML, GstXMLClass))
-
typedef struct _GstXML GstXML;
typedef struct _GstXMLClass GstXMLClass;
-struct _GstXML {
+struct _GstXML
+{
GstObject object;
- GList *topelements;
+ GList *topelements;
xmlNsPtr ns;
typedef struct _GstXMLNs GstXMLNs;
-struct _GstXMLClass {
+struct _GstXMLClass
+{
GstObjectClass parent_class;
/* signal callbacks */
- void (*object_loaded) (GstXML *xml, GstObject *object, xmlNodePtr self);
- void (*object_saved) (GstXML *xml, GstObject *object, xmlNodePtr self);
+ void (*object_loaded) (GstXML * xml, GstObject * object, xmlNodePtr self);
+ void (*object_saved) (GstXML * xml, GstObject * object, xmlNodePtr self);
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_xml_get_type (void);
+GType gst_xml_get_type (void);
/* create an XML document out of a pipeline */
-xmlDocPtr gst_xml_write (GstElement *element);
+xmlDocPtr gst_xml_write (GstElement * element);
/* write a formatted representation of a pipeline to an open file */
-gint gst_xml_write_file (GstElement *element, FILE *out);
+gint gst_xml_write_file (GstElement * element, FILE * out);
-GstXML* gst_xml_new (void);
+GstXML *gst_xml_new (void);
-gboolean gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root);
-gboolean gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root);
-gboolean gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root);
+gboolean gst_xml_parse_doc (GstXML * xml, xmlDocPtr doc, const guchar * root);
+gboolean gst_xml_parse_file (GstXML * xml, const guchar * fname,
+ const guchar * root);
+gboolean gst_xml_parse_memory (GstXML * xml, guchar * buffer, guint size,
+ const gchar * root);
-GstElement* gst_xml_get_element (GstXML *xml, const guchar *name);
-GList* gst_xml_get_topelements (GstXML *xml);
+GstElement *gst_xml_get_element (GstXML * xml, const guchar * name);
+GList *gst_xml_get_topelements (GstXML * xml);
-GstElement* gst_xml_make_element (xmlNodePtr cur, GstObject *parent);
+GstElement *gst_xml_make_element (xmlNodePtr cur, GstObject * parent);
G_END_DECLS
-
#else /* GST_DISABLE_LOADSAVE */
#pragma GCC poison gst_xml_write
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FILE_INDEX))
#define GST_IS_FILE_INDEX_CLASS(obj) \
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FILE_INDEX))
-
+
#ifndef __FUNCTION__
#define __FUNCTION__ "Unavailable"
#endif
/*
* Each array element is (32bits flags, nformats * 64bits)
*/
-typedef struct {
- gint id;
- gchar *id_desc;
- gint nformats;
- GstFormat *format;
- GArray *array;
+typedef struct
+{
+ gint id;
+ gchar *id_desc;
+ gint nformats;
+ GstFormat *format;
+ GArray *array;
} GstFileIndexId;
typedef struct _GstFileIndex GstFileIndex;
#define ARRAY_ROW_VALUE(_row,_vx) \
(*(gint64*) (((gchar*)(_row)) + sizeof (gint32) + (_vx) * sizeof (gint64)))
-GST_DEBUG_CATEGORY_STATIC(DC);
+GST_DEBUG_CATEGORY_STATIC (DC);
-struct _GstFileIndex {
- GstIndex parent;
+struct _GstFileIndex
+{
+ GstIndex parent;
- gchar *location;
- gboolean is_loaded;
- GSList *unresolved;
- gint next_id;
- GHashTable *id_index;
+ gchar *location;
+ gboolean is_loaded;
+ GSList *unresolved;
+ gint next_id;
+ GHashTable *id_index;
- GstIndexEntry *ret_entry; /* hack to avoid leaking memory */
+ GstIndexEntry *ret_entry; /* hack to avoid leaking memory */
};
-struct _GstFileIndexClass {
+struct _GstFileIndexClass
+{
GstIndexClass parent_class;
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
};
-static void gst_file_index_class_init (GstFileIndexClass *klass);
-static void gst_file_index_init (GstFileIndex *index);
-static void gst_file_index_dispose (GObject *object);
+static void gst_file_index_class_init (GstFileIndexClass * klass);
+static void gst_file_index_init (GstFileIndex * index);
+static void gst_file_index_dispose (GObject * object);
static void
-gst_file_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+gst_file_index_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
static void
-gst_file_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+gst_file_index_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static gboolean
-gst_file_index_get_writer_id (GstIndex *_index, gint *id, gchar *writer_string);
+gst_file_index_get_writer_id (GstIndex * _index, gint * id,
+ gchar * writer_string);
-static void gst_file_index_commit (GstIndex *index, gint writer_id);
-static void gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry);
-static GstIndexEntry* gst_file_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+static void gst_file_index_commit (GstIndex * index, gint writer_id);
+static void gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry);
+static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
#define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index))
static GstIndex *parent_class = NULL;
GType
-gst_file_index_get_type(void) {
+gst_file_index_get_type (void)
+{
static GType file_index_type = 0;
if (!file_index_type) {
static const GTypeInfo file_index_info = {
- sizeof(GstFileIndexClass),
+ sizeof (GstFileIndexClass),
NULL,
NULL,
- (GClassInitFunc)gst_file_index_class_init,
+ (GClassInitFunc) gst_file_index_class_init,
NULL,
NULL,
- sizeof(GstFileIndex),
+ sizeof (GstFileIndex),
1,
- (GInstanceInitFunc)gst_file_index_init,
+ (GInstanceInitFunc) gst_file_index_init,
NULL
};
- file_index_type = g_type_register_static(GST_TYPE_INDEX, "GstFileIndex", &file_index_info, 0);
+ file_index_type =
+ g_type_register_static (GST_TYPE_INDEX, "GstFileIndex",
+ &file_index_info, 0);
}
return file_index_type;
}
static void
-gst_file_index_class_init (GstFileIndexClass *klass)
+gst_file_index_class_init (GstFileIndexClass * klass)
{
GObjectClass *gobject_class;
GstIndexClass *gstindex_class;
- gobject_class = (GObjectClass*)klass;
- gstindex_class = (GstIndexClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstindex_class = (GstIndexClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_INDEX);
+ parent_class = g_type_class_ref (GST_TYPE_INDEX);
- gobject_class->dispose = gst_file_index_dispose;
- gobject_class->set_property = gst_file_index_set_property;
- gobject_class->get_property = gst_file_index_get_property;
+ gobject_class->dispose = gst_file_index_dispose;
+ gobject_class->set_property = gst_file_index_set_property;
+ gobject_class->get_property = gst_file_index_get_property;
- gstindex_class->add_entry = gst_file_index_add_entry;
+ gstindex_class->add_entry = gst_file_index_add_entry;
gstindex_class->get_assoc_entry = gst_file_index_get_assoc_entry;
- gstindex_class->commit = gst_file_index_commit;
- gstindex_class->get_writer_id = gst_file_index_get_writer_id ;
+ gstindex_class->commit = gst_file_index_commit;
+ gstindex_class->get_writer_id = gst_file_index_get_writer_id;
g_object_class_install_property (gobject_class, ARG_LOCATION,
- g_param_spec_string ("location", "File Location",
- "Location of the index file",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the index file", NULL, G_PARAM_READWRITE));
}
static void
-gst_file_index_init (GstFileIndex *index)
+gst_file_index_init (GstFileIndex * index)
{
- GST_DEBUG ( "created new file index");
+ GST_DEBUG ("created new file index");
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
}
static void
-_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped)
+_file_index_id_free (GstFileIndexId * index_id, gboolean is_mmapped)
{
if (index_id->id_desc)
g_free (index_id->id_desc);
g_free (index_id->format);
if (index_id->array) {
if (is_mmapped)
- munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
+ munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
g_array_free (index_id->array, !is_mmapped);
}
g_free (index_id);
}
static gboolean
-_id_index_free_helper (gpointer _key, GstFileIndexId *index_id,
- GstFileIndex *index)
+_id_index_free_helper (gpointer _key, GstFileIndexId * index_id,
+ GstFileIndex * index)
{
_file_index_id_free (index_id, index->is_loaded);
return TRUE;
}
static void
-gst_file_index_dispose (GObject *object)
+gst_file_index_dispose (GObject * object)
{
GstFileIndex *index = GST_FILE_INDEX (object);
{
GSList *elem;
+
for (elem = index->unresolved; elem; elem = g_slist_next (elem))
_file_index_id_free (elem->data, index->is_loaded);
g_slist_free (index->unresolved);
index->unresolved = NULL;
}
-
+
g_hash_table_foreach_steal (index->id_index,
- (GHRFunc) _id_index_free_helper, index);
+ (GHRFunc) _id_index_free_helper, index);
g_hash_table_destroy (index->id_index);
index->id_index = NULL;
- gst_index_entry_free (index->ret_entry); /* hack */
+ gst_index_entry_free (index->ret_entry); /* hack */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-struct fi_find_writer_context {
+struct fi_find_writer_context
+{
const gchar *writer_string;
GstFileIndexId *ii;
};
{
struct fi_find_writer_context *cx = data;
GstFileIndexId *ii = val;
+
if (strcmp (ii->id_desc, cx->writer_string) == 0)
cx->ii = ii;
}
static gboolean
-gst_file_index_get_writer_id (GstIndex *_index,
- gint *id, gchar *writer_string)
+gst_file_index_get_writer_id (GstIndex * _index,
+ gint * id, gchar * writer_string)
{
GstFileIndex *index = GST_FILE_INDEX (_index);
GSList *pending = index->unresolved;
for (elem = pending; elem; elem = g_slist_next (elem)) {
GstFileIndexId *ii = elem->data;
+
if (strcmp (ii->id_desc, writer_string) != 0) {
index->unresolved = g_slist_prepend (index->unresolved, ii);
continue;
}
-
+
if (match) {
GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'",
- writer_string);
+ writer_string);
continue;
}
if (!match) {
struct fi_find_writer_context cx;
+
cx.writer_string = writer_string;
cx.ii = NULL;
g_hash_table_foreach (index->id_index, _fi_find_writer, &cx);
if (cx.ii) {
match = TRUE;
GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again",
- writer_string);
- }
- else
+ writer_string);
+ } else
GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'",
- writer_string);
+ writer_string);
}
return match;
}
static void
-_fc_alloc_array (GstFileIndexId *id_index)
+_fc_alloc_array (GstFileIndexId * id_index)
{
g_assert (!id_index->array);
id_index->array =
- g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0);
+ g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0);
}
static void
-gst_file_index_load (GstFileIndex *index)
+gst_file_index_load (GstFileIndex * index)
{
xmlDocPtr doc;
xmlNodePtr root, part;
GError *err = NULL;
gchar *buf;
gsize len;
+
g_file_get_contents (path, &buf, &len, &err);
g_free (path);
if (err) {
GST_CAT_ERROR_OBJECT (DC, index, "root node isn't a gstfileindex");
return;
}
-
+
val = xmlGetProp (root, "version");
if (!val || atoi (val) != 1) {
GST_CAT_ERROR_OBJECT (DC, index, "version != 1");
for (part = root->children; part; part = part->next) {
if (strcmp (part->name, "writers") == 0) {
xmlNodePtr writer;
+
for (writer = part->children; writer; writer = writer->next) {
xmlChar *datafile = xmlGetProp (writer, "datafile");
gchar *path = g_strdup_printf ("%s/%s", index->location, datafile);
g_free (path);
if (fd < 0) {
GST_CAT_ERROR_OBJECT (DC, index,
- "Can't open '%s': %s", path, strerror (errno));
+ "Can't open '%s': %s", path, strerror (errno));
continue;
}
for (wpart = writer->children; wpart; wpart = wpart->next) {
if (strcmp (wpart->name, "formats") == 0) {
xmlChar *count_str = xmlGetProp (wpart, "count");
- gint fx=0;
+ gint fx = 0;
xmlNodePtr format;
id_index->nformats = atoi (count_str);
id_index->format = g_new (GstFormat, id_index->nformats);
- for (format = wpart->children;
- format; format = format->next) {
+ for (format = wpart->children; format; format = format->next) {
xmlChar *nick = xmlGetProp (format, "nick");
GstFormat fmt = gst_format_get_by_nick (nick);
+
if (fmt == GST_FORMAT_UNDEFINED)
- GST_CAT_ERROR_OBJECT (DC, index,
- "format '%s' undefined", nick);
+ GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick);
g_assert (fx < id_index->nformats);
id_index->format[fx++] = fmt;
free (nick);
g_assert (id_index->nformats > 0);
_fc_alloc_array (id_index);
- g_assert (id_index->array->data == NULL); /* little bit risky */
+ g_assert (id_index->array->data == NULL); /* little bit risky */
entries_str = xmlGetProp (writer, "entries");
id_index->array->len = atoi (entries_str);
free (entries_str);
array_data =
- mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, 0);
+ mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd,
+ 0);
close (fd);
if (array_data == MAP_FAILED) {
GST_CAT_ERROR_OBJECT (DC, index,
- "mmap %s failed: %s", path, strerror (errno));
+ "mmap %s failed: %s", path, strerror (errno));
continue;
}
}
static void
-gst_file_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_file_index_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstFileIndex *index = GST_FILE_INDEX (object);
switch (prop_id) {
- case ARG_LOCATION:
- if (index->location)
- g_free (index->location);
- index->location = g_value_dup_string (value);
+ case ARG_LOCATION:
+ if (index->location)
+ g_free (index->location);
+ index->location = g_value_dup_string (value);
- if (index->location && !g_hash_table_size (index->id_index))
- gst_file_index_load (index);
- break;
+ if (index->location && !g_hash_table_size (index->id_index))
+ gst_file_index_load (index);
+ break;
}
}
static void
-gst_file_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_file_index_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstFileIndex *index = GST_FILE_INDEX (object);
-
+
switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, index->location);
- break;
+ case ARG_LOCATION:
+ g_value_set_string (value, index->location);
+ break;
}
}
static void
-_file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers)
+_file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers)
{
const gint bufsize = 16;
gchar buf[bufsize];
xmlNodePtr writer;
xmlNodePtr formats;
gint xx;
-
+
if (!ii->array) {
GST_INFO ("Index for %s is empty", ii->id_desc);
return;
xmlSetProp (writer, "id", ii->id_desc);
g_snprintf (buf, bufsize, "%d", ii->array->len);
xmlSetProp (writer, "entries", buf);
- g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */
+ g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */
xmlSetProp (writer, "datafile", buf);
formats = xmlNewChild (writer, NULL, "formats", NULL);
g_snprintf (buf, bufsize, "%d", ii->nformats);
xmlSetProp (formats, "count", buf);
- for (xx=0; xx < ii->nformats; xx++) {
+ for (xx = 0; xx < ii->nformats; xx++) {
xmlNodePtr format = xmlNewChild (formats, NULL, "format", NULL);
- const GstFormatDefinition* def =
- gst_format_get_details (ii->format[xx]);
+ const GstFormatDefinition *def = gst_format_get_details (ii->format[xx]);
+
xmlSetProp (format, "nick", def->nick);
}
}
padding since the page size isn't fixed.
*/
static void
-_file_index_id_save_entries (gpointer *_key,
- GstFileIndexId *ii,
- gchar *prefix)
+_file_index_id_save_entries (gpointer * _key,
+ GstFileIndexId * ii, gchar * prefix)
{
GError *err;
gchar *path;
path = g_strdup_printf ("%s/%d", prefix, ii->id);
chan = g_io_channel_new_file (path, "w", &err);
g_free (path);
- if (err) goto fail;
-
+ if (err)
+ goto fail;
+
g_io_channel_set_encoding (chan, NULL, &err);
- if (err) goto fail;
+ if (err)
+ goto fail;
g_io_channel_write_chars (chan,
- ii->array->data,
- ARRAY_TOTAL_SIZE (ii),
- NULL,
- &err);
- if (err) goto fail;
+ ii->array->data, ARRAY_TOTAL_SIZE (ii), NULL, &err);
+ if (err)
+ goto fail;
g_io_channel_shutdown (chan, TRUE, &err);
- if (err) goto fail;
+ if (err)
+ goto fail;
g_io_channel_unref (chan);
return;
- fail:
+fail:
GST_CAT_ERROR (DC, "%s", err->message);
}
gst_index_commit (index, -1);
*/
static void
-gst_file_index_commit (GstIndex *_index, gint _writer_id)
+gst_file_index_commit (GstIndex * _index, gint _writer_id)
{
GstFileIndex *index = GST_FILE_INDEX (_index);
xmlDocPtr doc;
writers = xmlNewChild (doc->xmlRootNode, NULL, "writers", NULL);
g_hash_table_foreach (index->id_index,
- (GHFunc) _file_index_id_save_xml, writers);
+ (GHFunc) _file_index_id_save_xml, writers);
- if (mkdir (index->location, 0777) &&
- errno != EEXIST) {
+ if (mkdir (index->location, 0777) && errno != EEXIST) {
GST_CAT_ERROR_OBJECT (DC, index,
- "mkdir %s: %s", index->location, strerror (errno));
+ "mkdir %s: %s", index->location, strerror (errno));
return;
}
path = g_strdup_printf ("%s/gstindex.xml", index->location);
- tocfile =
- g_io_channel_new_file (path, "w", &err);
+ tocfile = g_io_channel_new_file (path, "w", &err);
g_free (path);
if (err) {
GST_CAT_ERROR_OBJECT (DC, index, "%s", err->message);
{
xmlChar *xmlmem;
int xmlsize;
+
xmlDocDumpMemory (doc, &xmlmem, &xmlsize);
g_io_channel_write_chars (tocfile, xmlmem, xmlsize, NULL, &err);
if (err) {
g_io_channel_unref (tocfile);
g_hash_table_foreach (index->id_index,
- (GHFunc) _file_index_id_save_entries,
- index->location);
+ (GHFunc) _file_index_id_save_entries, index->location);
}
static void
-gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_id (GstIndex * index, GstIndexEntry * entry)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
of non-exact matches. */
static gboolean
-_fc_bsearch (GArray * ary,
- gint stride,
- gint * ret,
- GCompareDataFunc compare,
- gconstpointer sample,
- gpointer user_data)
+_fc_bsearch (GArray * ary,
+ gint stride,
+ gint * ret,
+ GCompareDataFunc compare, gconstpointer sample, gpointer user_data)
{
gint first, last;
gint mid;
g_return_val_if_fail (compare, FALSE);
- if (!ary->len)
- {
- if (ret) *ret = 0;
- return FALSE;
- }
+ if (!ary->len) {
+ if (ret)
+ *ret = 0;
+ return FALSE;
+ }
first = 0;
last = ary->len - 1;
midsize = last - first;
-
+
while (midsize > 1) {
mid = first + midsize / 2;
-
- cmp = (*compare) (sample, ary->data + mid*stride, user_data);
-
- if (cmp == 0)
- {
- /* if there are multiple matches then scan for the first match */
- while (mid > 0 &&
- (*compare) (sample,
- ary->data + (mid - 1) * stride,
- user_data) == 0)
- --mid;
-
- if (ret) *ret = mid;
- return TRUE;
- }
-
+
+ cmp = (*compare) (sample, ary->data + mid * stride, user_data);
+
+ if (cmp == 0) {
+ /* if there are multiple matches then scan for the first match */
+ while (mid > 0 &&
+ (*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0)
+ --mid;
+
+ if (ret)
+ *ret = mid;
+ return TRUE;
+ }
+
if (cmp < 0)
- last = mid-1;
+ last = mid - 1;
else
- first = mid+1;
-
+ first = mid + 1;
+
midsize = last - first;
}
- for (tx = first; tx <= last; tx++)
- {
- cmp = (*compare) (sample, ary->data + tx*stride, user_data);
+ for (tx = first; tx <= last; tx++) {
+ cmp = (*compare) (sample, ary->data + tx * stride, user_data);
- if (cmp < 0)
- {
- if (ret) *ret = tx;
- return FALSE;
- }
- if (cmp == 0)
- {
- if (ret) *ret = tx;
- return TRUE;
- }
+ if (cmp < 0) {
+ if (ret)
+ *ret = tx;
+ return FALSE;
}
+ if (cmp == 0) {
+ if (ret)
+ *ret = tx;
+ return TRUE;
+ }
+ }
- if (ret) *ret = last+1;
+ if (ret)
+ *ret = last + 1;
return FALSE;
}
static gint
-file_index_compare (gconstpointer sample,
- gconstpointer row,
- gpointer user_data)
+file_index_compare (gconstpointer sample, gconstpointer row, gpointer user_data)
{
//GstFileIndexId *id_index = user_data;
const GstIndexAssociation *ca = sample;
gint64 val2_be = ARRAY_ROW_VALUE (row, ca->format);
gint64 val2 = GINT64_FROM_BE (val2_be);
gint64 diff = val2 - val1;
+
return (diff == 0 ? 0 : (diff < 0 ? 1 : -1));
}
static void
-gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
if (!id_index->nformats) {
gint fx;
+
id_index->nformats = GST_INDEX_NASSOCS (entry);
GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d",
- id_index->nformats, entry->id);
+ id_index->nformats, entry->id);
id_index->format = g_new (GstFormat, id_index->nformats);
- for (fx=0; fx < id_index->nformats; fx++)
+ for (fx = 0; fx < id_index->nformats; fx++)
id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx);
_fc_alloc_array (id_index);
} else {
/* only sanity checking */
if (id_index->nformats != GST_INDEX_NASSOCS (entry))
GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d",
- id_index->nformats, GST_INDEX_NASSOCS (entry));
+ id_index->nformats, GST_INDEX_NASSOCS (entry));
else {
gint fx;
- for (fx=0; fx < id_index->nformats; fx++)
+
+ for (fx = 0; fx < id_index->nformats; fx++)
if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx))
GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d",
- fx, id_index->format[fx],
- GST_INDEX_ASSOC_FORMAT (entry, fx));
+ fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx));
}
}
sample.value = GST_INDEX_ASSOC_VALUE (entry, 0);
exact =
- _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
- &mx, file_index_compare,
- &sample, id_index);
+ _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
+ &mx, file_index_compare, &sample, id_index);
if (exact) {
/* maybe overwrite instead? */
GST_CAT_DEBUG_OBJECT (DC, index,
- "Ignoring duplicate index association at %lld",
- GST_INDEX_ASSOC_VALUE (entry, 0));
+ "Ignoring duplicate index association at %lld",
+ GST_INDEX_ASSOC_VALUE (entry, 0));
return;
}
gint fx;
gint32 flags_host = GST_INDEX_ASSOC_FLAGS (entry);
+
ARRAY_ROW_FLAGS (row_data) = GINT32_TO_BE (flags_host);
for (fx = 0; fx < id_index->nformats; fx++) {
gint64 val_host = GST_INDEX_ASSOC_VALUE (entry, fx);
+
ARRAY_ROW_VALUE (row_data, fx) = GINT64_TO_BE (val_host);
}
*/
static void
-gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry)
{
GST_LOG_OBJECT (index, "adding this entry");
- switch (entry->type){
- case GST_INDEX_ENTRY_ID:
- gst_file_index_add_id (index, entry);
- break;
- case GST_INDEX_ENTRY_ASSOCIATION:
- gst_file_index_add_association (index, entry);
- break;
- case GST_INDEX_ENTRY_OBJECT:
- GST_CAT_ERROR_OBJECT (DC, index,
- "gst_file_index_add_object not implemented");
- break;
- case GST_INDEX_ENTRY_FORMAT:
- /*
- We infer the formats from the entry itself so this type of
- GST_INDEX_ENTRY_* can probably go away.
+ switch (entry->type) {
+ case GST_INDEX_ENTRY_ID:
+ gst_file_index_add_id (index, entry);
+ break;
+ case GST_INDEX_ENTRY_ASSOCIATION:
+ gst_file_index_add_association (index, entry);
+ break;
+ case GST_INDEX_ENTRY_OBJECT:
+ GST_CAT_ERROR_OBJECT (DC, index,
+ "gst_file_index_add_object not implemented");
+ break;
+ case GST_INDEX_ENTRY_FORMAT:
+ /*
+ We infer the formats from the entry itself so this type of
+ GST_INDEX_ENTRY_* can probably go away.
*/
- GST_CAT_DEBUG_OBJECT (DC, index,
- "gst_file_index_add_format not implemented");
- break;
- default:
- break;
+ GST_CAT_DEBUG_OBJECT (DC, index,
+ "gst_file_index_add_format not implemented");
+ break;
+ default:
+ break;
}
}
-static GstIndexEntry*
-gst_file_index_get_assoc_entry (GstIndex *index,
- gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format,
- gint64 value,
- GCompareDataFunc _ignore_func,
- gpointer _ignore_user_data)
+static GstIndexEntry *
+gst_file_index_get_assoc_entry (GstIndex * index,
+ gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format,
+ gint64 value, GCompareDataFunc _ignore_func, gpointer _ignore_user_data)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
return NULL;
}
- for (fx=0; fx < id_index->nformats; fx++)
- if (id_index->format[fx] == format)
- { formatx = fx; break; }
+ for (fx = 0; fx < id_index->nformats; fx++)
+ if (id_index->format[fx] == format) {
+ formatx = fx;
+ break;
+ }
if (formatx == -1) {
GST_CAT_WARNING_OBJECT (DC, fileindex,
- "%s, format %d not available", __FUNCTION__, format);
+ "%s, format %d not available", __FUNCTION__, format);
return NULL;
}
sample.value = value;
exact = _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
- &mx, file_index_compare, &sample, id_index);
+ &mx, file_index_compare, &sample, id_index);
if (!exact) {
if (method == GST_INDEX_LOOKUP_EXACT)
entry->type = GST_INDEX_ENTRY_ASSOCIATION;
GST_INDEX_NASSOCS (entry) = id_index->nformats;
- entry->data.assoc.assocs =
- g_new (GstIndexAssociation, id_index->nformats);
+ entry->data.assoc.assocs = g_new (GstIndexAssociation, id_index->nformats);
{
gint32 flags_be = ARRAY_ROW_FLAGS (row_data);
+
GST_INDEX_ASSOC_FLAGS (entry) = GINT32_FROM_BE (flags_be);
- for (xx=0; xx < id_index->nformats; xx++)
- {
- gint64 val_be = ARRAY_ROW_VALUE (row_data, xx);
- GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx];
- GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be);
- }
+ for (xx = 0; xx < id_index->nformats; xx++) {
+ gint64 val_be = ARRAY_ROW_VALUE (row_data, xx);
+
+ GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx];
+ GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be);
+ }
}
return entry;
}
gboolean
-gst_file_index_plugin_init (GstPlugin *plugin)
+gst_file_index_plugin_init (GstPlugin * plugin)
{
GstIndexFactory *factory;
- GST_DEBUG_CATEGORY_INIT(DC, "GST_FILEINDEX", 0, NULL);
+ GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL);
factory = gst_index_factory_new ("fileindex",
- "A index that stores entries in file",
- gst_file_index_get_type());
+ "A index that stores entries in file", gst_file_index_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
- }
- else {
+ } else {
GST_CAT_ERROR (DC, "could not register fileindex");
}
return TRUE;
#include <gst/gstversion.h>
#include <gst/gstplugin.h>
-extern gboolean gst_mem_index_plugin_init (GstPlugin *plugin);
-extern gboolean gst_file_index_plugin_init (GstPlugin *plugin);
+extern gboolean gst_mem_index_plugin_init (GstPlugin * plugin);
+extern gboolean gst_file_index_plugin_init (GstPlugin * plugin);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
gboolean res = TRUE;
res &= gst_mem_index_plugin_init (plugin);
res &= gst_file_index_plugin_init (plugin);
-
+
return res;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstindexers",
- "GStreamer core indexers",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstindexers",
+ "GStreamer core indexers",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX))
#define GST_IS_MEM_INDEX_CLASS(obj) \
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX))
-
+
/*
* Object model:
*
* then do a lookup in the Tree to get the required value.
*/
-typedef struct {
- GstFormat format;
- gint offset;
- GTree *tree;
+typedef struct
+{
+ GstFormat format;
+ gint offset;
+ GTree *tree;
} GstMemIndexFormatIndex;
-typedef struct {
- gint id;
- GHashTable *format_index;
+typedef struct
+{
+ gint id;
+ GHashTable *format_index;
} GstMemIndexId;
typedef struct _GstMemIndex GstMemIndex;
typedef struct _GstMemIndexClass GstMemIndexClass;
-struct _GstMemIndex {
- GstIndex parent;
+struct _GstMemIndex
+{
+ GstIndex parent;
- GList *associations;
+ GList *associations;
- GHashTable *id_index;
+ GHashTable *id_index;
};
-struct _GstMemIndexClass {
+struct _GstMemIndexClass
+{
GstIndexClass parent_class;
};
/* Index signals and args */
-enum {
+enum
+{
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_mem_index_class_init (GstMemIndexClass *klass);
-static void gst_mem_index_init (GstMemIndex *index);
-static void gst_mem_index_dispose (GObject *object);
+static void gst_mem_index_class_init (GstMemIndexClass * klass);
+static void gst_mem_index_init (GstMemIndex * index);
+static void gst_mem_index_dispose (GObject * object);
-static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry);
-static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry);
+static GstIndexEntry *gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
#define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index))
static GstIndex *parent_class = NULL;
+
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_mem_index_get_type(void) {
+gst_mem_index_get_type (void)
+{
static GType mem_index_type = 0;
if (!mem_index_type) {
static const GTypeInfo mem_index_info = {
- sizeof(GstMemIndexClass),
+ sizeof (GstMemIndexClass),
NULL,
NULL,
- (GClassInitFunc)gst_mem_index_class_init,
+ (GClassInitFunc) gst_mem_index_class_init,
NULL,
NULL,
- sizeof(GstMemIndex),
+ sizeof (GstMemIndex),
1,
- (GInstanceInitFunc)gst_mem_index_init,
+ (GInstanceInitFunc) gst_mem_index_init,
NULL
};
- mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0);
+ mem_index_type =
+ g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info,
+ 0);
}
return mem_index_type;
}
static void
-gst_mem_index_class_init (GstMemIndexClass *klass)
+gst_mem_index_class_init (GstMemIndexClass * klass)
{
GObjectClass *gobject_class;
GstIndexClass *gstindex_class;
- gobject_class = (GObjectClass*)klass;
- gstindex_class = (GstIndexClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstindex_class = (GstIndexClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_INDEX);
+ parent_class = g_type_class_ref (GST_TYPE_INDEX);
gobject_class->dispose = gst_mem_index_dispose;
- gstindex_class->add_entry = gst_mem_index_add_entry;
+ gstindex_class->add_entry = gst_mem_index_add_entry;
gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry;
}
static void
-gst_mem_index_init (GstMemIndex *index)
+gst_mem_index_init (GstMemIndex * index)
{
- GST_DEBUG ( "created new mem index");
+ GST_DEBUG ("created new mem index");
index->associations = NULL;
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
}
static void
-gst_mem_index_dispose (GObject *object)
+gst_mem_index_dispose (GObject * object)
{
//GstMemIndex *memindex = GST_MEM_INDEX (object);
}
static void
-gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_id (GstIndex * index, GstIndexEntry * entry)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
}
static gint
-mem_index_compare (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
+mem_index_compare (gconstpointer a, gconstpointer b, gpointer user_data)
{
GstMemIndexFormatIndex *index = user_data;
gint64 val1, val2;
gint64 diff;
- val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
- val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset);
-
+ val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
+ val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) b), index->offset);
+
diff = (val2 - val1);
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
}
static void
-gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc)
+gst_mem_index_index_format (GstMemIndexId * id_index, GstIndexEntry * entry,
+ gint assoc)
{
GstMemIndexFormatIndex *index;
GstFormat *format;
}
static void
-gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_association (GstIndex * index, GstIndexEntry * entry)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
}
static void
-gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_object (GstIndex * index, GstIndexEntry * entry)
{
}
static void
-gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_format (GstIndex * index, GstIndexEntry * entry)
{
}
static void
-gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry)
{
GST_LOG_OBJECT (index, "added this entry");
- switch (entry->type){
- case GST_INDEX_ENTRY_ID:
- gst_mem_index_add_id (index, entry);
- break;
- case GST_INDEX_ENTRY_ASSOCIATION:
- gst_mem_index_add_association (index, entry);
- break;
- case GST_INDEX_ENTRY_OBJECT:
- gst_mem_index_add_object (index, entry);
- break;
- case GST_INDEX_ENTRY_FORMAT:
- gst_mem_index_add_format (index, entry);
- break;
- default:
- break;
+ switch (entry->type) {
+ case GST_INDEX_ENTRY_ID:
+ gst_mem_index_add_id (index, entry);
+ break;
+ case GST_INDEX_ENTRY_ASSOCIATION:
+ gst_mem_index_add_association (index, entry);
+ break;
+ case GST_INDEX_ENTRY_OBJECT:
+ gst_mem_index_add_object (index, entry);
+ break;
+ case GST_INDEX_ENTRY_FORMAT:
+ gst_mem_index_add_format (index, entry);
+ break;
+ default:
+ break;
}
}
-typedef struct {
- gint64 value;
+typedef struct
+{
+ gint64 value;
GstMemIndexFormatIndex *index;
- gboolean exact;
- GstIndexEntry *lower;
- gint64 low_diff;
- GstIndexEntry *higher;
- gint64 high_diff;
+ gboolean exact;
+ GstIndexEntry *lower;
+ gint64 low_diff;
+ GstIndexEntry *higher;
+ gint64 high_diff;
} GstMemIndexSearchData;
static gint
-mem_index_search (gconstpointer a,
- gconstpointer b)
+mem_index_search (gconstpointer a, gconstpointer b)
{
GstMemIndexSearchData *data = (GstMemIndexSearchData *) b;
GstMemIndexFormatIndex *index = data->index;
gint64 val1, val2;
gint64 diff;
- val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
+ val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
val2 = data->value;
-
+
diff = (val1 - val2);
if (diff == 0)
return 0;
data->lower = (GstIndexEntry *) a;
}
diff = -1;
- }
- else {
+ } else {
if (diff < data->high_diff) {
data->high_diff = diff;
data->higher = (GstIndexEntry *) a;
return diff;
}
-static GstIndexEntry*
-gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data)
+static GstIndexEntry *
+gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
entry = g_tree_search (format_index->tree, mem_index_search, &data);
/* get the low/high values if we're not exact */
- if (entry == NULL && !data.exact) {
+ if (entry == NULL && !data.exact) {
if (method == GST_INDEX_LOOKUP_BEFORE)
entry = data.lower;
else if (method == GST_INDEX_LOOKUP_AFTER) {
while (l_entry) {
entry = (GstIndexEntry *) l_entry->data;
- if (entry->id == id &&
- (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
- break;
+ if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
+ break;
- if (method == GST_INDEX_LOOKUP_BEFORE)
- l_entry = g_list_next (l_entry);
- else if (method == GST_INDEX_LOOKUP_AFTER) {
- l_entry = g_list_previous (l_entry);
- }
+ if (method == GST_INDEX_LOOKUP_BEFORE)
+ l_entry = g_list_next (l_entry);
+ else if (method == GST_INDEX_LOOKUP_AFTER) {
+ l_entry = g_list_previous (l_entry);
+ }
}
}
}
}
gboolean
-gst_mem_index_plugin_init (GstPlugin *plugin)
+gst_mem_index_plugin_init (GstPlugin * plugin)
{
GstIndexFactory *factory;
factory = gst_index_factory_new ("memindex",
- "A index that stores entries in memory",
- gst_mem_index_get_type());
+ "A index that stores entries in memory", gst_mem_index_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
- }
- else {
+ } else {
g_warning ("could not register memindex");
}
return TRUE;
# include "config.h"
#endif
-typedef struct {
+typedef struct
+{
GstElement *src;
GstElement *sink;
gchar *src_name;
GstCaps *caps;
} link_t;
-typedef struct {
+typedef struct
+{
GSList *elements;
GstElement *first;
GstElement *last;
} chain_t;
typedef struct _graph_t graph_t;
-struct _graph_t {
- chain_t *chain; /* links are supposed to be done now */
+struct _graph_t
+{
+ chain_t *chain; /* links are supposed to be done now */
GSList *links;
GError **error;
};
#endif
#ifdef __GST_PARSE_TRACE
-gchar *__gst_parse_strdup (gchar *org);
-void __gst_parse_strfree (gchar *str);
+gchar *__gst_parse_strdup (gchar * org);
+void __gst_parse_strfree (gchar * str);
link_t *__gst_parse_link_new ();
-void __gst_parse_link_free (link_t *data);
+void __gst_parse_link_free (link_t * data);
chain_t *__gst_parse_chain_new ();
-void __gst_parse_chain_free (chain_t *data);
+void __gst_parse_chain_free (chain_t * data);
+
# define gst_parse_strdup __gst_parse_strdup
# define gst_parse_strfree __gst_parse_strfree
# define gst_parse_link_new __gst_parse_link_new
#endif /* __GST_PARSE_TRACE */
static inline void
-gst_parse_unescape (gchar *str)
+gst_parse_unescape (gchar * str)
{
gchar *walk;
-
+
g_return_if_fail (str != NULL);
-
+
walk = str;
-
+
while (*walk) {
if (*walk == '\\')
walk++;
#define CLASS(registry) GST_XML_REGISTRY_CLASS (G_OBJECT_GET_CLASS (registry))
-enum
+enum
{
PROP_0,
PROP_LOCATION
};
-static void gst_xml_registry_class_init (GstXMLRegistryClass *klass);
-static void gst_xml_registry_init (GstXMLRegistry *registry);
-
-static void gst_xml_registry_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_xml_registry_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static gboolean gst_xml_registry_load (GstRegistry *registry);
-static gboolean gst_xml_registry_save (GstRegistry *registry);
-static gboolean gst_xml_registry_rebuild (GstRegistry *registry);
-
-static void gst_xml_registry_get_perms_func (GstXMLRegistry *registry);
-static void gst_xml_registry_add_path_list_func (GstXMLRegistry *registry);
-static gboolean gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode);
-static gboolean gst_xml_registry_load_func (GstXMLRegistry *registry, gchar *data, gssize *size);
-static gboolean gst_xml_registry_save_func (GstXMLRegistry *registry, gchar *format, ...);
-static gboolean gst_xml_registry_close_func (GstXMLRegistry *registry);
-
-static GstRegistryReturn gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin);
-
-static void gst_xml_registry_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_text (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_passthrough (GMarkupParseContext *context,
- const gchar *passthrough_text,
- gsize text_len,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_error (GMarkupParseContext *context,
- GError *error,
- gpointer user_data);
-
-
-static void gst_xml_registry_paths_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_paths_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error);
-static void gst_xml_registry_paths_text (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
+static void gst_xml_registry_class_init (GstXMLRegistryClass * klass);
+static void gst_xml_registry_init (GstXMLRegistry * registry);
+
+static void gst_xml_registry_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_xml_registry_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_xml_registry_load (GstRegistry * registry);
+static gboolean gst_xml_registry_save (GstRegistry * registry);
+static gboolean gst_xml_registry_rebuild (GstRegistry * registry);
+
+static void gst_xml_registry_get_perms_func (GstXMLRegistry * registry);
+static void gst_xml_registry_add_path_list_func (GstXMLRegistry * registry);
+static gboolean gst_xml_registry_open_func (GstXMLRegistry * registry,
+ GstXMLRegistryMode mode);
+static gboolean gst_xml_registry_load_func (GstXMLRegistry * registry,
+ gchar * data, gssize * size);
+static gboolean gst_xml_registry_save_func (GstXMLRegistry * registry,
+ gchar * format, ...);
+static gboolean gst_xml_registry_close_func (GstXMLRegistry * registry);
+
+static GstRegistryReturn gst_xml_registry_load_plugin (GstRegistry * registry,
+ GstPlugin * plugin);
+
+static void gst_xml_registry_start_element (GMarkupParseContext * context,
+ const gchar * element_name,
+ const gchar ** attribute_names,
+ const gchar ** attribute_values, gpointer user_data, GError ** error);
+static void gst_xml_registry_end_element (GMarkupParseContext * context,
+ const gchar * element_name, gpointer user_data, GError ** error);
+static void gst_xml_registry_text (GMarkupParseContext * context,
+ const gchar * text, gsize text_len, gpointer user_data, GError ** error);
+static void gst_xml_registry_passthrough (GMarkupParseContext * context,
+ const gchar * passthrough_text,
+ gsize text_len, gpointer user_data, GError ** error);
+static void gst_xml_registry_error (GMarkupParseContext * context,
+ GError * error, gpointer user_data);
+
+
+static void gst_xml_registry_paths_start_element (GMarkupParseContext * context,
+ const gchar * element_name,
+ const gchar ** attribute_names,
+ const gchar ** attribute_values, gpointer user_data, GError ** error);
+static void gst_xml_registry_paths_end_element (GMarkupParseContext * context,
+ const gchar * element_name, gpointer user_data, GError ** error);
+static void gst_xml_registry_paths_text (GMarkupParseContext * context,
+ const gchar * text, gsize text_len, gpointer user_data, GError ** error);
static GstRegistryClass *parent_class = NULL;
+
/* static guint gst_xml_registry_signals[LAST_SIGNAL] = { 0 }; */
-static const GMarkupParser
-gst_xml_registry_parser =
-{
+static const GMarkupParser gst_xml_registry_parser = {
gst_xml_registry_start_element,
gst_xml_registry_end_element,
gst_xml_registry_text,
gst_xml_registry_error,
};
-static const GMarkupParser
-gst_xml_registry_paths_parser =
-{
+static const GMarkupParser gst_xml_registry_paths_parser = {
gst_xml_registry_paths_start_element,
gst_xml_registry_paths_end_element,
gst_xml_registry_paths_text,
};
-GType
-gst_xml_registry_get_type (void)
+GType
+gst_xml_registry_get_type (void)
{
static GType xml_registry_type = 0;
(GClassInitFunc) gst_xml_registry_class_init,
NULL,
NULL,
- sizeof(GstXMLRegistry),
+ sizeof (GstXMLRegistry),
0,
(GInstanceInitFunc) gst_xml_registry_init,
NULL
};
- xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY,
- "GstXMLRegistry", &xml_registry_info, 0);
+ xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY,
+ "GstXMLRegistry", &xml_registry_info, 0);
}
return xml_registry_type;
}
static void
-gst_xml_registry_class_init (GstXMLRegistryClass *klass)
+gst_xml_registry_class_init (GstXMLRegistryClass * klass)
{
GObjectClass *gobject_class;
GstRegistryClass *gstregistry_class;
GstXMLRegistryClass *gstxmlregistry_class;
- gobject_class = (GObjectClass*)klass;
- gstregistry_class = (GstRegistryClass*)klass;
- gstxmlregistry_class = (GstXMLRegistryClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstregistry_class = (GstRegistryClass *) klass;
+ gstxmlregistry_class = (GstXMLRegistryClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_REGISTRY);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_xml_registry_get_property);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_xml_registry_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_get_property);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_set_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION,
- g_param_spec_string ("location", "Location", "Location of the registry file",
- NULL, G_PARAM_READWRITE));
-
- gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load);
- gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save);
- gstregistry_class->rebuild = GST_DEBUG_FUNCPTR (gst_xml_registry_rebuild);
-
- gstregistry_class->load_plugin = GST_DEBUG_FUNCPTR (gst_xml_registry_load_plugin);
-
- gstxmlregistry_class->get_perms_func = GST_DEBUG_FUNCPTR (gst_xml_registry_get_perms_func);
- gstxmlregistry_class->add_path_list_func = GST_DEBUG_FUNCPTR (gst_xml_registry_add_path_list_func);
- gstxmlregistry_class->open_func = GST_DEBUG_FUNCPTR (gst_xml_registry_open_func);
- gstxmlregistry_class->load_func = GST_DEBUG_FUNCPTR (gst_xml_registry_load_func);
- gstxmlregistry_class->save_func = GST_DEBUG_FUNCPTR (gst_xml_registry_save_func);
- gstxmlregistry_class->close_func = GST_DEBUG_FUNCPTR (gst_xml_registry_close_func);
+ g_param_spec_string ("location", "Location",
+ "Location of the registry file", NULL, G_PARAM_READWRITE));
+
+ gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load);
+ gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save);
+ gstregistry_class->rebuild = GST_DEBUG_FUNCPTR (gst_xml_registry_rebuild);
+
+ gstregistry_class->load_plugin =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_load_plugin);
+
+ gstxmlregistry_class->get_perms_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_get_perms_func);
+ gstxmlregistry_class->add_path_list_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_add_path_list_func);
+ gstxmlregistry_class->open_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_open_func);
+ gstxmlregistry_class->load_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_load_func);
+ gstxmlregistry_class->save_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_save_func);
+ gstxmlregistry_class->close_func =
+ GST_DEBUG_FUNCPTR (gst_xml_registry_close_func);
}
static void
-gst_xml_registry_init (GstXMLRegistry *registry)
+gst_xml_registry_init (GstXMLRegistry * registry)
{
registry->location = NULL;
registry->context = NULL;
*
* Returns: a new GstXMLRegistry with the given name an location.
*/
-GstRegistry*
-gst_xml_registry_new (const gchar *name, const gchar *location)
+GstRegistry *
+gst_xml_registry_new (const gchar * name, const gchar * location)
{
GstXMLRegistry *xmlregistry;
-
+
xmlregistry = GST_XML_REGISTRY (g_object_new (GST_TYPE_XML_REGISTRY, NULL));
-
+
g_object_set (G_OBJECT (xmlregistry), "location", location, NULL);
GST_REGISTRY (xmlregistry)->name = g_strdup (name);
}
static void
-gst_xml_registry_set_property (GObject* object, guint prop_id,
- const GValue* value, GParamSpec* pspec)
+gst_xml_registry_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXMLRegistry *registry;
-
+
registry = GST_XML_REGISTRY (object);
switch (prop_id) {
case PROP_LOCATION:
if (registry->open) {
- CLASS (object)->close_func (registry);
- g_return_if_fail (registry->open == FALSE);
+ CLASS (object)->close_func (registry);
+ g_return_if_fail (registry->open == FALSE);
}
-
+
if (registry->location)
- g_free (registry->location);
-
+ g_free (registry->location);
+
registry->location = g_strdup (g_value_get_string (value));
GST_REGISTRY (registry)->flags = 0x0;
if (CLASS (object)->get_perms_func)
- CLASS (object)->get_perms_func (registry);
+ CLASS (object)->get_perms_func (registry);
if (CLASS (object)->add_path_list_func)
- CLASS (object)->add_path_list_func (registry);
+ CLASS (object)->add_path_list_func (registry);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static void
-gst_xml_registry_get_property (GObject* object, guint prop_id,
- GValue* value, GParamSpec* pspec)
+gst_xml_registry_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstXMLRegistry *registry;
-
+
registry = GST_XML_REGISTRY (object);
switch (prop_id) {
* so this function returns the last time *anything* changed to this path
*/
static time_t
-get_time(const char * path)
+get_time (const char *path)
{
struct stat statbuf;
- if (stat(path, &statbuf)) return 0;
- if (statbuf.st_mtime > statbuf.st_ctime) return statbuf.st_mtime;
+
+ if (stat (path, &statbuf))
+ return 0;
+ if (statbuf.st_mtime > statbuf.st_ctime)
+ return statbuf.st_mtime;
return statbuf.st_ctime;
}
(S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
static gboolean
-make_dir (gchar *filename)
+make_dir (gchar * filename)
{
struct stat dirstat;
gchar *dirname;
if (strrchr (filename, '/') == NULL)
return FALSE;
-
- dirname = g_strndup(filename, strrchr(filename, '/') - filename);
+
+ dirname = g_strndup (filename, strrchr (filename, '/') - filename);
if (stat (dirname, &dirstat) == -1 && errno == ENOENT) {
if (mkdir (dirname, dirmode) != 0) {
if (make_dir (dirname) != TRUE) {
- g_free(dirname);
- return FALSE;
+ g_free (dirname);
+ return FALSE;
} else {
- if (mkdir (dirname, dirmode) != 0)
- return FALSE;
+ if (mkdir (dirname, dirmode) != 0)
+ return FALSE;
}
}
}
- g_free(dirname);
+ g_free (dirname);
return TRUE;
}
static void
-gst_xml_registry_get_perms_func (GstXMLRegistry *registry)
+gst_xml_registry_get_perms_func (GstXMLRegistry * registry)
{
time_t mod_time = 0;
FILE *temp;
if the file can be appended to, it's writable. if it can then be read,
it's readable.
After that check if it exists. */
-
+
if (make_dir (registry->location) != TRUE) {
/* we can't do anything with it, leave flags as 0x0 */
return;
}
-
+
mod_time = get_time (registry->location);
-
+
if ((temp = fopen (registry->location, "a"))) {
GST_REGISTRY (registry)->flags |= GST_REGISTRY_WRITABLE;
fclose (temp);
}
-
+
if ((temp = fopen (registry->location, "r"))) {
GST_REGISTRY (registry)->flags |= GST_REGISTRY_READABLE;
fclose (temp);
if (mod_time) {
struct utimbuf utime_buf;
-
+
/* set the modification time back to its previous value */
utime_buf.actime = mod_time;
utime_buf.modtime = mod_time;
unlink (registry->location);
}
}
-
+
static void
-gst_xml_registry_add_path_list_func (GstXMLRegistry *registry)
+gst_xml_registry_add_path_list_func (GstXMLRegistry * registry)
{
FILE *reg = NULL;
GMarkupParseContext *context;
gssize size;
GError *error = NULL;
- context = g_markup_parse_context_new (&gst_xml_registry_paths_parser, 0,
- registry, NULL);
+ context = g_markup_parse_context_new (&gst_xml_registry_paths_parser, 0,
+ registry, NULL);
- if (! (reg = fopen (registry->location, "r"))) {
+ if (!(reg = fopen (registry->location, "r"))) {
goto finished;
}
g_markup_parse_context_parse (context, text, size, &error);
if (error) {
- GST_ERROR ("parsing registry %s: %s\n",
- registry->location, error->message);
+ GST_ERROR ("parsing registry %s: %s\n",
+ registry->location, error->message);
goto finished;
}
size = fread (text, 1, BLOCK_SIZE, reg);
}
- finished:
+finished:
g_markup_parse_context_free (context);
}
static gboolean
-plugin_times_older_than_recurse(gchar *path, time_t regtime)
+plugin_times_older_than_recurse (gchar * path, time_t regtime)
{
DIR *dir;
struct dirent *dirent;
gchar *pluginname;
- time_t pathtime = get_time(path);
+ time_t pathtime = get_time (path);
if (pathtime > regtime) {
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
- "time for %s was %ld; more recent than registry time of %ld\n",
- path, (long)pathtime, (long)regtime);
+ "time for %s was %ld; more recent than registry time of %ld\n",
+ path, (long) pathtime, (long) regtime);
return FALSE;
}
- dir = opendir(path);
+ dir = opendir (path);
if (dir) {
- while ((dirent = readdir(dir))) {
+ while ((dirent = readdir (dir))) {
/* don't want to recurse in place or backwards */
- if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) {
- pluginname = g_strjoin("/",path,dirent->d_name,NULL);
- if (!plugin_times_older_than_recurse(pluginname , regtime)) {
- g_free (pluginname);
- closedir(dir);
- return FALSE;
- }
- g_free (pluginname);
+ if (strcmp (dirent->d_name, ".") && strcmp (dirent->d_name, "..")) {
+ pluginname = g_strjoin ("/", path, dirent->d_name, NULL);
+ if (!plugin_times_older_than_recurse (pluginname, regtime)) {
+ g_free (pluginname);
+ closedir (dir);
+ return FALSE;
+ }
+ g_free (pluginname);
}
}
- closedir(dir);
+ closedir (dir);
}
return TRUE;
}
static gboolean
-plugin_times_older_than(GList *paths, time_t regtime)
+plugin_times_older_than (GList * paths, time_t regtime)
{
/* return true iff regtime is more recent than the times of all the files
* in the plugin dirs.
while (paths) {
GST_CAT_LOG (GST_CAT_PLUGIN_LOADING,
- "comparing plugin times from %s with %ld",
- (gchar *)paths->data, (long) regtime);
- if(!plugin_times_older_than_recurse(paths->data, regtime))
+ "comparing plugin times from %s with %ld",
+ (gchar *) paths->data, (long) regtime);
+ if (!plugin_times_older_than_recurse (paths->data, regtime))
return FALSE;
- paths = g_list_next(paths);
+ paths = g_list_next (paths);
}
return TRUE;
}
static gboolean
-gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode)
+gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
{
GstRegistry *gst_registry;
GList *paths;
* if it's not readable, return false
* if it's out of date, rebuild it */
if (mode == GST_XML_REGISTRY_READ) {
- if (!(gst_registry->flags & GST_REGISTRY_EXISTS))
- {
+ if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
/* if it's not writable, then don't bother */
- if (!(gst_registry->flags & GST_REGISTRY_WRITABLE))
- {
- GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable");
+ if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) {
+ GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable");
return FALSE;
}
- GST_CAT_INFO (GST_CAT_GST_INIT, "Registry doesn't exist, trying to build...");
+ GST_CAT_INFO (GST_CAT_GST_INIT,
+ "Registry doesn't exist, trying to build...");
gst_registry_rebuild (gst_registry);
gst_registry_save (gst_registry);
/* FIXME: verify that the flags actually get updated ! */
- if (!(gst_registry->flags & GST_REGISTRY_EXISTS))
- {
+ if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
return FALSE;
}
}
if (!plugin_times_older_than (paths, get_time (registry->location))) {
if (gst_registry->flags & GST_REGISTRY_WRITABLE) {
- GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding...");
-
- gst_registry_rebuild (gst_registry);
+ GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding...");
+
+ gst_registry_rebuild (gst_registry);
- gst_registry_save (gst_registry);
+ gst_registry_save (gst_registry);
- if (!plugin_times_older_than (paths, get_time (registry->location))) {
- GST_CAT_INFO (GST_CAT_GST_INIT, "Registry still out of date, something is wrong...");
- return FALSE;
- }
+ if (!plugin_times_older_than (paths, get_time (registry->location))) {
+ GST_CAT_INFO (GST_CAT_GST_INIT,
+ "Registry still out of date, something is wrong...");
+ return FALSE;
+ }
} else {
- GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Can't write to this registry and it's out of date, ignoring it");
- return FALSE;
+ GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
+ "Can't write to this registry and it's out of date, ignoring it");
+ return FALSE;
}
}
-
+
registry->regfile = fopen (registry->location, "r");
- }
- else if (mode == GST_XML_REGISTRY_WRITE)
- {
+ } else if (mode == GST_XML_REGISTRY_WRITE) {
g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_WRITABLE, FALSE);
registry->regfile = fopen (registry->location, "w");
}
static gboolean
-gst_xml_registry_load_func (GstXMLRegistry *registry, gchar *data, gssize *size)
+gst_xml_registry_load_func (GstXMLRegistry * registry, gchar * data,
+ gssize * size)
{
*size = fread (data, 1, *size, registry->regfile);
-
+
return TRUE;
}
static gboolean
-gst_xml_registry_save_func (GstXMLRegistry *registry, gchar *format, ...)
+gst_xml_registry_save_func (GstXMLRegistry * registry, gchar * format, ...)
{
va_list var_args;
}
static gboolean
-gst_xml_registry_close_func (GstXMLRegistry *registry)
+gst_xml_registry_close_func (GstXMLRegistry * registry)
{
fclose (registry->regfile);
}
static gboolean
-gst_xml_registry_load (GstRegistry *registry)
+gst_xml_registry_load (GstRegistry * registry)
{
GstXMLRegistry *xmlregistry;
gchar *text;
xmlregistry = GST_XML_REGISTRY (registry);
- timer = g_timer_new();
-
- xmlregistry->context = g_markup_parse_context_new (&gst_xml_registry_parser, 0, registry, NULL);
+ timer = g_timer_new ();
+
+ xmlregistry->context =
+ g_markup_parse_context_new (&gst_xml_registry_parser, 0, registry, NULL);
if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_READ)) {
g_timer_destroy (timer);
seconds = g_timer_elapsed (timer, NULL);
g_timer_destroy (timer);
- GST_INFO ("loaded %s in %f seconds (%s)",
- registry->name, seconds, xmlregistry->location);
+ GST_INFO ("loaded %s in %f seconds (%s)",
+ registry->name, seconds, xmlregistry->location);
CLASS (xmlregistry)->close_func (xmlregistry);
-
+
return TRUE;
}
-static GstRegistryReturn
-gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin)
+static GstRegistryReturn
+gst_xml_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin)
{
GError *error = NULL;
GstPlugin *loaded_plugin;
loaded_plugin = gst_plugin_load_file (plugin->filename, &error);
if (!plugin) {
if (error) {
- g_warning ("could not load plugin %s: %s", plugin->desc.name, error->message);
+ g_warning ("could not load plugin %s: %s", plugin->desc.name,
+ error->message);
}
return GST_REGISTRY_PLUGIN_LOAD_ERROR;
} else if (loaded_plugin != plugin) {
}
static gboolean
-gst_xml_registry_parse_plugin (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_plugin (GMarkupParseContext * context, const gchar * tag,
+ const gchar * text, gsize text_len, GstXMLRegistry * registry,
+ GError ** error)
{
GstPlugin *plugin = registry->current_plugin;
-
+
if (!strcmp (tag, "name")) {
plugin->desc.name = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "description")) {
+ } else if (!strcmp (tag, "description")) {
plugin->desc.description = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "filename")) {
+ } else if (!strcmp (tag, "filename")) {
plugin->filename = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "version")) {
+ } else if (!strcmp (tag, "version")) {
plugin->desc.version = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "license")) {
+ } else if (!strcmp (tag, "license")) {
plugin->desc.license = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "package")) {
+ } else if (!strcmp (tag, "package")) {
plugin->desc.package = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "origin")) {
+ } else if (!strcmp (tag, "origin")) {
plugin->desc.origin = g_strndup (text, text_len);
}
-
+
return TRUE;
}
static void
-add_to_char_array (gchar ***array, gchar *value)
+add_to_char_array (gchar *** array, gchar * value)
{
gchar **new;
gchar **old = *array;
gint i = 0;
-
+
/* expensive, but cycles are cheap... */
if (old)
- while (old[i]) i++;
+ while (old[i])
+ i++;
new = g_new0 (gchar *, i + 2);
new[i] = value;
while (i > 0) {
}
static gboolean
-gst_xml_registry_parse_element_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_element_factory (GMarkupParseContext * context,
+ const gchar * tag, const gchar * text, gsize text_len,
+ GstXMLRegistry * registry, GError ** error)
{
GstElementFactory *factory = GST_ELEMENT_FACTORY (registry->current_feature);
if (!strcmp (tag, "name")) {
gchar *name = g_strndup (text, text_len);
+
gst_plugin_feature_set_name (registry->current_feature, name);
g_free (name);
- }
- else if (!strcmp (tag, "longname")) {
+ } else if (!strcmp (tag, "longname")) {
g_free (factory->details.longname);
factory->details.longname = g_strndup (text, text_len);
- }
- else if (!strcmp(tag, "class")) {
+ } else if (!strcmp (tag, "class")) {
g_free (factory->details.klass);
factory->details.klass = g_strndup (text, text_len);
- }
- else if (!strcmp(tag, "description")) {
+ } else if (!strcmp (tag, "description")) {
g_free (factory->details.description);
factory->details.description = g_strndup (text, text_len);
- }
- else if (!strcmp(tag, "author")) {
+ } else if (!strcmp (tag, "author")) {
g_free (factory->details.author);
factory->details.author = g_strndup (text, text_len);
- }
- else if (!strcmp(tag, "rank")) {
+ } else if (!strcmp (tag, "rank")) {
gint rank;
gchar *ret;
-
+
rank = strtol (text, &ret, 0);
if (ret == text + text_len) {
- gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
+ gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
}
} else if (!strcmp (tag, "uri_type")) {
if (strncasecmp (text, "sink", 4) == 0) {
}
} else if (!strcmp (tag, "uri_protocol")) {
add_to_char_array (&factory->uri_protocols, g_strndup (text, text_len));
- }
- else if (!strcmp(tag, "interface")) {
+ } else if (!strcmp (tag, "interface")) {
gchar *tmp = g_strndup (text, text_len);
+
__gst_element_factory_add_interface (factory, tmp);
g_free (tmp);
}
}
static gboolean
-gst_xml_registry_parse_type_find_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_type_find_factory (GMarkupParseContext * context,
+ const gchar * tag, const gchar * text, gsize text_len,
+ GstXMLRegistry * registry, GError ** error)
{
- GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (registry->current_feature);
+ GstTypeFindFactory *factory =
+ GST_TYPE_FIND_FACTORY (registry->current_feature);
if (!strcmp (tag, "name")) {
registry->current_feature->name = g_strndup (text, text_len);
- }
- else if (!strcmp(tag, "rank")) {
+ } else if (!strcmp (tag, "rank")) {
glong rank;
gchar *ret;
- rank = strtol (text, &ret, 0);
+
+ rank = strtol (text, &ret, 0);
if (ret == text + text_len) {
- gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
+ gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
}
}
/* FIXME!!
- else if (!strcmp (tag, "caps")) {
- factory->caps = g_strndup (text, text_len);
- }*/
- else if (!strcmp(tag, "extension")) {
+ else if (!strcmp (tag, "caps")) {
+ factory->caps = g_strndup (text, text_len);
+ } */
+ else if (!strcmp (tag, "extension")) {
add_to_char_array (&factory->extensions, g_strndup (text, text_len));
}
}
static gboolean
-gst_xml_registry_parse_scheduler_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_scheduler_factory (GMarkupParseContext * context,
+ const gchar * tag, const gchar * text, gsize text_len,
+ GstXMLRegistry * registry, GError ** error)
{
- GstSchedulerFactory *factory = GST_SCHEDULER_FACTORY (registry->current_feature);
+ GstSchedulerFactory *factory =
+ GST_SCHEDULER_FACTORY (registry->current_feature);
if (!strcmp (tag, "name")) {
registry->current_feature->name = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "longdesc")) {
+ } else if (!strcmp (tag, "longdesc")) {
factory->longdesc = g_strndup (text, text_len);
}
return TRUE;
}
static gboolean
-gst_xml_registry_parse_index_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_index_factory (GMarkupParseContext * context,
+ const gchar * tag, const gchar * text, gsize text_len,
+ GstXMLRegistry * registry, GError ** error)
{
GstIndexFactory *factory = GST_INDEX_FACTORY (registry->current_feature);
if (!strcmp (tag, "name")) {
registry->current_feature->name = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "longdesc")) {
+ } else if (!strcmp (tag, "longdesc")) {
factory->longdesc = g_strndup (text, text_len);
}
return TRUE;
}
static gboolean
-gst_xml_registry_parse_padtemplate (GMarkupParseContext *context, const gchar *tag, const gchar *text,
- gsize text_len, GstXMLRegistry *registry, GError **error)
+gst_xml_registry_parse_padtemplate (GMarkupParseContext * context,
+ const gchar * tag, const gchar * text, gsize text_len,
+ GstXMLRegistry * registry, GError ** error)
{
if (!strcmp (tag, "nametemplate")) {
registry->name_template = g_strndup (text, text_len);
- }
- else if (!strcmp (tag, "direction")) {
- if (!strncmp(text, "sink", text_len)) {
+ } else if (!strcmp (tag, "direction")) {
+ if (!strncmp (text, "sink", text_len)) {
registry->direction = GST_PAD_SINK;
- }
- else if (!strncmp(text, "src", text_len)) {
+ } else if (!strncmp (text, "src", text_len)) {
registry->direction = GST_PAD_SRC;
}
- }
- else if (!strcmp (tag, "presence")) {
- if (!strncmp(text, "always", text_len)) {
+ } else if (!strcmp (tag, "presence")) {
+ if (!strncmp (text, "always", text_len)) {
registry->presence = GST_PAD_ALWAYS;
- }
- else if (!strncmp(text, "sometimes", text_len)) {
+ } else if (!strncmp (text, "sometimes", text_len)) {
registry->presence = GST_PAD_SOMETIMES;
- }
- else if (!strncmp(text, "request", text_len)) {
+ } else if (!strncmp (text, "request", text_len)) {
registry->presence = GST_PAD_REQUEST;
}
- }
- else if (!strncmp (tag, "caps", 4)) {
+ } else if (!strncmp (tag, "caps", 4)) {
char *s;
s = g_strndup (text, text_len);
g_assert (registry->caps == NULL);
registry->caps = gst_caps_from_string (s);
if (registry->caps == NULL) {
- g_critical ("Could not parse caps: length %d, content: %*s\n", text_len, text_len, text);
+ g_critical ("Could not parse caps: length %d, content: %*s\n", text_len,
+ text_len, text);
}
- g_free(s);
+ g_free (s);
return TRUE;
}
return TRUE;
}
static void
-gst_xml_registry_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data, GError **error)
+gst_xml_registry_start_element (GMarkupParseContext * context,
+ const gchar * element_name,
+ const gchar ** attribute_names,
+ const gchar ** attribute_values, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
- xmlregistry->open_tags = g_list_prepend (xmlregistry->open_tags,
- g_strdup (element_name));
+ xmlregistry->open_tags = g_list_prepend (xmlregistry->open_tags,
+ g_strdup (element_name));
switch (xmlregistry->state) {
case GST_XML_REGISTRY_NONE:
if (!strncmp (element_name, "feature", 7)) {
gint i = 0;
GstPluginFeature *feature = NULL;
-
+
xmlregistry->state = GST_XML_REGISTRY_FEATURE;
while (attribute_names[i]) {
- if (!strncmp (attribute_names[i], "typename", 8)) {
- feature = GST_PLUGIN_FEATURE (g_object_new (g_type_from_name (attribute_values[i]), NULL));
+ if (!strncmp (attribute_names[i], "typename", 8)) {
+ feature =
+ GST_PLUGIN_FEATURE (g_object_new (g_type_from_name
+ (attribute_values[i]), NULL));
break;
}
- i++;
+ i++;
}
if (feature) {
xmlregistry->current_feature = feature;
factory->padtemplates = NULL;
xmlregistry->parser = gst_xml_registry_parse_element_factory;
break;
- }
- else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
+ } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_type_find_factory;
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_scheduler_factory;
- GST_SCHEDULER_FACTORY (feature)->type = 0;
- }
- else if (GST_IS_INDEX_FACTORY (feature)) {
+ GST_SCHEDULER_FACTORY (feature)->type = 0;
+ } else if (GST_IS_INDEX_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_index_factory;
- }
- else {
- g_warning ("unknown feature type");
+ } else {
+ g_warning ("unknown feature type");
}
}
}
}
static void
-gst_xml_registry_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data, GError **error)
+gst_xml_registry_end_element (GMarkupParseContext * context,
+ const gchar * element_name, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
- gchar *open_tag = (gchar *)xmlregistry->open_tags->data;
+ gchar *open_tag = (gchar *) xmlregistry->open_tags->data;
xmlregistry->open_tags = g_list_remove (xmlregistry->open_tags, open_tag);
g_free (open_tag);
if (!strcmp (element_name, "plugin")) {
xmlregistry->state = GST_XML_REGISTRY_TOP;
xmlregistry->parser = NULL;
- gst_registry_add_plugin (GST_REGISTRY (xmlregistry), xmlregistry->current_plugin);
+ gst_registry_add_plugin (GST_REGISTRY (xmlregistry),
+ xmlregistry->current_plugin);
}
break;
case GST_XML_REGISTRY_FEATURE:
if (!strcmp (element_name, "feature")) {
xmlregistry->state = GST_XML_REGISTRY_PLUGIN;
xmlregistry->parser = gst_xml_registry_parse_plugin;
- gst_plugin_add_feature (xmlregistry->current_plugin, xmlregistry->current_feature);
+ gst_plugin_add_feature (xmlregistry->current_plugin,
+ xmlregistry->current_feature);
xmlregistry->current_feature = NULL;
}
break;
if (!strcmp (element_name, "padtemplate")) {
GstPadTemplate *template;
- template = gst_pad_template_new (xmlregistry->name_template,
- xmlregistry->direction,
- xmlregistry->presence,
- xmlregistry->caps);
+ template = gst_pad_template_new (xmlregistry->name_template,
+ xmlregistry->direction, xmlregistry->presence, xmlregistry->caps);
g_free (xmlregistry->name_template);
xmlregistry->name_template = NULL;
xmlregistry->caps = NULL;
- __gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY (xmlregistry->current_feature),
- template);
+ __gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY
+ (xmlregistry->current_feature), template);
xmlregistry->state = GST_XML_REGISTRY_FEATURE;
xmlregistry->parser = gst_xml_registry_parse_element_factory;
}
}
static void
-gst_xml_registry_text (GMarkupParseContext *context, const gchar *text,
- gsize text_len, gpointer user_data, GError **error)
+gst_xml_registry_text (GMarkupParseContext * context, const gchar * text,
+ gsize text_len, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
gchar *open_tag;
-
+
if (xmlregistry->open_tags) {
- open_tag = (gchar *)xmlregistry->open_tags->data;
+ open_tag = (gchar *) xmlregistry->open_tags->data;
if (!strcmp (open_tag, "plugin-path")) {
//gst_plugin_add_path (g_strndup (text, text_len));
- }
- else if (xmlregistry->parser) {
- xmlregistry->parser (context, open_tag, text, text_len, xmlregistry, error);
+ } else if (xmlregistry->parser) {
+ xmlregistry->parser (context, open_tag, text, text_len, xmlregistry,
+ error);
}
}
}
static void
-gst_xml_registry_passthrough (GMarkupParseContext *context, const gchar *passthrough_text,
- gsize text_len, gpointer user_data, GError **error)
+gst_xml_registry_passthrough (GMarkupParseContext * context,
+ const gchar * passthrough_text, gsize text_len, gpointer user_data,
+ GError ** error)
{
}
static void
-gst_xml_registry_error (GMarkupParseContext *context, GError *error,
- gpointer user_data)
+gst_xml_registry_error (GMarkupParseContext * context, GError * error,
+ gpointer user_data)
{
GST_ERROR ("%s\n", error->message);
}
static void
-gst_xml_registry_paths_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data, GError **error)
+gst_xml_registry_paths_start_element (GMarkupParseContext * context,
+ const gchar * element_name,
+ const gchar ** attribute_names,
+ const gchar ** attribute_values, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
}
static void
-gst_xml_registry_paths_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data, GError **error)
+gst_xml_registry_paths_end_element (GMarkupParseContext * context,
+ const gchar * element_name, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
}
static void
-gst_xml_registry_paths_text (GMarkupParseContext *context, const gchar *text,
- gsize text_len, gpointer user_data, GError **error)
+gst_xml_registry_paths_text (GMarkupParseContext * context, const gchar * text,
+ gsize text_len, gpointer user_data, GError ** error)
{
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
-
+
if (xmlregistry->state == GST_XML_REGISTRY_PATH)
- gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text, text_len));
+ gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text,
+ text_len));
}
/*
static gboolean
-gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, const GstCaps *caps)
+gst_xml_registry_save_caps (GstXMLRegistry * xmlregistry, const GstCaps * caps)
{
char *s = gst_caps_to_string (caps);
+
PUT_ESCAPED ("caps", s);
g_free (s);
return TRUE;
}
static gboolean
-gst_xml_registry_save_pad_template (GstXMLRegistry *xmlregistry, GstPadTemplate *template)
+gst_xml_registry_save_pad_template (GstXMLRegistry * xmlregistry,
+ GstPadTemplate * template)
{
gchar *presence;
-
+
PUT_ESCAPED ("nametemplate", template->name_template);
- CLASS (xmlregistry)->save_func (xmlregistry, "<direction>%s</direction>\n", (template->direction == GST_PAD_SINK? "sink":"src"));
+ CLASS (xmlregistry)->save_func (xmlregistry, "<direction>%s</direction>\n",
+ (template->direction == GST_PAD_SINK ? "sink" : "src"));
switch (template->presence) {
case GST_PAD_ALWAYS:
presence = "unknown";
break;
}
- CLASS (xmlregistry)->save_func (xmlregistry, "<presence>%s</presence>\n", presence);
+ CLASS (xmlregistry)->save_func (xmlregistry, "<presence>%s</presence>\n",
+ presence);
if (GST_PAD_TEMPLATE_CAPS (template)) {
gst_xml_registry_save_caps (xmlregistry, GST_PAD_TEMPLATE_CAPS (template));
}
static gboolean
-gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *feature)
+gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry,
+ GstPluginFeature * feature)
{
PUT_ESCAPED ("name", feature->name);
if (feature->rank > 0) {
gint rank = feature->rank;
+
CLASS (xmlregistry)->save_func (xmlregistry, "<rank>%d</rank>\n", rank);
- }
-
+ }
+
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
GList *walk;
PUT_ESCAPED ("class", factory->details.klass);
PUT_ESCAPED ("description", factory->details.description);
PUT_ESCAPED ("author", factory->details.author);
-
+
walk = factory->padtemplates;
while (walk) {
CLASS (xmlregistry)->save_func (xmlregistry, "<padtemplate>\n");
gst_xml_registry_save_pad_template (xmlregistry, template);
CLASS (xmlregistry)->save_func (xmlregistry, "</padtemplate>\n");
-
+
walk = g_list_next (walk);
}
if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
gchar **protocol;
-
- PUT_ESCAPED ("uri_type", factory->uri_type == GST_URI_SINK ? "sink" : "source");
+
+ PUT_ESCAPED ("uri_type",
+ factory->uri_type == GST_URI_SINK ? "sink" : "source");
g_assert (factory->uri_protocols);
protocol = factory->uri_protocols;
while (*protocol) {
protocol++;
}
}
- }
- else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
+ } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
gint i = 0;
+
if (factory->caps) {
gst_xml_registry_save_caps (xmlregistry, factory->caps);
}
if (factory->extensions) {
while (factory->extensions[i]) {
- PUT_ESCAPED ("extension", factory->extensions[i]);
- i++;
+ PUT_ESCAPED ("extension", factory->extensions[i]);
+ i++;
}
}
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
PUT_ESCAPED ("longdesc", GST_SCHEDULER_FACTORY (feature)->longdesc);
- }
- else if (GST_IS_INDEX_FACTORY (feature)) {
+ } else if (GST_IS_INDEX_FACTORY (feature)) {
PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc);
}
return TRUE;
}
static gboolean
-gst_xml_registry_save_plugin (GstXMLRegistry *xmlregistry, GstPlugin *plugin)
+gst_xml_registry_save_plugin (GstXMLRegistry * xmlregistry, GstPlugin * plugin)
{
GList *walk;
-
+
PUT_ESCAPED ("name", plugin->desc.name);
PUT_ESCAPED ("description", plugin->desc.description);
PUT_ESCAPED ("filename", plugin->filename);
while (walk) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
- CLASS (xmlregistry)->save_func (xmlregistry, "<feature typename=\"%s\">\n", g_type_name (G_OBJECT_TYPE (feature)));
+ CLASS (xmlregistry)->save_func (xmlregistry, "<feature typename=\"%s\">\n",
+ g_type_name (G_OBJECT_TYPE (feature)));
gst_xml_registry_save_feature (xmlregistry, feature);
CLASS (xmlregistry)->save_func (xmlregistry, "</feature>\n");
-
+
walk = g_list_next (walk);
}
return TRUE;
static gboolean
-gst_xml_registry_save (GstRegistry *registry)
+gst_xml_registry_save (GstRegistry * registry)
{
GList *walk;
GstXMLRegistry *xmlregistry;
-
+
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
g_return_val_if_fail (registry->flags & GST_REGISTRY_WRITABLE, FALSE);
-
+
xmlregistry = GST_XML_REGISTRY (registry);
if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_WRITE)) {
CLASS (xmlregistry)->save_func (xmlregistry, "<?xml version=\"1.0\"?>\n");
CLASS (xmlregistry)->save_func (xmlregistry, "<GST-PluginRegistry>\n");
-
+
walk = g_list_last (gst_registry_get_path_list (GST_REGISTRY (registry)));
-
+
CLASS (xmlregistry)->save_func (xmlregistry, "<gst-plugin-paths>\n");
while (walk) {
CLASS (xmlregistry)->save_func (xmlregistry, "<path>");
- CLASS (xmlregistry)->save_func (xmlregistry, (gchar*)walk->data);
+ CLASS (xmlregistry)->save_func (xmlregistry, (gchar *) walk->data);
CLASS (xmlregistry)->save_func (xmlregistry, "</path>\n");
walk = g_list_previous (walk);
}
CLASS (xmlregistry)->save_func (xmlregistry, "<plugin>\n");
gst_xml_registry_save_plugin (xmlregistry, plugin);
CLASS (xmlregistry)->save_func (xmlregistry, "</plugin>\n");
-
+
walk = g_list_previous (walk);
}
CLASS (xmlregistry)->save_func (xmlregistry, "</GST-PluginRegistry>\n");
return TRUE;
}
-static GList*
-gst_xml_registry_rebuild_recurse (GstXMLRegistry *registry,
- const gchar *directory)
+static GList *
+gst_xml_registry_rebuild_recurse (GstXMLRegistry * registry,
+ const gchar * directory)
{
GDir *dir;
gchar *temp;
while ((dirent = g_dir_read_name (dir))) {
gchar *dirname;
-
+
if (*dirent == '=') {
- /* =build, =inst, etc. -- automake distcheck directories */
- continue;
+ /* =build, =inst, etc. -- automake distcheck directories */
+ continue;
}
-
+
dirname = g_strjoin ("/", directory, dirent, NULL);
- ret = g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry, dirname));
- g_free(dirname);
+ ret =
+ g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry,
+ dirname));
+ g_free (dirname);
}
g_dir_close (dir);
} else {
if ((temp = strstr (directory, G_MODULE_SUFFIX)) &&
- (!strcmp (temp, G_MODULE_SUFFIX))) {
+ (!strcmp (temp, G_MODULE_SUFFIX))) {
ret = g_list_prepend (ret, g_strdup (directory));
}
}
}
static gboolean
-gst_xml_registry_rebuild (GstRegistry *registry)
+gst_xml_registry_rebuild (GstRegistry * registry)
{
GList *walk = NULL, *plugins = NULL, *prune = NULL;
GError *error = NULL;
guint length;
GstPlugin *plugin;
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (registry);
-
+
walk = registry->paths;
while (walk) {
gchar *path = (gchar *) walk->data;
-
- GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
- "Rebuilding registry %p in directory %s...", registry, path);
- plugins = g_list_concat (plugins,
- gst_xml_registry_rebuild_recurse (xmlregistry,
- path));
+ GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
+ "Rebuilding registry %p in directory %s...", registry, path);
+
+ plugins = g_list_concat (plugins,
+ gst_xml_registry_rebuild_recurse (xmlregistry, path));
walk = g_list_next (walk);
}
-
+
plugins = g_list_reverse (plugins);
do {
g_assert (walk->data);
plugin = gst_plugin_load_file ((gchar *) walk->data, NULL);
if (plugin) {
- prune = g_list_prepend (prune, walk->data);
- gst_registry_add_plugin (registry, plugin);
+ prune = g_list_prepend (prune, walk->data);
+ gst_registry_add_plugin (registry, plugin);
}
walk = g_list_next (walk);
g_list_free (prune);
prune = NULL;
} while (g_list_length (plugins) != length);
-
+
walk = plugins;
while (walk) {
if ((plugin = gst_plugin_load_file ((gchar *) walk->data, &error))) {
- g_warning ("Bizarre behavior: plugin %s actually loaded",
- (gchar *) walk->data);
+ g_warning ("Bizarre behavior: plugin %s actually loaded",
+ (gchar *) walk->data);
gst_registry_add_plugin (registry, plugin);
} else {
- GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s",
- (gchar *) walk->data, error->message);
+ GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s",
+ (gchar *) walk->data, error->message);
g_free (walk->data);
g_error_free (error);
error = NULL;
}
-
+
walk = g_list_next (walk);
}
return TRUE;
#include <gst/gstregistry.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XML_REGISTRY \
(gst_xml_registry_get_type())
#define GST_XML_REGISTRY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XML_REGISTRY))
#define GST_IS_XML_REGISTRY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XML_REGISTRY))
-
typedef struct _GstXMLRegistry GstXMLRegistry;
typedef struct _GstXMLRegistryClass GstXMLRegistryClass;
-typedef enum {
+typedef enum
+{
GST_XML_REGISTRY_NONE,
GST_XML_REGISTRY_TOP,
GST_XML_REGISTRY_PATHS,
GST_XML_REGISTRY_PROPERTIES
} GstXMLRegistryState;
-typedef enum {
+typedef enum
+{
GST_XML_REGISTRY_READ,
GST_XML_REGISTRY_WRITE
} GstXMLRegistryMode;
-typedef void (*GstXMLRegistryGetPerms) (GstXMLRegistry *registry);
-typedef void (*GstXMLRegistryAddPathList) (GstXMLRegistry *registry);
-typedef gboolean (*GstXMLRegistryParser) (GMarkupParseContext *context,
- const gchar *tag,
- const gchar *text,
- gsize text_len,
- GstXMLRegistry *registry,
- GError **error);
-
-typedef gboolean (*GstXMLRegistryOpen) (GstXMLRegistry *registry,
- GstXMLRegistryMode mode);
-typedef gboolean (*GstXMLRegistryLoad) (GstXMLRegistry *registry,
- gchar *dest,
- gssize *size);
-typedef gboolean (*GstXMLRegistrySave) (GstXMLRegistry *registry,
- gchar *format,
- ...);
-typedef gboolean (*GstXMLRegistryClose) (GstXMLRegistry *registry);
-
-struct _GstXMLRegistry {
- GstRegistry object;
-
- gchar *location;
- gboolean open;
-
- FILE *regfile;
- gchar *buffer;
-
- GMarkupParseContext *context;
- GList *open_tags;
- GstXMLRegistryState state;
- GstXMLRegistryParser parser;
-
- GstPlugin *current_plugin;
- GstPluginFeature *current_feature;
-
- gchar *name_template;
- GstPadDirection direction;
- GstPadPresence presence;
- GstCaps *caps;
-
- gchar *caps_name;
- gchar *structure_name;
-
- gboolean in_list;
- GList *entry_list;
- gchar *list_name;
+typedef void (*GstXMLRegistryGetPerms) (GstXMLRegistry * registry);
+typedef void (*GstXMLRegistryAddPathList) (GstXMLRegistry * registry);
+typedef gboolean (*GstXMLRegistryParser) (GMarkupParseContext * context,
+ const gchar * tag,
+ const gchar * text,
+ gsize text_len, GstXMLRegistry * registry, GError ** error);
+
+typedef gboolean (*GstXMLRegistryOpen) (GstXMLRegistry * registry,
+ GstXMLRegistryMode mode);
+typedef gboolean (*GstXMLRegistryLoad) (GstXMLRegistry * registry,
+ gchar * dest, gssize * size);
+typedef gboolean (*GstXMLRegistrySave) (GstXMLRegistry * registry,
+ gchar * format, ...);
+typedef gboolean (*GstXMLRegistryClose) (GstXMLRegistry * registry);
+
+struct _GstXMLRegistry
+{
+ GstRegistry object;
+
+ gchar *location;
+ gboolean open;
+
+ FILE *regfile;
+ gchar *buffer;
+
+ GMarkupParseContext *context;
+ GList *open_tags;
+ GstXMLRegistryState state;
+ GstXMLRegistryParser parser;
+
+ GstPlugin *current_plugin;
+ GstPluginFeature *current_feature;
+
+ gchar *name_template;
+ GstPadDirection direction;
+ GstPadPresence presence;
+ GstCaps *caps;
+
+ gchar *caps_name;
+ gchar *structure_name;
+
+ gboolean in_list;
+ GList *entry_list;
+ gchar *list_name;
};
-struct _GstXMLRegistryClass {
- GstRegistryClass parent_class;
+struct _GstXMLRegistryClass
+{
+ GstRegistryClass parent_class;
GstXMLRegistryGetPerms get_perms_func;
GstXMLRegistryAddPathList add_path_list_func;
- GstXMLRegistryOpen open_func;
- GstXMLRegistryLoad load_func;
- GstXMLRegistrySave save_func;
- GstXMLRegistryClose close_func;
+ GstXMLRegistryOpen open_func;
+ GstXMLRegistryLoad load_func;
+ GstXMLRegistrySave save_func;
+ GstXMLRegistryClose close_func;
};
/* normal GObject stuff */
-GType gst_xml_registry_get_type (void);
+GType gst_xml_registry_get_type (void);
-GstRegistry* gst_xml_registry_new (const gchar *name, const gchar *location);
+GstRegistry *gst_xml_registry_new (const gchar * name, const gchar * location);
G_END_DECLS
-
#endif /* __GST_XML_REGISTRY_H__ */
-
#include "gstxmlregistry.h"
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstRegistry *registry;
-
+
gst_init (&argc, &argv);
registry = gst_xml_registry_new ("test", "reg.xml");
gst_registry_load (registry);
-
+
return 0;
-
+
}
/* use the old cothreads implementation in gst/cothreads.[ch] */
#if defined(_COTHREADS_OMEGA)
-
+
#include "../cothreads.h"
/* the name of this cothreads type */
/* define functions
* the macros are prepended with "do_"
*/
-#define do_cothreads_init(x) /* NOP */
+#define do_cothreads_init(x) /* NOP */
#define do_cothreads_stackquery(stack,size) cothread_stackquery(stack,size)
#define do_cothread_setfunc(cothread, context, func, argc, argv) \
cothread_setfunc ((cothread), (func), (argc), (argv))
-
+
#define do_cothread_destroy(cothread) cothread_free(cothread)
#define do_cothread_context_init() (cothread_context_init ())
#define do_cothread_context_destroy(context) cothread_context_free (context)
-
+
#define do_cothread_lock(cothread) cothread_lock(cothread)
#define do_cothread_unlock(cothread) cothread_unlock(cothread)
#define do_cothread_get_current(context) (cothread_current())
#define do_cothread_get_main(context) (cothread_current_main())
-
-
-
-
+
+
+
+
/* use the gthread-based cothreads implementation */
#elif defined(_COTHREADS_GTHREAD)
#include "gthread-cothreads.h"
-
-
+
+
/* bail out with an error if no cothreads package is defined */
#else
#error "No cothreads package defined"
#include "cothreads_compat.h"
-GST_DEBUG_CATEGORY_STATIC(debug_dataflow);
-GST_DEBUG_CATEGORY_STATIC(debug_scheduler);
+GST_DEBUG_CATEGORY_STATIC (debug_dataflow);
+GST_DEBUG_CATEGORY_STATIC (debug_scheduler);
#define GST_CAT_DEFAULT debug_scheduler
typedef struct _GstSchedulerChain GstSchedulerChain;
# define _SCHEDULER_NAME "basic"
#endif
-struct _GstSchedulerChain {
+struct _GstSchedulerChain
+{
GstBasicScheduler *sched;
GList *disabled;
#define SCHED(element) GST_BASIC_SCHEDULER (GST_ELEMENT_SCHED (element))
-typedef enum {
+typedef enum
+{
GST_BASIC_SCHEDULER_STATE_NONE,
GST_BASIC_SCHEDULER_STATE_STOPPED,
GST_BASIC_SCHEDULER_STATE_ERROR,
GST_BASIC_SCHEDULER_STATE_RUNNING,
} GstBasicSchedulerState;
-typedef enum {
+typedef enum
+{
/* something important has changed inside the scheduler */
- GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST,
+ GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST,
} GstBasicSchedulerFlags;
-struct _GstBasicScheduler {
+struct _GstBasicScheduler
+{
GstScheduler parent;
GList *elements;
gint num_chains;
GstBasicSchedulerState state;
-
+
cothread_context *context;
GstElement *current;
};
-struct _GstBasicSchedulerClass {
+struct _GstBasicSchedulerClass
+{
GstSchedulerClass parent_class;
};
static GType _gst_basic_scheduler_type = 0;
-static void gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass);
-static void gst_basic_scheduler_init (GstBasicScheduler * scheduler);
-
-static void gst_basic_scheduler_dispose (GObject *object);
-
-static void gst_basic_scheduler_setup (GstScheduler *sched);
-static void gst_basic_scheduler_reset (GstScheduler *sched);
-static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element);
-static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element);
-static GstElementStateReturn
- gst_basic_scheduler_state_transition (GstScheduler *sched, GstElement *element,
- gint transition);
-static void gst_basic_scheduler_lock_element (GstScheduler *sched, GstElement *element);
-static void gst_basic_scheduler_unlock_element (GstScheduler *sched, GstElement *element);
-static gboolean gst_basic_scheduler_yield (GstScheduler *sched, GstElement *element);
-static gboolean gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element);
-static void gst_basic_scheduler_error (GstScheduler *sched, GstElement *element);
-static void gst_basic_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad,
- GstPad *sinkpad);
-static void gst_basic_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad,
- GstPad *sinkpad);
-static void gst_basic_scheduler_pad_select (GstScheduler *sched, GList *padlist);
-static GstSchedulerState
- gst_basic_scheduler_iterate (GstScheduler *sched);
-
-static void gst_basic_scheduler_show (GstScheduler *sched);
+static void gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass);
+static void gst_basic_scheduler_init (GstBasicScheduler * scheduler);
+
+static void gst_basic_scheduler_dispose (GObject * object);
+
+static void gst_basic_scheduler_setup (GstScheduler * sched);
+static void gst_basic_scheduler_reset (GstScheduler * sched);
+static void gst_basic_scheduler_add_element (GstScheduler * sched,
+ GstElement * element);
+static void gst_basic_scheduler_remove_element (GstScheduler * sched,
+ GstElement * element);
+static GstElementStateReturn gst_basic_scheduler_state_transition (GstScheduler
+ * sched, GstElement * element, gint transition);
+static void gst_basic_scheduler_lock_element (GstScheduler * sched,
+ GstElement * element);
+static void gst_basic_scheduler_unlock_element (GstScheduler * sched,
+ GstElement * element);
+static gboolean gst_basic_scheduler_yield (GstScheduler * sched,
+ GstElement * element);
+static gboolean gst_basic_scheduler_interrupt (GstScheduler * sched,
+ GstElement * element);
+static void gst_basic_scheduler_error (GstScheduler * sched,
+ GstElement * element);
+static void gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad);
+static void gst_basic_scheduler_pad_unlink (GstScheduler * sched,
+ GstPad * srcpad, GstPad * sinkpad);
+static void gst_basic_scheduler_pad_select (GstScheduler * sched,
+ GList * padlist);
+static GstSchedulerState gst_basic_scheduler_iterate (GstScheduler * sched);
+
+static void gst_basic_scheduler_show (GstScheduler * sched);
static GstSchedulerClass *parent_class = NULL;
NULL
};
- _gst_basic_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, "Gst"COTHREADS_NAME_CAPITAL"Scheduler", &scheduler_info, 0);
+ _gst_basic_scheduler_type =
+ g_type_register_static (GST_TYPE_SCHEDULER,
+ "Gst" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0);
}
return _gst_basic_scheduler_type;
}
GstObjectClass *gstobject_class;
GstSchedulerClass *gstscheduler_class;
- gobject_class = (GObjectClass*)klass;
- gstobject_class = (GstObjectClass*)klass;
- gstscheduler_class = (GstSchedulerClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstscheduler_class = (GstSchedulerClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_SCHEDULER);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
-
- gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
- gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
- gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
- gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element);
- gstscheduler_class->state_transition = GST_DEBUG_FUNCPTR (gst_basic_scheduler_state_transition);
- gstscheduler_class->lock_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_lock_element);
- gstscheduler_class->unlock_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_unlock_element);
- gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_basic_scheduler_yield);
- gstscheduler_class->interrupt = GST_DEBUG_FUNCPTR (gst_basic_scheduler_interrupt);
- gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_basic_scheduler_error);
- gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_link);
- gstscheduler_class->pad_unlink = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_unlink);
- gstscheduler_class->pad_select = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_select);
- gstscheduler_class->clock_wait = NULL;
- gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_basic_scheduler_iterate);
-
- gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_basic_scheduler_show);
-
- do_cothreads_init(NULL);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose);
+
+ gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup);
+ gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset);
+ gstscheduler_class->add_element =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element);
+ gstscheduler_class->remove_element =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element);
+ gstscheduler_class->state_transition =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_state_transition);
+ gstscheduler_class->lock_element =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_lock_element);
+ gstscheduler_class->unlock_element =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_unlock_element);
+ gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_basic_scheduler_yield);
+ gstscheduler_class->interrupt =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_interrupt);
+ gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_basic_scheduler_error);
+ gstscheduler_class->pad_link =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_link);
+ gstscheduler_class->pad_unlink =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_unlink);
+ gstscheduler_class->pad_select =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_select);
+ gstscheduler_class->clock_wait = NULL;
+ gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_basic_scheduler_iterate);
+
+ gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_basic_scheduler_show);
+
+ do_cothreads_init (NULL);
}
static void
-gst_basic_scheduler_init (GstBasicScheduler *scheduler)
+gst_basic_scheduler_init (GstBasicScheduler * scheduler)
{
scheduler->elements = NULL;
scheduler->num_elements = 0;
}
static void
-gst_basic_scheduler_dispose (GObject *object)
+gst_basic_scheduler_dispose (GObject * object)
{
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GstSchedulerFactory *factory;
- GST_DEBUG_CATEGORY_INIT (debug_dataflow, "dataflow", 0, "basic scheduler dataflow");
- GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, "basic scheduler general information");
+ GST_DEBUG_CATEGORY_INIT (debug_dataflow, "dataflow", 0,
+ "basic scheduler dataflow");
+ GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0,
+ "basic scheduler general information");
- factory = gst_scheduler_factory_new ("basic"COTHREADS_NAME,
- "A basic scheduler using "COTHREADS_NAME" cothreads",
- gst_basic_scheduler_get_type());
+ factory = gst_scheduler_factory_new ("basic" COTHREADS_NAME,
+ "A basic scheduler using " COTHREADS_NAME " cothreads",
+ gst_basic_scheduler_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
} else {
- g_warning ("could not register scheduler: "COTHREADS_NAME);
+ g_warning ("could not register scheduler: " COTHREADS_NAME);
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstbasic"COTHREADS_NAME"scheduler",
- "a basic scheduler using "COTHREADS_NAME" cothreads",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstbasic" COTHREADS_NAME "scheduler",
+ "a basic scheduler using " COTHREADS_NAME " cothreads",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
-static int
-gst_basic_scheduler_loopfunc_wrapper (int argc, char **argv)
+ static int gst_basic_scheduler_loopfunc_wrapper (int argc, char **argv)
{
GstElement *element = GST_ELEMENT (argv);
G_GNUC_UNUSED const gchar *name = GST_ELEMENT_NAME (element);
- GST_DEBUG("entering loopfunc wrapper of %s", name);
+ GST_DEBUG ("entering loopfunc wrapper of %s", name);
gst_object_ref (GST_OBJECT (element));
do {
GST_CAT_DEBUG (debug_dataflow, "calling loopfunc %s for element %s",
- GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name);
+ GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name);
(element->loopfunc) (element);
GST_CAT_DEBUG (debug_dataflow, "element %s ended loop function", name);
SCHED (element)->current = NULL;
}
- GST_DEBUG("leaving loopfunc wrapper of %s", name);
+ GST_DEBUG ("leaving loopfunc wrapper of %s", name);
gst_object_unref (GST_OBJECT (element));
return 0;
gst_object_ref (GST_OBJECT (element));
do {
GList *pads;
+
do {
pads = element->pads;
realpad = GST_REAL_PAD (pad);
- if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK &&
- GST_PAD_IS_LINKED (realpad) &&
+ if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK &&
+ GST_PAD_IS_LINKED (realpad) &&
g_slist_find (already_iterated, pad) == NULL) {
GstData *data;
- GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name,
- GST_PAD_NAME (pad));
+ GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name,
+ GST_PAD_NAME (pad));
data = gst_pad_pull (pad);
if (data) {
if (GST_IS_EVENT (data) && !GST_ELEMENT_IS_EVENT_AWARE (element)) {
gst_pad_send_event (pad, GST_EVENT (data));
- }
- else {
- GST_CAT_DEBUG (debug_dataflow, "calling chain function of %s:%s %p",
- name, GST_PAD_NAME (pad), data);
+ } else {
+ GST_CAT_DEBUG (debug_dataflow,
+ "calling chain function of %s:%s %p", name,
+ GST_PAD_NAME (pad), data);
GST_RPAD_CHAINFUNC (realpad) (pad, data);
- GST_CAT_DEBUG (debug_dataflow,
- "calling chain function of element %s done", name);
+ GST_CAT_DEBUG (debug_dataflow,
+ "calling chain function of element %s done", name);
}
}
already_iterated = g_slist_prepend (already_iterated, pad);
realpad = GST_REAL_PAD (pads->data);
pads = g_list_next (pads);
- if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC && GST_PAD_IS_USABLE (realpad)) {
- GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s", GST_DEBUG_PAD_NAME (realpad));
+ if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC
+ && GST_PAD_IS_USABLE (realpad)) {
+ GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s",
+ GST_DEBUG_PAD_NAME (realpad));
g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0);
data = GST_RPAD_GETFUNC (realpad) (GST_PAD (realpad));
if (data) {
GST_CAT_DEBUG (debug_dataflow, "calling gst_pad_push on pad %s:%s %p",
- GST_DEBUG_PAD_NAME (realpad), data);
+ GST_DEBUG_PAD_NAME (realpad), data);
gst_pad_push (GST_PAD (realpad), data);
}
}
peer = GST_RPAD_PEER (pad);
GST_DEBUG ("entered chainhandler proxy of %s:%s", GST_DEBUG_PAD_NAME (pad));
- GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer \"%s:%s\"'s pen", data,
- GST_DEBUG_PAD_NAME (peer));
+ GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer \"%s:%s\"'s pen",
+ data, GST_DEBUG_PAD_NAME (peer));
/*
* loop until the bufferpen is empty so we can fill it up again
*/
while (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) != NULL && --loop_count) {
GST_CAT_DEBUG (debug_dataflow, "switching to %p to empty bufpen %d",
- GST_ELEMENT_THREADSTATE (parent), loop_count);
+ GST_ELEMENT_THREADSTATE (parent), loop_count);
do_element_switch (parent);
if (loop_count == 0) {
GST_ELEMENT_ERROR (parent, CORE, SCHEDULER, (NULL),
- ("(internal error) basic: maximum number of switches exceeded"));
+ ("(internal error) basic: maximum number of switches exceeded"));
return;
}
/* now fill the bufferpen and switch so it can be consumed */
GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = data;
GST_CAT_DEBUG (debug_dataflow, "switching to %p to consume buffer %p",
- GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), data);
+ GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), data);
do_element_switch (parent);
gst_basic_scheduler_select_proxy (GstPad * pad, GstData * data)
{
GstElement *parent;
-
+
parent = GST_PAD_PARENT (pad);
- GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer's pen of pad %s:%s",
- data, GST_DEBUG_PAD_NAME (pad));
+ GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer's pen of pad %s:%s",
+ data, GST_DEBUG_PAD_NAME (pad));
g_assert (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) == NULL);
/* now fill the bufferpen and switch so it can be consumed */
GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = data;
GST_CAT_DEBUG (debug_dataflow, "switching to %p",
- GST_ELEMENT_THREADSTATE (parent));
+ GST_ELEMENT_THREADSTATE (parent));
/* FIXME temporarily diabled */
/* parent->select_pad = pad; */
do_element_switch (parent);
-
+
GST_CAT_DEBUG (debug_dataflow, "done switching");
}
while (GST_RPAD_BUFPEN (pad) == NULL) {
GST_CAT_DEBUG (debug_dataflow, "switching to \"%s\": %p to fill bufpen",
- GST_ELEMENT_NAME (parent),
- GST_ELEMENT_THREADSTATE (parent));
+ GST_ELEMENT_NAME (parent), GST_ELEMENT_THREADSTATE (parent));
do_element_switch (parent);
}
static gboolean
-gst_basic_scheduler_eventhandler_proxy (GstPad *srcpad, GstEvent *event)
+gst_basic_scheduler_eventhandler_proxy (GstPad * srcpad, GstEvent * event)
{
gboolean flush;
GST_INFO ("intercepting event %d on pad %s:%s",
- GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad));
+ GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad));
/* figure out if we need to flush */
switch (GST_EVENT_TYPE (event)) {
if (data) {
GST_INFO ("need to clear some buffers");
-
+
gst_data_unref (data);
GST_RPAD_BUFPEN (srcpad) = NULL;
}
/* if the element has a loopfunc... */
if (element->loopfunc != NULL) {
- wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper);
- GST_DEBUG ("element '%s' is a loop-based",
- GST_ELEMENT_NAME (element));
- }
- else {
+ wrapper_function =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper);
+ GST_DEBUG ("element '%s' is a loop-based", GST_ELEMENT_NAME (element));
+ } else {
/* otherwise we need to decide what kind of cothread
* if it's not DECOUPLED, we decide based on
* whether it's a source or not */
if (!decoupled) {
/* if it doesn't have any sinks, it must be a source (duh) */
if (element->numsinkpads == 0) {
- wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper);
+ wrapper_function =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper);
GST_DEBUG ("element '%s' is a source, using _src_wrapper",
- GST_ELEMENT_NAME (element));
- }
- else {
- wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper);
+ GST_ELEMENT_NAME (element));
+ } else {
+ wrapper_function =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper);
GST_DEBUG ("element '%s' is a filter, using _chain_wrapper",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
}
}
}
if (!GST_IS_REAL_PAD (pad))
continue;
-
+
peerpad = GST_PAD_PEER (pad);
if (peerpad) {
GstElement *peerelement = GST_ELEMENT (GST_PAD_PARENT (peerpad));
- gboolean different_sched = (peerelement->sched != GST_SCHEDULER (chain->sched));
- gboolean peer_decoupled = GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED);
+ gboolean different_sched =
+ (peerelement->sched != GST_SCHEDULER (chain->sched));
+ gboolean peer_decoupled =
+ GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED);
- GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad));
+ GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad));
/* we don't need to check this for decoupled elements */
if (!decoupled) {
/* if the peer element is in another schedule,
* it's not decoupled and we are not decoupled
* either, we have an error */
- if (different_sched && !peer_decoupled)
- {
- GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL),
- ("element \"%s\" is not decoupled but has pads in different schedulers",
- GST_ELEMENT_NAME (element)));
+ if (different_sched && !peer_decoupled) {
+ GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL),
+ ("element \"%s\" is not decoupled but has pads in different schedulers",
+ GST_ELEMENT_NAME (element)));
return FALSE;
}
/* ok, the peer is in a different scheduler and is decoupled,
else if (different_sched) {
if (GST_RPAD_DIRECTION (peerpad) == GST_PAD_SINK) {
GST_DEBUG ("copying chain func into push proxy for peer %s:%s",
- GST_DEBUG_PAD_NAME (peerpad));
+ GST_DEBUG_PAD_NAME (peerpad));
GST_RPAD_CHAINHANDLER (peerpad) = GST_RPAD_CHAINFUNC (peerpad);
- }
- else {
+ } else {
GST_DEBUG ("copying get func into pull proxy for peer %s:%s",
- GST_DEBUG_PAD_NAME (peerpad));
+ GST_DEBUG_PAD_NAME (peerpad));
GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad);
}
}
/* set the chain proxies */
if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) {
GST_DEBUG ("copying chain function into push proxy for %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad);
- }
- else {
+ } else {
GST_DEBUG ("copying get function into pull proxy for %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETFUNC (pad);
}
}
else {
if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) {
GST_DEBUG ("setting cothreaded push proxy for sinkpad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
- GST_RPAD_CHAINHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy);
- GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad);
- }
- else {
+ GST_DEBUG_PAD_NAME (pad));
+ GST_RPAD_CHAINHANDLER (pad) =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy);
+ GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad);
+ } else {
GST_DEBUG ("setting cothreaded pull proxy for srcpad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
- GST_RPAD_GETHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy);
+ GST_DEBUG_PAD_NAME (pad));
+ GST_RPAD_GETHANDLER (pad) =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy);
/* the gethandler proxy function can queue a buffer in the bufpen, we need
* to remove this buffer when a flush event is sent on the pad */
- GST_RPAD_EVENTHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy);
+ GST_RPAD_EVENTHANDLER (pad) =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy);
}
}
}
if (wrapper_function != NULL) {
if (GST_ELEMENT_THREADSTATE (element) == NULL) {
GST_DEBUG ("about to create a cothread, wrapper for '%s' is &%s",
- GST_ELEMENT_NAME (element),
- GST_DEBUG_FUNCPTR_NAME (wrapper_function));
- do_cothread_create (GST_ELEMENT_THREADSTATE (element),
- chain->sched->context,
- wrapper_function, 0, (char **) element);
+ GST_ELEMENT_NAME (element),
+ GST_DEBUG_FUNCPTR_NAME (wrapper_function));
+ do_cothread_create (GST_ELEMENT_THREADSTATE (element),
+ chain->sched->context, wrapper_function, 0, (char **) element);
if (GST_ELEMENT_THREADSTATE (element) == NULL) {
- GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL), ("could not create cothread for \"%s\"",
- GST_ELEMENT_NAME (element)));
+ GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL),
+ ("could not create cothread for \"%s\"",
+ GST_ELEMENT_NAME (element)));
return FALSE;
}
- GST_DEBUG ("created cothread %p for '%s'",
- GST_ELEMENT_THREADSTATE (element),
- GST_ELEMENT_NAME (element));
+ GST_DEBUG ("created cothread %p for '%s'",
+ GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element));
} else {
/* set the cothread wrapper function */
GST_DEBUG ("about to set the wrapper function for '%s' to &%s",
- GST_ELEMENT_NAME (element),
- GST_DEBUG_FUNCPTR_NAME (wrapper_function));
- do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element),
- chain->sched->context,
- wrapper_function, 0, (char **) element);
+ GST_ELEMENT_NAME (element),
+ GST_DEBUG_FUNCPTR_NAME (wrapper_function));
+ do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element),
+ chain->sched->context, wrapper_function, 0, (char **) element);
GST_DEBUG ("set wrapper function for '%s' to &%s",
- GST_ELEMENT_NAME (element),
- GST_DEBUG_FUNCPTR_NAME (wrapper_function));
+ GST_ELEMENT_NAME (element),
+ GST_DEBUG_FUNCPTR_NAME (wrapper_function));
}
}
}
sched->num_chains++;
/* notify the scheduler that something changed */
- GST_FLAG_SET(sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (sched, GST_BASIC_SCHEDULER_CHANGE);
GST_INFO ("created new chain %p, now are %d chains in sched %p",
- chain, sched->num_chains, sched);
+ chain, sched->num_chains, sched);
return chain;
}
/* destroy the chain */
g_list_free (chain->disabled); /* should be empty... */
- g_list_free (chain->elements); /* ditto */
+ g_list_free (chain->elements); /* ditto */
GST_INFO ("destroyed chain %p, now are %d chains in sched %p", chain,
- sched->num_chains, sched);
+ sched->num_chains, sched);
g_free (chain);
/* notify the scheduler that something changed */
- GST_FLAG_SET(sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (sched, GST_BASIC_SCHEDULER_CHANGE);
}
static void
-gst_basic_scheduler_chain_add_element (GstSchedulerChain * chain, GstElement * element)
+gst_basic_scheduler_chain_add_element (GstSchedulerChain * chain,
+ GstElement * element)
{
/* set the sched pointer for the element */
element->sched = GST_SCHEDULER (chain->sched);
/* add the element to either the main list or the disabled list */
- if (GST_STATE(element) == GST_STATE_PLAYING) {
- GST_INFO ("adding element \"%s\" to chain %p enabled", GST_ELEMENT_NAME (element),chain);
+ if (GST_STATE (element) == GST_STATE_PLAYING) {
+ GST_INFO ("adding element \"%s\" to chain %p enabled",
+ GST_ELEMENT_NAME (element), chain);
chain->elements = g_list_prepend (chain->elements, element);
} else {
- GST_INFO ("adding element \"%s\" to chain %p disabled", GST_ELEMENT_NAME (element),chain);
+ GST_INFO ("adding element \"%s\" to chain %p disabled",
+ GST_ELEMENT_NAME (element), chain);
chain->disabled = g_list_prepend (chain->disabled, element);
}
chain->num_elements++;
/* notify the scheduler that something changed */
- GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE);
}
static gboolean
-gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain,
- GstElement * element)
+gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain,
+ GstElement * element)
{
- GST_INFO ("enabling element \"%s\" in chain %p",
- GST_ELEMENT_NAME (element), chain);
+ GST_INFO ("enabling element \"%s\" in chain %p",
+ GST_ELEMENT_NAME (element), chain);
/* remove from disabled list */
chain->disabled = g_list_remove (chain->disabled, element);
chain->elements = g_list_prepend (chain->elements, element);
/* notify the scheduler that something changed */
- GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE);
/* GST_FLAG_UNSET(element, GST_ELEMENT_COTHREAD_STOPPING); */
/* reschedule the chain */
- return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain->sched)->parent), chain);
+ return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain->
+ sched)->parent), chain);
}
static void
-gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain,
- GstElement * element)
+gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain,
+ GstElement * element)
{
- GST_INFO ("disabling element \"%s\" in chain %p",
- GST_ELEMENT_NAME (element), chain);
+ GST_INFO ("disabling element \"%s\" in chain %p",
+ GST_ELEMENT_NAME (element), chain);
/* remove from elements list */
chain->elements = g_list_remove (chain->elements, element);
chain->disabled = g_list_prepend (chain->disabled, element);
/* notify the scheduler that something changed */
- GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE);
- GST_FLAG_SET(element, GST_ELEMENT_COTHREAD_STOPPING);
+ GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING);
/* reschedule the chain */
/* FIXME this should be done only if manager state != NULL */
}
static void
-gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain, GstElement * element)
+gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain,
+ GstElement * element)
{
GST_INFO ("removing element \"%s\" from chain %p", GST_ELEMENT_NAME (element),
- chain);
+ chain);
/* if it's active, deactivate it */
if (g_list_find (chain->elements, element)) {
chain->num_elements--;
/* notify the scheduler that something changed */
- GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE);
+ GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE);
/* if there are no more elements in the chain, destroy the chain */
if (chain->num_elements == 0)
}
static void
-gst_basic_scheduler_chain_elements (GstBasicScheduler * sched, GstElement * element1, GstElement * element2)
+gst_basic_scheduler_chain_elements (GstBasicScheduler * sched,
+ GstElement * element1, GstElement * element2)
{
GList *chains;
GstSchedulerChain *chain;
/* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */
/* otherwise if both have chains already, join them */
- }
- else if ((chain1 != NULL) && (chain2 != NULL)) {
+ } else if ((chain1 != NULL) && (chain2 != NULL)) {
GST_INFO ("merging chain %p into chain %p", chain2, chain1);
/* take the contents of chain2 and merge them into chain1 */
- chain1->disabled = g_list_concat (chain1->disabled, g_list_copy (chain2->disabled));
- chain1->elements = g_list_concat (chain1->elements, g_list_copy (chain2->elements));
+ chain1->disabled =
+ g_list_concat (chain1->disabled, g_list_copy (chain2->disabled));
+ chain1->elements =
+ g_list_concat (chain1->elements, g_list_copy (chain2->elements));
chain1->num_elements += chain2->num_elements;
/* FIXME chain changed here */
/* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */
gst_basic_scheduler_chain_destroy (chain2);
/* otherwise one has a chain already, the other doesn't */
- }
- else {
+ } else {
/* pick out which one has the chain, and which doesn't */
if (chain1 != NULL)
chain = chain1, element = element2;
GstSchedulerChain *chain;
GST_INFO ("searching for element \"%s\" in chains",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
chains = sched->chains;
while (chains) {
}
static void
-gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * element, gboolean remove)
+gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain,
+ GstElement * element, gboolean remove)
{
GList *pads;
GstPad *pad;
pads = g_list_next (pads);
GST_DEBUG ("have pad %s:%s, checking for valid peer",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
/* if the peer exists and could be in the same chain */
if (GST_PAD_PEER (pad)) {
GST_DEBUG ("has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad)));
peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad));
- if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == GST_ELEMENT_SCHED (peerelement)) {
- GST_DEBUG ("peer \"%s\" is valid for same chain",
- GST_ELEMENT_NAME (peerelement));
- gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove);
+ if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) ==
+ GST_ELEMENT_SCHED (peerelement)) {
+ GST_DEBUG ("peer \"%s\" is valid for same chain",
+ GST_ELEMENT_NAME (peerelement));
+ gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove);
}
}
}
* Entry points for this scheduler.
*/
static void
-gst_basic_scheduler_setup (GstScheduler *sched)
+gst_basic_scheduler_setup (GstScheduler * sched)
{
/* first create thread context */
if (GST_BASIC_SCHEDULER (sched)->context == NULL) {
}
static void
-gst_basic_scheduler_reset (GstScheduler *sched)
+gst_basic_scheduler_reset (GstScheduler * sched)
{
cothread_context *ctx;
GList *elements = GST_BASIC_SCHEDULER (sched)->elements;
while (elements) {
GstElement *element = GST_ELEMENT (elements->data);
+
if (GST_ELEMENT_THREADSTATE (element)) {
do_cothread_destroy (GST_ELEMENT_THREADSTATE (element));
GST_ELEMENT_THREADSTATE (element) = NULL;
}
elements = g_list_next (elements);
}
-
+
ctx = GST_BASIC_SCHEDULER (sched)->context;
do_cothread_context_destroy (ctx);
-
+
GST_BASIC_SCHEDULER (sched)->context = NULL;
}
/* only deal with elements after this point, not bins */
/* exception is made for Bin's that are schedulable, like the autoplugger */
- if (GST_IS_BIN (element) && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE))
+ if (GST_IS_BIN (element)
+ && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE))
return;
/* first add it to the list of elements that are to be scheduled */
if (g_list_find (bsched->elements, element)) {
GST_INFO ("removing element \"%s\" from scheduler",
- GST_ELEMENT_NAME (element));
+ GST_ELEMENT_NAME (element));
/* if we are removing the currently scheduled element */
if (bsched->current == element) {
- GST_FLAG_SET(element, GST_ELEMENT_COTHREAD_STOPPING);
- if (element->post_run_func)
- element->post_run_func (element);
- bsched->current = NULL;
+ GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING);
+ if (element->post_run_func)
+ element->post_run_func (element);
+ bsched->current = NULL;
}
/* find what chain the element is in */
chain = gst_basic_scheduler_find_chain (bsched, element);
if (chain != NULL) {
gst_basic_scheduler_chain_remove_element (chain, element);
}
-
+
/* remove it from the list of elements */
bsched->elements = g_list_remove (bsched->elements, element);
bsched->num_elements--;
}
static GstElementStateReturn
-gst_basic_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition)
+gst_basic_scheduler_state_transition (GstScheduler * sched,
+ GstElement * element, gint transition)
{
GstSchedulerChain *chain;
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
if (transition == GST_STATE_PLAYING_TO_PAUSED) {
GST_INFO ("setting scheduler state to stopped");
GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED;
- }
- else if (transition == GST_STATE_PAUSED_TO_PLAYING) {
+ } else if (transition == GST_STATE_PAUSED_TO_PLAYING) {
GST_INFO ("setting scheduler state to running");
GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING;
- }
- else {
+ } else {
GST_INFO ("no interesting state change, doing nothing");
}
- }
- else if (transition == GST_STATE_PLAYING_TO_PAUSED ||
- transition == GST_STATE_PAUSED_TO_PLAYING) {
+ } else if (transition == GST_STATE_PLAYING_TO_PAUSED ||
+ transition == GST_STATE_PAUSED_TO_PLAYING) {
/* find the chain the element is in */
chain = gst_basic_scheduler_find_chain (bsched, element);
/* remove it from the chain */
if (chain) {
if (transition == GST_STATE_PLAYING_TO_PAUSED) {
- gst_basic_scheduler_chain_disable_element (chain, element);
- }
- else if (transition == GST_STATE_PAUSED_TO_PLAYING) {
- if (!gst_basic_scheduler_chain_enable_element (chain, element)) {
- GST_INFO ("could not enable element \"%s\"",
- GST_ELEMENT_NAME (element));
- return GST_STATE_FAILURE;
- }
+ gst_basic_scheduler_chain_disable_element (chain, element);
+ } else if (transition == GST_STATE_PAUSED_TO_PLAYING) {
+ if (!gst_basic_scheduler_chain_enable_element (chain, element)) {
+ GST_INFO ("could not enable element \"%s\"",
+ GST_ELEMENT_NAME (element));
+ return GST_STATE_FAILURE;
+ }
}
- }
- else {
- GST_INFO ("element \"%s\" not found in any chain, no state change",
- GST_ELEMENT_NAME (element));
+ } else {
+ GST_INFO ("element \"%s\" not found in any chain, no state change",
+ GST_ELEMENT_NAME (element));
}
}
}
static gboolean
-gst_basic_scheduler_yield (GstScheduler *sched, GstElement *element)
+gst_basic_scheduler_yield (GstScheduler * sched, GstElement * element)
{
if (GST_ELEMENT_IS_COTHREAD_STOPPING (element)) {
do_switch_to_main (sched);
-
+
/* no need to do a pre_run, the cothread is stopping */
}
return FALSE;
}
static gboolean
-gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element)
+gst_basic_scheduler_interrupt (GstScheduler * sched, GstElement * element)
{
GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING);
}
static void
-gst_basic_scheduler_error (GstScheduler *sched, GstElement *element)
+gst_basic_scheduler_error (GstScheduler * sched, GstElement * element)
{
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
if (GST_ELEMENT_THREADSTATE (element)) {
GstSchedulerChain *chain;
-
+
chain = gst_basic_scheduler_find_chain (bsched, element);
if (chain)
gst_basic_scheduler_chain_disable_element (chain, element);
}
static void
-gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad *srcpad, GstPad *sinkpad)
+gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad)
{
GstElement *srcelement, *sinkelement;
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
g_return_if_fail (sinkelement != NULL);
GST_INFO ("have pad linked callback on %s:%s to %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
GST_DEBUG ("srcpad sched is %p, sinkpad sched is %p",
- GST_ELEMENT_SCHED (srcelement), GST_ELEMENT_SCHED (sinkelement));
+ GST_ELEMENT_SCHED (srcelement), GST_ELEMENT_SCHED (sinkelement));
if (GST_ELEMENT_SCHED (srcelement) == GST_ELEMENT_SCHED (sinkelement)) {
GST_INFO ("peer %s:%s is in same scheduler, chaining together",
- GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (sinkpad));
gst_basic_scheduler_chain_elements (bsched, srcelement, sinkelement);
}
}
static void
-gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad)
+gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad)
{
GstElement *element1, *element2;
GstSchedulerChain *chain1, *chain2;
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
GST_INFO ("unlinking pads %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
/* we need to have the parent elements of each pad */
element1 = GST_ELEMENT (GST_PAD_PARENT (srcpad));
chain2 = gst_basic_scheduler_chain_new (bsched);
gst_basic_scheduler_chain_recursive_add (chain2, element2, FALSE);
}
-
#else
/* if they're both in the same chain, move second set of elements to a new chain */
while (padlist) {
pad = GST_PAD (padlist->data);
- GST_RPAD_CHAINHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy);
+ GST_RPAD_CHAINHANDLER (pad) =
+ GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy);
padlist = g_list_next (padlist);
}
do_element_switch (GST_PAD_PARENT (peer));
/* FIXME disabled for now */
- /* pad = GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad;*/
+ /* pad = GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad; */
g_assert (pad != NULL);
}
gint scheduled = 0;
GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched);
- GST_CAT_LOG_OBJECT (debug_dataflow, sched,
- "starting iteration in bin %s",
- GST_ELEMENT_NAME (sched->parent));
+ GST_CAT_LOG_OBJECT (debug_dataflow, sched,
+ "starting iteration in bin %s", GST_ELEMENT_NAME (sched->parent));
/* clear the changes flag */
- GST_FLAG_UNSET(bsched, GST_BASIC_SCHEDULER_CHANGE);
-
+ GST_FLAG_UNSET (bsched, GST_BASIC_SCHEDULER_CHANGE);
+
/* step through all the chains */
chains = bsched->chains;
chain = (GstSchedulerChain *) (chains->data);
chains = g_list_next (chains);
- /* all we really have to do is switch to the first child */
+ /* all we really have to do is switch to the first child */
/* FIXME this should be lots more intelligent about where to start */
- GST_CAT_DEBUG (debug_dataflow, "starting iteration via cothreads using %s scheduler",
- _SCHEDULER_NAME);
+ GST_CAT_DEBUG (debug_dataflow,
+ "starting iteration via cothreads using %s scheduler", _SCHEDULER_NAME);
if (chain->elements) {
- entry = NULL; /*MattH ADDED?*/
+ entry = NULL; /*MattH ADDED? */
GST_DEBUG ("there are %d elements in this chain", chain->num_elements);
elements = chain->elements;
while (elements) {
elements = g_list_next (elements);
if (GST_FLAG_IS_SET (entry, GST_ELEMENT_DECOUPLED)) {
GST_DEBUG ("entry \"%s\" is DECOUPLED, skipping",
- GST_ELEMENT_NAME (entry));
+ GST_ELEMENT_NAME (entry));
entry = NULL;
- }
- else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) {
+ } else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) {
GST_DEBUG ("entry \"%s\" is not valid, skipping",
- GST_ELEMENT_NAME (entry));
+ GST_ELEMENT_NAME (entry));
entry = NULL;
- }
- else
+ } else
break;
}
if (entry) {
GstSchedulerState state;
-
+
GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING);
- GST_CAT_DEBUG (debug_dataflow, "set COTHREAD_STOPPING flag on \"%s\"(@%p)",
- GST_ELEMENT_NAME (entry), entry);
+ GST_CAT_DEBUG (debug_dataflow,
+ "set COTHREAD_STOPPING flag on \"%s\"(@%p)",
+ GST_ELEMENT_NAME (entry), entry);
if (GST_ELEMENT_THREADSTATE (entry)) {
- do_switch_from_main (entry);
+ do_switch_from_main (entry);
state = GST_SCHEDULER_STATE (sched);
/* if something changed, return - go on else */
- if (GST_FLAG_IS_SET(bsched, GST_BASIC_SCHEDULER_CHANGE) &&
+ if (GST_FLAG_IS_SET (bsched, GST_BASIC_SCHEDULER_CHANGE) &&
state != GST_SCHEDULER_STATE_ERROR)
return GST_SCHEDULER_STATE_RUNNING;
- }
- else {
- GST_CAT_DEBUG (debug_dataflow, "cothread switch not possible, element has no threadstate");
+ } else {
+ GST_CAT_DEBUG (debug_dataflow,
+ "cothread switch not possible, element has no threadstate");
return GST_SCHEDULER_STATE_ERROR;
}
GST_CAT_DEBUG (debug_dataflow, "cothread switch ended or interrupted");
if (state != GST_SCHEDULER_STATE_RUNNING) {
- GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d", state);
+ GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d",
+ state);
return state;
}
scheduled++;
+ } else {
+ GST_CAT_INFO (debug_dataflow,
+ "no entry in this chain, trying the next one");
}
- else {
- GST_CAT_INFO (debug_dataflow, "no entry in this chain, trying the next one");
- }
- }
- else {
- GST_CAT_INFO (debug_dataflow, "no enabled elements in this chain, trying the next one");
+ } else {
+ GST_CAT_INFO (debug_dataflow,
+ "no enabled elements in this chain, trying the next one");
}
}
GST_CAT_LOG_OBJECT (debug_dataflow, sched, "leaving (%s)",
- GST_ELEMENT_NAME (sched->parent));
+ GST_ELEMENT_NAME (sched->parent));
if (scheduled == 0) {
GST_CAT_INFO (debug_dataflow, "nothing was scheduled, return STOPPED");
return GST_SCHEDULER_STATE_STOPPED;
- }
- else {
+ } else {
GST_CAT_INFO (debug_dataflow, "scheduler still running, return RUNNING");
return GST_SCHEDULER_STATE_RUNNING;
}
g_return_if_fail (GST_IS_SCHEDULER (sched));
- g_print ("SCHEDULER DUMP FOR MANAGING BIN \"%s\"\n", GST_ELEMENT_NAME (sched->parent));
+ g_print ("SCHEDULER DUMP FOR MANAGING BIN \"%s\"\n",
+ GST_ELEMENT_NAME (sched->parent));
g_print ("scheduler has %d elements in it: ", bsched->num_elements);
elements = bsched->elements;
#include <gst/gst.h>
-GST_DEBUG_CATEGORY_STATIC(debug_scheduler);
+GST_DEBUG_CATEGORY_STATIC (debug_scheduler);
#define GST_CAT_DEFAULT debug_scheduler
#ifdef USE_COTHREADS
#define GST_IS_OPT_SCHEDULER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPT_SCHEDULER))
-typedef enum {
+typedef enum
+{
GST_OPT_SCHEDULER_STATE_NONE,
GST_OPT_SCHEDULER_STATE_STOPPED,
GST_OPT_SCHEDULER_STATE_ERROR,
GST_OPT_SCHEDULER_STATE_INTERRUPTED
} GstOptSchedulerState;
-struct _GstOptScheduler {
- GstScheduler parent;
+struct _GstOptScheduler
+{
+ GstScheduler parent;
- GstOptSchedulerState state;
+ GstOptSchedulerState state;
#ifdef USE_COTHREADS
- cothread_context *context;
+ cothread_context *context;
#endif
- gint iterations;
+ gint iterations;
- GSList *elements;
- GSList *chains;
+ GSList *elements;
+ GSList *chains;
- GList *runqueue;
- gint recursion;
+ GList *runqueue;
+ gint recursion;
- gint max_recursion;
+ gint max_recursion;
};
-struct _GstOptSchedulerClass {
+struct _GstOptSchedulerClass
+{
GstSchedulerClass parent_class;
};
static GType _gst_opt_scheduler_type = 0;
-typedef enum {
- GST_OPT_SCHEDULER_CHAIN_DIRTY = (1 << 1),
- GST_OPT_SCHEDULER_CHAIN_DISABLED = (1 << 2),
- GST_OPT_SCHEDULER_CHAIN_RUNNING = (1 << 3),
+typedef enum
+{
+ GST_OPT_SCHEDULER_CHAIN_DIRTY = (1 << 1),
+ GST_OPT_SCHEDULER_CHAIN_DISABLED = (1 << 2),
+ GST_OPT_SCHEDULER_CHAIN_RUNNING = (1 << 3),
} GstOptSchedulerChainFlags;
#define GST_OPT_SCHEDULER_CHAIN_DISABLE(chain) ((chain)->flags |= GST_OPT_SCHEDULER_CHAIN_DISABLED)
typedef struct _GstOptSchedulerChain GstOptSchedulerChain;
-struct _GstOptSchedulerChain {
- gint refcount;
-
- GstOptScheduler *sched;
+struct _GstOptSchedulerChain
+{
+ gint refcount;
+
+ GstOptScheduler *sched;
+
+ GstOptSchedulerChainFlags flags;
- GstOptSchedulerChainFlags flags;
-
- GSList *groups; /* the groups in this chain */
- gint num_groups;
- gint num_enabled;
+ GSList *groups; /* the groups in this chain */
+ gint num_groups;
+ gint num_enabled;
};
/*
* elements that are scheduled in one cothread
*/
-typedef enum {
- GST_OPT_SCHEDULER_GROUP_DIRTY = (1 << 1), /* this group has been modified */
- GST_OPT_SCHEDULER_GROUP_COTHREAD_STOPPING = (1 << 2), /* the group's cothread stops after one iteration */
- GST_OPT_SCHEDULER_GROUP_DISABLED = (1 << 3), /* this group is disabled */
- GST_OPT_SCHEDULER_GROUP_RUNNING = (1 << 4), /* this group is running */
- GST_OPT_SCHEDULER_GROUP_SCHEDULABLE = (1 << 5), /* this group is schedulable */
- GST_OPT_SCHEDULER_GROUP_VISITED = (1 << 6), /* this group is visited when finding links */
+typedef enum
+{
+ GST_OPT_SCHEDULER_GROUP_DIRTY = (1 << 1), /* this group has been modified */
+ GST_OPT_SCHEDULER_GROUP_COTHREAD_STOPPING = (1 << 2), /* the group's cothread stops after one iteration */
+ GST_OPT_SCHEDULER_GROUP_DISABLED = (1 << 3), /* this group is disabled */
+ GST_OPT_SCHEDULER_GROUP_RUNNING = (1 << 4), /* this group is running */
+ GST_OPT_SCHEDULER_GROUP_SCHEDULABLE = (1 << 5), /* this group is schedulable */
+ GST_OPT_SCHEDULER_GROUP_VISITED = (1 << 6), /* this group is visited when finding links */
} GstOptSchedulerGroupFlags;
-typedef enum {
- GST_OPT_SCHEDULER_GROUP_GET = 1,
- GST_OPT_SCHEDULER_GROUP_LOOP = 2,
+typedef enum
+{
+ GST_OPT_SCHEDULER_GROUP_GET = 1,
+ GST_OPT_SCHEDULER_GROUP_LOOP = 2,
} GstOptSchedulerGroupType;
#define GST_OPT_SCHEDULER_GROUP_SET_FLAG(group,flag) ((group)->flags |= (flag))
typedef struct _GstOptSchedulerGroupLink GstOptSchedulerGroupLink;
/* used to keep track of links with other groups */
-struct _GstOptSchedulerGroupLink {
- GstOptSchedulerGroup *group1; /* the group we are linked with */
- GstOptSchedulerGroup *group2; /* the group we are linked with */
- gint count; /* the number of links with the group */
+struct _GstOptSchedulerGroupLink
+{
+ GstOptSchedulerGroup *group1; /* the group we are linked with */
+ GstOptSchedulerGroup *group2; /* the group we are linked with */
+ gint count; /* the number of links with the group */
};
#define IS_GROUP_LINK(link, group1, group2) ((link->group1 == group1 && link->group2 == group2) || \
(link->group2 == group1 && link->group1 == group2))
#define OTHER_GROUP_LINK(link, group) (link->group1 == group ? link->group2 : link->group1)
-typedef int (*GroupScheduleFunction) (int argc, char *argv[]);
+typedef int (*GroupScheduleFunction) (int argc, char *argv[]);
-struct _GstOptSchedulerGroup {
- GstOptSchedulerChain *chain; /* the chain this group belongs to */
- GstOptSchedulerGroupFlags flags; /* flags for this group */
- GstOptSchedulerGroupType type; /* flags for this group */
+struct _GstOptSchedulerGroup
+{
+ GstOptSchedulerChain *chain; /* the chain this group belongs to */
+ GstOptSchedulerGroupFlags flags; /* flags for this group */
+ GstOptSchedulerGroupType type; /* flags for this group */
- gint refcount;
+ gint refcount;
- GSList *elements; /* elements of this group */
- gint num_elements;
- gint num_enabled;
- GstElement *entry; /* the group's entry point */
+ GSList *elements; /* elements of this group */
+ gint num_elements;
+ gint num_enabled;
+ GstElement *entry; /* the group's entry point */
- GSList *group_links; /* other groups that are linked with this group */
+ GSList *group_links; /* other groups that are linked with this group */
#ifdef USE_COTHREADS
- cothread *cothread; /* the cothread of this group */
+ cothread *cothread; /* the cothread of this group */
#else
- GroupScheduleFunction schedulefunc;
+ GroupScheduleFunction schedulefunc;
#endif
- int argc;
- char **argv;
+ int argc;
+ char **argv;
};
* A group is a set of elements through which data can flow without switching
* cothreads or without invoking the scheduler's run queue.
*/
-static GstOptSchedulerGroup* ref_group (GstOptSchedulerGroup *group);
-static GstOptSchedulerGroup* unref_group (GstOptSchedulerGroup *group);
-static GstOptSchedulerGroup* create_group (GstOptSchedulerChain *chain,
- GstElement *element,
- GstOptSchedulerGroupType type);
-static void destroy_group (GstOptSchedulerGroup *group);
-static GstOptSchedulerGroup* add_to_group (GstOptSchedulerGroup *group,
- GstElement *element);
-static GstOptSchedulerGroup* remove_from_group (GstOptSchedulerGroup *group,
- GstElement *element);
-static GstOptSchedulerGroup* merge_groups (GstOptSchedulerGroup *group1,
- GstOptSchedulerGroup *group2);
-static void setup_group_scheduler (GstOptScheduler *osched,
- GstOptSchedulerGroup *group);
-static void destroy_group_scheduler (GstOptSchedulerGroup *group);
-static void group_error_handler (GstOptSchedulerGroup *group);
-static void group_element_set_enabled (GstOptSchedulerGroup *group,
- GstElement *element,
- gboolean enabled);
-static gboolean schedule_group (GstOptSchedulerGroup *group);
+static GstOptSchedulerGroup *ref_group (GstOptSchedulerGroup * group);
+static GstOptSchedulerGroup *unref_group (GstOptSchedulerGroup * group);
+static GstOptSchedulerGroup *create_group (GstOptSchedulerChain * chain,
+ GstElement * element, GstOptSchedulerGroupType type);
+static void destroy_group (GstOptSchedulerGroup * group);
+static GstOptSchedulerGroup *add_to_group (GstOptSchedulerGroup * group,
+ GstElement * element);
+static GstOptSchedulerGroup *remove_from_group (GstOptSchedulerGroup * group,
+ GstElement * element);
+static GstOptSchedulerGroup *merge_groups (GstOptSchedulerGroup * group1,
+ GstOptSchedulerGroup * group2);
+static void setup_group_scheduler (GstOptScheduler * osched,
+ GstOptSchedulerGroup * group);
+static void destroy_group_scheduler (GstOptSchedulerGroup * group);
+static void group_error_handler (GstOptSchedulerGroup * group);
+static void group_element_set_enabled (GstOptSchedulerGroup * group,
+ GstElement * element, gboolean enabled);
+static gboolean schedule_group (GstOptSchedulerGroup * group);
/*
* A chain is a set of groups that are linked to each other.
*/
-static void destroy_chain (GstOptSchedulerChain *chain);
-static GstOptSchedulerChain* create_chain (GstOptScheduler *osched);
-static GstOptSchedulerChain* ref_chain (GstOptSchedulerChain *chain);
-static GstOptSchedulerChain* unref_chain (GstOptSchedulerChain *chain);
-static GstOptSchedulerChain* add_to_chain (GstOptSchedulerChain *chain,
- GstOptSchedulerGroup *group);
-static GstOptSchedulerChain* remove_from_chain (GstOptSchedulerChain *chain,
- GstOptSchedulerGroup *group);
-static GstOptSchedulerChain* merge_chains (GstOptSchedulerChain *chain1,
- GstOptSchedulerChain *chain2);
-static void chain_recursively_migrate_group (GstOptSchedulerChain *chain,
- GstOptSchedulerGroup *group);
-static void chain_group_set_enabled (GstOptSchedulerChain *chain,
- GstOptSchedulerGroup *group,
- gboolean enabled);
-static void schedule_chain (GstOptSchedulerChain *chain);
+static void destroy_chain (GstOptSchedulerChain * chain);
+static GstOptSchedulerChain *create_chain (GstOptScheduler * osched);
+static GstOptSchedulerChain *ref_chain (GstOptSchedulerChain * chain);
+static GstOptSchedulerChain *unref_chain (GstOptSchedulerChain * chain);
+static GstOptSchedulerChain *add_to_chain (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group);
+static GstOptSchedulerChain *remove_from_chain (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group);
+static GstOptSchedulerChain *merge_chains (GstOptSchedulerChain * chain1,
+ GstOptSchedulerChain * chain2);
+static void chain_recursively_migrate_group (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group);
+static void chain_group_set_enabled (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group, gboolean enabled);
+static void schedule_chain (GstOptSchedulerChain * chain);
/*
* The schedule functions are the entry points for cothreads, or called directly
* by gst_opt_scheduler_schedule_run_queue
*/
-static int get_group_schedule_function (int argc, char *argv[]);
-static int loop_group_schedule_function (int argc, char *argv[]);
-static int unknown_group_schedule_function (int argc, char *argv[]);
+static int get_group_schedule_function (int argc, char *argv[]);
+static int loop_group_schedule_function (int argc, char *argv[]);
+static int unknown_group_schedule_function (int argc, char *argv[]);
/*
* These wrappers are set on the pads as the chain handler (what happens when
* gst_pad_push is called) or get handler (for gst_pad_pull).
*/
-static void gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstData *data);
-static GstData* gst_opt_scheduler_get_wrapper (GstPad *srcpad);
-static void gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstData *data);
+static void gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data);
+static GstData *gst_opt_scheduler_get_wrapper (GstPad * srcpad);
+static void gst_opt_scheduler_chain_wrapper (GstPad * sinkpad, GstData * data);
/*
* instead of relying on cothreads to do the switch for us.
*/
#ifndef USE_COTHREADS
-static void gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched);
+static void gst_opt_scheduler_schedule_run_queue (GstOptScheduler * osched);
#endif
*/
typedef struct _GstOptSchedulerCtx GstOptSchedulerCtx;
-typedef enum {
- GST_OPT_SCHEDULER_CTX_DISABLED = (1 << 1), /* the element is disabled */
+typedef enum
+{
+ GST_OPT_SCHEDULER_CTX_DISABLED = (1 << 1), /* the element is disabled */
} GstOptSchedulerCtxFlags;
-struct _GstOptSchedulerCtx {
- GstOptSchedulerGroup *group; /* the group this element belongs to */
+struct _GstOptSchedulerCtx
+{
+ GstOptSchedulerGroup *group; /* the group this element belongs to */
- GstOptSchedulerCtxFlags flags; /* flags for this element */
+ GstOptSchedulerCtxFlags flags; /* flags for this element */
};
-
+
/*
* Implementation of GstScheduler
*/
ARG_MAX_RECURSION,
};
-static void gst_opt_scheduler_class_init (GstOptSchedulerClass *klass);
-static void gst_opt_scheduler_init (GstOptScheduler *scheduler);
-
-static void gst_opt_scheduler_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_opt_scheduler_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static void gst_opt_scheduler_dispose (GObject *object);
-
-static void gst_opt_scheduler_setup (GstScheduler *sched);
-static void gst_opt_scheduler_reset (GstScheduler *sched);
-static void gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element);
-static void gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element);
-static GstElementStateReturn
- gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition);
-static void gst_opt_scheduler_scheduling_change (GstScheduler *sched, GstElement *element);
-static void gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element);
-static void gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element);
-static gboolean gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element);
-static gboolean gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element);
-static void gst_opt_scheduler_error (GstScheduler *sched, GstElement *element);
-static void gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
-static void gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
-static void gst_opt_scheduler_pad_select (GstScheduler *sched, GList *padlist);
-static GstSchedulerState
- gst_opt_scheduler_iterate (GstScheduler *sched);
-
-static void gst_opt_scheduler_show (GstScheduler *sched);
+static void gst_opt_scheduler_class_init (GstOptSchedulerClass * klass);
+static void gst_opt_scheduler_init (GstOptScheduler * scheduler);
+
+static void gst_opt_scheduler_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_opt_scheduler_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static void gst_opt_scheduler_dispose (GObject * object);
+
+static void gst_opt_scheduler_setup (GstScheduler * sched);
+static void gst_opt_scheduler_reset (GstScheduler * sched);
+static void gst_opt_scheduler_add_element (GstScheduler * sched,
+ GstElement * element);
+static void gst_opt_scheduler_remove_element (GstScheduler * sched,
+ GstElement * element);
+static GstElementStateReturn gst_opt_scheduler_state_transition (GstScheduler *
+ sched, GstElement * element, gint transition);
+static void gst_opt_scheduler_scheduling_change (GstScheduler * sched,
+ GstElement * element);
+static void gst_opt_scheduler_lock_element (GstScheduler * sched,
+ GstElement * element);
+static void gst_opt_scheduler_unlock_element (GstScheduler * sched,
+ GstElement * element);
+static gboolean gst_opt_scheduler_yield (GstScheduler * sched,
+ GstElement * element);
+static gboolean gst_opt_scheduler_interrupt (GstScheduler * sched,
+ GstElement * element);
+static void gst_opt_scheduler_error (GstScheduler * sched,
+ GstElement * element);
+static void gst_opt_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad);
+static void gst_opt_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad);
+static void gst_opt_scheduler_pad_select (GstScheduler * sched,
+ GList * padlist);
+static GstSchedulerState gst_opt_scheduler_iterate (GstScheduler * sched);
+
+static void gst_opt_scheduler_show (GstScheduler * sched);
static GstSchedulerClass *parent_class = NULL;
NULL
};
- _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER,
- "GstOpt"COTHREADS_NAME_CAPITAL"Scheduler", &scheduler_info, 0);
+ _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER,
+ "GstOpt" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0);
}
return _gst_opt_scheduler_type;
}
static void
-gst_opt_scheduler_class_init (GstOptSchedulerClass *klass)
+gst_opt_scheduler_class_init (GstOptSchedulerClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstSchedulerClass *gstscheduler_class;
- gobject_class = (GObjectClass*)klass;
- gstobject_class = (GstObjectClass*)klass;
- gstscheduler_class = (GstSchedulerClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstscheduler_class = (GstSchedulerClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_SCHEDULER);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_get_property);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_opt_scheduler_dispose);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_opt_scheduler_dispose);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ITERATIONS,
- g_param_spec_int ("iterations", "Iterations",
- "Number of groups to schedule in one iteration (-1 == until EOS/error)",
- -1, G_MAXINT, 1, G_PARAM_READWRITE));
+ g_param_spec_int ("iterations", "Iterations",
+ "Number of groups to schedule in one iteration (-1 == until EOS/error)",
+ -1, G_MAXINT, 1, G_PARAM_READWRITE));
#ifndef USE_COTHREADS
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_RECURSION,
- g_param_spec_int ("max_recursion", "Max recursion",
- "Maximum number of recursions",
- 1, G_MAXINT, 100, G_PARAM_READWRITE));
+ g_param_spec_int ("max_recursion", "Max recursion",
+ "Maximum number of recursions", 1, G_MAXINT, 100, G_PARAM_READWRITE));
#endif
- gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_opt_scheduler_setup);
- gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_opt_scheduler_reset);
- gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_add_element);
- gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_remove_element);
- gstscheduler_class->state_transition = GST_DEBUG_FUNCPTR (gst_opt_scheduler_state_transition);
- gstscheduler_class->scheduling_change = GST_DEBUG_FUNCPTR (gst_opt_scheduler_scheduling_change);
- gstscheduler_class->lock_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_lock_element);
- gstscheduler_class->unlock_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_unlock_element);
- gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_opt_scheduler_yield);
- gstscheduler_class->interrupt = GST_DEBUG_FUNCPTR (gst_opt_scheduler_interrupt);
- gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_opt_scheduler_error);
- gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_link);
- gstscheduler_class->pad_unlink = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_unlink);
- gstscheduler_class->pad_select = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_select);
- gstscheduler_class->clock_wait = NULL;
- gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_opt_scheduler_iterate);
- gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_opt_scheduler_show);
-
+ gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_opt_scheduler_setup);
+ gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_opt_scheduler_reset);
+ gstscheduler_class->add_element =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_add_element);
+ gstscheduler_class->remove_element =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_remove_element);
+ gstscheduler_class->state_transition =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_state_transition);
+ gstscheduler_class->scheduling_change =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_scheduling_change);
+ gstscheduler_class->lock_element =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_lock_element);
+ gstscheduler_class->unlock_element =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_unlock_element);
+ gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_opt_scheduler_yield);
+ gstscheduler_class->interrupt =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_interrupt);
+ gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_opt_scheduler_error);
+ gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_link);
+ gstscheduler_class->pad_unlink =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_unlink);
+ gstscheduler_class->pad_select =
+ GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_select);
+ gstscheduler_class->clock_wait = NULL;
+ gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_opt_scheduler_iterate);
+ gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_opt_scheduler_show);
+
#ifdef USE_COTHREADS
- do_cothreads_init(NULL);
+ do_cothreads_init (NULL);
#endif
}
static void
-gst_opt_scheduler_init (GstOptScheduler *scheduler)
+gst_opt_scheduler_init (GstOptScheduler * scheduler)
{
scheduler->elements = NULL;
scheduler->iterations = 1;
}
static void
-gst_opt_scheduler_dispose (GObject *object)
+gst_opt_scheduler_dispose (GObject * object)
{
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GstSchedulerFactory *factory;
- GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, "optimal scheduler");
+ GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0,
+ "optimal scheduler");
#ifdef USE_COTHREADS
- factory = gst_scheduler_factory_new ("opt"COTHREADS_NAME,
- "An optimal scheduler using "COTHREADS_NAME" cothreads",
- gst_opt_scheduler_get_type());
+ factory = gst_scheduler_factory_new ("opt" COTHREADS_NAME,
+ "An optimal scheduler using " COTHREADS_NAME " cothreads",
+ gst_opt_scheduler_get_type ());
#else
factory = gst_scheduler_factory_new ("opt",
- "An optimal scheduler using no cothreads",
- gst_opt_scheduler_get_type());
+ "An optimal scheduler using no cothreads", gst_opt_scheduler_get_type ());
#endif
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
- }
- else {
+ } else {
g_warning ("could not register scheduler: optimal");
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstopt"COTHREADS_NAME"scheduler",
- "An optimal scheduler using "COTHREADS_NAME" cothreads",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstopt" COTHREADS_NAME "scheduler",
+ "An optimal scheduler using " COTHREADS_NAME " cothreads",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
-static GstOptSchedulerChain*
-ref_chain (GstOptSchedulerChain *chain)
+static GstOptSchedulerChain *
+ref_chain (GstOptSchedulerChain * chain)
{
- GST_LOG ("ref chain %p %d->%d", chain,
- chain->refcount, chain->refcount+1);
+ GST_LOG ("ref chain %p %d->%d", chain, chain->refcount, chain->refcount + 1);
chain->refcount++;
return chain;
}
-static GstOptSchedulerChain*
-unref_chain (GstOptSchedulerChain *chain)
+static GstOptSchedulerChain *
+unref_chain (GstOptSchedulerChain * chain)
{
- GST_LOG ("unref chain %p %d->%d", chain,
- chain->refcount, chain->refcount-1);
+ GST_LOG ("unref chain %p %d->%d", chain,
+ chain->refcount, chain->refcount - 1);
if (--chain->refcount == 0) {
destroy_chain (chain);
return chain;
}
-static GstOptSchedulerChain*
-create_chain (GstOptScheduler *osched)
+static GstOptSchedulerChain *
+create_chain (GstOptScheduler * osched)
{
GstOptSchedulerChain *chain;
gst_object_ref (GST_OBJECT (osched));
osched->chains = g_slist_prepend (osched->chains, chain);
- GST_LOG ( "new chain %p", chain);
+ GST_LOG ("new chain %p", chain);
return chain;
}
static void
-destroy_chain (GstOptSchedulerChain *chain)
+destroy_chain (GstOptSchedulerChain * chain)
{
GstOptScheduler *osched;
-
- GST_LOG ( "destroy chain %p", chain);
+
+ GST_LOG ("destroy chain %p", chain);
g_assert (chain->num_groups == 0);
g_assert (chain->groups == NULL);
g_free (chain);
}
-static GstOptSchedulerChain*
-add_to_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group)
+static GstOptSchedulerChain *
+add_to_chain (GstOptSchedulerChain * chain, GstOptSchedulerGroup * group)
{
GST_LOG ("adding group %p to chain %p", group, chain);
chain->groups = g_slist_prepend (chain->groups, group);
else
chain->groups = g_slist_append (chain->groups, group);
-
+
chain->num_groups++;
if (GST_OPT_SCHEDULER_GROUP_IS_ENABLED (group)) {
return chain;
}
-static GstOptSchedulerChain*
-remove_from_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group)
+static GstOptSchedulerChain *
+remove_from_chain (GstOptSchedulerChain * chain, GstOptSchedulerGroup * group)
{
GST_LOG ("removing group %p from chain %p", group, chain);
chain->num_groups--;
unref_group (group);
- if (chain->num_groups == 0)
+ if (chain->num_groups == 0)
chain = unref_chain (chain);
chain = unref_chain (chain);
return chain;
}
-static GstOptSchedulerChain*
-merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2)
+static GstOptSchedulerChain *
+merge_chains (GstOptSchedulerChain * chain1, GstOptSchedulerChain * chain2)
{
GSList *walk;
g_assert (chain1 != NULL);
-
+
GST_LOG ("merging chain %p and %p", chain1, chain2);
-
+
/* FIXME: document how chain2 can be NULL */
if (chain1 == chain2 || chain2 == NULL)
return chain1;
/* switch if it's more efficient */
if (chain1->num_groups < chain2->num_groups) {
GstOptSchedulerChain *tmp = chain2;
+
chain2 = chain1;
chain1 = tmp;
}
walk = chain2->groups;
while (walk) {
GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) walk->data;
+
walk = g_slist_next (walk);
- GST_LOG ("reparenting group %p from chain %p to %p",
- group, chain2, chain1);
+ GST_LOG ("reparenting group %p from chain %p to %p", group, chain2, chain1);
ref_group (group);
-
+
remove_from_chain (chain2, group);
add_to_chain (chain1, group);
}
static void
-chain_group_set_enabled (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group, gboolean enabled)
+chain_group_set_enabled (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group, gboolean enabled)
{
g_assert (group != NULL);
g_assert (chain != NULL);
- GST_LOG ("request to %d group %p in chain %p, have %d groups enabled out of %d",
- enabled, group, chain, chain->num_enabled, chain->num_groups);
+ GST_LOG
+ ("request to %d group %p in chain %p, have %d groups enabled out of %d",
+ enabled, group, chain, chain->num_enabled, chain->num_groups);
if (enabled)
GST_OPT_SCHEDULER_GROUP_ENABLE (group);
- else
+ else
GST_OPT_SCHEDULER_GROUP_DISABLE (group);
if (enabled) {
if (chain->num_enabled < chain->num_groups)
chain->num_enabled++;
- GST_DEBUG ("enable group %p in chain %p, now %d groups enabled out of %d", group, chain,
- chain->num_enabled, chain->num_groups);
+ GST_DEBUG ("enable group %p in chain %p, now %d groups enabled out of %d",
+ group, chain, chain->num_enabled, chain->num_groups);
/* OK to call even if the scheduler (cothread context / schedulerfunc) was
setup already -- will get destroyed when the group is destroyed */
GST_DEBUG ("enable chain %p", chain);
GST_OPT_SCHEDULER_CHAIN_ENABLE (chain);
}
- }
- else {
+ } else {
if (chain->num_enabled > 0)
chain->num_enabled--;
- GST_DEBUG ("disable group %p in chain %p, now %d groups enabled out of %d", group, chain,
- chain->num_enabled, chain->num_groups);
+ GST_DEBUG ("disable group %p in chain %p, now %d groups enabled out of %d",
+ group, chain, chain->num_enabled, chain->num_groups);
if (chain->num_enabled == 0) {
GST_DEBUG ("disable chain %p", chain);
/* recursively migrate the group and all connected groups into the new chain */
static void
-chain_recursively_migrate_group (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group)
+chain_recursively_migrate_group (GstOptSchedulerChain * chain,
+ GstOptSchedulerGroup * group)
{
GSList *links;
-
+
/* group already in chain */
if (group->chain == chain)
return;
links = group->group_links;
while (links) {
GstOptSchedulerGroupLink *link = (GstOptSchedulerGroupLink *) links->data;
+
links = g_slist_next (links);
- chain_recursively_migrate_group (chain, (link->group1 == group ? link->group2 : link->group1));
+ chain_recursively_migrate_group (chain,
+ (link->group1 == group ? link->group2 : link->group1));
}
}
-static GstOptSchedulerGroup*
-ref_group (GstOptSchedulerGroup *group)
+static GstOptSchedulerGroup *
+ref_group (GstOptSchedulerGroup * group)
{
- GST_LOG ("ref group %p %d->%d", group,
- group->refcount, group->refcount+1);
+ GST_LOG ("ref group %p %d->%d", group, group->refcount, group->refcount + 1);
group->refcount++;
return group;
}
-static GstOptSchedulerGroup*
-unref_group (GstOptSchedulerGroup *group)
+static GstOptSchedulerGroup *
+unref_group (GstOptSchedulerGroup * group)
{
- GST_LOG ("unref group %p %d->%d", group,
- group->refcount, group->refcount-1);
+ GST_LOG ("unref group %p %d->%d", group,
+ group->refcount, group->refcount - 1);
if (--group->refcount == 0) {
destroy_group (group);
return group;
}
-static GstOptSchedulerGroup*
-create_group (GstOptSchedulerChain *chain, GstElement *element,
- GstOptSchedulerGroupType type)
+static GstOptSchedulerGroup *
+create_group (GstOptSchedulerChain * chain, GstElement * element,
+ GstOptSchedulerGroupType type)
{
GstOptSchedulerGroup *group;
group = g_new0 (GstOptSchedulerGroup, 1);
GST_LOG ("new group %p", group);
- group->refcount = 1; /* float... */
+ group->refcount = 1; /* float... */
group->flags = GST_OPT_SCHEDULER_GROUP_DISABLED;
group->type = type;
add_to_group (group, element);
add_to_chain (chain, group);
- group = unref_group (group); /* ...and sink. */
+ group = unref_group (group); /* ...and sink. */
/* group's refcount is now 2 (one for the element, one for the chain) */
-
+
return group;
}
static void
-destroy_group (GstOptSchedulerGroup *group)
+destroy_group (GstOptSchedulerGroup * group)
{
GST_LOG ("destroy group %p", group);
g_free (group);
}
-static GstOptSchedulerGroup*
-add_to_group (GstOptSchedulerGroup *group, GstElement *element)
+static GstOptSchedulerGroup *
+add_to_group (GstOptSchedulerGroup * group, GstElement * element)
{
g_assert (group != NULL);
g_assert (element != NULL);
- GST_DEBUG ("adding element \"%s\" to group %p", GST_ELEMENT_NAME (element), group);
+ GST_DEBUG ("adding element \"%s\" to group %p", GST_ELEMENT_NAME (element),
+ group);
if (GST_ELEMENT_IS_DECOUPLED (element)) {
- GST_DEBUG ("element \"%s\" is decoupled, not adding to group %p",
- GST_ELEMENT_NAME (element), group);
+ GST_DEBUG ("element \"%s\" is decoupled, not adding to group %p",
+ GST_ELEMENT_NAME (element), group);
return group;
}
/* if the element is linked to elements from other groups, you must decrement
the link count prior to calling this function */
-static GstOptSchedulerGroup*
-remove_from_group (GstOptSchedulerGroup *group, GstElement *element)
+static GstOptSchedulerGroup *
+remove_from_group (GstOptSchedulerGroup * group, GstElement * element)
{
- GST_DEBUG ("removing element \"%s\" from group %p", GST_ELEMENT_NAME (element), group);
+ GST_DEBUG ("removing element \"%s\" from group %p",
+ GST_ELEMENT_NAME (element), group);
g_assert (group != NULL);
g_assert (element != NULL);
/* FIXME need to check if the groups are of the same type -- otherwise need to
setup the scheduler again, if it is setup */
-static GstOptSchedulerGroup*
-merge_groups (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2)
+static GstOptSchedulerGroup *
+merge_groups (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2)
{
g_assert (group1 != NULL);
GST_DEBUG ("merging groups %p and %p", group1, group2);
-
+
if (group1 == group2 || group2 == NULL)
return group1;
while (group2 && group2->elements) {
- GstElement *element = (GstElement *)group2->elements->data;
+ GstElement *element = (GstElement *) group2->elements->data;
group2 = remove_from_group (group2, element);
add_to_group (group1, element);
}
-
+
return group1;
}
/* setup the scheduler context for a group. The right schedule function
* is selected based on the group type and cothreads are created if
* needed */
-static void
-setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group)
+static void
+setup_group_scheduler (GstOptScheduler * osched, GstOptSchedulerGroup * group)
{
GroupScheduleFunction wrapper;
wrapper = get_group_schedule_function;
else if (group->type == GST_OPT_SCHEDULER_GROUP_LOOP)
wrapper = loop_group_schedule_function;
-
+
#ifdef USE_COTHREADS
if (!(group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE)) {
do_cothread_create (group->cothread, osched->context,
- (cothread_func) wrapper, 0, (char **) group);
- }
- else {
+ (cothread_func) wrapper, 0, (char **) group);
+ } else {
do_cothread_setfunc (group->cothread, osched->context,
- (cothread_func) wrapper, 0, (char **) group);
+ (cothread_func) wrapper, 0, (char **) group);
}
#else
group->schedulefunc = wrapper;
group->flags |= GST_OPT_SCHEDULER_GROUP_SCHEDULABLE;
}
-static void
-destroy_group_scheduler (GstOptSchedulerGroup *group)
+static void
+destroy_group_scheduler (GstOptSchedulerGroup * group)
{
g_assert (group);
}
static void
-group_error_handler (GstOptSchedulerGroup *group)
+group_error_handler (GstOptSchedulerGroup * group)
{
GST_DEBUG ("group %p has errored", group);
* and tells the chain that the group is enabled if all elements inside the group are
* enabled */
static void
-group_element_set_enabled (GstOptSchedulerGroup *group, GstElement *element, gboolean enabled)
+group_element_set_enabled (GstOptSchedulerGroup * group, GstElement * element,
+ gboolean enabled)
{
g_assert (group != NULL);
g_assert (element != NULL);
- GST_LOG ("request to %d element %s in group %p, have %d elements enabled out of %d",
- enabled, GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements);
+ GST_LOG
+ ("request to %d element %s in group %p, have %d elements enabled out of %d",
+ enabled, GST_ELEMENT_NAME (element), group, group->num_enabled,
+ group->num_elements);
/* Note that if an unlinked PLAYING element is added to a bin, we have to
create a new group to hold the element, and this function will be called
if (group->num_enabled < group->num_elements)
group->num_enabled++;
- GST_DEBUG ("enable element %s in group %p, now %d elements enabled out of %d",
- GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements);
+ GST_DEBUG
+ ("enable element %s in group %p, now %d elements enabled out of %d",
+ GST_ELEMENT_NAME (element), group, group->num_enabled,
+ group->num_elements);
if (group->num_enabled == group->num_elements) {
if (!group->chain) {
- GST_DEBUG ("enable chainless group %p", group);
- GST_OPT_SCHEDULER_GROUP_ENABLE (group);
+ GST_DEBUG ("enable chainless group %p", group);
+ GST_OPT_SCHEDULER_GROUP_ENABLE (group);
} else {
- GST_LOG ("enable group %p", group);
- chain_group_set_enabled (group->chain, group, TRUE);
+ GST_LOG ("enable group %p", group);
+ chain_group_set_enabled (group->chain, group, TRUE);
}
}
- }
- else {
+ } else {
if (group->num_enabled > 0)
group->num_enabled--;
- GST_DEBUG ("disable element %s in group %p, now %d elements enabled out of %d",
- GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements);
+ GST_DEBUG
+ ("disable element %s in group %p, now %d elements enabled out of %d",
+ GST_ELEMENT_NAME (element), group, group->num_enabled,
+ group->num_elements);
if (group->num_enabled == 0) {
if (!group->chain) {
- GST_DEBUG ("disable chainless group %p", group);
- GST_OPT_SCHEDULER_GROUP_DISABLE (group);
+ GST_DEBUG ("disable chainless group %p", group);
+ GST_OPT_SCHEDULER_GROUP_DISABLE (group);
} else {
- GST_LOG ("disable group %p", group);
- chain_group_set_enabled (group->chain, group, FALSE);
+ GST_LOG ("disable group %p", group);
+ chain_group_set_enabled (group->chain, group, FALSE);
}
}
}
* by calling the schedule function. In the non-cothread case
* we cannot run already running groups so we return FALSE here
* to indicate this to the caller */
-static gboolean
-schedule_group (GstOptSchedulerGroup *group)
+static gboolean
+schedule_group (GstOptSchedulerGroup * group)
{
if (!group->entry) {
GST_INFO ("not scheduling group %p without entry", group);
return FALSE;
}
-
#ifdef USE_COTHREADS
if (group->cothread)
do_cothread_switch (group->cothread);
} else {
GSList *l;
- for (l=group->elements; l; l=l->next) {
- GstElement *e = (GstElement*)l->data;
+ for (l = group->elements; l; l = l->next) {
+ GstElement *e = (GstElement *) l->data;
+
if (e->pre_run_func)
- e->pre_run_func (e);
+ e->pre_run_func (e);
}
group->schedulefunc (group->argc, group->argv);
- for (l=group->elements; l; l=l->next) {
- GstElement *e = (GstElement*)l->data;
+ for (l = group->elements; l; l = l->next) {
+ GstElement *e = (GstElement *) l->data;
+
if (e->post_run_func)
- e->post_run_func (e);
+ e->post_run_func (e);
}
}
#ifndef USE_COTHREADS
static void
-gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched)
+gst_opt_scheduler_schedule_run_queue (GstOptScheduler * osched)
{
GST_LOG_OBJECT (osched, "running queue: %d groups, recursed %d times",
- g_list_length (osched->runqueue),
- osched->recursion, g_list_length (osched->runqueue));
+ g_list_length (osched->runqueue),
+ osched->recursion, g_list_length (osched->runqueue));
/* note that we have a ref on each group on the queue (unref after running) */
while (osched->runqueue) {
GstOptSchedulerGroup *group;
gboolean res;
-
+
group = (GstOptSchedulerGroup *) osched->runqueue->data;
/* runqueue holds refcount to group */
res = schedule_group (group);
if (!res) {
- g_warning ("error scheduling group %p", group);
+ g_warning ("error scheduling group %p", group);
group_error_handler (group);
- }
- else {
+ } else {
GST_LOG_OBJECT (osched, "done scheduling group %p", group);
}
unref_group (group);
}
- GST_LOG_OBJECT (osched, "run queue length after scheduling %d", g_list_length (osched->runqueue));
+ GST_LOG_OBJECT (osched, "run queue length after scheduling %d",
+ g_list_length (osched->runqueue));
osched->recursion--;
}
/* a chain is scheduled by picking the first active group and scheduling it */
static void
-schedule_chain (GstOptSchedulerChain *chain)
+schedule_chain (GstOptSchedulerChain * chain)
{
GSList *groups;
GstOptScheduler *osched;
if (!GST_OPT_SCHEDULER_GROUP_IS_DISABLED (group)) {
ref_group (group);
- GST_LOG ("scheduling group %p in chain %p",
- group, chain);
+ GST_LOG ("scheduling group %p in chain %p", group, chain);
#ifdef USE_COTHREADS
schedule_group (group);
#else
osched->recursion = 0;
- if (!g_list_find (osched->runqueue, group))
- {
- ref_group (group);
- osched->runqueue = g_list_append (osched->runqueue, group);
+ if (!g_list_find (osched->runqueue, group)) {
+ ref_group (group);
+ osched->runqueue = g_list_append (osched->runqueue, group);
}
gst_opt_scheduler_schedule_run_queue (osched);
#endif
- GST_LOG ("done scheduling group %p in chain %p",
- group, chain);
+ GST_LOG ("done scheduling group %p in chain %p", group, chain);
unref_group (group);
break;
}
while (pads) {
GstData *data;
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
/* skip sinks and ghostpads */
if (!GST_PAD_IS_SRC (pad) || !GST_IS_REAL_PAD (pad))
continue;
- GST_DEBUG ("doing get and push on pad \"%s:%s\" in group %p",
- GST_DEBUG_PAD_NAME (pad), group);
+ GST_DEBUG ("doing get and push on pad \"%s:%s\" in group %p",
+ GST_DEBUG_PAD_NAME (pad), group);
data = GST_RPAD_GETFUNC (pad) (pad);
if (data) {
group->flags |= GST_OPT_SCHEDULER_GROUP_RUNNING;
- GST_DEBUG ("calling loopfunc of element %s in group %p",
- GST_ELEMENT_NAME (entry), group);
+ GST_DEBUG ("calling loopfunc of element %s in group %p",
+ GST_ELEMENT_NAME (entry), group);
entry->loopfunc (entry);
- GST_LOG ("loopfunc ended of element %s in group %p",
- GST_ELEMENT_NAME (entry), group);
+ GST_LOG ("loopfunc ended of element %s in group %p",
+ GST_ELEMENT_NAME (entry), group);
group->flags &= ~GST_OPT_SCHEDULER_GROUP_RUNNING;
{
GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv;
- g_warning ("(internal error) unknown group type %d, disabling\n", group->type);
+ g_warning ("(internal error) unknown group type %d, disabling\n",
+ group->type);
group_error_handler (group);
return 0;
* link performs a push to the loop element. We then schedule the
* group with the loop-based element until the bufpen is empty */
static void
-gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstData *data)
+gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data)
{
GstOptSchedulerGroup *group;
GstOptScheduler *osched;
if (GST_PAD_BUFLIST (peer)) {
g_warning ("deadlock detected, disabling group %p", group);
group_error_handler (group);
- }
- else {
+ } else {
GST_LOG ("queueing data %p on %s:%s's bufpen", data,
- GST_DEBUG_PAD_NAME (peer));
+ GST_DEBUG_PAD_NAME (peer));
GST_PAD_BUFLIST (peer) = g_list_append (GST_PAD_BUFLIST (peer), data);
schedule_group (group);
}
#else
GST_LOG ("queueing data %p on %s:%s's bufpen", data,
- GST_DEBUG_PAD_NAME (peer));
+ GST_DEBUG_PAD_NAME (peer));
GST_PAD_BUFLIST (peer) = g_list_append (GST_PAD_BUFLIST (peer), data);
if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) {
GST_LOG ("adding group %p to runqueue", group);
- if (!g_list_find (osched->runqueue, group))
- {
+ if (!g_list_find (osched->runqueue, group)) {
ref_group (group);
osched->runqueue = g_list_append (osched->runqueue, group);
}
}
#endif
-
+
GST_LOG ("%d buffers left on %s:%s's bufpen after chain handler",
- g_list_length (GST_PAD_BUFLIST (peer)));
+ g_list_length (GST_PAD_BUFLIST (peer)));
}
/* this function is called by a loop based element that performs a
* pull on a sinkpad. We schedule the peer group until the bufpen
* is filled with the buffer so that this function can return */
-static GstData*
-gst_opt_scheduler_get_wrapper (GstPad *srcpad)
+static GstData *
+gst_opt_scheduler_get_wrapper (GstPad * srcpad)
{
GstData *data;
GstOptSchedulerGroup *group;
GstOptScheduler *osched;
gboolean disabled;
-
+
GST_LOG ("get handler for %" GST_PTR_FORMAT, srcpad);
/* first try to grab a queued buffer */
if (GST_PAD_BUFLIST (srcpad)) {
data = GST_PAD_BUFLIST (srcpad)->data;
GST_PAD_BUFLIST (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), data);
-
+
GST_LOG ("returning popped queued data %p", data);
return data;
if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) {
ref_group (group);
- if (!g_list_find (osched->runqueue, group))
- {
- ref_group (group);
- osched->runqueue = g_list_append (osched->runqueue, group);
+ if (!g_list_find (osched->runqueue, group)) {
+ ref_group (group);
+ osched->runqueue = g_list_append (osched->runqueue, group);
}
GST_LOG ("recursing into scheduler group %p", group);
/* if the group was gone we also might have to break out of the loop */
disabled = TRUE;
}
- }
- else {
+ } else {
/* in this case, the group was running and we wanted to swtich to it,
* this is not allowed in the optimal scheduler (yet) */
g_warning ("deadlock detected, disabling group %p", group);
if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) {
GST_INFO ("scheduler interrupted, return interrupt event");
data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
- }
- else {
+ } else {
if (GST_PAD_BUFLIST (srcpad)) {
- data = GST_PAD_BUFLIST (srcpad)->data;
- GST_PAD_BUFLIST (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), data);
- }
- else if (disabled) {
- /* no buffer in queue and peer group was disabled */
- data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
+ data = GST_PAD_BUFLIST (srcpad)->data;
+ GST_PAD_BUFLIST (srcpad) =
+ g_list_remove (GST_PAD_BUFLIST (srcpad), data);
+ } else if (disabled) {
+ /* no buffer in queue and peer group was disabled */
+ data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
}
}
}
while (data == NULL);
GST_LOG ("get handler, returning data %p, queue length %d",
- data, g_list_length (GST_PAD_BUFLIST (srcpad)));
+ data, g_list_length (GST_PAD_BUFLIST (srcpad)));
return data;
}
/* this function is a chain wrapper for non-event-aware plugins,
* it'll simply dispatch the events to the (default) event handler */
static void
-gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstData *data)
+gst_opt_scheduler_chain_wrapper (GstPad * sinkpad, GstData * data)
{
if (GST_IS_EVENT (data)) {
gst_pad_send_event (sinkpad, GST_EVENT (data));
- }
- else {
+ } else {
GST_RPAD_CHAINFUNC (sinkpad) (sinkpad, data);
}
}
static void
-clear_queued (GstData *data, gpointer user_data)
+clear_queued (GstData * data, gpointer user_data)
{
gst_data_unref (data);
}
static void
-pad_clear_queued (GstPad *srcpad, gpointer user_data)
+pad_clear_queued (GstPad * srcpad, gpointer user_data)
{
GList *buflist = GST_PAD_BUFLIST (srcpad);
}
static gboolean
-gst_opt_scheduler_event_wrapper (GstPad *srcpad, GstEvent *event)
+gst_opt_scheduler_event_wrapper (GstPad * srcpad, GstEvent * event)
{
gboolean flush;
- GST_DEBUG ("intercepting event %d on pad %s:%s",
- GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad));
-
+ GST_DEBUG ("intercepting event %d on pad %s:%s",
+ GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad));
+
/* figure out if this is a flush event */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
}
static GstElementStateReturn
-gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition)
+gst_opt_scheduler_state_transition (GstScheduler * sched, GstElement * element,
+ gint transition)
{
GstOptSchedulerGroup *group;
GstElementStateReturn res = GST_STATE_SUCCESS;
-
- GST_DEBUG ("element \"%s\" state change %d", GST_ELEMENT_NAME (element), transition);
+
+ GST_DEBUG ("element \"%s\" state change %d", GST_ELEMENT_NAME (element),
+ transition);
/* we check the state of the managing pipeline here */
if (GST_IS_BIN (element)) {
GST_LOG ("parent \"%s\" changed state", GST_ELEMENT_NAME (element));
switch (transition) {
- case GST_STATE_PLAYING_TO_PAUSED:
- GST_INFO ("setting scheduler state to stopped");
- GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED;
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- GST_INFO ("setting scheduler state to running");
- GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ GST_INFO ("setting scheduler state to stopped");
+ GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED;
break;
- default:
- GST_LOG ("no interesting state change, doing nothing");
+ case GST_STATE_PAUSED_TO_PLAYING:
+ GST_INFO ("setting scheduler state to running");
+ GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING;
+ break;
+ default:
+ GST_LOG ("no interesting state change, doing nothing");
}
}
return res;
/* an element withut a group has to be an unlinked src, sink
* filter element */
if (!group) {
- GST_INFO ("element \"%s\" has no group", GST_ELEMENT_NAME (element));
+ GST_INFO ("element \"%s\" has no group", GST_ELEMENT_NAME (element));
res = GST_STATE_FAILURE;
}
/* else construct the scheduling context of this group and enable it */
else {
- group_element_set_enabled (group, element, TRUE);
+ group_element_set_enabled (group, element, TRUE);
}
break;
case GST_STATE_PLAYING_TO_PAUSED:
/* if the element still has a group, we disable it */
- if (group)
- group_element_set_enabled (group, element, FALSE);
+ if (group)
+ group_element_set_enabled (group, element, FALSE);
break;
case GST_STATE_PAUSED_TO_READY:
- {
+ {
GList *pads = (GList *) gst_element_get_pad_list (element);
g_list_foreach (pads, (GFunc) pad_clear_queued, NULL);
}
static void
-gst_opt_scheduler_scheduling_change (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_scheduling_change (GstScheduler * sched, GstElement * element)
{
g_warning ("scheduling change, implement me");
}
static void
-get_group (GstElement *element, GstOptSchedulerGroup **group)
+get_group (GstElement * element, GstOptSchedulerGroup ** group)
{
GstOptSchedulerCtx *ctx;
- /*GList *pads;*/
+
+ /*GList *pads; */
ctx = GST_ELEMENT_SCHED_CONTEXT (element);
- if (ctx)
+ if (ctx)
*group = ctx->group;
else
*group = NULL;
* - if both of the elements have a group, we merge the groups, which
* will also merge the chains.
*/
-static GstOptSchedulerGroup*
-group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *element2,
- GstOptSchedulerGroupType type)
+static GstOptSchedulerGroup *
+group_elements (GstOptScheduler * osched, GstElement * element1,
+ GstElement * element2, GstOptSchedulerGroupType type)
{
GstOptSchedulerGroup *group1, *group2, *group = NULL;
-
+
get_group (element1, &group1);
get_group (element2, &group2);
-
+
/* none of the elements is added to a group, create a new group
* and chain to add the elements to */
if (!group1 && !group2) {
GstOptSchedulerChain *chain;
- GST_DEBUG ("creating new group to hold \"%s\" and \"%s\"",
- GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2));
+ GST_DEBUG ("creating new group to hold \"%s\" and \"%s\"",
+ GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2));
chain = create_chain (osched);
group = create_group (chain, element1, type);
}
/* the first element has a group */
else if (group1) {
- GST_DEBUG ("adding \"%s\" to \"%s\"'s group",
- GST_ELEMENT_NAME (element2), GST_ELEMENT_NAME (element1));
+ GST_DEBUG ("adding \"%s\" to \"%s\"'s group",
+ GST_ELEMENT_NAME (element2), GST_ELEMENT_NAME (element1));
/* the second element also has a group, merge */
if (group2)
/* element1 has no group, element2 does. Add element1 to the
* group of element2 */
else {
- GST_DEBUG ("adding \"%s\" to \"%s\"'s group",
- GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2));
+ GST_DEBUG ("adding \"%s\" to \"%s\"'s group",
+ GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2));
add_to_group (group2, element1);
group = group2;
}
* increment link counts between groups
*/
static void
-group_inc_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2)
+group_inc_link (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2)
{
GSList *links = group1->group_links;
gboolean done = FALSE;
while (links && !done) {
link = (GstOptSchedulerGroupLink *) links->data;
links = g_slist_next (links);
-
+
if (IS_GROUP_LINK (link, group1, group2)) {
/* we found a link to this group, increment the link count */
link->count++;
- GST_LOG ("incremented group link count between %p and %p to %d",
- group1, group2, link->count);
+ GST_LOG ("incremented group link count between %p and %p to %d",
+ group1, group2, link->count);
done = TRUE;
}
}
group1->group_links = g_slist_prepend (group1->group_links, link);
group2->group_links = g_slist_prepend (group2->group_links, link);
- GST_DEBUG ("added group link between %p and %p",
- group1, group2);
+ GST_DEBUG ("added group link between %p and %p", group1, group2);
}
}
* decrement link counts between groups, returns TRUE if the link count reaches 0
*/
static gboolean
-group_dec_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2)
+group_dec_link (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2)
{
GSList *links = group1->group_links;
gboolean res = FALSE;
while (links) {
link = (GstOptSchedulerGroupLink *) links->data;
links = g_slist_next (links);
-
+
if (IS_GROUP_LINK (link, group1, group2)) {
link->count--;
- GST_LOG ("link count between %p and %p is now %d",
- group1, group2, link->count);
+ GST_LOG ("link count between %p and %p is now %d",
+ group1, group2, link->count);
if (link->count == 0) {
group1->group_links = g_slist_remove (group1->group_links, link);
group2->group_links = g_slist_remove (group2->group_links, link);
g_free (link);
- GST_DEBUG ("removed group link between %p and %p",
- group1, group2);
+ GST_DEBUG ("removed group link between %p and %p", group1, group2);
res = TRUE;
}
break;
}
-typedef enum {
+typedef enum
+{
GST_OPT_INVALID,
GST_OPT_GET_TO_CHAIN,
GST_OPT_LOOP_TO_CHAIN,
* Entry points for this scheduler.
*/
static void
-gst_opt_scheduler_setup (GstScheduler *sched)
-{
+gst_opt_scheduler_setup (GstScheduler * sched)
+{
#ifdef USE_COTHREADS
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
-
+
/* first create thread context */
if (osched->context == NULL) {
GST_DEBUG ("initializing cothread context");
osched->context = do_cothread_context_init ();
}
#endif
-}
-
-static void
-gst_opt_scheduler_reset (GstScheduler *sched)
-{
+}
+
+static void
+gst_opt_scheduler_reset (GstScheduler * sched)
+{
#ifdef USE_COTHREADS
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
GSList *chains = osched->chains;
}
chains = chains->next;
}
-
+
if (osched->context) {
do_cothread_context_destroy (osched->context);
- osched->context = NULL;
+ osched->context = NULL;
}
#endif
-}
+}
static void
-gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_add_element (GstScheduler * sched, GstElement * element)
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
GstOptSchedulerCtx *ctx;
- const GList *pads;
+ const GList *pads;
GST_DEBUG_OBJECT (sched, "adding element \"%s\"", GST_OBJECT_NAME (element));
pads = gst_element_get_pad_list (element);
while (pads) {
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
- if (!GST_IS_REAL_PAD (pad)) continue;
+ if (!GST_IS_REAL_PAD (pad))
+ continue;
GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad);
}
group = create_group (chain, element, GST_OPT_SCHEDULER_GROUP_LOOP);
group->entry = element;
- GST_LOG ("added element \"%s\" as loop based entry", GST_ELEMENT_NAME (element));
+ GST_LOG ("added element \"%s\" as loop based entry",
+ GST_ELEMENT_NAME (element));
}
}
static void
-gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_remove_element (GstScheduler * sched, GstElement * element)
{
GstOptSchedulerGroup *group;
- GST_DEBUG_OBJECT (sched, "removing element \"%s\"", GST_OBJECT_NAME (element));
+ GST_DEBUG_OBJECT (sched, "removing element \"%s\"",
+ GST_OBJECT_NAME (element));
/* decoupled elements are not added to the scheduler lists and should therefore
* no be removed */
}
static void
-gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_lock_element (GstScheduler * sched, GstElement * element)
{
//GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
g_warning ("lock element, implement me");
}
static void
-gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_unlock_element (GstScheduler * sched, GstElement * element)
{
//GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
g_warning ("unlock element, implement me");
}
static gboolean
-gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_yield (GstScheduler * sched, GstElement * element)
{
#ifdef USE_COTHREADS
/* yield hands control to the main cothread context if the requesting
* element is the entry point of the group */
GstOptSchedulerGroup *group;
+
get_group (element, &group);
if (group && group->entry == element)
- do_cothread_switch (do_cothread_get_main (((GstOptScheduler*)sched)->context));
+ do_cothread_switch (do_cothread_get_main (((GstOptScheduler *) sched)->
+ context));
return FALSE;
#else
- g_warning ("element %s performs a yield, please fix the element",
- GST_ELEMENT_NAME (element));
+ g_warning ("element %s performs a yield, please fix the element",
+ GST_ELEMENT_NAME (element));
return TRUE;
#endif
}
static gboolean
-gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_interrupt (GstScheduler * sched, GstElement * element)
{
- GST_INFO ("interrupt from \"%s\"",
- GST_OBJECT_NAME (element));
+ GST_INFO ("interrupt from \"%s\"", GST_OBJECT_NAME (element));
#ifdef USE_COTHREADS
- do_cothread_switch (do_cothread_get_main (((GstOptScheduler*)sched)->context));
+ do_cothread_switch (do_cothread_get_main (((GstOptScheduler *) sched)->
+ context));
return FALSE;
#else
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
-
+
GST_INFO ("scheduler set interrupted state");
osched->state = GST_OPT_SCHEDULER_STATE_INTERRUPTED;
}
}
static void
-gst_opt_scheduler_error (GstScheduler *sched, GstElement *element)
+gst_opt_scheduler_error (GstScheduler * sched, GstElement * element)
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
GstOptSchedulerGroup *group;
+
get_group (element, &group);
if (group)
group_error_handler (group);
/* link pads, merge groups and chains */
static void
-gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
+gst_opt_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad)
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
LinkType type = GST_OPT_INVALID;
GstElement *element1, *element2;
- GST_INFO ("scheduling link between %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_INFO ("scheduling link between %s:%s and %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
element1 = GST_PAD_PARENT (srcpad);
element2 = GST_PAD_PARENT (sinkpad);
else {
if (element1->loopfunc) {
if (GST_RPAD_CHAINFUNC (sinkpad))
- type = GST_OPT_LOOP_TO_CHAIN;
- }
- else if (element2->loopfunc) {
+ type = GST_OPT_LOOP_TO_CHAIN;
+ } else if (element2->loopfunc) {
if (GST_RPAD_GETFUNC (srcpad)) {
- type = GST_OPT_GET_TO_LOOP;
+ type = GST_OPT_GET_TO_LOOP;
/* this could be tricky, the get based source could
* already be part of a loop based group in another pad,
* we assert on that for now */
if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL &&
- GST_ELEMENT_SCHED_GROUP (element1) != NULL)
- {
- GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1);
+ GST_ELEMENT_SCHED_GROUP (element1) != NULL) {
+ GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1);
/* if the loop based element is the entry point we're ok, if it
* isn't then we have multiple loop based elements in this group */
if (group->entry != element2) {
- g_error ("internal error: cannot schedule get to loop in multi-loop based group");
+ g_error
+ ("internal error: cannot schedule get to loop in multi-loop based group");
return;
}
}
- }
- else
- type = GST_OPT_CHAIN_TO_LOOP;
- }
- else {
+ } else
+ type = GST_OPT_CHAIN_TO_LOOP;
+ } else {
if (GST_RPAD_GETFUNC (srcpad) && GST_RPAD_CHAINFUNC (sinkpad)) {
- type = GST_OPT_GET_TO_CHAIN;
+ type = GST_OPT_GET_TO_CHAIN;
/* the get based source could already be part of a loop
* based group in another pad, we assert on that for now */
if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL &&
- GST_ELEMENT_SCHED_GROUP (element1) != NULL)
- {
- GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1);
+ GST_ELEMENT_SCHED_GROUP (element1) != NULL) {
+ GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1);
/* if the get based element is the entry point we're ok, if it
* isn't then we have a mixed loop/chain based group */
if (group->entry != element1) {
- g_error ("internal error: cannot schedule get to chain with mixed loop/chain based group");
+ g_error
+ ("internal error: cannot schedule get to chain with mixed loop/chain based group");
return;
}
}
- }
- else
- type = GST_OPT_CHAIN_TO_CHAIN;
+ } else
+ type = GST_OPT_CHAIN_TO_CHAIN;
}
}
-
+
/* since we can't set event handlers on pad creation after addition, it is
* best we set all of them again to the default before linking */
GST_RPAD_EVENTHANDLER (srcpad) = GST_RPAD_EVENTFUNC (srcpad);
GST_RPAD_EVENTHANDLER (sinkpad) = GST_RPAD_EVENTFUNC (sinkpad);
-
+
/* for each link type, perform specific actions */
switch (type) {
case GST_OPT_GET_TO_CHAIN:
/* setup get/chain handlers */
GST_RPAD_GETHANDLER (srcpad) = GST_RPAD_GETFUNC (srcpad);
if (GST_ELEMENT_IS_EVENT_AWARE (element2))
- GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad);
+ GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad);
else
- GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper;
+ GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper;
/* the two elements should be put into the same group,
* this also means that they are in the same chain automatically */
group = group_elements (osched, element1, element2,
- GST_OPT_SCHEDULER_GROUP_GET);
+ GST_OPT_SCHEDULER_GROUP_GET);
/* if there is not yet an entry in the group, select the source
* element as the entry point */
if (!group->entry) {
- group->entry = element1;
+ group->entry = element1;
- GST_DEBUG ("setting \"%s\" as entry point of _get-based group %p",
- GST_ELEMENT_NAME (element1), group);
+ GST_DEBUG ("setting \"%s\" as entry point of _get-based group %p",
+ GST_ELEMENT_NAME (element1), group);
}
break;
}
GST_LOG ("loop/chain to chain based link");
if (GST_ELEMENT_IS_EVENT_AWARE (element2))
- GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad);
+ GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad);
else
- GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper;
+ GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper;
/* the two elements should be put into the same group,
* this also means that they are in the same chain automatically,
if (!group1) {
/* create a new group for element1 as it cannot be merged into another group
* here. we create the group in the same chain as the loop-based element. */
- GST_DEBUG ("creating new group for element %s", GST_ELEMENT_NAME (element1));
- group1 = create_group (group2->chain, element1,
- GST_OPT_SCHEDULER_GROUP_LOOP);
- }
- else {
+ GST_DEBUG ("creating new group for element %s",
+ GST_ELEMENT_NAME (element1));
+ group1 =
+ create_group (group2->chain, element1,
+ GST_OPT_SCHEDULER_GROUP_LOOP);
+ } else {
/* both elements are already in a group, make sure they are added to
* the same chain */
- merge_chains (group1->chain, group2->chain);
+ merge_chains (group1->chain, group2->chain);
}
group_inc_link (group1, group2);
break;
* no checking is done on the brokenpad arg
*/
static gboolean
-element_has_link_with_group (GstElement *element, GstOptSchedulerGroup *group, GstPad *brokenpad)
+element_has_link_with_group (GstElement * element, GstOptSchedulerGroup * group,
+ GstPad * brokenpad)
{
gboolean linked = FALSE;
const GList *pads;
pads = gst_element_get_pad_list (element);
while (pads && !linked) {
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
/* we only operate on real pads and on the pad that is not broken */
/* links with decoupled elements are valid */
if (GST_ELEMENT_IS_DECOUPLED (parent)) {
- linked = TRUE;
- }
- else {
+ linked = TRUE;
+ } else {
/* for non-decoupled elements we need to check the group */
- get_group (parent, &parentgroup);
+ get_group (parent, &parentgroup);
- /* if it's in the same group, we're still linked */
- if (parentgroup == group)
- linked = TRUE;
+ /* if it's in the same group, we're still linked */
+ if (parentgroup == group)
+ linked = TRUE;
}
- }
+ }
}
return linked;
}
* group link into account.
*/
static gboolean
-group_can_reach_group (GstOptSchedulerGroup *group, GstOptSchedulerGroup *target)
+group_can_reach_group (GstOptSchedulerGroup * group,
+ GstOptSchedulerGroup * target)
{
gboolean reachable = FALSE;
const GSList *links = group->group_links;
- GST_LOG ("checking if group %p can reach %p",
- group, target);
+ GST_LOG ("checking if group %p can reach %p", group, target);
/* seems like we found the target element */
if (group == target) {
}
/* if the group is marked as visited, we don't need to check here */
- if (GST_OPT_SCHEDULER_GROUP_IS_FLAG_SET (group, GST_OPT_SCHEDULER_GROUP_VISITED)) {
+ if (GST_OPT_SCHEDULER_GROUP_IS_FLAG_SET (group,
+ GST_OPT_SCHEDULER_GROUP_VISITED)) {
GST_LOG ("already visited %p", group);
return FALSE;
}
/* find other group in this link */
other = OTHER_GROUP_LINK (link, group);
- GST_LOG ("found link from %p to %p, count %d",
- group, other, link->count);
+ GST_LOG ("found link from %p to %p, count %d", group, other, link->count);
/* check if we can reach the target recursiveley */
reachable = group_can_reach_group (other, target);
* all groups are checked. */
GST_OPT_SCHEDULER_GROUP_UNSET_FLAG (group, GST_OPT_SCHEDULER_GROUP_VISITED);
- GST_LOG ("leaving group %p with %s", group, (reachable ? "TRUE":"FALSE"));
+ GST_LOG ("leaving group %p with %s", group, (reachable ? "TRUE" : "FALSE"));
return reachable;
}
static void
-group_dec_links_for_element (GstOptSchedulerGroup* group, GstElement *element)
+group_dec_links_for_element (GstOptSchedulerGroup * group, GstElement * element)
{
GList *l;
GstPad *pad;
GstOptSchedulerGroup *peer_group;
-
- for (l=GST_ELEMENT_PADS(element); l; l=l->next) {
- pad = (GstPad*)l->data;
+
+ for (l = GST_ELEMENT_PADS (element); l; l = l->next) {
+ pad = (GstPad *) l->data;
if (GST_IS_REAL_PAD (pad) && GST_PAD_PEER (pad)) {
get_group (GST_PAD_PARENT (GST_PAD_PEER (pad)), &peer_group);
if (peer_group && peer_group != group)
}
static void
-gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
+gst_opt_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad,
+ GstPad * sinkpad)
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
GstElement *element1, *element2;
GstOptSchedulerGroup *group1, *group2;
- GST_INFO ("unscheduling link between %s:%s and %s:%s",
- GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
+ GST_INFO ("unscheduling link between %s:%s and %s:%s",
+ GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
element1 = GST_PAD_PARENT (srcpad);
element2 = GST_PAD_PARENT (sinkpad);
-
+
get_group (element1, &group1);
get_group (element2, &group2);
/* if one the elements has no group (anymore) we don't really care
* about the link */
if (!group1 || !group2) {
- GST_LOG ("one (or both) of the elements is not in a group, not interesting");
+ GST_LOG
+ ("one (or both) of the elements is not in a group, not interesting");
return;
}
/* see if group1 and group2 are still connected in any indirect way */
still_link = group_can_reach_group (group1, group2);
- GST_DEBUG ("group %p %s reach group %p", group1, (still_link ? "can":"can't"), group2);
+ GST_DEBUG ("group %p %s reach group %p", group1,
+ (still_link ? "can" : "can't"), group2);
if (!still_link) {
/* groups are really disconnected, migrate one group to a new chain */
- chain = create_chain (osched);
- chain_recursively_migrate_group (chain, group1);
+ chain = create_chain (osched);
+ chain_recursively_migrate_group (chain, group1);
- GST_DEBUG ("migrated group %p to new chain %p", group1, chain);
+ GST_DEBUG ("migrated group %p to new chain %p", group1, chain);
}
- }
- else {
- GST_DEBUG ("group %p still has direct link with group %p", group1, group2);
+ } else {
+ GST_DEBUG ("group %p still has direct link with group %p", group1,
+ group2);
}
}
/* hard part, groups are equal */
else {
gboolean still_link1, still_link2;
GstOptSchedulerGroup *group;
- GstElement *element = NULL; /* shut up gcc */
-
+ GstElement *element = NULL; /* shut up gcc */
+
/* since group1 == group2, it doesn't matter which group we take */
group = group1;
GSList *l;
GList *m;;
int linkcount;
-
- GST_LOG ( "elements still have links with other elements in the group");
-
+
+ GST_LOG ("elements still have links with other elements in the group");
+
while (group->elements)
- for (l = group->elements; l && l->data; l = l->next) {
- element = (GstElement*)l->data;
+ for (l = group->elements; l && l->data; l = l->next) {
+ element = (GstElement *) l->data;
if (GST_ELEMENT_IS_DECOUPLED (element))
continue;
-
+
linkcount = 0;
GST_LOG ("Examining %s\n", GST_ELEMENT_NAME (element));
for (m = GST_ELEMENT_PADS (element); m; m = m->next) {
GstElement *parent;
GstOptSchedulerGroup *peer_group;
- pad = (GstPad*)m->data;
+ pad = (GstPad *) m->data;
if (!pad || !GST_IS_REAL_PAD (pad))
continue;
peer = GST_PAD_PEER (pad);
if (!peer || !GST_IS_REAL_PAD (peer))
continue;
-
+
parent = GST_PAD_PARENT (GST_PAD_PEER (pad));
get_group (parent, &peer_group);
if (peer_group && peer_group != group) {
GST_LOG ("pad %s is linked with %s\n",
- GST_PAD_NAME (pad),
- GST_ELEMENT_NAME (parent));
+ GST_PAD_NAME (pad), GST_ELEMENT_NAME (parent));
linkcount++;
}
}
if (linkcount < 2) {
- group_dec_links_for_element (group, element);
+ group_dec_links_for_element (group, element);
remove_from_group (group, element);
}
/* if linkcount == 2, it will be unlinked later on */
else if (linkcount > 2) {
- g_warning ("opt: Can't handle element %s with 3 or more links, aborting",
- GST_ELEMENT_NAME (element));
+ g_warning
+ ("opt: Can't handle element %s with 3 or more links, aborting",
+ GST_ELEMENT_NAME (element));
return;
}
- }
+ }
/* Peer element will be catched during next iteration */
return;
}
if (!still_link1 && !still_link2)
return;
-
+
/* now check which one of the elements we can remove from the group */
if (still_link1) {
element = element2;
- }
- else if (still_link2) {
+ } else if (still_link2) {
element = element1;
}
/* we only remove elements that are not the entry point of a loop based
* group and are not decoupled */
if (!(group->entry == element &&
- group->type == GST_OPT_SCHEDULER_GROUP_LOOP) &&
- !GST_ELEMENT_IS_DECOUPLED (element)) {
+ group->type == GST_OPT_SCHEDULER_GROUP_LOOP) &&
+ !GST_ELEMENT_IS_DECOUPLED (element)) {
GST_LOG ("element is separated from the group");
-
+
/* have to decrement links to other groups from other pads */
- group_dec_links_for_element (group, element);
+ group_dec_links_for_element (group, element);
remove_from_group (group, element);
- }
- else {
+ } else {
GST_LOG ("element is decoupled or entry in loop based group");
}
}
}
static void
-gst_opt_scheduler_pad_select (GstScheduler *sched, GList *padlist)
+gst_opt_scheduler_pad_select (GstScheduler * sched, GList * padlist)
{
//GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
-
+
g_warning ("pad select, implement me");
}
/* a scheduler iteration is done by looping and scheduling the active chains */
static GstSchedulerState
-gst_opt_scheduler_iterate (GstScheduler *sched)
+gst_opt_scheduler_iterate (GstScheduler * sched)
{
GstSchedulerState state = GST_SCHEDULER_STATE_STOPPED;
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
ref_chain (chain);
/* if the chain is not disabled, schedule it */
if (!GST_OPT_SCHEDULER_CHAIN_IS_DISABLED (chain)) {
- GST_LOG ("scheduling chain %p", chain);
- schedule_chain (chain);
- scheduled = TRUE;
+ GST_LOG ("scheduling chain %p", chain);
+ schedule_chain (chain);
+ scheduled = TRUE;
}
/* don't schedule any more chains when in error */
if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) {
- GST_ERROR_OBJECT (sched, "in error state");
- break;
- }
- else if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) {
- GST_DEBUG_OBJECT (osched, "got interrupted, continue with next chain");
- osched->state = GST_OPT_SCHEDULER_STATE_RUNNING;
+ GST_ERROR_OBJECT (sched, "in error state");
+ break;
+ } else if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) {
+ GST_DEBUG_OBJECT (osched, "got interrupted, continue with next chain");
+ osched->state = GST_OPT_SCHEDULER_STATE_RUNNING;
}
chains = g_slist_next (chains);
if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) {
state = GST_SCHEDULER_STATE_ERROR;
break;
- }
- else {
+ } else {
/* if chains were scheduled, return our current state */
if (scheduled)
- state = GST_SCHEDULER_STATE (sched);
+ state = GST_SCHEDULER_STATE (sched);
/* if no chains were scheduled, we say we are stopped */
else {
- state = GST_SCHEDULER_STATE_STOPPED;
- break;
+ state = GST_SCHEDULER_STATE_STOPPED;
+ break;
}
}
if (iterations > 0)
static void
-gst_opt_scheduler_show (GstScheduler *sched)
+gst_opt_scheduler_show (GstScheduler * sched)
{
GstOptScheduler *osched = GST_OPT_SCHEDULER (sched);
GSList *chains;
while (chains) {
GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data;
GSList *groups = chain->groups;
+
chains = g_slist_next (chains);
- g_print ("+- chain %p: refcount %d, %d groups, %d enabled, flags %d\n",
- chain, chain->refcount, chain->num_groups, chain->num_enabled, chain->flags);
+ g_print ("+- chain %p: refcount %d, %d groups, %d enabled, flags %d\n",
+ chain, chain->refcount, chain->num_groups, chain->num_enabled,
+ chain->flags);
while (groups) {
GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data;
GSList *elements = group->elements;
+
groups = g_slist_next (groups);
- g_print (" +- group %p: refcount %d, %d elements, %d enabled, flags %d, entry %s, %s\n",
- group, group->refcount, group->num_elements, group->num_enabled, group->flags,
- (group->entry ? GST_ELEMENT_NAME (group->entry): "(none)"),
- (group->type == GST_OPT_SCHEDULER_GROUP_GET ? "get-based" : "loop-based") );
+ g_print
+ (" +- group %p: refcount %d, %d elements, %d enabled, flags %d, entry %s, %s\n",
+ group, group->refcount, group->num_elements, group->num_enabled,
+ group->flags,
+ (group->entry ? GST_ELEMENT_NAME (group->entry) : "(none)"),
+ (group->type ==
+ GST_OPT_SCHEDULER_GROUP_GET ? "get-based" : "loop-based"));
while (elements) {
- GstElement *element = (GstElement *) elements->data;
- elements = g_slist_next (elements);
+ GstElement *element = (GstElement *) elements->data;
- g_print (" +- element %s\n", GST_ELEMENT_NAME (element));
+ elements = g_slist_next (elements);
+
+ g_print (" +- element %s\n", GST_ELEMENT_NAME (element));
}
}
}
}
static void
-gst_opt_scheduler_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_opt_scheduler_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstOptScheduler *osched;
-
+
g_return_if_fail (GST_IS_OPT_SCHEDULER (object));
osched = GST_OPT_SCHEDULER (object);
}
static void
-gst_opt_scheduler_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_opt_scheduler_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstOptScheduler *osched;
-
+
g_return_if_fail (GST_IS_OPT_SCHEDULER (object));
osched = GST_OPT_SCHEDULER (object);
typedef struct _cothread cothread;
typedef struct _cothread_context cothread_context;
-struct _cothread_context {
- GSList * cothreads; /* contains all threads but main */
- cothread * main;
- cothread * current;
- GMutex * mutex;
- GstThread * gst_thread; /* the GstThread we're running from */
+struct _cothread_context
+{
+ GSList *cothreads; /* contains all threads but main */
+ cothread *main;
+ cothread *current;
+ GMutex *mutex;
+ GstThread *gst_thread; /* the GstThread we're running from */
};
-struct _cothread {
- GThread * thread;
- GCond * cond;
- cothread_func run;
- int argc;
- char ** argv;
- cothread * creator;
- gboolean die;
- cothread_context * context;
+struct _cothread
+{
+ GThread *thread;
+ GCond *cond;
+ cothread_func run;
+ int argc;
+ char **argv;
+ cothread *creator;
+ gboolean die;
+ cothread_context *context;
};
/* define functions
* Functions starting with "do_" are used by the scheduler.
*/
-static void do_cothreads_init (void *unused);
-static cothread_context *do_cothread_context_init (void);
-static void do_cothread_context_destroy (cothread_context *context);
-static cothread * cothread_create (cothread_context *context,
- cothread_func func,
- int argc,
- char **argv);
+static void do_cothreads_init (void *unused);
+static cothread_context *do_cothread_context_init (void);
+static void do_cothread_context_destroy (cothread_context * context);
+static cothread *cothread_create (cothread_context * context,
+ cothread_func func, int argc, char **argv);
#define do_cothread_create(new_cothread, context, func, argc, argv) \
G_STMT_START{ \
new_cothread = cothread_create ((context), (func), argc, (char**) (argv)); \
}G_STMT_END
-static void do_cothread_switch (cothread *to);
-static void do_cothread_setfunc (cothread *thread,
- cothread_context *context,
- cothread_func func,
- int argc,
- char **argv);
-static void do_cothread_destroy (cothread *thread);
-#define do_cothread_lock(cothread) /* FIXME */
-#define do_cothread_unlock(cothread) /* FIXME */
+static void do_cothread_switch (cothread * to);
+static void do_cothread_setfunc (cothread * thread,
+ cothread_context * context, cothread_func func, int argc, char **argv);
+static void do_cothread_destroy (cothread * thread);
+
+#define do_cothread_lock(cothread) /* FIXME */
+#define do_cothread_unlock(cothread) /* FIXME */
#define do_cothread_get_current(context) ((context)->current)
#define do_cothread_get_main(context) ((context)->main)
static void
do_cothreads_init (void *unused)
{
- if (!g_thread_supported ()) g_thread_init (NULL);
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
}
static cothread_context *
do_cothread_context_init (void)
ret->mutex = g_mutex_new ();
ret->cothreads = NULL;
ret->current = ret->main;
- ret->gst_thread = gst_thread_get_current();
+ ret->gst_thread = gst_thread_get_current ();
g_mutex_lock (ret->mutex);
-
+
return ret;
}
static void
-do_cothread_context_destroy (cothread_context *context)
+do_cothread_context_destroy (cothread_context * context)
{
- g_assert (g_thread_self() == context->main->thread);
-
+ g_assert (g_thread_self () == context->main->thread);
+
while (context->cothreads) {
do_cothread_destroy ((cothread *) context->cothreads->data);
}
g_mutex_unlock (context->mutex);
g_mutex_free (context->mutex);
-
+
g_free (context);
}
static void
-die (cothread *to_die) {
+die (cothread * to_die)
+{
g_cond_free (to_die->cond);
- to_die->context->cothreads = g_slist_remove (to_die->context->cothreads, to_die);
+ to_die->context->cothreads =
+ g_slist_remove (to_die->context->cothreads, to_die);
g_free (to_die);
g_thread_exit (to_die);
/* don't unlock the mutex here, the thread waiting for us to die is gonna take it */
}
+
static gpointer
run_new_thread (gpointer data)
{
cothread *self = (cothread *) data;
-
+
g_mutex_lock (self->context->mutex);
g_private_set (gst_thread_current, self->context->gst_thread);
g_cond_signal (self->creator->cond);
return NULL;
}
static cothread *
-cothread_create (cothread_context *context, cothread_func func, int argc, char **argv)
+cothread_create (cothread_context * context, cothread_func func, int argc,
+ char **argv)
{
cothread *ret;
-
+
if ((ret = g_new (cothread, 1)) == NULL) {
goto out1;
}
ret->argv = argv;
ret->creator = do_cothread_get_current (context);
ret->die = FALSE;
- ret->context = context;
- context->cothreads = g_slist_prepend (context->cothreads, ret);
+ ret->context = context;
+ context->cothreads = g_slist_prepend (context->cothreads, ret);
ret->thread = g_thread_create (run_new_thread, ret, TRUE, NULL);
- if (ret->thread == NULL) goto out2;
+ if (ret->thread == NULL)
+ goto out2;
g_cond_wait (do_cothread_get_current (context)->cond, context->mutex);
return ret;
return NULL;
}
-static void do_cothread_switch (cothread *to)
+static void
+do_cothread_switch (cothread * to)
{
- cothread *self = do_cothread_get_current(to->context);
-
+ cothread *self = do_cothread_get_current (to->context);
+
if (self == to) {
g_warning ("trying to switch to the same cothread, not allowed");
} else {
}
static void
-do_cothread_setfunc (cothread *thread, cothread_context *context,
- cothread_func func, int argc, char **argv)
+do_cothread_setfunc (cothread * thread, cothread_context * context,
+ cothread_func func, int argc, char **argv)
{
thread->run = func;
thread->argc = argc;
thread->argv = argv;
}
static void
-do_cothread_destroy (cothread *thread)
+do_cothread_destroy (cothread * thread)
{
GThread *join;
cothread_context *context;
+
g_return_if_fail (thread != thread->context->main);
g_return_if_fail (thread != thread->context->current);
-
+
thread->die = TRUE;
join = thread->thread;
context = thread->context;
g_thread_join (join);
/* the mutex was locked by the thread that we joined, no need to lock again */
}
-
-#define do_cothread_lock(cothread) /* FIXME */
-#define do_cothread_unlock(cothread) /* FIXME */
+
+#define do_cothread_lock(cothread) /* FIXME */
+#define do_cothread_unlock(cothread) /* FIXME */
#define do_cothread_get_current(context) ((context)->current)
#define do_cothread_get_main(context) ((context)->main)
by LL and unsigned long long values by ULL, lest
they be truncated by the compiler)
*/
-typedef union {
- long long q; /* Quadword (64-bit) value */
- unsigned long long uq; /* Unsigned Quadword */
- int d[2]; /* 2 Doubleword (32-bit) values */
- unsigned int ud[2]; /* 2 Unsigned Doubleword */
- short w[4]; /* 4 Word (16-bit) values */
- unsigned short uw[4]; /* 4 Unsigned Word */
- char b[8]; /* 8 Byte (8-bit) values */
- unsigned char ub[8]; /* 8 Unsigned Byte */
- float s[2]; /* Single-precision (32-bit) value */
+typedef union
+{
+ long long q; /* Quadword (64-bit) value */
+ unsigned long long uq; /* Unsigned Quadword */
+ int d[2]; /* 2 Doubleword (32-bit) values */
+ unsigned int ud[2]; /* 2 Unsigned Doubleword */
+ short w[4]; /* 4 Word (16-bit) values */
+ unsigned short uw[4]; /* 4 Unsigned Word */
+ char b[8]; /* 8 Byte (8-bit) values */
+ unsigned char ub[8]; /* 8 Unsigned Byte */
+ float s[2]; /* Single-precision (32-bit) value */
} mmx_t;
/* Function to test if multimedia instructions are supported...
*/
inline extern int
-mm_support(void)
+mm_support (void)
{
- /* Returns 1 if MMX instructions are supported,
- 3 if Cyrix MMX and Extended MMX instructions are supported
- 5 if AMD MMX and 3DNow! instructions are supported
- 0 if hardware does not support any of these
- */
- register int rval = 0;
-
- __asm__ __volatile__ (
- /* See if CPUID instruction is supported ... */
- /* ... Get copies of EFLAGS into eax and ecx */
- "pushf\n\t"
- "popl %%eax\n\t"
- "movl %%eax, %%ecx\n\t"
-
- /* ... Toggle the ID bit in one copy and store */
- /* to the EFLAGS reg */
- "xorl $0x200000, %%eax\n\t"
- "push %%eax\n\t"
- "popf\n\t"
-
- /* ... Get the (hopefully modified) EFLAGS */
- "pushf\n\t"
- "popl %%eax\n\t"
-
- /* ... Compare and test result */
- "xorl %%eax, %%ecx\n\t"
- "testl $0x200000, %%ecx\n\t"
- "jz NotSupported1\n\t" /* Nothing supported */
-
-
- /* Get standard CPUID information, and
- go to a specific vendor section */
- "movl $0, %%eax\n\t"
- "cpuid\n\t"
-
- /* Check for Intel */
- "cmpl $0x756e6547, %%ebx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x49656e69, %%edx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x6c65746e, %%ecx\n"
- "jne TryAMD\n\t"
- "jmp Intel\n\t"
-
- /* Check for AMD */
- "\nTryAMD:\n\t"
- "cmpl $0x68747541, %%ebx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x69746e65, %%edx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x444d4163, %%ecx\n"
- "jne TryCyrix\n\t"
- "jmp AMD\n\t"
-
- /* Check for Cyrix */
- "\nTryCyrix:\n\t"
- "cmpl $0x69727943, %%ebx\n\t"
- "jne NotSupported2\n\t"
- "cmpl $0x736e4978, %%edx\n\t"
- "jne NotSupported3\n\t"
- "cmpl $0x64616574, %%ecx\n\t"
- "jne NotSupported4\n\t"
- /* Drop through to Cyrix... */
-
-
- /* Cyrix Section */
- /* See if extended CPUID is supported */
- "movl $0x80000000, %%eax\n\t"
- "cpuid\n\t"
- "cmpl $0x80000000, %%eax\n\t"
- "jl MMXtest\n\t" /* Try standard CPUID instead */
-
- /* Extended CPUID supported, so get extended features */
- "movl $0x80000001, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%eax\n\t" /* Test for MMX */
- "jz NotSupported5\n\t" /* MMX not supported */
- "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
- "jnz EMMXSupported\n\t"
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n"
- "EMMXSupported:\n\t"
- "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
- "jmp Return\n\t"
-
-
- /* AMD Section */
- "AMD:\n\t"
-
- /* See if extended CPUID is supported */
- "movl $0x80000000, %%eax\n\t"
- "cpuid\n\t"
- "cmpl $0x80000000, %%eax\n\t"
- "jl MMXtest\n\t" /* Try standard CPUID instead */
-
- /* Extended CPUID supported, so get extended features */
- "movl $0x80000001, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported6\n\t" /* MMX not supported */
- "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
- "jnz ThreeDNowSupported\n\t"
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n"
- "ThreeDNowSupported:\n\t"
- "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
- "jmp Return\n\t"
-
-
- /* Intel Section */
- "Intel:\n\t"
-
- /* Check for MMX */
- "MMXtest:\n\t"
- "movl $1, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported7\n\t" /* MMX Not supported */
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\t"
-
- /* Nothing supported */
- "\nNotSupported1:\n\t"
- "#movl $101, %0:\n\n\t"
- "\nNotSupported2:\n\t"
- "#movl $102, %0:\n\n\t"
- "\nNotSupported3:\n\t"
- "#movl $103, %0:\n\n\t"
- "\nNotSupported4:\n\t"
- "#movl $104, %0:\n\n\t"
- "\nNotSupported5:\n\t"
- "#movl $105, %0:\n\n\t"
- "\nNotSupported6:\n\t"
- "#movl $106, %0:\n\n\t"
- "\nNotSupported7:\n\t"
- "#movl $107, %0:\n\n\t"
- "movl $0, %0:\n\n\t"
-
- "Return:\n\t"
- : "=a" (rval)
- : /* no input */
- : "eax", "ebx", "ecx", "edx"
- );
-
- /* Return */
- return(rval);
+ /* Returns 1 if MMX instructions are supported,
+ 3 if Cyrix MMX and Extended MMX instructions are supported
+ 5 if AMD MMX and 3DNow! instructions are supported
+ 0 if hardware does not support any of these
+ */
+ register int rval = 0;
+
+ __asm__ __volatile__ (
+ /* See if CPUID instruction is supported ... */
+ /* ... Get copies of EFLAGS into eax and ecx */
+ "pushf\n\t" "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
+ /* ... Toggle the ID bit in one copy and store */
+ /* to the EFLAGS reg */
+ "xorl $0x200000, %%eax\n\t" "push %%eax\n\t" "popf\n\t"
+ /* ... Get the (hopefully modified) EFLAGS */
+ "pushf\n\t" "popl %%eax\n\t"
+ /* ... Compare and test result */
+ "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* Nothing supported */
+ /* Get standard CPUID information, and
+ go to a specific vendor section */
+ "movl $0, %%eax\n\t" "cpuid\n\t"
+ /* Check for Intel */
+ "cmpl $0x756e6547, %%ebx\n\t"
+ "jne TryAMD\n\t"
+ "cmpl $0x49656e69, %%edx\n\t"
+ "jne TryAMD\n\t"
+ "cmpl $0x6c65746e, %%ecx\n" "jne TryAMD\n\t" "jmp Intel\n\t"
+ /* Check for AMD */
+ "\nTryAMD:\n\t"
+ "cmpl $0x68747541, %%ebx\n\t"
+ "jne TryCyrix\n\t"
+ "cmpl $0x69746e65, %%edx\n\t"
+ "jne TryCyrix\n\t"
+ "cmpl $0x444d4163, %%ecx\n" "jne TryCyrix\n\t" "jmp AMD\n\t"
+ /* Check for Cyrix */
+ "\nTryCyrix:\n\t"
+ "cmpl $0x69727943, %%ebx\n\t"
+ "jne NotSupported2\n\t"
+ "cmpl $0x736e4978, %%edx\n\t"
+ "jne NotSupported3\n\t"
+ "cmpl $0x64616574, %%ecx\n\t" "jne NotSupported4\n\t"
+ /* Drop through to Cyrix... */
+ /* Cyrix Section */
+ /* See if extended CPUID is supported */
+ "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Try standard CPUID instead */
+ /* Extended CPUID supported, so get extended features */
+ "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */
+ "jz NotSupported5\n\t" /* MMX not supported */
+ "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
+ "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
+ "jmp Return\n\t"
+ /* AMD Section */
+ "AMD:\n\t"
+ /* See if extended CPUID is supported */
+ "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Try standard CPUID instead */
+ /* Extended CPUID supported, so get extended features */
+ "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
+ "jz NotSupported6\n\t" /* MMX not supported */
+ "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
+ "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
+ "jmp Return\n\t"
+ /* Intel Section */
+ "Intel:\n\t"
+ /* Check for MMX */
+ "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
+ "jz NotSupported7\n\t" /* MMX Not supported */
+ "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\t"
+ /* Nothing supported */
+ "\nNotSupported1:\n\t"
+ "#movl $101, %0:\n\n\t"
+ "\nNotSupported2:\n\t"
+ "#movl $102, %0:\n\n\t"
+ "\nNotSupported3:\n\t"
+ "#movl $103, %0:\n\n\t"
+ "\nNotSupported4:\n\t"
+ "#movl $104, %0:\n\n\t"
+ "\nNotSupported5:\n\t"
+ "#movl $105, %0:\n\n\t"
+ "\nNotSupported6:\n\t"
+ "#movl $106, %0:\n\n\t"
+ "\nNotSupported7:\n\t"
+ "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval)
+ : /* no input */
+ :"eax", "ebx", "ecx", "edx");
+
+ /* Return */
+ return (rval);
}
/* Function to test if mmx instructions are supported...
*/
inline extern int
-mmx_ok(void)
+mmx_ok (void)
{
- /* Returns 1 if MMX instructions are supported, 0 otherwise */
- return ( mm_support() & 0x1 );
+ /* Returns 1 if MMX instructions are supported, 0 otherwise */
+ return (mm_support () & 0x1);
}
#endif
#endif
-
by LL and unsigned long long values by ULL, lest
they be truncated by the compiler)
*/
-typedef union {
- float sf[4]; /* Single-precision (32-bit) value */
+typedef union
+{
+ float sf[4]; /* Single-precision (32-bit) value */
} __attribute__ ((aligned (16))) sse_t; /* On a 16 byte (128-bit) boundary */
/* Function to test if multimedia instructions are supported...
*/
inline extern int
-mm_support(void)
+mm_support (void)
{
- /* Returns 1 if MMX instructions are supported,
- 3 if Cyrix MMX and Extended MMX instructions are supported
- 5 if AMD MMX and 3DNow! instructions are supported
- 9 if MMX and SSE instructions are supported
- 0 if hardware does not support any of these
- */
- register int rval = 0;
-
- __asm__ __volatile__ (
- /* See if CPUID instruction is supported ... */
- /* ... Get copies of EFLAGS into eax and ecx */
- "pushf\n\t"
- "popl %%eax\n\t"
- "movl %%eax, %%ecx\n\t"
-
- /* ... Toggle the ID bit in one copy and store */
- /* to the EFLAGS reg */
- "xorl $0x200000, %%eax\n\t"
- "push %%eax\n\t"
- "popf\n\t"
-
- /* ... Get the (hopefully modified) EFLAGS */
- "pushf\n\t"
- "popl %%eax\n\t"
-
- /* ... Compare and test result */
- "xorl %%eax, %%ecx\n\t"
- "testl $0x200000, %%ecx\n\t"
- "jz NotSupported1\n\t" /* CPUID not supported */
-
-
- /* Get standard CPUID information, and
- go to a specific vendor section */
- "movl $0, %%eax\n\t"
- "cpuid\n\t"
-
- /* Check for Intel */
- "cmpl $0x756e6547, %%ebx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x49656e69, %%edx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x6c65746e, %%ecx\n"
- "jne TryAMD\n\t"
- "jmp Intel\n\t"
-
- /* Check for AMD */
- "\nTryAMD:\n\t"
- "cmpl $0x68747541, %%ebx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x69746e65, %%edx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x444d4163, %%ecx\n"
- "jne TryCyrix\n\t"
- "jmp AMD\n\t"
-
- /* Check for Cyrix */
- "\nTryCyrix:\n\t"
- "cmpl $0x69727943, %%ebx\n\t"
- "jne NotSupported2\n\t"
- "cmpl $0x736e4978, %%edx\n\t"
- "jne NotSupported3\n\t"
- "cmpl $0x64616574, %%ecx\n\t"
- "jne NotSupported4\n\t"
- /* Drop through to Cyrix... */
-
-
- /* Cyrix Section */
- /* See if extended CPUID level 80000001 is supported */
- /* The value of CPUID/80000001 for the 6x86MX is undefined
- according to the Cyrix CPU Detection Guide (Preliminary
- Rev. 1.01 table 1), so we'll check the value of eax for
- CPUID/0 to see if standard CPUID level 2 is supported.
- According to the table, the only CPU which supports level
- 2 is also the only one which supports extended CPUID levels.
- */
- "cmpl $0x2, %%eax\n\t"
- "jne MMXtest\n\t" /* Use standard CPUID instead */
-
- /* Extended CPUID supported (in theory), so get extended
- features */
- "movl $0x80000001, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%eax\n\t" /* Test for MMX */
- "jz NotSupported5\n\t" /* MMX not supported */
- "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
- "jnz EMMXSupported\n\t"
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n"
- "EMMXSupported:\n\t"
- "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
- "jmp Return\n\t"
-
-
- /* AMD Section */
- "AMD:\n\t"
-
- /* See if extended CPUID is supported */
- "movl $0x80000000, %%eax\n\t"
- "cpuid\n\t"
- "cmpl $0x80000000, %%eax\n\t"
- "jl MMXtest\n\t" /* Use standard CPUID instead */
-
- /* Extended CPUID supported, so get extended features */
- "movl $0x80000001, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported6\n\t" /* MMX not supported */
- "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
- "jnz ThreeDNowSupported\n\t"
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n"
- "ThreeDNowSupported:\n\t"
- "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
- "jmp Return\n\t"
-
-
- /* Intel Section */
- "Intel:\n\t"
-
- /* Check for SSE */
- "SSEtest:\n\t"
- "movl $1, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x02000000, %%edx\n\t" /* Test for SSE */
- "jz MMXtest\n\t" /* SSE Not supported */
- "movl $9, %0:\n\n\t" /* SSE Supported */
- "jmp Return\n\t"
-
- /* Check for MMX */
- "MMXtest:\n\t"
- "movl $1, %%eax\n\t"
- "cpuid\n\t"
- "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported7\n\t" /* MMX Not supported */
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\t"
-
- /* Nothing supported */
- "\nNotSupported1:\n\t"
- "#movl $101, %0:\n\n\t"
- "\nNotSupported2:\n\t"
- "#movl $102, %0:\n\n\t"
- "\nNotSupported3:\n\t"
- "#movl $103, %0:\n\n\t"
- "\nNotSupported4:\n\t"
- "#movl $104, %0:\n\n\t"
- "\nNotSupported5:\n\t"
- "#movl $105, %0:\n\n\t"
- "\nNotSupported6:\n\t"
- "#movl $106, %0:\n\n\t"
- "\nNotSupported7:\n\t"
- "#movl $107, %0:\n\n\t"
- "movl $0, %0:\n\n\t"
-
- "Return:\n\t"
- : "=a" (rval)
- : /* no input */
- : "eax", "ebx", "ecx", "edx"
- );
-
- /* Return */
- return(rval);
+ /* Returns 1 if MMX instructions are supported,
+ 3 if Cyrix MMX and Extended MMX instructions are supported
+ 5 if AMD MMX and 3DNow! instructions are supported
+ 9 if MMX and SSE instructions are supported
+ 0 if hardware does not support any of these
+ */
+ register int rval = 0;
+
+ __asm__ __volatile__ (
+ /* See if CPUID instruction is supported ... */
+ /* ... Get copies of EFLAGS into eax and ecx */
+ "pushf\n\t" "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
+ /* ... Toggle the ID bit in one copy and store */
+ /* to the EFLAGS reg */
+ "xorl $0x200000, %%eax\n\t" "push %%eax\n\t" "popf\n\t"
+ /* ... Get the (hopefully modified) EFLAGS */
+ "pushf\n\t" "popl %%eax\n\t"
+ /* ... Compare and test result */
+ "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
+ /* Get standard CPUID information, and
+ go to a specific vendor section */
+ "movl $0, %%eax\n\t" "cpuid\n\t"
+ /* Check for Intel */
+ "cmpl $0x756e6547, %%ebx\n\t"
+ "jne TryAMD\n\t"
+ "cmpl $0x49656e69, %%edx\n\t"
+ "jne TryAMD\n\t"
+ "cmpl $0x6c65746e, %%ecx\n" "jne TryAMD\n\t" "jmp Intel\n\t"
+ /* Check for AMD */
+ "\nTryAMD:\n\t"
+ "cmpl $0x68747541, %%ebx\n\t"
+ "jne TryCyrix\n\t"
+ "cmpl $0x69746e65, %%edx\n\t"
+ "jne TryCyrix\n\t"
+ "cmpl $0x444d4163, %%ecx\n" "jne TryCyrix\n\t" "jmp AMD\n\t"
+ /* Check for Cyrix */
+ "\nTryCyrix:\n\t"
+ "cmpl $0x69727943, %%ebx\n\t"
+ "jne NotSupported2\n\t"
+ "cmpl $0x736e4978, %%edx\n\t"
+ "jne NotSupported3\n\t"
+ "cmpl $0x64616574, %%ecx\n\t" "jne NotSupported4\n\t"
+ /* Drop through to Cyrix... */
+ /* Cyrix Section */
+ /* See if extended CPUID level 80000001 is supported */
+ /* The value of CPUID/80000001 for the 6x86MX is undefined
+ according to the Cyrix CPU Detection Guide (Preliminary
+ Rev. 1.01 table 1), so we'll check the value of eax for
+ CPUID/0 to see if standard CPUID level 2 is supported.
+ According to the table, the only CPU which supports level
+ 2 is also the only one which supports extended CPUID levels.
+ */
+ "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */
+ /* Extended CPUID supported (in theory), so get extended
+ features */
+ "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */
+ "jz NotSupported5\n\t" /* MMX not supported */
+ "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
+ "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
+ "jmp Return\n\t"
+ /* AMD Section */
+ "AMD:\n\t"
+ /* See if extended CPUID is supported */
+ "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */
+ /* Extended CPUID supported, so get extended features */
+ "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
+ "jz NotSupported6\n\t" /* MMX not supported */
+ "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
+ "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
+ "jmp Return\n\t"
+ /* Intel Section */
+ "Intel:\n\t"
+ /* Check for SSE */
+ "SSEtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x02000000, %%edx\n\t" /* Test for SSE */
+ "jz MMXtest\n\t" /* SSE Not supported */
+ "movl $9, %0:\n\n\t" /* SSE Supported */
+ "jmp Return\n\t"
+ /* Check for MMX */
+ "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
+ "jz NotSupported7\n\t" /* MMX Not supported */
+ "movl $1, %0:\n\n\t" /* MMX Supported */
+ "jmp Return\n\t"
+ /* Nothing supported */
+ "\nNotSupported1:\n\t"
+ "#movl $101, %0:\n\n\t"
+ "\nNotSupported2:\n\t"
+ "#movl $102, %0:\n\n\t"
+ "\nNotSupported3:\n\t"
+ "#movl $103, %0:\n\n\t"
+ "\nNotSupported4:\n\t"
+ "#movl $104, %0:\n\n\t"
+ "\nNotSupported5:\n\t"
+ "#movl $105, %0:\n\n\t"
+ "\nNotSupported6:\n\t"
+ "#movl $106, %0:\n\n\t"
+ "\nNotSupported7:\n\t"
+ "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval)
+ : /* no input */
+ :"eax", "ebx", "ecx", "edx");
+
+ /* Return */
+ return (rval);
}
/* Function to test if sse instructions are supported...
*/
inline extern int
-sse_ok(void)
+sse_ok (void)
{
- /* Returns 1 if SSE instructions are supported, 0 otherwise */
- return ( (mm_support() & 0x8) >> 3 );
+ /* Returns 1 if SSE instructions are supported, 0 otherwise */
+ return ((mm_support () & 0x8) >> 3);
}
#endif
/* MOVe MaSK from Packed Single-fp
*/
#ifdef SSE_TRACE
- #define movmskps(xmmreg, reg) \
+#define movmskps(xmmreg, reg) \
{ \
fprintf(stderr, "movmskps()\n"); \
__asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg) \
}
#else
- #define movmskps(xmmreg, reg) \
+#define movmskps(xmmreg, reg) \
__asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg)
#endif
/* Parallel MOVe MaSK from mmx reg to 32-bit reg
*/
#ifdef SSE_TRACE
- #define pmovmskb(mmreg, reg) \
+#define pmovmskb(mmreg, reg) \
{ \
fprintf(stderr, "movmskps()\n"); \
__asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg) \
}
#else
- #define pmovmskb(mmreg, reg) \
+#define pmovmskb(mmreg, reg) \
__asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg)
#endif
/* Fp and mmX ReSTORe state
*/
#ifdef SSE_TRACE
- #define fxrstor(mem) \
+#define fxrstor(mem) \
{ \
fprintf(stderr, "fxrstor()\n"); \
__asm__ __volatile__ ("fxrstor %0" \
: "X" (mem)) \
}
#else
- #define fxrstor(mem) \
+#define fxrstor(mem) \
__asm__ __volatile__ ("fxrstor %0" \
: /* nothing */ \
: "X" (mem))
/* Fp and mmX SAVE state
*/
#ifdef SSE_TRACE
- #define fxsave(mem) \
+#define fxsave(mem) \
{ \
fprintf(stderr, "fxsave()\n"); \
__asm__ __volatile__ ("fxsave %0" \
: "X" (mem)) \
}
#else
- #define fxsave(mem) \
+#define fxsave(mem) \
__asm__ __volatile__ ("fxsave %0" \
: /* nothing */ \
: "X" (mem))
/* STore streaMing simd eXtensions Control/Status Register
*/
#ifdef SSE_TRACE
- #define stmxcsr(mem) \
+#define stmxcsr(mem) \
{ \
fprintf(stderr, "stmxcsr()\n"); \
__asm__ __volatile__ ("stmxcsr %0" \
: "X" (mem)) \
}
#else
- #define stmxcsr(mem) \
+#define stmxcsr(mem) \
__asm__ __volatile__ ("stmxcsr %0" \
: /* nothing */ \
: "X" (mem))
/* LoaD streaMing simd eXtensions Control/Status Register
*/
#ifdef SSE_TRACE
- #define ldmxcsr(mem) \
+#define ldmxcsr(mem) \
{ \
fprintf(stderr, "ldmxcsr()\n"); \
__asm__ __volatile__ ("ldmxcsr %0" \
: "X" (mem)) \
}
#else
- #define ldmxcsr(mem) \
+#define ldmxcsr(mem) \
__asm__ __volatile__ ("ldmxcsr %0" \
: /* nothing */ \
: "X" (mem))
occuring after fence in source code.
*/
#ifdef SSE_TRACE
- #define sfence() \
+#define sfence() \
{ \
fprintf(stderr, "sfence()\n"); \
__asm__ __volatile__ ("sfence\n\t") \
}
#else
- #define sfence() \
+#define sfence() \
__asm__ __volatile__ ("sfence\n\t")
#endif
*/
#ifdef SSE_TRACE
#else
- #define prefetch(mem, hint) \
+#define prefetch(mem, hint) \
__asm__ __volatile__ ("prefetch" #hint " %0" \
: /* nothing */ \
: "X" (mem))
- #define prefetcht0(mem) prefetch(mem, t0)
- #define prefetcht1(mem) prefetch(mem, t1)
- #define prefetcht2(mem) prefetch(mem, t2)
- #define prefetchnta(mem) prefetch(mem, nta)
+#define prefetcht0(mem) prefetch(mem, t0)
+#define prefetcht1(mem) prefetch(mem, t1)
+#define prefetcht2(mem) prefetch(mem, t2)
+#define prefetchnta(mem) prefetch(mem, nta)
#endif
#endif
-
#include <gst/gstversion.h>
#include "bytestream.h"
-GST_DEBUG_CATEGORY_STATIC(debug_bs);
+GST_DEBUG_CATEGORY_STATIC (debug_bs);
#define GST_CAT_DEFAULT debug_bs
static guint8 *gst_bytestream_assemble (GstByteStream * bs, guint32 len);
static inline void
-gst_bytestream_init (GstByteStream *bs)
+gst_bytestream_init (GstByteStream * bs)
{
bs->event = NULL;
bs->buflist = NULL;
bs->in_seek = FALSE;
}
static inline void
-gst_bytestream_exit (GstByteStream *bs)
+gst_bytestream_exit (GstByteStream * bs)
{
GSList *walk;
if (bs->event)
gst_event_unref (bs->event);
-
+
walk = bs->buflist;
while (walk) {
gst_buffer_unref (GST_BUFFER (walk->data));
g_free (bs->assembled);
}
+
/**
* gst_bytestream_new:
* @pad: the pad to attach the bytestream to
gst_bytestream_exit (bs);
g_free (bs);
}
+
void
-gst_bytestream_reset (GstByteStream *bs)
+gst_bytestream_reset (GstByteStream * bs)
{
/* free all data */
gst_bytestream_exit (bs);
/* reset data to clean state */
gst_bytestream_init (bs);
}
+
/* HOW THIS WORKS:
*
* The fundamental structure is a singly-linked list of buffers. The
* else add it onto the head of the
*/
static gboolean
-gst_bytestream_get_next_buf (GstByteStream *bs)
+gst_bytestream_get_next_buf (GstByteStream * bs)
{
GstBuffer *nextbuf, *lastbuf, *headbuf;
GSList *end;
gst_buffer_unref (nextbuf);
/* if we can't, we just append this buffer */
- }
- else {
+ } else {
GST_DEBUG ("get_next_buf: adding new buffer to the end of the list");
end = g_slist_append (end, nextbuf);
/* also need to increment length of list and buffer count */
}
/* if there are no buffers in the list */
- }
- else {
+ } else {
GST_DEBUG ("get_next_buf: buflist is empty, adding new buffer to list");
/* put this on the end of the list */
bs->buflist = g_slist_append (bs->buflist, nextbuf);
bs->headbufavail = GST_BUFFER_SIZE (nextbuf);
}
- /* a zero offset is a indication that we might need to set the timestamp */
- if (bs->offset == 0LL){
+ /* a zero offset is a indication that we might need to set the timestamp */
+ if (bs->offset == 0LL) {
headbuf = GST_BUFFER (bs->buflist->data);
- bs->offset = GST_BUFFER_OFFSET(headbuf);
+ bs->offset = GST_BUFFER_OFFSET (headbuf);
}
-
+
return TRUE;
}
static gboolean
-gst_bytestream_fill_bytes (GstByteStream *bs, guint32 len)
+gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len)
{
/* as long as we don't have enough, we get more buffers */
while (bs->listavail < len) {
- GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d", bs->listavail, len);
+ GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d",
+ bs->listavail, len);
if (!gst_bytestream_get_next_buf (bs))
return FALSE;
}
* Returns: The number of bytes successfully peeked.
*/
guint32
-gst_bytestream_peek (GstByteStream *bs, GstBuffer **buf, guint32 len)
+gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len)
{
GstBuffer *headbuf, *retbuf = NULL;
g_return_val_if_fail (bs != NULL, 0);
g_return_val_if_fail (buf != NULL, 0);
-
+
if (len == 0)
return 0;
if (!gst_bytestream_fill_bytes (bs, len)) {
/* we must have an event coming up */
if (bs->listavail > 0) {
- /* we have some data left, len will be shrunk to the amount of data available */
- len = bs->listavail;
- }
- else {
- /* there is no data */
- *buf = retbuf;
- return 0;
+ /* we have some data left, len will be shrunk to the amount of data available */
+ len = bs->listavail;
+ } else {
+ /* there is no data */
+ *buf = retbuf;
+ return 0;
}
}
GST_DEBUG ("peek: there are now %d bytes in the list", bs->listavail);
/* if the requested bytes are in the current buffer */
GST_DEBUG ("peek: headbufavail is %d", bs->headbufavail);
if (len <= bs->headbufavail) {
- GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)", len, bs->headbufavail);
+ GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)",
+ len, bs->headbufavail);
/* create a sub-buffer of the headbuf */
- retbuf = gst_buffer_create_sub (headbuf, GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len);
- GST_BUFFER_OFFSET (retbuf) = GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) - bs->headbufavail;
+ retbuf =
+ gst_buffer_create_sub (headbuf,
+ GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len);
+ GST_BUFFER_OFFSET (retbuf) =
+ GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) -
+ bs->headbufavail;
}
/* otherwise we need to figure out how to assemble one */
* Returns: The number of bytes successfully peeked.
*/
guint32
-gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len)
+gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, guint32 len)
{
GstBuffer *headbuf;
/* make sure we have enough */
GST_DEBUG ("peek_bytes: there are %d bytes in the list", bs->listavail);
if (len > bs->listavail) {
- if (!gst_bytestream_fill_bytes (bs, len)){
+ if (!gst_bytestream_fill_bytes (bs, len)) {
/* we must have an event coming up */
- if (bs->listavail > 0){
- /* we have some data left, len will be shrunk to the amount of data available */
- len = bs->listavail;
- }
- else {
- /* there is no data */
- *data = NULL;
- return 0;
+ if (bs->listavail > 0) {
+ /* we have some data left, len will be shrunk to the amount of data available */
+ len = bs->listavail;
+ } else {
+ /* there is no data */
+ *data = NULL;
+ return 0;
}
}
GST_DEBUG ("peek_bytes: there are now %d bytes in the list", bs->listavail);
/* if the requested bytes are in the current buffer */
GST_DEBUG ("peek_bytes: headbufavail is %d", bs->headbufavail);
if (len <= bs->headbufavail) {
- GST_DEBUG ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)", len, bs->headbufavail);
+ GST_DEBUG
+ ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)",
+ len, bs->headbufavail);
/* create a sub-buffer of the headbuf */
- *data = GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) - bs->headbufavail);
+ *data =
+ GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) -
+ bs->headbufavail);
}
/* otherwise we need to figure out how to assemble one */
return len;
}
-static guint8*
-gst_bytestream_assemble (GstByteStream *bs, guint32 len)
+static guint8 *
+gst_bytestream_assemble (GstByteStream * bs, guint32 len)
{
guint8 *data = g_malloc (len);
GSList *walk;
/* copy the data from the curbuf */
buf = GST_BUFFER (bs->buflist->data);
- GST_DEBUG ("assemble: copying %d bytes from curbuf at %d to *data", bs->headbufavail,
- GST_BUFFER_SIZE (buf) - bs->headbufavail);
- memcpy (data, GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf) - bs->headbufavail, bs->headbufavail);
+ GST_DEBUG ("assemble: copying %d bytes from curbuf at %d to *data",
+ bs->headbufavail, GST_BUFFER_SIZE (buf) - bs->headbufavail);
+ memcpy (data,
+ GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf) - bs->headbufavail,
+ bs->headbufavail);
copied += bs->headbufavail;
/* asumption is made that the buffers all exist in the list */
while (copied < len) {
buf = GST_BUFFER (walk->data);
if (GST_BUFFER_SIZE (buf) < (len - copied)) {
- GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", GST_BUFFER_SIZE (buf), copied);
+ GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
+ GST_BUFFER_SIZE (buf), copied);
memcpy (data + copied, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
copied += GST_BUFFER_SIZE (buf);
- }
- else {
- GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", len - copied, copied);
+ } else {
+ GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
+ len - copied, copied);
memcpy (data + copied, GST_BUFFER_DATA (buf), len - copied);
copied = len;
}
* Returns: TRUE if the number of bytes could be flushed.
*/
gboolean
-gst_bytestream_flush (GstByteStream *bs, guint32 len)
+gst_bytestream_flush (GstByteStream * bs, guint32 len)
{
GST_DEBUG ("flush: flushing %d bytes", len);
* with gst_bytestream_peek() or gst_bytestream_peek_bytes().
*/
void
-gst_bytestream_flush_fast (GstByteStream *bs, guint32 len)
+gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
{
GstBuffer *headbuf;
if (len == 0)
return;
-
+
g_assert (len <= bs->listavail);
if (bs->assembled) {
while (len > 0) {
headbuf = GST_BUFFER (bs->buflist->data);
- GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %" G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf),
- GST_BUFFER_OFFSET (headbuf));
+ GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %"
+ G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf),
+ GST_BUFFER_OFFSET (headbuf));
/* if there's enough to complete the flush */
if (bs->headbufavail > len) {
len = 0;
/* otherwise we have to trim the whole buffer */
- }
- else {
+ } else {
GST_DEBUG ("flush: removing head buffer completely");
/* remove it from the list */
bs->buflist = g_slist_delete_link (bs->buflist, bs->buflist);
if (bs->buflist) {
bs->headbufavail = GST_BUFFER_SIZE (GST_BUFFER (bs->buflist->data));
GST_DEBUG ("flush: next headbuf is %d bytes", bs->headbufavail);
- }
- else {
+ } else {
GST_DEBUG ("flush: no more bytes at all");
}
}
* Returns: TRUE when the seek succeeded.
*/
gboolean
-gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType method)
+gst_bytestream_seek (GstByteStream * bs, gint64 offset, GstSeekType method)
{
GstRealPad *peer;
-
+
g_return_val_if_fail (bs != NULL, FALSE);
-
+
peer = GST_RPAD_PEER (bs->pad);
GST_DEBUG ("bs: send event\n");
- if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (
- GST_FORMAT_BYTES |
- (method & GST_SEEK_METHOD_MASK) |
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- offset)))
- {
+ if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (GST_FORMAT_BYTES |
+ (method & GST_SEEK_METHOD_MASK) |
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
gst_bytestream_flush_fast (bs, bs->listavail);
/* we set the seek flag here. We cannot pull the pad here
* bacause a seek might occur outisde of the pads cothread context */
bs->in_seek = TRUE;
-
+
return TRUE;
}
GST_DEBUG ("bs: send event failed\n");
* Returns: the offset or -1 on error.
*/
guint64
-gst_bytestream_tell (GstByteStream *bs)
+gst_bytestream_tell (GstByteStream * bs)
{
GstFormat format;
gint64 value;
-
+
g_return_val_if_fail (bs != NULL, -1);
format = GST_FORMAT_BYTES;
- if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format, &value)) {
+ if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format,
+ &value)) {
return value - bs->listavail;
}
-
+
return -1;
}
* Returns: the total length or -1 on error.
*/
guint64
-gst_bytestream_length (GstByteStream *bs)
+gst_bytestream_length (GstByteStream * bs)
{
GstFormat format;
gint64 value;
-
+
g_return_val_if_fail (bs != NULL, -1);
format = GST_FORMAT_BYTES;
- if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_TOTAL, &format, &value))
+ if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_TOTAL, &format, &value))
return value;
-
+
return -1;
}
* Returns: The number of bytes successfully read.
*/
guint32
-gst_bytestream_read (GstByteStream *bs, GstBuffer** buf, guint32 len)
+gst_bytestream_read (GstByteStream * bs, GstBuffer ** buf, guint32 len)
{
guint32 len_peeked;
g_return_val_if_fail (bs != NULL, -1);
-
+
len_peeked = gst_bytestream_peek (bs, buf, len);
if (len_peeked == 0)
return 0;
* Returns: TRUE if the hint was accepted
*/
gboolean
-gst_bytestream_size_hint (GstByteStream *bs, guint32 size)
+gst_bytestream_size_hint (GstByteStream * bs, guint32 size)
{
GstEvent *event;
* before reading more bytes from the stream.
*/
void
-gst_bytestream_get_status (GstByteStream *bs,
- guint32 *avail_out,
- GstEvent **event_out)
+gst_bytestream_get_status (GstByteStream * bs,
+ guint32 * avail_out, GstEvent ** event_out)
{
if (avail_out)
*avail_out = bs->listavail;
* Returns: a timestamp
*/
guint64
-gst_bytestream_get_timestamp (GstByteStream *bs)
+gst_bytestream_get_timestamp (GstByteStream * bs)
{
GstBuffer *headbuf;
buf = GST_BUFFER (walk->data);
walk = g_slist_next (walk);
- GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT " and is %d bytes long",
- GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
+ GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT
+ " and is %d bytes long", GST_BUFFER_OFFSET (buf),
+ GST_BUFFER_SIZE (buf));
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (debug_bs, "bytestream", 0, "bytestream library");
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstbytestream",
- "a byte-oriented layer on top of buffer-passing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstbytestream",
+ "a byte-oriented layer on top of buffer-passing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gstpad.h>
#include <gst/gstevent.h>
-G_BEGIN_DECLS
+G_BEGIN_DECLS typedef struct _GstByteStream GstByteStream;
-typedef struct _GstByteStream GstByteStream;
+struct _GstByteStream
+{
+ GstPad *pad;
-struct _GstByteStream {
- GstPad *pad;
+ GstEvent *event;
- GstEvent *event;
-
- GSList *buflist;
- guint32 headbufavail;
- guint32 listavail;
+ GSList *buflist;
+ guint32 headbufavail;
+ guint32 listavail;
/* we keep state of assembled pieces */
- guint8 *assembled;
- guint32 assembled_len; /* only valid when assembled != NULL */
+ guint8 *assembled;
+ guint32 assembled_len; /* only valid when assembled != NULL */
/* this is needed for gst_bytestream_tell */
- guint64 offset;
- guint64 last_ts;
+ guint64 offset;
+ guint64 last_ts;
/* if we are in the seek state (waiting for DISCONT) */
- gboolean in_seek;
+ gboolean in_seek;
gpointer _gst_reserved[GST_PADDING];
};
-GstByteStream* gst_bytestream_new (GstPad *pad);
-void gst_bytestream_destroy (GstByteStream *bs);
-
-void gst_bytestream_reset (GstByteStream *bs);
-guint32 gst_bytestream_read (GstByteStream *bs, GstBuffer** buf, guint32 len);
-guint64 gst_bytestream_tell (GstByteStream *bs);
-guint64 gst_bytestream_length (GstByteStream *bs);
-gboolean gst_bytestream_size_hint (GstByteStream *bs, guint32 size);
-gboolean gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType type);
-guint32 gst_bytestream_peek (GstByteStream *bs, GstBuffer** buf, guint32 len);
-guint32 gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len);
-gboolean gst_bytestream_flush (GstByteStream *bs, guint32 len);
-void gst_bytestream_flush_fast (GstByteStream *bs, guint32 len);
-void gst_bytestream_get_status (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out);
-guint64 gst_bytestream_get_timestamp (GstByteStream *bs);
-
-void gst_bytestream_print_status (GstByteStream *bs);
+GstByteStream *gst_bytestream_new (GstPad * pad);
+void gst_bytestream_destroy (GstByteStream * bs);
+
+void gst_bytestream_reset (GstByteStream * bs);
+guint32 gst_bytestream_read (GstByteStream * bs, GstBuffer ** buf, guint32 len);
+guint64 gst_bytestream_tell (GstByteStream * bs);
+guint64 gst_bytestream_length (GstByteStream * bs);
+gboolean gst_bytestream_size_hint (GstByteStream * bs, guint32 size);
+gboolean gst_bytestream_seek (GstByteStream * bs, gint64 offset,
+ GstSeekType type);
+guint32 gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len);
+guint32 gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data,
+ guint32 len);
+gboolean gst_bytestream_flush (GstByteStream * bs, guint32 len);
+void gst_bytestream_flush_fast (GstByteStream * bs, guint32 len);
+void gst_bytestream_get_status (GstByteStream * bs, guint32 * avail_out,
+ GstEvent ** event_out);
+guint64 gst_bytestream_get_timestamp (GstByteStream * bs);
+
+void gst_bytestream_print_status (GstByteStream * bs);
G_END_DECLS
-
#endif /* __GST_BYTESTREAM_H__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#include <gst/gst.h>
#include "control.h"
-GST_DEBUG_CATEGORY(_gst_control_debug);
+GST_DEBUG_CATEGORY (_gst_control_debug);
void
-gst_control_init (int *argc, char **argv[]) {
- GST_DEBUG_CATEGORY_INIT (_gst_control_debug, "control", 0, "libgstcontrol");
- _gst_dpman_initialize ();
- _gst_unitconv_initialize ();
+gst_control_init (int *argc, char **argv[])
+{
+ GST_DEBUG_CATEGORY_INIT (_gst_control_debug, "control", 0, "libgstcontrol");
+ _gst_dpman_initialize ();
+ _gst_unitconv_initialize ();
}
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_CONTROL_H__
#define __GST_CONTROL_H__
#include <gst/control/dplinearinterp.h>
#include <gst/control/unitconvert.h>
-G_BEGIN_DECLS
-
-void gst_control_init (int *argc, char **argv[]);
+G_BEGIN_DECLS void gst_control_init (int *argc, char **argv[]);
G_END_DECLS
-
#endif /* __GST_CONTROL_H__ */
#include "dparammanager.h"
#include <gst/gstmarshal.h>
-GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug);
-
-static void gst_dparam_class_init (GstDParamClass *klass);
-static void gst_dparam_init (GstDParam *dparam);
-static void gst_dparam_dispose (GObject *object);
-static void gst_dparam_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void gst_dparam_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-
-enum {
- ARG_0,
- ARG_VALUE_FLOAT,
- ARG_VALUE_DOUBLE,
- ARG_VALUE_INT,
- ARG_VALUE_INT64,
+GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug);
+
+static void gst_dparam_class_init (GstDParamClass * klass);
+static void gst_dparam_init (GstDParam * dparam);
+static void gst_dparam_dispose (GObject * object);
+static void gst_dparam_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_dparam_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+
+enum
+{
+ ARG_0,
+ ARG_VALUE_FLOAT,
+ ARG_VALUE_DOUBLE,
+ ARG_VALUE_INT,
+ ARG_VALUE_INT64,
};
-enum {
+enum
+{
VALUE_CHANGED,
LAST_SIGNAL
};
static guint gst_dparam_signals[LAST_SIGNAL] = { 0 };
-GType
-gst_dparam_get_type(void) {
- static GType dparam_type = 0;
-
- if (!dparam_type) {
- static const GTypeInfo dparam_info = {
- sizeof(GstDParamClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_dparam_class_init,
- NULL,
- NULL,
- sizeof(GstDParam),
- 0,
- (GInstanceInitFunc)gst_dparam_init,
- };
- dparam_type = g_type_register_static(GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0);
- }
- return dparam_type;
+GType
+gst_dparam_get_type (void)
+{
+ static GType dparam_type = 0;
+
+ if (!dparam_type) {
+ static const GTypeInfo dparam_info = {
+ sizeof (GstDParamClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_dparam_class_init,
+ NULL,
+ NULL,
+ sizeof (GstDParam),
+ 0,
+ (GInstanceInitFunc) gst_dparam_init,
+ };
+ dparam_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0);
+ }
+ return dparam_type;
}
static void
-gst_dparam_class_init (GstDParamClass *klass)
+gst_dparam_class_init (GstDParamClass * klass)
{
- GObjectClass *gobject_class;
- GstDParamClass *dparam_class;
- GstObjectClass *gstobject_class;
-
- gobject_class = (GObjectClass*)klass;
- dparam_class = (GstDParamClass*)klass;
- gstobject_class = (GstObjectClass*) klass;
-
- gobject_class->get_property = gst_dparam_get_property;
- gobject_class->set_property = gst_dparam_set_property;
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_FLOAT,
- g_param_spec_float("value_float","Float Value",
- "The value that should be changed if gfloat is the type",
- -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_DOUBLE,
- g_param_spec_double("value_double","Double Value",
- "The value that should be changed if gdouble is the type",
- -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_INT,
- g_param_spec_int("value_int","Integer Value",
- "The value that should be changed if gint is the type",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_INT64,
- g_param_spec_int64("value_int64","64 bit Integer Value",
- "The value that should be changed if gint64 is the type",
- G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE));
-
- gobject_class->dispose = gst_dparam_dispose;
-
- gst_dparam_signals[VALUE_CHANGED] =
- g_signal_new ("value-changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstDParamClass, value_changed), NULL, NULL,
- gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
- /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
+ GObjectClass *gobject_class;
+ GstDParamClass *dparam_class;
+ GstObjectClass *gstobject_class;
+
+ gobject_class = (GObjectClass *) klass;
+ dparam_class = (GstDParamClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+
+ gobject_class->get_property = gst_dparam_get_property;
+ gobject_class->set_property = gst_dparam_set_property;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_FLOAT,
+ g_param_spec_float ("value_float", "Float Value",
+ "The value that should be changed if gfloat is the type",
+ -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_DOUBLE,
+ g_param_spec_double ("value_double", "Double Value",
+ "The value that should be changed if gdouble is the type",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT,
+ g_param_spec_int ("value_int", "Integer Value",
+ "The value that should be changed if gint is the type",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT64,
+ g_param_spec_int64 ("value_int64", "64 bit Integer Value",
+ "The value that should be changed if gint64 is the type",
+ G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE));
+
+ gobject_class->dispose = gst_dparam_dispose;
+
+ gst_dparam_signals[VALUE_CHANGED] =
+ g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamClass, value_changed), NULL,
+ NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
}
static void
-gst_dparam_init (GstDParam *dparam)
+gst_dparam_init (GstDParam * dparam)
{
- g_return_if_fail (dparam != NULL);
- GST_DPARAM_TYPE(dparam) = 0;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam)=0LL;
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam)=0LL;
- GST_DPARAM_READY_FOR_UPDATE(dparam)=FALSE;
- dparam->lock = g_mutex_new ();
+ g_return_if_fail (dparam != NULL);
+ GST_DPARAM_TYPE (dparam) = 0;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL;
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = 0LL;
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE;
+ dparam->lock = g_mutex_new ();
}
/**
*
* Returns: a new instance of GstDParam
*/
-GstDParam*
+GstDParam *
gst_dparam_new (GType type)
{
- GstDParam *dparam;
+ GstDParam *dparam;
- dparam = g_object_new (gst_dparam_get_type (), NULL);
- dparam->do_update_func = gst_dparam_do_update_default;
+ dparam = g_object_new (gst_dparam_get_type (), NULL);
+ dparam->do_update_func = gst_dparam_do_update_default;
- GST_DPARAM_TYPE(dparam) = type;
-
- return dparam;
+ GST_DPARAM_TYPE (dparam) = type;
+
+ return dparam;
}
-static void
-gst_dparam_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_dparam_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstDParam *dparam;
- g_return_if_fail(GST_IS_DPARAM(object));
- dparam = GST_DPARAM(object);
-
- switch (prop_id) {
- case ARG_VALUE_FLOAT:
- g_value_set_float (value, dparam->value_float);
- break;
-
- case ARG_VALUE_DOUBLE:
- g_value_set_double (value, dparam->value_double);
- break;
-
- case ARG_VALUE_INT:
- g_value_set_int (value, dparam->value_int);
- break;
-
- case ARG_VALUE_INT64:
- g_value_set_int64 (value, dparam->value_int64);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstDParam *dparam;
+
+ g_return_if_fail (GST_IS_DPARAM (object));
+ dparam = GST_DPARAM (object);
+
+ switch (prop_id) {
+ case ARG_VALUE_FLOAT:
+ g_value_set_float (value, dparam->value_float);
+ break;
+
+ case ARG_VALUE_DOUBLE:
+ g_value_set_double (value, dparam->value_double);
+ break;
+
+ case ARG_VALUE_INT:
+ g_value_set_int (value, dparam->value_int);
+ break;
+
+ case ARG_VALUE_INT64:
+ g_value_set_int64 (value, dparam->value_int64);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void
-gst_dparam_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_dparam_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
- GstDParam *dparam;
- g_return_if_fail(GST_IS_DPARAM(object));
- dparam = GST_DPARAM(object);
- GST_DPARAM_LOCK(dparam);
-
- switch (prop_id) {
- case ARG_VALUE_FLOAT:
- GST_DEBUG ("setting value from %g to %g", dparam->value_float, g_value_get_float (value));
- dparam->value_float = g_value_get_float (value);
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_VALUE_DOUBLE:
- GST_DEBUG ("setting value from %g to %g",
- dparam->value_double, g_value_get_double (value));
- dparam->value_double = g_value_get_double (value);
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) =
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_VALUE_INT:
- GST_DEBUG ("setting value from %d to %d", dparam->value_int, g_value_get_int (value));
- dparam->value_int = g_value_get_int (value);
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_VALUE_INT64:
- GST_DEBUG ("setting value from %"
- G_GINT64_FORMAT " to %"
- G_GINT64_FORMAT,
- dparam->value_int64, g_value_get_int64 (value));
- dparam->value_int64 = g_value_get_int64 (value);
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- default:
- break;
- }
-
- /* note that this signal is sent while we still have the lock. */
- g_signal_emit (G_OBJECT (dparam), gst_dparam_signals[VALUE_CHANGED], 0);
- GST_DPARAM_UNLOCK(dparam);
+ GstDParam *dparam;
+
+ g_return_if_fail (GST_IS_DPARAM (object));
+ dparam = GST_DPARAM (object);
+ GST_DPARAM_LOCK (dparam);
+
+ switch (prop_id) {
+ case ARG_VALUE_FLOAT:
+ GST_DEBUG ("setting value from %g to %g", dparam->value_float,
+ g_value_get_float (value));
+ dparam->value_float = g_value_get_float (value);
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_VALUE_DOUBLE:
+ GST_DEBUG ("setting value from %g to %g",
+ dparam->value_double, g_value_get_double (value));
+ dparam->value_double = g_value_get_double (value);
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_VALUE_INT:
+ GST_DEBUG ("setting value from %d to %d", dparam->value_int,
+ g_value_get_int (value));
+ dparam->value_int = g_value_get_int (value);
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_VALUE_INT64:
+ GST_DEBUG ("setting value from %"
+ G_GINT64_FORMAT " to %"
+ G_GINT64_FORMAT, dparam->value_int64, g_value_get_int64 (value));
+ dparam->value_int64 = g_value_get_int64 (value);
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
+ /* note that this signal is sent while we still have the lock. */
+ g_signal_emit (G_OBJECT (dparam), gst_dparam_signals[VALUE_CHANGED], 0);
+ GST_DPARAM_UNLOCK (dparam);
}
void
-gst_dparam_do_update_default (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info)
+gst_dparam_do_update_default (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info)
{
- GST_DPARAM_LOCK(dparam);
-
- g_return_if_fail (G_VALUE_TYPE(value) == GST_DPARAM_TYPE(dparam));
- GST_DEBUG ("updating value for %s(%p)",GST_DPARAM_NAME (dparam),dparam);
-
- switch (G_VALUE_TYPE(value)) {
- case G_TYPE_FLOAT:
- g_value_set_float(value, dparam->value_float);
- break;
-
- case G_TYPE_DOUBLE:
- g_value_set_double(value, dparam->value_double);
- break;
-
- case G_TYPE_INT:
- g_value_set_int(value, dparam->value_int);
- break;
-
- case G_TYPE_INT64:
- g_value_set_int64(value, dparam->value_int64);
- break;
-
- default:
- break;
- }
-
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
-
- GST_DPARAM_UNLOCK(dparam);
+ GST_DPARAM_LOCK (dparam);
+
+ g_return_if_fail (G_VALUE_TYPE (value) == GST_DPARAM_TYPE (dparam));
+ GST_DEBUG ("updating value for %s(%p)", GST_DPARAM_NAME (dparam), dparam);
+
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_FLOAT:
+ g_value_set_float (value, dparam->value_float);
+ break;
+
+ case G_TYPE_DOUBLE:
+ g_value_set_double (value, dparam->value_double);
+ break;
+
+ case G_TYPE_INT:
+ g_value_set_int (value, dparam->value_int);
+ break;
+
+ case G_TYPE_INT64:
+ g_value_set_int64 (value, dparam->value_int64);
+ break;
+
+ default:
+ break;
+ }
+
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE;
+
+ GST_DPARAM_UNLOCK (dparam);
}
static void
-gst_dparam_dispose (GObject *object)
+gst_dparam_dispose (GObject * object)
{
- GstDParam *dparam = GST_DPARAM(object);
- gchar *dparam_name = g_strdup(GST_DPARAM_NAME(dparam));
-
- GST_DEBUG ("disposing of %s", dparam_name);
- if (GST_DPARAM_MANAGER(dparam)){
- gst_dpman_detach_dparam(GST_DPARAM_MANAGER(dparam), dparam_name);
- }
- g_free(dparam_name);
+ GstDParam *dparam = GST_DPARAM (object);
+ gchar *dparam_name = g_strdup (GST_DPARAM_NAME (dparam));
+
+ GST_DEBUG ("disposing of %s", dparam_name);
+ if (GST_DPARAM_MANAGER (dparam)) {
+ gst_dpman_detach_dparam (GST_DPARAM_MANAGER (dparam), dparam_name);
+ }
+ g_free (dparam_name);
}
/**
*
*/
void
-gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GParamSpec *param_spec, gchar *unit_name)
+gst_dparam_attach (GstDParam * dparam, GstDParamManager * manager,
+ GParamSpec * param_spec, gchar * unit_name)
{
-
- g_return_if_fail (dparam != NULL);
- g_return_if_fail (GST_IS_DPARAM (dparam));
- g_return_if_fail (manager != NULL);
- g_return_if_fail (GST_IS_DPMAN (manager));
- g_return_if_fail (param_spec != NULL);
- g_return_if_fail (unit_name != NULL);
- g_return_if_fail (G_IS_PARAM_SPEC (param_spec));
- g_return_if_fail (G_PARAM_SPEC_VALUE_TYPE (param_spec) == GST_DPARAM_TYPE(dparam));
-
- GST_DPARAM_NAME(dparam) = g_param_spec_get_name(param_spec);
- GST_DPARAM_PARAM_SPEC(dparam) = param_spec;
- GST_DPARAM_MANAGER(dparam) = manager;
- GST_DPARAM_UNIT_NAME(dparam) = unit_name;
- GST_DPARAM_IS_LOG(dparam) = gst_unitconv_unit_is_logarithmic(unit_name);
- GST_DEBUG ("attaching %s to dparam %p",GST_DPARAM_NAME (dparam),dparam);
+
+ g_return_if_fail (dparam != NULL);
+ g_return_if_fail (GST_IS_DPARAM (dparam));
+ g_return_if_fail (manager != NULL);
+ g_return_if_fail (GST_IS_DPMAN (manager));
+ g_return_if_fail (param_spec != NULL);
+ g_return_if_fail (unit_name != NULL);
+ g_return_if_fail (G_IS_PARAM_SPEC (param_spec));
+ g_return_if_fail (G_PARAM_SPEC_VALUE_TYPE (param_spec) ==
+ GST_DPARAM_TYPE (dparam));
+
+ GST_DPARAM_NAME (dparam) = g_param_spec_get_name (param_spec);
+ GST_DPARAM_PARAM_SPEC (dparam) = param_spec;
+ GST_DPARAM_MANAGER (dparam) = manager;
+ GST_DPARAM_UNIT_NAME (dparam) = unit_name;
+ GST_DPARAM_IS_LOG (dparam) = gst_unitconv_unit_is_logarithmic (unit_name);
+ GST_DEBUG ("attaching %s to dparam %p", GST_DPARAM_NAME (dparam), dparam);
}
*
*/
void
-gst_dparam_detach (GstDParam *dparam)
+gst_dparam_detach (GstDParam * dparam)
{
-
- g_return_if_fail (dparam != NULL);
- g_return_if_fail (GST_IS_DPARAM (dparam));
-
- GST_DEBUG ("detaching %s from dparam %p",GST_DPARAM_NAME (dparam),dparam);
-
- GST_DPARAM_NAME(dparam) = NULL;
- GST_DPARAM_PARAM_SPEC(dparam) = NULL;
- GST_DPARAM_MANAGER(dparam) = NULL;
+
+ g_return_if_fail (dparam != NULL);
+ g_return_if_fail (GST_IS_DPARAM (dparam));
+
+ GST_DEBUG ("detaching %s from dparam %p", GST_DPARAM_NAME (dparam), dparam);
+
+ GST_DPARAM_NAME (dparam) = NULL;
+ GST_DPARAM_PARAM_SPEC (dparam) = NULL;
+ GST_DPARAM_MANAGER (dparam) = NULL;
}
#include "dparamcommon.h"
G_BEGIN_DECLS
-
#define GST_TYPE_DPARAM (gst_dparam_get_type ())
#define GST_DPARAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPARAM,GstDParam))
#define GST_DPARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPARAM,GstDParam))
#define GST_IS_DPARAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPARAM))
#define GST_IS_DPARAM_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPARAM))
-
#define GST_DPARAM_NAME(dparam) (GST_OBJECT_NAME(dparam))
#define GST_DPARAM_PARENT(dparam) (GST_OBJECT_PARENT(dparam))
#define GST_DPARAM_CHANGE_VALUE(dparam) ((dparam)->change_value)
#define GST_DPARAM_META_PARAM_SPECS(dparam) ((dparam)->meta_param_specs)
#define GST_DPARAM_LOCK(dparam) (g_mutex_lock((dparam)->lock))
#define GST_DPARAM_UNLOCK(dparam) (g_mutex_unlock((dparam)->lock))
-
#define GST_DPARAM_READY_FOR_UPDATE(dparam) ((dparam)->ready_for_update)
#define GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) ((dparam)->next_update_timestamp)
#define GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) ((dparam)->last_update_timestamp)
-
#define GST_DPARAM_DO_UPDATE(dparam, timestamp, value, update_info) \
((dparam->do_update_func)(dparam, timestamp, value, update_info))
-
typedef struct _GstDParamClass GstDParamClass;
-typedef enum {
+typedef enum
+{
GST_DPARAM_UPDATE_FIRST,
GST_DPARAM_UPDATE_NORMAL,
} GstDParamUpdateInfo;
-typedef void (*GstDParamDoUpdateFunction) (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info);
+typedef void (*GstDParamDoUpdateFunction) (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info);
+
+struct _GstDParam
+{
+ GstObject object;
-struct _GstDParam {
- GstObject object;
+ GstDParamDoUpdateFunction do_update_func;
- GstDParamDoUpdateFunction do_update_func;
-
- GMutex *lock;
+ GMutex *lock;
- gfloat value_float;
- gdouble value_double;
- gint value_int;
- gint64 value_int64;
-
- GstDParamManager *manager;
- GParamSpec *param_spec;
- GType type;
- gboolean ready_for_update;
+ gfloat value_float;
+ gdouble value_double;
+ gint value_int;
+ gint64 value_int64;
- gint64 next_update_timestamp;
- gint64 last_update_timestamp;
- gchar *unit_name;
- gboolean is_log;
+ GstDParamManager *manager;
+ GParamSpec *param_spec;
+ GType type;
+ gboolean ready_for_update;
- gpointer _gst_reserved[GST_PADDING];
+ gint64 next_update_timestamp;
+ gint64 last_update_timestamp;
+ gchar *unit_name;
+ gboolean is_log;
+
+ gpointer _gst_reserved[GST_PADDING];
};
-struct _GstDParamClass {
- GstObjectClass parent_class;
+struct _GstDParamClass
+{
+ GstObjectClass parent_class;
- /* signal callbacks */
- void (*value_changed) (GstDParam *dparam);
+ /* signal callbacks */
+ void (*value_changed) (GstDParam * dparam);
- gpointer _gst_reserved[GST_PADDING];
+ gpointer _gst_reserved[GST_PADDING];
};
GType gst_dparam_get_type (void);
-GstDParam* gst_dparam_new (GType type);
-void gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GParamSpec *param_spec, gchar *unit_name);
-void gst_dparam_detach (GstDParam *dparam);
-void gst_dparam_do_update_default (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info);
+GstDParam *gst_dparam_new (GType type);
+void gst_dparam_attach (GstDParam * dparam, GstDParamManager * manager,
+ GParamSpec * param_spec, gchar * unit_name);
+void gst_dparam_detach (GstDParam * dparam);
+void gst_dparam_do_update_default (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info);
G_END_DECLS
-
#endif /* __GST_DPARAM_H__ */
#include "dparam_smooth.h"
#include "dparammanager.h"
-GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug);
-
-static void gst_dpsmooth_class_init (GstDParamSmoothClass *klass);
-static void gst_dpsmooth_init (GstDParamSmooth *dparam);
-static void gst_dpsmooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_dpsmooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void gst_dpsmooth_do_update_float (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info);
-static void gst_dpsmooth_value_changed_float (GstDParam *dparam);
-static void gst_dpsmooth_do_update_double (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info);
-static void gst_dpsmooth_value_changed_double (GstDParam *dparam);
-
-enum {
- ARG_0,
- ARG_UPDATE_PERIOD,
- ARG_SLOPE_TIME,
- ARG_SLOPE_DELTA_FLOAT,
- ARG_SLOPE_DELTA_DOUBLE,
- ARG_SLOPE_DELTA_INT,
- ARG_SLOPE_DELTA_INT64,
+GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug);
+
+static void gst_dpsmooth_class_init (GstDParamSmoothClass * klass);
+static void gst_dpsmooth_init (GstDParamSmooth * dparam);
+static void gst_dpsmooth_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_dpsmooth_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_dpsmooth_do_update_float (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info);
+static void gst_dpsmooth_value_changed_float (GstDParam * dparam);
+static void gst_dpsmooth_do_update_double (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info);
+static void gst_dpsmooth_value_changed_double (GstDParam * dparam);
+
+enum
+{
+ ARG_0,
+ ARG_UPDATE_PERIOD,
+ ARG_SLOPE_TIME,
+ ARG_SLOPE_DELTA_FLOAT,
+ ARG_SLOPE_DELTA_DOUBLE,
+ ARG_SLOPE_DELTA_INT,
+ ARG_SLOPE_DELTA_INT64,
};
-GType
-gst_dpsmooth_get_type(void) {
- static GType dpsmooth_type = 0;
-
- if (!dpsmooth_type) {
- static const GTypeInfo dpsmooth_info = {
- sizeof(GstDParamSmoothClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_dpsmooth_class_init,
- NULL,
- NULL,
- sizeof(GstDParamSmooth),
- 0,
- (GInstanceInitFunc)gst_dpsmooth_init,
- };
- dpsmooth_type = g_type_register_static(GST_TYPE_DPARAM, "GstDParamSmooth", &dpsmooth_info, 0);
- }
- return dpsmooth_type;
+GType
+gst_dpsmooth_get_type (void)
+{
+ static GType dpsmooth_type = 0;
+
+ if (!dpsmooth_type) {
+ static const GTypeInfo dpsmooth_info = {
+ sizeof (GstDParamSmoothClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_dpsmooth_class_init,
+ NULL,
+ NULL,
+ sizeof (GstDParamSmooth),
+ 0,
+ (GInstanceInitFunc) gst_dpsmooth_init,
+ };
+ dpsmooth_type =
+ g_type_register_static (GST_TYPE_DPARAM, "GstDParamSmooth",
+ &dpsmooth_info, 0);
+ }
+ return dpsmooth_type;
}
static void
-gst_dpsmooth_class_init (GstDParamSmoothClass *klass)
+gst_dpsmooth_class_init (GstDParamSmoothClass * klass)
{
- GObjectClass *gobject_class;
- GstDParamSmoothClass *dpsmooth_class;
- GstObjectClass *gstobject_class;
-
- gobject_class = (GObjectClass*)klass;
- dpsmooth_class = (GstDParamSmoothClass*)klass;
- gstobject_class = (GstObjectClass*) klass;
-
- gobject_class->get_property = gst_dpsmooth_get_property;
- gobject_class->set_property = gst_dpsmooth_set_property;
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_UPDATE_PERIOD,
- g_param_spec_int64("update_period",
- "Update Period (nanoseconds)",
- "Number of nanoseconds between updates",
- 0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SLOPE_TIME,
- g_param_spec_int64("slope_time",
- "Slope Time (nanoseconds)",
- "The time period to define slope_delta by",
- 0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass),
- ARG_SLOPE_DELTA_FLOAT,
- g_param_spec_float("slope_delta_float", "Slope Delta float",
- "The amount a float value can change for a given slope_time",
- 0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass),
- ARG_SLOPE_DELTA_DOUBLE,
- g_param_spec_double("slope_delta_double", "Slope Delta double",
- "The amount a double value can change for a given slope_time",
- 0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE));
-
- /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
+ GObjectClass *gobject_class;
+ GstDParamSmoothClass *dpsmooth_class;
+ GstObjectClass *gstobject_class;
+
+ gobject_class = (GObjectClass *) klass;
+ dpsmooth_class = (GstDParamSmoothClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+
+ gobject_class->get_property = gst_dpsmooth_get_property;
+ gobject_class->set_property = gst_dpsmooth_set_property;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_PERIOD,
+ g_param_spec_int64 ("update_period",
+ "Update Period (nanoseconds)",
+ "Number of nanoseconds between updates",
+ 0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLOPE_TIME,
+ g_param_spec_int64 ("slope_time",
+ "Slope Time (nanoseconds)",
+ "The time period to define slope_delta by",
+ 0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_SLOPE_DELTA_FLOAT,
+ g_param_spec_float ("slope_delta_float", "Slope Delta float",
+ "The amount a float value can change for a given slope_time",
+ 0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_SLOPE_DELTA_DOUBLE,
+ g_param_spec_double ("slope_delta_double", "Slope Delta double",
+ "The amount a double value can change for a given slope_time",
+ 0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE));
+
+ /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
}
static void
-gst_dpsmooth_init (GstDParamSmooth *dpsmooth)
+gst_dpsmooth_init (GstDParamSmooth * dpsmooth)
{
- g_return_if_fail (dpsmooth != NULL);
+ g_return_if_fail (dpsmooth != NULL);
}
/**
*
* Returns: a new instance of GstDParam
*/
-GstDParam*
+GstDParam *
gst_dpsmooth_new (GType type)
{
- GstDParam *dparam;
- GstDParamSmooth *dpsmooth;
-
- dpsmooth =g_object_new (gst_dpsmooth_get_type (), NULL);
- dparam = GST_DPARAM(dpsmooth);
-
- GST_DPARAM_TYPE(dparam) = type;
-
- switch (type){
- case G_TYPE_FLOAT: {
- dparam->do_update_func = gst_dpsmooth_do_update_float;
- g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
- G_CALLBACK (gst_dpsmooth_value_changed_float), NULL);
- break;
- }
- case G_TYPE_DOUBLE: {
- dparam->do_update_func = gst_dpsmooth_do_update_double;
- g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
- G_CALLBACK (gst_dpsmooth_value_changed_double), NULL);
- break;
- }
- default:
- /* we don't support this type here */
- dparam->do_update_func = gst_dparam_do_update_default;
- break;
- }
- return dparam;
+ GstDParam *dparam;
+ GstDParamSmooth *dpsmooth;
+
+ dpsmooth = g_object_new (gst_dpsmooth_get_type (), NULL);
+ dparam = GST_DPARAM (dpsmooth);
+
+ GST_DPARAM_TYPE (dparam) = type;
+
+ switch (type) {
+ case G_TYPE_FLOAT:{
+ dparam->do_update_func = gst_dpsmooth_do_update_float;
+ g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
+ G_CALLBACK (gst_dpsmooth_value_changed_float), NULL);
+ break;
+ }
+ case G_TYPE_DOUBLE:{
+ dparam->do_update_func = gst_dpsmooth_do_update_double;
+ g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
+ G_CALLBACK (gst_dpsmooth_value_changed_double), NULL);
+ break;
+ }
+ default:
+ /* we don't support this type here */
+ dparam->do_update_func = gst_dparam_do_update_default;
+ break;
+ }
+ return dparam;
}
-static void
-gst_dpsmooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_dpsmooth_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GstDParam *dparam;
- GstDParamSmooth *dpsmooth;
-
- g_return_if_fail(GST_IS_DPSMOOTH(object));
-
- dpsmooth = GST_DPSMOOTH(object);
- dparam = GST_DPARAM(object);
-
- GST_DPARAM_LOCK(dparam);
-
- switch (prop_id) {
- case ARG_UPDATE_PERIOD:
- dpsmooth->update_period = g_value_get_int64 (value);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_SLOPE_TIME:
- dpsmooth->slope_time = g_value_get_int64 (value);
- GST_DEBUG ("dpsmooth->slope_time:%"
- G_GINT64_FORMAT,
- dpsmooth->slope_time);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_SLOPE_DELTA_FLOAT:
- dpsmooth->slope_delta_float = g_value_get_float (value);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- case ARG_SLOPE_DELTA_DOUBLE:
- dpsmooth->slope_delta_double = g_value_get_double (value);
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- break;
-
- default:
- break;
- }
- GST_DPARAM_UNLOCK(dparam);
+ GstDParam *dparam;
+ GstDParamSmooth *dpsmooth;
+
+ g_return_if_fail (GST_IS_DPSMOOTH (object));
+
+ dpsmooth = GST_DPSMOOTH (object);
+ dparam = GST_DPARAM (object);
+
+ GST_DPARAM_LOCK (dparam);
+
+ switch (prop_id) {
+ case ARG_UPDATE_PERIOD:
+ dpsmooth->update_period = g_value_get_int64 (value);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_SLOPE_TIME:
+ dpsmooth->slope_time = g_value_get_int64 (value);
+ GST_DEBUG ("dpsmooth->slope_time:%"
+ G_GINT64_FORMAT, dpsmooth->slope_time);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_SLOPE_DELTA_FLOAT:
+ dpsmooth->slope_delta_float = g_value_get_float (value);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ case ARG_SLOPE_DELTA_DOUBLE:
+ dpsmooth->slope_delta_double = g_value_get_double (value);
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ break;
+
+ default:
+ break;
+ }
+ GST_DPARAM_UNLOCK (dparam);
}
-static void
-gst_dpsmooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_dpsmooth_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstDParam *dparam;
- GstDParamSmooth *dpsmooth;
-
- g_return_if_fail(GST_IS_DPSMOOTH(object));
-
- dpsmooth = GST_DPSMOOTH(object);
- dparam = GST_DPARAM(object);
-
- switch (prop_id) {
- case ARG_UPDATE_PERIOD:
- g_value_set_int64(value, dpsmooth->update_period);
- break;
- case ARG_SLOPE_TIME:
- g_value_set_int64(value, dpsmooth->slope_time);
- break;
- case ARG_SLOPE_DELTA_FLOAT:
- g_value_set_float (value, dpsmooth->slope_delta_float);
- break;
- case ARG_SLOPE_DELTA_DOUBLE:
- g_value_set_double (value, dpsmooth->slope_delta_double);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstDParam *dparam;
+ GstDParamSmooth *dpsmooth;
+
+ g_return_if_fail (GST_IS_DPSMOOTH (object));
+
+ dpsmooth = GST_DPSMOOTH (object);
+ dparam = GST_DPARAM (object);
+
+ switch (prop_id) {
+ case ARG_UPDATE_PERIOD:
+ g_value_set_int64 (value, dpsmooth->update_period);
+ break;
+ case ARG_SLOPE_TIME:
+ g_value_set_int64 (value, dpsmooth->slope_time);
+ break;
+ case ARG_SLOPE_DELTA_FLOAT:
+ g_value_set_float (value, dpsmooth->slope_delta_float);
+ break;
+ case ARG_SLOPE_DELTA_DOUBLE:
+ g_value_set_double (value, dpsmooth->slope_delta_double);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void
-gst_dpsmooth_value_changed_float (GstDParam *dparam)
+static void
+gst_dpsmooth_value_changed_float (GstDParam * dparam)
{
- GstDParamSmooth *dpsmooth;
- gfloat time_ratio;
+ GstDParamSmooth *dpsmooth;
+ gfloat time_ratio;
- g_return_if_fail(GST_IS_DPSMOOTH(dparam));
- dpsmooth = GST_DPSMOOTH(dparam);
+ g_return_if_fail (GST_IS_DPSMOOTH (dparam));
+ dpsmooth = GST_DPSMOOTH (dparam);
- if (GST_DPARAM_IS_LOG(dparam)){
- dparam->value_float = log(dparam->value_float);
- }
- dpsmooth->start_float = dpsmooth->current_float;
- dpsmooth->diff_float = dparam->value_float - dpsmooth->start_float;
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ dparam->value_float = log (dparam->value_float);
+ }
+ dpsmooth->start_float = dpsmooth->current_float;
+ dpsmooth->diff_float = dparam->value_float - dpsmooth->start_float;
- time_ratio = ABS(dpsmooth->diff_float) / dpsmooth->slope_delta_float;
- dpsmooth->duration_interp = (gint64)(time_ratio * (gfloat)dpsmooth->slope_time);
+ time_ratio = ABS (dpsmooth->diff_float) / dpsmooth->slope_delta_float;
+ dpsmooth->duration_interp =
+ (gint64) (time_ratio * (gfloat) dpsmooth->slope_time);
- dpsmooth->need_interp_times = TRUE;
+ dpsmooth->need_interp_times = TRUE;
- GST_DEBUG ("%f to %f ratio:%f duration:%"
- G_GINT64_FORMAT "\n",
- dpsmooth->start_float, dparam->value_float, time_ratio, dpsmooth->duration_interp);
+ GST_DEBUG ("%f to %f ratio:%f duration:%"
+ G_GINT64_FORMAT "\n",
+ dpsmooth->start_float, dparam->value_float, time_ratio,
+ dpsmooth->duration_interp);
}
static void
-gst_dpsmooth_do_update_float (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info)
+gst_dpsmooth_do_update_float (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info)
{
- gfloat time_ratio;
- GstDParamSmooth *dpsmooth = GST_DPSMOOTH(dparam);
-
- GST_DPARAM_LOCK(dparam);
-
- if (dpsmooth->need_interp_times){
- dpsmooth->start_interp = timestamp;
- dpsmooth->end_interp = timestamp + dpsmooth->duration_interp;
- dpsmooth->need_interp_times = FALSE;
- }
-
- if ((update_info == GST_DPARAM_UPDATE_FIRST) || (timestamp >= dpsmooth->end_interp)){
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_float(value, exp(dparam->value_float));
- }
- else {
- g_value_set_float(value, dparam->value_float);
- }
- dpsmooth->current_float = dparam->value_float;
-
- GST_DEBUG ("interp finished at %"
- G_GINT64_FORMAT, timestamp);
-
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp;
-
- GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
- GST_DPARAM_UNLOCK(dparam);
- return;
- }
-
- if (timestamp <= dpsmooth->start_interp){
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_float(value, exp(dpsmooth->start_float));
- }
- else {
- g_value_set_float(value, dpsmooth->start_float);
- }
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->start_interp + dpsmooth->update_period;
-
- GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);
-
- GST_DPARAM_UNLOCK(dparam);
- return;
-
- }
-
- time_ratio = (gfloat)(timestamp - dpsmooth->start_interp) / (gfloat)dpsmooth->duration_interp;
-
- GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, dpsmooth->end_interp, time_ratio);
- GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_float, dpsmooth->current_float, dparam->value_float);
-
- dpsmooth->current_float = dpsmooth->start_float + (dpsmooth->diff_float * time_ratio);
-
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp + dpsmooth->update_period;
- if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) > dpsmooth->end_interp){
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->end_interp;
- }
-
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
-
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_float(value, exp(dpsmooth->current_float));
- }
- else {
- g_value_set_float(value, dpsmooth->current_float);
- }
-
- GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_float, dpsmooth->current_float, dparam->value_float);
-
- GST_DPARAM_UNLOCK(dparam);
+ gfloat time_ratio;
+ GstDParamSmooth *dpsmooth = GST_DPSMOOTH (dparam);
+
+ GST_DPARAM_LOCK (dparam);
+
+ if (dpsmooth->need_interp_times) {
+ dpsmooth->start_interp = timestamp;
+ dpsmooth->end_interp = timestamp + dpsmooth->duration_interp;
+ dpsmooth->need_interp_times = FALSE;
+ }
+
+ if ((update_info == GST_DPARAM_UPDATE_FIRST)
+ || (timestamp >= dpsmooth->end_interp)) {
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_float (value, exp (dparam->value_float));
+ } else {
+ g_value_set_float (value, dparam->value_float);
+ }
+ dpsmooth->current_float = dparam->value_float;
+
+ GST_DEBUG ("interp finished at %" G_GINT64_FORMAT, timestamp);
+
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp;
+
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE;
+ GST_DPARAM_UNLOCK (dparam);
+ return;
+ }
+
+ if (timestamp <= dpsmooth->start_interp) {
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_float (value, exp (dpsmooth->start_float));
+ } else {
+ g_value_set_float (value, dpsmooth->start_float);
+ }
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ dpsmooth->start_interp + dpsmooth->update_period;
+
+ GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);
+
+ GST_DPARAM_UNLOCK (dparam);
+ return;
+
+ }
+
+ time_ratio =
+ (gfloat) (timestamp -
+ dpsmooth->start_interp) / (gfloat) dpsmooth->duration_interp;
+
+ GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%"
+ G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp,
+ dpsmooth->end_interp, time_ratio);
+ GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_float,
+ dpsmooth->current_float, dparam->value_float);
+
+ dpsmooth->current_float =
+ dpsmooth->start_float + (dpsmooth->diff_float * time_ratio);
+
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ timestamp + dpsmooth->update_period;
+ if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) > dpsmooth->end_interp) {
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = dpsmooth->end_interp;
+ }
+
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_float (value, exp (dpsmooth->current_float));
+ } else {
+ g_value_set_float (value, dpsmooth->current_float);
+ }
+
+ GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_float,
+ dpsmooth->current_float, dparam->value_float);
+
+ GST_DPARAM_UNLOCK (dparam);
}
-static void
-gst_dpsmooth_value_changed_double (GstDParam *dparam)
+static void
+gst_dpsmooth_value_changed_double (GstDParam * dparam)
{
- GstDParamSmooth *dpsmooth;
- gdouble time_ratio;
+ GstDParamSmooth *dpsmooth;
+ gdouble time_ratio;
- g_return_if_fail(GST_IS_DPSMOOTH(dparam));
- dpsmooth = GST_DPSMOOTH(dparam);
+ g_return_if_fail (GST_IS_DPSMOOTH (dparam));
+ dpsmooth = GST_DPSMOOTH (dparam);
- if (GST_DPARAM_IS_LOG(dparam)){
- dparam->value_double = log(dparam->value_double);
- }
- dpsmooth->start_double = dpsmooth->current_double;
- dpsmooth->diff_double = dparam->value_double - dpsmooth->start_double;
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ dparam->value_double = log (dparam->value_double);
+ }
+ dpsmooth->start_double = dpsmooth->current_double;
+ dpsmooth->diff_double = dparam->value_double - dpsmooth->start_double;
- time_ratio = ABS(dpsmooth->diff_double) / dpsmooth->slope_delta_double;
- dpsmooth->duration_interp = (gint64)(time_ratio * (gdouble)dpsmooth->slope_time);
+ time_ratio = ABS (dpsmooth->diff_double) / dpsmooth->slope_delta_double;
+ dpsmooth->duration_interp =
+ (gint64) (time_ratio * (gdouble) dpsmooth->slope_time);
- dpsmooth->need_interp_times = TRUE;
+ dpsmooth->need_interp_times = TRUE;
- GST_DEBUG ("%f to %f ratio:%f duration:%"
- G_GINT64_FORMAT "\n",
- dpsmooth->start_double, dparam->value_double, time_ratio, dpsmooth->duration_interp);
+ GST_DEBUG ("%f to %f ratio:%f duration:%"
+ G_GINT64_FORMAT "\n",
+ dpsmooth->start_double, dparam->value_double, time_ratio,
+ dpsmooth->duration_interp);
}
static void
-gst_dpsmooth_do_update_double (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info)
+gst_dpsmooth_do_update_double (GstDParam * dparam, gint64 timestamp,
+ GValue * value, GstDParamUpdateInfo update_info)
{
- gdouble time_ratio;
- GstDParamSmooth *dpsmooth = GST_DPSMOOTH(dparam);
-
- GST_DPARAM_LOCK(dparam);
-
- if (dpsmooth->need_interp_times){
- dpsmooth->start_interp = timestamp;
- dpsmooth->end_interp = timestamp + dpsmooth->duration_interp;
- dpsmooth->need_interp_times = FALSE;
- }
-
- if ((update_info == GST_DPARAM_UPDATE_FIRST) || (timestamp >= dpsmooth->end_interp)){
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_double(value, exp(dparam->value_double));
- }
- else {
- g_value_set_double(value, dparam->value_double);
- }
- dpsmooth->current_double = dparam->value_double;
-
- GST_DEBUG ("interp finished at %"
- G_GINT64_FORMAT, timestamp);
-
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp;
-
- GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
- GST_DPARAM_UNLOCK(dparam);
- return;
- }
-
- if (timestamp <= dpsmooth->start_interp){
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_double(value, exp(dpsmooth->start_double));
- }
- else {
- g_value_set_double(value, dpsmooth->start_double);
- }
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->start_interp + dpsmooth->update_period;
-
- GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);
-
- GST_DPARAM_UNLOCK(dparam);
- return;
-
- }
-
- time_ratio = (gdouble)(timestamp - dpsmooth->start_interp) / (gdouble)dpsmooth->duration_interp;
-
- GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, dpsmooth->end_interp, time_ratio);
- GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_double, dpsmooth->current_double, dparam->value_double);
-
- dpsmooth->current_double = dpsmooth->start_double + (dpsmooth->diff_double * time_ratio);
-
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp + dpsmooth->update_period;
- if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) > dpsmooth->end_interp){
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->end_interp;
- }
-
- GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
-
- if (GST_DPARAM_IS_LOG(dparam)){
- g_value_set_double(value, exp(dpsmooth->current_double));
- }
- else {
- g_value_set_double(value, dpsmooth->current_double);
- }
-
- GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_double, dpsmooth->current_double, dparam->value_double);
-
- GST_DPARAM_UNLOCK(dparam);
+ gdouble time_ratio;
+ GstDParamSmooth *dpsmooth = GST_DPSMOOTH (dparam);
+
+ GST_DPARAM_LOCK (dparam);
+
+ if (dpsmooth->need_interp_times) {
+ dpsmooth->start_interp = timestamp;
+ dpsmooth->end_interp = timestamp + dpsmooth->duration_interp;
+ dpsmooth->need_interp_times = FALSE;
+ }
+
+ if ((update_info == GST_DPARAM_UPDATE_FIRST)
+ || (timestamp >= dpsmooth->end_interp)) {
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_double (value, exp (dparam->value_double));
+ } else {
+ g_value_set_double (value, dparam->value_double);
+ }
+ dpsmooth->current_double = dparam->value_double;
+
+ GST_DEBUG ("interp finished at %" G_GINT64_FORMAT, timestamp);
+
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp;
+
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE;
+ GST_DPARAM_UNLOCK (dparam);
+ return;
+ }
+
+ if (timestamp <= dpsmooth->start_interp) {
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_double (value, exp (dpsmooth->start_double));
+ } else {
+ g_value_set_double (value, dpsmooth->start_double);
+ }
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ dpsmooth->start_interp + dpsmooth->update_period;
+
+ GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);
+
+ GST_DPARAM_UNLOCK (dparam);
+ return;
+
+ }
+
+ time_ratio =
+ (gdouble) (timestamp -
+ dpsmooth->start_interp) / (gdouble) dpsmooth->duration_interp;
+
+ GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%"
+ G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp,
+ dpsmooth->end_interp, time_ratio);
+ GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_double,
+ dpsmooth->current_double, dparam->value_double);
+
+ dpsmooth->current_double =
+ dpsmooth->start_double + (dpsmooth->diff_double * time_ratio);
+
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
+ timestamp + dpsmooth->update_period;
+ if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) > dpsmooth->end_interp) {
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = dpsmooth->end_interp;
+ }
+
+ GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
+
+ if (GST_DPARAM_IS_LOG (dparam)) {
+ g_value_set_double (value, exp (dpsmooth->current_double));
+ } else {
+ g_value_set_double (value, dpsmooth->current_double);
+ }
+
+ GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_double,
+ dpsmooth->current_double, dparam->value_double);
+
+ GST_DPARAM_UNLOCK (dparam);
}
#include "dparam.h"
G_BEGIN_DECLS
-
#define GST_TYPE_DPSMOOTH (gst_dpsmooth_get_type ())
#define GST_DPSMOOTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPSMOOTH,GstDParamSmooth))
#define GST_DPSMOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPSMOOTH,GstDParamSmooth))
#define GST_IS_DPSMOOTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPSMOOTH))
#define GST_IS_DPSMOOTH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPSMOOTH))
-
typedef struct _GstDParamSmoothClass GstDParamSmoothClass;
typedef struct _GstDParamSmooth GstDParamSmooth;
-struct _GstDParamSmooth {
- GstDParam dparam;
+struct _GstDParamSmooth
+{
+ GstDParam dparam;
- gint64 start_interp;
- gint64 end_interp;
- gint64 duration_interp;
+ gint64 start_interp;
+ gint64 end_interp;
+ gint64 duration_interp;
- gfloat start_float;
- gfloat diff_float;
- gfloat current_float;
- gdouble start_double;
- gdouble diff_double;
- gdouble current_double;
+ gfloat start_float;
+ gfloat diff_float;
+ gfloat current_float;
+ gdouble start_double;
+ gdouble diff_double;
+ gdouble current_double;
- gint64 update_period;
- gint64 slope_time;
- gfloat slope_delta_float;
- gdouble slope_delta_double;
+ gint64 update_period;
+ gint64 slope_time;
+ gfloat slope_delta_float;
+ gdouble slope_delta_double;
- gboolean need_interp_times;
+ gboolean need_interp_times;
- gpointer _gst_reserved[GST_PADDING];
+ gpointer _gst_reserved[GST_PADDING];
};
-struct _GstDParamSmoothClass {
- GstDParamClass parent_class;
+struct _GstDParamSmoothClass
+{
+ GstDParamClass parent_class;
- /* signal callbacks */
- gpointer _gst_reserved[GST_PADDING];
+ /* signal callbacks */
+ gpointer _gst_reserved[GST_PADDING];
};
GType gst_dpsmooth_get_type (void);
-GstDParam* gst_dpsmooth_new (GType type);
+GstDParam *gst_dpsmooth_new (GType type);
G_END_DECLS
-
#endif /* __GST_DPSMOOTH_H__ */
#ifndef __GST_DPCOMMON_H__
#define __GST_DPCOMMON_H__
-G_BEGIN_DECLS
-
-typedef struct _GstDParam GstDParam;
+G_BEGIN_DECLS typedef struct _GstDParam GstDParam;
typedef struct _GstDParamManager GstDParamManager;
G_END_DECLS
-
#endif /* __GST_DPCOMMON_H__ */
#include <gst/gstmarshal.h>
#include <gst/gstinfo.h>
-GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug);
+GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug);
static GHashTable *_element_registry = NULL;
static gboolean _gst_dpman_init_done = FALSE;
-enum {
+enum
+{
NEW_REQUIRED_DPARAM,
LAST_SIGNAL
};
-static void gst_dpman_class_init (GstDParamManagerClass *klass);
-static void gst_dpman_init (GstDParamManager *dpman);
-static void gst_dpman_dispose (GObject *object);
-static GstDParamWrapper* gst_dpman_new_wrapper(GstDParamManager *dpman, GParamSpec *param_spec, gchar *unit_name, GstDPMUpdateMethod update_method);
-static GstDParamWrapper* gst_dpman_get_wrapper(GstDParamManager *dpman, gchar *dparam_name);
-static void gst_dpman_state_change (GstElement *element, gint old_state, gint new_state, GstDParamManager *dpman);
-static gboolean gst_dpman_preprocess_synchronous(GstDParamManager *dpman, guint frames, gint64 timestamp);
-static gboolean gst_dpman_preprocess_asynchronous(GstDParamManager *dpman, guint frames, gint64 timestamp);
-static gboolean gst_dpman_process_asynchronous(GstDParamManager *dpman, guint frame_count);
-static gboolean gst_dpman_preprocess_noop(GstDParamManager *dpman, guint frames, gint64 timestamp);
-static gboolean gst_dpman_process_noop(GstDParamManager *dpman, guint frame_count);
-static void gst_dpman_setup_synchronous(GstDParamManager *dpman);
-static void gst_dpman_setup_asynchronous(GstDParamManager *dpman);
-static void gst_dpman_setup_disabled(GstDParamManager *dpman);
-static void gst_dpman_teardown_synchronous(GstDParamManager *dpman);
-static void gst_dpman_teardown_asynchronous(GstDParamManager *dpman);
-static void gst_dpman_teardown_disabled(GstDParamManager *dpman);
+static void gst_dpman_class_init (GstDParamManagerClass * klass);
+static void gst_dpman_init (GstDParamManager * dpman);
+static void gst_dpman_dispose (GObject * object);
+static GstDParamWrapper *gst_dpman_new_wrapper (GstDParamManager * dpman,
+ GParamSpec * param_spec, gchar * unit_name,
+ GstDPMUpdateMethod update_method);
+static GstDParamWrapper *gst_dpman_get_wrapper (GstDParamManager * dpman,
+ gchar * dparam_name);
+static void gst_dpman_state_change (GstElement * element, gint old_state,
+ gint new_state, GstDParamManager * dpman);
+static gboolean gst_dpman_preprocess_synchronous (GstDParamManager * dpman,
+ guint frames, gint64 timestamp);
+static gboolean gst_dpman_preprocess_asynchronous (GstDParamManager * dpman,
+ guint frames, gint64 timestamp);
+static gboolean gst_dpman_process_asynchronous (GstDParamManager * dpman,
+ guint frame_count);
+static gboolean gst_dpman_preprocess_noop (GstDParamManager * dpman,
+ guint frames, gint64 timestamp);
+static gboolean gst_dpman_process_noop (GstDParamManager * dpman,
+ guint frame_count);
+static void gst_dpman_setup_synchronous (GstDParamManager * dpman);
+static void gst_dpman_setup_asynchronous (GstDParamManager * dpman);
+static void gst_dpman_setup_disabled (GstDParamManager * dpman);
+static void gst_dpman_teardown_synchronous (GstDParamManager * dpman);
+static void gst_dpman_teardown_asynchronous (GstDParamManager * dpman);
+static void gst_dpman_teardown_disabled (GstDParamManager * dpman);
static GObjectClass *parent_class;
static guint gst_dpman_signals[LAST_SIGNAL] = { 0 };
-void
-_gst_dpman_initialize()
+void
+_gst_dpman_initialize ()
{
- if (_gst_dpman_init_done) return;
-
- _gst_dpman_init_done = TRUE;
- _element_registry = g_hash_table_new(NULL,NULL);
+ if (_gst_dpman_init_done)
+ return;
+
+ _gst_dpman_init_done = TRUE;
+ _element_registry = g_hash_table_new (NULL, NULL);
}
GType
gst_dpman_get_type (void)
{
- static GType dpman_type = 0;
-
- if (!dpman_type) {
- static const GTypeInfo dpman_info = {
- sizeof(GstDParamManagerClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_dpman_class_init,
- NULL,
- NULL,
- sizeof(GstDParamManager),
- 0,
- (GInstanceInitFunc)gst_dpman_init,
- };
- dpman_type = g_type_register_static(GST_TYPE_OBJECT, "GstDParamManager", &dpman_info, 0);
- }
- return dpman_type;
+ static GType dpman_type = 0;
+
+ if (!dpman_type) {
+ static const GTypeInfo dpman_info = {
+ sizeof (GstDParamManagerClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_dpman_class_init,
+ NULL,
+ NULL,
+ sizeof (GstDParamManager),
+ 0,
+ (GInstanceInitFunc) gst_dpman_init,
+ };
+ dpman_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstDParamManager",
+ &dpman_info, 0);
+ }
+ return dpman_type;
}
static void
-gst_dpman_class_init (GstDParamManagerClass *klass)
+gst_dpman_class_init (GstDParamManagerClass * klass)
{
- GstObjectClass *gstobject_class;
- GObjectClass *gobject_class;
+ GstObjectClass *gstobject_class;
+ GObjectClass *gobject_class;
- parent_class = g_type_class_peek_parent (klass);
+ parent_class = g_type_class_peek_parent (klass);
- gstobject_class = (GstObjectClass*) klass;
- gobject_class = (GObjectClass*) klass;
- gobject_class->dispose = gst_dpman_dispose;
+ gstobject_class = (GstObjectClass *) klass;
+ gobject_class = (GObjectClass *) klass;
+ gobject_class->dispose = gst_dpman_dispose;
- klass->modes = g_hash_table_new(g_str_hash,g_str_equal);
+ klass->modes = g_hash_table_new (g_str_hash, g_str_equal);
- gst_dpman_register_mode (klass, "synchronous",
- gst_dpman_preprocess_synchronous, gst_dpman_process_noop,
- gst_dpman_setup_synchronous, gst_dpman_teardown_synchronous);
- gst_dpman_register_mode (klass, "asynchronous",
- gst_dpman_preprocess_asynchronous, gst_dpman_process_asynchronous,
- gst_dpman_setup_asynchronous, gst_dpman_teardown_asynchronous);
- gst_dpman_register_mode (klass, "disabled",
- gst_dpman_preprocess_noop, gst_dpman_process_noop,
- gst_dpman_setup_disabled, gst_dpman_teardown_disabled);
+ gst_dpman_register_mode (klass, "synchronous",
+ gst_dpman_preprocess_synchronous, gst_dpman_process_noop,
+ gst_dpman_setup_synchronous, gst_dpman_teardown_synchronous);
+ gst_dpman_register_mode (klass, "asynchronous",
+ gst_dpman_preprocess_asynchronous, gst_dpman_process_asynchronous,
+ gst_dpman_setup_asynchronous, gst_dpman_teardown_asynchronous);
+ gst_dpman_register_mode (klass, "disabled",
+ gst_dpman_preprocess_noop, gst_dpman_process_noop,
+ gst_dpman_setup_disabled, gst_dpman_teardown_disabled);
- gst_dpman_signals[NEW_REQUIRED_DPARAM] =
- g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstDParamManagerClass, new_required_dparam), NULL, NULL,
- gst_marshal_VOID__STRING, G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ gst_dpman_signals[NEW_REQUIRED_DPARAM] =
+ g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamManagerClass,
+ new_required_dparam), NULL, NULL, gst_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
-gst_dpman_init (GstDParamManager *dpman)
+gst_dpman_init (GstDParamManager * dpman)
{
- GST_DPMAN_DPARAMS(dpman) = g_hash_table_new(g_str_hash,g_str_equal);
- GST_DPMAN_DPARAMS_LIST(dpman) = NULL;
- GST_DPMAN_NAME(dpman) = NULL;
- GST_DPMAN_PARENT(dpman) = NULL;
- GST_DPMAN_MODE_NAME(dpman) = NULL;
- GST_DPMAN_MODE(dpman) = NULL;
- GST_DPMAN_RATE(dpman) = 0;
+ GST_DPMAN_DPARAMS (dpman) = g_hash_table_new (g_str_hash, g_str_equal);
+ GST_DPMAN_DPARAMS_LIST (dpman) = NULL;
+ GST_DPMAN_NAME (dpman) = NULL;
+ GST_DPMAN_PARENT (dpman) = NULL;
+ GST_DPMAN_MODE_NAME (dpman) = NULL;
+ GST_DPMAN_MODE (dpman) = NULL;
+ GST_DPMAN_RATE (dpman) = 0;
}
/**
*
* Returns: a new instance of GstDParamManager
*/
-GstDParamManager*
-gst_dpman_new (gchar *name, GstElement *parent)
+GstDParamManager *
+gst_dpman_new (gchar * name, GstElement * parent)
{
- GstDParamManager *dpman;
-
- g_return_val_if_fail (name != NULL, NULL);
+ GstDParamManager *dpman;
+
+ g_return_val_if_fail (name != NULL, NULL);
- dpman = g_object_new (gst_dpman_get_type (), NULL);
- gst_object_set_name (GST_OBJECT (dpman), name);
- gst_dpman_set_parent(dpman, parent);
+ dpman = g_object_new (gst_dpman_get_type (), NULL);
+ gst_object_set_name (GST_OBJECT (dpman), name);
+ gst_dpman_set_parent (dpman, parent);
- gst_dpman_set_mode(dpman, "disabled");
+ gst_dpman_set_mode (dpman, "disabled");
- return dpman;
+ return dpman;
}
static void
-gst_dpman_dispose (GObject *object)
+gst_dpman_dispose (GObject * object)
{
/* GstDParamManager *dpman = GST_DPMAN(object); */
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
/**
*
* Returns: true if it was successfully added
*/
-gboolean
-gst_dpman_add_required_dparam_callback (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- GstDPMUpdateFunction update_func,
- gpointer update_data)
+gboolean
+gst_dpman_add_required_dparam_callback (GstDParamManager * dpman,
+ GParamSpec * param_spec,
+ gchar * unit_name, GstDPMUpdateFunction update_func, gpointer update_data)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (dpman != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- g_return_val_if_fail (update_func != NULL, FALSE);
+ g_return_val_if_fail (dpman != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (update_func != NULL, FALSE);
- dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_CALLBACK);
+ dpwrap =
+ gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_CALLBACK);
- g_return_val_if_fail (dpwrap != NULL, FALSE);
+ g_return_val_if_fail (dpwrap != NULL, FALSE);
- GST_DEBUG ("adding required callback dparam '%s'", g_param_spec_get_name(param_spec));
+ GST_DEBUG ("adding required callback dparam '%s'",
+ g_param_spec_get_name (param_spec));
- dpwrap->update_func = update_func;
- dpwrap->update_data = update_data;
-
- g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec));
+ dpwrap->update_func = update_func;
+ dpwrap->update_data = update_data;
- return TRUE;
+ g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
+ g_param_spec_get_name (param_spec));
+
+ return TRUE;
}
/**
*
* Returns: true if it was successfully added
*/
-gboolean
-gst_dpman_add_required_dparam_direct (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- gpointer update_data)
+gboolean
+gst_dpman_add_required_dparam_direct (GstDParamManager * dpman,
+ GParamSpec * param_spec, gchar * unit_name, gpointer update_data)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (dpman != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- g_return_val_if_fail (update_data != NULL, FALSE);
+ g_return_val_if_fail (dpman != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (update_data != NULL, FALSE);
- dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_DIRECT);
+ dpwrap =
+ gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_DIRECT);
- g_return_val_if_fail (dpwrap != NULL, FALSE);
+ g_return_val_if_fail (dpwrap != NULL, FALSE);
- GST_DEBUG ("adding required direct dparam '%s'", g_param_spec_get_name(param_spec));
+ GST_DEBUG ("adding required direct dparam '%s'",
+ g_param_spec_get_name (param_spec));
- dpwrap->update_data = update_data;
+ dpwrap->update_data = update_data;
- g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec));
+ g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
+ g_param_spec_get_name (param_spec));
- return TRUE;
+ return TRUE;
}
/**
*
* Returns: true if it was successfully added
*/
-gboolean
-gst_dpman_add_required_dparam_array (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- gpointer update_data)
+gboolean
+gst_dpman_add_required_dparam_array (GstDParamManager * dpman,
+ GParamSpec * param_spec, gchar * unit_name, gpointer update_data)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (dpman != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- g_return_val_if_fail (update_data != NULL, FALSE);
+ g_return_val_if_fail (dpman != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (update_data != NULL, FALSE);
- dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_ARRAY);
+ dpwrap =
+ gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_ARRAY);
- g_return_val_if_fail (dpwrap != NULL, FALSE);
+ g_return_val_if_fail (dpwrap != NULL, FALSE);
- GST_DEBUG ("adding required array dparam '%s'", g_param_spec_get_name(param_spec));
+ GST_DEBUG ("adding required array dparam '%s'",
+ g_param_spec_get_name (param_spec));
- dpwrap->update_data = update_data;
+ dpwrap->update_data = update_data;
- g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec));
+ g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0,
+ g_param_spec_get_name (param_spec));
- return TRUE;
+ return TRUE;
}
/**
* @dparam_name: the name of an existing parameter
*
*/
-void
-gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name)
+void
+gst_dpman_remove_required_dparam (GstDParamManager * dpman, gchar * dparam_name)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_if_fail (dpman != NULL);
- g_return_if_fail (GST_IS_DPMAN (dpman));
- g_return_if_fail (dparam_name != NULL);
+ g_return_if_fail (dpman != NULL);
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+ g_return_if_fail (dparam_name != NULL);
- dpwrap = gst_dpman_get_wrapper(dpman, dparam_name);
-
- g_return_if_fail(dpwrap != NULL);
- g_return_if_fail(dpwrap->dparam == NULL);
+ dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
- GST_DEBUG ("removing required dparam: %s", dparam_name);
-
- g_hash_table_remove(GST_DPMAN_DPARAMS(dpman), dparam_name);
- GST_DPMAN_DPARAMS_LIST(dpman) = g_list_remove(GST_DPMAN_DPARAMS_LIST(dpman), dpwrap);
+ g_return_if_fail (dpwrap != NULL);
+ g_return_if_fail (dpwrap->dparam == NULL);
- g_free(dpwrap->value);
- g_free(dpwrap);
+ GST_DEBUG ("removing required dparam: %s", dparam_name);
+
+ g_hash_table_remove (GST_DPMAN_DPARAMS (dpman), dparam_name);
+ GST_DPMAN_DPARAMS_LIST (dpman) =
+ g_list_remove (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap);
+
+ g_free (dpwrap->value);
+ g_free (dpwrap);
}
/**
*
* Returns: true if it was successfully attached
*/
-gboolean
-gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam)
+gboolean
+gst_dpman_attach_dparam (GstDParamManager * dpman, gchar * dparam_name,
+ GstDParam * dparam)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (dpman != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- g_return_val_if_fail (dparam_name != NULL, FALSE);
- g_return_val_if_fail (dparam != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPARAM (dparam), FALSE);
- g_return_val_if_fail (dparam != NULL, FALSE);
+ g_return_val_if_fail (dpman != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (dparam_name != NULL, FALSE);
+ g_return_val_if_fail (dparam != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPARAM (dparam), FALSE);
+ g_return_val_if_fail (dparam != NULL, FALSE);
- dpwrap = gst_dpman_get_wrapper(dpman, dparam_name);
+ dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
- g_return_val_if_fail (dpwrap != NULL, FALSE);
- g_return_val_if_fail (dpwrap->value != NULL, FALSE);
- g_return_val_if_fail (G_PARAM_SPEC_VALUE_TYPE (dpwrap->param_spec) == GST_DPARAM_TYPE(dparam), FALSE);
+ g_return_val_if_fail (dpwrap != NULL, FALSE);
+ g_return_val_if_fail (dpwrap->value != NULL, FALSE);
+ g_return_val_if_fail (G_PARAM_SPEC_VALUE_TYPE (dpwrap->param_spec) ==
+ GST_DPARAM_TYPE (dparam), FALSE);
- dpwrap->dparam = dparam;
- gst_dparam_attach(dparam, dpman, dpwrap->param_spec, dpwrap->unit_name);
+ dpwrap->dparam = dparam;
+ gst_dparam_attach (dparam, dpman, dpwrap->param_spec, dpwrap->unit_name);
- return TRUE;
+ return TRUE;
}
/**
* @dparam_name: the name of a parameter with a previously attached GstDParam
*
*/
-void
-gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name)
+void
+gst_dpman_detach_dparam (GstDParamManager * dpman, gchar * dparam_name)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
+
+ g_return_if_fail (dpman != NULL);
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+ g_return_if_fail (dparam_name != NULL);
+
+ dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
+
+ g_return_if_fail (dpwrap);
- g_return_if_fail (dpman != NULL);
- g_return_if_fail (GST_IS_DPMAN (dpman));
- g_return_if_fail (dparam_name != NULL);
-
- dpwrap = gst_dpman_get_wrapper(dpman, dparam_name);
+ gst_dparam_detach (dpwrap->dparam);
+ dpwrap->dparam = NULL;
- g_return_if_fail(dpwrap);
-
- gst_dparam_detach(dpwrap->dparam);
- dpwrap->dparam = NULL;
-
}
/**
* Returns: the dparam with the given name - or NULL otherwise
*/
GstDParam *
-gst_dpman_get_dparam (GstDParamManager *dpman, gchar *name)
+gst_dpman_get_dparam (GstDParamManager * dpman, gchar * name)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (dpman != NULL, NULL);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- dpwrap = g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), name);
- g_return_val_if_fail (dpwrap != NULL, NULL);
-
- return dpwrap->dparam;
+ g_return_val_if_fail (dpman != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ dpwrap = g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), name);
+ g_return_val_if_fail (dpwrap != NULL, NULL);
+
+ return dpwrap->dparam;
}
/**
* Returns: the type that this dparam requires/uses
*/
GType
-gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name)
-{
- GstDParamWrapper* dpwrap;
-
- g_return_val_if_fail (dpman != NULL, 0);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), 0);
- g_return_val_if_fail (name != NULL, 0);
-
- dpwrap = g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), name);
- g_return_val_if_fail (dpwrap != NULL, 0);
-
- return G_VALUE_TYPE(dpwrap->value);
-}
-
-GParamSpec**
-gst_dpman_list_dparam_specs(GstDParamManager *dpman)
-{
- GstDParamWrapper* dpwrap;
- GList *dwraps;
- GParamSpec** param_specs;
- guint x = 0;
-
- g_return_val_if_fail (dpman != NULL, NULL);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
-
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
-
- param_specs = g_new0(GParamSpec*, g_list_length(dwraps) + 1);
-
- while (dwraps){
- dpwrap = (GstDParamWrapper*)dwraps->data;
- param_specs[x++] = dpwrap->param_spec;
- dwraps = g_list_next(dwraps);
- }
- return param_specs;
+gst_dpman_get_dparam_type (GstDParamManager * dpman, gchar * name)
+{
+ GstDParamWrapper *dpwrap;
+
+ g_return_val_if_fail (dpman != NULL, 0);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), 0);
+ g_return_val_if_fail (name != NULL, 0);
+
+ dpwrap = g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), name);
+ g_return_val_if_fail (dpwrap != NULL, 0);
+
+ return G_VALUE_TYPE (dpwrap->value);
}
-GParamSpec*
-gst_dpman_get_param_spec (GstDParamManager *dpman, gchar *dparam_name)
+GParamSpec **
+gst_dpman_list_dparam_specs (GstDParamManager * dpman)
{
- GstDParamWrapper* dpwrap;
+ GstDParamWrapper *dpwrap;
+ GList *dwraps;
+ GParamSpec **param_specs;
+ guint x = 0;
+
+ g_return_val_if_fail (dpman != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
+
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
- g_return_val_if_fail (dpman != NULL, NULL);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
- g_return_val_if_fail (dparam_name != NULL, NULL);
+ param_specs = g_new0 (GParamSpec *, g_list_length (dwraps) + 1);
- dpwrap = gst_dpman_get_wrapper(dpman, dparam_name);
- return dpwrap->param_spec;
+ while (dwraps) {
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+ param_specs[x++] = dpwrap->param_spec;
+ dwraps = g_list_next (dwraps);
+ }
+ return param_specs;
+}
+
+GParamSpec *
+gst_dpman_get_param_spec (GstDParamManager * dpman, gchar * dparam_name)
+{
+ GstDParamWrapper *dpwrap;
+
+ g_return_val_if_fail (dpman != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
+ g_return_val_if_fail (dparam_name != NULL, NULL);
+
+ dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
+ return dpwrap->param_spec;
}
void
-gst_dpman_set_rate (GstDParamManager *dpman, gint rate)
+gst_dpman_set_rate (GstDParamManager * dpman, gint rate)
{
- g_return_if_fail (GST_IS_DPMAN (dpman));
- GST_DPMAN_RATE(dpman) = rate;
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+ GST_DPMAN_RATE (dpman) = rate;
}
/**
*
*/
void
-gst_dpman_register_mode (GstDParamManagerClass *klass,
- gchar *modename,
- GstDPMModePreProcessFunction preprocessfunc,
- GstDPMModeProcessFunction processfunc,
- GstDPMModeSetupFunction setupfunc,
- GstDPMModeTeardownFunction teardownfunc)
+gst_dpman_register_mode (GstDParamManagerClass * klass,
+ gchar * modename,
+ GstDPMModePreProcessFunction preprocessfunc,
+ GstDPMModeProcessFunction processfunc,
+ GstDPMModeSetupFunction setupfunc, GstDPMModeTeardownFunction teardownfunc)
{
- GstDPMMode *mode;
+ GstDPMMode *mode;
+
+ g_return_if_fail (klass != NULL);
+ g_return_if_fail (modename != NULL);
+ g_return_if_fail (GST_IS_DPMAN_CLASS (klass));
+
+ mode = g_new0 (GstDPMMode, 1);
- g_return_if_fail (klass != NULL);
- g_return_if_fail (modename != NULL);
- g_return_if_fail (GST_IS_DPMAN_CLASS (klass));
-
- mode = g_new0(GstDPMMode,1);
+ mode->preprocessfunc = preprocessfunc;
+ mode->processfunc = processfunc;
+ mode->setupfunc = setupfunc;
+ mode->teardownfunc = teardownfunc;
- mode->preprocessfunc = preprocessfunc;
- mode->processfunc = processfunc;
- mode->setupfunc = setupfunc;
- mode->teardownfunc = teardownfunc;
-
- g_hash_table_insert(klass->modes, modename, mode);
+ g_hash_table_insert (klass->modes, modename, mode);
}
/**
* Returns: TRUE if the mode was set, FALSE otherwise
*/
gboolean
-gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename)
-{
- GstDPMMode *mode=NULL;
- GstDParamManagerClass *oclass;
-
- g_return_val_if_fail (dpman != NULL, FALSE);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- g_return_val_if_fail (modename != NULL, FALSE);
-
- oclass = (GstDParamManagerClass*)(G_OBJECT_GET_CLASS(dpman));
-
- mode = g_hash_table_lookup(oclass->modes, modename);
- g_return_val_if_fail (mode != NULL, FALSE);
-
- if (GST_DPMAN_MODE(dpman) == mode) {
- GST_DEBUG ("mode %s already set", modename);
- return TRUE;
- }
-
- GST_DEBUG ("setting mode to %s", modename);
- if (GST_DPMAN_MODE(dpman) && GST_DPMAN_TEARDOWNFUNC(dpman)){
- GST_DPMAN_TEARDOWNFUNC(dpman)(dpman);
- }
-
- GST_DPMAN_MODE(dpman) = mode;
+gst_dpman_set_mode (GstDParamManager * dpman, gchar * modename)
+{
+ GstDPMMode *mode = NULL;
+ GstDParamManagerClass *oclass;
- if (GST_DPMAN_SETUPFUNC(dpman)){
- GST_DPMAN_SETUPFUNC(dpman)(dpman);
- }
-
- return TRUE;
+ g_return_val_if_fail (dpman != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (modename != NULL, FALSE);
+
+ oclass = (GstDParamManagerClass *) (G_OBJECT_GET_CLASS (dpman));
+
+ mode = g_hash_table_lookup (oclass->modes, modename);
+ g_return_val_if_fail (mode != NULL, FALSE);
+
+ if (GST_DPMAN_MODE (dpman) == mode) {
+ GST_DEBUG ("mode %s already set", modename);
+ return TRUE;
+ }
+
+ GST_DEBUG ("setting mode to %s", modename);
+ if (GST_DPMAN_MODE (dpman) && GST_DPMAN_TEARDOWNFUNC (dpman)) {
+ GST_DPMAN_TEARDOWNFUNC (dpman) (dpman);
+ }
+
+ GST_DPMAN_MODE (dpman) = mode;
+
+ if (GST_DPMAN_SETUPFUNC (dpman)) {
+ GST_DPMAN_SETUPFUNC (dpman) (dpman);
+ }
+
+ return TRUE;
}
/**
*
*/
void
-gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent)
+gst_dpman_set_parent (GstDParamManager * dpman, GstElement * parent)
{
- g_return_if_fail (dpman != NULL);
- g_return_if_fail (GST_IS_DPMAN (dpman));
- g_return_if_fail (parent != NULL);
- g_return_if_fail (GST_IS_ELEMENT (parent));
-
- g_hash_table_insert(_element_registry, parent, dpman);
- gst_object_set_parent (GST_OBJECT (dpman), GST_OBJECT(parent));
- g_signal_connect(G_OBJECT(parent), "state_change",
- G_CALLBACK (gst_dpman_state_change), dpman);
+ g_return_if_fail (dpman != NULL);
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+ g_return_if_fail (parent != NULL);
+ g_return_if_fail (GST_IS_ELEMENT (parent));
+
+ g_hash_table_insert (_element_registry, parent, dpman);
+ gst_object_set_parent (GST_OBJECT (dpman), GST_OBJECT (parent));
+ g_signal_connect (G_OBJECT (parent), "state_change",
+ G_CALLBACK (gst_dpman_state_change), dpman);
}
/**
* if it doesn't exist
*/
GstDParamManager *
-gst_dpman_get_manager (GstElement *parent)
+gst_dpman_get_manager (GstElement * parent)
{
- GstDParamManager *dpman;
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL);
-
- dpman = (GstDParamManager*)g_hash_table_lookup(_element_registry, parent);
- return dpman;
+ GstDParamManager *dpman;
+
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL);
+
+ dpman = (GstDParamManager *) g_hash_table_lookup (_element_registry, parent);
+ return dpman;
}
/**
*
*/
void
-gst_dpman_bypass_dparam(GstDParamManager *dpman, gchar *dparam_name)
-{
- GstDParamWrapper* dpwrap;
-
- g_return_if_fail (dpman != NULL);
- g_return_if_fail (GST_IS_DPMAN (dpman));
- g_return_if_fail (dparam_name != NULL);
-
- dpwrap = gst_dpman_get_wrapper(dpman, dparam_name);
- g_return_if_fail (dpwrap != NULL);
-
- if (dpwrap->dparam != NULL){
- g_warning("Bypassing attached dparam '%s'. It will be detached", dparam_name);
- gst_dpman_detach_dparam(dpman, dparam_name);
- }
-}
+gst_dpman_bypass_dparam (GstDParamManager * dpman, gchar * dparam_name)
+{
+ GstDParamWrapper *dpwrap;
-static GstDParamWrapper*
-gst_dpman_get_wrapper(GstDParamManager *dpman, gchar *dparam_name)
-{
- g_return_val_if_fail (dpman != NULL, NULL);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
- g_return_val_if_fail (dparam_name != NULL, NULL);
-
- return g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), dparam_name);
-}
-
-static GstDParamWrapper*
-gst_dpman_new_wrapper(GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- GstDPMUpdateMethod update_method)
-{
- GstDParamWrapper* dpwrap;
- gchar *dparam_name;
-
- g_return_val_if_fail (dpman != NULL, NULL);
- g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
- g_return_val_if_fail (param_spec != NULL, NULL);
- g_return_val_if_fail (gst_unitconv_unit_exists(unit_name), NULL);
-
- dparam_name = g_strdup(g_param_spec_get_name(param_spec));
- g_return_val_if_fail(gst_dpman_get_wrapper(dpman, dparam_name) == NULL, NULL);
-
- dpwrap = g_new0(GstDParamWrapper,1);
- dpwrap->update_method = update_method;
- dpwrap->value = g_new0(GValue,1);
- g_value_init(dpwrap->value, G_PARAM_SPEC_VALUE_TYPE(param_spec));
- dpwrap->param_spec = param_spec;
- dpwrap->unit_name = unit_name;
-
- g_hash_table_insert(GST_DPMAN_DPARAMS(dpman), dparam_name, dpwrap);
- GST_DPMAN_DPARAMS_LIST(dpman) = g_list_append(GST_DPMAN_DPARAMS_LIST(dpman), dpwrap);
-
- return dpwrap;
-}
-
-
-static void
-gst_dpman_state_change (GstElement *element, gint old_state, gint new_state, GstDParamManager *dpman)
-{
- GList *dwraps;
- GstDParam *dparam;
- GstDParamWrapper *dpwrap;
-
- g_return_if_fail (dpman != NULL);
- g_return_if_fail (GST_IS_DPMAN (dpman));
-
- if (new_state == GST_STATE_PLAYING){
- GST_DEBUG ("initialising params");
-
-
- /* force all params to be updated */
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- while (dwraps){
- dpwrap = (GstDParamWrapper*)dwraps->data;
- dparam = dpwrap->dparam;
-
- if (dparam){
- GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = 0LL;
- }
- /* some dparams treat the first update after the pipeline starts differently */
- dpwrap->update_info = GST_DPARAM_UPDATE_FIRST;
- dwraps = g_list_next(dwraps);
- }
- }
+ g_return_if_fail (dpman != NULL);
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+ g_return_if_fail (dparam_name != NULL);
+
+ dpwrap = gst_dpman_get_wrapper (dpman, dparam_name);
+ g_return_if_fail (dpwrap != NULL);
+
+ if (dpwrap->dparam != NULL) {
+ g_warning ("Bypassing attached dparam '%s'. It will be detached",
+ dparam_name);
+ gst_dpman_detach_dparam (dpman, dparam_name);
+ }
}
-static inline void
-gst_dpman_inline_direct_update(GValue *value, gpointer data){
- switch (G_VALUE_TYPE(value)){
- case G_TYPE_INT:
- *(gint*)data = g_value_get_int(value);
- break;
- case G_TYPE_INT64:
- *(gint64*)data = g_value_get_int64(value);
- break;
- case G_TYPE_FLOAT:
- *(gfloat*)data = g_value_get_float(value);
- break;
- case G_TYPE_DOUBLE:
- *(double*)data = g_value_get_double(value);
- break;
- default:
- break;
- }
+static GstDParamWrapper *
+gst_dpman_get_wrapper (GstDParamManager * dpman, gchar * dparam_name)
+{
+ g_return_val_if_fail (dpman != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
+ g_return_val_if_fail (dparam_name != NULL, NULL);
+
+ return g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), dparam_name);
}
-static gboolean
-gst_dpman_preprocess_synchronous(GstDParamManager *dpman, guint frames, gint64 timestamp)
-{
- GList *dwraps;
- GstDParamWrapper *dpwrap;
-
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
-
- /* this basically means don't call GST_DPMAN_PREPROCESS at all */
- dpman->next_update_frame = frames;
- dpman->frames_to_process = frames;
-
- /* now check whether any dparams are ready for an update */
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- while (dwraps){
- dpwrap = (GstDParamWrapper*)dwraps->data;
-
- if (dpwrap->dparam &&
- GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam) &&
- GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam) <= timestamp){
-
- switch (dpwrap->update_method) {
-
- /* direct method - set the value directly in the struct of the element */
- case GST_DPMAN_DIRECT:
- GST_DPARAM_DO_UPDATE(dpwrap->dparam, timestamp, dpwrap->value, dpwrap->update_info);
- GST_DEBUG ("doing direct update");
-
- gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data);
- break;
-
- /* callback method - call the element's callback so it can do what it likes */
- case GST_DPMAN_CALLBACK:
- GST_DPARAM_DO_UPDATE(dpwrap->dparam, timestamp, dpwrap->value, dpwrap->update_info);
- GST_DEBUG ("doing callback update");
-
- GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value);
- break;
-
- case GST_DPMAN_ARRAY:
- /* FIXME do array method checking here */
- break;
- default:
- break;
- }
-
- if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST){
- /* it is not the first update anymore */
- dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
- }
- }
- dwraps = g_list_next(dwraps);
- }
+static GstDParamWrapper *
+gst_dpman_new_wrapper (GstDParamManager * dpman,
+ GParamSpec * param_spec,
+ gchar * unit_name, GstDPMUpdateMethod update_method)
+{
+ GstDParamWrapper *dpwrap;
+ gchar *dparam_name;
+
+ g_return_val_if_fail (dpman != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL);
+ g_return_val_if_fail (param_spec != NULL, NULL);
+ g_return_val_if_fail (gst_unitconv_unit_exists (unit_name), NULL);
+
+ dparam_name = g_strdup (g_param_spec_get_name (param_spec));
+ g_return_val_if_fail (gst_dpman_get_wrapper (dpman, dparam_name) == NULL,
+ NULL);
+
+ dpwrap = g_new0 (GstDParamWrapper, 1);
+ dpwrap->update_method = update_method;
+ dpwrap->value = g_new0 (GValue, 1);
+ g_value_init (dpwrap->value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
+ dpwrap->param_spec = param_spec;
+ dpwrap->unit_name = unit_name;
+
+ g_hash_table_insert (GST_DPMAN_DPARAMS (dpman), dparam_name, dpwrap);
+ GST_DPMAN_DPARAMS_LIST (dpman) =
+ g_list_append (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap);
+
+ return dpwrap;
+}
- return FALSE;
+static void
+gst_dpman_state_change (GstElement * element, gint old_state, gint new_state,
+ GstDParamManager * dpman)
+{
+ GList *dwraps;
+ GstDParam *dparam;
+ GstDParamWrapper *dpwrap;
+
+ g_return_if_fail (dpman != NULL);
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+
+ if (new_state == GST_STATE_PLAYING) {
+ GST_DEBUG ("initialising params");
+
+
+ /* force all params to be updated */
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ while (dwraps) {
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+ dparam = dpwrap->dparam;
+
+ if (dparam) {
+ GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL;
+ }
+ /* some dparams treat the first update after the pipeline starts differently */
+ dpwrap->update_info = GST_DPARAM_UPDATE_FIRST;
+ dwraps = g_list_next (dwraps);
+ }
+ }
}
-static gint
-gst_dpman_dpwrap_compare (const GstDParamWrapper *a, const GstDParamWrapper *b)
+static inline void
+gst_dpman_inline_direct_update (GValue * value, gpointer data)
{
- if (a->next_update_frame > b->next_update_frame) return 1;
- return (a->next_update_frame < b->next_update_frame) ? -1 : 0;
+ switch (G_VALUE_TYPE (value)) {
+ case G_TYPE_INT:
+ *(gint *) data = g_value_get_int (value);
+ break;
+ case G_TYPE_INT64:
+ *(gint64 *) data = g_value_get_int64 (value);
+ break;
+ case G_TYPE_FLOAT:
+ *(gfloat *) data = g_value_get_float (value);
+ break;
+ case G_TYPE_DOUBLE:
+ *(double *) data = g_value_get_double (value);
+ break;
+ default:
+ break;
+ }
}
-static gboolean
-gst_dpman_preprocess_asynchronous(GstDParamManager *dpman, guint frames, gint64 timestamp)
+static gboolean
+gst_dpman_preprocess_synchronous (GstDParamManager * dpman, guint frames,
+ gint64 timestamp)
{
- GList *dwraps;
- GstDParamWrapper *dpwrap;
- gint64 current_time;
- gboolean updates_pending;
+ GList *dwraps;
+ GstDParamWrapper *dpwrap;
- g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
+ /* this basically means don't call GST_DPMAN_PREPROCESS at all */
+ dpman->next_update_frame = frames;
+ dpman->frames_to_process = frames;
- if (GST_DPMAN_RATE(dpman) == 0){
- g_warning("The element hasn't given GstDParamManager a frame rate");
- return FALSE;
- }
- dpman->rate_ratio = (guint)(1000000000LL / (gint64)GST_DPMAN_RATE(dpman));
-
- dpman->time_buffer_starts = timestamp;
- dpman->time_buffer_ends = timestamp + ((gint64)frames * (gint64)dpman->rate_ratio);
- dpman->num_frames = frames;
-
- updates_pending = FALSE;
-
- /* now check whether any dparams are ready for an update */
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- while (dwraps){
- dpwrap = (GstDParamWrapper*)dwraps->data;
-
- dpwrap->next_update_frame = frames;
-
- if (dpwrap->dparam &&
- GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam)){
-
- current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam);
- if (current_time > dpman->time_buffer_ends){
- /* not due for an update in this buffer */
- dwraps = g_list_next(dwraps);
- continue;
- }
- if (current_time < timestamp){
- current_time = timestamp;
- }
-
- if (current_time == timestamp){
- /* we are overdue for an update. lets do it now */
-
- GST_DPARAM_DO_UPDATE(dpwrap->dparam, current_time, dpwrap->value, dpwrap->update_info);
-
- if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST){
- /* it is not the first update anymore */
- dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
- }
-
- switch (dpwrap->update_method) {
-
- /* direct method - set the value directly in the struct of the element */
- case GST_DPMAN_DIRECT:
- GST_DEBUG ("doing direct update");
- gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data);
- break;
-
- /* callback method - call the element's callback so it can do what it likes */
- case GST_DPMAN_CALLBACK:
- GST_DEBUG ("doing callback update");
- GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value);
- break;
- default:
- break;
- }
-
- current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam);
-
- if (!GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam) ||
- current_time > dpman->time_buffer_ends){
- /* not due for an update in this buffer */
- dwraps = g_list_next(dwraps);
- continue;
- }
- }
-
- dpwrap->next_update_frame = (guint)(current_time - timestamp) / dpman->rate_ratio;
- updates_pending = TRUE;
-
- GST_DEBUG ("timestamp start: %"
- G_GINT64_FORMAT " end: %"
- G_GINT64_FORMAT " current: %"
- G_GINT64_FORMAT,
- timestamp, dpman->time_buffer_ends, current_time);
-
- }
- dwraps = g_list_next(dwraps);
- }
- if (updates_pending){
- GST_DPMAN_DPARAMS_LIST(dpman) = g_list_sort(GST_DPMAN_DPARAMS_LIST(dpman), (GCompareFunc)gst_dpman_dpwrap_compare);
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- dpwrap = (GstDParamWrapper*)dwraps->data;
+ /* now check whether any dparams are ready for an update */
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ while (dwraps) {
+ dpwrap = (GstDParamWrapper *) dwraps->data;
- dpman->next_update_frame = dpwrap->next_update_frame;
- dpman->frames_to_process = dpman->next_update_frame;
+ if (dpwrap->dparam &&
+ GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) &&
+ GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam) <= timestamp) {
- GST_DEBUG ("next update frame %u, frames to process %u", dpman->next_update_frame, dpman->frames_to_process);
- return TRUE;
- }
-
- dpman->next_update_frame = frames;
- dpman->frames_to_process = frames;
- return FALSE;
+ switch (dpwrap->update_method) {
+
+ /* direct method - set the value directly in the struct of the element */
+ case GST_DPMAN_DIRECT:
+ GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
+ dpwrap->update_info);
+ GST_DEBUG ("doing direct update");
+
+ gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
+ break;
+
+ /* callback method - call the element's callback so it can do what it likes */
+ case GST_DPMAN_CALLBACK:
+ GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
+ dpwrap->update_info);
+ GST_DEBUG ("doing callback update");
+
+ GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
+ break;
+
+ case GST_DPMAN_ARRAY:
+ /* FIXME do array method checking here */
+ break;
+ default:
+ break;
+ }
+
+ if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
+ /* it is not the first update anymore */
+ dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
+ }
+ }
+ dwraps = g_list_next (dwraps);
+ }
+
+
+ return FALSE;
}
-static gboolean
-gst_dpman_process_asynchronous(GstDParamManager *dpman, guint frame_count)
+static gint
+gst_dpman_dpwrap_compare (const GstDParamWrapper * a,
+ const GstDParamWrapper * b)
{
- GstDParamWrapper *dpwrap;
- GList *dwraps;
- gint64 current_time;
- gboolean needs_resort = FALSE;
+ if (a->next_update_frame > b->next_update_frame)
+ return 1;
+ return (a->next_update_frame < b->next_update_frame) ? -1 : 0;
+}
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- dpwrap = (GstDParamWrapper*)dwraps->data;
+static gboolean
+gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, guint frames,
+ gint64 timestamp)
+{
+ GList *dwraps;
+ GstDParamWrapper *dpwrap;
+ gint64 current_time;
+ gboolean updates_pending;
- GST_DEBUG ("in gst_dpman_process_asynchronous");
+ g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE);
- if (frame_count >= dpman->num_frames){
- g_warning("there is no more buffer to process");
- dpman->next_update_frame = dpman->num_frames;
- dpman->frames_to_process = 0;
- return FALSE;
- }
- if (frame_count != dpwrap->next_update_frame){
- g_warning("frame count %u does not match update frame %u",
- frame_count, dpwrap->next_update_frame);
- }
+ if (GST_DPMAN_RATE (dpman) == 0) {
+ g_warning ("The element hasn't given GstDParamManager a frame rate");
+ return FALSE;
+ }
+ dpman->rate_ratio = (guint) (1000000000LL / (gint64) GST_DPMAN_RATE (dpman));
- while (dpwrap){
-
- current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam);
- GST_DPARAM_DO_UPDATE(dpwrap->dparam, current_time, dpwrap->value, dpwrap->update_info);
- switch (dpwrap->update_method) {
-
- /* direct method - set the value directly in the struct of the element */
- case GST_DPMAN_DIRECT:
- GST_DEBUG ("doing direct update");
- gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data);
- break;
-
- /* callback method - call the element's callback so it can do what it likes */
- case GST_DPMAN_CALLBACK:
- GST_DEBUG ("doing callback update");
- GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value);
- break;
- default:
- break;
- }
-
- dpwrap->next_update_frame = dpman->num_frames;
- needs_resort = TRUE;
-
- if(GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam)){
- current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam);
- if (current_time <= dpman->time_buffer_ends){
- dpwrap->next_update_frame = (guint)(current_time - dpman->time_buffer_starts) / dpman->rate_ratio;
- }
- }
-
- if ((dwraps = g_list_next(dwraps))){
- dpwrap = (GstDParamWrapper*)dwraps->data;
- if (frame_count == dpwrap->next_update_frame){
- continue;
- }
- }
- dpwrap = NULL;
- }
+ dpman->time_buffer_starts = timestamp;
+ dpman->time_buffer_ends =
+ timestamp + ((gint64) frames * (gint64) dpman->rate_ratio);
+ dpman->num_frames = frames;
+
+ updates_pending = FALSE;
+
+ /* now check whether any dparams are ready for an update */
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ while (dwraps) {
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+
+ dpwrap->next_update_frame = frames;
+
+ if (dpwrap->dparam && GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) {
+
+ current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
+ if (current_time > dpman->time_buffer_ends) {
+ /* not due for an update in this buffer */
+ dwraps = g_list_next (dwraps);
+ continue;
+ }
+ if (current_time < timestamp) {
+ current_time = timestamp;
+ }
+
+ if (current_time == timestamp) {
+ /* we are overdue for an update. lets do it now */
- if (needs_resort && g_list_length(GST_DPMAN_DPARAMS_LIST(dpman)) > 1){
- GST_DPMAN_DPARAMS_LIST(dpman) = g_list_sort(GST_DPMAN_DPARAMS_LIST(dpman), (GCompareFunc)gst_dpman_dpwrap_compare);
+ GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
+ dpwrap->update_info);
+
+ if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
+ /* it is not the first update anymore */
+ dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
}
-
- dwraps = GST_DPMAN_DPARAMS_LIST(dpman);
- dpwrap = (GstDParamWrapper*)dwraps->data;
-
- if (dpwrap->next_update_frame == dpman->num_frames){
- dpman->next_update_frame = dpman->num_frames;
- dpman->frames_to_process = dpman->num_frames - frame_count;
- GST_DEBUG ("no more updates, frames to process %u", dpman->frames_to_process);
+
+ switch (dpwrap->update_method) {
+
+ /* direct method - set the value directly in the struct of the element */
+ case GST_DPMAN_DIRECT:
+ GST_DEBUG ("doing direct update");
+ gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
+ break;
+
+ /* callback method - call the element's callback so it can do what it likes */
+ case GST_DPMAN_CALLBACK:
+ GST_DEBUG ("doing callback update");
+ GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
+ break;
+ default:
+ break;
}
- else {
- dpman->next_update_frame = dpwrap->next_update_frame;
- dpman->frames_to_process = dpman->next_update_frame - frame_count;
- GST_DEBUG ("next update frame %u, frames to process %u", dpman->next_update_frame, dpman->frames_to_process);
+
+ current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
+
+ if (!GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) ||
+ current_time > dpman->time_buffer_ends) {
+ /* not due for an update in this buffer */
+ dwraps = g_list_next (dwraps);
+ continue;
}
+ }
+
+ dpwrap->next_update_frame =
+ (guint) (current_time - timestamp) / dpman->rate_ratio;
+ updates_pending = TRUE;
+
+ GST_DEBUG ("timestamp start: %"
+ G_GINT64_FORMAT " end: %"
+ G_GINT64_FORMAT " current: %"
+ G_GINT64_FORMAT, timestamp, dpman->time_buffer_ends, current_time);
+
+ }
+ dwraps = g_list_next (dwraps);
+ }
+ if (updates_pending) {
+ GST_DPMAN_DPARAMS_LIST (dpman) =
+ g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
+ (GCompareFunc) gst_dpman_dpwrap_compare);
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+
+ dpman->next_update_frame = dpwrap->next_update_frame;
+ dpman->frames_to_process = dpman->next_update_frame;
+
+ GST_DEBUG ("next update frame %u, frames to process %u",
+ dpman->next_update_frame, dpman->frames_to_process);
+ return TRUE;
+ }
+
+ dpman->next_update_frame = frames;
+ dpman->frames_to_process = frames;
+ return FALSE;
+}
- return TRUE;
+static gboolean
+gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
+{
+ GstDParamWrapper *dpwrap;
+ GList *dwraps;
+ gint64 current_time;
+ gboolean needs_resort = FALSE;
+
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+
+ GST_DEBUG ("in gst_dpman_process_asynchronous");
+
+ if (frame_count >= dpman->num_frames) {
+ g_warning ("there is no more buffer to process");
+ dpman->next_update_frame = dpman->num_frames;
+ dpman->frames_to_process = 0;
+ return FALSE;
+ }
+
+ if (frame_count != dpwrap->next_update_frame) {
+ g_warning ("frame count %u does not match update frame %u",
+ frame_count, dpwrap->next_update_frame);
+ }
+
+ while (dpwrap) {
+
+ current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
+ GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
+ dpwrap->update_info);
+ switch (dpwrap->update_method) {
+
+ /* direct method - set the value directly in the struct of the element */
+ case GST_DPMAN_DIRECT:
+ GST_DEBUG ("doing direct update");
+ gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
+ break;
+
+ /* callback method - call the element's callback so it can do what it likes */
+ case GST_DPMAN_CALLBACK:
+ GST_DEBUG ("doing callback update");
+ GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
+ break;
+ default:
+ break;
+ }
+
+ dpwrap->next_update_frame = dpman->num_frames;
+ needs_resort = TRUE;
+
+ if (GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) {
+ current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
+ if (current_time <= dpman->time_buffer_ends) {
+ dpwrap->next_update_frame =
+ (guint) (current_time -
+ dpman->time_buffer_starts) / dpman->rate_ratio;
+ }
+ }
+
+ if ((dwraps = g_list_next (dwraps))) {
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+ if (frame_count == dpwrap->next_update_frame) {
+ continue;
+ }
+ }
+ dpwrap = NULL;
+ }
+
+ if (needs_resort && g_list_length (GST_DPMAN_DPARAMS_LIST (dpman)) > 1) {
+ GST_DPMAN_DPARAMS_LIST (dpman) =
+ g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
+ (GCompareFunc) gst_dpman_dpwrap_compare);
+ }
+
+ dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
+ dpwrap = (GstDParamWrapper *) dwraps->data;
+
+ if (dpwrap->next_update_frame == dpman->num_frames) {
+ dpman->next_update_frame = dpman->num_frames;
+ dpman->frames_to_process = dpman->num_frames - frame_count;
+ GST_DEBUG ("no more updates, frames to process %u",
+ dpman->frames_to_process);
+ } else {
+ dpman->next_update_frame = dpwrap->next_update_frame;
+ dpman->frames_to_process = dpman->next_update_frame - frame_count;
+ GST_DEBUG ("next update frame %u, frames to process %u",
+ dpman->next_update_frame, dpman->frames_to_process);
+ }
+
+ return TRUE;
}
-static gboolean
-gst_dpman_preprocess_noop(GstDParamManager *dpman, guint frames, gint64 timestamp)
+static gboolean
+gst_dpman_preprocess_noop (GstDParamManager * dpman, guint frames,
+ gint64 timestamp)
{
- dpman->next_update_frame = frames;
- dpman->frames_to_process = frames;
- return FALSE;
+ dpman->next_update_frame = frames;
+ dpman->frames_to_process = frames;
+ return FALSE;
}
-static gboolean
-gst_dpman_process_noop(GstDParamManager *dpman, guint frame_count)
+static gboolean
+gst_dpman_process_noop (GstDParamManager * dpman, guint frame_count)
{
- g_warning("gst_dpman_process_noop should never be called - something might be wrong with your processing loop");
- return FALSE;
+ g_warning
+ ("gst_dpman_process_noop should never be called - something might be wrong with your processing loop");
+ return FALSE;
}
-static void
-gst_dpman_setup_synchronous(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
+static void
+gst_dpman_setup_synchronous (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
}
-static void
-gst_dpman_setup_asynchronous(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
+static void
+gst_dpman_setup_asynchronous (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
}
-static void
-gst_dpman_setup_disabled(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
+static void
+gst_dpman_setup_disabled (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
}
-static void
-gst_dpman_teardown_synchronous(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
+static void
+gst_dpman_teardown_synchronous (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
}
-static void
-gst_dpman_teardown_asynchronous(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
-
+static void
+gst_dpman_teardown_asynchronous (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
+
}
-static void
-gst_dpman_teardown_disabled(GstDParamManager *dpman){
- g_return_if_fail (GST_IS_DPMAN (dpman));
+static void
+gst_dpman_teardown_disabled (GstDParamManager * dpman)
+{
+ g_return_if_fail (GST_IS_DPMAN (dpman));
}
#include <gst/control/unitconvert.h>
G_BEGIN_DECLS
-
#define GST_TYPE_DPMAN (gst_dpman_get_type ())
#define GST_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPMAN,GstDParamManager))
#define GST_DPMAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPMAN,GstDParamManager))
#define GST_IS_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPMAN))
#define GST_IS_DPMAN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPMAN))
-
#define GST_DPMAN_NAME(dpman) (GST_OBJECT_NAME(dpman))
#define GST_DPMAN_PARENT(dpman) (GST_OBJECT_PARENT(dpman))
#define GST_DPMAN_DPARAMS(dpman) ((dpman)->dparams)
#define GST_DPMAN_DPARAMS_LIST(dpman) ((dpman)->dparams_list)
-
#define GST_DPMAN_MODE_NAME(dpman) ((dpman)->mode_name)
#define GST_DPMAN_MODE(dpman) ((dpman)->mode)
#define GST_DPMAN_RATE(dpman) ((dpman)->rate)
#define GST_DPMAN_FRAMES_TO_PROCESS(dpman) ((dpman)->frames_to_process)
#define GST_DPMAN_NEXT_UPDATE_FRAME(dpman) ((dpman)->next_update_frame)
-
-typedef enum {
+ typedef enum
+{
GST_DPMAN_CALLBACK,
GST_DPMAN_DIRECT,
GST_DPMAN_ARRAY,
typedef struct _GstDParamWrapper GstDParamWrapper;
typedef struct _GstDParamAsyncToUpdate GstDParamAsyncToUpdate;
-typedef gboolean (*GstDPMModePreProcessFunction) (GstDParamManager *dpman, guint frames, gint64 timestamp);
-typedef gboolean (*GstDPMModeProcessFunction) (GstDParamManager *dpman, guint frame_count);
-typedef void (*GstDPMModeSetupFunction) (GstDParamManager *dpman);
-typedef void (*GstDPMModeTeardownFunction) (GstDParamManager *dpman);
+typedef gboolean (*GstDPMModePreProcessFunction) (GstDParamManager * dpman,
+ guint frames, gint64 timestamp);
+typedef gboolean (*GstDPMModeProcessFunction) (GstDParamManager * dpman,
+ guint frame_count);
+typedef void (*GstDPMModeSetupFunction) (GstDParamManager * dpman);
+typedef void (*GstDPMModeTeardownFunction) (GstDParamManager * dpman);
+
+typedef void (*GstDPMUpdateFunction) (const GValue * value, gpointer data);
-typedef void (*GstDPMUpdateFunction) (const GValue *value, gpointer data);
+struct _GstDParamManager
+{
+ GstObject object;
-struct _GstDParamManager {
- GstObject object;
+ GHashTable *dparams;
+ GList *dparams_list;
- GHashTable *dparams;
- GList *dparams_list;
+ /* mode state */
+ GstDPMMode *mode;
+ gchar *mode_name;
- /* mode state */
- GstDPMMode* mode;
- gchar *mode_name;
-
- guint frames_to_process; /* the number of frames in the current buffer */
- guint next_update_frame; /* the frame when the next update is required */
+ guint frames_to_process; /* the number of frames in the current buffer */
+ guint next_update_frame; /* the frame when the next update is required */
- /* the following data is only used for async mode */
- guint rate; /* the frame/sample rate - */
- guint rate_ratio; /* number used to convert between samples and time */
- guint num_frames; /* the number of frames in the current buffer */
+ /* the following data is only used for async mode */
+ guint rate; /* the frame/sample rate - */
+ guint rate_ratio; /* number used to convert between samples and time */
+ guint num_frames; /* the number of frames in the current buffer */
- gint64 time_buffer_ends;
- gint64 time_buffer_starts;
+ gint64 time_buffer_ends;
+ gint64 time_buffer_starts;
};
-struct _GstDParamManagerClass {
- GstObjectClass parent_class;
- GHashTable *modes;
- /* signal callbacks */
- void (*new_required_dparam) (GstDParamManager *dpman, gchar* dparam_name);
+struct _GstDParamManagerClass
+{
+ GstObjectClass parent_class;
+ GHashTable *modes;
+ /* signal callbacks */
+ void (*new_required_dparam) (GstDParamManager * dpman, gchar * dparam_name);
};
-struct _GstDPMMode {
- GstDPMModePreProcessFunction preprocessfunc;
- GstDPMModeProcessFunction processfunc;
- GstDPMModeSetupFunction setupfunc;
- GstDPMModeTeardownFunction teardownfunc;
+struct _GstDPMMode
+{
+ GstDPMModePreProcessFunction preprocessfunc;
+ GstDPMModeProcessFunction processfunc;
+ GstDPMModeSetupFunction setupfunc;
+ GstDPMModeTeardownFunction teardownfunc;
};
-struct _GstDParamWrapper {
- GParamSpec* param_spec;
- GValue *value;
- GstDParam *dparam;
-
- guint next_update_frame;
-
- GstDPMUpdateMethod update_method;
- gpointer update_data;
- GstDPMUpdateFunction update_func;
-
- gchar *unit_name;
- GstDParamUpdateInfo update_info;
+struct _GstDParamWrapper
+{
+ GParamSpec *param_spec;
+ GValue *value;
+ GstDParam *dparam;
+
+ guint next_update_frame;
+
+ GstDPMUpdateMethod update_method;
+ gpointer update_data;
+ GstDPMUpdateFunction update_func;
+
+ gchar *unit_name;
+ GstDParamUpdateInfo update_info;
};
-struct _GstDParamAsyncToUpdate {
- guint frame;
- GValue *value;
- GstDParamWrapper *dpwrap;
+struct _GstDParamAsyncToUpdate
+{
+ guint frame;
+ GValue *value;
+ GstDParamWrapper *dpwrap;
};
#define GST_DPMAN_PREPROCESSFUNC(dpman) (((dpman)->mode)->preprocessfunc)
#define GST_DPMAN_CALLBACK_UPDATE(dpwrap, value) ((dpwrap->update_func)(value, dpwrap->update_data))
-void _gst_dpman_initialize(void);
+void _gst_dpman_initialize (void);
GType gst_dpman_get_type (void);
-GstDParamManager* gst_dpman_new (gchar *name, GstElement *parent);
-void gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent);
-GstDParamManager* gst_dpman_get_manager (GstElement *parent);
-
-gboolean gst_dpman_add_required_dparam_callback (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- GstDPMUpdateFunction update_func,
- gpointer update_data);
-gboolean gst_dpman_add_required_dparam_direct (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- gpointer update_data);
-
-gboolean gst_dpman_add_required_dparam_array (GstDParamManager *dpman,
- GParamSpec *param_spec,
- gchar *unit_name,
- gpointer update_data);
-
-void gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name);
-gboolean gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam);
-void gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name);
-GstDParam* gst_dpman_get_dparam(GstDParamManager *dpman, gchar *name);
-GType gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name);
-
-GParamSpec** gst_dpman_list_dparam_specs(GstDParamManager *dpman);
-GParamSpec* gst_dpman_get_param_spec (GstDParamManager *dpman, gchar *dparam_name);
-void gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, gchar *dparam_name);
-
-void gst_dpman_set_rate(GstDParamManager *dpman, gint rate);
-void gst_dpman_bypass_dparam(GstDParamManager *dpman, gchar *dparam_name);
-
-gboolean gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename);
-void gst_dpman_register_mode (GstDParamManagerClass *klass,
- gchar *modename,
- GstDPMModePreProcessFunction preprocessfunc,
- GstDPMModeProcessFunction processfunc,
- GstDPMModeSetupFunction setupfunc,
- GstDPMModeTeardownFunction teardownfunc);
+GstDParamManager *gst_dpman_new (gchar * name, GstElement * parent);
+void gst_dpman_set_parent (GstDParamManager * dpman, GstElement * parent);
+GstDParamManager *gst_dpman_get_manager (GstElement * parent);
+
+gboolean gst_dpman_add_required_dparam_callback (GstDParamManager * dpman,
+ GParamSpec * param_spec,
+ gchar * unit_name, GstDPMUpdateFunction update_func, gpointer update_data);
+gboolean gst_dpman_add_required_dparam_direct (GstDParamManager * dpman,
+ GParamSpec * param_spec, gchar * unit_name, gpointer update_data);
+
+gboolean gst_dpman_add_required_dparam_array (GstDParamManager * dpman,
+ GParamSpec * param_spec, gchar * unit_name, gpointer update_data);
+
+void gst_dpman_remove_required_dparam (GstDParamManager * dpman,
+ gchar * dparam_name);
+gboolean gst_dpman_attach_dparam (GstDParamManager * dpman, gchar * dparam_name,
+ GstDParam * dparam);
+void gst_dpman_detach_dparam (GstDParamManager * dpman, gchar * dparam_name);
+GstDParam *gst_dpman_get_dparam (GstDParamManager * dpman, gchar * name);
+GType gst_dpman_get_dparam_type (GstDParamManager * dpman, gchar * name);
+
+GParamSpec **gst_dpman_list_dparam_specs (GstDParamManager * dpman);
+GParamSpec *gst_dpman_get_param_spec (GstDParamManager * dpman,
+ gchar * dparam_name);
+void gst_dpman_dparam_spec_has_changed (GstDParamManager * dpman,
+ gchar * dparam_name);
+
+void gst_dpman_set_rate (GstDParamManager * dpman, gint rate);
+void gst_dpman_bypass_dparam (GstDParamManager * dpman, gchar * dparam_name);
+
+gboolean gst_dpman_set_mode (GstDParamManager * dpman, gchar * modename);
+void gst_dpman_register_mode (GstDParamManagerClass * klass,
+ gchar * modename,
+ GstDPMModePreProcessFunction preprocessfunc,
+ GstDPMModeProcessFunction processfunc,
+ GstDPMModeSetupFunction setupfunc, GstDPMModeTeardownFunction teardownfunc);
G_END_DECLS
-
#endif /* __GST_DPMAN_H__ */
#include "dplinearinterp.h"
-static void gst_dp_linint_class_init (GstDParamClass *klass);
-static void gst_dp_linint_base_class_init (GstDParamClass *klass);
-static void gst_dp_linint_init (GstDParam *dp_linint);
+static void gst_dp_linint_class_init (GstDParamClass * klass);
+static void gst_dp_linint_base_class_init (GstDParamClass * klass);
+static void gst_dp_linint_init (GstDParam * dp_linint);
-GType
-gst_dp_linint_get_type(void) {
- static GType dp_linint_type = 0;
+GType
+gst_dp_linint_get_type (void)
+{
+ static GType dp_linint_type = 0;
- if (!dp_linint_type) {
- static const GTypeInfo dp_linint_info = {
- sizeof(GstDParamClass),
- (GBaseInitFunc)gst_dp_linint_base_class_init,
- NULL,
- (GClassInitFunc)gst_dp_linint_class_init,
- NULL,
- NULL,
- sizeof(GstDParam),
- 0,
- (GInstanceInitFunc)gst_dp_linint_init,
- };
- dp_linint_type = g_type_register_static(GST_TYPE_DPARAM, "GstDParamLinInterp", &dp_linint_info, 0);
- }
- return dp_linint_type;
+ if (!dp_linint_type) {
+ static const GTypeInfo dp_linint_info = {
+ sizeof (GstDParamClass),
+ (GBaseInitFunc) gst_dp_linint_base_class_init,
+ NULL,
+ (GClassInitFunc) gst_dp_linint_class_init,
+ NULL,
+ NULL,
+ sizeof (GstDParam),
+ 0,
+ (GInstanceInitFunc) gst_dp_linint_init,
+ };
+ dp_linint_type =
+ g_type_register_static (GST_TYPE_DPARAM, "GstDParamLinInterp",
+ &dp_linint_info, 0);
+ }
+ return dp_linint_type;
}
static void
-gst_dp_linint_base_class_init (GstDParamClass *klass)
+gst_dp_linint_base_class_init (GstDParamClass * klass)
{
}
static void
-gst_dp_linint_class_init (GstDParamClass *klass)
+gst_dp_linint_class_init (GstDParamClass * klass)
{
}
static void
-gst_dp_linint_init (GstDParam *dp_linint)
+gst_dp_linint_init (GstDParam * dp_linint)
{
- g_return_if_fail (dp_linint != NULL);
+ g_return_if_fail (dp_linint != NULL);
}
/**
*
* Returns: a new instance of GstDParam
*/
-GstDParam*
+GstDParam *
gst_dp_linint_new (GType type)
{
- GstDParam *dparam;
- GstDParamLinInterp *dp_linint;
+ GstDParam *dparam;
+ GstDParamLinInterp *dp_linint;
+
+ dp_linint = g_object_new (gst_dp_linint_get_type (), NULL);
+ dparam = GST_DPARAM (dp_linint);
- dp_linint = g_object_new (gst_dp_linint_get_type (), NULL);
- dparam = GST_DPARAM(dp_linint);
-
- return dparam;
+ return dparam;
}
#include "dparam.h"
G_BEGIN_DECLS
-
#define GST_TYPE_DP_LININT (gst_dp_linint_get_type ())
#define GST_DP_LININT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DP_LININT,GstDParamLinInterp))
#define GST_DP_LININT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DP_LININT,GstDParamLinInterp))
#define GST_IS_DP_LININT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DP_LININT))
#define GST_IS_DP_LININT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DP_LININT))
-
typedef struct _GstDParamLinInterp GstDParamLinInterp;
typedef struct _GstDParamLinInterpClass GstDParamLinInterpClass;
-struct _GstDParamLinInterp {
- GstDParam dparam;
+struct _GstDParamLinInterp
+{
+ GstDParam dparam;
};
-struct _GstDParamLinInterpClass {
- GstDParamClass parent_class;
+struct _GstDParamLinInterpClass
+{
+ GstDParamClass parent_class;
- /* signal callbacks */
+ /* signal callbacks */
};
GType gst_dp_linint_get_type (void);
-GstDParam* gst_dp_linint_new (GType type);
+GstDParam *gst_dp_linint_new (GType type);
G_END_DECLS
-
#endif /* __GST_DP_LININT_H__ */
typedef struct _GstUnit GstUnit;
-struct _GstUnit {
- GParamSpec *unit_spec;
- const gchar *domain_name;
- gboolean domain_default;
- gboolean logarithmic;
- GHashTable *convert_to_funcs;
- GSList *convert_paramspecs;
+struct _GstUnit
+{
+ GParamSpec *unit_spec;
+ const gchar *domain_name;
+ gboolean domain_default;
+ gboolean logarithmic;
+ GHashTable *convert_to_funcs;
+ GSList *convert_paramspecs;
};
-static void gst_unitconv_add_core_converters(void);
-
-static void gst_unitconv_class_init (GstUnitConvertClass *klass);
-static void gst_unitconv_init (GstUnitConvert *unitconv);
-static void gst_unitconv_dispose (GObject *object);
-
-GType
-gst_unitconv_get_type(void) {
- static GType unitconv_type = 0;
-
- if (!unitconv_type) {
- static const GTypeInfo unitconv_info = {
- sizeof(GstUnitConvertClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_unitconv_class_init,
- NULL,
- NULL,
- sizeof(GstUnitConvert),
- 0,
- (GInstanceInitFunc)gst_unitconv_init,
- };
- unitconv_type = g_type_register_static(GST_TYPE_OBJECT, "GstUnitConvert", &unitconv_info, 0);
- }
- return unitconv_type;
+static void gst_unitconv_add_core_converters (void);
+
+static void gst_unitconv_class_init (GstUnitConvertClass * klass);
+static void gst_unitconv_init (GstUnitConvert * unitconv);
+static void gst_unitconv_dispose (GObject * object);
+
+GType
+gst_unitconv_get_type (void)
+{
+ static GType unitconv_type = 0;
+
+ if (!unitconv_type) {
+ static const GTypeInfo unitconv_info = {
+ sizeof (GstUnitConvertClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_unitconv_class_init,
+ NULL,
+ NULL,
+ sizeof (GstUnitConvert),
+ 0,
+ (GInstanceInitFunc) gst_unitconv_init,
+ };
+ unitconv_type =
+ g_type_register_static (GST_TYPE_OBJECT, "GstUnitConvert",
+ &unitconv_info, 0);
+ }
+ return unitconv_type;
}
static void
-gst_unitconv_class_init (GstUnitConvertClass *klass)
+gst_unitconv_class_init (GstUnitConvertClass * klass)
{
- GObjectClass *gobject_class;
- GstUnitConvertClass *unitconv_class;
- GstObjectClass *gstobject_class;
+ GObjectClass *gobject_class;
+ GstUnitConvertClass *unitconv_class;
+ GstObjectClass *gstobject_class;
+
+ gobject_class = (GObjectClass *) klass;
+ unitconv_class = (GstUnitConvertClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
- gobject_class = (GObjectClass*)klass;
- unitconv_class = (GstUnitConvertClass*)klass;
- gstobject_class = (GstObjectClass*) klass;
+ gobject_class->dispose = gst_unitconv_dispose;
- gobject_class->dispose = gst_unitconv_dispose;
-
}
static void
-gst_unitconv_init (GstUnitConvert *unitconv)
+gst_unitconv_init (GstUnitConvert * unitconv)
{
- g_return_if_fail (unitconv != NULL);
-
- unitconv->convert_func_chain = NULL;
- unitconv->convert_params = g_hash_table_new(g_str_hash,g_str_equal);
+ g_return_if_fail (unitconv != NULL);
+
+ unitconv->convert_func_chain = NULL;
+ unitconv->convert_params = g_hash_table_new (g_str_hash, g_str_equal);
}
-GstUnitConvert*
+GstUnitConvert *
gst_unitconv_new ()
{
- GstUnitConvert *unitconv;
+ GstUnitConvert *unitconv;
+
+ unitconv = g_object_new (gst_unitconv_get_type (), NULL);
- unitconv = g_object_new (gst_unitconv_get_type (), NULL);
-
- return unitconv;
+ return unitconv;
}
static void
-gst_unitconv_init_for_change_state(GstUnitConvert *unitconv){
- unitconv->convert_func_chain = NULL;
+gst_unitconv_init_for_change_state (GstUnitConvert * unitconv)
+{
+ unitconv->convert_func_chain = NULL;
}
-gboolean
-gst_unitconv_set_convert_units(GstUnitConvert *unitconv, gchar *from_unit_named, gchar *to_unit_named)
+gboolean
+gst_unitconv_set_convert_units (GstUnitConvert * unitconv,
+ gchar * from_unit_named, gchar * to_unit_named)
{
- GHashTable *convert_funcs;
- GstUnit *from_unit, *to_unit;
- GstUnitConvertFunc convert_func;
-
- g_return_val_if_fail (unitconv != NULL, FALSE);
- g_return_val_if_fail (from_unit_named != NULL, FALSE);
- g_return_val_if_fail (to_unit_named != NULL, FALSE);
- g_return_val_if_fail (GST_IS_UNIT_CONVERT(unitconv), FALSE);
-
- from_unit = g_hash_table_lookup(_gst_units, from_unit_named);
- to_unit = g_hash_table_lookup(_gst_units, to_unit_named);
-
- g_return_val_if_fail (from_unit != NULL, FALSE);
- g_return_val_if_fail (to_unit != NULL, FALSE);
-
- convert_funcs = from_unit->convert_to_funcs;
-
- convert_func = g_hash_table_lookup(convert_funcs, to_unit);
- if (convert_func == NULL){
- g_warning("cannot convert from %s to %s", from_unit_named, to_unit_named);
- }
-
- gst_unitconv_init_for_change_state(unitconv);
-
- unitconv->convert_func_chain = g_slist_append(unitconv->convert_func_chain, convert_func);
-
-
- return TRUE;
+ GHashTable *convert_funcs;
+ GstUnit *from_unit, *to_unit;
+ GstUnitConvertFunc convert_func;
+
+ g_return_val_if_fail (unitconv != NULL, FALSE);
+ g_return_val_if_fail (from_unit_named != NULL, FALSE);
+ g_return_val_if_fail (to_unit_named != NULL, FALSE);
+ g_return_val_if_fail (GST_IS_UNIT_CONVERT (unitconv), FALSE);
+
+ from_unit = g_hash_table_lookup (_gst_units, from_unit_named);
+ to_unit = g_hash_table_lookup (_gst_units, to_unit_named);
+
+ g_return_val_if_fail (from_unit != NULL, FALSE);
+ g_return_val_if_fail (to_unit != NULL, FALSE);
+
+ convert_funcs = from_unit->convert_to_funcs;
+
+ convert_func = g_hash_table_lookup (convert_funcs, to_unit);
+ if (convert_func == NULL) {
+ g_warning ("cannot convert from %s to %s", from_unit_named, to_unit_named);
+ }
+
+ gst_unitconv_init_for_change_state (unitconv);
+
+ unitconv->convert_func_chain =
+ g_slist_append (unitconv->convert_func_chain, convert_func);
+
+
+ return TRUE;
}
-gboolean
-gst_unitconv_convert_value(GstUnitConvert *unitconv, GValue *from_value, GValue *to_value)
+gboolean
+gst_unitconv_convert_value (GstUnitConvert * unitconv, GValue * from_value,
+ GValue * to_value)
{
- GstUnitConvertFunc convert_func;
- GSList *convert_func_chain;
-
- g_return_val_if_fail (unitconv->convert_func_chain != NULL, FALSE);
-
- /* only do this until we can chain convert funcs */
- g_return_val_if_fail (g_slist_length(unitconv->convert_func_chain) == 1, FALSE);
-
- convert_func_chain = unitconv->convert_func_chain;
-
- convert_func = (GstUnitConvertFunc)(convert_func_chain);
- convert_func(unitconv, from_value, to_value);
-
- return TRUE;
+ GstUnitConvertFunc convert_func;
+ GSList *convert_func_chain;
+
+ g_return_val_if_fail (unitconv->convert_func_chain != NULL, FALSE);
+
+ /* only do this until we can chain convert funcs */
+ g_return_val_if_fail (g_slist_length (unitconv->convert_func_chain) == 1,
+ FALSE);
+
+ convert_func_chain = unitconv->convert_func_chain;
+
+ convert_func = (GstUnitConvertFunc) (convert_func_chain);
+ convert_func (unitconv, from_value, to_value);
+
+ return TRUE;
}
gboolean
-gst_unitconv_unit_exists(gchar *unit_name)
+gst_unitconv_unit_exists (gchar * unit_name)
{
- g_return_val_if_fail (unit_name != NULL, FALSE);
- return (g_hash_table_lookup(_gst_units, unit_name) != NULL);
+ g_return_val_if_fail (unit_name != NULL, FALSE);
+ return (g_hash_table_lookup (_gst_units, unit_name) != NULL);
}
gboolean
-gst_unitconv_unit_is_logarithmic(gchar *unit_name)
+gst_unitconv_unit_is_logarithmic (gchar * unit_name)
{
- GstUnit *unit;
- g_return_val_if_fail (unit_name != NULL, FALSE);
-
- unit = g_hash_table_lookup(_gst_units, unit_name);
- g_return_val_if_fail (unit != NULL, FALSE);
-
- return unit->logarithmic;
+ GstUnit *unit;
+
+ g_return_val_if_fail (unit_name != NULL, FALSE);
+
+ unit = g_hash_table_lookup (_gst_units, unit_name);
+ g_return_val_if_fail (unit != NULL, FALSE);
+
+ return unit->logarithmic;
}
-GParamSpec*
-gst_unitconv_unit_spec(gchar *unit_name)
+GParamSpec *
+gst_unitconv_unit_spec (gchar * unit_name)
{
- GstUnit *unit;
- g_return_val_if_fail (unit_name != NULL, FALSE);
-
- unit = g_hash_table_lookup(_gst_units, unit_name);
- g_return_val_if_fail (unit != NULL, FALSE);
-
- return unit->unit_spec;
+ GstUnit *unit;
+
+ g_return_val_if_fail (unit_name != NULL, FALSE);
+
+ unit = g_hash_table_lookup (_gst_units, unit_name);
+ g_return_val_if_fail (unit != NULL, FALSE);
+
+ return unit->unit_spec;
}
static void
-gst_unitconv_dispose (GObject *object)
+gst_unitconv_dispose (GObject * object)
{
}
-void
+void
_gst_unitconv_initialize (void)
{
- if (_gst_unitconv_init_done) return;
-
- _gst_unitconv_init_done = TRUE;
-
- _gst_units = g_hash_table_new(g_str_hash,g_str_equal);
- _gst_unit_domain_defaults = g_hash_table_new(g_str_hash,g_str_equal);
-
- /* frequency based units */
-
- gst_unitconv_register_unit("frequency", TRUE, TRUE,
- g_param_spec_float("hertz", "Hz", "Frequency in hertz",
- 0, G_MAXFLOAT, 0, 0));
-
- gst_unitconv_register_unit("frequency", FALSE, TRUE,
- g_param_spec_float("hertz-rate-bound", "Hz", "Frequency in hertz, bound by the sample rate",
- 0.0, G_MAXFLOAT, 0.0, 0));
-
- gst_unitconv_register_unit("frequency", FALSE, FALSE,
- g_param_spec_string("twelve-tone-scale", "note", "Name of the note from the western twelve tone scale",
- "C", 0));
-
- gst_unitconv_register_unit("frequency", FALSE, FALSE,
- g_param_spec_int("midi-note", "midi note", "MIDI note value of the frequency",
- 1, 127, 1, 0));
-
- /* time based units */
- gst_unitconv_register_unit("time", TRUE, FALSE,
- g_param_spec_float("seconds", "s", "Time in seconds",
- -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
-
- gst_unitconv_register_unit("time", FALSE, FALSE,
- g_param_spec_int64("nanoseconds", "ns", "Time in nanoseconds",
- G_MININT64, G_MAXINT64, 0, 0));
-
- gst_unitconv_register_unit("time", FALSE, FALSE,
- g_param_spec_int64("samples", "samples", "Time in number of samples",
- G_MININT64, G_MAXINT64, 0, 0));
-
- gst_unitconv_register_convert_property("samples",
- g_param_spec_int("samplerate","samplerate","samplerate",
- 0, G_MAXINT,0,G_PARAM_READWRITE));
-
-
- /* magnitude based units */
- gst_unitconv_register_unit("magnitude", TRUE, FALSE,
- g_param_spec_float("scalar", "scalar", "Magnitude as a scalar",
- -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
-
- gst_unitconv_register_unit("magnitude", FALSE, FALSE,
- g_param_spec_int("scalar-int", "scalar int", "Magnitude as an integer scalar",
- G_MININT, G_MAXINT, 0, 0));
-
- gst_unitconv_register_unit("magnitude", FALSE, TRUE,
- g_param_spec_float("decibel", "dB", "Magnitude in decibels",
- -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
-
- gst_unitconv_register_unit("magnitude", FALSE, FALSE,
- g_param_spec_float("percent", "%", "Magnitude in percent",
- -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
-
- /* generic units */
- gst_unitconv_register_unit("float_default", TRUE, FALSE,
- g_param_spec_float("float", "float", "Float value",
- -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
-
- gst_unitconv_register_unit("int_default", TRUE, FALSE,
- g_param_spec_int("int", "int", "Integer value",
- G_MININT, G_MAXINT, 0, 0));
-
- gst_unitconv_register_unit("int64_default", TRUE, FALSE,
- g_param_spec_int64("int64", "int64", "64 bit integer value",
- G_MININT, G_MAXINT, 0, 0));
-
-
- gst_unitconv_add_core_converters();
+ if (_gst_unitconv_init_done)
+ return;
+
+ _gst_unitconv_init_done = TRUE;
+
+ _gst_units = g_hash_table_new (g_str_hash, g_str_equal);
+ _gst_unit_domain_defaults = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* frequency based units */
+
+ gst_unitconv_register_unit ("frequency", TRUE, TRUE,
+ g_param_spec_float ("hertz", "Hz", "Frequency in hertz",
+ 0, G_MAXFLOAT, 0, 0));
+
+ gst_unitconv_register_unit ("frequency", FALSE, TRUE,
+ g_param_spec_float ("hertz-rate-bound", "Hz",
+ "Frequency in hertz, bound by the sample rate", 0.0, G_MAXFLOAT, 0.0,
+ 0));
+
+ gst_unitconv_register_unit ("frequency", FALSE, FALSE,
+ g_param_spec_string ("twelve-tone-scale", "note",
+ "Name of the note from the western twelve tone scale", "C", 0));
+
+ gst_unitconv_register_unit ("frequency", FALSE, FALSE,
+ g_param_spec_int ("midi-note", "midi note",
+ "MIDI note value of the frequency", 1, 127, 1, 0));
+
+ /* time based units */
+ gst_unitconv_register_unit ("time", TRUE, FALSE,
+ g_param_spec_float ("seconds", "s", "Time in seconds",
+ -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
+
+ gst_unitconv_register_unit ("time", FALSE, FALSE,
+ g_param_spec_int64 ("nanoseconds", "ns", "Time in nanoseconds",
+ G_MININT64, G_MAXINT64, 0, 0));
+
+ gst_unitconv_register_unit ("time", FALSE, FALSE,
+ g_param_spec_int64 ("samples", "samples", "Time in number of samples",
+ G_MININT64, G_MAXINT64, 0, 0));
+
+ gst_unitconv_register_convert_property ("samples",
+ g_param_spec_int ("samplerate", "samplerate", "samplerate",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+
+
+ /* magnitude based units */
+ gst_unitconv_register_unit ("magnitude", TRUE, FALSE,
+ g_param_spec_float ("scalar", "scalar", "Magnitude as a scalar",
+ -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
+
+ gst_unitconv_register_unit ("magnitude", FALSE, FALSE,
+ g_param_spec_int ("scalar-int", "scalar int",
+ "Magnitude as an integer scalar", G_MININT, G_MAXINT, 0, 0));
+
+ gst_unitconv_register_unit ("magnitude", FALSE, TRUE,
+ g_param_spec_float ("decibel", "dB", "Magnitude in decibels",
+ -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
+
+ gst_unitconv_register_unit ("magnitude", FALSE, FALSE,
+ g_param_spec_float ("percent", "%", "Magnitude in percent",
+ -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
+
+ /* generic units */
+ gst_unitconv_register_unit ("float_default", TRUE, FALSE,
+ g_param_spec_float ("float", "float", "Float value",
+ -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
+
+ gst_unitconv_register_unit ("int_default", TRUE, FALSE,
+ g_param_spec_int ("int", "int", "Integer value",
+ G_MININT, G_MAXINT, 0, 0));
+
+ gst_unitconv_register_unit ("int64_default", TRUE, FALSE,
+ g_param_spec_int64 ("int64", "int64", "64 bit integer value",
+ G_MININT, G_MAXINT, 0, 0));
+
+
+ gst_unitconv_add_core_converters ();
}
gboolean
-gst_unitconv_register_unit(const gchar *domain_name,
- gboolean is_domain_default,
- gboolean is_logarithmic,
- GParamSpec *unit_spec)
+gst_unitconv_register_unit (const gchar * domain_name,
+ gboolean is_domain_default, gboolean is_logarithmic, GParamSpec * unit_spec)
{
- GstUnit* unit;
- gchar *unit_name;
+ GstUnit *unit;
+ gchar *unit_name;
- g_return_val_if_fail (unit_spec != NULL, FALSE);
- g_return_val_if_fail (G_IS_PARAM_SPEC(unit_spec), FALSE);
- g_return_val_if_fail (domain_name != NULL, FALSE);
+ g_return_val_if_fail (unit_spec != NULL, FALSE);
+ g_return_val_if_fail (G_IS_PARAM_SPEC (unit_spec), FALSE);
+ g_return_val_if_fail (domain_name != NULL, FALSE);
- unit_name = g_strdup(g_param_spec_get_name(unit_spec));
+ unit_name = g_strdup (g_param_spec_get_name (unit_spec));
- /* check if this unit name already exists */
- if (g_hash_table_lookup (_gst_units, unit_name) != NULL)
- {
- g_free (unit_name);
- return FALSE;
- }
- if (is_domain_default){
- /* check if an default unit already exists for this domain */
- g_return_val_if_fail (
- g_hash_table_lookup(_gst_unit_domain_defaults, domain_name) == NULL, FALSE);
- }
+ /* check if this unit name already exists */
+ if (g_hash_table_lookup (_gst_units, unit_name) != NULL) {
+ g_free (unit_name);
+ return FALSE;
+ }
+ if (is_domain_default) {
+ /* check if an default unit already exists for this domain */
+ g_return_val_if_fail (g_hash_table_lookup (_gst_unit_domain_defaults,
+ domain_name) == NULL, FALSE);
+ }
- GST_DEBUG ("creating unit: %s", unit_name);
+ GST_DEBUG ("creating unit: %s", unit_name);
- unit = g_new0(GstUnit,1);
+ unit = g_new0 (GstUnit, 1);
- unit->unit_spec = unit_spec;
- unit->domain_name = domain_name;
- unit->domain_default = is_domain_default;
- unit->logarithmic = is_logarithmic;
- unit->convert_to_funcs = g_hash_table_new(NULL,NULL);
- /* unit->convert_properties = g_hash_table_new(g_str_hash,g_str_equal); */
+ unit->unit_spec = unit_spec;
+ unit->domain_name = domain_name;
+ unit->domain_default = is_domain_default;
+ unit->logarithmic = is_logarithmic;
+ unit->convert_to_funcs = g_hash_table_new (NULL, NULL);
+ /* unit->convert_properties = g_hash_table_new(g_str_hash,g_str_equal); */
- g_hash_table_insert(_gst_units, unit_name, unit);
+ g_hash_table_insert (_gst_units, unit_name, unit);
- if (is_domain_default){
- g_hash_table_insert(_gst_unit_domain_defaults, g_strdup(domain_name), unit);
- }
+ if (is_domain_default) {
+ g_hash_table_insert (_gst_unit_domain_defaults, g_strdup (domain_name),
+ unit);
+ }
- return TRUE;
+ return TRUE;
}
gboolean
-gst_unitconv_register_convert_func(gchar *from_unit_named, gchar *to_unit_named, GstUnitConvertFunc convert_func)
+gst_unitconv_register_convert_func (gchar * from_unit_named,
+ gchar * to_unit_named, GstUnitConvertFunc convert_func)
{
- GHashTable *convert_funcs;
- GstUnit *from_unit, *to_unit;
-
- g_return_val_if_fail (from_unit_named != NULL, FALSE);
- g_return_val_if_fail (to_unit_named != NULL, FALSE);
-
- from_unit = g_hash_table_lookup(_gst_units, from_unit_named);
- to_unit = g_hash_table_lookup(_gst_units, to_unit_named);
-
- g_return_val_if_fail (from_unit != NULL, FALSE);
- g_return_val_if_fail (to_unit != NULL, FALSE);
-
- convert_funcs = from_unit->convert_to_funcs;
-
- g_return_val_if_fail (
- g_hash_table_lookup(convert_funcs, to_unit) == NULL, FALSE);
-
- GST_DEBUG ("adding unit converter from %s to %s\n",
- g_param_spec_get_name(from_unit->unit_spec),
- g_param_spec_get_name(to_unit->unit_spec));
-
- g_hash_table_insert(convert_funcs, to_unit, convert_func);
-
- return TRUE;
+ GHashTable *convert_funcs;
+ GstUnit *from_unit, *to_unit;
+
+ g_return_val_if_fail (from_unit_named != NULL, FALSE);
+ g_return_val_if_fail (to_unit_named != NULL, FALSE);
+
+ from_unit = g_hash_table_lookup (_gst_units, from_unit_named);
+ to_unit = g_hash_table_lookup (_gst_units, to_unit_named);
+
+ g_return_val_if_fail (from_unit != NULL, FALSE);
+ g_return_val_if_fail (to_unit != NULL, FALSE);
+
+ convert_funcs = from_unit->convert_to_funcs;
+
+ g_return_val_if_fail (g_hash_table_lookup (convert_funcs, to_unit) == NULL,
+ FALSE);
+
+ GST_DEBUG ("adding unit converter from %s to %s\n",
+ g_param_spec_get_name (from_unit->unit_spec),
+ g_param_spec_get_name (to_unit->unit_spec));
+
+ g_hash_table_insert (convert_funcs, to_unit, convert_func);
+
+ return TRUE;
}
gboolean
-gst_unitconv_register_convert_property(gchar *unit_name, GParamSpec *convert_prop_spec)
+gst_unitconv_register_convert_property (gchar * unit_name,
+ GParamSpec * convert_prop_spec)
{
- GstUnit *unit;
- g_return_val_if_fail (unit_name != NULL, FALSE);
- g_return_val_if_fail (convert_prop_spec != NULL, FALSE);
- unit = g_hash_table_lookup(_gst_units, unit_name);
-
- g_return_val_if_fail (unit != NULL, FALSE);
-
- unit->convert_paramspecs = g_slist_append(unit->convert_paramspecs, convert_prop_spec);
-
- return TRUE;
+ GstUnit *unit;
+
+ g_return_val_if_fail (unit_name != NULL, FALSE);
+ g_return_val_if_fail (convert_prop_spec != NULL, FALSE);
+ unit = g_hash_table_lookup (_gst_units, unit_name);
+
+ g_return_val_if_fail (unit != NULL, FALSE);
+
+ unit->convert_paramspecs =
+ g_slist_append (unit->convert_paramspecs, convert_prop_spec);
+
+ return TRUE;
}
static void
-gst_unitconv_time_seconds_to_nanoseconds(GstUnitConvert *unitconv, GValue *seconds_val, GValue *nanos_val)
+gst_unitconv_time_seconds_to_nanoseconds (GstUnitConvert * unitconv,
+ GValue * seconds_val, GValue * nanos_val)
{
- g_value_set_int64(nanos_val,
- (gint64)(g_value_get_float(seconds_val) * 1000000000.0));
+ g_value_set_int64 (nanos_val,
+ (gint64) (g_value_get_float (seconds_val) * 1000000000.0));
}
static void
-gst_unitconv_time_nanoseconds_to_seconds(GstUnitConvert *unitconv, GValue *nanos_val, GValue *seconds_val)
+gst_unitconv_time_nanoseconds_to_seconds (GstUnitConvert * unitconv,
+ GValue * nanos_val, GValue * seconds_val)
{
- g_value_set_float(seconds_val,
- ((gfloat)g_value_get_int64(nanos_val)) / 1000000000.0);
+ g_value_set_float (seconds_val,
+ ((gfloat) g_value_get_int64 (nanos_val)) / 1000000000.0);
}
static void
-gst_unitconv_time_seconds_to_samples(GstUnitConvert *unitconv, GValue *seconds_val, GValue *samples_val)
-{
- /* GValue *samplerate;
- GValue *samplerate = g_hash_table_lookup(unitconv->currentToUnit->convert_properties, "samplerate");
- g_value_set_int64(samples_val,
- (gint64)(g_value_get_float(seconds_val) * (gfloat)g_value_get_int(samplerate))); */
+gst_unitconv_time_seconds_to_samples (GstUnitConvert * unitconv,
+ GValue * seconds_val, GValue * samples_val)
+{
+ /* GValue *samplerate;
+ GValue *samplerate = g_hash_table_lookup(unitconv->currentToUnit->convert_properties, "samplerate");
+ g_value_set_int64(samples_val,
+ (gint64)(g_value_get_float(seconds_val) * (gfloat)g_value_get_int(samplerate))); */
}
static void
-gst_unitconv_time_samples_to_seconds(GstUnitConvert *unitconv, GValue *samples_val, GValue *seconds_val)
-{
- /* GValue *samplerate;
- GValue *samplerate = g_hash_table_lookup(unitconv->currentFromUnit->convert_properties, "samplerate");
- g_value_set_float(seconds_val,
- ((gfloat)g_value_get_int64(samples_val)) / (gfloat)g_value_get_int(samplerate));*/
+gst_unitconv_time_samples_to_seconds (GstUnitConvert * unitconv,
+ GValue * samples_val, GValue * seconds_val)
+{
+ /* GValue *samplerate;
+ GValue *samplerate = g_hash_table_lookup(unitconv->currentFromUnit->convert_properties, "samplerate");
+ g_value_set_float(seconds_val,
+ ((gfloat)g_value_get_int64(samples_val)) / (gfloat)g_value_get_int(samplerate)); */
}
static void
-gst_unitconv_magnitude_scalar_to_percent(GstUnitConvert *unitconv, GValue *scalar_val, GValue *percent_val)
-{
- g_value_set_float(percent_val,
- g_value_get_float(scalar_val) * 100.0);
+gst_unitconv_magnitude_scalar_to_percent (GstUnitConvert * unitconv,
+ GValue * scalar_val, GValue * percent_val)
+{
+ g_value_set_float (percent_val, g_value_get_float (scalar_val) * 100.0);
}
static void
-gst_unitconv_magnitude_percent_to_scalar(GstUnitConvert *unitconv, GValue *percent_val, GValue *scalar_val)
-{
- g_value_set_float(scalar_val,
- g_value_get_float(percent_val) / 100.0);
+gst_unitconv_magnitude_percent_to_scalar (GstUnitConvert * unitconv,
+ GValue * percent_val, GValue * scalar_val)
+{
+ g_value_set_float (scalar_val, g_value_get_float (percent_val) / 100.0);
}
static void
-gst_unitconv_add_core_converters(void){
-
- gst_unitconv_register_convert_func("nanoseconds", "seconds", gst_unitconv_time_nanoseconds_to_seconds);
- gst_unitconv_register_convert_func("seconds", "nanoseconds", gst_unitconv_time_seconds_to_nanoseconds);
- gst_unitconv_register_convert_func("seconds", "samples", gst_unitconv_time_seconds_to_samples);
- gst_unitconv_register_convert_func("samples", "seconds", gst_unitconv_time_samples_to_seconds);
-
- gst_unitconv_register_convert_func("scalar", "percent", gst_unitconv_magnitude_scalar_to_percent);
- gst_unitconv_register_convert_func("percent", "scalar", gst_unitconv_magnitude_percent_to_scalar);
+gst_unitconv_add_core_converters (void)
+{
+
+ gst_unitconv_register_convert_func ("nanoseconds", "seconds",
+ gst_unitconv_time_nanoseconds_to_seconds);
+ gst_unitconv_register_convert_func ("seconds", "nanoseconds",
+ gst_unitconv_time_seconds_to_nanoseconds);
+ gst_unitconv_register_convert_func ("seconds", "samples",
+ gst_unitconv_time_seconds_to_samples);
+ gst_unitconv_register_convert_func ("samples", "seconds",
+ gst_unitconv_time_samples_to_seconds);
+
+ gst_unitconv_register_convert_func ("scalar", "percent",
+ gst_unitconv_magnitude_scalar_to_percent);
+ gst_unitconv_register_convert_func ("percent", "scalar",
+ gst_unitconv_magnitude_percent_to_scalar);
}
#include <gst/gstobject.h>
G_BEGIN_DECLS
-
#define GST_TYPE_UNIT_CONVERT (gst_unitconv_get_type ())
#define GST_UNIT_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_UNIT_CONVERT,GstUnitConvert))
#define GST_UNIT_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_UNIT_CONVERT,GstUnitConvert))
#define GST_IS_UNIT_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_UNIT_CONVERT))
#define GST_IS_UNIT_CONVERT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_UNIT_CONVERT))
-
#define GST_UNIT_CONVERT_NAME(unitconv) (GST_OBJECT_NAME(unitconv))
#define GST_UNIT_CONVERT_PARENT(unitconv) (GST_OBJECT_PARENT(unitconv))
-
typedef struct _GstUnitConvertClass GstUnitConvertClass;
typedef struct _GstUnitConvert GstUnitConvert;
-typedef void (*GstUnitConvertFunc) (GstUnitConvert *unitconv, GValue *from_val, GValue *to_val);
+typedef void (*GstUnitConvertFunc) (GstUnitConvert * unitconv,
+ GValue * from_val, GValue * to_val);
-struct _GstUnitConvert {
- GstObject object;
+struct _GstUnitConvert
+{
+ GstObject object;
- GHashTable *convert_params;
- GSList *convert_func_chain;
- GSList *temp_gvalues;
+ GHashTable *convert_params;
+ GSList *convert_func_chain;
+ GSList *temp_gvalues;
};
-struct _GstUnitConvertClass {
- GstObjectClass parent_class;
+struct _GstUnitConvertClass
+{
+ GstObjectClass parent_class;
- /* signal callbacks */
+ /* signal callbacks */
};
GType gst_unitconv_get_type (void);
-GstUnitConvert* gst_unitconv_new (void);
+GstUnitConvert *gst_unitconv_new (void);
void _gst_unitconv_initialize (void);
-gboolean gst_unitconv_set_convert_units(GstUnitConvert *unitconv, gchar *from_unit_named, gchar *to_unit_named);
-gboolean gst_unitconv_convert_value(GstUnitConvert *unitconv, GValue *from_value, GValue *to_value);
+gboolean gst_unitconv_set_convert_units (GstUnitConvert * unitconv,
+ gchar * from_unit_named, gchar * to_unit_named);
+gboolean gst_unitconv_convert_value (GstUnitConvert * unitconv,
+ GValue * from_value, GValue * to_value);
-GParamSpec* gst_unitconv_unit_spec(gchar *unit_name);
-gboolean gst_unitconv_unit_exists(gchar *unit_name);
-gboolean gst_unitconv_unit_is_logarithmic(gchar *unit_name);
+GParamSpec *gst_unitconv_unit_spec (gchar * unit_name);
+gboolean gst_unitconv_unit_exists (gchar * unit_name);
+gboolean gst_unitconv_unit_is_logarithmic (gchar * unit_name);
-gboolean gst_unitconv_register_unit(const gchar *domain_name,
- gboolean is_domain_default,
- gboolean is_logarithmic,
- GParamSpec *unit_spec);
+gboolean gst_unitconv_register_unit (const gchar * domain_name,
+ gboolean is_domain_default,
+ gboolean is_logarithmic, GParamSpec * unit_spec);
-gboolean gst_unitconv_register_convert_func(gchar *from_unit_named, gchar *to_unit_named, GstUnitConvertFunc convert_func);
-gboolean gst_unitconv_register_convert_property(gchar *unit_name, GParamSpec *convert_prop_spec);
+gboolean gst_unitconv_register_convert_func (gchar * from_unit_named,
+ gchar * to_unit_named, GstUnitConvertFunc convert_func);
+gboolean gst_unitconv_register_convert_property (gchar * unit_name,
+ GParamSpec * convert_prop_spec);
G_END_DECLS
-
#endif /* __GST_UNITCONVERT_H__ */
#include <stdlib.h>
#include "gstgetbits.h"
-char *print_bits(unsigned long bits,int size) {
- char *ret = (char *)malloc(size+1);
+char *
+print_bits (unsigned long bits, int size)
+{
+ char *ret = (char *) malloc (size + 1);
int i;
+
ret[size] = 0;
- for (i=0;i<size;i++) {
- if (bits & (1<<i))
- ret[(size-1)-i] = '1';
+ for (i = 0; i < size; i++) {
+ if (bits & (1 << i))
+ ret[(size - 1) - i] = '1';
else
- ret[(size-1)-i] = '0';
+ ret[(size - 1) - i] = '0';
}
return ret;
}
-static unsigned char testbuffer[] =
-{
- 0x11, 0x22, 0x44, 0x88, 0xCC, 0xEE,0xFF,0x11
+static unsigned char testbuffer[] = {
+ 0x11, 0x22, 0x44, 0x88, 0xCC, 0xEE, 0xFF, 0x11
};
-void empty(gst_getbits_t *gb, void *data) {
- printf("buffer empty\n");
+void
+empty (gst_getbits_t * gb, void *data)
+{
+ printf ("buffer empty\n");
- gst_getbits_newbuf(gb,(unsigned char *)testbuffer, 7);
+ gst_getbits_newbuf (gb, (unsigned char *) testbuffer, 7);
}
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
gst_getbits_t gb;
int i, j;
int bits;
- gst_getbits_init(&gb, NULL, NULL);
- gst_getbits_newbuf(&gb,(unsigned char *)testbuffer, 7);
+ gst_getbits_init (&gb, NULL, NULL);
+ gst_getbits_newbuf (&gb, (unsigned char *) testbuffer, 7);
- for (i=0;i<7;i++) {
- for (j=0;j<8;j++) {
- printf("%lu",gst_getbits2(&gb));
- gst_backbitsn(&gb, 1);
+ for (i = 0; i < 7; i++) {
+ for (j = 0; j < 8; j++) {
+ printf ("%lu", gst_getbits2 (&gb));
+ gst_backbitsn (&gb, 1);
}
- printf(" = %01x\n", testbuffer[i]);
+ printf (" = %01x\n", testbuffer[i]);
}
- gst_getbits_newbuf(&gb,(unsigned char *)testbuffer, 7);
+ gst_getbits_newbuf (&gb, (unsigned char *) testbuffer, 7);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000011 %lu\n",bits, gb.bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000022 %lu\n",bits, gb.bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000044 %lu\n",bits, gb.bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000088 %lu\n",bits, gb.bits);
- bits = gst_getbits6(&gb);
- printf("%08x <-> 00000033 %lu\n",bits, gb.bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000011 %lu\n", bits, gb.bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000022 %lu\n", bits, gb.bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000044 %lu\n", bits, gb.bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000088 %lu\n", bits, gb.bits);
+ bits = gst_getbits6 (&gb);
+ printf ("%08x <-> 00000033 %lu\n", bits, gb.bits);
- gst_backbitsn(&gb, 16);
+ gst_backbitsn (&gb, 16);
- bits = gst_getbits10(&gb);
- printf("%08x <-> 00000088 \n",bits);
+ bits = gst_getbits10 (&gb);
+ printf ("%08x <-> 00000088 \n", bits);
- gst_getbits_newbuf(&gb,(unsigned char *)testbuffer, 7);
+ gst_getbits_newbuf (&gb, (unsigned char *) testbuffer, 7);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000011 \n",bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000022 \n",bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000044 \n",bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000011 \n", bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000022 \n", bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000044 \n", bits);
- bits = gst_getbits6(&gb);
- printf("%08x <-> 00000022 \n",bits);
+ bits = gst_getbits6 (&gb);
+ printf ("%08x <-> 00000022 \n", bits);
- gst_backbitsn(&gb, 19);
+ gst_backbitsn (&gb, 19);
- bits = gst_getbits19(&gb);
- printf("%08x <-> 00009122 \n",bits);
+ bits = gst_getbits19 (&gb);
+ printf ("%08x <-> 00009122 \n", bits);
- bits = gst_getbits10(&gb);
- printf("%08x <-> 000000cc \n",bits);
+ bits = gst_getbits10 (&gb);
+ printf ("%08x <-> 000000cc \n", bits);
- gst_backbitsn(&gb, 8);
+ gst_backbitsn (&gb, 8);
- gst_backbitsn(&gb, 19);
+ gst_backbitsn (&gb, 19);
- gst_backbitsn(&gb, 8);
+ gst_backbitsn (&gb, 8);
- bits = gst_getbits19(&gb);
- printf("%08x <-> 00012244 \n",bits);
- bits = gst_getbits8(&gb);
- printf("%08x <-> 00000088 \n",bits);
+ bits = gst_getbits19 (&gb);
+ printf ("%08x <-> 00012244 \n", bits);
+ bits = gst_getbits8 (&gb);
+ printf ("%08x <-> 00000088 \n", bits);
return 0;
}
#include "getbits.h"
/* Defined in gstgetbits_i386.s */
-extern unsigned long _gst_get1bit_i386(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_getbits_i386(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_getbits_fast_i386(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_showbits_i386(gst_getbits_t *gb, unsigned long bits);
-extern void _gst_flushbits_i386(gst_getbits_t *gb, unsigned long bits);
-extern void _gst_getbits_back_i386(gst_getbits_t *gb, unsigned long bits);
+extern unsigned long _gst_get1bit_i386 (gst_getbits_t * gb, unsigned long bits);
+extern unsigned long _gst_getbits_i386 (gst_getbits_t * gb, unsigned long bits);
+extern unsigned long _gst_getbits_fast_i386 (gst_getbits_t * gb,
+ unsigned long bits);
+extern unsigned long _gst_showbits_i386 (gst_getbits_t * gb,
+ unsigned long bits);
+extern void _gst_flushbits_i386 (gst_getbits_t * gb, unsigned long bits);
+extern void _gst_getbits_back_i386 (gst_getbits_t * gb, unsigned long bits);
/* Defined in gstgetbits_generic.c */
-extern unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits);
-extern unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits);
-extern void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits);
-extern void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits);
-
-
-unsigned long gst_getbits_nBitMask[] = {
+extern unsigned long _gst_getbits_int_cb (gst_getbits_t * gb,
+ unsigned long bits);
+extern unsigned long _gst_get1bit_int (gst_getbits_t * gb, unsigned long bits);
+extern unsigned long _gst_getbits_int (gst_getbits_t * gb, unsigned long bits);
+extern unsigned long _gst_getbits_fast_int (gst_getbits_t * gb,
+ unsigned long bits);
+extern unsigned long _gst_showbits_int (gst_getbits_t * gb, unsigned long bits);
+extern void _gst_flushbits_int (gst_getbits_t * gb, unsigned long bits);
+extern void _gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits);
+
+
+unsigned long gst_getbits_nBitMask[] = {
0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000,
0xff000000, 0xff800000, 0xffc00000, 0xffe00000,
0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
- 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe};
+ 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe
+};
unsigned long _getbits_masks[] = {
0x00000000,
#ifdef unused
unsigned long _getbits_64_minus_index[] = {
- 64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,
- 40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,
- 16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1 };
+ 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46,
+ 45, 44, 43, 42, 41,
+ 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22,
+ 21, 20, 19, 18, 17,
+ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
+};
/* this routine taken from Intel AppNote AP-527:
"Using MMX[tm] Instructions to Get Bits From a Data Stream"
this isn't as cycle-efficient, due to the simple fact that I must call
emms() at the end. all state must be kept in *gb, not in registers */
-unsigned long _gst_getbits_mmx(gst_getbits_t *gb,unsigned long bits) {
+unsigned long
+_gst_getbits_mmx (gst_getbits_t * gb, unsigned long bits)
+{
signed long remaining;
unsigned long result;
symbolically in this C code. gcc is probably going to lose horribly,
I'll do an inline asm version later. I've a point to prove ;-) */
/* find the right shift value, put it in mm3 */
- movd_m2r(_getbits_64_minus_index[bits],mm3);
+ movd_m2r (_getbits_64_minus_index[bits], mm3);
/* load the current quadword into mm0 */
- movq_m2r(gb->qword,mm0);
+ movq_m2r (gb->qword, mm0);
/* copy it to mm2 */
- movq_r2r(mm0,mm2);
+ movq_r2r (mm0, mm2);
remaining = gb->bits - bits;
if (remaining <= 0) {
- unsigned long dword1,dword2;
+ unsigned long dword1, dword2;
/* shift the pointer by 64 bits (8 bytes) */
gb->ptr += 8;
remaining += 64;
/* grab the first 32 bits from the buffer and swap them around */
- dword1 = swab32(*(gb->ptr-8));
+ dword1 = swab32 (*(gb->ptr - 8));
/* grab the second 32 bits, swap */
- dword2 = swab32(*(gb->ptr-4));
+ dword2 = swab32 (*(gb->ptr - 4));
/* put second dword in mm4 */
- movd_m2r(dword2,mm4);
+ movd_m2r (dword2, mm4);
/* shift mm2 over to make room for new bits */
- psrlq_r2r(mm3,mm2);
+ psrlq_r2r (mm3, mm2);
/* put first dword in mm1 */
- movd_m2r(dword1,mm1);
+ movd_m2r (dword1, mm1);
/* shift second dword up 32 bits */
- psrlq_i2r(32,mm4);
+ psrlq_i2r (32, mm4);
/* put the shift counter in mm3 */
- movd_m2r(remaining,mm3);
+ movd_m2r (remaining, mm3);
/* combine the swapped data in mm4 */
- por_r2r(mm1,mm4);
+ por_r2r (mm1, mm4);
/* save off the bits in mm4 to mm0 */
- movq_r2r(mm4,mm0);
+ movq_r2r (mm4, mm0);
/* get the new low-order bits in mm4, shifted by 'mm3' */
- psrlq_r2r(mm3,mm4);
+ psrlq_r2r (mm3, mm4);
/* save off new remaining bits */
gb->bits = remaining;
/* combine bits into mm2 */
- por_r2r(mm2,mm4);
+ por_r2r (mm2, mm4);
/* save off the result */
- movd_r2m(mm2,result);
+ movd_r2m (mm2, result);
/* get rid of the bits we just read */
- psllq_r2r(mm1,mm0);
+ psllq_r2r (mm1, mm0);
/* save off mm0 */
- movq_r2m(mm0,gb->qword);
+ movq_r2m (mm0, gb->qword);
/* finished with MMX */
- emms();
+ emms ();
/* we have what we came for */
- return(result);
+ return (result);
} else {
/* load the number of bits requested into mm1 */
- movd_m2r(bits,mm1);
+ movd_m2r (bits, mm1);
/* shift the quadword in mm2 by 'mm3' bits */
- psrlq_r2r(mm3,mm2);
+ psrlq_r2r (mm3, mm2);
/* update the number of valid bits */
gb->bits = remaining;
/* save off the remaining bits */
- movd_r2m(mm2,result);
+ movd_r2m (mm2, result);
/* discard those bits in mm0 */
- psllq_r2r(mm1,mm0);
+ psllq_r2r (mm1, mm0);
/* save off mm0 */
- movq_r2m(mm0,gb->qword);
+ movq_r2m (mm0, gb->qword);
/* finished with MMX */
- emms();
+ emms ();
/* we have what we came for */
- return(result);
+ return (result);
}
}
#endif /* HAVE_LIBMMX */
-unsigned long _gst_getbyte(gst_getbits_t *gb, unsigned long bits) {
+unsigned long
+_gst_getbyte (gst_getbits_t * gb, unsigned long bits)
+{
return *gb->ptr++;
}
/* initialize the getbits structure with the proper getbits func */
-void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data) {
+void
+gst_getbits_init (gst_getbits_t * gb, GstGetbitsCallback callback, void *data)
+{
gb->ptr = NULL;
gb->bits = 0;
gb->callback = callback;
gb->flushbits = _gst_flushbits_int;
gb->backbits = _gst_getbits_back_int;
/* printf("gstgetbits: using callback versions\n"); */
- }
- else {
+ } else {
#ifdef HAVE_CPU_I386
gb->get1bit = _gst_get1bit_i386;
gb->getbits = _gst_getbits_i386;
}
/* set up the getbits structure with a new buffer */
-void gst_getbits_newbuf(gst_getbits_t *gb,unsigned char *buffer, unsigned long len) {
+void
+gst_getbits_newbuf (gst_getbits_t * gb, unsigned char *buffer,
+ unsigned long len)
+{
gb->ptr = buffer;
- gb->endptr = buffer+len;
+ gb->endptr = buffer + len;
gb->bits = 0;
#ifdef unused
/* gb->qword = 0; */
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstgetbits",
- "Accelerated routines for getting bits from a data stream",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstgetbits",
+ "Accelerated routines for getting bits from a data stream",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#define swab32(x) GUINT32_FROM_BE(x)
typedef struct _gst_getbits_t gst_getbits_t;
-typedef void (*GstGetbitsCallback) (gst_getbits_t *gb, void *data);
+typedef void (*GstGetbitsCallback) (gst_getbits_t * gb, void *data);
/* breaks in structure show alignment on quadword boundaries */
/* FIXME: need to find out how to force GCC to align this to octwords */
-struct _gst_getbits_t {
- unsigned char *ptr;
+struct _gst_getbits_t
+{
+ unsigned char *ptr;
unsigned long *longptr;
unsigned char *endptr;
unsigned long length;
- long bits;
+ long bits;
unsigned long dword;
unsigned long temp;
GstGetbitsCallback callback;
void *data;
- unsigned long (*get1bit)(gst_getbits_t *gb, unsigned long bits);
- unsigned long (*getbits)(gst_getbits_t *gb, unsigned long bits);
- unsigned long (*getbits_fast)(gst_getbits_t *gb, unsigned long bits);
- unsigned long (*getbyte)(gst_getbits_t *gb, unsigned long bits);
- unsigned long (*show1bit)(gst_getbits_t *gb, unsigned long bits);
- unsigned long (*showbits)(gst_getbits_t *gb, unsigned long bits);
- void (*flushbits)(gst_getbits_t *gb, unsigned long bits);
- void (*backbits)(gst_getbits_t *gb, unsigned long bits);
+ unsigned long (*get1bit) (gst_getbits_t * gb, unsigned long bits);
+ unsigned long (*getbits) (gst_getbits_t * gb, unsigned long bits);
+ unsigned long (*getbits_fast) (gst_getbits_t * gb, unsigned long bits);
+ unsigned long (*getbyte) (gst_getbits_t * gb, unsigned long bits);
+ unsigned long (*show1bit) (gst_getbits_t * gb, unsigned long bits);
+ unsigned long (*showbits) (gst_getbits_t * gb, unsigned long bits);
+ void (*flushbits) (gst_getbits_t * gb, unsigned long bits);
+ void (*backbits) (gst_getbits_t * gb, unsigned long bits);
};
#include "gstgetbits_inl.h"
#else
-void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data);
-void gst_getbits_newbuf(gst_getbits_t *gb, unsigned char *buffer, unsigned long len);
+void gst_getbits_init (gst_getbits_t * gb, GstGetbitsCallback callback,
+ void *data);
+void gst_getbits_newbuf (gst_getbits_t * gb, unsigned char *buffer,
+ unsigned long len);
#define gst_getbits_bitoffset(gb) \
( \
(-(gb)->bits)&0x7 \
)
-#define gst_getbits_align_byte(gb)
+#define gst_getbits_align_byte(gb)
#define gst_getbits_bufferpos(gb) ((gb)->ptr)
-#define gst_getbits_bytesleft(gb) ((gb)->endptr - (gb)->ptr)
+#define gst_getbits_bytesleft(gb) ((gb)->endptr - (gb)->ptr)
#define gst_getbits_bitsleft(gb) (((gb)->endptr - (gb)->ptr)*8 - ((-(gb)->bits)&0x7))
#include "getbits.h"
-unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits);
-unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits);
-unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits);
-unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits);
-unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits);
-void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits);
-void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits);
-
-
-unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits) {
+unsigned long _gst_getbits_int_cb (gst_getbits_t * gb, unsigned long bits);
+unsigned long _gst_get1bit_int (gst_getbits_t * gb, unsigned long bits);
+unsigned long _gst_getbits_int (gst_getbits_t * gb, unsigned long bits);
+unsigned long _gst_getbits_fast_int (gst_getbits_t * gb, unsigned long bits);
+unsigned long _gst_showbits_int (gst_getbits_t * gb, unsigned long bits);
+void _gst_flushbits_int (gst_getbits_t * gb, unsigned long bits);
+void _gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits);
+
+
+unsigned long
+_gst_getbits_int_cb (gst_getbits_t * gb, unsigned long bits)
+{
int result;
int bitsleft;
/*printf("gst_getbits%lu %ld %p %08x\n", bits, gb->bits, gb->ptr, gb->dword); */
- if (!bits) return 0;
+ if (!bits)
+ return 0;
gb->bits -= bits;
- result = gb->dword >> (32-bits);
+ result = gb->dword >> (32 - bits);
if (gb->bits < 0) {
-
+
gb->ptr += 4;
- bitsleft = (gb->endptr - gb->ptr)*8;
+ bitsleft = (gb->endptr - gb->ptr) * 8;
bits = -gb->bits;
- gb->bits += (bitsleft>32? 32 : bitsleft);
-
+ gb->bits += (bitsleft > 32 ? 32 : bitsleft);
+
if (gb->endptr <= gb->ptr) {
- (gb->callback)(gb, gb->data);
+ (gb->callback) (gb, gb->data);
gb->bits -= bits;
}
- gb->dword = swab32(*((unsigned long *)(gb->ptr)));
+ gb->dword = swab32 (*((unsigned long *) (gb->ptr)));
- result |= (gb->dword >> (32-bits));
+ result |= (gb->dword >> (32 - bits));
}
gb->dword <<= bits;
return result;
}
-unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits) {
+unsigned long
+_gst_get1bit_int (gst_getbits_t * gb, unsigned long bits)
+{
unsigned char rval;
rval = *gb->ptr << gb->bits;
gb->bits++;
- gb->ptr += (gb->bits>>3);
+ gb->ptr += (gb->bits >> 3);
gb->bits &= 0x7;
GST_DEBUG ("getbits%ld, %08x", bits, rval);
- return rval>>7;
+ return rval >> 7;
}
-unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits) {
+unsigned long
+_gst_getbits_int (gst_getbits_t * gb, unsigned long bits)
+{
unsigned long rval;
- if (bits == 0) return 0;
+ if (bits == 0)
+ return 0;
- rval = swab32(*((unsigned long *)(gb->ptr)));
+ rval = swab32 (*((unsigned long *) (gb->ptr)));
rval <<= gb->bits;
gb->bits += bits;
- rval >>= (32-bits);
- gb->ptr += (gb->bits>>3);
+ rval >>= (32 - bits);
+ gb->ptr += (gb->bits >> 3);
gb->bits &= 0x7;
GST_DEBUG ("getbits%ld, %08lx", bits, rval);
return rval;
}
-unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits) {
+unsigned long
+_gst_getbits_fast_int (gst_getbits_t * gb, unsigned long bits)
+{
unsigned long rval;
rval = (unsigned char) (gb->ptr[0] << gb->bits);
- rval |= ((unsigned int) gb->ptr[1] << gb->bits)>>8;
+ rval |= ((unsigned int) gb->ptr[1] << gb->bits) >> 8;
rval <<= bits;
rval >>= 8;
gb->bits += bits;
- gb->ptr += (gb->bits>>3);
+ gb->ptr += (gb->bits >> 3);
gb->bits &= 0x7;
GST_DEBUG ("getbits%ld, %08lx", bits, rval);
return rval;
}
-unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits) {
+unsigned long
+_gst_showbits_int (gst_getbits_t * gb, unsigned long bits)
+{
unsigned long rval;
- if (bits == 0) return 0;
+ if (bits == 0)
+ return 0;
- rval = swab32(*((unsigned long *)(gb->ptr)));
+ rval = swab32 (*((unsigned long *) (gb->ptr)));
rval <<= gb->bits;
- rval >>= (32-bits);
+ rval >>= (32 - bits);
GST_DEBUG ("showbits%ld, %08lx", bits, rval);
return rval;
}
-void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits) {
+void
+_gst_flushbits_int (gst_getbits_t * gb, unsigned long bits)
+{
gb->bits += bits;
- gb->ptr += (gb->bits>>3);
+ gb->ptr += (gb->bits >> 3);
gb->bits &= 0x7;
GST_DEBUG ("flushbits%ld", bits);
}
-void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits) {
+void
+_gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits)
+{
gb->bits -= bits;
- gb->ptr += (gb->bits>>3);
+ gb->ptr += (gb->bits >> 3);
gb->bits &= 0x7;
}
-
#define gst_getbits_bufferpos(gb) ((gb)->longptr)
-#define gst_getbits_bytesleft(gb) ((gb)->endptr - (unsigned char*)(gb)->longptr)
+#define gst_getbits_bytesleft(gb) ((gb)->endptr - (unsigned char*)(gb)->longptr)
#define gst_getbits_bitsleft(gb) (((gb)->endptr - (unsigned char*)(gb)->longptr)*8 - (gb)->bits)
GST_DEBUG_CATEGORY_STATIC (gst_aggregator_debug);
#define GST_CAT_DEFAULT gst_aggregator_debug
-GstElementDetails gst_aggregator_details = GST_ELEMENT_DETAILS (
- "Aggregator pipe fitting",
- "Generic",
- "N-to-1 pipe fitting",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_aggregator_details =
+GST_ELEMENT_DETAILS ("Aggregator pipe fitting",
+ "Generic",
+ "N-to-1 pipe fitting",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Aggregator signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUM_PADS,
ARG_SILENT,
/* FILL ME */
};
-GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate aggregator_src_template =
+GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type())
static GType
{
static GType aggregator_sched_type = 0;
static GEnumValue aggregator_sched[] = {
- { AGGREGATOR_LOOP, "1", "Loop Based"},
- { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
- { AGGREGATOR_CHAIN, "4", "Chain Based"},
+ {AGGREGATOR_LOOP, "1", "Loop Based"},
+ {AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"},
+ {AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL},
};
if (!aggregator_sched_type) {
- aggregator_sched_type = g_enum_register_static ("GstAggregatorSched", aggregator_sched);
+ aggregator_sched_type =
+ g_enum_register_static ("GstAggregatorSched", aggregator_sched);
}
return aggregator_sched_type;
}
#define AGGREGATOR_IS_LOOP_BASED(ag) ((ag)->sched != AGGREGATOR_CHAIN)
-static GstPad* gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *temp, const
- gchar *unused);
-static void gst_aggregator_update_functions (GstAggregator *aggregator);
+static GstPad *gst_aggregator_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * unused);
+static void gst_aggregator_update_functions (GstAggregator * aggregator);
-static void gst_aggregator_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_aggregator_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_aggregator_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_aggregator_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_aggregator_chain (GstPad *pad, GstData *_data);
-static void gst_aggregator_loop (GstElement *element);
+static void gst_aggregator_chain (GstPad * pad, GstData * _data);
+static void gst_aggregator_loop (GstElement * element);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_aggregator_debug, "aggregator", 0, "aggregator element");
-GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
static void
gst_aggregator_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
static void
-gst_aggregator_class_init (GstAggregatorClass *klass)
+gst_aggregator_class_init (GstAggregatorClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
- g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED,
- g_param_spec_enum ("sched", "Scheduling", "The type of scheduling this element should use",
- GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("sched", "Scheduling",
+ "The type of scheduling this element should use",
+ GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "Last message", "The current state of the element",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last_message", "Last message",
+ "The current state of the element", NULL, G_PARAM_READABLE));
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad);
}
-static void
-gst_aggregator_init (GstAggregator *aggregator)
+static void
+gst_aggregator_init (GstAggregator * aggregator)
{
aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_getcaps_function (aggregator->srcpad, gst_pad_proxy_getcaps);
gst_aggregator_update_functions (aggregator);
}
-static GstPad*
-gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *sinkpad;
aggregator = GST_AGGREGATOR (element);
- name = g_strdup_printf ("sink%d",aggregator->numsinkpads);
-
+ name = g_strdup_printf ("sink%d", aggregator->numsinkpads);
+
sinkpad = gst_pad_new_from_template (templ, name);
g_free (name);
-
+
if (!AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_pad_set_chain_function (sinkpad, gst_aggregator_chain);
}
gst_pad_set_getcaps_function (sinkpad, gst_pad_proxy_getcaps);
gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad);
-
+
aggregator->sinkpads = g_list_prepend (aggregator->sinkpads, sinkpad);
aggregator->numsinkpads++;
-
+
return sinkpad;
}
static void
-gst_aggregator_update_functions (GstAggregator *aggregator)
+gst_aggregator_update_functions (GstAggregator * aggregator)
{
GList *pads;
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
- gst_element_set_loop_function (GST_ELEMENT (aggregator), GST_DEBUG_FUNCPTR (gst_aggregator_loop));
- }
- else {
+ gst_element_set_loop_function (GST_ELEMENT (aggregator),
+ GST_DEBUG_FUNCPTR (gst_aggregator_loop));
+ } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
}
pads = aggregator->sinkpads;
while (pads) {
GstPad *pad = GST_PAD (pads->data);
-
+
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_pad_set_get_function (pad, NULL);
- }
- else {
+ } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
}
pads = g_list_next (pads);
}
static void
-gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_aggregator_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAggregator *aggregator;
}
static void
-gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_aggregator_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAggregator *aggregator;
}
}
-static void
-gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug)
+static void
+gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf,
+ guchar * debug)
{
if (!aggregator->silent) {
g_free (aggregator->last_message);
- aggregator->last_message = g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
- G_GUINT64_FORMAT ")",
- debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ aggregator->last_message =
+ g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
+ G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (aggregator), "last_message");
}
gst_pad_push (aggregator->srcpad, GST_DATA (buf));
}
-static void
-gst_aggregator_loop (GstElement *element)
+static void
+gst_aggregator_loop (GstElement * element)
{
GstAggregator *aggregator;
GstBuffer *buf;
* active ones */
while (pads) {
GstPad *pad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
/* we need to check is the pad is usable. IS_USABLE will check
* and that the peer pad is also enabled.
*/
if (GST_PAD_IS_USABLE (pad)) {
- buf = GST_BUFFER (gst_pad_pull (pad));
- debug = "loop";
+ buf = GST_BUFFER (gst_pad_pull (pad));
+ debug = "loop";
/* then push it forward */
- gst_aggregator_push (aggregator, pad, buf, debug);
+ gst_aggregator_push (aggregator, pad, buf, debug);
}
}
- }
- else {
+ } else {
if (aggregator->sched == AGGREGATOR_LOOP_SELECT) {
GstPad *pad;
buf = GST_BUFFER (gst_pad_pull (pad));
gst_aggregator_push (aggregator, pad, buf, debug);
- }
- else {
+ } else {
g_assert_not_reached ();
}
}
*
* Chain a buffer on a pad.
*/
-static void
-gst_aggregator_chain (GstPad *pad, GstData *_data)
+static void
+gst_aggregator_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstAggregator *aggregator;
gst_aggregator_push (aggregator, pad, buf, "chain");
}
-
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-
-typedef enum {
- AGGREGATOR_LOOP = 1,
+G_BEGIN_DECLS typedef enum
+{
+ AGGREGATOR_LOOP = 1,
AGGREGATOR_LOOP_SELECT,
AGGREGATOR_CHAIN
} GstAggregatorSchedType;
#define GST_IS_AGGREGATOR_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR))
-typedef struct _GstAggregator GstAggregator;
-typedef struct _GstAggregatorClass GstAggregatorClass;
+typedef struct _GstAggregator GstAggregator;
+typedef struct _GstAggregatorClass GstAggregatorClass;
-struct _GstAggregator {
+struct _GstAggregator
+{
GstElement element;
GstPad *srcpad;
gchar *last_message;
};
-struct _GstAggregatorClass {
+struct _GstAggregatorClass
+{
GstElementClass parent_class;
};
-GType gst_aggregator_get_type (void);
+GType gst_aggregator_get_type (void);
-gboolean gst_aggregator_factory_init (GstElementFactory *factory);
+gboolean gst_aggregator_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_AGGREGATOR_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_buffer_store_debug);
#define GST_CAT_DEFAULT gst_buffer_store_debug
-enum {
+enum
+{
CLEARED,
BUFFER_ADDED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
-static void gst_buffer_store_dispose (GObject * object);
+static void gst_buffer_store_dispose (GObject * object);
+
+static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store,
+ GstBuffer * buffer);
+static void gst_buffer_store_cleared_func (GstBufferStore * store);
-static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store,
- GstBuffer * buffer);
-static void gst_buffer_store_cleared_func (GstBufferStore * store);
-
static guint gst_buffer_store_signals[LAST_SIGNAL] = { 0 };
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_buffer_store_debug, "GstBufferStore", 0, "buffer store helper");
-GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, _do_init);
+GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT,
+ _do_init);
G_GNUC_UNUSED static void
-debug_buffers (GstBufferStore *store)
+debug_buffers (GstBufferStore * store)
{
GList *walk = store->buffers;
-
+
g_printerr ("BUFFERS in store:\n");
while (walk) {
- g_print ("%15"G_GUINT64_FORMAT" - %7u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data));
+ g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data),
+ GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk);
}
g_printerr ("\n");
}
+
static gboolean
-continue_accu (GSignalInvocationHint *ihint, GValue *return_accu,
- const GValue *handler_return, gpointer data)
+continue_accu (GSignalInvocationHint * ihint, GValue * return_accu,
+ const GValue * handler_return, gpointer data)
{
gboolean do_continue = g_value_get_boolean (handler_return);
+
g_value_set_boolean (return_accu, do_continue);
return do_continue;
{
}
static void
-gst_buffer_store_class_init (GstBufferStoreClass *store_class)
+gst_buffer_store_class_init (GstBufferStoreClass * store_class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (store_class);
gobject_class->dispose = gst_buffer_store_dispose;
-
- gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared",
- G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL,
- gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
- gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added",
- G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL,
- gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER);
+
+ gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared",
+ G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL,
+ gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added",
+ G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL,
+ gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER);
store_class->cleared = gst_buffer_store_cleared_func;
store_class->buffer_added = gst_buffer_store_add_buffer_func;
}
static void
-gst_buffer_store_init (GstBufferStore *store)
+gst_buffer_store_init (GstBufferStore * store)
{
store->buffers = NULL;
}
static void
-gst_buffer_store_dispose (GObject *object)
+gst_buffer_store_dispose (GObject * object)
{
GstBufferStore *store = GST_BUFFER_STORE (object);
parent_class->dispose (object);
}
+
static gboolean
-gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
+gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
{
g_assert (buffer != NULL);
-
+
if (!GST_BUFFER_OFFSET_IS_VALID (buffer) &&
- store->buffers &&
- GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
+ store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* we assumed valid offsets, but suddenly they are not anymore */
- GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort",
- buffer);
+ GST_DEBUG_OBJECT (store,
+ "attempting to add buffer %p with invalid offset to store with valid offset, abort",
+ buffer);
return FALSE;
- } else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
+ } else if (!store->buffers
+ || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* the starting buffer had an invalid offset, in that case we assume continuous buffers */
GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u",
- buffer, GST_BUFFER_SIZE (buffer));
+ buffer, GST_BUFFER_SIZE (buffer));
gst_data_ref (GST_DATA (buffer));
store->buffers = g_list_append (store->buffers, buffer);
return TRUE;
/* both list and buffer have valid offsets, we can really go wild */
GList *walk, *current_list = NULL;
GstBuffer *current;
-
+
g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer));
- GST_LOG_OBJECT (store, "attempting to add buffer %p with offset %"G_GUINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_LOG_OBJECT (store,
+ "attempting to add buffer %p with offset %" G_GUINT64_FORMAT
+ " and size %u", buffer, GST_BUFFER_OFFSET (buffer),
+ GST_BUFFER_SIZE (buffer));
/* we keep a sorted list of non-overlapping buffers */
walk = store->buffers;
while (walk) {
continue;
} else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) {
guint needed_size;
+
if (walk) {
- needed_size = MIN (GST_BUFFER_SIZE (buffer),
- GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
+ needed_size = MIN (GST_BUFFER_SIZE (buffer),
+ GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
} else {
needed_size = GST_BUFFER_SIZE (buffer);
}
if (needed_size < GST_BUFFER_SIZE (buffer)) {
/* need to create subbuffer to not have overlapping data */
GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size);
+
g_assert (sub);
buffer = sub;
} else {
gst_data_ref (GST_DATA (buffer));
}
/* replace current buffer with new one */
- GST_INFO_OBJECT (store, "replacing buffer %p with buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- current_list->data, buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_INFO_OBJECT (store,
+ "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT
+ " and size %u", current_list->data, buffer,
+ GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
gst_data_unref (GST_DATA (current_list->data));
current_list->data = buffer;
buffer = NULL;
}
} else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) {
GList *previous = g_list_previous (current_list);
- guint64 start_offset = previous ?
- GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_SIZE (previous->data) : 0;
+ guint64 start_offset = previous ?
+ GST_BUFFER_OFFSET (previous->data) +
+ GST_BUFFER_SIZE (previous->data) : 0;
if (start_offset == GST_BUFFER_OFFSET (current)) {
buffer = NULL;
} else {
/* we have data to insert */
if (start_offset > GST_BUFFER_OFFSET (buffer) ||
- GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (current)) {
+ GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) >
+ GST_BUFFER_OFFSET (current)) {
GstBuffer *sub;
/* need a subbuffer */
- start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
- start_offset - GST_BUFFER_OFFSET (buffer);
+ start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
+ start_offset - GST_BUFFER_OFFSET (buffer);
sub = gst_buffer_create_sub (buffer, start_offset,
- MIN (GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (buffer)));
+ MIN (GST_BUFFER_SIZE (buffer),
+ GST_BUFFER_OFFSET (current) - start_offset -
+ GST_BUFFER_OFFSET (buffer)));
g_assert (sub);
GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer);
buffer = sub;
} else {
gst_data_ref (GST_DATA (buffer));
}
- GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
- store->buffers = g_list_insert_before (store->buffers, current_list, buffer);
+ GST_INFO_OBJECT (store,
+ "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
+ buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ store->buffers =
+ g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL;
break;
}
}
if (buffer) {
gst_data_ref (GST_DATA (buffer));
- GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u",
- buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
+ GST_INFO_OBJECT (store,
+ "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
+ buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
if (current_list) {
g_list_append (current_list, buffer);
} else {
}
}
static void
-gst_buffer_store_cleared_func (GstBufferStore *store)
+gst_buffer_store_cleared_func (GstBufferStore * store)
{
g_list_foreach (store->buffers, (GFunc) gst_data_unref, NULL);
g_list_free (store->buffers);
store->buffers = NULL;
}
+
/**
* gst_buffer_store_new:
*
{
return GST_BUFFER_STORE (g_object_new (GST_TYPE_BUFFER_STORE, NULL));
}
+
/**
* gst_buffer_store_clear:
* @store: a bufferstore
*/
/* FIXME: call this function _reset ? */
void
-gst_buffer_store_clear (GstBufferStore *store)
+gst_buffer_store_clear (GstBufferStore * store)
{
g_return_if_fail (GST_IS_BUFFER_STORE (store));
-
- g_signal_emit (store, gst_buffer_store_signals [CLEARED], 0, NULL);
+
+ g_signal_emit (store, gst_buffer_store_signals[CLEARED], 0, NULL);
}
+
/**
* gst_buffer_store_add_buffer:
* @store: a bufferstore
* Returns: TRUE, if the buffer was added, FALSE if an error occured.
*/
gboolean
-gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer)
+gst_buffer_store_add_buffer (GstBufferStore * store, GstBuffer * buffer)
{
gboolean ret;
-
+
g_return_val_if_fail (GST_IS_BUFFER_STORE (store), FALSE);
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
GST_BUFFER_OFFSET_IS_VALID (store->buffers->data) &&
!GST_BUFFER_OFFSET_IS_VALID (buffer))
return FALSE;
-
- g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret);
-
+
+ g_signal_emit (store, gst_buffer_store_signals[BUFFER_ADDED], 0, buffer,
+ &ret);
+
return ret;
}
+
/**
* gst_buffer_store_get_buffer:
* @store: a bufferstore
* available.
*/
GstBuffer *
-gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
+gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size)
{
GstBuffer *current;
GList *walk;
if (cur_offset > offset) {
/* #include <windows.h>
do_nothing_loop (); */
- } else if (cur_offset == offset &&
- GST_BUFFER_SIZE (current) == size) {
- GST_LOG_OBJECT (store, "found matching buffer %p for offset %"G_GUINT64_FORMAT" and size %u",
- current, offset, size);
+ } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) {
+ GST_LOG_OBJECT (store,
+ "found matching buffer %p for offset %" G_GUINT64_FORMAT
+ " and size %u", current, offset, size);
ret = current;
gst_data_ref (GST_DATA (ret));
- GST_LOG_OBJECT (store, "refcount %d",
- GST_DATA_REFCOUNT_VALUE(ret));
+ GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret));
break;
} else if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) {
ret = gst_buffer_create_sub (current, offset - cur_offset, size);
- GST_LOG_OBJECT (store, "created subbuffer %p from buffer %p for offset %llu and size %u",
- ret, current, offset, size);
+ GST_LOG_OBJECT (store,
+ "created subbuffer %p from buffer %p for offset %llu and size %u",
+ ret, current, offset, size);
break;
}
/* uh, the requested data spans some buffers */
ret = gst_buffer_new_and_alloc (size);
- GST_LOG_OBJECT (store, "created buffer %p for offset %"G_GUINT64_FORMAT
- " and size %u, will fill with data now",
- ret, offset, size);
+ GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT
+ " and size %u, will fill with data now", ret, offset, size);
data = GST_BUFFER_DATA (ret);
tmp = GST_BUFFER_SIZE (current) - offset + cur_offset;
memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp);
data += tmp;
size -= tmp;
while (size) {
- if (walk == NULL ||
- (have_offset &&
- GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) {
- GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and remaining size %u available, aborting",
- offset, size);
+ if (walk == NULL ||
+ (have_offset &&
+ GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) !=
+ GST_BUFFER_OFFSET (walk->data))) {
+ GST_DEBUG_OBJECT (store,
+ "not all data for offset %" G_GUINT64_FORMAT
+ " and remaining size %u available, aborting", offset, size);
gst_data_unref (GST_DATA (ret));
ret = NULL;
goto out;
}
}
out:
-
+
return ret;
}
+
/**
* gst_buffer_store_get_size:
* @store: a bufferstore
* offset.
*/
guint
-gst_buffer_store_get_size (GstBufferStore *store, guint64 offset)
+gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
{
GList *walk;
gboolean have_offset;
have_offset = FALSE;
}
while (walk) {
- if (have_offset && counting &&
- cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data)) {
+ if (have_offset && counting &&
+ cur_offset + GST_BUFFER_SIZE (current) !=
+ GST_BUFFER_OFFSET (walk->data)) {
break;
}
current = GST_BUFFER (walk->data);
cur_offset += GST_BUFFER_SIZE (current);
}
}
-
+
return ret;
}
#include <gst/gstmarshal.h>
G_BEGIN_DECLS
-
#define GST_TYPE_BUFFER_STORE (gst_buffer_store_get_type ())
#define GST_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_STORE, GstBufferStore))
#define GST_IS_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_STORE))
#define GST_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_STORE, GstBufferStoreClass))
#define GST_IS_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_STORE))
#define GST_BUFFER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_STORE, GstBufferStoreClass))
+typedef struct _GstBufferStore GstBufferStore;
+typedef struct _GstBufferStoreClass GstBufferStoreClass;
-typedef struct _GstBufferStore GstBufferStore;
-typedef struct _GstBufferStoreClass GstBufferStoreClass;
-
-struct _GstBufferStore {
- GObject object;
+struct _GstBufferStore
+{
+ GObject object;
- GList * buffers;
+ GList *buffers;
};
-struct _GstBufferStoreClass {
- GObjectClass parent_class;
+struct _GstBufferStoreClass
+{
+ GObjectClass parent_class;
/* signals */
- void (* cleared) (GstBufferStore * store);
- gboolean (* buffer_added) (GstBufferStore * store,
- GstBuffer * buffer);
+ void (*cleared) (GstBufferStore * store);
+ gboolean (*buffer_added) (GstBufferStore * store, GstBuffer * buffer);
};
-GType gst_buffer_store_get_type (void);
+GType gst_buffer_store_get_type (void);
-GstBufferStore * gst_buffer_store_new (void);
-void gst_buffer_store_clear (GstBufferStore * store);
+GstBufferStore *gst_buffer_store_new (void);
+void gst_buffer_store_clear (GstBufferStore * store);
-gboolean gst_buffer_store_add_buffer (GstBufferStore * store,
- GstBuffer * buffer);
+gboolean gst_buffer_store_add_buffer (GstBufferStore * store,
+ GstBuffer * buffer);
-GstBuffer * gst_buffer_store_get_buffer (GstBufferStore * store,
- guint64 offset,
- guint size);
-guint gst_buffer_store_get_size (GstBufferStore * store,
- guint64 offset);
+GstBuffer *gst_buffer_store_get_buffer (GstBufferStore * store,
+ guint64 offset, guint size);
+guint gst_buffer_store_get_size (GstBufferStore * store, guint64 offset);
G_END_DECLS
-
#endif /* __GST_BUFFER_STORE_H__ */
#include "gsttypefind.h"
-struct _elements_entry {
+struct _elements_entry
+{
gchar *name;
guint rank;
- GType (*type) (void);
+ GType (*type) (void);
};
-extern GType gst_filesrc_get_type(void);
+extern GType gst_filesrc_get_type (void);
extern GstElementDetails gst_filesrc_details;
static struct _elements_entry _elements[] = {
- { "aggregator", GST_RANK_NONE, gst_aggregator_get_type },
- { "fakesrc", GST_RANK_NONE, gst_fakesrc_get_type },
- { "fakesink", GST_RANK_NONE, gst_fakesink_get_type },
- { "fdsink", GST_RANK_NONE, gst_fdsink_get_type },
- { "fdsrc", GST_RANK_NONE, gst_fdsrc_get_type },
- { "filesrc", GST_RANK_NONE, gst_filesrc_get_type },
- { "filesink", GST_RANK_NONE, gst_filesink_get_type },
- { "identity", GST_RANK_NONE, gst_identity_get_type },
- { "md5sink", GST_RANK_NONE, gst_md5sink_get_type },
- { "multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type },
- { "pipefilter", GST_RANK_NONE, gst_pipefilter_get_type },
- { "shaper", GST_RANK_NONE, gst_shaper_get_type },
- { "statistics", GST_RANK_NONE, gst_statistics_get_type },
- { "tee", GST_RANK_NONE, gst_tee_get_type },
- { "typefind", GST_RANK_NONE, gst_type_find_element_get_type },
- { NULL, 0 },
+ {"aggregator", GST_RANK_NONE, gst_aggregator_get_type},
+ {"fakesrc", GST_RANK_NONE, gst_fakesrc_get_type},
+ {"fakesink", GST_RANK_NONE, gst_fakesink_get_type},
+ {"fdsink", GST_RANK_NONE, gst_fdsink_get_type},
+ {"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type},
+ {"filesrc", GST_RANK_NONE, gst_filesrc_get_type},
+ {"filesink", GST_RANK_NONE, gst_filesink_get_type},
+ {"identity", GST_RANK_NONE, gst_identity_get_type},
+ {"md5sink", GST_RANK_NONE, gst_md5sink_get_type},
+ {"multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type},
+ {"pipefilter", GST_RANK_NONE, gst_pipefilter_get_type},
+ {"shaper", GST_RANK_NONE, gst_shaper_get_type},
+ {"statistics", GST_RANK_NONE, gst_statistics_get_type},
+ {"tee", GST_RANK_NONE, gst_tee_get_type},
+ {"typefind", GST_RANK_NONE, gst_type_find_element_get_type},
+ {NULL, 0},
};
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
struct _elements_entry *my_elements = _elements;
-
- while ((*my_elements).name) {
- if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, ((*my_elements).type) ()))
+
+ while ((*my_elements).name) {
+ if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank,
+ ((*my_elements).type) ()))
return FALSE;
my_elements++;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstelements",
- "standard GStreamer elements",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstelements",
+ "standard GStreamer elements",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
GST_DEBUG_CATEGORY_STATIC (gst_fakesink_debug);
#define GST_CAT_DEFAULT gst_fakesink_debug
-GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS (
- "Fake Sink",
- "Sink",
- "Black hole for data",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ("Fake Sink",
+ "Sink",
+ "Black hole for data",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FakeSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_STATE_ERROR,
ARG_NUM_SINKS,
ARG_LAST_MESSAGE,
};
-GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type())
static GType
{
static GType fakesink_state_error_type = 0;
static GEnumValue fakesink_state_error[] = {
- { FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
- { FAKESINK_STATE_ERROR_NULL_READY, "1", "Fail state change from NULL to READY"},
- { FAKESINK_STATE_ERROR_READY_PAUSED, "2", "Fail state change from READY to PAUSED"},
- { FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", "Fail state change from PAUSED to PLAYING"},
- { FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", "Fail state change from PLAYING to PAUSED"},
- { FAKESINK_STATE_ERROR_PAUSED_READY , "5", "Fail state change from PAUSED to READY"},
- { FAKESINK_STATE_ERROR_READY_NULL , "6", "Fail state change from READY to NULL"},
+ {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
+ {FAKESINK_STATE_ERROR_NULL_READY, "1",
+ "Fail state change from NULL to READY"},
+ {FAKESINK_STATE_ERROR_READY_PAUSED, "2",
+ "Fail state change from READY to PAUSED"},
+ {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3",
+ "Fail state change from PAUSED to PLAYING"},
+ {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4",
+ "Fail state change from PLAYING to PAUSED"},
+ {FAKESINK_STATE_ERROR_PAUSED_READY, "5",
+ "Fail state change from PAUSED to READY"},
+ {FAKESINK_STATE_ERROR_READY_NULL, "6",
+ "Fail state change from READY to NULL"},
{0, NULL, NULL},
};
if (!fakesink_state_error_type) {
- fakesink_state_error_type = g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
+ fakesink_state_error_type =
+ g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
}
return fakesink_state_error_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fakesink_debug, "fakesink", 0, "fakesink element");
-GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fakesink_set_clock (GstElement *element, GstClock *clock);
-static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const
- gchar *unused);
+static void gst_fakesink_set_clock (GstElement * element, GstClock * clock);
+static GstPad *gst_fakesink_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
-static void gst_fakesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fakesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fakesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fakesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn
- gst_fakesink_change_state (GstElement *element);
+static GstElementStateReturn gst_fakesink_change_state (GstElement * element);
-static void gst_fakesink_chain (GstPad *pad, GstData *_data);
+static void gst_fakesink_chain (GstPad * pad, GstData * _data);
static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
static void
gst_fakesink_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_set_details (gstelement_class, &gst_fakesink_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesink_sink_template));
}
static void
-gst_fakesink_class_init (GstFakeSinkClass *klass)
+gst_fakesink_class_init (GstFakeSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
- g_param_spec_int ("num_sinks", "Number of sinks", "The number of sinkpads",
- 1, G_MAXINT, 1, G_PARAM_READABLE));
+ g_param_spec_int ("num_sinks", "Number of sinks",
+ "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR,
- g_param_spec_enum ("state_error", "State Error", "Generate a state change error",
- GST_TYPE_FAKESINK_STATE_ERROR, FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
+ g_param_spec_enum ("state_error", "State Error",
+ "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR,
+ FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "Last Message", "The message describing current status",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last_message", "Last Message",
+ "The message describing current status", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
- g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
- g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
+ "Send a signal before unreffing the buffer", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent",
+ "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
- GST_TYPE_BUFFER, GST_TYPE_PAD);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
+ GST_TYPE_BUFFER, GST_TYPE_PAD);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad);
- gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesink_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad);
+ gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock);
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_fakesink_change_state);
}
-static void
-gst_fakesink_init (GstFakeSink *fakesink)
+static void
+gst_fakesink_init (GstFakeSink * fakesink)
{
GstPad *pad;
}
static void
-gst_fakesink_set_clock (GstElement *element, GstClock *clock)
-{
+gst_fakesink_set_clock (GstElement * element, GstClock * clock)
+{
GstFakeSink *sink;
sink = GST_FAKESINK (element);
sink->clock = clock;
-}
+}
-static GstPad*
-gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_fakesink_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *sinkpad;
sinkpad = gst_pad_new_from_template (templ, name);
g_free (name);
gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
-
+
gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad);
return sinkpad;
}
static void
-gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_fakesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFakeSink *sink;
}
}
-static void
-gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fakesink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFakeSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FAKESINK (object));
-
+
sink = GST_FAKESINK (object);
-
+
switch (prop_id) {
case ARG_NUM_SINKS:
g_value_set_int (value, GST_ELEMENT (sink)->numsinkpads);
}
}
-static void
-gst_fakesink_chain (GstPad *pad, GstData *_data)
+static void
+gst_fakesink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFakeSink *fakesink;
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
-
- if (!fakesink->silent) {
+
+ if (!fakesink->silent) {
g_free (fakesink->last_message);
- fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
- GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
-
+ fakesink->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
+ GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
+
g_object_notify (G_OBJECT (fakesink), "last_message");
}
-
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
- if (fakesink->sync && fakesink->clock) {
- gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
- gst_element_set_time (GST_ELEMENT (fakesink), value);
+ if (fakesink->sync && fakesink->clock) {
+ gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
+
+ gst_element_set_time (GST_ELEMENT (fakesink), value);
}
default:
gst_pad_event_default (pad, event);
- break;
+ break;
}
return;
}
- if (fakesink->sync && fakesink->clock) {
+ if (fakesink->sync && fakesink->clock) {
gst_element_wait (GST_ELEMENT (fakesink), GST_BUFFER_TIMESTAMP (buf));
}
- if (!fakesink->silent) {
+ if (!fakesink->silent) {
g_free (fakesink->last_message);
- fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
- G_GINT64_FORMAT ", duration: %"
- G_GINT64_FORMAT ", offset: %"
- G_GINT64_FORMAT ", flags: %d) %p",
- GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf),
- GST_BUFFER_TIMESTAMP (buf),
- GST_BUFFER_DURATION (buf),
- GST_BUFFER_OFFSET (buf),
- GST_BUFFER_FLAGS (buf), buf);
-
+ fakesink->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
+ G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %"
+ G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf),
+ GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf),
+ GST_BUFFER_FLAGS (buf), buf);
+
g_object_notify (G_OBJECT (fakesink), "last_message");
}
if (fakesink->signal_handoffs)
- g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
+ g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
+ buf, pad);
if (fakesink->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
static GstElementStateReturn
-gst_fakesink_change_state (GstElement *element)
+gst_fakesink_change_state (GstElement * element)
{
GstFakeSink *fakesink = GST_FAKESINK (element);
GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL));
return GST_STATE_FAILURE;
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FAKESINK \
(gst_fakesink_get_type())
#define GST_FAKESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FAKESINK))
#define GST_IS_FAKESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK))
-
-typedef enum {
+ typedef enum
+{
FAKESINK_STATE_ERROR_NONE = 0,
FAKESINK_STATE_ERROR_NULL_READY,
FAKESINK_STATE_ERROR_READY_PAUSED,
typedef struct _GstFakeSink GstFakeSink;
typedef struct _GstFakeSinkClass GstFakeSinkClass;
-struct _GstFakeSink {
- GstElement element;
+struct _GstFakeSink
+{
+ GstElement element;
- gboolean silent;
- gboolean dump;
- gboolean sync;
- gboolean signal_handoffs;
- GstClock *clock;
+ gboolean silent;
+ gboolean dump;
+ gboolean sync;
+ gboolean signal_handoffs;
+ GstClock *clock;
GstFakeSinkStateError state_error;
- gchar *last_message;
+ gchar *last_message;
};
-struct _GstFakeSinkClass {
+struct _GstFakeSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad);
+ void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad);
};
-GType gst_fakesink_get_type(void);
+GType gst_fakesink_get_type (void);
-gboolean gst_fakesink_factory_init (GstElementFactory *factory);
+gboolean gst_fakesink_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_FAKESINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fakesrc_debug);
#define GST_CAT_DEFAULT gst_fakesrc_debug
-GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS (
- "Fake Source",
- "Source",
- "Push empty (no data) buffers around",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ("Fake Source",
+ "Source",
+ "Push empty (no data) buffers around",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* FakeSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_NUM_SOURCES,
ARG_LOOP_BASED,
ARG_LAST_MESSAGE,
};
-GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
static GType
-gst_fakesrc_output_get_type (void)
+gst_fakesrc_output_get_type (void)
{
static GType fakesrc_output_type = 0;
static GEnumValue fakesrc_output[] = {
- { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
- { FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"},
- { FAKESRC_PING_PONG, "3", "Ping-Pong"},
- { FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"},
- { FAKESRC_RANDOM, "5", "Random"},
- { FAKESRC_PATTERN_LOOP, "6", "Patttern loop"},
- { FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"},
- { FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
+ {FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
+ {FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"},
+ {FAKESRC_PING_PONG, "3", "Ping-Pong"},
+ {FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"},
+ {FAKESRC_RANDOM, "5", "Random"},
+ {FAKESRC_PATTERN_LOOP, "6", "Patttern loop"},
+ {FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"},
+ {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
{0, NULL, NULL},
};
if (!fakesrc_output_type) {
- fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
+ fakesrc_output_type =
+ g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
}
return fakesrc_output_type;
}
#define GST_TYPE_FAKESRC_DATA (gst_fakesrc_data_get_type())
static GType
-gst_fakesrc_data_get_type (void)
+gst_fakesrc_data_get_type (void)
{
static GType fakesrc_data_type = 0;
static GEnumValue fakesrc_data[] = {
- { FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
- { FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
+ {FAKESRC_DATA_ALLOCATE, "1", "Allocate data"},
+ {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{0, NULL, NULL},
};
if (!fakesrc_data_type) {
#define GST_TYPE_FAKESRC_SIZETYPE (gst_fakesrc_sizetype_get_type())
static GType
-gst_fakesrc_sizetype_get_type (void)
+gst_fakesrc_sizetype_get_type (void)
{
static GType fakesrc_sizetype_type = 0;
static GEnumValue fakesrc_sizetype[] = {
- { FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
- { FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
- { FAKESRC_SIZETYPE_RANDOM, "3", "Random sized buffers (sizemin <= size <= sizemax)"},
+ {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
+ {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
+ {FAKESRC_SIZETYPE_RANDOM, "3",
+ "Random sized buffers (sizemin <= size <= sizemax)"},
{0, NULL, NULL},
};
if (!fakesrc_sizetype_type) {
- fakesrc_sizetype_type = g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
+ fakesrc_sizetype_type =
+ g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
}
return fakesrc_sizetype_type;
}
#define GST_TYPE_FAKESRC_FILLTYPE (gst_fakesrc_filltype_get_type())
static GType
-gst_fakesrc_filltype_get_type (void)
+gst_fakesrc_filltype_get_type (void)
{
static GType fakesrc_filltype_type = 0;
static GEnumValue fakesrc_filltype[] = {
- { FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"},
- { FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"},
- { FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
- { FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
- { FAKESRC_FILLTYPE_PATTERN_CONT, "5", "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
+ {FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"},
+ {FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"},
+ {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
+ {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
+ {FAKESRC_FILLTYPE_PATTERN_CONT, "5",
+ "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
{0, NULL, NULL},
};
if (!fakesrc_filltype_type) {
- fakesrc_filltype_type = g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
+ fakesrc_filltype_type =
+ g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
}
return fakesrc_filltype_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fakesrc_debug, "fakesrc", 0, "fakesrc element");
-GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ,const gchar *unused);
-static void gst_fakesrc_update_functions (GstFakeSrc *src);
-static void gst_fakesrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fakesrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static GstPad *gst_fakesrc_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
+static void gst_fakesrc_update_functions (GstFakeSrc * src);
+static void gst_fakesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fakesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_fakesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_fakesrc_change_state (GstElement * element);
-static GstData* gst_fakesrc_get (GstPad *pad);
-static void gst_fakesrc_loop (GstElement *element);
+static GstData *gst_fakesrc_get (GstPad * pad);
+static void gst_fakesrc_loop (GstElement * element);
static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 };
static void
gst_fakesrc_base_init (gpointer g_class)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_set_details (gstelement_class, &gst_fakesrc_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&fakesrc_src_template));
}
static void
-gst_fakesrc_class_init (GstFakeSrcClass *klass)
+gst_fakesrc_class_init (GstFakeSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
- g_param_spec_int ("num-sources", "num-sources", "Number of sources",
- 1, G_MAXINT, 1, G_PARAM_READABLE));
+ g_param_spec_int ("num-sources", "num-sources", "Number of sources",
+ 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
- g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("loop-based", "loop-based",
+ "Enable loop-based operation", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
- g_param_spec_enum ("output", "output", "Output method (currently unused)",
- GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
+ g_param_spec_enum ("output", "output", "Output method (currently unused)",
+ GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
- g_param_spec_enum ("data", "data", "Data allocation method",
- GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
+ g_param_spec_enum ("data", "data", "Data allocation method",
+ GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE,
- g_param_spec_enum ("sizetype", "sizetype", "How to determine buffer sizes",
- GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
+ g_param_spec_enum ("sizetype", "sizetype",
+ "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE,
+ FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
- g_param_spec_int ("sizemin","sizemin","Minimum buffer size",
- 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0,
+ G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
- g_param_spec_int ("sizemax","sizemax","Maximum buffer size",
- 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0,
+ G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
- g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation",
- 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
+ g_param_spec_int ("parentsize", "parentsize",
+ "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT,
+ DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
- g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
- GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
+ g_param_spec_enum ("filltype", "filltype",
+ "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE,
+ FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
- g_param_spec_string ("pattern", "pattern", "pattern",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("pattern", "pattern", "pattern", NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
- g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("num-buffers", "num-buffers",
+ "Number of buffers to output before sending EOS", G_MININT, G_MAXINT,
+ 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
- g_param_spec_boolean ("eos", "eos", "Send out the EOS event?",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "The last status message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message",
+ "The last status message", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "Silent",
+ "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
- g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
+ "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
- GST_TYPE_BUFFER, GST_TYPE_PAD);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2,
+ GST_TYPE_BUFFER, GST_TYPE_PAD);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state);
}
-static void
-gst_fakesrc_init (GstFakeSrc *fakesrc)
+static void
+gst_fakesrc_init (GstFakeSrc * fakesrc)
{
GstPad *pad;
fakesrc->last_message = NULL;
}
-static GstPad*
-gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_fakesrc_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *srcpad;
}
static const GstFormat *
-gst_fakesrc_get_formats (GstPad *pad)
+gst_fakesrc_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_DEFAULT,
}
static const GstQueryType *
-gst_fakesrc_get_query_types (GstPad *pad)
+gst_fakesrc_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
}
static gboolean
-gst_fakesrc_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_fakesrc_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFakeSrc *src = GST_FAKESRC (GST_PAD_PARENT (pad));
break;
default:
return FALSE;
- }
+ }
return TRUE;
}
static const GstEventMask *
-gst_fakesrc_get_event_mask (GstPad *pad)
+gst_fakesrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP },
- { GST_EVENT_FLUSH, 0 },
- { 0, 0 },
+ {GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP},
+ {GST_EVENT_FLUSH, 0},
+ {0, 0},
};
return masks;
}
static gboolean
-gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
+gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
{
GstFakeSrc *src;
src->buffer_count = GST_EVENT_SEEK_OFFSET (event);
if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
- break;
+ break;
}
/* else we do a flush too */
case GST_EVENT_SEEK_SEGMENT:
src->segment_start = GST_EVENT_SEEK_OFFSET (event);
src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
src->buffer_count = src->segment_start;
- src->segment_loop = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
+ src->segment_loop =
+ GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
}
static void
-gst_fakesrc_update_functions (GstFakeSrc *src)
+gst_fakesrc_update_functions (GstFakeSrc * src)
{
GList *pads;
if (src->loop_based) {
- gst_element_set_loop_function (GST_ELEMENT (src), GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
- }
- else {
+ gst_element_set_loop_function (GST_ELEMENT (src),
+ GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
+ } else {
gst_element_set_loop_function (GST_ELEMENT (src), NULL);
}
if (src->loop_based) {
gst_pad_set_get_function (pad, NULL);
- }
- else {
+ } else {
gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get));
}
}
static void
-gst_fakesrc_alloc_parent (GstFakeSrc *src)
+gst_fakesrc_alloc_parent (GstFakeSrc * src)
{
GstBuffer *buf;
}
static void
-gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFakeSrc *src;
/* it's not null if we got it, but it might not be ours */
src = GST_FAKESRC (object);
-
+
switch (prop_id) {
case ARG_LOOP_BASED:
src->loop_based = g_value_get_boolean (value);
src->data = g_value_get_enum (value);
if (src->data == FAKESRC_DATA_SUBBUFFER) {
- if (!src->parent)
- gst_fakesrc_alloc_parent (src);
+ if (!src->parent)
+ gst_fakesrc_alloc_parent (src);
} else {
- if (src->parent) {
- gst_buffer_unref (src->parent);
- src->parent = NULL;
- }
+ if (src->parent) {
+ gst_buffer_unref (src->parent);
+ src->parent = NULL;
+ }
}
break;
case ARG_SIZETYPE:
break;
case ARG_EOS:
src->eos = g_value_get_boolean (value);
- GST_INFO ( "will EOS on next buffer");
+ GST_INFO ("will EOS on next buffer");
break;
case ARG_SILENT:
src->silent = g_value_get_boolean (value);
}
}
-static void
-gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fakesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFakeSrc *src;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FAKESRC (object));
-
+
src = GST_FAKESRC (object);
-
+
switch (prop_id) {
case ARG_NUM_SOURCES:
g_value_set_int (value, GST_ELEMENT (src)->numsrcpads);
}
static void
-gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf)
+gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
{
- if (GST_BUFFER_SIZE (buf) == 0)
+ if (GST_BUFFER_SIZE (buf) == 0)
return;
switch (src->filltype) {
guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) {
- *ptr++ = (gint8)((255.0)*rand()/(RAND_MAX));
+ *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX));
}
break;
}
}
}
-static GstBuffer*
-gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size)
+static GstBuffer *
+gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size)
{
GstBuffer *buf;
buf = gst_buffer_new ();
- GST_BUFFER_SIZE(buf) = size;
+ GST_BUFFER_SIZE (buf) = size;
- if (size != 0) {
+ if (size != 0) {
switch (src->filltype) {
case FAKESRC_FILLTYPE_NOTHING:
- GST_BUFFER_DATA(buf) = g_malloc (size);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc (size);
+ break;
case FAKESRC_FILLTYPE_NULL:
- GST_BUFFER_DATA(buf) = g_malloc0 (size);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc0 (size);
+ break;
case FAKESRC_FILLTYPE_RANDOM:
case FAKESRC_FILLTYPE_PATTERN:
case FAKESRC_FILLTYPE_PATTERN_CONT:
default:
- GST_BUFFER_DATA(buf) = g_malloc (size);
- gst_fakesrc_prepare_buffer (src, buf);
- break;
+ GST_BUFFER_DATA (buf) = g_malloc (size);
+ gst_fakesrc_prepare_buffer (src, buf);
+ break;
}
}
}
static guint
-gst_fakesrc_get_size (GstFakeSrc *src)
+gst_fakesrc_get_size (GstFakeSrc * src)
{
guint size;
size = src->sizemax;
break;
case FAKESRC_SIZETYPE_RANDOM:
- size = src->sizemin + (guint8)(((gfloat)src->sizemax)*rand()/(RAND_MAX + (gfloat)src->sizemin));
+ size =
+ src->sizemin +
+ (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX +
+ (gfloat) src->sizemin));
break;
case FAKESRC_SIZETYPE_NULL:
default:
- size = 0;
+ size = 0;
break;
}
}
static GstBuffer *
-gst_fakesrc_create_buffer (GstFakeSrc *src)
+gst_fakesrc_create_buffer (GstFakeSrc * src)
{
GstBuffer *buf;
guint size;
size = gst_fakesrc_get_size (src);
if (size == 0)
- return gst_buffer_new();
+ return gst_buffer_new ();
switch (src->data) {
case FAKESRC_DATA_ALLOCATE:
}
/* see if it's large enough */
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
- buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
- src->parentoffset += size;
- }
- else {
+ buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
+ src->parentoffset += size;
+ } else {
/* the parent is useless now */
gst_buffer_unref (src->parent);
src->parent = NULL;
/* try again (this will allocate a new parent) */
- return gst_fakesrc_create_buffer (src);
+ return gst_fakesrc_create_buffer (src);
}
gst_fakesrc_prepare_buffer (src, buf);
break;
default:
g_warning ("fakesrc: dunno how to allocate buffers !");
- buf = gst_buffer_new();
+ buf = gst_buffer_new ();
break;
}
if (dump) {
}
static GstData *
-gst_fakesrc_get(GstPad *pad)
+gst_fakesrc_get (GstPad * pad)
{
GstFakeSrc *src;
GstBuffer *buf;
if (src->need_flush) {
src->need_flush = FALSE;
- return GST_DATA(gst_event_new (GST_EVENT_FLUSH));
+ return GST_DATA (gst_event_new (GST_EVENT_FLUSH));
}
if (src->buffer_count == src->segment_end) {
if (src->segment_loop) {
- return GST_DATA(gst_event_new (GST_EVENT_SEGMENT_DONE));
- }
- else {
+ return GST_DATA (gst_event_new (GST_EVENT_SEGMENT_DONE));
+ } else {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
}
if (src->rt_num_buffers == 0) {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
- }
- else {
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ } else {
if (src->rt_num_buffers > 0)
src->rt_num_buffers--;
}
if (src->eos) {
- GST_INFO ( "fakesrc is setting eos on pad");
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ GST_INFO ("fakesrc is setting eos on pad");
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
buf = gst_fakesrc_create_buffer (src);
if (!src->silent) {
g_free (src->last_message);
- src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
- G_GUINT64_FORMAT " ) %p",
- GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
+ src->last_message =
+ g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
+ G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (src), "last_message");
}
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
- buf, pad);
+ buf, pad);
GST_LOG_OBJECT (src, "post handoff emit");
}
* generate an empty buffer and push it to the next element.
*/
static void
-gst_fakesrc_loop(GstElement *element)
+gst_fakesrc_loop (GstElement * element)
{
GstFakeSrc *src;
const GList *pads;
- g_return_if_fail(element != NULL);
- g_return_if_fail(GST_IS_FAKESRC(element));
+ g_return_if_fail (element != NULL);
+ g_return_if_fail (GST_IS_FAKESRC (element));
src = GST_FAKESRC (element);
}
static GstElementStateReturn
-gst_fakesrc_change_state (GstElement *element)
+gst_fakesrc_change_state (GstElement * element)
{
GstFakeSrc *fakesrc;
break;
case GST_STATE_PAUSED_TO_READY:
if (fakesrc->parent) {
- gst_buffer_unref (fakesrc->parent);
- fakesrc->parent = NULL;
+ gst_buffer_unref (fakesrc->parent);
+ fakesrc->parent = NULL;
}
g_free (fakesrc->last_message);
fakesrc->last_message = NULL;
return GST_STATE_SUCCESS;
}
-
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
FAKESRC_FIRST_LAST_LOOP = 1,
FAKESRC_LAST_FIRST_LOOP,
FAKESRC_PING_PONG,
FAKESRC_GET_ALWAYS_SUCEEDS
} GstFakeSrcOutputType;
-typedef enum {
+typedef enum
+{
FAKESRC_DATA_ALLOCATE = 1,
FAKESRC_DATA_SUBBUFFER,
} GstFakeSrcDataType;
-typedef enum {
+typedef enum
+{
FAKESRC_SIZETYPE_NULL = 1,
FAKESRC_SIZETYPE_FIXED,
FAKESRC_SIZETYPE_RANDOM
} GstFakeSrcSizeType;
-typedef enum {
+typedef enum
+{
FAKESRC_FILLTYPE_NOTHING = 1,
FAKESRC_FILLTYPE_NULL,
FAKESRC_FILLTYPE_RANDOM,
typedef struct _GstFakeSrc GstFakeSrc;
typedef struct _GstFakeSrcClass GstFakeSrcClass;
-struct _GstFakeSrc {
- GstElement element;
+struct _GstFakeSrc
+{
+ GstElement element;
- gboolean loop_based;
- gboolean eos;
+ gboolean loop_based;
+ gboolean eos;
GstFakeSrcOutputType output;
- GstFakeSrcDataType data;
- GstFakeSrcSizeType sizetype;
- GstFakeSrcFillType filltype;
-
- guint sizemin;
- guint sizemax;
- GstBuffer *parent;
- guint parentsize;
- guint parentoffset;
- guint8 pattern_byte;
- gchar *pattern;
- GList *patternlist;
- gint64 segment_start;
- gint64 segment_end;
- gboolean segment_loop;
- gint num_buffers;
- gint rt_num_buffers; /* we are going to change this at runtime */
- guint64 buffer_count;
- gboolean silent;
- gboolean signal_handoffs;
- gboolean dump;
- gboolean need_flush;
-
- gchar *last_message;
+ GstFakeSrcDataType data;
+ GstFakeSrcSizeType sizetype;
+ GstFakeSrcFillType filltype;
+
+ guint sizemin;
+ guint sizemax;
+ GstBuffer *parent;
+ guint parentsize;
+ guint parentoffset;
+ guint8 pattern_byte;
+ gchar *pattern;
+ GList *patternlist;
+ gint64 segment_start;
+ gint64 segment_end;
+ gboolean segment_loop;
+ gint num_buffers;
+ gint rt_num_buffers; /* we are going to change this at runtime */
+ guint64 buffer_count;
+ gboolean silent;
+ gboolean signal_handoffs;
+ gboolean dump;
+ gboolean need_flush;
+
+ gchar *last_message;
};
-struct _GstFakeSrcClass {
+struct _GstFakeSrcClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad);
+ void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad);
};
-GType gst_fakesrc_get_type(void);
+GType gst_fakesrc_get_type (void);
-gboolean gst_fakesrc_factory_init (GstElementFactory *factory);
+gboolean gst_fakesrc_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_FAKESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fdsink_debug);
#define GST_CAT_DEFAULT gst_fdsink_debug
-GstElementDetails gst_fdsink_details = GST_ELEMENT_DETAILS (
- "Filedescriptor Sink",
- "Sink/File",
- "Write data to a file descriptor",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fdsink_details =
+GST_ELEMENT_DETAILS ("Filedescriptor Sink",
+ "Sink/File",
+ "Write data to a file descriptor",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FdSink signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FD
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fdsink_debug, "fdsink", 0, "fdsink element");
-GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fdsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fdsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fdsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_fdsink_chain (GstPad *pad,GstData *_data);
+static void gst_fdsink_chain (GstPad * pad, GstData * _data);
static void
gst_fdsink_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_fdsink_details);
}
static void
-gst_fdsink_class_init (GstFdSinkClass *klass)
+gst_fdsink_class_init (GstFdSinkClass * klass)
{
GObjectClass *gobject_class;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
- 0, G_MAXINT, 1, G_PARAM_READWRITE));
+ g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
+ 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property;
}
-static void
-gst_fdsink_init (GstFdSink *fdsink)
+static void
+gst_fdsink_init (GstFdSink * fdsink)
{
fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad);
fdsink->fd = 1;
}
-static void
-gst_fdsink_chain (GstPad *pad, GstData *_data)
+static void
+gst_fdsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFdSink *fdsink;
g_return_if_fail (buf != NULL);
fdsink = GST_FDSINK (gst_pad_get_parent (pad));
-
+
g_return_if_fail (fdsink->fd >= 0);
-
+
if (GST_BUFFER_DATA (buf)) {
- GST_DEBUG ("writing %d bytes to file descriptor %d",GST_BUFFER_SIZE (buf), fdsink->fd);
+ GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf),
+ fdsink->fd);
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
-
+
gst_buffer_unref (buf);
}
-static void
-gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_fdsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFdSink *fdsink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSINK (object));
-
+
fdsink = GST_FDSINK (object);
switch (prop_id) {
}
}
-static void
-gst_fdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fdsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFdSink *fdsink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSINK (object));
-
+
fdsink = GST_FDSINK (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FDSINK \
(gst_fdsink_get_type())
#define GST_FDSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSINK))
#define GST_IS_FDSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK))
-
typedef struct _GstFdSink GstFdSink;
typedef struct _GstFdSinkClass GstFdSinkClass;
-struct _GstFdSink {
+struct _GstFdSink
+{
GstElement element;
GstPad *sinkpad;
int fd;
};
-struct _GstFdSinkClass {
+struct _GstFdSinkClass
+{
GstElementClass parent_class;
};
-GType gst_fdsink_get_type(void);
+GType gst_fdsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_FDSINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_fdsrc_debug);
#define GST_CAT_DEFAULT gst_fdsrc_debug
-GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS (
- "Disk Source",
- "Source/File",
- "Synchronous read from a file",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source",
+ "Source/File",
+ "Synchronous read from a file",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* FdSrc signals and args */
-enum {
+enum
+{
SIGNAL_TIMEOUT,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FD,
ARG_BLOCKSIZE,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element");
-GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_fdsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fdsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fdsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fdsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstData * gst_fdsrc_get (GstPad *pad);
+static GstData *gst_fdsrc_get (GstPad * pad);
static void
gst_fdsrc_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_fdsrc_details);
}
static void
-gst_fdsrc_class_init (GstFdSrcClass *klass)
+gst_fdsrc_class_init (GstFdSrcClass * klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
- g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
- 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("blocksize", "Block size",
+ "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT,
- g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
gst_fdsrc_signals[SIGNAL_TIMEOUT] =
- g_signal_new ("timeout", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_fdsrc_set_property;
gobject_class->get_property = gst_fdsrc_get_property;
}
-static void gst_fdsrc_init(GstFdSrc *fdsrc) {
+static void
+gst_fdsrc_init (GstFdSrc * fdsrc)
+{
fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
-
+
gst_pad_set_get_function (fdsrc->srcpad, gst_fdsrc_get);
gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad);
}
-static void
-gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFdSrc *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
-
+
src = GST_FDSRC (object);
switch (prop_id) {
}
}
-static void
-gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_fdsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFdSrc *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
-
+
src = GST_FDSRC (object);
switch (prop_id) {
}
static GstData *
-gst_fdsrc_get(GstPad *pad)
+gst_fdsrc_get (GstPad * pad)
{
GstFdSrc *src;
GstBuffer *buf;
FD_ZERO (&readfds);
FD_SET (src->fd, &readfds);
- if (src->timeout != 0)
- {
+ if (src->timeout != 0) {
GST_TIME_TO_TIMEVAL (src->timeout, t);
- }
- else
+ } else
tp = NULL;
- do
- {
+ do {
retval = select (1, &readfds, NULL, NULL, tp);
- } while (retval == -1 && errno == EINTR); /* retry if interrupted */
+ } while (retval == -1 && errno == EINTR); /* retry if interrupted */
- if (retval == -1)
- {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("select on file descriptor: %s.", g_strerror(errno)));
+ if (retval == -1) {
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("select on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- else if (retval == 0)
- {
+ } else if (retval == 0) {
g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0);
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA(gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
- do
- {
+ do {
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize);
- } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
+ } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
- if (readbytes > 0)
- {
+ if (readbytes > 0) {
GST_BUFFER_OFFSET (buf) = src->curoffset;
GST_BUFFER_SIZE (buf) = readbytes;
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
/* we're done, return the buffer */
return GST_DATA (buf);
- }
- else if (readbytes == 0)
- {
+ } else if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- else
- {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("read on file descriptor: %s.", g_strerror(errno)));
+ } else {
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("read on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FDSRC \
(gst_fdsrc_get_type())
#define GST_FDSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSRC))
#define GST_IS_FDSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC))
-
-
typedef struct _GstFdSrc GstFdSrc;
typedef struct _GstFdSrcClass GstFdSrcClass;
-struct _GstFdSrc {
+struct _GstFdSrc
+{
GstElement element;
/* pads */
GstPad *srcpad;
/* fd */
gint fd;
- gulong curoffset; /* current offset in file */
- gulong blocksize; /* bytes per read */
- guint64 timeout; /* read timeout, in nanoseconds */
-
- gulong seq; /* buffer sequence number */
+ gulong curoffset; /* current offset in file */
+ gulong blocksize; /* bytes per read */
+ guint64 timeout; /* read timeout, in nanoseconds */
+
+ gulong seq; /* buffer sequence number */
};
-struct _GstFdSrcClass {
+struct _GstFdSrcClass
+{
GstElementClass parent_class;
/* signals */
- void (*timeout) (GstElement *element);
+ void (*timeout) (GstElement * element);
};
-GType gst_fdsrc_get_type(void);
+GType gst_fdsrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_FDSRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_filesink_debug);
#define GST_CAT_DEFAULT gst_filesink_debug
-GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS (
- "File Sink",
- "Sink/File",
- "Write stream to a file",
- "Thomas <thomas@apestaart.org>"
-);
+GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ("File Sink",
+ "Sink/File",
+ "Write stream to a file",
+ "Thomas <thomas@apestaart.org>");
/* FileSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
static const GstFormat *
-gst_filesink_get_formats (GstPad *pad)
+gst_filesink_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_BYTES,
}
static const GstQueryType *
-gst_filesink_get_query_types (GstPad *pad)
+gst_filesink_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
return types;
}
-static void gst_filesink_dispose (GObject *object);
+static void gst_filesink_dispose (GObject * object);
+
+static void gst_filesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_filesink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_filesink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_filesink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static gboolean gst_filesink_open_file (GstFileSink * sink);
+static void gst_filesink_close_file (GstFileSink * sink);
-static gboolean gst_filesink_open_file (GstFileSink *sink);
-static void gst_filesink_close_file (GstFileSink *sink);
+static gboolean gst_filesink_handle_event (GstPad * pad, GstEvent * event);
+static gboolean gst_filesink_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
+static void gst_filesink_chain (GstPad * pad, GstData * _data);
-static gboolean gst_filesink_handle_event (GstPad *pad, GstEvent *event);
-static gboolean gst_filesink_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
-static void gst_filesink_chain (GstPad *pad,GstData *_data);
+static void gst_filesink_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
-static void gst_filesink_uri_handler_init (gpointer g_iface, gpointer iface_data);
-
-static GstElementStateReturn gst_filesink_change_state (GstElement *element);
+static GstElementStateReturn gst_filesink_change_state (GstElement * element);
static guint gst_filesink_signals[LAST_SIGNAL] = { 0 };
NULL,
NULL
};
- g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, &urihandler_info);
- GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, "filesink element");
+ g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER,
+ &urihandler_info);
+ GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0,
+ "filesink element");
}
-GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, _do_init);
-
+GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
+
static void
gst_filesink_base_init (gpointer g_class)
gst_element_class_set_details (gstelement_class, &gst_filesink_details);
}
static void
-gst_filesink_class_init (GstFileSinkClass *klass)
+gst_filesink_class_init (GstFileSinkClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
- g_param_spec_string ("location", "File Location", "Location of the file to write",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the file to write", NULL, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_filesink_set_property;
gobject_class->get_property = gst_filesink_get_property;
- gobject_class->dispose = gst_filesink_dispose;
+ gobject_class->dispose = gst_filesink_dispose;
}
-static void
-gst_filesink_init (GstFileSink *filesink)
+static void
+gst_filesink_init (GstFileSink * filesink)
{
GstPad *pad;
gst_element_add_pad (GST_ELEMENT (filesink), pad);
gst_pad_set_chain_function (pad, gst_filesink_chain);
- GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (GST_ELEMENT (filesink), GST_ELEMENT_EVENT_AWARE);
gst_pad_set_query_function (pad, gst_filesink_pad_query);
gst_pad_set_query_type_function (pad, gst_filesink_get_query_types);
filesink->file = NULL;
}
static void
-gst_filesink_dispose (GObject *object)
+gst_filesink_dispose (GObject * object)
{
GstFileSink *sink = GST_FILESINK (object);
G_OBJECT_CLASS (parent_class)->dispose (object);
-
+
g_free (sink->uri);
sink->uri = NULL;
g_free (sink->filename);
sink->filename = NULL;
}
+
static gboolean
-gst_filesink_set_location (GstFileSink *sink, const gchar *location)
+gst_filesink_set_location (GstFileSink * sink, const gchar * location)
{
/* the element must be stopped or paused in order to do this */
if (GST_STATE (sink) > GST_STATE_PAUSED)
sink->filename = NULL;
sink->uri = NULL;
}
-
+
if (GST_STATE (sink) == GST_STATE_PAUSED)
gst_filesink_open_file (sink);
return TRUE;
}
static void
-gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_filesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFileSink *sink;
}
}
-static void
-gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_filesink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFileSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FILESINK (object));
-
+
sink = GST_FILESINK (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->filename);
}
static gboolean
-gst_filesink_open_file (GstFileSink *sink)
+gst_filesink_open_file (GstFileSink * sink)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN), FALSE);
/* open the file */
- if (sink->filename == NULL || sink->filename[0] == '\0')
- {
+ if (sink->filename == NULL || sink->filename[0] == '\0') {
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
- (_("No file name specified for writing.")), (NULL));
+ (_("No file name specified for writing.")), (NULL));
return FALSE;
}
sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), sink->filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open file \"%s\" for writing."), sink->filename),
+ GST_ERROR_SYSTEM);
return FALSE;
}
}
static void
-gst_filesink_close_file (GstFileSink *sink)
+gst_filesink_close_file (GstFileSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN));
- if (fclose (sink->file) != 0)
- {
+ if (fclose (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), sink->filename),
- GST_ERROR_SYSTEM);
- }
- else {
+ (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
+ } else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
}
}
static gboolean
-gst_filesink_pad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_filesink_pad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFileSink *sink = GST_FILESINK (GST_PAD_PARENT (pad));
case GST_QUERY_TOTAL:
switch (*format) {
case GST_FORMAT_BYTES:
- if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) {
- *value = sink->data_written; /* FIXME - doesn't the kernel provide
- such a function? */
- break;
- }
- default:
+ if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
+ *value = sink->data_written; /* FIXME - doesn't the kernel provide
+ such a function? */
+ break;
+ }
+ default:
return FALSE;
}
break;
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_BYTES:
- if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) {
- *value = ftell (sink->file);
- break;
- }
- default:
+ if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
+ *value = ftell (sink->file);
+ break;
+ }
+ default:
return FALSE;
}
break;
/* handle events (search) */
static gboolean
-gst_filesink_handle_event (GstPad *pad, GstEvent *event)
+gst_filesink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
GstFileSink *filesink;
filesink = GST_FILESINK (gst_pad_get_parent (pad));
- g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN),
- FALSE);
+ g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), FALSE);
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
case GST_EVENT_SEEK:
g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES,
- FALSE);
+ FALSE);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
- if (fflush (filesink->file))
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- GST_ERROR_SYSTEM);
-
- switch (GST_EVENT_SEEK_METHOD(event))
- {
- case GST_SEEK_METHOD_SET:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
- break;
- case GST_SEEK_METHOD_CUR:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
- break;
- case GST_SEEK_METHOD_END:
- fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
- break;
- default:
- g_warning ("unknown seek method!");
- break;
+ if (fflush (filesink->file))
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ GST_ERROR_SYSTEM);
+
+ switch (GST_EVENT_SEEK_METHOD (event)) {
+ case GST_SEEK_METHOD_SET:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
+ break;
+ case GST_SEEK_METHOD_CUR:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
+ break;
+ case GST_SEEK_METHOD_END:
+ fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
+ break;
+ default:
+ g_warning ("unknown seek method!");
+ break;
}
break;
case GST_EVENT_DISCONTINUOUS:
{
gint64 offset;
-
+
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset))
- fseek (filesink->file, offset, SEEK_SET);
+ fseek (filesink->file, offset, SEEK_SET);
gst_event_unref (event);
break;
}
case GST_EVENT_FLUSH:
if (fflush (filesink->file)) {
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- GST_ERROR_SYSTEM);
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ GST_ERROR_SYSTEM);
}
break;
case GST_EVENT_EOS:
*
* take the buffer from the pad and write to file if it's open
*/
-static void
-gst_filesink_chain (GstPad *pad, GstData *_data)
+static void
+gst_filesink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFileSink *filesink;
filesink = GST_FILESINK (gst_pad_get_parent (pad));
- if (GST_IS_EVENT(buf))
- {
- gst_filesink_handle_event(pad, GST_EVENT(buf));
+ if (GST_IS_EVENT (buf)) {
+ gst_filesink_handle_event (pad, GST_EVENT (buf));
return;
}
- if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) {
guint bytes_written = 0, back_pending = 0;
- if (ftell(filesink->file) < filesink->data_written)
- back_pending = filesink->data_written - ftell(filesink->file);
+
+ if (ftell (filesink->file) < filesink->data_written)
+ back_pending = filesink->data_written - ftell (filesink->file);
while (bytes_written < GST_BUFFER_SIZE (buf)) {
size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
- GST_BUFFER_SIZE (buf) - bytes_written,
- filesink->file);
+ GST_BUFFER_SIZE (buf) - bytes_written,
+ filesink->file);
+
if (wrote <= 0) {
- GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
- (_("Error while writing to file \"%s\"."), filesink->filename),
- ("Only %d of %d bytes written: %s",
- bytes_written, GST_BUFFER_SIZE (buf),
- strerror (errno)));
+ GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
+ (_("Error while writing to file \"%s\"."), filesink->filename),
+ ("Only %d of %d bytes written: %s",
+ bytes_written, GST_BUFFER_SIZE (buf), strerror (errno)));
break;
}
bytes_written += wrote;
gst_buffer_unref (buf);
g_signal_emit (G_OBJECT (filesink),
- gst_filesink_signals[SIGNAL_HANDOFF], 0,
- filesink);
+ gst_filesink_signals[SIGNAL_HANDOFF], 0, filesink);
}
static GstElementStateReturn
-gst_filesink_change_state (GstElement *element)
+gst_filesink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_FILESINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN))
- gst_filesink_close_file (GST_FILESINK (element));
+ gst_filesink_close_file (GST_FILESINK (element));
break;
case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) {
- if (!gst_filesink_open_file (GST_FILESINK (element)))
- return GST_STATE_FAILURE;
+ if (!gst_filesink_open_file (GST_FILESINK (element)))
+ return GST_STATE_FAILURE;
}
break;
}
return GST_URI_SINK;
}
static gchar **
-gst_filesink_uri_get_protocols(void)
+gst_filesink_uri_get_protocols (void)
{
- static gchar *protocols[] = {"file", NULL};
+ static gchar *protocols[] = { "file", NULL };
return protocols;
}
static const gchar *
-gst_filesink_uri_get_uri (GstURIHandler *handler)
+gst_filesink_uri_get_uri (GstURIHandler * handler)
{
GstFileSink *sink = GST_FILESINK (handler);
-
+
return sink->uri;
}
+
static gboolean
-gst_filesink_uri_set_uri (GstURIHandler *handler, const gchar *uri)
+gst_filesink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
gchar *protocol, *location;
gboolean ret;
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FILESINK \
(gst_filesink_get_type())
#define GST_FILESINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESINK))
#define GST_IS_FILESINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESINK))
-
typedef struct _GstFileSink GstFileSink;
typedef struct _GstFileSinkClass GstFileSinkClass;
-typedef enum {
- GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST,
+typedef enum
+{
+ GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSinkFlags;
-struct _GstFileSink {
+struct _GstFileSink
+{
GstElement element;
gchar *filename;
guint64 data_written;
};
-struct _GstFileSinkClass {
+struct _GstFileSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstPad *pad);
+ void (*handoff) (GstElement * element, GstPad * pad);
};
-GType gst_filesink_get_type(void);
+GType gst_filesink_get_type (void);
G_END_DECLS
-
#endif /* __GST_FILESINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_filesrc_debug);
#define GST_CAT_DEFAULT gst_filesrc_debug
-GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS (
- "File Source",
- "Source/File",
- "Read from arbitrary point in a file",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ("File Source",
+ "Source/File",
+ "Read from arbitrary point in a file",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
#define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024
/* FileSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_FD,
};
static const GstEventMask *
-gst_filesrc_get_event_mask (GstPad *pad)
+gst_filesrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
- GST_SEEK_METHOD_SET |
- GST_SEEK_METHOD_END |
- GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_FLUSH, 0 },
- { GST_EVENT_SIZE, 0 },
- { 0, 0 }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
+ GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_FLUSH, 0},
+ {GST_EVENT_SIZE, 0},
+ {0, 0}
};
return masks;
}
static const GstQueryType *
-gst_filesrc_get_query_types (GstPad *pad)
+gst_filesrc_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
}
static const GstFormat *
-gst_filesrc_get_formats (GstPad *pad)
+gst_filesrc_get_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_BYTES,
return formats;
}
-static void gst_filesrc_dispose (GObject *object);
+static void gst_filesrc_dispose (GObject * object);
-static void gst_filesrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_filesrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_filesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_filesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_filesrc_check_filesize (GstFileSrc *src);
-static GstData * gst_filesrc_get (GstPad *pad);
-static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event);
-static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
+static gboolean gst_filesrc_check_filesize (GstFileSrc * src);
+static GstData *gst_filesrc_get (GstPad * pad);
+static gboolean gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event);
+static gboolean gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
-static GstElementStateReturn gst_filesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_filesrc_change_state (GstElement * element);
-static void gst_filesrc_uri_handler_init (gpointer g_iface, gpointer iface_data);
+static void gst_filesrc_uri_handler_init (gpointer g_iface,
+ gpointer iface_data);
static void
_do_init (GType filesrc_type)
NULL,
NULL
};
- g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, &urihandler_info);
+ g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER,
+ &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element");
}
-GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
-
+GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
+
static void
gst_filesrc_base_init (gpointer g_class)
{
gst_element_class_set_details (gstelement_class, &gst_filesrc_details);
}
static void
-gst_filesrc_class_init (GstFileSrcClass *klass)
+gst_filesrc_class_init (GstFileSrcClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
- gobject_class = (GObjectClass*)klass;
+ gobject_class = (GObjectClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
- g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("fd", "File-descriptor",
+ "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
- g_param_spec_string ("location", "File Location", "Location of the file to read",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the file to read", NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
- g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
- 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("blocksize", "Block size",
+ "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
- g_param_spec_ulong ("mmapsize", "mmap() Block Size",
- "Size in bytes of mmap()d regions",
- 0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE));
+ g_param_spec_ulong ("mmapsize", "mmap() Block Size",
+ "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
- g_param_spec_boolean ("touch", "Touch read data",
- "Touch data to force disk read",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("touch", "Touch read data",
+ "Touch data to force disk read", FALSE, G_PARAM_READWRITE));
- gobject_class->dispose = gst_filesrc_dispose;
- gobject_class->set_property = gst_filesrc_set_property;
- gobject_class->get_property = gst_filesrc_get_property;
+ gobject_class->dispose = gst_filesrc_dispose;
+ gobject_class->set_property = gst_filesrc_set_property;
+ gobject_class->get_property = gst_filesrc_get_property;
gstelement_class->change_state = gst_filesrc_change_state;
}
static void
-gst_filesrc_init (GstFileSrc *src)
+gst_filesrc_init (GstFileSrc * src)
{
src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (src->srcpad, gst_filesrc_get);
gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats);
gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
- src->pagesize = getpagesize();
+ src->pagesize = getpagesize ();
src->filename = NULL;
src->fd = 0;
src->touch = FALSE;
src->mapbuf = NULL;
- src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
+ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->seek_happened = FALSE;
}
static void
-gst_filesrc_dispose (GObject *object)
+gst_filesrc_dispose (GObject * object)
{
GstFileSrc *src;
}
static gboolean
-gst_filesrc_set_location (GstFileSrc *src, const gchar *location)
+gst_filesrc_set_location (GstFileSrc * src, const gchar * location)
{
/* the element must be stopped in order to do this */
- if (GST_STATE (src) != GST_STATE_READY &&
- GST_STATE (src) != GST_STATE_NULL)
+ if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL)
return FALSE;
- if (src->filename) g_free (src->filename);
- if (src->uri) g_free (src->uri);
+ if (src->filename)
+ g_free (src->filename);
+ if (src->uri)
+ g_free (src->uri);
/* clear the filename if we get a NULL (is that possible?) */
if (location == NULL) {
src->filename = NULL;
}
static void
-gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFileSrc *src;
break;
case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) {
- src->mapsize = g_value_get_ulong (value);
- g_object_notify (G_OBJECT (src), "mmapsize");
+ src->mapsize = g_value_get_ulong (value);
+ g_object_notify (G_OBJECT (src), "mmapsize");
} else {
- GST_INFO_OBJECT (src, "invalid mapsize, must be a multiple of pagesize, which is %d",
- src->pagesize);
+ GST_INFO_OBJECT (src,
+ "invalid mapsize, must be a multiple of pagesize, which is %d",
+ src->pagesize);
}
break;
case ARG_TOUCH:
}
static void
-gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_filesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFileSrc *src;
}
static void
-gst_filesrc_free_parent_mmap (GstBuffer *buf)
+gst_filesrc_free_parent_mmap (GstBuffer * buf)
{
- GST_LOG ("freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u",
+ GST_LOG ("freeing mmap()d buffer at %" G_GUINT64_FORMAT "+%u",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
#ifdef MADV_DONTNEED
munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
/* cast to unsigned long, since there's no gportable way to print
* guint64 as hex */
- GST_LOG ("unmapped region %08lx+%08lx at %p",
+ GST_LOG ("unmapped region %08lx+%08lx at %p",
(unsigned long) GST_BUFFER_OFFSET (buf),
- (unsigned long) GST_BUFFER_MAXSIZE (buf),
- GST_BUFFER_DATA (buf));
+ (unsigned long) GST_BUFFER_MAXSIZE (buf), GST_BUFFER_DATA (buf));
GST_BUFFER_DATA (buf) = NULL;
}
static GstBuffer *
-gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
+gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size)
{
GstBuffer *buf;
gint retval;
g_return_val_if_fail (offset >= 0, NULL);
- GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size);
+ GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",
+ offset, (unsigned long) size);
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) {
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), ("mmap call failed."));
return NULL;
- }
- else if (mmapregion == MAP_FAILED) {
+ } else if (mmapregion == MAP_FAILED) {
GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
- (unsigned long)size, src->fd, offset, strerror (errno));
+ (unsigned long) size, src->fd, offset, strerror (errno));
return NULL;
}
- GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
- (unsigned long)offset, (unsigned long)size, mmapregion);
+ GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
+ (unsigned long) offset, (unsigned long) size, mmapregion);
/* time to allocate a new mapbuf */
buf = gst_buffer_new ();
#ifdef MADV_SEQUENTIAL
/* madvise to tell the kernel what to do with it */
- retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
+ retval =
+ madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
#endif
/* fill in the rest of the fields */
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
}
static GstBuffer *
-gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size)
+gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size)
{
size_t mapsize;
off_t mod, mapbase;
GstBuffer *ret;
mapbase = offset - mod;
- mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
+ mapsize =
+ ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
- map = gst_filesrc_map_region(src, mapbase, mapsize);
+ map = gst_filesrc_map_region (src, mapbase, mapsize);
if (map == NULL)
return NULL;
return ret;
}
- return gst_filesrc_map_region(src,offset,size);
+ return gst_filesrc_map_region (src, offset, size);
}
/**
* Push a new buffer from the filesrc at the current offset.
*/
static GstBuffer *
-gst_filesrc_get_mmap (GstFileSrc *src)
+gst_filesrc_get_mmap (GstFileSrc * src)
{
GstBuffer *buf = NULL;
size_t readsize, mapsize;
- off_t readend,mapstart,mapend;
+ off_t readend, mapstart, mapend;
int i;
/* calculate end pointers so we don't have to do so repeatedly later */
readsize = src->block_size;
- readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
+ readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
mapstart = GST_BUFFER_OFFSET (src->mapbuf);
mapsize = GST_BUFFER_SIZE (src->mapbuf);
- mapend = mapstart + mapsize; /* note this is the byte *after* the map */
+ mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) {
}
}
- GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx",
- (unsigned long)readsize, (unsigned long)readend,
- (unsigned long)mapstart, (unsigned long)mapend);
+ GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx",
+ (unsigned long) readsize, (unsigned long) readend,
+ (unsigned long) mapstart, (unsigned long) mapend);
/* if the start is past the mapstart */
if (src->curoffset >= mapstart) {
/* if the end is before the mapend, the buffer is in current mmap region... */
/* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) {
- GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
- src->curoffset, (int)readsize, mapstart, mapsize);
- buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
- readsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
+ src->curoffset, (int) readsize, mapstart, mapsize);
+ buf =
+ gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
+ readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset;
- /* if the start actually is within the current mmap region, map an overlap buffer */
+ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) {
- GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
- (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
+ (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
+ (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
- return NULL;
+ return NULL;
}
/* the only other option is that buffer is totally outside, which means we search for it */
- /* now we can assume that the start is *before* the current mmap region */
- /* if the readend is past mapstart, we have two options */
+ /* now we can assume that the start is *before* the current mmap region */
+ /* if the readend is past mapstart, we have two options */
} else if (readend >= mapstart) {
/* either the read buffer overlaps the start of the mmap region */
/* or the read buffer fully contains the current mmap region */
- /* either way, it's really not relevant, we just create a new region anyway*/
- GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
- (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
+ /* either way, it's really not relevant, we just create a new region anyway */
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
+ (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
+ (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
return NULL;
if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */
GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",
- src->curoffset,(int)readsize);
-
+ src->curoffset, (int) readsize);
+
/* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
- GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
- src->curoffset,(int)readsize,(int)src->mapsize);
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
+ src->curoffset, (int) readsize, (int) src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL)
return NULL;
- /* otherwise we will create a new mmap region and set it to the default */
+ /* otherwise we will create a new mmap region and set it to the default */
} else {
size_t mapsize;
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
- GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
- src->curoffset, readsize, nextmap, src->mapsize);
+
+ GST_LOG_OBJECT (src,
+ "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
+ src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */
- gst_buffer_unref(src->mapbuf);
+ gst_buffer_unref (src->mapbuf);
mapsize = src->mapsize;
/* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) {
GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d",
- readsize, (int)mapsize);
- mapsize <<=1;
+ readsize, (int) mapsize);
+ mapsize <<= 1;
}
/* create a new one */
src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize);
return NULL;
/* subbuffer it */
- buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, readsize);
- GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
+ buf =
+ gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap,
+ readsize);
+ GST_BUFFER_OFFSET (buf) =
+ GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
}
}
if (src->touch) {
volatile guchar *p = GST_BUFFER_DATA (buf), c;
- for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
+ for (i = 0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
c = p[i];
}
/* we're done, return the buffer */
g_assert (src->curoffset == GST_BUFFER_OFFSET (buf));
- src->curoffset += GST_BUFFER_SIZE(buf);
+ src->curoffset += GST_BUFFER_SIZE (buf);
return buf;
}
static GstBuffer *
-gst_filesrc_get_read (GstFileSrc *src)
+gst_filesrc_get_read (GstFileSrc * src)
{
GstBuffer *buf = NULL;
size_t readsize;
readsize = src->block_size;
if (src->curoffset + readsize > src->filelen) {
- if (!gst_filesrc_check_filesize (src) || src->curoffset + readsize > src->filelen) {
+ if (!gst_filesrc_check_filesize (src)
+ || src->curoffset + readsize > src->filelen) {
readsize = src->filelen - src->curoffset;
}
}
g_return_val_if_fail (buf != NULL, NULL);
ret = read (src->fd, GST_BUFFER_DATA (buf), readsize);
- if (ret < 0){
+ if (ret < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
return NULL;
}
if (ret < readsize) {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("unexpected end of file."));
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
+ ("unexpected end of file."));
return NULL;
}
}
static GstData *
-gst_filesrc_get (GstPad *pad)
+gst_filesrc_get (GstPad * pad)
{
GstFileSrc *src;
src->seek_happened = FALSE;
GST_DEBUG_OBJECT (src, "sending discont");
- event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
+ event =
+ gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
+ NULL);
return GST_DATA (event);
}
g_assert (src->curoffset <= src->filelen);
if (src->curoffset == src->filelen) {
if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) {
- GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT,
- src->curoffset, src->filelen);
+ GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
+ src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
}
- if (src->using_mmap){
+ if (src->using_mmap) {
return GST_DATA (gst_filesrc_get_mmap (src));
- }else{
+ } else {
return GST_DATA (gst_filesrc_get_read (src));
}
}
/* TRUE if the filesize of the file was updated */
static gboolean
-gst_filesrc_check_filesize (GstFileSrc *src)
+gst_filesrc_check_filesize (GstFileSrc * src)
{
struct stat stat_results;
-
- g_return_val_if_fail (GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
- fstat(src->fd, &stat_results);
- GST_DEBUG_OBJECT (src, "checked filesize on %s (was %"G_GUINT64_FORMAT", is %"G_GUINT64_FORMAT")",
- src->filename, src->filelen, (guint64) stat_results.st_size);
+ g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE);
+
+ fstat (src->fd, &stat_results);
+ GST_DEBUG_OBJECT (src,
+ "checked filesize on %s (was %" G_GUINT64_FORMAT ", is %" G_GUINT64_FORMAT
+ ")", src->filename, src->filelen, (guint64) stat_results.st_size);
if (src->filelen == (guint64) stat_results.st_size)
return FALSE;
src->filelen = stat_results.st_size;
return TRUE;
}
+
/* open the file and mmap it, necessary to go to READY state */
static gboolean
-gst_filesrc_open_file (GstFileSrc *src)
+gst_filesrc_open_file (GstFileSrc * src)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE);
- if (src->filename == NULL || src->filename[0] == '\0')
- {
+ if (src->filename == NULL || src->filename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
- (_("No file name specified for reading.")), (NULL));
+ (_("No file name specified for reading.")), (NULL));
return FALSE;
}
- GST_INFO_OBJECT (src, "opening file %s",src->filename);
+ GST_INFO_OBJECT (src, "opening file %s", src->filename);
/* open the file */
src->fd = open (src->filename, O_RDONLY);
- if (src->fd < 0)
- {
+ if (src->fd < 0) {
if (errno == ENOENT)
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL));
else
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open file \"%s\" for reading."), src->filename),
+ GST_ERROR_SYSTEM);
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
struct stat stat_results;
- fstat(src->fd, &stat_results);
+ fstat (src->fd, &stat_results);
- if (!S_ISREG(stat_results.st_mode)) {
+ if (!S_ISREG (stat_results.st_mode)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("File \"%s\" isn't a regular file."), src->filename),
- (NULL));
- close(src->fd);
+ (_("File \"%s\" isn't a regular file."), src->filename), (NULL));
+ close (src->fd);
return FALSE;
}
-
+
/* find the file length */
src->filelen = stat_results.st_size;
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
if (src->mapbuf == NULL) {
src->using_mmap = FALSE;
- }else{
+ } else {
src->using_mmap = TRUE;
}
/* unmap and close the file */
static void
-gst_filesrc_close_file (GstFileSrc *src)
+gst_filesrc_close_file (GstFileSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN));
static GstElementStateReturn
-gst_filesrc_change_state (GstElement *element)
+gst_filesrc_change_state (GstElement * element)
{
- GstFileSrc *src = GST_FILESRC(element);
+ GstFileSrc *src = GST_FILESRC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) {
- if (!gst_filesrc_open_file (GST_FILESRC (element)))
- return GST_STATE_FAILURE;
+ if (!gst_filesrc_open_file (GST_FILESRC (element)))
+ return GST_STATE_FAILURE;
}
break;
case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN))
- gst_filesrc_close_file (GST_FILESRC (element));
+ gst_filesrc_close_file (GST_FILESRC (element));
src->seek_happened = TRUE;
break;
default:
}
static gboolean
-gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_BYTES:
- *value = src->curoffset;
- break;
+ *value = src->curoffset;
+ break;
case GST_FORMAT_PERCENT:
if (src->filelen == 0)
return FALSE;
- *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
- break;
- default:
+ *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
+ break;
+ default:
return FALSE;
}
break;
}
static gboolean
-gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
+gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
{
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
offset = GST_EVENT_SEEK_OFFSET (event);
switch (GST_EVENT_SEEK_METHOD (event)) {
- case GST_SEEK_METHOD_SET:
- if (offset > src->filelen && (!gst_filesrc_check_filesize (src) || offset > src->filelen)) {
- goto error;
+ case GST_SEEK_METHOD_SET:
+ if (offset > src->filelen && (!gst_filesrc_check_filesize (src)
+ || offset > src->filelen)) {
+ goto error;
}
- src->curoffset = offset;
- GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset = offset;
+ GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
- case GST_SEEK_METHOD_CUR:
- if (offset + src->curoffset > src->filelen)
- if (!gst_filesrc_check_filesize (src) || offset + src->curoffset > src->filelen)
+ case GST_SEEK_METHOD_CUR:
+ if (offset + src->curoffset > src->filelen)
+ if (!gst_filesrc_check_filesize (src)
+ || offset + src->curoffset > src->filelen)
goto error;
- src->curoffset += offset;
- GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset += offset;
+ GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
- case GST_SEEK_METHOD_END:
- if (ABS (offset) > src->filelen) {
- if (!gst_filesrc_check_filesize (src) || ABS (offset) > src->filelen)
+ case GST_SEEK_METHOD_END:
+ if (ABS (offset) > src->filelen) {
+ if (!gst_filesrc_check_filesize (src)
+ || ABS (offset) > src->filelen)
goto error;
goto error;
}
- src->curoffset = src->filelen - ABS (offset);
- GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset);
+ src->curoffset = src->filelen - ABS (offset);
+ GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT,
+ src->curoffset);
break;
default:
- goto error;
+ goto error;
break;
}
src->seek_happened = TRUE;
- src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH;
+ src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
break;
}
case GST_EVENT_SIZE:
goto error;
}
src->block_size = GST_EVENT_SIZE_VALUE (event);
- g_object_notify (G_OBJECT (src), "blocksize");
+ g_object_notify (G_OBJECT (src), "blocksize");
break;
case GST_EVENT_FLUSH:
src->need_flush = TRUE;
return GST_URI_SRC;
}
static gchar **
-gst_filesrc_uri_get_protocols(void)
+gst_filesrc_uri_get_protocols (void)
{
- static gchar *protocols[] = {"file", NULL};
+ static gchar *protocols[] = { "file", NULL };
return protocols;
}
static const gchar *
-gst_filesrc_uri_get_uri (GstURIHandler *handler)
+gst_filesrc_uri_get_uri (GstURIHandler * handler)
{
GstFileSrc *src = GST_FILESRC (handler);
-
+
return src->uri;
}
+
static gboolean
-gst_filesrc_uri_set_uri (GstURIHandler *handler, const gchar *uri)
+gst_filesrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
{
gchar *protocol, *location;
gboolean ret;
#include <sys/types.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_FILESRC \
(gst_filesrc_get_type())
#define GST_FILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FILESRC,GstFileSrc))
#define GST_FILESRC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass))
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass))
#define GST_IS_FILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESRC))
#define GST_IS_FILESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESRC))
-
-typedef enum {
- GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+{
+ GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
GST_FILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSrcFlags;
typedef struct _GstFileSrc GstFileSrc;
typedef struct _GstFileSrcClass GstFileSrcClass;
-struct _GstFileSrc {
+struct _GstFileSrc
+{
GstElement element;
GstPad *srcpad;
- guint pagesize; /* system page size*/
-
- gchar *filename; /* filename */
- gchar *uri; /* caching the URI */
- gint fd; /* open file descriptor*/
- off_t filelen; /* what's the file length?*/
+ guint pagesize; /* system page size */
- off_t curoffset; /* current offset in file*/
- off_t block_size; /* bytes per read */
- gboolean touch; /* whether to touch every page */
+ gchar *filename; /* filename */
+ gchar *uri; /* caching the URI */
+ gint fd; /* open file descriptor */
+ off_t filelen; /* what's the file length? */
+
+ off_t curoffset; /* current offset in file */
+ off_t block_size; /* bytes per read */
+ gboolean touch; /* whether to touch every page */
gboolean using_mmap;
GstBuffer *mapbuf;
gboolean need_flush;
};
-struct _GstFileSrcClass {
+struct _GstFileSrcClass
+{
GstElementClass parent_class;
};
-GType gst_filesrc_get_type(void);
+GType gst_filesrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_FILESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_identity_debug);
#define GST_CAT_DEFAULT gst_identity_debug
-GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS (
- "Identity",
- "Generic",
- "Pass data without modification",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ("Identity",
+ "Generic",
+ "Pass data without modification",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Identity signals and args */
-enum {
+enum
+{
SIGNAL_HANDOFF,
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOOP_BASED,
ARG_SLEEP_TIME,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element");
-GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_identity_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_identity_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_identity_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_identity_chain (GstPad *pad, GstData *_data);
+static void gst_identity_chain (GstPad * pad, GstData * _data);
static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
gst_identity_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_identity_details);
}
-static void
-gst_identity_class_init (GstIdentityClass *klass)
+static void
+gst_identity_class_init (GstIdentityClass * klass)
{
GObjectClass *gobject_class;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
- g_param_spec_boolean ("loop-based", "Loop-based",
- "Set to TRUE to use loop-based rather than chain-based scheduling",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("loop-based", "Loop-based",
+ "Set to TRUE to use loop-based rather than chain-based scheduling",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME,
- g_param_spec_uint ("sleep-time", "Sleep time", "Microseconds to sleep between processing",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("sleep-time", "Sleep time",
+ "Microseconds to sleep between processing", 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE,
- g_param_spec_uint ("duplicate", "Duplicate Buffers", "Push the buffers N times",
- 0, G_MAXUINT, 1, G_PARAM_READWRITE));
+ g_param_spec_uint ("duplicate", "Duplicate Buffers",
+ "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
- g_param_spec_int ("error_after", "Error After", "Error after N buffers",
- G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_param_spec_int ("error_after", "Error After", "Error after N buffers",
+ G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
- g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped",
- 0.0, 1.0, 0.0, G_PARAM_READWRITE));
+ g_param_spec_float ("drop_probability", "Drop Probability",
+ "The Probability a buffer is dropped", 0.0, 1.0, 0.0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "last-message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message", "last-message", NULL,
+ G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
- g_param_spec_boolean("dump", "Dump", "Dump buffer contents",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE,
+ G_PARAM_READWRITE));
gst_identity_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
- gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- GST_TYPE_BUFFER);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
+ gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
-static void
-gst_identity_init (GstIdentity *identity)
+static void
+gst_identity_init (GstIdentity * identity)
{
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
- gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
+ gst_pad_set_chain_function (identity->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_link_function (identity->sinkpad, gst_pad_proxy_pad_link);
gst_pad_set_getcaps_function (identity->sinkpad, gst_pad_proxy_getcaps);
-
+
identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
gst_pad_set_link_function (identity->srcpad, gst_pad_proxy_pad_link);
identity->srccaps = NULL;
}
-static void
-gst_identity_chain (GstPad *pad, GstData *_data)
+static void
+gst_identity_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstIdentity *identity;
if (identity->error_after == 0) {
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (identity, CORE, FAILED,
- (_("Failed after iterations as requested.")),
- (NULL));
+ (_("Failed after iterations as requested.")), (NULL));
return;
}
}
if (identity->drop_probability > 0.0) {
- if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) {
+ if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
if (identity->last_message != NULL) {
g_free (identity->last_message);
}
- identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
- G_GINT64_FORMAT ")",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ identity->last_message =
+ g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
+ G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message");
gst_buffer_unref (buf);
return;
for (i = identity->duplicate; i; i--) {
if (!identity->silent) {
g_free (identity->last_message);
- identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
- G_GINT64_FORMAT ")",
- GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
+ identity->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
+ G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message");
}
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
- buf);
+ buf);
- if (i>1)
+ if (i > 1)
gst_buffer_ref (buf);
gst_pad_push (identity->srcpad, GST_DATA (buf));
}
}
-static void
-gst_identity_loop (GstElement *element)
+static void
+gst_identity_loop (GstElement * element)
{
GstIdentity *identity;
GstBuffer *buf;
g_return_if_fail (GST_IS_IDENTITY (element));
identity = GST_IDENTITY (element);
-
+
buf = GST_BUFFER (gst_pad_pull (identity->sinkpad));
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
if (GST_EVENT_IS_INTERRUPT (event)) {
gst_event_unref (event);
- }
- else {
+ } else {
gst_pad_event_default (identity->sinkpad, event);
}
- }
- else {
+ } else {
gst_identity_chain (identity->sinkpad, GST_DATA (buf));
}
}
-static void
-gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_identity_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstIdentity *identity;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_IDENTITY (object));
-
+
identity = GST_IDENTITY (object);
switch (prop_id) {
case ARG_LOOP_BASED:
identity->loop_based = g_value_get_boolean (value);
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);
+ 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;
case ARG_SLEEP_TIME:
}
}
-static void gst_identity_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstIdentity *identity;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_IDENTITY (object));
-
+
identity = GST_IDENTITY (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_IDENTITY \
(gst_identity_get_type())
#define GST_IDENTITY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IDENTITY))
#define GST_IS_IDENTITY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY))
-
typedef struct _GstIdentity GstIdentity;
typedef struct _GstIdentityClass GstIdentityClass;
-struct _GstIdentity {
- GstElement element;
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- gboolean loop_based;
- guint duplicate;
- gint error_after;
- gfloat drop_probability;
- guint sleep_time;
- gboolean silent;
- gboolean dump;
- gchar *last_message;
- GstCaps *srccaps;
+struct _GstIdentity
+{
+ GstElement element;
+
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ gboolean loop_based;
+ guint duplicate;
+ gint error_after;
+ gfloat drop_probability;
+ guint sleep_time;
+ gboolean silent;
+ gboolean dump;
+ gchar *last_message;
+ GstCaps *srccaps;
};
-struct _GstIdentityClass {
+struct _GstIdentityClass
+{
GstElementClass parent_class;
/* signals */
- void (*handoff) (GstElement *element, GstBuffer *buf);
+ void (*handoff) (GstElement * element, GstBuffer * buf);
};
-GType gst_identity_get_type(void);
+GType gst_identity_get_type (void);
G_END_DECLS
-
#endif /* __GST_IDENTITY_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_md5sink_debug);
#define GST_CAT_DEFAULT gst_md5sink_debug
-GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS (
- "MD5 Sink",
- "Sink",
- "compute MD5 for incoming data",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ("MD5 Sink",
+ "Sink",
+ "compute MD5 for incoming data",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* MD5Sink signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MD5,
/* FILL ME */
};
-GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_md5sink_debug, "md5sink", 0, "md5sink element");
-GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
/* GObject stuff */
/*static void gst_md5sink_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);*/
-static void gst_md5sink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_md5sink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_md5sink_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn gst_md5sink_change_state (GstElement *element);
+static void gst_md5sink_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_md5sink_change_state (GstElement * element);
/* MD5 stuff */
-static void md5_init_ctx (GstMD5Sink *ctx);
-static gpointer md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf);
-static gpointer md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf);
-static void md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx);
-static void md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx);
+static void md5_init_ctx (GstMD5Sink * ctx);
+static gpointer md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf);
+static gpointer md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf);
+static void md5_process_bytes (const void *buffer, size_t len,
+ GstMD5Sink * ctx);
+static void md5_process_block (const void *buffer, size_t len,
+ GstMD5Sink * ctx);
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
-static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
/* MD5 functions */
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
static void
-md5_init_ctx (GstMD5Sink *ctx)
+md5_init_ctx (GstMD5Sink * ctx)
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
}
+
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
static gpointer
-md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf)
+md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf)
{
/* Take yet unprocessed bytes into account. */
guint32 bytes = ctx->buflen;
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(guint32 *) &ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3);
- *(guint32 *) &ctx->buffer[bytes + pad + 4] = GUINT32_TO_LE ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ *(guint32 *) & ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3);
+ *(guint32 *) & ctx->buffer[bytes + pad + 4] =
+ GUINT32_TO_LE ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
/* Process last bytes. */
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
return md5_read_ctx (ctx, resbuf);
}
+
/* Put result from CTX in first 16 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
static gpointer
-md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf)
+md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf)
{
((guint32 *) resbuf)[0] = GUINT32_TO_LE (ctx->A);
((guint32 *) resbuf)[1] = GUINT32_TO_LE (ctx->B);
}
static void
-md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx)
+md5_process_bytes (const void *buffer, size_t len, GstMD5Sink * ctx)
{
/*const void aligned_buffer = buffer; */
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
- if (ctx->buflen != 0)
- {
- size_t left_over = ctx->buflen;
- size_t add = 128 - left_over > len ? len : 128 - left_over;
-
- /* Only put full words in the buffer. */
- /* Forcing alignment here appears to be only an optimization.
- * The glibc source uses __alignof__, which seems to be a
- * gratuitous usage of a GCC extension, when sizeof() will
- * work fine. (And don't question the sanity of using
- * sizeof(guint32) instead of 4. */
- /* add -= add % __alignof__ (guint32); */
- add -= add % sizeof(guint32);
-
- memcpy (&ctx->buffer[left_over], buffer, add);
- ctx->buflen += add;
-
- if (ctx->buflen > 64)
- {
- md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
-
- ctx->buflen &= 63;
- /* The regions in the following copy operation cannot overlap. */
- memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
- ctx->buflen);
- }
-
- buffer = (const char *) buffer + add;
- len -= add;
+ if (ctx->buflen != 0) {
+ size_t left_over = ctx->buflen;
+ size_t add = 128 - left_over > len ? len : 128 - left_over;
+
+ /* Only put full words in the buffer. */
+ /* Forcing alignment here appears to be only an optimization.
+ * The glibc source uses __alignof__, which seems to be a
+ * gratuitous usage of a GCC extension, when sizeof() will
+ * work fine. (And don't question the sanity of using
+ * sizeof(guint32) instead of 4. */
+ /* add -= add % __alignof__ (guint32); */
+ add -= add % sizeof (guint32);
+
+ memcpy (&ctx->buffer[left_over], buffer, add);
+ ctx->buflen += add;
+
+ if (ctx->buflen > 64) {
+ md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen);
}
+ buffer = (const char *) buffer + add;
+ len -= add;
+ }
+
/* Process available complete blocks. */
- if (len > 64)
- {
- md5_process_block (buffer, len & ~63, ctx);
- buffer = (const char *) buffer + (len & ~63);
- len &= 63;
- }
+ if (len > 64) {
+ md5_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
/* Move remaining bytes in internal buffer. */
- if (len > 0)
- {
- size_t left_over = ctx->buflen;
-
- memcpy (&ctx->buffer[left_over], buffer, len);
- left_over += len;
- if (left_over >= 64)
- {
- md5_process_block (ctx->buffer, 64, ctx);
- left_over -= 64;
- memcpy (ctx->buffer, &ctx->buffer[64], left_over);
- }
- ctx->buflen = left_over;
+ if (len > 0) {
+ size_t left_over = ctx->buflen;
+
+ memcpy (&ctx->buffer[left_over], buffer, len);
+ left_over += len;
+ if (left_over >= 64) {
+ md5_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[64], left_over);
}
+ ctx->buflen = left_over;
+ }
}
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
static void
-md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx)
+md5_process_block (const void *buffer, size_t len, GstMD5Sink * ctx)
{
guint32 correct_words[16];
const guint32 *words = buffer;
/* Process all bytes in the buffer with 64 bytes in each round of
the loop. */
- while (words < endp)
- {
- guint32 *cwp = correct_words;
- guint32 A_save = A;
- guint32 B_save = B;
- guint32 C_save = C;
- guint32 D_save = D;
-
- /* First round: using the given function, the context and a constant
- the next context is computed. Because the algorithms processing
- unit is a 32-bit word and it is determined to work on words in
- little endian byte order we perhaps have to change the byte order
- before the computation. To reduce the work for the next steps
- we store the swapped words in the array CORRECT_WORDS. */
+ while (words < endp) {
+ guint32 *cwp = correct_words;
+ guint32 A_save = A;
+ guint32 B_save = B;
+ guint32 C_save = C;
+ guint32 D_save = D;
+
+ /* First round: using the given function, the context and a constant
+ the next context is computed. Because the algorithms processing
+ unit is a 32-bit word and it is determined to work on words in
+ little endian byte order we perhaps have to change the byte order
+ before the computation. To reduce the work for the next steps
+ we store the swapped words in the array CORRECT_WORDS. */
#define OP(a, b, c, d, s, T) \
do \
} \
while (0)
- /* It is unfortunate that C does not provide an operator for
- cyclic rotation. Hope the C compiler is smart enough. */
+ /* It is unfortunate that C does not provide an operator for
+ cyclic rotation. Hope the C compiler is smart enough. */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
- /* Before we start, one word to the strange constants.
- They are defined in RFC 1321 as
-
- T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
- */
-
- /* Round 1. */
- OP (A, B, C, D, 7, 0xd76aa478);
- OP (D, A, B, C, 12, 0xe8c7b756);
- OP (C, D, A, B, 17, 0x242070db);
- OP (B, C, D, A, 22, 0xc1bdceee);
- OP (A, B, C, D, 7, 0xf57c0faf);
- OP (D, A, B, C, 12, 0x4787c62a);
- OP (C, D, A, B, 17, 0xa8304613);
- OP (B, C, D, A, 22, 0xfd469501);
- OP (A, B, C, D, 7, 0x698098d8);
- OP (D, A, B, C, 12, 0x8b44f7af);
- OP (C, D, A, B, 17, 0xffff5bb1);
- OP (B, C, D, A, 22, 0x895cd7be);
- OP (A, B, C, D, 7, 0x6b901122);
- OP (D, A, B, C, 12, 0xfd987193);
- OP (C, D, A, B, 17, 0xa679438e);
- OP (B, C, D, A, 22, 0x49b40821);
-
- /* For the second to fourth round we have the possibly swapped words
- in CORRECT_WORDS. Redefine the macro to take an additional first
- argument specifying the function to use. */
+ /* Before we start, one word to the strange constants.
+ They are defined in RFC 1321 as
+
+ T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
+ */
+
+ /* Round 1. */
+ OP (A, B, C, D, 7, 0xd76aa478);
+ OP (D, A, B, C, 12, 0xe8c7b756);
+ OP (C, D, A, B, 17, 0x242070db);
+ OP (B, C, D, A, 22, 0xc1bdceee);
+ OP (A, B, C, D, 7, 0xf57c0faf);
+ OP (D, A, B, C, 12, 0x4787c62a);
+ OP (C, D, A, B, 17, 0xa8304613);
+ OP (B, C, D, A, 22, 0xfd469501);
+ OP (A, B, C, D, 7, 0x698098d8);
+ OP (D, A, B, C, 12, 0x8b44f7af);
+ OP (C, D, A, B, 17, 0xffff5bb1);
+ OP (B, C, D, A, 22, 0x895cd7be);
+ OP (A, B, C, D, 7, 0x6b901122);
+ OP (D, A, B, C, 12, 0xfd987193);
+ OP (C, D, A, B, 17, 0xa679438e);
+ OP (B, C, D, A, 22, 0x49b40821);
+
+ /* For the second to fourth round we have the possibly swapped words
+ in CORRECT_WORDS. Redefine the macro to take an additional first
+ argument specifying the function to use. */
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
} \
while (0)
- /* Round 2. */
- OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
- OP (FG, D, A, B, C, 6, 9, 0xc040b340);
- OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
- OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
- OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
- OP (FG, D, A, B, C, 10, 9, 0x02441453);
- OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
- OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
- OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
- OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
- OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
- OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
- OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
- OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
- OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
- OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
-
- /* Round 3. */
- OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
- OP (FH, D, A, B, C, 8, 11, 0x8771f681);
- OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
- OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
- OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
- OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
- OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
- OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
- OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
- OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
- OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
- OP (FH, B, C, D, A, 6, 23, 0x04881d05);
- OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
- OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
- OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
- OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
-
- /* Round 4. */
- OP (FI, A, B, C, D, 0, 6, 0xf4292244);
- OP (FI, D, A, B, C, 7, 10, 0x432aff97);
- OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
- OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
- OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
- OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
- OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
- OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
- OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
- OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
- OP (FI, C, D, A, B, 6, 15, 0xa3014314);
- OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
- OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
- OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
- OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
- OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
-
- /* Add the starting values of the context. */
- A += A_save;
- B += B_save;
- C += C_save;
- D += D_save;
- }
+ /* Round 2. */
+ OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, 0xc040b340);
+ OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
+ OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, 0x02441453);
+ OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
+ OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
+ OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
+
+ /* Round 3. */
+ OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, 0x8771f681);
+ OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
+ OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
+ OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
+ OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
+ OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
+ OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
+ OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
+ OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+
+ /* Round 4. */
+ OP (FI, A, B, C, D, 0, 6, 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, 0x432aff97);
+ OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
+ OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
+ OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
+ OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
+ OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
+ OP (FI, C, D, A, B, 6, 15, 0xa3014314);
+ OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
+ OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
+ OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
+ OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+
+ /* Add the starting values of the context. */
+ A += A_save;
+ B += B_save;
+ C += C_save;
+ D += D_save;
+ }
/* Put checksum in context given as argument. */
ctx->A = A;
gst_md5sink_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_md5sink_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&md5_sink_template));
}
static void
-gst_md5sink_class_init (GstMD5SinkClass *klass)
+gst_md5sink_class_init (GstMD5SinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_md5sink_get_property);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5,
- g_param_spec_string ("md5", "md5", "current value of the md5 sum",
- "", G_PARAM_READABLE));
+ g_param_spec_string ("md5", "md5", "current value of the md5 sum",
+ "", G_PARAM_READABLE));
- gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_md5sink_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state);
}
-static void
-gst_md5sink_init (GstMD5Sink *md5sink)
+static void
+gst_md5sink_init (GstMD5Sink * md5sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (gst_static_pad_template_get (
- &md5_sink_template), "sink");
+
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&md5_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (md5sink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain));
}
static GstElementStateReturn
-gst_md5sink_change_state (GstElement *element)
+gst_md5sink_change_state (GstElement * element)
{
GstMD5Sink *sink;
-
+
/* element check */
sink = GST_MD5SINK (element);
g_return_val_if_fail (GST_IS_MD5SINK (sink), GST_STATE_FAILURE);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
md5_init_ctx (sink);
default:
break;
}
-
+
if ((GST_ELEMENT_CLASS (parent_class)->change_state))
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
-static void
-gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMD5Sink *sink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_MD5SINK (object));
-
+
sink = GST_MD5SINK (object);
-
+
switch (prop_id) {
case ARG_MD5:
- {
- /* you could actually get a value for the current md5.
- * This is currently disabled.
- * md5_read_ctx (sink, sink->md5); */
- /* md5 is a guchar[16] */
- int i;
- guchar *md5string = g_malloc0 (33);
-
- for (i = 0; i < 16; ++i)
- sprintf (md5string + i * 2, "%02x", sink->md5[i]);
- g_value_set_string (value, md5string);
- g_free (md5string);
- }
+ {
+ /* you could actually get a value for the current md5.
+ * This is currently disabled.
+ * md5_read_ctx (sink, sink->md5); */
+ /* md5 is a guchar[16] */
+ int i;
+ guchar *md5string = g_malloc0 (33);
+
+ for (i = 0; i < 16; ++i)
+ sprintf (md5string + i * 2, "%02x", sink->md5[i]);
+ g_value_set_string (value, md5string);
+ g_free (md5string);
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
-static void
-gst_md5sink_chain (GstPad *pad, GstData *_data)
+static void
+gst_md5sink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMD5Sink *md5sink;
md5sink = GST_MD5SINK (gst_pad_get_parent (pad));
- if (GST_IS_BUFFER (buf))
- {
+ if (GST_IS_BUFFER (buf)) {
md5_process_bytes (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), md5sink);
}
-
+
gst_buffer_unref (buf);
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_MD5SINK \
(gst_md5sink_get_type())
#define GST_MD5SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MD5SINK))
#define GST_IS_MD5SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MD5SINK))
-
typedef struct _GstMD5Sink GstMD5Sink;
typedef struct _GstMD5SinkClass GstMD5SinkClass;
-struct _GstMD5Sink {
+struct _GstMD5Sink
+{
GstElement element;
/* md5 information */
guint32 total[2];
guint32 buflen;
gchar buffer[128];
-
+
/* latest md5 */
guchar md5[16];
-
+
};
-struct _GstMD5SinkClass {
+struct _GstMD5SinkClass
+{
GstElementClass parent_class;
};
-GType gst_md5sink_get_type (void);
+GType gst_md5sink_get_type (void);
-gboolean gst_md5sink_factory_init (GstElementFactory *factory);
+gboolean gst_md5sink_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_MD5SINK_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_multifilesrc_debug);
#define GST_CAT_DEFAULT gst_multifilesrc_debug
-GstElementDetails gst_multifilesrc_details = GST_ELEMENT_DETAILS (
- "Multi File Source",
- "Source/File",
- "Read from multiple files in order",
- "Dominic Ludlam <dom@openfx.org>"
-);
+GstElementDetails gst_multifilesrc_details =
+GST_ELEMENT_DETAILS ("Multi File Source",
+ "Source/File",
+ "Read from multiple files in order",
+ "Dominic Ludlam <dom@openfx.org>");
/* FileSrc signals and args */
-enum {
+enum
+{
NEW_FILE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATIONS
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_multifilesrc_debug, "multifilesrc", 0, "multifilesrc element");
-GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_multifilesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_multifilesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstData *gst_multifilesrc_get (GstPad * pad);
-static GstData * gst_multifilesrc_get (GstPad *pad);
/*static GstBuffer * gst_multifilesrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
-static GstElementStateReturn gst_multifilesrc_change_state (GstElement *element);
+static GstElementStateReturn gst_multifilesrc_change_state (GstElement *
+ element);
-static gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad);
-static void gst_multifilesrc_close_file (GstMultiFileSrc *src);
+static gboolean gst_multifilesrc_open_file (GstMultiFileSrc * src,
+ GstPad * srcpad);
+static void gst_multifilesrc_close_file (GstMultiFileSrc * src);
static guint gst_multifilesrc_signals[LAST_SIGNAL] = { 0 };
gst_multifilesrc_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_multifilesrc_details);
}
static void
-gst_multifilesrc_class_init (GstMultiFileSrcClass *klass)
+gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gst_multifilesrc_signals[NEW_FILE] =
- g_signal_new ("new-file", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
- g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ g_signal_new ("new-file", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
- g_param_spec_pointer("locations","locations","locations",
- G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property;
}
static void
-gst_multifilesrc_init (GstMultiFileSrc *multifilesrc)
+gst_multifilesrc_init (GstMultiFileSrc * multifilesrc)
{
/* GST_FLAG_SET (filesrc, GST_SRC_); */
multifilesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
- gst_pad_set_get_function (multifilesrc->srcpad,gst_multifilesrc_get);
+ gst_pad_set_get_function (multifilesrc->srcpad, gst_multifilesrc_get);
/* gst_pad_set_getregion_function (multifilesrc->srcpad,gst_multifilesrc_get_region); */
gst_element_add_pad (GST_ELEMENT (multifilesrc), multifilesrc->srcpad);
}
static void
-gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_multifilesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMultiFileSrc *src;
/* clear the filename if we get a NULL */
if (g_value_get_pointer (value) == NULL) {
- gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
- src->listptr = NULL;
- /* otherwise set the new filenames */
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ src->listptr = NULL;
+ /* otherwise set the new filenames */
} else {
- src->listptr = g_value_get_pointer (value);
+ src->listptr = g_value_get_pointer (value);
}
break;
default:
}
static void
-gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMultiFileSrc *src;
* Push a new buffer from the filesrc at the current offset.
*/
static GstData *
-gst_multifilesrc_get (GstPad *pad)
+gst_multifilesrc_get (GstPad * pad)
{
GstMultiFileSrc *src;
GstBuffer *buf;
src = GST_MULTIFILESRC (gst_pad_get_parent (pad));
if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN))
- gst_multifilesrc_close_file(src);
+ gst_multifilesrc_close_file (src);
if (!src->listptr) {
return GST_DATA (gst_event_new (GST_EVENT_EOS));
src->currentfilename = (gchar *) list->data;
src->listptr = src->listptr->next;
- if (!gst_multifilesrc_open_file(src, pad))
- return NULL;
+ if (!gst_multifilesrc_open_file (src, pad))
+ return NULL;
- /* emitted after the open, as the user may free the list and string from here*/
- g_signal_emit(G_OBJECT(src), gst_multifilesrc_signals[NEW_FILE], 0, list);
+ /* emitted after the open, as the user may free the list and string from here */
+ g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
}
/* open the file and mmap it, necessary to go to READY state */
-static
-gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad)
+static gboolean
+gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN), FALSE);
- if (src->currentfilename == NULL || src->currentfilename[0] == '\0')
- {
+ if (src->currentfilename == NULL || src->currentfilename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
- (_("No file name specified for reading.")), (NULL));
+ (_("No file name specified for reading.")), (NULL));
return FALSE;
}
/* open the file */
src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->currentfilename),
- GST_ERROR_SYSTEM);
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open file \"%s\" for reading."), src->currentfilename),
+ GST_ERROR_SYSTEM);
return FALSE;
} else {
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
+ madvise (src->map, src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
- ("mmap call failed."));
+ ("mmap call failed."));
return FALSE;
}
GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN);
/* unmap and close the file */
static void
-gst_multifilesrc_close_file (GstMultiFileSrc *src)
+gst_multifilesrc_close_file (GstMultiFileSrc * src)
{
g_return_if_fail (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN));
}
static GstElementStateReturn
-gst_multifilesrc_change_state (GstElement *element)
+gst_multifilesrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_MULTIFILESRC (element), GST_STATE_FAILURE);
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_MULTIFILESRC \
(gst_multifilesrc_get_type())
#define GST_MULTIFILESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFILESRC))
#define GST_IS_MULTIFILESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFILESRC))
+ typedef enum
+{
+ GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
-typedef enum {
- GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstMultiFileSrcFlags;
typedef struct _GstMultiFileSrc GstMultiFileSrc;
typedef struct _GstMultiFileSrcClass GstMultiFileSrcClass;
-struct _GstMultiFileSrc {
+struct _GstMultiFileSrc
+{
GstElement element;
/* pads */
GstPad *srcpad;
/* current file details */
- gchar *currentfilename;
+ gchar *currentfilename;
GSList *listptr;
/* mapping parameters */
gint fd;
- gulong size; /* how long is the file? */
- guchar *map; /* where the file is mapped to */
+ gulong size; /* how long is the file? */
+ guchar *map; /* where the file is mapped to */
gboolean new_seek;
};
-struct _GstMultiFileSrcClass {
+struct _GstMultiFileSrcClass
+{
GstElementClass parent_class;
- void (*new_file) (GstMultiFileSrc *multifilesrc, gchar *newfilename);
+ void (*new_file) (GstMultiFileSrc * multifilesrc, gchar * newfilename);
};
-GType gst_multifilesrc_get_type(void);
+GType gst_multifilesrc_get_type (void);
G_END_DECLS
-
#endif /* __GST_MULTIFILESRC_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_pipefilter_debug);
#define GST_CAT_DEFAULT gst_pipefilter_debug
-GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS (
- "Pipefilter",
- "Filter",
- "Interoperate with an external program using stdin and stdout",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ("Pipefilter",
+ "Filter",
+ "Interoperate with an external program using stdin and stdout",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* Pipefilter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_COMMAND
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_pipefilter_debug, "pipefilter", 0, "pipefilter element");
-GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_pipefilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_pipefilter_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstData* gst_pipefilter_get (GstPad *pad);
-static void gst_pipefilter_chain (GstPad *pad, GstData *_data);
-static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event);
+static GstData *gst_pipefilter_get (GstPad * pad);
+static void gst_pipefilter_chain (GstPad * pad, GstData * _data);
+static gboolean gst_pipefilter_handle_event (GstPad * pad, GstEvent * event);
-static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
+static GstElementStateReturn gst_pipefilter_change_state (GstElement * element);
static void
gst_pipefilter_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_pipefilter_details);
}
-static void
-gst_pipefilter_class_init (GstPipefilterClass *klass)
+static void
+gst_pipefilter_class_init (GstPipefilterClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- gobject_class->set_property = gst_pipefilter_set_property;
+ gobject_class->set_property = gst_pipefilter_set_property;
gobject_class->get_property = gst_pipefilter_get_property;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
- g_param_spec_string("command","command","command",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_pipefilter_change_state;
}
static void
-gst_pipefilter_init (GstPipefilter *pipefilter)
+gst_pipefilter_init (GstPipefilter * pipefilter)
{
GST_FLAG_SET (pipefilter, GST_ELEMENT_DECOUPLED);
}
static gboolean
-gst_pipefilter_handle_event (GstPad *pad, GstEvent *event)
+gst_pipefilter_handle_event (GstPad * pad, GstEvent * event)
{
GstPipefilter *pipefilter;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
if (close (pipefilter->fdin[1]) < 0)
- perror("close");
+ perror ("close");
if (close (pipefilter->fdout[0]) < 0)
- perror("close");
+ perror ("close");
break;
default:
break;
return TRUE;
}
-static GstData*
-gst_pipefilter_get (GstPad *pad)
+static GstData *
+gst_pipefilter_get (GstPad * pad)
{
GstPipefilter *pipefilter;
GstBuffer *newbuf;
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
- newbuf = gst_buffer_new();
- g_return_val_if_fail(newbuf, NULL);
+ newbuf = gst_buffer_new ();
+ g_return_val_if_fail (newbuf, NULL);
/* allocate the space for the buffer data */
- GST_BUFFER_DATA(newbuf) = g_malloc(pipefilter->bytes_per_read);
- g_return_val_if_fail(GST_BUFFER_DATA(newbuf) != NULL, NULL);
+ GST_BUFFER_DATA (newbuf) = g_malloc (pipefilter->bytes_per_read);
+ g_return_val_if_fail (GST_BUFFER_DATA (newbuf) != NULL, NULL);
/* read it in from the file */
GST_DEBUG ("attemting to read %ld bytes", pipefilter->bytes_per_read);
- readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read);
+ readbytes =
+ read (pipefilter->fdout[0], GST_BUFFER_DATA (newbuf),
+ pipefilter->bytes_per_read);
GST_DEBUG ("read %ld bytes", readbytes);
if (readbytes < 0) {
GST_ELEMENT_ERROR (pipefilter, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
}
- GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset;
- GST_BUFFER_SIZE(newbuf) = readbytes;
+ GST_BUFFER_OFFSET (newbuf) = pipefilter->curoffset;
+ GST_BUFFER_SIZE (newbuf) = readbytes;
pipefilter->curoffset += readbytes;
return GST_DATA (newbuf);
}
static void
-gst_pipefilter_chain (GstPad *pad,GstData *_data)
+gst_pipefilter_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf;
GstPipefilter *pipefilter;
guchar *data;
gulong size;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
if (GST_IS_EVENT (_data)) {
gst_pipefilter_handle_event (pad, GST_EVENT (_data));
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
buf = GST_BUFFER (_data);
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
GST_DEBUG ("attemting to write %ld bytes", size);
- writebytes = write(pipefilter->fdin[1],data,size);
+ writebytes = write (pipefilter->fdin[1], data, size);
GST_DEBUG ("written %ld bytes", writebytes);
if (writebytes < 0) {
GST_ELEMENT_ERROR (pipefilter, RESOURCE, WRITE, (NULL), GST_ERROR_SYSTEM);
return;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_pipefilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstPipefilter *pipefilter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_PIPEFILTER(object));
- pipefilter = GST_PIPEFILTER(object);
+ g_return_if_fail (GST_IS_PIPEFILTER (object));
+ pipefilter = GST_PIPEFILTER (object);
switch (prop_id) {
case ARG_COMMAND:
- pipefilter->orig_command = g_strdup(g_value_get_string (value));
- pipefilter->command = g_strsplit(g_value_get_string (value), " ", 0);
+ pipefilter->orig_command = g_strdup (g_value_get_string (value));
+ pipefilter->command = g_strsplit (g_value_get_string (value), " ", 0);
break;
default:
break;
}
static void
-gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_pipefilter_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstPipefilter *pipefilter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_PIPEFILTER(object));
- pipefilter = GST_PIPEFILTER(object);
+ g_return_if_fail (GST_IS_PIPEFILTER (object));
+ pipefilter = GST_PIPEFILTER (object);
switch (prop_id) {
case ARG_COMMAND:
/* open the file, necessary to go to RUNNING state */
static gboolean
-gst_pipefilter_open_file (GstPipefilter *src)
+gst_pipefilter_open_file (GstPipefilter * src)
{
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN), FALSE);
- pipe(src->fdin);
- pipe(src->fdout);
+ pipe (src->fdin);
+ pipe (src->fdout);
- if((src->childpid = fork()) == -1)
- {
+ if ((src->childpid = fork ()) == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
- if(src->childpid == 0)
- {
- close(src->fdin[1]);
- close(src->fdout[0]);
+ if (src->childpid == 0) {
+ close (src->fdin[1]);
+ close (src->fdout[0]);
/* child */
- dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
- dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
- execvp(src->command[0], &src->command[0]);
+ dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */
+ dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
+ execvp (src->command[0], &src->command[0]);
/* will only be reached if execvp has an error */
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
return FALSE;
-
- }
- else {
- close(src->fdin[0]);
- close(src->fdout[1]);
+
+ } else {
+ close (src->fdin[0]);
+ close (src->fdout[1]);
}
-
- GST_FLAG_SET(src,GST_PIPEFILTER_OPEN);
+
+ GST_FLAG_SET (src, GST_PIPEFILTER_OPEN);
return TRUE;
}
/* close the file */
static void
-gst_pipefilter_close_file (GstPipefilter *src)
+gst_pipefilter_close_file (GstPipefilter * src)
{
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN));
/* close the file */
- close(src->fdout[0]);
- close(src->fdout[1]);
- close(src->fdin[0]);
- close(src->fdin[1]);
+ close (src->fdout[0]);
+ close (src->fdout[1]);
+ close (src->fdin[0]);
+ close (src->fdin[1]);
/* zero out a lot of our state */
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,GST_PIPEFILTER_OPEN);
+ GST_FLAG_UNSET (src, GST_PIPEFILTER_OPEN);
}
static GstElementStateReturn
-gst_pipefilter_change_state (GstElement *element)
+gst_pipefilter_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_PIPEFILTER(element), FALSE);
+ g_return_val_if_fail (GST_IS_PIPEFILTER (element), FALSE);
- /* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN))
- gst_pipefilter_close_file(GST_PIPEFILTER(element));
- /* otherwise (READY or higher) we need to open the file */
+ /* if going down into NULL state, close the file if it's open */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN))
+ gst_pipefilter_close_file (GST_PIPEFILTER (element));
+ /* otherwise (READY or higher) we need to open the file */
} else {
- if (!GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) {
- if (!gst_pipefilter_open_file(GST_PIPEFILTER(element)))
- return GST_STATE_FAILURE;
+ if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) {
+ if (!gst_pipefilter_open_file (GST_PIPEFILTER (element)))
+ return GST_STATE_FAILURE;
}
}
-
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_PIPEFILTER \
(gst_pipefilter_get_type())
#define GST_PIPEFILTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PIPEFILTER))
#define GST_IS_PIPEFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PIPEFILTER))
+ typedef enum
+{
+ GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST,
-typedef enum {
- GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstPipeFilterFlags;
typedef struct _GstPipefilter GstPipefilter;
typedef struct _GstPipefilterClass GstPipefilterClass;
-struct _GstPipefilter {
+struct _GstPipefilter
+{
GstElement element;
GstPad *sinkpad;
/* fd */
gint fdout[2];
gint fdin[2];
- pid_t childpid;
+ pid_t childpid;
- gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong curoffset; /* current offset in file */
+ gulong bytes_per_read; /* bytes per read */
- gulong seq; /* buffer sequence number */
+ gulong seq; /* buffer sequence number */
};
-struct _GstPipefilterClass {
+struct _GstPipefilterClass
+{
GstElementClass parent_class;
};
-GType gst_pipefilter_get_type(void);
+GType gst_pipefilter_get_type (void);
G_END_DECLS
-
#endif /* __GST_PIPEFILTER_H__ */
#include "gstinfo.h"
#include "gsterror.h"
-static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS (
- "Queue",
- "Generic",
- "Simple data queue",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue",
+ "Generic",
+ "Simple data queue",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Queue signals and args */
-enum {
+enum
+{
SIGNAL_UNDERRUN,
SIGNAL_RUNNING,
SIGNAL_OVERRUN,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FIXME: don't we have another way of doing this
* "Gstreamer format" (frame/byte/time) queries? */
ARG_LEAKY,
ARG_MAY_DEADLOCK,
ARG_BLOCK_TIMEOUT
- /* FILL ME */
+ /* FILL ME */
};
-typedef struct _GstQueueEventResponse {
+typedef struct _GstQueueEventResponse
+{
GstEvent *event;
gboolean ret, handled;
} GstQueueEventResponse;
-static void gst_queue_base_init (GstQueueClass *klass);
-static void gst_queue_class_init (GstQueueClass *klass);
-static void gst_queue_init (GstQueue *queue);
-static void gst_queue_dispose (GObject *object);
-
-static void gst_queue_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_queue_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gst_queue_chain (GstPad *pad,
- GstData *data);
-static GstData *gst_queue_get (GstPad *pad);
-
-static gboolean gst_queue_handle_src_event (GstPad *pad,
- GstEvent *event);
-
-static GstCaps *gst_queue_getcaps (GstPad *pad);
-static GstPadLinkReturn
- gst_queue_link (GstPad *pad,
- const GstCaps *caps);
-static void gst_queue_locked_flush (GstQueue *queue);
+static void gst_queue_base_init (GstQueueClass * klass);
+static void gst_queue_class_init (GstQueueClass * klass);
+static void gst_queue_init (GstQueue * queue);
+static void gst_queue_dispose (GObject * object);
+
+static void gst_queue_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_queue_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static void gst_queue_chain (GstPad * pad, GstData * data);
+static GstData *gst_queue_get (GstPad * pad);
+
+static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
+
+static GstCaps *gst_queue_getcaps (GstPad * pad);
+static GstPadLinkReturn gst_queue_link (GstPad * pad, const GstCaps * caps);
+static void gst_queue_locked_flush (GstQueue * queue);
+
+static GstElementStateReturn gst_queue_change_state (GstElement * element);
+static gboolean gst_queue_release_locks (GstElement * element);
-static GstElementStateReturn
- gst_queue_change_state (GstElement *element);
-static gboolean gst_queue_release_locks (GstElement *element);
-
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
static GType
{
static GType queue_leaky_type = 0;
static GEnumValue queue_leaky[] = {
- { GST_QUEUE_NO_LEAK, "0", "Not Leaky" },
- { GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream" },
- { GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream" },
- { 0, NULL, NULL },
+ {GST_QUEUE_NO_LEAK, "0", "Not Leaky"},
+ {GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream"},
+ {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"},
+ {0, NULL, NULL},
};
if (!queue_leaky_type) {
- queue_leaky_type = g_enum_register_static("GstQueueLeaky", queue_leaky);
+ queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
}
return queue_leaky_type;
}
static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
GType
-gst_queue_get_type (void)
+gst_queue_get_type (void)
{
static GType queue_type = 0;
};
queue_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstQueue", &queue_info, 0);
+ "GstQueue", &queue_info, 0);
}
return queue_type;
}
static void
-gst_queue_base_init (GstQueueClass *klass)
+gst_queue_base_init (GstQueueClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_queue_class_init (GstQueueClass *klass)
+gst_queue_class_init (GstQueueClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
/* signals */
gst_queue_signals[SIGNAL_UNDERRUN] =
- g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_queue_signals[SIGNAL_RUNNING] =
- g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_queue_signals[SIGNAL_OVERRUN] =
- g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/* properties */
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES,
- g_param_spec_uint ("current-level-bytes", "Current level (kB)",
- "Current amount of data in the queue (bytes)",
- 0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_param_spec_uint ("current-level-bytes", "Current level (kB)",
+ "Current amount of data in the queue (bytes)",
+ 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS,
- g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
- "Current number of buffers in the queue",
- 0, G_MAXUINT, 0, G_PARAM_READABLE));
+ g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
+ "Current number of buffers in the queue",
+ 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME,
- g_param_spec_uint64 ("current-level-time", "Current level (ns)",
- "Current amount of data in the queue (in ns)",
- 0, G_MAXUINT64, 0, G_PARAM_READABLE));
+ g_param_spec_uint64 ("current-level-time", "Current level (ns)",
+ "Current amount of data in the queue (in ns)",
+ 0, G_MAXUINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES,
- g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
- "Max. amount of data in the queue (bytes, 0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
+ "Max. amount of data in the queue (bytes, 0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS,
- g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
- "Max. number of buffers in the queue (0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
+ "Max. number of buffers in the queue (0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME,
- g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
- "Max. amount of data in the queue (in ns, 0=disable)",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
+ "Max. amount of data in the queue (in ns, 0=disable)",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES,
- g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
- "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
+ "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS,
- g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
- "Min. number of buffers in the queue to allow reading (0=disable)",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
+ "Min. number of buffers in the queue to allow reading (0=disable)",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME,
- g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
- "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
- 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
+ "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_LEAKY,
- g_param_spec_enum ("leaky", "Leaky",
- "Where the queue leaks, if at all",
- GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
+ g_param_spec_enum ("leaky", "Leaky",
+ "Where the queue leaks, if at all",
+ GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK,
- g_param_spec_boolean ("may_deadlock", "May Deadlock",
- "The queue may deadlock if it's full and not PLAYING",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("may_deadlock", "May Deadlock",
+ "The queue may deadlock if it's full and not PLAYING",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT,
- g_param_spec_uint64 ("block_timeout", "Timeout for Block",
- "Nanoseconds until blocked queue times out and returns filler event. "
- "Value of -1 disables timeout",
- 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
+ g_param_spec_uint64 ("block_timeout", "Timeout for Block",
+ "Nanoseconds until blocked queue times out and returns filler event. "
+ "Value of -1 disables timeout",
+ 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
/* set several parent class virtual functions */
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state);
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state);
gstelement_class->release_locks = GST_DEBUG_FUNCPTR (gst_queue_release_locks);
}
static void
-gst_queue_init (GstQueue *queue)
+gst_queue_init (GstQueue * queue)
{
/* scheduling on this kind of element is, well, interesting */
GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED);
GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE);
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
- gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain));
+ gst_pad_set_chain_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_chain));
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
- gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link));
- gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
+ gst_pad_set_link_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_link));
+ gst_pad_set_getcaps_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue_getcaps));
gst_pad_set_active (queue->sinkpad, TRUE);
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_get));
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link));
- gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps));
- gst_pad_set_event_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
+ gst_pad_set_getcaps_function (queue->srcpad,
+ GST_DEBUG_FUNCPTR (gst_queue_getcaps));
+ gst_pad_set_event_function (queue->srcpad,
+ GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
gst_pad_set_active (queue->srcpad, TRUE);
- queue->cur_level.buffers = 0; /* no content */
- queue->cur_level.bytes = 0; /* no content */
- queue->cur_level.time = 0; /* no content */
- queue->max_size.buffers = 100; /* 100 buffers */
- queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
- queue->max_size.time = GST_SECOND; /* 1 s. */
- queue->min_threshold.buffers = 0; /* no threshold */
- queue->min_threshold.bytes = 0; /* no threshold */
- queue->min_threshold.time = 0; /* no threshold */
+ queue->cur_level.buffers = 0; /* no content */
+ queue->cur_level.bytes = 0; /* no content */
+ queue->cur_level.time = 0; /* no content */
+ queue->max_size.buffers = 100; /* 100 buffers */
+ queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
+ queue->max_size.time = GST_SECOND; /* 1 s. */
+ queue->min_threshold.buffers = 0; /* no threshold */
+ queue->min_threshold.bytes = 0; /* no threshold */
+ queue->min_threshold.time = 0; /* no threshold */
queue->leaky = GST_QUEUE_NO_LEAK;
queue->may_deadlock = TRUE;
queue->queue = g_queue_new ();
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue,
- "initialized queue's not_empty & not_full conditions");
+ "initialized queue's not_empty & not_full conditions");
}
static void
-gst_queue_dispose (GObject *object)
+gst_queue_dispose (GObject * object)
{
GstQueue *queue = GST_QUEUE (object);
while (!g_queue_is_empty (queue->queue)) {
GstData *data = g_queue_pop_head (queue->queue);
+
gst_data_unref (data);
}
g_queue_free (queue->queue);
g_cond_free (queue->event_done);
while (!g_queue_is_empty (queue->events)) {
GstEvent *event = g_queue_pop_head (queue->events);
+
gst_event_unref (event);
}
}
static GstCaps *
-gst_queue_getcaps (GstPad *pad)
+gst_queue_getcaps (GstPad * pad)
{
GstQueue *queue;
}
static GstPadLinkReturn
-gst_queue_link (GstPad *pad, const GstCaps *caps)
+gst_queue_link (GstPad * pad, const GstCaps * caps)
{
GstQueue *queue;
GstPadLinkReturn link_ret;
}
static void
-gst_queue_locked_flush (GstQueue *queue)
+gst_queue_locked_flush (GstQueue * queue)
{
while (!g_queue_is_empty (queue->queue)) {
GstData *data = g_queue_pop_head (queue->queue);
+
/* First loose the reference we added when putting that data in the queue */
gst_data_unref (data);
/* Then loose another reference because we are supposed to destroy that
}
static void
-gst_queue_handle_pending_events (GstQueue *queue)
+gst_queue_handle_pending_events (GstQueue * queue)
{
/* check for events to send upstream */
- while (!g_queue_is_empty (queue->events)){
+ while (!g_queue_is_empty (queue->events)) {
GstQueueEventResponse *er = g_queue_pop_head (queue->events);
+
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "sending event upstream");
er->ret = gst_pad_event_default (queue->srcpad, er->event);
er->handled = TRUE;
queue->queue->length)
static void
-gst_queue_chain (GstPad *pad,
- GstData *data)
+gst_queue_chain (GstPad * pad, GstData * data)
{
GstQueue *queue;
g_return_if_fail (data != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
-
+
restart:
/* we have to lock the queue since we span threads */
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", g_thread_self ());
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p",
+ g_thread_self ());
g_mutex_lock (queue->qlock);
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ());
/* assume don't need to flush this buffer when the queue is filled */
queue->flush = FALSE;
-
+
if (GST_IS_EVENT (data)) {
switch (GST_EVENT_TYPE (data)) {
case GST_EVENT_FLUSH:
- STATUS (queue, "received flush event");
- gst_queue_locked_flush (queue);
- STATUS (queue, "after flush");
+ STATUS (queue, "received flush event");
+ gst_queue_locked_flush (queue);
+ STATUS (queue, "after flush");
break;
case GST_EVENT_EOS:
STATUS (queue, "received EOS");
break;
default:
/* we put the event in the queue, we don't have to act ourselves */
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding event %p of type %d",
- data, GST_EVENT_TYPE (data));
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding event %p of type %d", data, GST_EVENT_TYPE (data));
break;
}
}
-
+
if (GST_IS_BUFFER (data))
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding buffer %p of size %d",
- data, GST_BUFFER_SIZE (data));
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
/* We make space available if we're "full" according to whatever
* the user defined as "full". Note that this only applies to buffers.
* We always handle events and they don't count in our statistics. */
if (GST_IS_BUFFER (data) &&
((queue->max_size.buffers > 0 &&
- queue->cur_level.buffers >= queue->max_size.buffers) ||
- (queue->max_size.bytes > 0 &&
- queue->cur_level.bytes >= queue->max_size.bytes) ||
- (queue->max_size.time > 0 &&
- queue->cur_level.time >= queue->max_size.time))) {
+ queue->cur_level.buffers >= queue->max_size.buffers) ||
+ (queue->max_size.bytes > 0 &&
+ queue->cur_level.bytes >= queue->max_size.bytes) ||
+ (queue->max_size.time > 0 &&
+ queue->cur_level.time >= queue->max_size.time))) {
g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
g_mutex_lock (queue->qlock);
/* how are we going to make space for this buffer? */
switch (queue->leaky) {
- /* leak current buffer */
+ /* leak current buffer */
case GST_QUEUE_LEAK_UPSTREAM:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue is full, leaking buffer on upstream end");
- /* now we can clean up and exit right away */
- g_mutex_unlock (queue->qlock);
- goto out_unref;
-
- /* leak first buffer in the queue */
- case GST_QUEUE_LEAK_DOWNSTREAM: {
- /* this is a bit hacky. We'll manually iterate the list
- * and find the first buffer from the head on. We'll
- * unref that and "fix up" the GQueue object... */
- GList *item;
- GstData *leak = NULL;
-
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue is full, leaking buffer on downstream end");
-
- for (item = queue->queue->head; item != NULL; item = item->next) {
- if (GST_IS_BUFFER (item->data)) {
- leak = item->data;
- break;
- }
- }
-
- /* if we didn't find anything, it means we have no buffers
- * in here. That cannot happen, since we had >= 1 bufs */
- g_assert (leak);
-
- /* Now remove it from the list, fixing up the GQueue
- * CHECKME: is a queue->head the first or the last item? */
- item = g_list_delete_link (queue->queue->head, item);
- queue->queue->head = g_list_first (item);
- queue->queue->tail = g_list_last (item);
- queue->queue->length--;
-
- /* and unref the data at the end. Twice, because we keep a ref
- * to make things read-only. Also keep our list uptodate. */
- queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
- queue->cur_level.buffers --;
- if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
- queue->cur_level.time -= GST_BUFFER_DURATION (data);
-
- gst_data_unref (data);
- gst_data_unref (data);
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue is full, leaking buffer on upstream end");
+ /* now we can clean up and exit right away */
+ g_mutex_unlock (queue->qlock);
+ goto out_unref;
+
+ /* leak first buffer in the queue */
+ case GST_QUEUE_LEAK_DOWNSTREAM:{
+ /* this is a bit hacky. We'll manually iterate the list
+ * and find the first buffer from the head on. We'll
+ * unref that and "fix up" the GQueue object... */
+ GList *item;
+ GstData *leak = NULL;
+
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue is full, leaking buffer on downstream end");
+
+ for (item = queue->queue->head; item != NULL; item = item->next) {
+ if (GST_IS_BUFFER (item->data)) {
+ leak = item->data;
+ break;
+ }
+ }
+
+ /* if we didn't find anything, it means we have no buffers
+ * in here. That cannot happen, since we had >= 1 bufs */
+ g_assert (leak);
+
+ /* Now remove it from the list, fixing up the GQueue
+ * CHECKME: is a queue->head the first or the last item? */
+ item = g_list_delete_link (queue->queue->head, item);
+ queue->queue->head = g_list_first (item);
+ queue->queue->tail = g_list_last (item);
+ queue->queue->length--;
+
+ /* and unref the data at the end. Twice, because we keep a ref
+ * to make things read-only. Also keep our list uptodate. */
+ queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
+ queue->cur_level.buffers--;
+ if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
+ queue->cur_level.time -= GST_BUFFER_DURATION (data);
+
+ gst_data_unref (data);
+ gst_data_unref (data);
+ break;
}
default:
- g_warning ("Unknown leaky type, using default");
- /* fall-through */
+ g_warning ("Unknown leaky type, using default");
+ /* fall-through */
- /* don't leak. Instead, wait for space to be available */
+ /* don't leak. Instead, wait for space to be available */
case GST_QUEUE_NO_LEAK:
- STATUS (queue, "pre-full wait");
-
- while ((queue->max_size.buffers > 0 &&
- queue->cur_level.buffers >= queue->max_size.buffers) ||
- (queue->max_size.bytes > 0 &&
- queue->cur_level.bytes >= queue->max_size.bytes) ||
- (queue->max_size.time > 0 &&
- queue->cur_level.time >= queue->max_size.time)) {
- /* if there's a pending state change for this queue
- * or its manager, switch back to iterator so bottom
- * half of state change executes */
- if (queue->interrupt) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
- g_mutex_unlock (queue->qlock);
- if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
- GST_ELEMENT (queue))) {
- goto out_unref;
- }
+ STATUS (queue, "pre-full wait");
+
+ while ((queue->max_size.buffers > 0 &&
+ queue->cur_level.buffers >= queue->max_size.buffers) ||
+ (queue->max_size.bytes > 0 &&
+ queue->cur_level.bytes >= queue->max_size.bytes) ||
+ (queue->max_size.time > 0 &&
+ queue->cur_level.time >= queue->max_size.time)) {
+ /* if there's a pending state change for this queue
+ * or its manager, switch back to iterator so bottom
+ * half of state change executes */
+ if (queue->interrupt) {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
+ g_mutex_unlock (queue->qlock);
+ if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
+ GST_ELEMENT (queue))) {
+ goto out_unref;
+ }
/* if we got here because we were unlocked after a
- * flush, we don't need to add the buffer to the
- * queue again */
+ * flush, we don't need to add the buffer to the
+ * queue again */
if (queue->flush) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "not adding pending buffer after flush");
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "not adding pending buffer after flush");
goto out_unref;
}
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "adding pending buffer after interrupt");
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "adding pending buffer after interrupt");
goto restart;
- }
+ }
- if (GST_STATE (queue) != GST_STATE_PLAYING) {
+ if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down. Try to
- * signal to resolve the error */
+ * signal to resolve the error */
if (!queue->may_deadlock) {
- g_mutex_unlock (queue->qlock);
- gst_data_unref (data);
- GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
- ("deadlock found, shutting down source pad elements"));
+ g_mutex_unlock (queue->qlock);
+ gst_data_unref (data);
+ GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
+ ("deadlock found, shutting down source pad elements"));
/* we don't go to out_unref here, since we want to
- * unref the buffer *before* calling GST_ELEMENT_ERROR */
+ * unref the buffer *before* calling GST_ELEMENT_ERROR */
return;
} else {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "%s: waiting for the app to restart "
- "source pad elements",
- GST_ELEMENT_NAME (queue));
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "%s: waiting for the app to restart "
+ "source pad elements", GST_ELEMENT_NAME (queue));
}
- }
-
- /* OK, we've got a serious issue here. Imagine the situation
- * where the puller (next element) is sending an event here,
- * so it cannot pull events from the queue, and we cannot
- * push data further because the queue is 'full' and therefore,
- * we wait here (and do not handle events): deadlock! to solve
- * that, we handle pending upstream events here, too. */
- gst_queue_handle_pending_events (queue);
-
- STATUS (queue, "waiting for item_del signal");
- g_cond_wait (queue->item_del, queue->qlock);
- STATUS (queue, "received item_del signal");
- }
-
- STATUS (queue, "post-full wait");
- g_mutex_unlock (queue->qlock);
- g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
- g_mutex_lock (queue->qlock);
- break;
+ }
+
+ /* OK, we've got a serious issue here. Imagine the situation
+ * where the puller (next element) is sending an event here,
+ * so it cannot pull events from the queue, and we cannot
+ * push data further because the queue is 'full' and therefore,
+ * we wait here (and do not handle events): deadlock! to solve
+ * that, we handle pending upstream events here, too. */
+ gst_queue_handle_pending_events (queue);
+
+ STATUS (queue, "waiting for item_del signal");
+ g_cond_wait (queue->item_del, queue->qlock);
+ STATUS (queue, "received item_del signal");
+ }
+
+ STATUS (queue, "post-full wait");
+ g_mutex_unlock (queue->qlock);
+ g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
+ g_mutex_lock (queue->qlock);
+ break;
}
}
}
static GstData *
-gst_queue_get (GstPad *pad)
+gst_queue_get (GstPad * pad)
{
GstQueue *queue;
GstData *data;
restart:
/* have to lock for thread-safety */
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "locking t:%p", g_thread_self ());
+ "locking t:%p", g_thread_self ());
g_mutex_lock (queue->qlock);
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "locked t:%p", g_thread_self ());
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ());
if (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 &&
- queue->cur_level.buffers < queue->min_threshold.buffers) ||
+ queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 &&
- queue->cur_level.bytes < queue->min_threshold.bytes) ||
+ queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 &&
- queue->cur_level.time < queue->min_threshold.time)) {
+ queue->cur_level.time < queue->min_threshold.time)) {
g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
g_mutex_lock (queue->qlock);
STATUS (queue, "pre-empty wait");
while (queue->queue->length == 0 ||
- (queue->min_threshold.buffers > 0 &&
- queue->cur_level.buffers < queue->min_threshold.buffers) ||
- (queue->min_threshold.bytes > 0 &&
- queue->cur_level.bytes < queue->min_threshold.bytes) ||
- (queue->min_threshold.time > 0 &&
- queue->cur_level.time < queue->min_threshold.time)) {
+ (queue->min_threshold.buffers > 0 &&
+ queue->cur_level.buffers < queue->min_threshold.buffers) ||
+ (queue->min_threshold.bytes > 0 &&
+ queue->cur_level.bytes < queue->min_threshold.bytes) ||
+ (queue->min_threshold.time > 0 &&
+ queue->cur_level.time < queue->min_threshold.time)) {
/* if there's a pending state change for this queue or its
* manager, switch back to iterator so bottom half of state
* change executes. */
if (queue->interrupt) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
- g_mutex_unlock (queue->qlock);
- if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
- GST_ELEMENT (queue)))
- return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
- goto restart;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
+ g_mutex_unlock (queue->qlock);
+ if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
+ GST_ELEMENT (queue)))
+ return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
+ goto restart;
}
if (GST_STATE (queue) != GST_STATE_PLAYING) {
- /* this means the other end is shut down */
- if (!queue->may_deadlock) {
- g_mutex_unlock (queue->qlock);
- GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
- ("deadlock found, shutting down sink pad elements"));
- goto restart;
- } else {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "%s: waiting for the app to restart "
- "source pad elements",
- GST_ELEMENT_NAME (queue));
- }
+ /* this means the other end is shut down */
+ if (!queue->may_deadlock) {
+ g_mutex_unlock (queue->qlock);
+ GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
+ ("deadlock found, shutting down sink pad elements"));
+ goto restart;
+ } else {
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "%s: waiting for the app to restart "
+ "source pad elements", GST_ELEMENT_NAME (queue));
+ }
}
STATUS (queue, "waiting for item_add");
-
+
if (queue->block_timeout != GST_CLOCK_TIME_NONE) {
- GTimeVal timeout;
- g_get_current_time (&timeout);
- g_time_val_add (&timeout, queue->block_timeout / 1000);
- if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)){
- g_mutex_unlock (queue->qlock);
+ GTimeVal timeout;
+
+ g_get_current_time (&timeout);
+ g_time_val_add (&timeout, queue->block_timeout / 1000);
+ if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) {
+ g_mutex_unlock (queue->qlock);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Sending filler event");
- return GST_DATA (gst_event_new_filler ());
- }
+ "Sending filler event");
+ return GST_DATA (gst_event_new_filler ());
+ }
} else {
- g_cond_wait (queue->item_add, queue->qlock);
+ g_cond_wait (queue->item_add, queue->qlock);
}
STATUS (queue, "got item_add signal");
}
/* There's something in the list now, whatever it is */
data = g_queue_pop_head (queue->queue);
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
- "retrieved data %p from queue", data);
-
+ "retrieved data %p from queue", data);
+
if (data == NULL)
return NULL;
* locked too so it'd cause a deadlock. */
if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data);
+
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "queue \"%s\" eos",
- GST_ELEMENT_NAME (queue));
- gst_element_set_eos (GST_ELEMENT (queue));
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "queue \"%s\" eos", GST_ELEMENT_NAME (queue));
+ gst_element_set_eos (GST_ELEMENT (queue));
+ break;
default:
- break;
+ break;
}
}
static gboolean
-gst_queue_handle_src_event (GstPad *pad,
- GstEvent *event)
+gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
{
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
gboolean res;
er.handled = FALSE;
g_queue_push_tail (queue->events, &er);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Preparing for loop for event handler");
+ "Preparing for loop for event handler");
/* see the chain function on why this is here - it prevents a deadlock */
g_cond_signal (queue->item_del);
while (!er.handled) {
GTimeVal timeout;
+
g_get_current_time (&timeout);
- g_time_val_add (&timeout, 500 * 1000); /* half a second */
+ g_time_val_add (&timeout, 500 * 1000); /* half a second */
if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) &&
- !er.handled) {
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "timeout in upstream event handling");
- /* remove ourselves from the pending list. Since we're
- * locked, others cannot reference this anymore. */
- queue->queue->head = g_list_remove (queue->queue->head, &er);
- queue->queue->head = g_list_first (queue->queue->head);
- queue->queue->tail = g_list_last (queue->queue->head);
- queue->queue->length--;
- res = FALSE;
- goto handled;
+ !er.handled) {
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
+ "timeout in upstream event handling");
+ /* remove ourselves from the pending list. Since we're
+ * locked, others cannot reference this anymore. */
+ queue->queue->head = g_list_remove (queue->queue->head, &er);
+ queue->queue->head = g_list_first (queue->queue->head);
+ queue->queue->tail = g_list_last (queue->queue->head);
+ queue->queue->length--;
+ res = FALSE;
+ goto handled;
}
}
- GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
- "Event handled");
+ GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled");
res = er.ret;
} else {
- res = gst_pad_event_default (pad, event);
+ res = gst_pad_event_default (pad, event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
- GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
- "FLUSH event, flushing queue\n");
- gst_queue_locked_flush (queue);
- break;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
+ "FLUSH event, flushing queue\n");
+ gst_queue_locked_flush (queue);
+ break;
case GST_EVENT_SEEK:
- if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
- gst_queue_locked_flush (queue);
- }
+ if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
+ gst_queue_locked_flush (queue);
+ }
default:
- break;
+ break;
}
}
handled:
}
static gboolean
-gst_queue_release_locks (GstElement *element)
+gst_queue_release_locks (GstElement * element)
{
GstQueue *queue;
}
static GstElementStateReturn
-gst_queue_change_state (GstElement *element)
+gst_queue_change_state (GstElement * element)
{
GstQueue *queue;
GstElementStateReturn ret = GST_STATE_SUCCESS;
break;
case GST_STATE_PAUSED_TO_PLAYING:
if (!GST_PAD_IS_LINKED (queue->sinkpad)) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
- "queue %s is not linked",
- GST_ELEMENT_NAME (queue));
- /* FIXME can this be? */
- g_cond_signal (queue->item_add);
-
- ret = GST_STATE_FAILURE;
- goto error;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
+ "queue %s is not linked", GST_ELEMENT_NAME (queue));
+ /* FIXME can this be? */
+ g_cond_signal (queue->item_add);
+
+ ret = GST_STATE_FAILURE;
+ goto error;
} else {
- GstScheduler *src_sched, *sink_sched;
-
- src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
- sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
+ GstScheduler *src_sched, *sink_sched;
+
+ src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
+ sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
- if (src_sched == sink_sched) {
- GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
- "queue %s does not connect different schedulers",
- GST_ELEMENT_NAME (queue));
+ if (src_sched == sink_sched) {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
+ "queue %s does not connect different schedulers",
+ GST_ELEMENT_NAME (queue));
g_warning ("queue %s does not connect different schedulers",
- GST_ELEMENT_NAME (queue));
+ GST_ELEMENT_NAME (queue));
ret = GST_STATE_FAILURE;
goto error;
- }
+ }
}
queue->interrupt = FALSE;
break;
static void
-gst_queue_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_queue_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstQueue *queue = GST_QUEUE (object);
}
static void
-gst_queue_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_queue_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstQueue *queue = GST_QUEUE (object);
G_BEGIN_DECLS
-
#define GST_TYPE_QUEUE \
(gst_queue_get_type())
#define GST_QUEUE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE))
#define GST_IS_QUEUE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE))
-
-enum {
- GST_QUEUE_NO_LEAK = 0,
- GST_QUEUE_LEAK_UPSTREAM = 1,
- GST_QUEUE_LEAK_DOWNSTREAM = 2
+ enum
+{
+ GST_QUEUE_NO_LEAK = 0,
+ GST_QUEUE_LEAK_UPSTREAM = 1,
+ GST_QUEUE_LEAK_DOWNSTREAM = 2
};
typedef struct _GstQueue GstQueue;
typedef struct _GstQueueClass GstQueueClass;
-struct _GstQueue {
+struct _GstQueue
+{
GstElement element;
GstPad *sinkpad;
/* the queue of data we're keeping our grubby hands on */
GQueue *queue;
- struct {
- guint buffers; /* no. of buffers */
- guint bytes; /* no. of bytes */
- guint64 time; /* amount of time */
- } cur_level, /* currently in the queue */
- max_size, /* max. amount of data allowed in the queue */
- min_threshold; /* min. amount of data required to wake reader */
+ struct
+ {
+ guint buffers; /* no. of buffers */
+ guint bytes; /* no. of bytes */
+ guint64 time; /* amount of time */
+ } cur_level, /* currently in the queue */
+ max_size, /* max. amount of data allowed in the queue */
+ min_threshold; /* min. amount of data required to wake reader */
/* whether we leak data, and at which end */
gint leaky;
gboolean interrupt;
gboolean flush;
- GMutex *qlock; /* lock for queue (vs object lock) */
- GCond *item_add; /* signals buffers now available for reading */
- GCond *item_del; /* signals space now available for writing */
- GCond *event_done; /* upstream event signaller */
+ GMutex *qlock; /* lock for queue (vs object lock) */
+ GCond *item_add; /* signals buffers now available for reading */
+ GCond *item_del; /* signals space now available for writing */
+ GCond *event_done; /* upstream event signaller */
- GTimeVal *timeval; /* the timeout for the queue locking */
- GQueue *events; /* upstream events get decoupled here */
+ GTimeVal *timeval; /* the timeout for the queue locking */
+ GQueue *events; /* upstream events get decoupled here */
GstCaps *negotiated_caps;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstQueueClass {
+struct _GstQueueClass
+{
GstElementClass parent_class;
/* signals - 'running' is called from both sides
* which might make it sort of non-useful... */
- void (*underrun) (GstQueue *queue);
- void (*running) (GstQueue *queue);
- void (*overrun) (GstQueue *queue);
+ void (*underrun) (GstQueue * queue);
+ void (*running) (GstQueue * queue);
+ void (*overrun) (GstQueue * queue);
gpointer _gst_reserved[GST_PADDING];
};
GType gst_queue_get_type (void);
G_END_DECLS
-
-
#endif /* __GST_QUEUE_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_shaper_debug);
#define GST_CAT_DEFAULT gst_shaper_debug
-GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS (
- "Shaper",
- "Generic",
- "Synchronizes streams on different pads",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ("Shaper",
+ "Generic",
+ "Synchronizes streams on different pads",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Shaper signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_POLICY,
ARG_SILENT,
typedef struct
{
- GstPad *sinkpad;
- GstPad *srcpad;
- GstBuffer *buffer;
+ GstPad *sinkpad;
+ GstPad *srcpad;
+ GstBuffer *buffer;
} GstShaperConnection;
-GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
-GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type())
static GType
{
static GType shaper_policy_type = 0;
static GEnumValue shaper_policy[] = {
- { SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"},
- { SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
+ {SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"},
+ {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
{0, NULL, NULL},
};
if (!shaper_policy_type) {
- shaper_policy_type = g_enum_register_static ("GstShaperPolicy", shaper_policy);
+ shaper_policy_type =
+ g_enum_register_static ("GstShaperPolicy", shaper_policy);
}
return shaper_policy_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_shaper_debug, "shaper", 0, "shaper element");
-GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT,
+ _do_init);
-static void gst_shaper_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_shaper_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_shaper_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_shaper_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstPad* gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused);
+static GstPad *gst_shaper_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
-static void gst_shaper_loop (GstElement *element);
+static void gst_shaper_loop (GstElement * element);
static void
gst_shaper_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_shaper_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&shaper_src_template));
gst_static_pad_template_get (&shaper_sink_template));
}
-static void
-gst_shaper_class_init (GstShaperClass *klass)
+static void
+gst_shaper_class_init (GstShaperClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY,
- g_param_spec_enum ("policy", "Policy", "Shaper policy",
- GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
+ g_param_spec_enum ("policy", "Policy", "Shaper policy",
+ GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last-message", "last-message", "last-message",
- NULL, G_PARAM_READABLE));
+ g_param_spec_string ("last-message", "last-message", "last-message",
+ NULL, G_PARAM_READABLE));
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad);
}
-static GstCaps*
-gst_shaper_getcaps (GstPad *pad)
+static GstCaps *
+gst_shaper_getcaps (GstPad * pad)
{
GstPad *otherpad;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
if (GST_PAD_PEER (otherpad)) {
return gst_pad_get_caps (GST_PAD_PEER (otherpad));
}
}
-static GList*
-gst_shaper_get_internal_link (GstPad *pad)
+static GList *
+gst_shaper_get_internal_link (GstPad * pad)
{
GList *res = NULL;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
res = g_list_prepend (res, otherpad);
}
static GstPadLinkReturn
-gst_shaper_link (GstPad *pad, const GstCaps *caps)
+gst_shaper_link (GstPad * pad, const GstCaps * caps)
{
GstPad *otherpad;
GstShaperConnection *connection;
connection = gst_pad_get_element_private (pad);
- otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
+ otherpad =
+ (pad == connection->srcpad ? connection->sinkpad : connection->srcpad);
return gst_pad_try_set_caps (otherpad, caps);
}
-static GstShaperConnection*
-gst_shaper_create_connection (GstShaper *shaper)
+static GstShaperConnection *
+gst_shaper_create_connection (GstShaper * shaper)
{
GstShaperConnection *connection;
gchar *padname;
connection = g_new0 (GstShaperConnection, 1);
padname = g_strdup_printf ("sink%d", shaper->nconnections);
- connection->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&shaper_sink_template), padname);
+ connection->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&shaper_sink_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps);
- gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link);
+ gst_pad_set_internal_link_function (connection->sinkpad,
+ gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->sinkpad, gst_shaper_link);
gst_pad_set_element_private (connection->sinkpad, connection);
gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad);
padname = g_strdup_printf ("src%d", shaper->nconnections);
- connection->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&shaper_src_template), padname);
+ connection->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&shaper_src_template), padname);
g_free (padname);
gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps);
- gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link);
+ gst_pad_set_internal_link_function (connection->srcpad,
+ gst_shaper_get_internal_link);
gst_pad_set_link_function (connection->srcpad, gst_shaper_link);
gst_pad_set_element_private (connection->srcpad, connection);
gst_element_add_pad (GST_ELEMENT (shaper), connection->srcpad);
return connection;
}
-static GstPad*
-gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_shaper_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
GstShaper *shaper = GST_SHAPER (element);
GstShaperConnection *connection;
return connection->sinkpad;
}
-static void
-gst_shaper_init (GstShaper *shaper)
+static void
+gst_shaper_init (GstShaper * shaper)
{
gst_element_set_loop_function (GST_ELEMENT (shaper), gst_shaper_loop);
shaper->last_message = NULL;
}
-static void
-gst_shaper_loop (GstElement *element)
+static void
+gst_shaper_loop (GstElement * element)
{
GstShaper *shaper;
GSList *connections;
gst_pad_push (connection->srcpad, GST_DATA (buffer));
switch (type) {
- /* on EOS we disable the pad so that we don't pull on
- * it again and never get more data */
- case GST_EVENT_EOS:
+ /* on EOS we disable the pad so that we don't pull on
+ * it again and never get more data */
+ case GST_EVENT_EOS:
gst_pad_set_active (connection->sinkpad, FALSE);
break;
default:
break;
}
- }
- else {
+ } else {
/* we store the buffer */
connection->buffer = buffer;
}
/* FIXME policy stuff goes here */
/* find connection with lowest timestamp */
if (min == NULL || (connection->buffer != NULL &&
- (GST_BUFFER_TIMESTAMP (connection->buffer) <
- GST_BUFFER_TIMESTAMP (min->buffer))))
- {
+ (GST_BUFFER_TIMESTAMP (connection->buffer) <
+ GST_BUFFER_TIMESTAMP (min->buffer)))) {
min = connection;
}
connections = g_slist_next (connections);
/* since we pushed a buffer, it's not EOS */
eos = FALSE;
}
-
+
if (eos) {
gst_element_set_eos (element);
}
}
-static void
-gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_shaper_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstShaper *shaper;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SHAPER (object));
-
+
shaper = GST_SHAPER (object);
switch (prop_id) {
}
}
-static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_shaper_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstShaper *shaper;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SHAPER (object));
-
+
shaper = GST_SHAPER (object);
switch (prop_id) {
break;
}
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_SHAPER \
(gst_shaper_get_type())
#define GST_SHAPER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHAPER))
#define GST_IS_SHAPER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SHAPER))
-
-typedef enum {
+ typedef enum
+{
SHAPER_POLICY_TIMESTAMPS = 1,
SHAPER_POLICY_BUFFERSIZE
} GstShaperPolicyType;
typedef struct _GstShaper GstShaper;
typedef struct _GstShaperClass GstShaperClass;
-struct _GstShaper {
- GstElement element;
+struct _GstShaper
+{
+ GstElement element;
- GSList *connections;
- gint nconnections;
+ GSList *connections;
+ gint nconnections;
- GstShaperPolicyType policy;
+ GstShaperPolicyType policy;
- gboolean silent;
- gchar *last_message;
+ gboolean silent;
+ gchar *last_message;
};
-struct _GstShaperClass {
+struct _GstShaperClass
+{
GstElementClass parent_class;
};
-GType gst_shaper_get_type (void);
-gboolean gst_shaper_factory_init (GstElementFactory *factory);
+GType gst_shaper_get_type (void);
+gboolean gst_shaper_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_SHAPER_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_statistics_debug);
#define GST_CAT_DEFAULT gst_statistics_debug
-GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS (
- "Statistics",
- "Generic",
- "Statistics on buffers/bytes/events",
- "David I. Lehn <dlehn@users.sourceforge.net>"
-);
+GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ("Statistics",
+ "Generic",
+ "Statistics on buffers/bytes/events",
+ "David I. Lehn <dlehn@users.sourceforge.net>");
/* Statistics signals and args */
-enum {
+enum
+{
SIGNAL_UPDATE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_BUFFERS,
ARG_BYTES,
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_statistics_debug, "statistics", 0, "statistics element");
-GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_statistics_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_statistics_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_statistics_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_statistics_chain (GstPad *pad, GstData *_data);
-static void gst_statistics_reset (GstStatistics *statistics);
-static void gst_statistics_print (GstStatistics *statistics);
+static void gst_statistics_chain (GstPad * pad, GstData * _data);
+static void gst_statistics_reset (GstStatistics * statistics);
+static void gst_statistics_print (GstStatistics * statistics);
static guint gst_statistics_signals[LAST_SIGNAL] = { 0, };
gst_statistics_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_statistics_details);
}
-static void
-gst_statistics_class_init (GstStatisticsClass *klass)
+static void
+gst_statistics_class_init (GstStatisticsClass * klass)
{
GObjectClass *gobject_class;
-
+
gobject_class = G_OBJECT_CLASS (klass);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS,
- g_param_spec_int64 ("buffers", "buffers", "total buffers count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_param_spec_int64 ("buffers", "buffers", "total buffers count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES,
- g_param_spec_int64 ("bytes", "bytes", "total bytes count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_param_spec_int64 ("bytes", "bytes", "total bytes count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS,
- g_param_spec_int64 ("events", "events", "total event count",
- 0, G_MAXINT64, 0, G_PARAM_READABLE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFER_UPDATE_FREQ,
- g_param_spec_int64 ("buffer_update_freq", "buffer update freq", "buffer update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES_UPDATE_FREQ,
- g_param_spec_int64 ("bytes_update_freq", "bytes update freq", "bytes update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_UPDATE_FREQ,
- g_param_spec_int64 ("event_update_freq", "event update freq", "event update frequency",
- 0, G_MAXINT64, 0, G_PARAM_READWRITE));
+ g_param_spec_int64 ("events", "events", "total event count",
+ 0, G_MAXINT64, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq",
+ "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq",
+ "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq",
+ "event update freq", "event update frequency", 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS,
- g_param_spec_boolean ("update_on_eos", "update on EOS", "update on EOS event",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("update_on_eos", "update on EOS",
+ "update on EOS event", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE,
- g_param_spec_boolean ("update", "update", "update",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("update", "update", "update", TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- TRUE,G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent", TRUE,
+ G_PARAM_READWRITE));
gst_statistics_signals[SIGNAL_UPDATE] =
- g_signal_new ("update", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
-static void
-gst_statistics_init (GstStatistics *statistics)
+static void
+gst_statistics_init (GstStatistics * statistics)
{
statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad);
- gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain));
-
+ gst_pad_set_chain_function (statistics->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_statistics_chain));
+
statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad);
statistics->timer = NULL;
statistics->last_timer = NULL;
- gst_statistics_reset(statistics);
+ gst_statistics_reset (statistics);
}
static void
-gst_statistics_reset (GstStatistics *statistics)
+gst_statistics_reset (GstStatistics * statistics)
{
g_return_if_fail (statistics != NULL);
g_return_if_fail (GST_IS_STATISTICS (statistics));
statistics->silent = FALSE;
if (!statistics->timer) {
- statistics->timer = g_timer_new();
+ statistics->timer = g_timer_new ();
}
if (!statistics->last_timer) {
- statistics->last_timer = g_timer_new();
+ statistics->last_timer = g_timer_new ();
}
}
static void
-print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, stats *final, double time)
+print_stats (gboolean first, const gchar * name, const gchar * type,
+ stats * base, stats * final, double time)
{
const gchar *header0 = "statistics";
const gchar *headerN = " ";
delta.bytes = final->bytes - base->bytes;
delta.events = final->events - base->events;
- g_print("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT
- " bytes:%" G_GINT64_FORMAT
- " events:%" G_GINT64_FORMAT "\n",
- first ? header0 : headerN,
- name, type, time,
- final->buffers,
- final->bytes,
- final->events);
- g_print("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n",
- headerN,
- name, type,
- delta.buffers/time,
- delta.bytes/time,
- delta.events/time,
- ((double)delta.bytes/(double)delta.buffers));
+ g_print ("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT
+ " bytes:%" G_GINT64_FORMAT
+ " events:%" G_GINT64_FORMAT "\n",
+ first ? header0 : headerN,
+ name, type, time, final->buffers, final->bytes, final->events);
+ g_print ("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n",
+ headerN,
+ name, type,
+ delta.buffers / time,
+ delta.bytes / time,
+ delta.events / time, ((double) delta.bytes / (double) delta.buffers));
}
static void
-gst_statistics_print (GstStatistics *statistics)
+gst_statistics_print (GstStatistics * statistics)
{
const gchar *name;
double elapsed;
g_return_if_fail (statistics != NULL);
g_return_if_fail (GST_IS_STATISTICS (statistics));
- name = gst_object_get_name(GST_OBJECT(statistics));
+ name = gst_object_get_name (GST_OBJECT (statistics));
if (!name) {
name = "";
}
- elapsed = g_timer_elapsed(statistics->timer, NULL);
- last_elapsed = g_timer_elapsed(statistics->last_timer, NULL);
+ elapsed = g_timer_elapsed (statistics->timer, NULL);
+ last_elapsed = g_timer_elapsed (statistics->last_timer, NULL);
- print_stats(1, name, "total", &zero_stats, &statistics->stats, elapsed);
- print_stats(0, name, "last", &statistics->last_stats, &statistics->stats, last_elapsed);
+ print_stats (1, name, "total", &zero_stats, &statistics->stats, elapsed);
+ print_stats (0, name, "last", &statistics->last_stats, &statistics->stats,
+ last_elapsed);
statistics->last_stats = statistics->stats;
- g_timer_reset(statistics->last_timer);
+ g_timer_reset (statistics->last_timer);
}
-static void
-gst_statistics_chain (GstPad *pad, GstData *_data)
+static void
+gst_statistics_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstStatistics *statistics;
statistics = GST_STATISTICS (gst_pad_get_parent (pad));
- if (GST_IS_EVENT(buf)) {
+ if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
+
statistics->stats.events += 1;
- if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
+ if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
gst_element_set_eos (GST_ELEMENT (statistics));
if (statistics->update_on_eos) {
- update = TRUE;
+ update = TRUE;
}
}
if (statistics->update_freq.events) {
statistics->update_count.events += 1;
if (statistics->update_count.events == statistics->update_freq.events) {
- statistics->update_count.events = 0;
- update = TRUE;
+ statistics->update_count.events = 0;
+ update = TRUE;
}
}
} else {
if (statistics->update_freq.buffers) {
statistics->update_count.buffers += 1;
if (statistics->update_count.buffers == statistics->update_freq.buffers) {
- statistics->update_count.buffers = 0;
- update = TRUE;
+ statistics->update_count.buffers = 0;
+ update = TRUE;
}
}
- statistics->stats.bytes += GST_BUFFER_SIZE(buf);
+ statistics->stats.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_freq.bytes) {
- statistics->update_count.bytes += GST_BUFFER_SIZE(buf);
+ statistics->update_count.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_count.bytes >= statistics->update_freq.bytes) {
- statistics->update_count.bytes = 0;
- update = TRUE;
+ statistics->update_count.bytes = 0;
+ update = TRUE;
}
}
}
if (update) {
if (statistics->update) {
GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics));
- g_signal_emit (G_OBJECT (statistics), gst_statistics_signals[SIGNAL_UPDATE], 0);
+ g_signal_emit (G_OBJECT (statistics),
+ gst_statistics_signals[SIGNAL_UPDATE], 0);
GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics));
}
if (!statistics->silent) {
- gst_statistics_print(statistics);
+ gst_statistics_print (statistics);
}
}
gst_pad_push (statistics->srcpad, GST_DATA (buf));
}
-static void
-gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_statistics_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstStatistics *statistics;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_STATISTICS (object));
-
+
statistics = GST_STATISTICS (object);
switch (prop_id) {
}
}
-static void gst_statistics_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void
+gst_statistics_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
GstStatistics *statistics;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_STATISTICS (object));
-
+
statistics = GST_STATISTICS (object);
switch (prop_id) {
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_STATISTICS \
(gst_statistics_get_type())
#define GST_STATISTICS(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATISTICS))
#define GST_IS_STATISTICS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATISTICS))
-
typedef struct _GstStatistics GstStatistics;
typedef struct _GstStatisticsClass GstStatisticsClass;
typedef struct _stats stats;
-struct _stats {
+struct _stats
+{
gint64 buffers;
gint64 bytes;
gint64 events;
};
-struct _GstStatistics {
+struct _GstStatistics
+{
GstElement element;
GstPad *sinkpad;
stats update_count;
stats update_freq;
- gboolean update_on_eos;
+ gboolean update_on_eos;
gboolean update;
gboolean silent;
};
-struct _GstStatisticsClass {
+struct _GstStatisticsClass
+{
GstElementClass parent_class;
/* signals */
- void (*update) (GstElement *element);
+ void (*update) (GstElement * element);
};
-GType gst_statistics_get_type(void);
+GType gst_statistics_get_type (void);
G_END_DECLS
-
#endif /* __GST_STATISTICS_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_tee_debug);
#define GST_CAT_DEFAULT gst_tee_debug
-GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS (
- "Tee pipe fitting",
- "Generic",
- "1-to-N pipe fitting",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ("Tee pipe fitting",
+ "Generic",
+ "1-to-N pipe fitting",
+ "Erik Walthinsen <omega@cse.ogi.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* Tee signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SILENT,
ARG_NUM_PADS,
/* FILL ME */
};
-GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_tee_debug, "tee", 0, "tee element");
GST_BOILERPLATE_FULL (GstTee, gst_tee, GstElement, GST_TYPE_ELEMENT, _do_init);
-static GstPad* gst_tee_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *unused);
+static GstPad *gst_tee_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * unused);
-static void gst_tee_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_tee_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_tee_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_tee_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_tee_chain (GstPad *pad, GstData *_data);
+static void gst_tee_chain (GstPad * pad, GstData * _data);
static void
gst_tee_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_tee_details);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
static void
-gst_tee_class_init (GstTeeClass *klass)
+gst_tee_class_init (GstTeeClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
- g_param_spec_int ("num_pads", "num_pads", "num_pads",
- 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_pads", "num_pads", "num_pads",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
- g_param_spec_string ("last_message", "last_message", "last_message",
- NULL, G_PARAM_READABLE));
-
+ g_param_spec_string ("last_message", "last_message", "last_message",
+ NULL, G_PARAM_READABLE));
+
- gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property);
+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property);
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_tee_request_new_pad);
}
-static void
-gst_tee_init (GstTee *tee)
+static void
+gst_tee_init (GstTee * tee)
{
tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
- gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
- gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_link_function (tee->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ gst_pad_set_getcaps_function (tee->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
tee->last_message = NULL;
}
/* helper compare function */
-gint name_pad_compare (gconstpointer a, gconstpointer b)
+gint
+name_pad_compare (gconstpointer a, gconstpointer b)
{
- GstPad* pad = (GstPad*) a;
+ GstPad *pad = (GstPad *) a;
gchar *name = (gchar *) b;
-
+
g_assert (GST_IS_PAD (pad));
- return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
+ return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
}
-static GstPad*
-gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstPad *srcpad;
const GList *pads;
g_return_val_if_fail (GST_IS_TEE (element), NULL);
-
+
if (templ->direction != GST_PAD_SRC) {
g_warning ("gsttee: request new pad that is not a SRC pad\n");
return NULL;
/* try names in order and find one that's not in use atm */
pads = gst_element_get_pad_list (element);
-
+
name = NULL;
- while (!name)
- {
+ while (!name) {
name = g_strdup_printf ("src%d", i);
- if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL)
- {
+ if (g_list_find_custom ((GList *) pads, (gconstpointer) name,
+ name_pad_compare) != NULL) {
/* this name is taken, use the next one */
++i;
g_free (name);
tee->last_message = g_strdup_printf ("new pad %s", name);
g_object_notify (G_OBJECT (tee), "last_message");
}
-
+
srcpad = gst_pad_new_from_template (templ, name);
g_free (name);
- gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
- gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ gst_pad_set_link_function (srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ gst_pad_set_getcaps_function (srcpad,
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_add_pad (GST_ELEMENT (tee), srcpad);
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;
}
static void
-gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_tee_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstTee *tee;
}
static void
-gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tee_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstTee *tee;
*
* Chain a buffer on a pad.
*/
-static void
-gst_tee_chain (GstPad *pad, GstData *_data)
+static void
+gst_tee_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstTee *tee;
tee = GST_TEE (gst_pad_get_parent (pad));
gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1);
-
+
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
while (pads) {
GstPad *outpad = GST_PAD (pads->data);
+
pads = g_list_next (pads);
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC)
if (!tee->silent) {
g_free (tee->last_message);
- tee->last_message = g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
- G_GUINT64_FORMAT ") %p",
- GST_DEBUG_PAD_NAME (outpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
+ tee->last_message =
+ g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
+ G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad),
+ GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (tee), "last_message");
}
gst_buffer_unref (buf);
}
}
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_TEE \
(gst_tee_get_type())
#define GST_TEE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEE))
#define GST_IS_TEE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEE))
+typedef struct _GstTee GstTee;
+typedef struct _GstTeeClass GstTeeClass;
-typedef struct _GstTee GstTee;
-typedef struct _GstTeeClass GstTeeClass;
-
-struct _GstTee {
+struct _GstTee
+{
GstElement element;
GstPad *sinkpad;
gboolean silent;
- gchar *last_message;
+ gchar *last_message;
};
-struct _GstTeeClass {
+struct _GstTeeClass
+{
GstElementClass parent_class;
};
-GType gst_tee_get_type (void);
+GType gst_tee_get_type (void);
-gboolean gst_tee_factory_init (GstElementFactory *factory);
+gboolean gst_tee_factory_init (GstElementFactory * factory);
G_END_DECLS
-
#endif /* __GST_TEE_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_type_find_element_debug);
#define GST_CAT_DEFAULT gst_type_find_element_debug
-GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS (
- "TypeFind",
- "Generic",
- "Finds the media type of a stream",
- "Benjamin Otte <in7y118@public.uni-hamburg.de>"
-);
+GstElementDetails gst_type_find_element_details =
+GST_ELEMENT_DETAILS ("TypeFind",
+ "Generic",
+ "Finds the media type of a stream",
+ "Benjamin Otte <in7y118@public.uni-hamburg.de>");
/* generic templates */
-GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
-
-GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GstStaticPadTemplate type_find_element_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+GstStaticPadTemplate type_find_element_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
/* TypeFind signals and args */
-enum {
+enum
+{
HAVE_TYPE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_CAPS,
ARG_MINIMUM,
ARG_MAXIMUM
};
-enum {
- MODE_NORMAL, /* act as identity */
- MODE_TYPEFIND, /* do typefinding */
+enum
+{
+ MODE_NORMAL, /* act as identity */
+ MODE_TYPEFIND, /* do typefinding */
};
GST_DEBUG_CATEGORY_INIT (gst_type_find_element_debug, "typefind", \
GST_DEBUG_BG_YELLOW | GST_DEBUG_FG_GREEN, "type finding element");
-GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, GST_TYPE_ELEMENT, _do_init);
+GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
-static void gst_type_find_element_dispose (GObject * object);
-static void gst_type_find_element_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_type_find_element_get_property (GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec);
+static void gst_type_find_element_dispose (GObject * object);
+static void gst_type_find_element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_type_find_element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-static const GstEventMask *
- gst_type_find_element_src_event_mask (GstPad * pad);
-static gboolean gst_type_find_element_src_event (GstPad * pad,
- GstEvent * event);
+static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad);
+static gboolean gst_type_find_element_src_event (GstPad * pad,
+ GstEvent * event);
-static void gst_type_find_element_chain (GstPad * sinkpad,
- GstData * data);
+static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data);
static GstElementStateReturn
- gst_type_find_element_change_state (GstElement * element);
+gst_type_find_element_change_state (GstElement * element);
static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 };
static void
-gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps)
+gst_type_find_element_have_type (GstTypeFindElement * typefind,
+ guint probability, const GstCaps * caps)
{
g_assert (typefind->caps == NULL);
g_assert (caps != NULL);
gst_type_find_element_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_set_details (gstelement_class, &gst_type_find_element_details);
+
+ gst_element_class_set_details (gstelement_class,
+ &gst_type_find_element_details);
}
static void
-gst_type_find_element_class_init (GstTypeFindElementClass *typefind_class)
+gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (typefind_class);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (typefind_class);
- gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_type_find_element_set_property);
- gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_type_find_element_get_property);
- gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose);
+ gobject_class->set_property =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_set_property);
+ gobject_class->get_property =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_get_property);
+ gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose);
typefind_class->have_type = gst_type_find_element_have_type;
g_object_class_install_property (gobject_class, ARG_CAPS,
- g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"),
- gst_caps_get_type(), G_PARAM_READABLE));
+ g_param_spec_boxed ("caps", _("caps"),
+ _("detected capabilities in stream"), gst_caps_get_type (),
+ G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
- g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps",
- GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
+ g_param_spec_uint ("minimum", _("minimum"),
+ "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM,
+ GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MINIMUM,
- g_param_spec_uint ("maximum", _("maximum"), "probability to stop typefinding",
- GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE));
-
- gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type",
- G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
- gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
- G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
+ g_param_spec_uint ("maximum", _("maximum"),
+ "probability to stop typefinding", GST_TYPE_FIND_MINIMUM,
+ GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE));
+
+ gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type",
+ G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL,
+ gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2,
+ G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_type_find_element_change_state);
}
static void
-gst_type_find_element_init (GstTypeFindElement *typefind)
+gst_type_find_element_init (GstTypeFindElement * typefind)
{
/* sinkpad */
- typefind->sink = gst_pad_new_from_template (
- gst_static_pad_template_get (&type_find_element_sink_template), "sink");
- gst_pad_set_chain_function (typefind->sink,
- gst_type_find_element_chain);
+ typefind->sink =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&type_find_element_sink_template), "sink");
+ gst_pad_set_chain_function (typefind->sink, gst_type_find_element_chain);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink);
/* srcpad */
- typefind->src = gst_pad_new_from_template (
- gst_static_pad_template_get (&type_find_element_src_template), "src");
+ typefind->src =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&type_find_element_src_template), "src");
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
- gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask);
+ gst_pad_set_event_mask_function (typefind->src,
+ gst_type_find_element_src_event_mask);
gst_pad_use_explicit_caps (typefind->src);
gst_element_add_pad (GST_ELEMENT (typefind), typefind->src);
GST_FLAG_SET (typefind, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_type_find_element_dispose (GObject *object)
+gst_type_find_element_dispose (GObject * object)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (object);
}
}
static void
-gst_type_find_element_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_type_find_element_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstTypeFindElement *typefind;
}
}
static void
-gst_type_find_element_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_type_find_element_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstTypeFindElement *typefind;
}
}
static const GstEventMask *
-gst_type_find_element_src_event_mask (GstPad *pad)
+gst_type_find_element_src_event_mask (GstPad * pad)
{
static const GstEventMask mask[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
+ {GST_EVENT_SEEK,
+ GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END |
+ GST_SEEK_FLAG_FLUSH},
/* add more if you want, event masks suck and need to die anyway */
- { 0, }
+ {0,}
};
-
+
return mask;
}
-static gboolean
-gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
+
+static gboolean
+gst_type_find_element_src_event (GstPad * pad, GstEvent * event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
}
return gst_pad_event_default (pad, event);
}
-typedef struct {
- GstTypeFindFactory * factory;
- gint probability;
- GstCaps * caps;
- gint64 requested_offset;
- guint requested_size;
-
- GList * buffers;
- GstTypeFindElement * self;
+typedef struct
+{
+ GstTypeFindFactory *factory;
+ gint probability;
+ GstCaps *caps;
+ gint64 requested_offset;
+ guint requested_size;
+
+ GList *buffers;
+ GstTypeFindElement *self;
} TypeFindEntry;
static inline TypeFindEntry *
return g_new0 (TypeFindEntry, 1);
}
static void
-free_entry_buffers (TypeFindEntry *entry)
+free_entry_buffers (TypeFindEntry * entry)
{
g_list_foreach (entry->buffers, (GFunc) gst_data_unref, NULL);
g_list_free (entry->buffers);
entry->buffers = NULL;
}
static void
-free_entry (TypeFindEntry *entry)
+free_entry (TypeFindEntry * entry)
{
free_entry_buffers (entry);
-
+
if (entry->caps)
gst_caps_free (entry->caps);
g_free (entry);
}
static void
-start_typefinding (GstTypeFindElement *typefind)
+start_typefinding (GstTypeFindElement * typefind)
{
g_assert (typefind->caps == NULL);
g_assert (typefind->possibilities == NULL);
-
+
GST_DEBUG_OBJECT (typefind, "starting typefinding");
- typefind->mode = MODE_TYPEFIND;
- typefind->stream_length_available = TRUE;
- typefind->stream_length = 0;
+ typefind->mode = MODE_TYPEFIND;
+ typefind->stream_length_available = TRUE;
+ typefind->stream_length = 0;
}
static void
-stop_typefinding (GstTypeFindElement *typefind)
+stop_typefinding (GstTypeFindElement * typefind)
{
/* stop all typefinding and set mode back to normal */
- gboolean push_cached_buffers = gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING;
-
- GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
+ gboolean push_cached_buffers =
+ gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING;
+
+ GST_DEBUG_OBJECT (typefind, "stopping typefinding%s",
+ push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this should only happen on PAUSED => READY or EOS */
- GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
+ GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions",
+ g_list_length (typefind->possibilities));
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
GstBuffer *buffer;
guint size = gst_buffer_store_get_size (typefind->store, 0);
- if (size && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) {
+ if (size
+ && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) {
GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size);
gst_pad_push (typefind->src, GST_DATA (buffer));
} else {
size = 0;
}
GST_LOG_OBJECT (typefind, "seeking back to current position %u", size);
- if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink),
- gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, size))) {
- GST_WARNING_OBJECT (typefind, "could not seek to required position %u, hope for the best", size);
+ if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink),
+ gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES,
+ size))) {
+ GST_WARNING_OBJECT (typefind,
+ "could not seek to required position %u, hope for the best", size);
}
}
gst_buffer_store_clear (typefind->store);
}
+
static guint64
find_element_get_length (gpointer data)
{
TypeFindEntry *entry = (TypeFindEntry *) data;
GstTypeFindElement *typefind = entry->self;
GstFormat format = GST_FORMAT_BYTES;
-
+
if (!typefind->stream_length_available) {
- GST_LOG_OBJECT (entry->self, "'%s' called get_length () but we know it's not available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_LOG_OBJECT (entry->self,
+ "'%s' called get_length () but we know it's not available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0;
}
if (entry->self->stream_length == 0) {
- typefind->stream_length_available = gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
- &format, &entry->self->stream_length);
+ typefind->stream_length_available =
+ gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
+ &format, &entry->self->stream_length);
if (format != GST_FORMAT_BYTES)
typefind->stream_length_available = FALSE;
if (!typefind->stream_length_available) {
- GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () but it's not available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (entry->self,
+ "'%s' called get_length () but it's not available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0;
} else {
- GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () and it's %"G_GUINT64_FORMAT" bytes",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
+ GST_DEBUG_OBJECT (entry->self,
+ "'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
}
}
-
+
return entry->self->stream_length;
}
static void
-gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
+gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_EOS:
- /* this should only happen when we got all available data */
- entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
- if (entry && entry->probability >= typefind->min_probability) {
- GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
- }
- stop_typefinding (typefind);
- gst_pad_event_default (pad, event);
- break;
- default:
- gst_data_unref (GST_DATA (event));
- break;
+ case GST_EVENT_EOS:
+ /* this should only happen when we got all available data */
+ entry =
+ (TypeFindEntry *) typefind->possibilities ? typefind->
+ possibilities->data : NULL;
+ if (entry && entry->probability >= typefind->min_probability) {
+ GST_INFO_OBJECT (typefind,
+ "'%s' is the best typefind left after we got all data, using it now (probability %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
+ entry->probability, entry->caps);
+ }
+ stop_typefinding (typefind);
+ gst_pad_event_default (pad, event);
+ break;
+ default:
+ gst_data_unref (GST_DATA (event));
+ break;
}
} else {
gst_pad_event_default (pad, event);
{
GstBuffer *buf;
TypeFindEntry *entry = (TypeFindEntry *) data;
-
- GST_LOG_OBJECT (entry->self, "'%s' called peek (%"G_GINT64_FORMAT", %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size);
+
+ GST_LOG_OBJECT (entry->self, "'%s' called peek (%" G_GINT64_FORMAT ", %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size);
if (offset >= 0) {
buf = gst_buffer_store_get_buffer (entry->self->store, offset, size);
} else {
if (length == 0) {
buf = NULL;
} else {
- buf = gst_buffer_store_get_buffer (entry->self->store, length + offset, size);
+ buf =
+ gst_buffer_store_get_buffer (entry->self->store, length + offset,
+ size);
}
}
return GST_BUFFER_DATA (buf);
} else {
if (entry->requested_size == 0) {
- GST_LOG_OBJECT (entry->self, "setting requested peek (%"G_GINT64_FORMAT", %u) on '%s'",
- offset, size, GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_LOG_OBJECT (entry->self,
+ "setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset,
+ size, GST_PLUGIN_FEATURE_NAME (entry->factory));
entry->requested_offset = offset;
entry->requested_size = size;
}
}
}
static void
-find_suggest (gpointer data, guint probability, const GstCaps *caps)
+find_suggest (gpointer data, guint probability, const GstCaps * caps)
{
TypeFindEntry *entry = (TypeFindEntry *) data;
-
- GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")",
- GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
+
+ GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps);
if (((gint) probability) > entry->probability) {
entry->probability = probability;
gst_caps_replace (&entry->caps, gst_caps_copy (caps));
return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank;
}
static void
-gst_type_find_element_chain (GstPad *pad, GstData *data)
+gst_type_find_element_chain (GstPad * pad, GstData * data)
{
GstTypeFindElement *typefind;
GList *entries;
TypeFindEntry *entry;
GList *walk;
- GstTypeFind find = {find_peek, find_suggest, NULL, find_element_get_length };
+ GstTypeFind find = { find_peek, find_suggest, NULL, find_element_get_length };
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (GST_IS_EVENT (data)) {
case MODE_NORMAL:
gst_pad_push (typefind->src, data);
return;
- case MODE_TYPEFIND: {
+ case MODE_TYPEFIND:{
guint64 current_offset;
-
+
gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data));
- current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ?
- GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) :
+ current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ?
+ GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) :
gst_buffer_store_get_size (typefind->store, 0);
gst_data_unref (data);
if (typefind->possibilities == NULL) {
/* not yet started, get all typefinding functions into our "queue" */
GList *all_factories = gst_type_find_factory_get_list ();
- GST_INFO_OBJECT (typefind, "starting with %u typefinding functions",
- g_list_length ((GList *) all_factories));
-
+
+ GST_INFO_OBJECT (typefind, "starting with %u typefinding functions",
+ g_list_length ((GList *) all_factories));
+
all_factories = g_list_sort (all_factories, compare_type_find_factory);
walk = all_factories;
while (all_factories) {
entry = new_entry ();
-
+
entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data);
entry->self = typefind;
entry->probability = 0;
- typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
+ typefind->possibilities =
+ g_list_prepend (typefind->possibilities, entry);
all_factories = g_list_next (all_factories);
}
g_list_free (all_factories);
}
/* call every typefind function once */
walk = entries = typefind->possibilities;
- GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", g_list_length (entries));
+ GST_INFO_OBJECT (typefind, "iterating %u typefinding functions",
+ g_list_length (entries));
typefind->possibilities = NULL;
while (walk) {
find.data = entry = (TypeFindEntry *) walk->data;
gst_type_find_factory_call_function (entry->factory, &find);
free_entry_buffers (entry);
if (entry->probability == 0 && entry->requested_size == 0) {
- GST_DEBUG_OBJECT (typefind, "'%s' was removed - no chance of being the right plugin",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was removed - no chance of being the right plugin",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry);
} else if (entry->probability >= typefind->max_probability) {
/* wooha, got caps */
GstCaps *found_caps = entry->caps;
guint probability = entry->probability;
-
- GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW",
- GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability);
+
+ GST_INFO_OBJECT (typefind,
+ "'%s' returned %u/%u probability, using it NOW",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), probability,
+ typefind->max_probability);
while (walk) {
free_entry ((TypeFindEntry *) walk->data);
walk = g_list_next (walk);
walk = g_list_next (walk);
}
typefind->possibilities = NULL;
- g_list_free (typefind->possibilities);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps);
+ g_list_free (typefind->possibilities);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
+ probability, found_caps);
free_entry (entry);
} else {
- typefind->possibilities = g_list_prepend (typefind->possibilities, entry);
+ typefind->possibilities =
+ g_list_prepend (typefind->possibilities, entry);
}
}
g_list_free (entries);
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
} else {
/* set up typefind element for next iteration */
- typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry);
-
+ typefind->possibilities =
+ g_list_sort (typefind->possibilities, compare_type_find_entry);
+
/* look for typefind functions that require data without seeking */
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data;
gint64 seek_offset;
GstEvent *event;
- seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
- find_element_get_length (entry) + entry->requested_offset;
- seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
- event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
+ seek_offset =
+ entry->requested_offset >
+ 0 ? entry->
+ requested_offset : find_element_get_length (entry) +
+ entry->requested_offset;
+ seek_offset +=
+ gst_buffer_store_get_size (typefind->store, seek_offset);
+ event =
+ gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET,
+ seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
- GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
- GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was reset - seeked to %" G_GINT64_FORMAT,
+ GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
- GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
- GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
+ GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}
walk = g_list_next (typefind->possibilities);
while (walk) {
GList *cur = walk;
+
entry = (TypeFindEntry *) walk->data;
walk = g_list_next (walk);
if (entry->requested_size == 0) {
- GST_DEBUG_OBJECT (typefind, "'%s' was removed - higher possibilities available",
- GST_PLUGIN_FEATURE_NAME (entry->factory));
+ GST_DEBUG_OBJECT (typefind,
+ "'%s' was removed - higher possibilities available",
+ GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry);
- typefind->possibilities = g_list_delete_link (typefind->possibilities, cur);
+ typefind->possibilities =
+ g_list_delete_link (typefind->possibilities, cur);
}
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > typefind->min_probability) {
- GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
- GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
- g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
+ GST_INFO_OBJECT (typefind,
+ "'%s' is the only typefind left, using it now (probability %u)",
+ GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
+ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
+ 0, entry->probability, entry->caps);
free_entry (entry);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
}
}
static GstElementStateReturn
-gst_type_find_element_change_state (GstElement *element)
+gst_type_find_element_change_state (GstElement * element)
{
GstTypeFindElement *typefind;
default:
break;
}
-
+
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
#include "gstbufferstore.h"
G_BEGIN_DECLS
-
-
-
#define GST_TYPE_TYPE_FIND_ELEMENT (gst_type_find_element_get_type ())
#define GST_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElement))
#define GST_IS_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_ELEMENT))
#define GST_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass))
#define GST_IS_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_ELEMENT))
#define GST_TYPE_FIND_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass))
+typedef struct _GstTypeFindElement GstTypeFindElement;
+typedef struct _GstTypeFindElementClass GstTypeFindElementClass;
-typedef struct _GstTypeFindElement GstTypeFindElement;
-typedef struct _GstTypeFindElementClass GstTypeFindElementClass;
+struct _GstTypeFindElement
+{
+ GstElement element;
-struct _GstTypeFindElement {
- GstElement element;
+ GstPad *sink;
+ GstPad *src;
- GstPad * sink;
- GstPad * src;
+ guint min_probability;
+ guint max_probability;
+ GstCaps *caps;
- guint min_probability;
- guint max_probability;
- GstCaps * caps;
+ guint mode;
+ GstBufferStore *store;
+ guint64 stream_length;
+ gboolean stream_length_available;
- guint mode;
- GstBufferStore * store;
- guint64 stream_length;
- gboolean stream_length_available;
-
- GList * possibilities;
+ GList *possibilities;
};
-struct _GstTypeFindElementClass {
- GstElementClass parent_class;
+struct _GstTypeFindElementClass
+{
+ GstElementClass parent_class;
/* signals */
- void (*have_type) (GstTypeFindElement *element,
- guint probability,
- const GstCaps * caps);
+ void (*have_type) (GstTypeFindElement * element,
+ guint probability, const GstCaps * caps);
};
GType gst_type_find_element_get_type (void);
G_END_DECLS
-
#endif /* __GST_TYPE_FIND_ELEMENT_H__ */
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FILE_INDEX))
#define GST_IS_FILE_INDEX_CLASS(obj) \
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FILE_INDEX))
-
+
#ifndef __FUNCTION__
#define __FUNCTION__ "Unavailable"
#endif
/*
* Each array element is (32bits flags, nformats * 64bits)
*/
-typedef struct {
- gint id;
- gchar *id_desc;
- gint nformats;
- GstFormat *format;
- GArray *array;
+typedef struct
+{
+ gint id;
+ gchar *id_desc;
+ gint nformats;
+ GstFormat *format;
+ GArray *array;
} GstFileIndexId;
typedef struct _GstFileIndex GstFileIndex;
#define ARRAY_ROW_VALUE(_row,_vx) \
(*(gint64*) (((gchar*)(_row)) + sizeof (gint32) + (_vx) * sizeof (gint64)))
-GST_DEBUG_CATEGORY_STATIC(DC);
+GST_DEBUG_CATEGORY_STATIC (DC);
-struct _GstFileIndex {
- GstIndex parent;
+struct _GstFileIndex
+{
+ GstIndex parent;
- gchar *location;
- gboolean is_loaded;
- GSList *unresolved;
- gint next_id;
- GHashTable *id_index;
+ gchar *location;
+ gboolean is_loaded;
+ GSList *unresolved;
+ gint next_id;
+ GHashTable *id_index;
- GstIndexEntry *ret_entry; /* hack to avoid leaking memory */
+ GstIndexEntry *ret_entry; /* hack to avoid leaking memory */
};
-struct _GstFileIndexClass {
+struct _GstFileIndexClass
+{
GstIndexClass parent_class;
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
};
-static void gst_file_index_class_init (GstFileIndexClass *klass);
-static void gst_file_index_init (GstFileIndex *index);
-static void gst_file_index_dispose (GObject *object);
+static void gst_file_index_class_init (GstFileIndexClass * klass);
+static void gst_file_index_init (GstFileIndex * index);
+static void gst_file_index_dispose (GObject * object);
static void
-gst_file_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+gst_file_index_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
static void
-gst_file_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+gst_file_index_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static gboolean
-gst_file_index_get_writer_id (GstIndex *_index, gint *id, gchar *writer_string);
+gst_file_index_get_writer_id (GstIndex * _index, gint * id,
+ gchar * writer_string);
-static void gst_file_index_commit (GstIndex *index, gint writer_id);
-static void gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry);
-static GstIndexEntry* gst_file_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+static void gst_file_index_commit (GstIndex * index, gint writer_id);
+static void gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry);
+static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
#define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index))
static GstIndex *parent_class = NULL;
GType
-gst_file_index_get_type(void) {
+gst_file_index_get_type (void)
+{
static GType file_index_type = 0;
if (!file_index_type) {
static const GTypeInfo file_index_info = {
- sizeof(GstFileIndexClass),
+ sizeof (GstFileIndexClass),
NULL,
NULL,
- (GClassInitFunc)gst_file_index_class_init,
+ (GClassInitFunc) gst_file_index_class_init,
NULL,
NULL,
- sizeof(GstFileIndex),
+ sizeof (GstFileIndex),
1,
- (GInstanceInitFunc)gst_file_index_init,
+ (GInstanceInitFunc) gst_file_index_init,
NULL
};
- file_index_type = g_type_register_static(GST_TYPE_INDEX, "GstFileIndex", &file_index_info, 0);
+ file_index_type =
+ g_type_register_static (GST_TYPE_INDEX, "GstFileIndex",
+ &file_index_info, 0);
}
return file_index_type;
}
static void
-gst_file_index_class_init (GstFileIndexClass *klass)
+gst_file_index_class_init (GstFileIndexClass * klass)
{
GObjectClass *gobject_class;
GstIndexClass *gstindex_class;
- gobject_class = (GObjectClass*)klass;
- gstindex_class = (GstIndexClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstindex_class = (GstIndexClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_INDEX);
+ parent_class = g_type_class_ref (GST_TYPE_INDEX);
- gobject_class->dispose = gst_file_index_dispose;
- gobject_class->set_property = gst_file_index_set_property;
- gobject_class->get_property = gst_file_index_get_property;
+ gobject_class->dispose = gst_file_index_dispose;
+ gobject_class->set_property = gst_file_index_set_property;
+ gobject_class->get_property = gst_file_index_get_property;
- gstindex_class->add_entry = gst_file_index_add_entry;
+ gstindex_class->add_entry = gst_file_index_add_entry;
gstindex_class->get_assoc_entry = gst_file_index_get_assoc_entry;
- gstindex_class->commit = gst_file_index_commit;
- gstindex_class->get_writer_id = gst_file_index_get_writer_id ;
+ gstindex_class->commit = gst_file_index_commit;
+ gstindex_class->get_writer_id = gst_file_index_get_writer_id;
g_object_class_install_property (gobject_class, ARG_LOCATION,
- g_param_spec_string ("location", "File Location",
- "Location of the index file",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("location", "File Location",
+ "Location of the index file", NULL, G_PARAM_READWRITE));
}
static void
-gst_file_index_init (GstFileIndex *index)
+gst_file_index_init (GstFileIndex * index)
{
- GST_DEBUG ( "created new file index");
+ GST_DEBUG ("created new file index");
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
}
static void
-_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped)
+_file_index_id_free (GstFileIndexId * index_id, gboolean is_mmapped)
{
if (index_id->id_desc)
g_free (index_id->id_desc);
g_free (index_id->format);
if (index_id->array) {
if (is_mmapped)
- munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
+ munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
g_array_free (index_id->array, !is_mmapped);
}
g_free (index_id);
}
static gboolean
-_id_index_free_helper (gpointer _key, GstFileIndexId *index_id,
- GstFileIndex *index)
+_id_index_free_helper (gpointer _key, GstFileIndexId * index_id,
+ GstFileIndex * index)
{
_file_index_id_free (index_id, index->is_loaded);
return TRUE;
}
static void
-gst_file_index_dispose (GObject *object)
+gst_file_index_dispose (GObject * object)
{
GstFileIndex *index = GST_FILE_INDEX (object);
{
GSList *elem;
+
for (elem = index->unresolved; elem; elem = g_slist_next (elem))
_file_index_id_free (elem->data, index->is_loaded);
g_slist_free (index->unresolved);
index->unresolved = NULL;
}
-
+
g_hash_table_foreach_steal (index->id_index,
- (GHRFunc) _id_index_free_helper, index);
+ (GHRFunc) _id_index_free_helper, index);
g_hash_table_destroy (index->id_index);
index->id_index = NULL;
- gst_index_entry_free (index->ret_entry); /* hack */
+ gst_index_entry_free (index->ret_entry); /* hack */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
-struct fi_find_writer_context {
+struct fi_find_writer_context
+{
const gchar *writer_string;
GstFileIndexId *ii;
};
{
struct fi_find_writer_context *cx = data;
GstFileIndexId *ii = val;
+
if (strcmp (ii->id_desc, cx->writer_string) == 0)
cx->ii = ii;
}
static gboolean
-gst_file_index_get_writer_id (GstIndex *_index,
- gint *id, gchar *writer_string)
+gst_file_index_get_writer_id (GstIndex * _index,
+ gint * id, gchar * writer_string)
{
GstFileIndex *index = GST_FILE_INDEX (_index);
GSList *pending = index->unresolved;
for (elem = pending; elem; elem = g_slist_next (elem)) {
GstFileIndexId *ii = elem->data;
+
if (strcmp (ii->id_desc, writer_string) != 0) {
index->unresolved = g_slist_prepend (index->unresolved, ii);
continue;
}
-
+
if (match) {
GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'",
- writer_string);
+ writer_string);
continue;
}
if (!match) {
struct fi_find_writer_context cx;
+
cx.writer_string = writer_string;
cx.ii = NULL;
g_hash_table_foreach (index->id_index, _fi_find_writer, &cx);
if (cx.ii) {
match = TRUE;
GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again",
- writer_string);
- }
- else
+ writer_string);
+ } else
GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'",
- writer_string);
+ writer_string);
}
return match;
}
static void
-_fc_alloc_array (GstFileIndexId *id_index)
+_fc_alloc_array (GstFileIndexId * id_index)
{
g_assert (!id_index->array);
id_index->array =
- g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0);
+ g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0);
}
static void
-gst_file_index_load (GstFileIndex *index)
+gst_file_index_load (GstFileIndex * index)
{
xmlDocPtr doc;
xmlNodePtr root, part;
GError *err = NULL;
gchar *buf;
gsize len;
+
g_file_get_contents (path, &buf, &len, &err);
g_free (path);
if (err) {
GST_CAT_ERROR_OBJECT (DC, index, "root node isn't a gstfileindex");
return;
}
-
+
val = xmlGetProp (root, "version");
if (!val || atoi (val) != 1) {
GST_CAT_ERROR_OBJECT (DC, index, "version != 1");
for (part = root->children; part; part = part->next) {
if (strcmp (part->name, "writers") == 0) {
xmlNodePtr writer;
+
for (writer = part->children; writer; writer = writer->next) {
xmlChar *datafile = xmlGetProp (writer, "datafile");
gchar *path = g_strdup_printf ("%s/%s", index->location, datafile);
g_free (path);
if (fd < 0) {
GST_CAT_ERROR_OBJECT (DC, index,
- "Can't open '%s': %s", path, strerror (errno));
+ "Can't open '%s': %s", path, strerror (errno));
continue;
}
for (wpart = writer->children; wpart; wpart = wpart->next) {
if (strcmp (wpart->name, "formats") == 0) {
xmlChar *count_str = xmlGetProp (wpart, "count");
- gint fx=0;
+ gint fx = 0;
xmlNodePtr format;
id_index->nformats = atoi (count_str);
id_index->format = g_new (GstFormat, id_index->nformats);
- for (format = wpart->children;
- format; format = format->next) {
+ for (format = wpart->children; format; format = format->next) {
xmlChar *nick = xmlGetProp (format, "nick");
GstFormat fmt = gst_format_get_by_nick (nick);
+
if (fmt == GST_FORMAT_UNDEFINED)
- GST_CAT_ERROR_OBJECT (DC, index,
- "format '%s' undefined", nick);
+ GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick);
g_assert (fx < id_index->nformats);
id_index->format[fx++] = fmt;
free (nick);
g_assert (id_index->nformats > 0);
_fc_alloc_array (id_index);
- g_assert (id_index->array->data == NULL); /* little bit risky */
+ g_assert (id_index->array->data == NULL); /* little bit risky */
entries_str = xmlGetProp (writer, "entries");
id_index->array->len = atoi (entries_str);
free (entries_str);
array_data =
- mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, 0);
+ mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd,
+ 0);
close (fd);
if (array_data == MAP_FAILED) {
GST_CAT_ERROR_OBJECT (DC, index,
- "mmap %s failed: %s", path, strerror (errno));
+ "mmap %s failed: %s", path, strerror (errno));
continue;
}
}
static void
-gst_file_index_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_file_index_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstFileIndex *index = GST_FILE_INDEX (object);
switch (prop_id) {
- case ARG_LOCATION:
- if (index->location)
- g_free (index->location);
- index->location = g_value_dup_string (value);
+ case ARG_LOCATION:
+ if (index->location)
+ g_free (index->location);
+ index->location = g_value_dup_string (value);
- if (index->location && !g_hash_table_size (index->id_index))
- gst_file_index_load (index);
- break;
+ if (index->location && !g_hash_table_size (index->id_index))
+ gst_file_index_load (index);
+ break;
}
}
static void
-gst_file_index_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_file_index_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstFileIndex *index = GST_FILE_INDEX (object);
-
+
switch (prop_id) {
- case ARG_LOCATION:
- g_value_set_string (value, index->location);
- break;
+ case ARG_LOCATION:
+ g_value_set_string (value, index->location);
+ break;
}
}
static void
-_file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers)
+_file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers)
{
const gint bufsize = 16;
gchar buf[bufsize];
xmlNodePtr writer;
xmlNodePtr formats;
gint xx;
-
+
if (!ii->array) {
GST_INFO ("Index for %s is empty", ii->id_desc);
return;
xmlSetProp (writer, "id", ii->id_desc);
g_snprintf (buf, bufsize, "%d", ii->array->len);
xmlSetProp (writer, "entries", buf);
- g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */
+ g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */
xmlSetProp (writer, "datafile", buf);
formats = xmlNewChild (writer, NULL, "formats", NULL);
g_snprintf (buf, bufsize, "%d", ii->nformats);
xmlSetProp (formats, "count", buf);
- for (xx=0; xx < ii->nformats; xx++) {
+ for (xx = 0; xx < ii->nformats; xx++) {
xmlNodePtr format = xmlNewChild (formats, NULL, "format", NULL);
- const GstFormatDefinition* def =
- gst_format_get_details (ii->format[xx]);
+ const GstFormatDefinition *def = gst_format_get_details (ii->format[xx]);
+
xmlSetProp (format, "nick", def->nick);
}
}
padding since the page size isn't fixed.
*/
static void
-_file_index_id_save_entries (gpointer *_key,
- GstFileIndexId *ii,
- gchar *prefix)
+_file_index_id_save_entries (gpointer * _key,
+ GstFileIndexId * ii, gchar * prefix)
{
GError *err;
gchar *path;
path = g_strdup_printf ("%s/%d", prefix, ii->id);
chan = g_io_channel_new_file (path, "w", &err);
g_free (path);
- if (err) goto fail;
-
+ if (err)
+ goto fail;
+
g_io_channel_set_encoding (chan, NULL, &err);
- if (err) goto fail;
+ if (err)
+ goto fail;
g_io_channel_write_chars (chan,
- ii->array->data,
- ARRAY_TOTAL_SIZE (ii),
- NULL,
- &err);
- if (err) goto fail;
+ ii->array->data, ARRAY_TOTAL_SIZE (ii), NULL, &err);
+ if (err)
+ goto fail;
g_io_channel_shutdown (chan, TRUE, &err);
- if (err) goto fail;
+ if (err)
+ goto fail;
g_io_channel_unref (chan);
return;
- fail:
+fail:
GST_CAT_ERROR (DC, "%s", err->message);
}
gst_index_commit (index, -1);
*/
static void
-gst_file_index_commit (GstIndex *_index, gint _writer_id)
+gst_file_index_commit (GstIndex * _index, gint _writer_id)
{
GstFileIndex *index = GST_FILE_INDEX (_index);
xmlDocPtr doc;
writers = xmlNewChild (doc->xmlRootNode, NULL, "writers", NULL);
g_hash_table_foreach (index->id_index,
- (GHFunc) _file_index_id_save_xml, writers);
+ (GHFunc) _file_index_id_save_xml, writers);
- if (mkdir (index->location, 0777) &&
- errno != EEXIST) {
+ if (mkdir (index->location, 0777) && errno != EEXIST) {
GST_CAT_ERROR_OBJECT (DC, index,
- "mkdir %s: %s", index->location, strerror (errno));
+ "mkdir %s: %s", index->location, strerror (errno));
return;
}
path = g_strdup_printf ("%s/gstindex.xml", index->location);
- tocfile =
- g_io_channel_new_file (path, "w", &err);
+ tocfile = g_io_channel_new_file (path, "w", &err);
g_free (path);
if (err) {
GST_CAT_ERROR_OBJECT (DC, index, "%s", err->message);
{
xmlChar *xmlmem;
int xmlsize;
+
xmlDocDumpMemory (doc, &xmlmem, &xmlsize);
g_io_channel_write_chars (tocfile, xmlmem, xmlsize, NULL, &err);
if (err) {
g_io_channel_unref (tocfile);
g_hash_table_foreach (index->id_index,
- (GHFunc) _file_index_id_save_entries,
- index->location);
+ (GHFunc) _file_index_id_save_entries, index->location);
}
static void
-gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_id (GstIndex * index, GstIndexEntry * entry)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
of non-exact matches. */
static gboolean
-_fc_bsearch (GArray * ary,
- gint stride,
- gint * ret,
- GCompareDataFunc compare,
- gconstpointer sample,
- gpointer user_data)
+_fc_bsearch (GArray * ary,
+ gint stride,
+ gint * ret,
+ GCompareDataFunc compare, gconstpointer sample, gpointer user_data)
{
gint first, last;
gint mid;
g_return_val_if_fail (compare, FALSE);
- if (!ary->len)
- {
- if (ret) *ret = 0;
- return FALSE;
- }
+ if (!ary->len) {
+ if (ret)
+ *ret = 0;
+ return FALSE;
+ }
first = 0;
last = ary->len - 1;
midsize = last - first;
-
+
while (midsize > 1) {
mid = first + midsize / 2;
-
- cmp = (*compare) (sample, ary->data + mid*stride, user_data);
-
- if (cmp == 0)
- {
- /* if there are multiple matches then scan for the first match */
- while (mid > 0 &&
- (*compare) (sample,
- ary->data + (mid - 1) * stride,
- user_data) == 0)
- --mid;
-
- if (ret) *ret = mid;
- return TRUE;
- }
-
+
+ cmp = (*compare) (sample, ary->data + mid * stride, user_data);
+
+ if (cmp == 0) {
+ /* if there are multiple matches then scan for the first match */
+ while (mid > 0 &&
+ (*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0)
+ --mid;
+
+ if (ret)
+ *ret = mid;
+ return TRUE;
+ }
+
if (cmp < 0)
- last = mid-1;
+ last = mid - 1;
else
- first = mid+1;
-
+ first = mid + 1;
+
midsize = last - first;
}
- for (tx = first; tx <= last; tx++)
- {
- cmp = (*compare) (sample, ary->data + tx*stride, user_data);
+ for (tx = first; tx <= last; tx++) {
+ cmp = (*compare) (sample, ary->data + tx * stride, user_data);
- if (cmp < 0)
- {
- if (ret) *ret = tx;
- return FALSE;
- }
- if (cmp == 0)
- {
- if (ret) *ret = tx;
- return TRUE;
- }
+ if (cmp < 0) {
+ if (ret)
+ *ret = tx;
+ return FALSE;
}
+ if (cmp == 0) {
+ if (ret)
+ *ret = tx;
+ return TRUE;
+ }
+ }
- if (ret) *ret = last+1;
+ if (ret)
+ *ret = last + 1;
return FALSE;
}
static gint
-file_index_compare (gconstpointer sample,
- gconstpointer row,
- gpointer user_data)
+file_index_compare (gconstpointer sample, gconstpointer row, gpointer user_data)
{
//GstFileIndexId *id_index = user_data;
const GstIndexAssociation *ca = sample;
gint64 val2_be = ARRAY_ROW_VALUE (row, ca->format);
gint64 val2 = GINT64_FROM_BE (val2_be);
gint64 diff = val2 - val1;
+
return (diff == 0 ? 0 : (diff < 0 ? 1 : -1));
}
static void
-gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
if (!id_index->nformats) {
gint fx;
+
id_index->nformats = GST_INDEX_NASSOCS (entry);
GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d",
- id_index->nformats, entry->id);
+ id_index->nformats, entry->id);
id_index->format = g_new (GstFormat, id_index->nformats);
- for (fx=0; fx < id_index->nformats; fx++)
+ for (fx = 0; fx < id_index->nformats; fx++)
id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx);
_fc_alloc_array (id_index);
} else {
/* only sanity checking */
if (id_index->nformats != GST_INDEX_NASSOCS (entry))
GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d",
- id_index->nformats, GST_INDEX_NASSOCS (entry));
+ id_index->nformats, GST_INDEX_NASSOCS (entry));
else {
gint fx;
- for (fx=0; fx < id_index->nformats; fx++)
+
+ for (fx = 0; fx < id_index->nformats; fx++)
if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx))
GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d",
- fx, id_index->format[fx],
- GST_INDEX_ASSOC_FORMAT (entry, fx));
+ fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx));
}
}
sample.value = GST_INDEX_ASSOC_VALUE (entry, 0);
exact =
- _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
- &mx, file_index_compare,
- &sample, id_index);
+ _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
+ &mx, file_index_compare, &sample, id_index);
if (exact) {
/* maybe overwrite instead? */
GST_CAT_DEBUG_OBJECT (DC, index,
- "Ignoring duplicate index association at %lld",
- GST_INDEX_ASSOC_VALUE (entry, 0));
+ "Ignoring duplicate index association at %lld",
+ GST_INDEX_ASSOC_VALUE (entry, 0));
return;
}
gint fx;
gint32 flags_host = GST_INDEX_ASSOC_FLAGS (entry);
+
ARRAY_ROW_FLAGS (row_data) = GINT32_TO_BE (flags_host);
for (fx = 0; fx < id_index->nformats; fx++) {
gint64 val_host = GST_INDEX_ASSOC_VALUE (entry, fx);
+
ARRAY_ROW_VALUE (row_data, fx) = GINT64_TO_BE (val_host);
}
*/
static void
-gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry)
+gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry)
{
GST_LOG_OBJECT (index, "adding this entry");
- switch (entry->type){
- case GST_INDEX_ENTRY_ID:
- gst_file_index_add_id (index, entry);
- break;
- case GST_INDEX_ENTRY_ASSOCIATION:
- gst_file_index_add_association (index, entry);
- break;
- case GST_INDEX_ENTRY_OBJECT:
- GST_CAT_ERROR_OBJECT (DC, index,
- "gst_file_index_add_object not implemented");
- break;
- case GST_INDEX_ENTRY_FORMAT:
- /*
- We infer the formats from the entry itself so this type of
- GST_INDEX_ENTRY_* can probably go away.
+ switch (entry->type) {
+ case GST_INDEX_ENTRY_ID:
+ gst_file_index_add_id (index, entry);
+ break;
+ case GST_INDEX_ENTRY_ASSOCIATION:
+ gst_file_index_add_association (index, entry);
+ break;
+ case GST_INDEX_ENTRY_OBJECT:
+ GST_CAT_ERROR_OBJECT (DC, index,
+ "gst_file_index_add_object not implemented");
+ break;
+ case GST_INDEX_ENTRY_FORMAT:
+ /*
+ We infer the formats from the entry itself so this type of
+ GST_INDEX_ENTRY_* can probably go away.
*/
- GST_CAT_DEBUG_OBJECT (DC, index,
- "gst_file_index_add_format not implemented");
- break;
- default:
- break;
+ GST_CAT_DEBUG_OBJECT (DC, index,
+ "gst_file_index_add_format not implemented");
+ break;
+ default:
+ break;
}
}
-static GstIndexEntry*
-gst_file_index_get_assoc_entry (GstIndex *index,
- gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format,
- gint64 value,
- GCompareDataFunc _ignore_func,
- gpointer _ignore_user_data)
+static GstIndexEntry *
+gst_file_index_get_assoc_entry (GstIndex * index,
+ gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format,
+ gint64 value, GCompareDataFunc _ignore_func, gpointer _ignore_user_data)
{
GstFileIndex *fileindex = GST_FILE_INDEX (index);
GstFileIndexId *id_index;
return NULL;
}
- for (fx=0; fx < id_index->nformats; fx++)
- if (id_index->format[fx] == format)
- { formatx = fx; break; }
+ for (fx = 0; fx < id_index->nformats; fx++)
+ if (id_index->format[fx] == format) {
+ formatx = fx;
+ break;
+ }
if (formatx == -1) {
GST_CAT_WARNING_OBJECT (DC, fileindex,
- "%s, format %d not available", __FUNCTION__, format);
+ "%s, format %d not available", __FUNCTION__, format);
return NULL;
}
sample.value = value;
exact = _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
- &mx, file_index_compare, &sample, id_index);
+ &mx, file_index_compare, &sample, id_index);
if (!exact) {
if (method == GST_INDEX_LOOKUP_EXACT)
entry->type = GST_INDEX_ENTRY_ASSOCIATION;
GST_INDEX_NASSOCS (entry) = id_index->nformats;
- entry->data.assoc.assocs =
- g_new (GstIndexAssociation, id_index->nformats);
+ entry->data.assoc.assocs = g_new (GstIndexAssociation, id_index->nformats);
{
gint32 flags_be = ARRAY_ROW_FLAGS (row_data);
+
GST_INDEX_ASSOC_FLAGS (entry) = GINT32_FROM_BE (flags_be);
- for (xx=0; xx < id_index->nformats; xx++)
- {
- gint64 val_be = ARRAY_ROW_VALUE (row_data, xx);
- GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx];
- GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be);
- }
+ for (xx = 0; xx < id_index->nformats; xx++) {
+ gint64 val_be = ARRAY_ROW_VALUE (row_data, xx);
+
+ GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx];
+ GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be);
+ }
}
return entry;
}
gboolean
-gst_file_index_plugin_init (GstPlugin *plugin)
+gst_file_index_plugin_init (GstPlugin * plugin)
{
GstIndexFactory *factory;
- GST_DEBUG_CATEGORY_INIT(DC, "GST_FILEINDEX", 0, NULL);
+ GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL);
factory = gst_index_factory_new ("fileindex",
- "A index that stores entries in file",
- gst_file_index_get_type());
+ "A index that stores entries in file", gst_file_index_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
- }
- else {
+ } else {
GST_CAT_ERROR (DC, "could not register fileindex");
}
return TRUE;
#include <gst/gstversion.h>
#include <gst/gstplugin.h>
-extern gboolean gst_mem_index_plugin_init (GstPlugin *plugin);
-extern gboolean gst_file_index_plugin_init (GstPlugin *plugin);
+extern gboolean gst_mem_index_plugin_init (GstPlugin * plugin);
+extern gboolean gst_file_index_plugin_init (GstPlugin * plugin);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
gboolean res = TRUE;
res &= gst_mem_index_plugin_init (plugin);
res &= gst_file_index_plugin_init (plugin);
-
+
return res;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstindexers",
- "GStreamer core indexers",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstindexers",
+ "GStreamer core indexers",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX))
#define GST_IS_MEM_INDEX_CLASS(obj) \
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX))
-
+
/*
* Object model:
*
* then do a lookup in the Tree to get the required value.
*/
-typedef struct {
- GstFormat format;
- gint offset;
- GTree *tree;
+typedef struct
+{
+ GstFormat format;
+ gint offset;
+ GTree *tree;
} GstMemIndexFormatIndex;
-typedef struct {
- gint id;
- GHashTable *format_index;
+typedef struct
+{
+ gint id;
+ GHashTable *format_index;
} GstMemIndexId;
typedef struct _GstMemIndex GstMemIndex;
typedef struct _GstMemIndexClass GstMemIndexClass;
-struct _GstMemIndex {
- GstIndex parent;
+struct _GstMemIndex
+{
+ GstIndex parent;
- GList *associations;
+ GList *associations;
- GHashTable *id_index;
+ GHashTable *id_index;
};
-struct _GstMemIndexClass {
+struct _GstMemIndexClass
+{
GstIndexClass parent_class;
};
/* Index signals and args */
-enum {
+enum
+{
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_mem_index_class_init (GstMemIndexClass *klass);
-static void gst_mem_index_init (GstMemIndex *index);
-static void gst_mem_index_dispose (GObject *object);
+static void gst_mem_index_class_init (GstMemIndexClass * klass);
+static void gst_mem_index_init (GstMemIndex * index);
+static void gst_mem_index_dispose (GObject * object);
-static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry);
-static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method, GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data);
+static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry);
+static GstIndexEntry *gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method, GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
#define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index))
static GstIndex *parent_class = NULL;
+
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_mem_index_get_type(void) {
+gst_mem_index_get_type (void)
+{
static GType mem_index_type = 0;
if (!mem_index_type) {
static const GTypeInfo mem_index_info = {
- sizeof(GstMemIndexClass),
+ sizeof (GstMemIndexClass),
NULL,
NULL,
- (GClassInitFunc)gst_mem_index_class_init,
+ (GClassInitFunc) gst_mem_index_class_init,
NULL,
NULL,
- sizeof(GstMemIndex),
+ sizeof (GstMemIndex),
1,
- (GInstanceInitFunc)gst_mem_index_init,
+ (GInstanceInitFunc) gst_mem_index_init,
NULL
};
- mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0);
+ mem_index_type =
+ g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info,
+ 0);
}
return mem_index_type;
}
static void
-gst_mem_index_class_init (GstMemIndexClass *klass)
+gst_mem_index_class_init (GstMemIndexClass * klass)
{
GObjectClass *gobject_class;
GstIndexClass *gstindex_class;
- gobject_class = (GObjectClass*)klass;
- gstindex_class = (GstIndexClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstindex_class = (GstIndexClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_INDEX);
+ parent_class = g_type_class_ref (GST_TYPE_INDEX);
gobject_class->dispose = gst_mem_index_dispose;
- gstindex_class->add_entry = gst_mem_index_add_entry;
+ gstindex_class->add_entry = gst_mem_index_add_entry;
gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry;
}
static void
-gst_mem_index_init (GstMemIndex *index)
+gst_mem_index_init (GstMemIndex * index)
{
- GST_DEBUG ( "created new mem index");
+ GST_DEBUG ("created new mem index");
index->associations = NULL;
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
}
static void
-gst_mem_index_dispose (GObject *object)
+gst_mem_index_dispose (GObject * object)
{
//GstMemIndex *memindex = GST_MEM_INDEX (object);
}
static void
-gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_id (GstIndex * index, GstIndexEntry * entry)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
}
static gint
-mem_index_compare (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
+mem_index_compare (gconstpointer a, gconstpointer b, gpointer user_data)
{
GstMemIndexFormatIndex *index = user_data;
gint64 val1, val2;
gint64 diff;
- val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
- val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset);
-
+ val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
+ val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) b), index->offset);
+
diff = (val2 - val1);
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
}
static void
-gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc)
+gst_mem_index_index_format (GstMemIndexId * id_index, GstIndexEntry * entry,
+ gint assoc)
{
GstMemIndexFormatIndex *index;
GstFormat *format;
}
static void
-gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_association (GstIndex * index, GstIndexEntry * entry)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
}
static void
-gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_object (GstIndex * index, GstIndexEntry * entry)
{
}
static void
-gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_format (GstIndex * index, GstIndexEntry * entry)
{
}
static void
-gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry)
+gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry)
{
GST_LOG_OBJECT (index, "added this entry");
- switch (entry->type){
- case GST_INDEX_ENTRY_ID:
- gst_mem_index_add_id (index, entry);
- break;
- case GST_INDEX_ENTRY_ASSOCIATION:
- gst_mem_index_add_association (index, entry);
- break;
- case GST_INDEX_ENTRY_OBJECT:
- gst_mem_index_add_object (index, entry);
- break;
- case GST_INDEX_ENTRY_FORMAT:
- gst_mem_index_add_format (index, entry);
- break;
- default:
- break;
+ switch (entry->type) {
+ case GST_INDEX_ENTRY_ID:
+ gst_mem_index_add_id (index, entry);
+ break;
+ case GST_INDEX_ENTRY_ASSOCIATION:
+ gst_mem_index_add_association (index, entry);
+ break;
+ case GST_INDEX_ENTRY_OBJECT:
+ gst_mem_index_add_object (index, entry);
+ break;
+ case GST_INDEX_ENTRY_FORMAT:
+ gst_mem_index_add_format (index, entry);
+ break;
+ default:
+ break;
}
}
-typedef struct {
- gint64 value;
+typedef struct
+{
+ gint64 value;
GstMemIndexFormatIndex *index;
- gboolean exact;
- GstIndexEntry *lower;
- gint64 low_diff;
- GstIndexEntry *higher;
- gint64 high_diff;
+ gboolean exact;
+ GstIndexEntry *lower;
+ gint64 low_diff;
+ GstIndexEntry *higher;
+ gint64 high_diff;
} GstMemIndexSearchData;
static gint
-mem_index_search (gconstpointer a,
- gconstpointer b)
+mem_index_search (gconstpointer a, gconstpointer b)
{
GstMemIndexSearchData *data = (GstMemIndexSearchData *) b;
GstMemIndexFormatIndex *index = data->index;
gint64 val1, val2;
gint64 diff;
- val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
+ val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
val2 = data->value;
-
+
diff = (val1 - val2);
if (diff == 0)
return 0;
data->lower = (GstIndexEntry *) a;
}
diff = -1;
- }
- else {
+ } else {
if (diff < data->high_diff) {
data->high_diff = diff;
data->higher = (GstIndexEntry *) a;
return diff;
}
-static GstIndexEntry*
-gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
- GstIndexLookupMethod method,
- GstAssocFlags flags,
- GstFormat format, gint64 value,
- GCompareDataFunc func,
- gpointer user_data)
+static GstIndexEntry *
+gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
+ GstIndexLookupMethod method,
+ GstAssocFlags flags,
+ GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
{
GstMemIndex *memindex = GST_MEM_INDEX (index);
GstMemIndexId *id_index;
entry = g_tree_search (format_index->tree, mem_index_search, &data);
/* get the low/high values if we're not exact */
- if (entry == NULL && !data.exact) {
+ if (entry == NULL && !data.exact) {
if (method == GST_INDEX_LOOKUP_BEFORE)
entry = data.lower;
else if (method == GST_INDEX_LOOKUP_AFTER) {
while (l_entry) {
entry = (GstIndexEntry *) l_entry->data;
- if (entry->id == id &&
- (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
- break;
+ if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
+ break;
- if (method == GST_INDEX_LOOKUP_BEFORE)
- l_entry = g_list_next (l_entry);
- else if (method == GST_INDEX_LOOKUP_AFTER) {
- l_entry = g_list_previous (l_entry);
- }
+ if (method == GST_INDEX_LOOKUP_BEFORE)
+ l_entry = g_list_next (l_entry);
+ else if (method == GST_INDEX_LOOKUP_AFTER) {
+ l_entry = g_list_previous (l_entry);
+ }
}
}
}
}
gboolean
-gst_mem_index_plugin_init (GstPlugin *plugin)
+gst_mem_index_plugin_init (GstPlugin * plugin)
{
GstIndexFactory *factory;
factory = gst_index_factory_new ("memindex",
- "A index that stores entries in memory",
- gst_mem_index_get_type());
+ "A index that stores entries in memory", gst_mem_index_get_type ());
if (factory != NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
- }
- else {
+ } else {
g_warning ("could not register memindex");
}
return TRUE;
msgstr ""
"Project-Id-Version: gstreamer 0.7.6\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2004-03-09 16:16+0100\n"
+"POT-Creation-Date: 2004-03-11 11:33+0100\n"
"PO-Revision-Date: 2004-03-13 01:47+0100\n"
"Last-Translator: Danilo Segan <dsegan@gmx.net>\n"
"Language-Team: Serbian <gnu@prevod.org>\n"
msgstr "Испиши доступне категорије за налажење грешака и заврши"
#: gst/gst.c:125
-msgid "Default debug level from 1 (only error) to 5 (anything) or 0 for no output"
-msgstr "Подразумевани ниво опширности од 1 (само грешке) до 5 (све) или 0 (без излаза)"
+msgid ""
+"Default debug level from 1 (only error) to 5 (anything) or 0 for no output"
+msgstr ""
+"Подразумевани ниво опширности од 1 (само грешке) до 5 (све) или 0 (без "
+"излаза)"
#: gst/gst.c:125
msgid "LEVEL"
msgstr "НИВО"
#: gst/gst.c:126
-msgid "Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"
-msgstr "Запетом раздвојени списак парова име_категорије:ниво за постављање нарочитих нивоа за појединачне категорије. Пример: GST_AUTOPLUG:5,GST_ELEMENT_*:3"
+msgid ""
+"Comma-separated list of category_name:level pairs to set specific levels for "
+"the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"
+msgstr ""
+"Запетом раздвојени списак парова име_категорије:ниво за постављање нарочитих "
+"нивоа за појединачне категорије. Пример: GST_AUTOPLUG:5,GST_ELEMENT_*:3"
#: gst/gst.c:126
msgid "LIST"
msgstr "ПУТАЊЕ"
#: gst/gst.c:134
-msgid "Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"
-msgstr "Запетом раздвојен списак додатака који се предучитавају поред списка из променљиве окружења GST_PLUGIN_PATH"
+msgid ""
+"Comma-separated list of plugins to preload in addition to the list stored in "
+"env variable GST_PLUGIN_PATH"
+msgstr ""
+"Запетом раздвојен списак додатака који се предучитавају поред списка из "
+"променљиве окружења GST_PLUGIN_PATH"
#: gst/gst.c:134
msgid "PLUGINS"
msgstr "ГСтример је наишао на општу грешку у основној библиотеци."
#: gst/gsterror.c:58 gst/gsterror.c:94 gst/gsterror.c:116 gst/gsterror.c:154
-msgid "GStreamer developers were too lazy to assign an error code to this error. Please file a bug."
-msgstr "Програмери ГСтримера су били сувише лењи да доделе код за ову грешку. Пријавите грешку."
+msgid ""
+"GStreamer developers were too lazy to assign an error code to this error. "
+"Please file a bug."
+msgstr ""
+"Програмери ГСтримера су били сувише лењи да доделе код за ову грешку. "
+"Пријавите грешку."
#: gst/gsterror.c:61
msgid "Internal GStreamer error: code not implemented. File a bug."
#: gst/gsterror.c:63
msgid "Internal GStreamer error: state change failed. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неуспешна промена стања. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неуспешна промена стања. Пријавите грешку."
#: gst/gsterror.c:65
msgid "Internal GStreamer error: pad problem. File a bug."
#: gst/gsterror.c:69
msgid "Internal GStreamer error: scheduler problem. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неприлика са распоређивачем. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неприлика са распоређивачем. Пријавите грешку."
#: gst/gsterror.c:71
msgid "Internal GStreamer error: negotiation problem. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неприлика у преговарању. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неприлика у преговарању. Пријавите грешку."
#: gst/gsterror.c:73
msgid "Internal GStreamer error: event problem. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неприлика са догађајем. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неприлика са догађајем. Пријавите грешку."
#: gst/gsterror.c:75
msgid "Internal GStreamer error: seek problem. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неприлика са тражењем. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неприлика са тражењем. Пријавите грешку."
# bug: is "caps" short for "capabilities"? if so, it should be spelled completely
#: gst/gsterror.c:77
msgid "Internal GStreamer error: caps problem. File a bug."
-msgstr "Унутрашња грешка у ГСтримеру: неприлика са могућностима. Пријавите грешку."
+msgstr ""
+"Унутрашња грешка у ГСтримеру: неприлика са могућностима. Пријавите грешку."
#: gst/gsterror.c:79
msgid "Internal GStreamer error: tag problem. File a bug."
#: gst/gsttag.c:147
msgid "International Standard Recording Code - see http://www.ifpi.org/isrc/"
-msgstr "Међународни стандардни код за снимање — видети http://www.ifpi.org/isrc/"
+msgstr ""
+"Међународни стандардни код за снимање — видети http://www.ifpi.org/isrc/"
#: gst/gsttag.c:151 gst/gsttag.c:152
msgid "organization"
#: gst/parse/grammar.y:337
#, c-format
-msgid "could not convert \"%s\" so that it fits property \"%s\" in element \"%s\""
-msgstr "не могу да претворим „%s“ тако да одговара особини „%s“ у елементу „%s“"
+msgid ""
+"could not convert \"%s\" so that it fits property \"%s\" in element \"%s\""
+msgstr ""
+"не могу да претворим „%s“ тако да одговара особини „%s“ у елементу „%s“"
#: gst/parse/grammar.y:525
#, c-format
#: tools/gst-launch.c:99
msgid "Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"
-msgstr "Употреба: gst-xmllaunch <датотека.xml> [ елемент.особина=вредност ... ]\n"
+msgstr ""
+"Употреба: gst-xmllaunch <датотека.xml> [ елемент.особина=вредност ... ]\n"
#: tools/gst-launch.c:107
#, c-format
*
*/
static gboolean
-populate (GstMemPool *mem_pool)
+populate (GstMemPool * mem_pool)
{
guint8 *area;
gint i;
area = (guint8 *) g_malloc (mem_pool->area_size);
- for (i=0; i < mem_pool->area_size; i += mem_pool->pool_size) {
+ for (i = 0; i < mem_pool->area_size; i += mem_pool->pool_size) {
guint8 *areap = area + i;
- GST_MEM_POOL_AREA (areap) = (GstMemPoolElement *)area;
+ GST_MEM_POOL_AREA (areap) = (GstMemPoolElement *) area;
if (mem_pool->alloc_func) {
mem_pool->alloc_func (mem_pool, GST_MEM_POOL_DATA (areap));
}
-GstMemPool*
-gst_mem_pool_new (gchar* name, gint atom_size, gulong area_size, gint type,
- GstMemPoolAllocFunc alloc_func,
- GstMemPoolFreeFunc free_func)
+GstMemPool *
+gst_mem_pool_new (gchar * name, gint atom_size, gulong area_size, gint type,
+ GstMemPoolAllocFunc alloc_func, GstMemPoolFreeFunc free_func)
{
GstMemPool *mem_pool;
mem_pool = g_malloc (sizeof (GstMemPool));
mem_pool->pool_size = atom_size + sizeof (GstMemPoolElement);
- area_size = (area_size/atom_size) * mem_pool->pool_size;
+ area_size = (area_size / atom_size) * mem_pool->pool_size;
mem_pool->name = g_strdup (name);
mem_pool->free = NULL;
}
void
-gst_mem_pool_destroy (GstMemPool *mem_pool)
+gst_mem_pool_destroy (GstMemPool * mem_pool)
{
GHashTable *elements = g_hash_table_new (NULL, NULL);
gpointer data;
while (data) {
GstMemPoolElement *elem = GST_MEM_POOL_LINK (data);
- g_hash_table_insert (elements, GST_MEM_POOL_AREA (elem), NULL);
-
+ g_hash_table_insert (elements, GST_MEM_POOL_AREA (elem), NULL);
+
data = gst_mem_pool_alloc (mem_pool);
- }
+ }
g_hash_table_foreach_remove (elements, free_area, NULL);
g_hash_table_destroy (elements);
}
gpointer
-gst_mem_pool_alloc (GstMemPool *mem_pool)
+gst_mem_pool_alloc (GstMemPool * mem_pool)
{
volatile GstMemPoolElement *pool = NULL;
-
+
g_return_val_if_fail (mem_pool != NULL, NULL);
again:
#if defined(USE_ASM) && defined(HAVE_CPU_I386)
- __asm__ __volatile__ (" testl %%eax, %%eax \n\t"
- " jz 20f \n"
- "10: \t"
- " movl (%%eax), %%ebx \n\t"
- " movl %%edx, %%ecx \n\t"
- " incl %%ecx \n\t"
- POOL_LOCK "cmpxchg8b %1 \n\t"
- " jz 20f \n\t"
- " testl %%eax, %%eax \n\t"
- " jnz 10b \n"
- "20:\t"
- :"=a" (pool)
- :"m" (*mem_pool), "a" (mem_pool->free), "d" (mem_pool->cnt)
- :"ecx", "ebx");
+__asm__ __volatile__ (" testl %%eax, %%eax \n\t" " jz 20f \n" "10: \t" " movl (%%eax), %%ebx \n\t" " movl %%edx, %%ecx \n\t" " incl %%ecx \n\t" POOL_LOCK "cmpxchg8b %1 \n\t" " jz 20f \n\t" " testl %%eax, %%eax \n\t" " jnz 10b \n" "20:\t":"=a" (pool)
+: "m" (*mem_pool), "a" (mem_pool->free), "d" (mem_pool->cnt)
+: "ecx", "ebx");
#else
g_mutex_lock (mem_pool->chunk_lock);
if (mem_pool->free) {
/*g_print ("extending\n"); */
if (populate (mem_pool))
goto again;
- else
+ else
return NULL;
}
return GST_MEM_POOL_DATA (pool);
}
gpointer
-gst_mem_pool_alloc0 (GstMemPool *mem_pool)
+gst_mem_pool_alloc0 (GstMemPool * mem_pool)
{
gpointer mem = gst_mem_pool_alloc (mem_pool);
if (mem)
memset (mem, 0, mem_pool->atom_size);
-
+
return mem;
}
void
-gst_mem_pool_free (GstMemPool *mem_pool, gpointer mem)
+gst_mem_pool_free (GstMemPool * mem_pool, gpointer mem)
{
GstMemPoolElement *pool;
-
+
g_return_if_fail (mem_pool != NULL);
g_return_if_fail (mem != NULL);
pool = GST_MEM_POOL_LINK (mem);
#if defined(USE_ASM) && defined(HAVE_CPU_I386)
- __asm__ __volatile__ ( "1: \t"
- " movl %2, (%1) \n"
- POOL_LOCK "cmpxchg %1, %0 \n\t"
- " jnz 1b \n\t"
- :
- :"m" (*mem_pool), "r" (pool), "a" (mem_pool->free));
+ __asm__ __volatile__ ("1: \t"
+ " movl %2, (%1) \n"
+ POOL_LOCK "cmpxchg %1, %0 \n\t"
+ " jnz 1b \n\t"::"m"
+ (*mem_pool), "r" (pool), "a" (mem_pool->free));
#else
g_mutex_lock (mem_pool->chunk_lock);
pool->link = (GstMemPoolElement *) mem_pool->free;
typedef struct _GstMemPool GstMemPool;
typedef struct _GstMemPoolElement GstMemPoolElement;
-typedef void (*GstMemPoolAllocFunc) (GstMemPool *pool, gpointer data);
-typedef void (*GstMemPoolFreeFunc) (GstMemPool *pool, gpointer data);
+typedef void (*GstMemPoolAllocFunc) (GstMemPool * pool, gpointer data);
+typedef void (*GstMemPoolFreeFunc) (GstMemPool * pool, gpointer data);
struct _GstMemPoolElement
{
- GstMemPoolElement *link; /* next cell in the lifo */
+ GstMemPoolElement *link; /* next cell in the lifo */
GstMemPoolElement *area;
};
struct _GstMemPool
{
volatile GstMemPoolElement *free; /* the first free element */
- volatile gulong cnt; /* used to avoid ABA problem */
+ volatile gulong cnt; /* used to avoid ABA problem */
gchar *name;
gulong area_size;
};
-GstMemPool* gst_mem_pool_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type,
- GstMemPoolAllocFunc alloc_func,
- GstMemPoolFreeFunc free_func);
+GstMemPool *gst_mem_pool_new (gchar * name,
+ gint atom_size,
+ gulong area_size,
+ gint type, GstMemPoolAllocFunc alloc_func, GstMemPoolFreeFunc free_func);
-void gst_mem_pool_destroy (GstMemPool *mem_pool);
+void gst_mem_pool_destroy (GstMemPool * mem_pool);
-gpointer gst_mem_pool_alloc (GstMemPool *mem_pool);
-gpointer gst_mem_pool_alloc0 (GstMemPool *mem_pool);
-void gst_mem_pool_free (GstMemPool *mem_pool,
- gpointer mem);
+gpointer gst_mem_pool_alloc (GstMemPool * mem_pool);
+gpointer gst_mem_pool_alloc0 (GstMemPool * mem_pool);
+void gst_mem_pool_free (GstMemPool * mem_pool, gpointer mem);
#include "gst/gstbuffer.h"
#include "gst/gstbufferpool-default.h"
-int
+int
main (int argc, char *argv[])
{
GstBuffer *buf;
guint i;
-
+
gst_init (&argc, &argv);
- for (i=0; i<5000000; i++) {
+ for (i = 0; i < 5000000; i++) {
buf = gst_buffer_new ();
gst_buffer_unref (buf);
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstBuffer *buf;
guint i;
-
+
gst_init (&argc, &argv);
- for (i=0; i<5000000; i++) {
+ for (i = 0; i < 5000000; i++) {
buf = gst_buffer_new ();
gst_buffer_unref (buf);
}
/* get list of elements */
for (elements = gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY);
- elements != NULL; elements = elements->next) {
+ elements != NULL; elements = elements->next) {
factory = (GstElementFactory *) elements->data;
if ((element = gst_element_factory_create (factory, "test"))) {
gst_object_unref (GST_OBJECT (element));
}
gint
-main (gint argc,
- gchar *argv[])
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
create_all_elements ();
static guint iterations = 0;
static guint mhz = 0;
-void handoff_src(GstElement *src, GstBuffer *buf, gpointer user_data) {
- gst_trace_read_tsc(&GST_BUFFER_TIMESTAMP(buf));
+void
+handoff_src (GstElement * src, GstBuffer * buf, gpointer user_data)
+{
+ gst_trace_read_tsc (&GST_BUFFER_TIMESTAMP (buf));
}
-void handoff_sink(GstElement *sink, GstBuffer *buf, gpointer user_data) {
+void
+handoff_sink (GstElement * sink, GstBuffer * buf, gpointer user_data)
+{
guint64 end, d, avg;
guint avg_ns;
- gst_trace_read_tsc(&end);
- d = end - GST_BUFFER_TIMESTAMP(buf);
- if (d > max) max = d;
- if (d < min) min = d;
+ gst_trace_read_tsc (&end);
+ d = end - GST_BUFFER_TIMESTAMP (buf);
+ if (d > max)
+ max = d;
+ if (d < min)
+ min = d;
total += d;
count++;
- avg = total/count;
- avg_ns = (guint)(1000.0*(double)avg/(double)mhz);
-
+ avg = total / count;
+ avg_ns = (guint) (1000.0 * (double) avg / (double) mhz);
+
if ((count % print_del) == 0) {
- g_print("%07d:%08" G_GUINT64_FORMAT " min:%08" G_GUINT64_FORMAT " max:%08" G_GUINT64_FORMAT " avg:%08" G_GUINT64_FORMAT " avg-s:0.%09d\r",
- count, d, min, max, avg, avg_ns);
+ g_print ("%07d:%08" G_GUINT64_FORMAT " min:%08" G_GUINT64_FORMAT " max:%08"
+ G_GUINT64_FORMAT " avg:%08" G_GUINT64_FORMAT " avg-s:0.%09d\r", count,
+ d, min, max, avg, avg_ns);
}
}
-GstElement *identity_add(GstPipeline *pipeline, GstElement *first, int count) {
+GstElement *
+identity_add (GstPipeline * pipeline, GstElement * first, int count)
+{
GstElement *last, *ident;
int i;
char buf[20];
last = first;
- for (i=0; i<count; i++) {
- snprintf(buf, 20, "identity_%03d", i);
- ident = gst_element_factory_make("identity",buf);
- g_return_val_if_fail(ident != NULL,NULL);
- g_object_set(G_OBJECT(ident),"silent",TRUE,NULL);
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(ident));
- gst_pad_link(gst_element_get_pad(last,"src"),
- gst_element_get_pad(ident,"sink"));
+ for (i = 0; i < count; i++) {
+ snprintf (buf, 20, "identity_%03d", i);
+ ident = gst_element_factory_make ("identity", buf);
+ g_return_val_if_fail (ident != NULL, NULL);
+ g_object_set (G_OBJECT (ident), "silent", TRUE, NULL);
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (ident));
+ gst_pad_link (gst_element_get_pad (last, "src"),
+ gst_element_get_pad (ident, "sink"));
last = ident;
}
return last;
}
-GstElement *fakesrc(void) {
+GstElement *
+fakesrc (void)
+{
GstElement *src;
- src = gst_element_factory_make("fakesrc","src");
- g_return_val_if_fail(src != NULL,NULL);
- g_object_set(G_OBJECT(src),"silent",TRUE,NULL);
- g_object_set(G_OBJECT(src),"num_buffers",iterations,NULL);
- g_signal_connect(G_OBJECT(src),
- "handoff",G_CALLBACK(handoff_src),NULL);
+ src = gst_element_factory_make ("fakesrc", "src");
+ g_return_val_if_fail (src != NULL, NULL);
+ g_object_set (G_OBJECT (src), "silent", TRUE, NULL);
+ g_object_set (G_OBJECT (src), "num_buffers", iterations, NULL);
+ g_signal_connect (G_OBJECT (src), "handoff", G_CALLBACK (handoff_src), NULL);
return src;
}
-GstElement *fakesink(void) {
+GstElement *
+fakesink (void)
+{
GstElement *sink;
- sink = gst_element_factory_make("fakesink","fakesink");
- g_return_val_if_fail(sink != NULL,NULL);
- g_object_set(G_OBJECT(sink),"silent",TRUE,NULL);
- g_signal_connect(G_OBJECT(sink),
- "handoff",G_CALLBACK(handoff_sink),NULL);
+ sink = gst_element_factory_make ("fakesink", "fakesink");
+ g_return_val_if_fail (sink != NULL, NULL);
+ g_object_set (G_OBJECT (sink), "silent", TRUE, NULL);
+ g_signal_connect (G_OBJECT (sink),
+ "handoff", G_CALLBACK (handoff_sink), NULL);
return sink;
}
-GstPipeline *simple(int argc, int argi, char *argv[]) {
+GstPipeline *
+simple (int argc, int argi, char *argv[])
+{
GstPipeline *pipeline;
GstElement *last, *src, *sink;
int idents;
if ((argc - argi) < 1) {
- fprintf(stderr, "bad params");
+ fprintf (stderr, "bad params");
return NULL;
}
- idents = atoi(argv[argi]);
+ idents = atoi (argv[argi]);
if ((argc - argi) == 2) {
- gst_scheduler_factory_set_default_name (argv[argi+1]);
+ gst_scheduler_factory_set_default_name (argv[argi + 1]);
}
- pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
- g_return_val_if_fail(pipeline != NULL,NULL);
+ pipeline = GST_PIPELINE (gst_pipeline_new ("pipeline"));
+ g_return_val_if_fail (pipeline != NULL, NULL);
- src = fakesrc();
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
- last = identity_add(pipeline, src, idents);
- sink = fakesink();
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink));
- gst_pad_link(gst_element_get_pad(last,"src"),
- gst_element_get_pad(sink,"sink"));
+ src = fakesrc ();
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src));
+ last = identity_add (pipeline, src, idents);
+ sink = fakesink ();
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (sink));
+ gst_pad_link (gst_element_get_pad (last, "src"),
+ gst_element_get_pad (sink, "sink"));
return pipeline;
}
-GstPipeline *queue(int argc, int argi, char *argv[]) {
+GstPipeline *
+queue (int argc, int argi, char *argv[])
+{
GstPipeline *pipeline;
GstElement *last, *src, *sink, *src_thr, *src_q, *sink_q, *sink_thr;
int idents;
if ((argc - argi) < 1) {
- fprintf(stderr, "bad params");
+ fprintf (stderr, "bad params");
return NULL;
}
- idents = atoi(argv[argi]);
+ idents = atoi (argv[argi]);
if ((argc - argi) == 2) {
- gst_scheduler_factory_set_default_name (argv[argi+1]);
+ gst_scheduler_factory_set_default_name (argv[argi + 1]);
}
- pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
- g_return_val_if_fail(pipeline != NULL,NULL);
+ pipeline = GST_PIPELINE (gst_pipeline_new ("pipeline"));
+ g_return_val_if_fail (pipeline != NULL, NULL);
- src_thr = GST_ELEMENT(gst_thread_new("src_thread"));
- g_return_val_if_fail(src_thr != NULL,NULL);
+ src_thr = GST_ELEMENT (gst_thread_new ("src_thread"));
+ g_return_val_if_fail (src_thr != NULL, NULL);
- src = fakesrc();
- g_return_val_if_fail(src != NULL,NULL);
- gst_bin_add(GST_BIN(src_thr),GST_ELEMENT(src));
+ src = fakesrc ();
+ g_return_val_if_fail (src != NULL, NULL);
+ gst_bin_add (GST_BIN (src_thr), GST_ELEMENT (src));
- src_q = gst_element_factory_make("queue","src_q");
- g_return_val_if_fail(src_q != NULL,NULL);
- gst_bin_add(GST_BIN(src_thr),GST_ELEMENT(src_q));
- gst_pad_link(gst_element_get_pad(src,"src"),
- gst_element_get_pad(src_q,"sink"));
+ src_q = gst_element_factory_make ("queue", "src_q");
+ g_return_val_if_fail (src_q != NULL, NULL);
+ gst_bin_add (GST_BIN (src_thr), GST_ELEMENT (src_q));
+ gst_pad_link (gst_element_get_pad (src, "src"),
+ gst_element_get_pad (src_q, "sink"));
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src_thr));
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (src_thr));
- last = identity_add(pipeline, src_q, idents);
+ last = identity_add (pipeline, src_q, idents);
- sink_q = gst_element_factory_make("queue","sink_q");
- g_return_val_if_fail(sink_q != NULL,NULL);
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink_q));
- gst_pad_link(gst_element_get_pad(last,"src"),
- gst_element_get_pad(sink_q,"sink"));
+ sink_q = gst_element_factory_make ("queue", "sink_q");
+ g_return_val_if_fail (sink_q != NULL, NULL);
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (sink_q));
+ gst_pad_link (gst_element_get_pad (last, "src"),
+ gst_element_get_pad (sink_q, "sink"));
- sink_thr = GST_ELEMENT(gst_thread_new("sink_thread"));
- g_return_val_if_fail(sink_thr != NULL,NULL);
+ sink_thr = GST_ELEMENT (gst_thread_new ("sink_thread"));
+ g_return_val_if_fail (sink_thr != NULL, NULL);
- sink = fakesink();
- g_return_val_if_fail(sink != NULL,NULL);
- gst_bin_add(GST_BIN(sink_thr),GST_ELEMENT(sink));
+ sink = fakesink ();
+ g_return_val_if_fail (sink != NULL, NULL);
+ gst_bin_add (GST_BIN (sink_thr), GST_ELEMENT (sink));
- gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink_thr));
+ gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (sink_thr));
- gst_pad_link(gst_element_get_pad(sink_q,"src"),
- gst_element_get_pad(sink,"sink"));
+ gst_pad_link (gst_element_get_pad (sink_q, "src"),
+ gst_element_get_pad (sink, "sink"));
return pipeline;
}
-struct test {
+struct test
+{
char *name;
char *params;
- GstPipeline *(*func)(int argc, int argi, char *argv[]);
+ GstPipeline *(*func) (int argc, int argi, char *argv[]);
};
static struct test tests[] = {
{NULL, NULL, NULL}
};
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstPipeline *pipeline;
int i;
char *name;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc < 3) {
- fprintf(stderr, "usage: %s iterations print_del mhz test_name [test_params...]\n",
- argv[0]);
- for (i=0; tests[i].name; i++) {
- fprintf(stderr, " %s %s\n", tests[i].name, tests[i].params);
+ fprintf (stderr,
+ "usage: %s iterations print_del mhz test_name [test_params...]\n",
+ argv[0]);
+ for (i = 0; tests[i].name; i++) {
+ fprintf (stderr, " %s %s\n", tests[i].name, tests[i].params);
}
- exit(1);
+ exit (1);
} else {
- iterations = atoi(argv[1]);
- print_del = atoi(argv[2]);
- mhz = atoi(argv[3]);
+ iterations = atoi (argv[1]);
+ print_del = atoi (argv[2]);
+ mhz = atoi (argv[3]);
name = argv[4];
}
pipeline = NULL;
- for (i=0; tests[i].name && !pipeline; i++) {
- if (!strcmp(name, tests[i].name)) {
- pipeline = tests[i].func(argc,5,argv);
+ for (i = 0; tests[i].name && !pipeline; i++) {
+ if (!strcmp (name, tests[i].name)) {
+ pipeline = tests[i].func (argc, 5, argv);
}
}
- g_return_val_if_fail(pipeline != NULL, -1);
+ g_return_val_if_fail (pipeline != NULL, -1);
/*xmlSaveFile("lat.gst", gst_xml_write(GST_ELEMENT(pipeline))); */
- gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (count < iterations) {
- gst_bin_iterate(GST_BIN(pipeline));
+ gst_bin_iterate (GST_BIN (pipeline));
}
- g_print("\n");
+ g_print ("\n");
return 0;
}
static gint num_allocs;
static gint num_threads;
-static gpointer
+static gpointer
alloc_chunk (void)
{
gpointer ret;
- g_mutex_lock (_lock);
+
+ g_mutex_lock (_lock);
ret = g_mem_chunk_alloc (_chunks);
- g_mutex_unlock (_lock);
+ g_mutex_unlock (_lock);
return ret;
}
-static void
+static void
free_chunk (gpointer chunk)
{
- g_mutex_lock (_lock);
+ g_mutex_lock (_lock);
g_mem_chunk_free (_chunks, chunk);
- g_mutex_unlock (_lock);
+ g_mutex_unlock (_lock);
}
-void*
+void *
run_test (void *threadid)
{
gint i;
g_usleep (G_USEC_PER_SEC);
- for (i = 0; i<num_allocs; i++) {
+ for (i = 0; i < num_allocs; i++) {
chunk = alloc_chunk ();
free_chunk (chunk);
}
- g_thread_exit(NULL);
+ g_thread_exit (NULL);
return NULL;
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GThread *threads[MAX_THREADS];
GError *error;
int t;
-
+
gst_init (&argc, &argv);
if (argc != 3) {
_chunks = g_mem_chunk_new ("test", 32, 32 * 16, G_ALLOC_AND_FREE);
_lock = g_mutex_new ();
- for(t=0; t < num_threads; t++) {
+ for (t = 0; t < num_threads; t++) {
error = NULL;
- threads[t] = g_thread_create (run_test, GINT_TO_POINTER(t), TRUE, &error);
+ threads[t] = g_thread_create (run_test, GINT_TO_POINTER (t), TRUE, &error);
if (error) {
printf ("ERROR: g_thread_create () is %s\n", error->message);
exit (-1);
printf ("main(): Created %d threads.\n", t);
g_thread_exit (NULL);
- g_mem_chunk_info();
+ g_mem_chunk_info ();
return 0;
}
*
*/
static gboolean
-populate (GstMemChunk *mem_chunk)
+populate (GstMemChunk * mem_chunk)
{
guint8 *area;
gint i;
area = (guint8 *) g_malloc (mem_chunk->area_size);
g_print ("alloc %p\n", area);
- for (i=0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) {
- GST_MEM_CHUNK_AREA (area + i) = (GstMemChunkElement *)area;
+ for (i = 0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) {
+ GST_MEM_CHUNK_AREA (area + i) = (GstMemChunkElement *) area;
gst_mem_chunk_free (mem_chunk, GST_MEM_CHUNK_DATA (area + i));
}
}
-GstMemChunk*
-gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type)
+GstMemChunk *
+gst_mem_chunk_new (gchar * name, gint atom_size, gulong area_size, gint type)
{
GstMemChunk *mem_chunk;
mem_chunk = g_malloc (sizeof (GstMemChunk));
mem_chunk->chunk_size = atom_size + sizeof (GstMemChunkElement);
- area_size = (area_size/atom_size) * mem_chunk->chunk_size;
+ area_size = (area_size / atom_size) * mem_chunk->chunk_size;
mem_chunk->name = g_strdup (name);
mem_chunk->free = NULL;
}
void
-gst_mem_chunk_destroy (GstMemChunk *mem_chunk)
+gst_mem_chunk_destroy (GstMemChunk * mem_chunk)
{
GHashTable *elements = g_hash_table_new (NULL, NULL);
gpointer data;
while (data) {
GstMemChunkElement *elem = GST_MEM_CHUNK_LINK (data);
- g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL);
-
+ g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL);
+
data = gst_mem_chunk_alloc (mem_chunk);
- }
+ }
g_hash_table_foreach_remove (elements, free_area, NULL);
g_hash_table_destroy (elements);
}
gpointer
-gst_mem_chunk_alloc (GstMemChunk *mem_chunk)
+gst_mem_chunk_alloc (GstMemChunk * mem_chunk)
{
GstMemChunkElement *chunk = NULL;
-
+
g_return_val_if_fail (mem_chunk != NULL, NULL);
again:
#ifdef HAVE_I386
- __asm__ __volatile__ (" testl %%eax, %%eax \n\t"
- " jz 20f \n"
- "10: \t"
- " movl (%%eax), %%ebx \n\t"
- " movl %%edx, %%ecx \n\t"
- " incl %%ecx \n\t"
- CHUNK_LOCK "cmpxchg8b %1 \n\t"
- " jz 20f \n\t"
- " testl %%eax, %%eax \n\t"
- " jnz 10b \n"
- "20:\t"
- :"=a" (chunk)
- :"m" (*mem_chunk), "a" (mem_chunk->free), "d" (mem_chunk->cnt)
- :"ecx", "ebx");
+__asm__ __volatile__ (" testl %%eax, %%eax \n\t" " jz 20f \n" "10: \t" " movl (%%eax), %%ebx \n\t" " movl %%edx, %%ecx \n\t" " incl %%ecx \n\t" CHUNK_LOCK "cmpxchg8b %1 \n\t" " jz 20f \n\t" " testl %%eax, %%eax \n\t" " jnz 10b \n" "20:\t":"=a" (chunk)
+: "m" (*mem_chunk), "a" (mem_chunk->free), "d" (mem_chunk->cnt)
+: "ecx", "ebx");
#else
- fprintf(stderr,"This only compiles correctly on i386. Sorry\n");
- abort();
+ fprintf (stderr, "This only compiles correctly on i386. Sorry\n");
+ abort ();
#endif
if (!chunk) {
/*g_print ("extending\n"); */
if (populate (mem_chunk))
goto again;
- else
+ else
return NULL;
}
return GST_MEM_CHUNK_DATA (chunk);
}
gpointer
-gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk)
+gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk)
{
gpointer mem = gst_mem_chunk_alloc (mem_chunk);
if (mem)
memset (mem, 0, mem_chunk->atom_size);
-
+
return mem;
}
void
-gst_mem_chunk_free (GstMemChunk *mem_chunk, gpointer mem)
+gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem)
{
GstMemChunkElement *chunk;
-
+
g_return_if_fail (mem_chunk != NULL);
g_return_if_fail (mem != NULL);
chunk = GST_MEM_CHUNK_LINK (mem);
#ifdef HAVE_I386
- __asm__ __volatile__ ( "1: \t"
- " movl %2, (%1) \n"
- CHUNK_LOCK "cmpxchg %1, %0 \n\t"
- " jnz 1b \n\t"
- :
- :"m" (*mem_chunk), "r" (chunk), "a" (mem_chunk->free));
+ __asm__ __volatile__ ("1: \t"
+ " movl %2, (%1) \n"
+ CHUNK_LOCK "cmpxchg %1, %0 \n\t"
+ " jnz 1b \n\t"::"m"
+ (*mem_chunk), "r" (chunk), "a" (mem_chunk->free));
#else
- fprintf(stderr,"This only compiles correctly on i386. Sorry\n");
- abort();
+ fprintf (stderr, "This only compiles correctly on i386. Sorry\n");
+ abort ();
#endif
}
struct _GstMemChunkElement
{
- GstMemChunkElement *link; /* next cell in the lifo */
+ GstMemChunkElement *link; /* next cell in the lifo */
GstMemChunkElement *area;
};
struct _GstMemChunk
{
volatile GstMemChunkElement *free; /* the first free element */
- volatile gulong cnt; /* used to avoid ABA problem */
+ volatile gulong cnt; /* used to avoid ABA problem */
gchar *name;
gulong area_size;
gboolean cleanup;
};
-GstMemChunk* gst_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type);
+GstMemChunk *gst_mem_chunk_new (gchar * name,
+ gint atom_size, gulong area_size, gint type);
-void gst_mem_chunk_destroy (GstMemChunk *mem_chunk);
+void gst_mem_chunk_destroy (GstMemChunk * mem_chunk);
-gpointer gst_mem_chunk_alloc (GstMemChunk *mem_chunk);
-void gst_mem_chunk_free (GstMemChunk *mem_chunk,
- gpointer mem);
+gpointer gst_mem_chunk_alloc (GstMemChunk * mem_chunk);
+void gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem);
static gint num_allocs;
static gint num_threads;
-static gpointer
+static gpointer
alloc_chunk (void)
{
gpointer ret;
+
ret = gst_mem_chunk_alloc (_chunks);
return ret;
}
-static void
+static void
free_chunk (gpointer chunk)
{
gst_mem_chunk_free (_chunks, chunk);
}
-void*
+void *
run_test (void *threadid)
{
gint i;
gpointer chunk;
-
- g_usleep(G_USEC_PER_SEC);
- for (i = 0; i<num_allocs; i++) {
+ g_usleep (G_USEC_PER_SEC);
+
+ for (i = 0; i < num_allocs; i++) {
chunk = alloc_chunk ();
free_chunk (chunk);
}
- g_thread_exit(NULL);
+ g_thread_exit (NULL);
return NULL;
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
- GThread * threads[MAX_THREADS];
- GError * error;
+ GThread *threads[MAX_THREADS];
+ GError *error;
int t;
-
+
gst_init (&argc, &argv);
if (argc != 3) {
_chunks = gst_mem_chunk_new ("test", 32, 32 * 16, G_ALLOC_AND_FREE);
- for(t=0; t < num_threads; t++) {
+ for (t = 0; t < num_threads; t++) {
error = NULL;
- threads[t] = g_thread_create (run_test, GINT_TO_POINTER(t), TRUE, &error);
+ threads[t] = g_thread_create (run_test, GINT_TO_POINTER (t), TRUE, &error);
if (error) {
printf ("ERROR: g_thread_create() %s\n", error->message);
exit (-1);
}
printf ("main(): Created %d threads.\n", t);
- for(t=0; t < num_threads; t++) {
+ for (t = 0; t < num_threads; t++) {
g_thread_join (threads[t]);
}
- g_mem_chunk_info();
+ g_mem_chunk_info ();
gst_mem_chunk_destroy (_chunks);
gboolean playing = TRUE;
static void
-handoff_signal (GstElement *element, GstBuffer *buf)
+handoff_signal (GstElement * element, GstBuffer * buf)
{
- g_print ("handoff \"%s\" %" G_GINT64_FORMAT "\n", gst_element_get_name (element), GST_BUFFER_TIMESTAMP (buf));
+ g_print ("handoff \"%s\" %" G_GINT64_FORMAT "\n",
+ gst_element_get_name (element), GST_BUFFER_TIMESTAMP (buf));
}
static void
-eos_signal (GstElement *element)
+eos_signal (GstElement * element)
{
g_print ("eos received from \"%s\"\n", gst_element_get_name (element));
playing = FALSE;
}
-int
-main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstBin *pipeline;
GstElement *src, *tee, *identity1, *identity2, *aggregator, *sink;
sink = gst_element_factory_make ("fakesink", "sink");
g_return_val_if_fail (sink != NULL, 4);
- gst_bin_add_many (pipeline, src, tee, identity1, identity2, aggregator, sink, NULL);
+ gst_bin_add_many (pipeline, src, tee, identity1, identity2, aggregator, sink,
+ NULL);
gst_element_link_pads (src, "src", tee, "sink");
gst_pad_link (gst_element_get_request_pad (tee, "src%d"),
- gst_element_get_pad (identity1, "sink"));
+ gst_element_get_pad (identity1, "sink"));
gst_pad_link (gst_element_get_request_pad (tee, "src%d"),
- gst_element_get_pad (identity2, "sink"));
+ gst_element_get_pad (identity2, "sink"));
gst_pad_link (gst_element_get_pad (identity1, "src"),
- gst_element_get_request_pad (aggregator, "sink%d"));
+ gst_element_get_request_pad (aggregator, "sink%d"));
gst_pad_link (gst_element_get_pad (identity2, "src"),
- gst_element_get_request_pad (aggregator, "sink%d"));
+ gst_element_get_request_pad (aggregator, "sink%d"));
gst_element_link_pads (aggregator, "src", sink, "sink");
- g_signal_connect (G_OBJECT (src), "eos",
- G_CALLBACK (eos_signal), NULL);
+ g_signal_connect (G_OBJECT (src), "eos", G_CALLBACK (eos_signal), NULL);
g_signal_connect (G_OBJECT (sink), "handoff",
- G_CALLBACK (handoff_signal), NULL);
+ G_CALLBACK (handoff_signal), NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
#include <gst/gst.h>
static void
-caps_nego_failed (GstPad *pad, GstCaps *caps)
+caps_nego_failed (GstPad * pad, GstCaps * caps)
{
gboolean res;
GstPad *peer;
GstCaps *allowed;
- GValue v_caps = { 0, };
+ GValue v_caps = { 0, };
GValue v_allowed = { 0, };
GstCaps *toset;
-
+
peer = gst_pad_get_peer (pad);
g_value_init (&v_caps, GST_TYPE_CAPS);
- g_value_set_boxed (&v_caps, caps);
+ g_value_set_boxed (&v_caps, caps);
allowed = gst_pad_get_allowed_caps (pad);
g_value_init (&v_allowed, GST_TYPE_CAPS);
- g_value_set_boxed (&v_allowed, allowed);
+ g_value_set_boxed (&v_allowed, allowed);
g_print ("caps nego failed on pad %s:%s\n"
- " caps: %p (%s)\n"
- " allowed: %p (%s)\n",
- gst_element_get_name (gst_pad_get_parent (pad)),
- gst_pad_get_name (pad),
- caps,
- g_strdup_value_contents (&v_caps),
- allowed,
- g_strdup_value_contents (&v_allowed));
-
- if (GST_CAPS_IS_FIXED (caps))
+ " caps: %p (%s)\n"
+ " allowed: %p (%s)\n",
+ gst_element_get_name (gst_pad_get_parent (pad)),
+ gst_pad_get_name (pad),
+ caps,
+ g_strdup_value_contents (&v_caps),
+ allowed, g_strdup_value_contents (&v_allowed));
+
+ if (GST_CAPS_IS_FIXED (caps))
/* if the elements suggested fixed caps, we just relink that way */
toset = caps;
else
/* else we use our hardcoded caps as an exazmple */
- toset = GST_CAPS_NEW (
- "testcaps",
- "test/test",
- "prop", GST_PROPS_INT (2)
- );
+ toset = GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT (2)
+ );
res = gst_pad_relink_filtered (pad, peer, toset);
if (!res) {
}
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src, *identity, *sink;
g_object_set (G_OBJECT (src), "num_buffers", 4, NULL);
identity = gst_element_factory_make ("identity", "identity");
g_object_set (G_OBJECT (identity), "delay_capsnego", TRUE, NULL);
-
+
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add_many (GST_BIN (pipeline), src, identity, sink, NULL);
-
+
res = gst_element_link_pads_filtered (src, "src",
- identity, "sink",
- GST_CAPS_NEW (
- "testcaps",
- "test/test",
- "prop", GST_PROPS_INT (1)
- ));
+ identity, "sink",
+ GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT (1)
+ ));
if (!res) {
g_print ("could not link src and identity\n");
return -1;
}
-
+
res = gst_element_link_pads_filtered (identity, "src",
- sink, "sink",
- GST_CAPS_NEW (
- "testcaps",
- "test/test",
- "prop", GST_PROPS_INT_RANGE (2, 3)
- ));
+ sink, "sink",
+ GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT_RANGE (2, 3)
+ ));
if (!res) {
g_print ("could not link identity and sink\n");
return -1;
}
- g_signal_connect (gst_element_get_pad (identity, "src"),
- "caps_nego_failed", G_CALLBACK (caps_nego_failed), NULL);
+ g_signal_connect (gst_element_get_pad (identity, "src"),
+ "caps_nego_failed", G_CALLBACK (caps_nego_failed), NULL);
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
- g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
+ NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
-
+
return 0;
}
#include <gst/gst.h>
static void
-fill_queue (GstElement *queue, gint level, GstBin *pipeline)
+fill_queue (GstElement * queue, gint level, GstBin * pipeline)
{
/* this needs to iterate till something is pushed
* in the queue */
gst_bin_iterate (pipeline);
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *queue, *src, *pipeline;
GstBuffer *buffer;
gboolean done = FALSE;
GstPad *pad;
-
+
gst_init (&argc, &argv);
queue = gst_element_factory_make ("queue", "queue");
gst_element_link_many (src, queue, NULL);
pad = gst_element_get_pad (queue, "src");
- g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline);
+ g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue),
+ pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- do {
+ do {
/* get buffer into the app */
buffer = GST_RPAD_GETFUNC (pad) (pad);
/* just exit on any event */
if (GST_IS_EVENT (buffer)) {
done = TRUE;
- }
- else {
+ } else {
gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
}
gst_data_unref (GST_DATA (buffer));
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
-
+
return 0;
}
#define DEBUG
-gboolean playing = TRUE;
-gboolean cut_start_signalled = FALSE;
-gboolean cut_stop_signalled = FALSE;
-
-int id = 0; /* increment this for each new cut */
-GstElement *main_bin;
-GstElement *audiosrc;
-GstElement *queue;
-GstElement *thread;
-GstElement *cutter;
-GstElement *disksink;
-GstElement *encoder;
-char buffer[255];
+gboolean playing = TRUE;
+gboolean cut_start_signalled = FALSE;
+gboolean cut_stop_signalled = FALSE;
+
+int id = 0; /* increment this for each new cut */
+GstElement *main_bin;
+GstElement *audiosrc;
+GstElement *queue;
+GstElement *thread;
+GstElement *cutter;
+GstElement *disksink;
+GstElement *encoder;
+char buffer[255];
/* signal callbacks */
-void cut_start (GstElement *element)
+void
+cut_start (GstElement * element)
{
g_print ("\nDEBUG: main: cut start\n");
/* we should pause the pipeline, unlink cutter and disksink
{
time_t seconds;
struct tm *ct;
+
time (&seconds);
ct = localtime (&seconds);
/* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */
- sprintf (buffer, "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav",
- ct->tm_year + 1900, ct->tm_mon, ct->tm_mday,
- ct->tm_hour, ct->tm_min, ct->tm_sec);
+ sprintf (buffer,
+ "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav",
+ ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min,
+ ct->tm_sec);
}
g_print ("DEBUG: cut_start: setting new location to %s\n", buffer);
g_object_set (G_OBJECT (disksink), "location", buffer, NULL);
return;
}
-void cut_start_signal (GstElement *element)
+void
+cut_start_signal (GstElement * element)
{
g_print ("\nDEBUG: main: cut start signal\n");
cut_start_signalled = TRUE;
}
-void cut_stop (GstElement *element)
+void
+cut_stop (GstElement * element)
{
g_print ("\nDEBUG: main: cut stop\n");
/* we should pause the pipeline, unlink disksink, create a fake disksink,
return;
}
-void cut_stop_signal (GstElement *element)
+void
+cut_stop_signal (GstElement * element)
{
g_print ("\nDEBUG: main: cut stop signal\n");
cut_stop_signalled = TRUE;
}
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
/*int i, j; */
/*gboolean done; */
-
+
/*char buffer[20]; */
-
+
/*output_channel_t *channel_out; */
-
+
GstElement *audiosrc;
- gst_init (&argc,&argv);
+ gst_init (&argc, &argv);
/*
if (argc == 1)
{
g_print("usage: %s <filename1> <filename2> <...>\n", argv[0]);
exit(-1);
}*/
-
+
/* set up input channel and main bin */
- g_print ("creating main bin\n");
+ g_print ("creating main bin\n");
/* create cutter */
cutter = gst_element_factory_make ("cutter", "cutter");
- g_object_set (G_OBJECT (cutter),
- "threshold_dB", -40.0,
- "runlength", 0.5,
- "prelength", 1.0,
- NULL);
+ g_object_set (G_OBJECT (cutter),
+ "threshold_dB", -40.0, "runlength", 0.5, "prelength", 1.0, NULL);
/* create an audio src */
if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src")))
/* set params */
- g_object_set (G_OBJECT (audiosrc), "frequency", 44100,
- "channels", 1,
- "format", 16, NULL);
+ g_object_set (G_OBJECT (audiosrc), "frequency", 44100,
+ "channels", 1, "format", 16, NULL);
if (!(encoder = gst_element_factory_make ("passthrough", "encoder")))
g_error ("Could not create 'passthrough' element !\n");
-
+
if (!(disksink = gst_element_factory_make ("afsink", "disk_sink")))
g_error ("Could not create 'afsink' element !\n");
-
+
g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL);
thread = gst_thread_new ("thread");
g_assert (thread != NULL);
-
+
/* create main bin */
main_bin = gst_pipeline_new ("bin");
g_assert (main_bin != NULL);
/* set signal handlers */
g_print ("setting signal handlers\n");
- g_signal_connect (G_OBJECT(cutter), "cut_start",
- (GCallback)cut_start_signal, NULL);
- g_signal_connect (G_OBJECT(cutter), "cut_stop",
- (GCallback)cut_stop_signal, NULL);
+ g_signal_connect (G_OBJECT (cutter), "cut_start",
+ (GCallback) cut_start_signal, NULL);
+ g_signal_connect (G_OBJECT (cutter), "cut_stop",
+ (GCallback) cut_stop_signal, NULL);
/* start playing */
g_print ("setting to play\n");
g_print ("setting thread to play\n");
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
*/
- while (playing)
- {
+ while (playing) {
/* g_print ("> "); */
- gst_bin_iterate (GST_BIN (main_bin));
+ gst_bin_iterate (GST_BIN (main_bin));
/* g_print (" <"); */
- if (cut_start_signalled)
- {
- g_print ("\nDEBUG: main: cut_start_signalled true !\n");
- cut_start (cutter);
- cut_start_signalled = FALSE;
- }
- if (cut_stop_signalled)
- {
- g_print ("\nDEBUG: main: cut_stop_signalled true !\n");
- cut_stop (cutter);
- cut_stop_signalled = FALSE;
- }
+ if (cut_start_signalled) {
+ g_print ("\nDEBUG: main: cut_start_signalled true !\n");
+ cut_start (cutter);
+ cut_start_signalled = FALSE;
+ }
+ if (cut_stop_signalled) {
+ g_print ("\nDEBUG: main: cut_stop_signalled true !\n");
+ cut_stop (cutter);
+ cut_stop_signalled = FALSE;
+ }
}
g_print ("we're done iterating.\n");
/* stop the bin */
gst_object_unref (GST_OBJECT (disksink));
gst_object_unref (GST_OBJECT (main_bin));
- exit(0);
+ exit (0);
}
* thomas@apestaart.org
*/
-typedef struct
+typedef struct
{
GstElement *pipe;
GstElement *disksink;
GstElement *audiosink;
-
+
char *location;
int channel_id;
} output_channel_t;
#include <stdlib.h>
#include <gst/gst.h>
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *osssink;
/* link the elements */
gst_element_link_many (filesrc, decoder, osssink, NULL);
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
exit (0);
}
-
#include <gst/gst.h>
static void
-gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline)
+gst_play_have_type (GstElement * typefind, GstCaps * caps,
+ GstElement * pipeline)
{
GstElement *osssink;
GstElement *new_element;
/* unlink_pads the typefind from the pipeline and remove it */
gst_element_unlink_pads (cache, "src", typefind, "sink");
gst_bin_remove (GST_BIN (autobin), typefind);
-
+
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
autoplug = gst_autoplug_factory_make ("staticrender");
g_assert (autoplug != NULL);
- new_element = gst_autoplug_to_renderers (autoplug,
- caps,
- osssink,
- NULL);
+ new_element = gst_autoplug_to_renderers (autoplug, caps, osssink, NULL);
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");
}
static void
-gst_play_cache_empty (GstElement *element, GstElement *pipeline)
+gst_play_cache_empty (GstElement * element, GstElement * pipeline)
{
GstElement *autobin;
GstElement *filesrc;
fprintf (stderr, "done with cache_empty\n");
}
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc;
GstElement *pipeline;
autobin = gst_bin_new ("autobin");
cache = gst_element_factory_make ("autoplugcache", "cache");
- g_signal_connect (G_OBJECT (cache), "cache_empty",
- G_CALLBACK (gst_play_cache_empty), pipeline);
+ g_signal_connect (G_OBJECT (cache), "cache_empty",
+ G_CALLBACK (gst_play_cache_empty), pipeline);
typefind = gst_element_factory_make ("typefind", "typefind");
- g_signal_connect (G_OBJECT (typefind), "have_type",
- G_CALLBACK (gst_play_have_type), pipeline);
+ g_signal_connect (G_OBJECT (typefind), "have_type",
+ G_CALLBACK (gst_play_have_type), pipeline);
gst_bin_add (GST_BIN (autobin), cache);
gst_bin_add (GST_BIN (autobin), typefind);
gst_element_link_pads (cache, "src", typefind, "sink");
- gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink");
+ gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"),
+ "sink");
- gst_bin_add (GST_BIN( pipeline), autobin);
+ gst_bin_add (GST_BIN (pipeline), autobin);
gst_element_link_pads (filesrc, "src", autobin, "sink");
/* start playing */
- gst_element_set_state( GST_ELEMENT (pipeline), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_object_unref (GST_OBJECT (pipeline));
- exit(0);
+ exit (0);
}
-
#include <gst/gst.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *pipeline;
GstElement *filesrc;
return -1;
}
- pipeline = (GstElement*) gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
+ pipeline =
+ (GstElement *)
+ gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
if (!pipeline) {
fprintf (stderr, "Parse error: %s", error->message);
exit (1);
}
-
+
filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc");
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
-
+
return 0;
}
/*#define AUTOPLUG * define if you want autoplugging of input channels * */
/* function prototypes */
-input_channel_t* create_input_channel (int id, char* location);
-void destroy_input_channel (input_channel_t *pipe);
-void env_register_cp (GstElement *volenv, double cp_time, double cp_level);
+input_channel_t *create_input_channel (int id, char *location);
+void destroy_input_channel (input_channel_t * pipe);
+void env_register_cp (GstElement * volenv, double cp_time, double cp_level);
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element)
+void
+eos (GstElement * element)
{
- g_print("have eos, quitting ?\n");
+ g_print ("have eos, quitting ?\n");
/* playing = FALSE; */
}
-G_GNUC_UNUSED static GstCaps*
-gst_play_type_find (GstBin *bin, GstElement *element)
+G_GNUC_UNUSED static GstCaps *
+gst_play_type_find (GstBin * bin, GstElement * element)
{
GstElement *typefind;
GstElement *pipeline;
GstCaps *caps = NULL;
GST_DEBUG ("GstPipeline: typefind for element \"%s\"",
- GST_ELEMENT_NAME(element));
+ GST_ELEMENT_NAME (element));
pipeline = gst_pipeline_new ("autoplug_pipeline");
-
+
typefind = gst_element_factory_make ("typefind", "typefind");
g_return_val_if_fail (typefind != NULL, FALSE);
gst_pad_link (gst_element_get_pad (element, "src"),
- gst_element_get_pad (typefind, "sink"));
+ gst_element_get_pad (typefind, "sink"));
gst_bin_add (bin, typefind);
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (bin));
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
/* push a buffer... the have_type signal handler will set the found flag */
gst_bin_iterate (GST_BIN (pipeline));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
caps = gst_pad_get_caps (gst_element_get_pad (element, "src"));
gst_pad_unlink (gst_element_get_pad (element, "src"),
- gst_element_get_pad (typefind, "sink"));
+ gst_element_get_pad (typefind, "sink"));
gst_bin_remove (bin, typefind);
gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin));
gst_object_unref (GST_OBJECT (typefind));
gst_object_unref (GST_OBJECT (pipeline));
-
+
return caps;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
int i, j;
int num_channels;
-
+
char buffer[20];
-
- GList *input_channels; /* structure holding all the input channels */
-
+
+ GList *input_channels; /* structure holding all the input channels */
+
input_channel_t *channel_in;
-
+
GstElement *main_bin;
GstElement *adder;
GstElement *audiosink;
- GstPad *pad; /* to request pads for the adder */
+ GstPad *pad; /* to request pads for the adder */
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc == 1) {
- g_print("usage: %s <filename1> <filename2> <...>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename1> <filename2> <...>\n", argv[0]);
+ exit (-1);
}
num_channels = argc - 1;
-
+
/* set up output channel and main bin */
-
+
/* create adder */
adder = gst_element_factory_make ("adder", "adderel");
audiosink = gst_element_factory_make ("esdsink", "play_audio");
/* create main bin */
- main_bin = gst_pipeline_new("bin");
+ main_bin = gst_pipeline_new ("bin");
/* link adder and output to bin */
- GST_INFO ( "main: adding adder to bin");
- gst_bin_add (GST_BIN(main_bin), adder);
- GST_INFO ( "main: adding audiosink to bin");
- gst_bin_add (GST_BIN(main_bin), audiosink);
+ GST_INFO ("main: adding adder to bin");
+ gst_bin_add (GST_BIN (main_bin), adder);
+ GST_INFO ("main: adding audiosink to bin");
+ gst_bin_add (GST_BIN (main_bin), audiosink);
/* link adder and audiosink */
- gst_pad_link(gst_element_get_pad(adder,"src"),
- gst_element_get_pad(audiosink,"sink"));
-
+ gst_pad_link (gst_element_get_pad (adder, "src"),
+ gst_element_get_pad (audiosink, "sink"));
+
/* start looping */
input_channels = NULL;
-
- for (i = 1; i < argc; ++i)
- {
+
+ for (i = 1; i < argc; ++i) {
printf ("Opening channel %d from file %s...\n", i, argv[i]);
channel_in = create_input_channel (i, argv[i]);
input_channels = g_list_append (input_channels, channel_in);
- if (i > 1) gst_element_set_state (main_bin, GST_STATE_PAUSED);
- gst_bin_add (GST_BIN(main_bin), channel_in->pipe);
+ if (i > 1)
+ gst_element_set_state (main_bin, GST_STATE_PAUSED);
+ gst_bin_add (GST_BIN (main_bin), channel_in->pipe);
/* request pads and link to adder */
- GST_INFO ( "requesting pad\n");
+ GST_INFO ("requesting pad\n");
pad = gst_element_get_request_pad (adder, "sink%d");
printf ("\tGot new adder sink pad %s\n", gst_pad_get_name (pad));
sprintf (buffer, "channel%d", i);
* at a level ensuring no distortion
* example for three songs :
* song1 : starts at full level, plays 5 seconds, faded out at 10 seconds,
- * sleep until 25, fade to end level at 30
+ * sleep until 25, fade to end level at 30
* song2 : starts silent, fades in at 5 seconds, full blast at 10 seconds,
- * full level until 15, faded out at 20, sleep until 25, fade to end at 30
+ * full level until 15, faded out at 20, sleep until 25, fade to end at 30
* song3 : starts muted, fades in from 15, full at 20, until 25, fade to end level
*/
- if (i == 1)
- {
+ if (i == 1) {
/* first song gets special treatment for end style */
- env_register_cp (channel_in->volenv, 0.0, 1.0);
- }
- else
- {
- env_register_cp (channel_in->volenv, 0.0 , 0.0000001); /* start muted */
- env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
- env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
+ env_register_cp (channel_in->volenv, 0.0, 1.0);
+ } else {
+ env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */
+ env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
+ env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
}
- env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
+ env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
- if (i != num_channels)
- {
- env_register_cp (channel_in->volenv, i * 10.0 , 0.0000001); /* fade to black */
- env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
- }
- env_register_cp (channel_in->volenv, num_channels * 10.0 , 1.0 / num_channels); /* to end level */
+ if (i != num_channels) {
+ env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */
+ env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
+ }
+ env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */
#ifndef GST_DISABLE_LOADSAVE
gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w"));
#endif
/* start playing */
- gst_element_set_state(main_bin, GST_STATE_PLAYING);
+ gst_element_set_state (main_bin, GST_STATE_PLAYING);
/* write out the schedule */
- gst_scheduler_show(GST_ELEMENT_SCHED(main_bin));
+ gst_scheduler_show (GST_ELEMENT_SCHED (main_bin));
playing = TRUE;
j = 0;
/*printf ("main: start iterating from 0"); */
- while (playing && j < 100)
- {
+ while (playing && j < 100) {
/* printf ("main: iterating %d\n", j); */
- gst_bin_iterate(GST_BIN(main_bin));
- /*fprintf(stderr,"after iterate()\n"); */
+ gst_bin_iterate (GST_BIN (main_bin));
+ /*fprintf(stderr,"after iterate()\n"); */
++j;
}
}
printf ("main: all the channels are open\n");
- while (playing)
- {
- gst_bin_iterate(GST_BIN(main_bin));
+ while (playing) {
+ gst_bin_iterate (GST_BIN (main_bin));
/*fprintf(stderr,"after iterate()\n"); */
}
/* stop the bin */
- gst_element_set_state(main_bin, GST_STATE_NULL);
+ gst_element_set_state (main_bin, GST_STATE_NULL);
- while (input_channels)
- {
+ while (input_channels) {
destroy_input_channel (input_channels->data);
input_channels = g_list_next (input_channels);
}
g_list_free (input_channels);
-
- gst_object_unref(GST_OBJECT(audiosink));
- gst_object_unref(GST_OBJECT(main_bin));
+ gst_object_unref (GST_OBJECT (audiosink));
- exit(0);
+ gst_object_unref (GST_OBJECT (main_bin));
+
+ exit (0);
}
-input_channel_t*
-create_input_channel (int id, char* location)
+input_channel_t *
+create_input_channel (int id, char *location)
{
/* create an input channel, reading from location
* return a pointer to the channel
*/
input_channel_t *channel;
-
- char buffer[20]; /* hold the names */
+
+ char buffer[20]; /* hold the names */
/* GstAutoplug *autoplug;
GstCaps *srccaps; */
- GstElement *new_element;
+ GstElement *new_element;
GstElement *decoder;
- GST_DEBUG ( "c_i_p : creating channel with id %d for file %s",
- id, location);
-
+ GST_DEBUG ("c_i_p : creating channel with id %d for file %s", id, location);
+
/* allocate channel */
channel = (input_channel_t *) malloc (sizeof (input_channel_t));
- if (channel == NULL)
- {
+ if (channel == NULL) {
printf ("create_input_channel : could not allocate memory for channel !\n");
return NULL;
}
/* create channel */
- GST_DEBUG ( "c_i_p : creating pipeline");
+ GST_DEBUG ("c_i_p : creating pipeline");
sprintf (buffer, "pipeline%d", id);
channel->pipe = gst_bin_new (buffer);
- g_assert(channel->pipe != NULL);
-
+ g_assert (channel->pipe != NULL);
+
/* create elements */
- GST_DEBUG ( "c_i_p : creating filesrc");
+ GST_DEBUG ("c_i_p : creating filesrc");
sprintf (buffer, "filesrc%d", id);
channel->filesrc = gst_element_factory_make ("filesrc", buffer);
- g_assert(channel->filesrc != NULL);
+ g_assert (channel->filesrc != NULL);
- GST_DEBUG ( "c_i_p : setting location");
- g_object_set(G_OBJECT(channel->filesrc),"location", location, NULL);
+ GST_DEBUG ("c_i_p : setting location");
+ g_object_set (G_OBJECT (channel->filesrc), "location", location, NULL);
/* add filesrc to the bin before autoplug */
- gst_bin_add(GST_BIN(channel->pipe), channel->filesrc);
+ gst_bin_add (GST_BIN (channel->pipe), channel->filesrc);
/* link signal to eos of filesrc */
- g_signal_connect (G_OBJECT(channel->filesrc),"eos",
- G_CALLBACK(eos),NULL);
+ g_signal_connect (G_OBJECT (channel->filesrc), "eos", G_CALLBACK (eos), NULL);
#ifdef DEBUG
sprintf (buffer, "volenv%d", id);
channel->volenv = gst_element_factory_make ("volenv", buffer);
- g_assert(channel->volenv != NULL);
+ g_assert (channel->volenv != NULL);
/* autoplug the pipe */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_bin_remove (GST_BIN (pipeline), channel->pipe);
-
+
}
#endif
g_print ("could not autoplug, unknown media type...\n");
exit (-1);
}
-
#ifdef DEBUG
printf ("DEBUG : c_i_p : creating autoplug\n");
#endif
#ifdef DEBUG
printf ("DEBUG : c_i_p : autoplugging\n");
#endif
-
- new_element = gst_autoplug_to_caps (autoplug, srccaps,
- gst_caps_new ("audio/raw", NULL), NULL);
-
+
+ new_element = gst_autoplug_to_caps (autoplug, srccaps,
+ gst_caps_new ("audio/raw", NULL), NULL);
+
if (!new_element) {
g_print ("could not autoplug, no suitable codecs found...\n");
exit (-1);
}
-
#else
new_element = gst_bin_new ("autoplug_bin");
/* static plug, use mad plugin and assume mp3 input */
printf ("using static plugging for input channel\n");
- decoder = gst_element_factory_make ("mad", "mpg123");
- if (!decoder)
- {
+ decoder = gst_element_factory_make ("mad", "mpg123");
+ if (!decoder) {
fprintf (stderr, "Could not get a decoder element !\n");
exit (1);
}
gst_bin_add (GST_BIN (new_element), decoder);
- gst_element_add_ghost_pad (new_element,
- gst_element_get_pad (decoder, "sink"), "sink");
- gst_element_add_ghost_pad (new_element,
- gst_element_get_pad (decoder, "src"), "src_00");
-
-#endif
+ gst_element_add_ghost_pad (new_element,
+ gst_element_get_pad (decoder, "sink"), "sink");
+ gst_element_add_ghost_pad (new_element,
+ gst_element_get_pad (decoder, "src"), "src_00");
+
+#endif
#ifndef GST_DISABLE_LOADSAVE
gst_xml_write_file (GST_ELEMENT (new_element), fopen ("mixer.gst", "w"));
-#endif
+#endif
- gst_bin_add (GST_BIN(channel->pipe), channel->volenv);
+ gst_bin_add (GST_BIN (channel->pipe), channel->volenv);
gst_bin_add (GST_BIN (channel->pipe), new_element);
-
+
gst_element_link_pads (channel->filesrc, "src", new_element, "sink");
gst_element_link_pads (new_element, "src_00", channel->volenv, "sink");
-
+
/* add a ghost pad */
sprintf (buffer, "channel%d", id);
gst_element_add_ghost_pad (channel->pipe,
- gst_element_get_pad (channel->volenv, "src"), buffer);
+ gst_element_get_pad (channel->volenv, "src"), buffer);
+
-
#ifdef DEBUG
printf ("DEBUG : c_i_p : end function\n");
#endif
}
void
-destroy_input_channel (input_channel_t *channel)
+destroy_input_channel (input_channel_t * channel)
{
/*
* destroy an input channel
*/
-
+
#ifdef DEBUG
printf ("DEBUG : d_i_p : start\n");
#endif
free (channel);
}
-void env_register_cp (GstElement *volenv, double cp_time, double cp_level)
+void
+env_register_cp (GstElement * volenv, double cp_time, double cp_level)
{
char buffer[30];
sprintf (buffer, "%f:%f", cp_time, cp_level);
- g_object_set(G_OBJECT(volenv), "controlpoint", buffer, NULL);
+ g_object_set (G_OBJECT (volenv), "controlpoint", buffer, NULL);
}
* thomas@apestaart.org
*/
-typedef struct
+typedef struct
{
GstElement *pipe, *filesrc, *volenv;
-
+
char *location;
int channel_id;
} input_channel_t;
#include <gst/gst.h>
-static GstElement*
+static GstElement *
make_bin (gint count)
{
GstElement *bin;
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *aggregator, *sink;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("main");
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
-
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+
aggregator = gst_element_factory_make ("aggregator", "mixer");
sink = gst_element_factory_make ("fakesink", "sink");
i = 4;
while (i--)
gst_bin_iterate (GST_BIN (pipeline));
-
+
g_print ("playing bin1\n");
gst_element_set_state (bin1, GST_STATE_PLAYING);
* plugin, as well as author and version data. Use the GST_ELEMENT_DETAILS
* macro when defining it.
*/
-static GstElementDetails example_details = GST_ELEMENT_DETAILS (
- "An example plugin",
- "Example/FirstExample",
- "Shows the basic structure of a plugin",
- "your name <your.name@your.isp>"
-);
+static GstElementDetails example_details =
+GST_ELEMENT_DETAILS ("An example plugin",
+ "Example/FirstExample",
+ "Shows the basic structure of a plugin",
+ "your name <your.name@your.isp>");
/* These are the signals that this element can fire. They are zero-
* based because the numbers themselves are private to the object.
* LAST_SIGNAL is used for initialization of the signal array.
*/
-enum {
+enum
+{
ASDF,
/* FILL ME */
LAST_SIGNAL
/* Arguments are identified the same way, but cannot be zero, so you
* must leave the ARG_0 entry in as a placeholder.
*/
-enum {
+enum
+{
ARG_0,
ARG_ACTIVE
- /* FILL ME */
+ /* FILL ME */
};
/* The PadFactory structures describe what pads the element has or
* can have. They can be quite complex, but for this example plugin
* they are rather simple.
*/
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink", /* The name of the pad */
- GST_PAD_SINK, /* Direction of the pad */
- GST_PAD_ALWAYS, /* The pad exists for every instance */
- GST_STATIC_CAPS (
- "unknown/unknown, " /* The MIME media type */
- "foo:int=1, " /* an integer property */
- "bar:boolean=true, " /* a boolean property */
- "baz:int={ 1, 3 }" /* a list of values */
- )
-);
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */
+ GST_PAD_SINK, /* Direction of the pad */
+ GST_PAD_ALWAYS, /* The pad exists for every instance */
+ GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */
+ "foo:int=1, " /* an integer property */
+ "bar:boolean=true, " /* a boolean property */
+ "baz:int={ 1, 3 }" /* a list of values */
+ )
+ );
/* This factory is much simpler, and defines the source pad. */
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "unknown/unknown"
- )
-);
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("unknown/unknown")
+ );
/* A number of functon prototypes are given so we can refer to them later. */
-static void gst_example_class_init (GstExampleClass *klass);
-static void gst_example_init (GstExample *example);
+static void gst_example_class_init (GstExampleClass * klass);
+static void gst_example_init (GstExample * example);
-static void gst_example_chain (GstPad *pad, GstData *_data);
+static void gst_example_chain (GstPad * pad, GstData * _data);
-static void gst_example_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_example_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_example_change_state (GstElement *element);
+static void gst_example_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_example_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_example_change_state (GstElement * element);
/* The parent class pointer needs to be kept around for some object
* operations.
* and pointers to the various functions that define the class.
*/
GType
-gst_example_get_type(void)
+gst_example_get_type (void)
{
static GType example_type = 0;
if (!example_type) {
static const GTypeInfo example_info = {
- sizeof(GstExampleClass),
+ sizeof (GstExampleClass),
NULL,
NULL,
- (GClassInitFunc)gst_example_class_init,
+ (GClassInitFunc) gst_example_class_init,
NULL,
NULL,
- sizeof(GstExample),
+ sizeof (GstExample),
0,
- (GInstanceInitFunc)gst_example_init,
+ (GInstanceInitFunc) gst_example_init,
};
- example_type = g_type_register_static(GST_TYPE_ELEMENT, "GstExample", &example_info, 0);
+ example_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info,
+ 0);
}
return example_type;
}
* it, based on the pointer to the function provided above.
*/
static void
-gst_example_class_init (GstExampleClass *klass)
+gst_example_class_init (GstExampleClass * klass)
{
/* Class pointers are needed to supply pointers to the private
* implementations of parent class methods.
/* Since the example class contains the parent classes, you can simply
* cast the pointer to get access to the parent classes.
*/
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
/* The parent class is needed for class method overrides. */
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
/* Here we add an argument to the object. This argument is an integer,
* and can be both read and written.
*/
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE,
- g_param_spec_int("active","active","active",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
/* Here we add a signal to the object. This is avery useless signal
* called asdf. The signal will also pass a pointer to the listeners
* which happens to be the example element itself */
gst_example_signals[ASDF] =
- g_signal_new("asdf", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL,
- g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
- GST_TYPE_EXAMPLE);
+ g_signal_new ("asdf", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_EXAMPLE);
/* The last thing is to provide the functions that implement get and set
* the plugin.
*/
static void
-gst_example_init(GstExample *example)
+gst_example_init (GstExample * example)
{
/* First we create the sink pad, which is the input to the element.
* We will use the template constructed by the factory.
*/
- example->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ example->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
/* Setting the chain function allows us to supply the function that will
* actually be performing the work. Without this, the element would do
* nothing, with undefined results (assertion failures and such).
*/
- gst_pad_set_chain_function(example->sinkpad,gst_example_chain);
+ gst_pad_set_chain_function (example->sinkpad, gst_example_chain);
/* We then must add this pad to the element's list of pads. The base
* element class manages the list of pads, and provides accessors to it.
*/
- gst_element_add_pad(GST_ELEMENT(example),example->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (example), example->sinkpad);
/* The src pad, the output of the element, is created and registered
* in the same way, with the exception of the chain function. Source
* pads don't have chain functions, because they can't accept buffers,
* they only produce them.
*/
- example->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
- gst_element_add_pad(GST_ELEMENT(example),example->srcpad);
+ example->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (example), example->srcpad);
/* Initialization of element's private variables. */
example->active = FALSE;
* as the buffer provided by the peer element.
*/
static void
-gst_example_chain (GstPad *pad, GstData *_data)
+gst_example_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstExample *example;
/* Some of these checks are of dubious value, since if there were not
* already true, the chain function would never be called.
*/
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* We need to get a pointer to the element this pad belogs to. */
- example = GST_EXAMPLE(gst_pad_get_parent (pad));
+ example = GST_EXAMPLE (gst_pad_get_parent (pad));
/* A few more sanity checks to make sure that the element that owns
* this pad is the right kind of element, in case something got confused.
*/
- g_return_if_fail(example != NULL);
- g_return_if_fail(GST_IS_EXAMPLE(example));
+ g_return_if_fail (example != NULL);
+ g_return_if_fail (GST_IS_EXAMPLE (example));
/* If we are supposed to be doing something, here's where it happens. */
if (example->active) {
/* In this example we're going to copy the buffer to another one,
* so we need to allocate a new buffer first. */
- outbuf = gst_buffer_new();
+ outbuf = gst_buffer_new ();
/* We need to copy the size and offset of the buffer at a minimum. */
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf);
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf);
/* Then allocate the memory for the new buffer */
- GST_BUFFER_DATA (outbuf) = (guchar *)g_malloc (GST_BUFFER_SIZE (outbuf));
+ GST_BUFFER_DATA (outbuf) = (guchar *) g_malloc (GST_BUFFER_SIZE (outbuf));
/* Then copy the data in the incoming buffer into the new buffer. */
- memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (outbuf));
+ memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (outbuf));
/* we don't need the incomming buffer anymore so we unref it. When we are
* the last plugin with a handle to the buffer, its memory will be freed */
* in the pipeline, through the element's source pad, which is stored
* in the element's structure.
*/
- gst_pad_push(example->srcpad,GST_DATA (outbuf));
+ gst_pad_push (example->srcpad, GST_DATA (outbuf));
/* For fun we'll emit our useless signal here */
- g_signal_emit(G_OBJECT (example), gst_example_signals[ASDF], 0,
- example);
+ g_signal_emit (G_OBJECT (example), gst_example_signals[ASDF], 0, example);
- /* If we're not doing something, just send the original incoming buffer. */
+ /* If we're not doing something, just send the original incoming buffer. */
} else {
- gst_pad_push(example->srcpad,GST_DATA (buf));
+ gst_pad_push (example->srcpad, GST_DATA (buf));
}
}
* enable the element to respond to various arguments.
*/
static void
-gst_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_example_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstExample *example;
/* It's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_EXAMPLE(object));
+ g_return_if_fail (GST_IS_EXAMPLE (object));
/* Get a pointer of the right type. */
- example = GST_EXAMPLE(object);
+ example = GST_EXAMPLE (object);
/* Check the argument id to see which argument we're setting. */
switch (prop_id) {
* is running, if you are using threads.
*/
example->active = g_value_get_int (value);
- g_print("example: set active to %d\n",example->active);
+ g_print ("example: set active to %d\n", example->active);
break;
default:
break;
/* The set function is simply the inverse of the get fuction. */
static void
-gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_example_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstExample *example;
/* It's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_EXAMPLE(object));
- example = GST_EXAMPLE(object);
+ g_return_if_fail (GST_IS_EXAMPLE (object));
+ example = GST_EXAMPLE (object);
switch (prop_id) {
case ARG_ACTIVE:
* in the various state transitions.
*/
static GstElementStateReturn
-gst_example_change_state (GstElement *element)
+gst_example_change_state (GstElement * element)
{
GstExample *example;
-
+
/* cast to our plugin */
- example = GST_EXAMPLE(element);
-
+ example = GST_EXAMPLE (element);
+
/* we perform our actions based on the state transition
* of the element */
switch (GST_STATE_TRANSITION (element)) {
- /* The NULL to READY transition is used to
- * create threads (if any) */
+ /* The NULL to READY transition is used to
+ * create threads (if any) */
case GST_STATE_NULL_TO_READY:
break;
- /* In the READY to PAUSED state, the element should
- * open devices (if any) */
+ /* In the READY to PAUSED state, the element should
+ * open devices (if any) */
case GST_STATE_READY_TO_PAUSED:
break;
- /* In the PAUSED to PLAYING state, the element should
- * prepare itself for operation or continue after a PAUSE */
+ /* In the PAUSED to PLAYING state, the element should
+ * prepare itself for operation or continue after a PAUSE */
case GST_STATE_PAUSED_TO_PLAYING:
break;
- /* In the PLAYING to PAUSED state, the element should
- * PAUSE itself and make sure it can resume operation */
+ /* In the PLAYING to PAUSED state, the element should
+ * PAUSE itself and make sure it can resume operation */
case GST_STATE_PLAYING_TO_PAUSED:
break;
- /* In the PAUSED to READY state, the element should reset
- * its internal state and close any devices. */
+ /* In the PAUSED to READY state, the element should reset
+ * its internal state and close any devices. */
case GST_STATE_PAUSED_TO_READY:
break;
- /* The element should free all resources, terminate threads
- * and put itself into its initial state again */
+ /* The element should free all resources, terminate threads
+ * and put itself into its initial state again */
case GST_STATE_READY_TO_NULL:
break;
}
* this function is called to register everything that the plugin provides.
*/
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* We need to register each element we provide with the plugin. This consists
* of the name of the element, a rank that gives the importance of the element
* when compared to similar plugins and the GType identifier.
*/
- if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, GST_TYPE_EXAMPLE))
+ if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL,
+ GST_TYPE_EXAMPLE))
return FALSE;
/* Now we can return successfully. */
* The symbol pointing to this structure is the only symbol looked up when
* loading the plugin.
*/
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR, /* The major version of the core that this was built with */
- GST_VERSION_MINOR, /* The minor version of the core that this was built with */
- "example", /* The name of the plugin. This must be unique: plugins with
- * the same name will be assumed to be identical, and only
- * one will be loaded. */
- "an example plugin", /* a short description of the plugin in English */
- plugin_init, /* Pointer to the initialisation function for the plugin. */
- "0.1", /* The version number of the plugin */
- "LGPL", /* ieffective license the plugin can be shipped with. Must be
- * valid for all libraries it links to, too. */
- "my nifty plugin package",
- /* package this plugin belongs to. */
- "http://www.mydomain.com"
- /* originating URL for this plugin. This is the place to look
- * for updates, information and so on. */
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */
+ GST_VERSION_MINOR, /* The minor version of the core that this was built with */
+ "example", /* The name of the plugin. This must be unique: plugins with
+ * the same name will be assumed to be identical, and only
+ * one will be loaded. */
+ "an example plugin", /* a short description of the plugin in English */
+ plugin_init, /* Pointer to the initialisation function for the plugin. */
+ "0.1", /* The version number of the plugin */
+ "LGPL", /* ieffective license the plugin can be shipped with. Must be
+ * valid for all libraries it links to, too. */
+ "my nifty plugin package",
+ /* package this plugin belongs to. */
+ "http://www.mydomain.com"
+ /* originating URL for this plugin. This is the place to look
+ * for updates, information and so on. */
+ );
#include <gst/gst.h>
G_BEGIN_DECLS
-
/* This is the definition of the element's object structure. */
typedef struct _GstExample GstExample;
* the beginning of the object. This allows the element to be cast to
* an Element or even an Object.
*/
-struct _GstExample {
+struct _GstExample
+{
GstElement element;
/* We need to keep track of our pads, so we do so here. */
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* We'll use this to decide whether to do anything to the data we get. */
gboolean active;
* structure. */
typedef struct _GstExampleClass GstExampleClass;
-struct _GstExampleClass {
+struct _GstExampleClass
+{
GstElementClass parent_class;
/* signals */
- void (*asdf) (GstElement *element, GstExample *example);
+ void (*asdf) (GstElement * element, GstExample * example);
};
/* Five standard preprocessing macros are used in the Gtk+ object system.
/* This is the only prototype needed, because it is used in the above
* GST_TYPE_EXAMPLE macro.
*/
-GType gst_example_get_type(void);
+GType gst_example_get_type (void);
G_END_DECLS
-
#endif /* __GST_EXAMPLE_H__ */
#include <stdlib.h>
#include <gst/gst.h>
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *parse, *decode, *queue;
GstElement *bin;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, parse, decode, queue, NULL);
- gst_bin_add(GST_BIN(thread), osssink);
- gst_bin_add(GST_BIN(bin), thread);
+ gst_bin_add (GST_BIN (thread), osssink);
+ gst_bin_add (GST_BIN (bin), thread);
gst_element_link_many (filesrc, parse, decode, queue, osssink, NULL);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- while (gst_bin_iterate(GST_BIN(bin)));
+ while (gst_bin_iterate (GST_BIN (bin)));
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue;
GstElement *pipeline;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- pipeline = gst_pipeline_new("pipeline");
- g_assert(pipeline != NULL);
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect (G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
/*
- gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
- gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue);
+ gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
+ gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue);
- gst_bin_add(GST_BIN(thread), osssink);
+ gst_bin_add(GST_BIN(thread), osssink);
- gst_pad_link(gst_element_get_pad(queue,"src"),
- gst_element_get_pad(osssink,"sink"));
+ gst_pad_link(gst_element_get_pad(queue,"src"),
+ gst_element_get_pad(osssink,"sink"));
- if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
- g_print("cannot autoplug pipeline\n");
- exit(-1);
- }
- */
+ if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
+ g_print("cannot autoplug pipeline\n");
+ exit(-1);
+ }
+ */
- gst_bin_add(GST_BIN(pipeline), thread);
+ gst_bin_add (GST_BIN (pipeline), thread);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(pipeline));
+ gst_bin_iterate (GST_BIN (pipeline));
}
- gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *parse, *decode;
GstElement *bin;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
+ queue = gst_element_factory_make ("queue", "queue");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
/* add objects to the main bin */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), queue);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), queue);
- gst_bin_add(GST_BIN(thread), parse);
- gst_bin_add(GST_BIN(thread), decode);
- gst_bin_add(GST_BIN(thread), osssink);
+ gst_bin_add (GST_BIN (thread), parse);
+ gst_bin_add (GST_BIN (thread), decode);
+ gst_bin_add (GST_BIN (thread), osssink);
gst_element_link_many (filesrc, queue, parse, decode, osssink, NULL);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
}
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
playing = FALSE;
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *queue2, *parse, *decode;
GstElement *bin;
GstElement *thread, *thread2;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
- thread2 = gst_thread_new("thread2");
- g_assert(thread2 != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
+ thread2 = gst_thread_new ("thread2");
+ g_assert (thread2 != NULL);
/* create a new bin to hold the elements */
- bin = gst_bin_new("bin");
- g_assert(bin != NULL);
+ bin = gst_bin_new ("bin");
+ g_assert (bin != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
- queue = gst_element_factory_make("queue", "queue");
- queue2 = gst_element_factory_make("queue", "queue2");
+ queue = gst_element_factory_make ("queue", "queue");
+ queue2 = gst_element_factory_make ("queue", "queue2");
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
- parse = gst_element_factory_make("mp3parse", "parse");
- decode = gst_element_factory_make("mpg123", "decode");
+ parse = gst_element_factory_make ("mp3parse", "parse");
+ decode = gst_element_factory_make ("mpg123", "decode");
/* add objects to the main bin */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), queue);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), queue);
- gst_bin_add(GST_BIN(thread), parse);
- gst_bin_add(GST_BIN(thread), decode);
- gst_bin_add(GST_BIN(thread), queue2);
+ gst_bin_add (GST_BIN (thread), parse);
+ gst_bin_add (GST_BIN (thread), decode);
+ gst_bin_add (GST_BIN (thread), queue2);
- gst_bin_add(GST_BIN(thread2), osssink);
+ gst_bin_add (GST_BIN (thread2), osssink);
gst_element_link_many (filesrc, queue, parse, decode, queue2, osssink, NULL);
- gst_bin_add(GST_BIN(bin), thread);
- gst_bin_add(GST_BIN(bin), thread2);
+ gst_bin_add (GST_BIN (bin), thread);
+ gst_bin_add (GST_BIN (bin), thread2);
/* make it ready */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
}
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
#include <string.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *tag_changer, *filesink;
gchar *artist, *title, *ext, *filename;
-
+
/* initialize GStreamer */
gst_init (&argc, &argv);
artist = argv[1];
artist = g_strdup (artist);
ext = strrchr (artist, '.');
- if (ext) *ext = '\0';
+ if (ext)
+ *ext = '\0';
title = strstr (artist, " - ");
if (title == NULL) {
g_print ("The format of the mp3 file is invalid.\n");
}
*title = '\0';
title += 3;
-
-
+
+
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("pipeline");
g_assert (bin);
g_assert (filesink);
/* set the filenames */
- filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */
+ filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL);
/* make sure the tag setter uses our stuff
(though that should already be default) */
- gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_KEEP);
+ gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer),
+ GST_TAG_MERGE_KEEP);
/* set the tagging information */
gst_tag_setter_add (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_REPLACE,
- GST_TAG_ARTIST, artist,
- GST_TAG_TITLE, title,
- NULL);
+ GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, tag_changer, filesink, NULL);
/* link the elements */
g_assert (gst_element_link_many (filesrc, tag_changer, filesink));
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
return 0;
}
-
#include <string.h>
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *encoder, *filesink;
gchar *artist, *title, *ext, *filename;
-
+
/* initialize GStreamer */
gst_init (&argc, &argv);
artist = argv[1];
artist = g_strdup (artist);
ext = strrchr (artist, '.');
- if (ext) *ext = '\0';
+ if (ext)
+ *ext = '\0';
title = strstr (artist, " - ");
if (title == NULL) {
g_print ("The format of the mp3 file is invalid.\n");
}
*title = '\0';
title += 3;
-
-
+
+
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("pipeline");
g_assert (bin);
g_print ("cound not find plugin \"vorbisenc\"");
return 1;
}
-
+
/* and a file writer */
filesink = gst_element_factory_make ("filesink", "filesink");
g_assert (filesink);
/* set the filenames */
- filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */
+ filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL);
g_free (filename);
gst_tag_setter_set_merge_mode (GST_TAG_SETTER (encoder), GST_TAG_MERGE_KEEP);
/* set the tagging information */
gst_tag_setter_add (GST_TAG_SETTER (encoder), GST_TAG_MERGE_REPLACE,
- GST_TAG_ARTIST, artist,
- GST_TAG_TITLE, title,
- NULL);
+ GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, encoder, filesink, NULL);
/* link the elements */
gst_element_link_many (filesrc, decoder, encoder, filesink, NULL);
-
+
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
return 0;
}
-
#include <gst/gst.h>
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- GstThread *thread = GST_THREAD(data);
- g_print("have eos, quitting\n");
+ GstThread *thread = GST_THREAD (data);
+
+ g_print ("have eos, quitting\n");
/* stop the bin */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
- gst_main_quit();
+ gst_main_quit ();
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink;
GstElement *pipeline;
GstElement *thread;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new thread to hold the elements */
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
/* create a new bin to hold the elements */
- pipeline = gst_pipeline_new("pipeline");
- g_assert(pipeline != NULL);
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
/* create a disk reader */
- filesrc = gst_element_factory_make("filesrc", "disk_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
- g_signal_connect(G_OBJECT(filesrc),"eos",
- G_CALLBACK(eos), thread);
+ filesrc = gst_element_factory_make ("filesrc", "disk_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
/* and an audio sink */
- osssink = gst_element_factory_make("osssink", "play_audio");
- g_assert(osssink != NULL);
+ osssink = gst_element_factory_make ("osssink", "play_audio");
+ g_assert (osssink != NULL);
/* add objects to the main pipeline */
/*
- gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
- gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink);
+ gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc);
+ gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink);
- if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
- g_print("unable to handle stream\n");
- exit(-1);
- }
- */
+ if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
+ g_print("unable to handle stream\n");
+ exit(-1);
+ }
+ */
/*gst_bin_remove(GST_BIN(pipeline), filesrc); */
/*gst_bin_add(GST_BIN(thread), filesrc); */
- gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline));
+ gst_bin_add (GST_BIN (thread), GST_ELEMENT (pipeline));
/* make it ready */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_READY);
/* start playing */
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
- gst_main();
+ gst_main ();
- gst_object_unref(GST_OBJECT(thread));
+ gst_object_unref (GST_OBJECT (thread));
- exit(0);
+ exit (0);
}
#include <gst/gst.h>
void
-type_found (GstElement *typefind, const GstCaps * caps)
+type_found (GstElement * typefind, const GstCaps * caps)
{
xmlDocPtr doc;
xmlNodePtr parent;
-
- doc = xmlNewDoc ("1.0");
+
+ doc = xmlNewDoc ("1.0");
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL);
xmlDocDump (stdout, doc);
}
-int
-main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *typefind;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create a new bin to hold the elements */
- bin = gst_pipeline_new("bin");
- g_assert(bin != NULL);
+ bin = gst_pipeline_new ("bin");
+ g_assert (bin != NULL);
/* create a file reader */
- filesrc = gst_element_factory_make("filesrc", "file_source");
- g_assert(filesrc != NULL);
- g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
+ filesrc = gst_element_factory_make ("filesrc", "file_source");
+ g_assert (filesrc != NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
- typefind = gst_element_factory_make("typefind", "typefind");
- g_assert(typefind != NULL);
+ typefind = gst_element_factory_make ("typefind", "typefind");
+ g_assert (typefind != NULL);
/* add objects to the main pipeline */
- gst_bin_add(GST_BIN(bin), filesrc);
- gst_bin_add(GST_BIN(bin), typefind);
+ gst_bin_add (GST_BIN (bin), filesrc);
+ gst_bin_add (GST_BIN (bin), typefind);
- g_signal_connect (G_OBJECT (typefind), "have_type",
- G_CALLBACK (type_found), NULL);
+ g_signal_connect (G_OBJECT (typefind), "have_type",
+ G_CALLBACK (type_found), NULL);
gst_element_link (filesrc, typefind);
/* start playing */
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- gst_bin_iterate(GST_BIN(bin));
+ gst_bin_iterate (GST_BIN (bin));
- gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
gboolean playing;
static void
-object_saved (GstObject *object, xmlNodePtr parent, gpointer data)
+object_saved (GstObject * object, xmlNodePtr parent, gpointer data)
{
xmlNodePtr child;
xmlNsPtr ns;
-
+
/* first see if the namespace is already known */
- ns = xmlSearchNsByHref (parent->doc, parent, "http://gstreamer.net/gst-test/1.0/");
+ ns = xmlSearchNsByHref (parent->doc, parent,
+ "http://gstreamer.net/gst-test/1.0/");
if (ns == NULL) {
xmlNodePtr root = xmlDocGetRootElement (parent->doc);
+
/* add namespace to root node */
ns = xmlNewNs (root, "http://gstreamer.net/gst-test/1.0/", "test");
}
- child = xmlNewChild(parent, ns, "comment", NULL);
-
- xmlNewChild(child, NULL, "text", (gchar *)data);
+ child = xmlNewChild (parent, ns, "comment", NULL);
+
+ xmlNewChild (child, NULL, "text", (gchar *) data);
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink, *queue, *queue2, *decode;
GstElement *pipeline;
GstElement *thread, *thread2;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
- g_print("usage: %s <filename>\n", argv[0]);
- exit(-1);
+ g_print ("usage: %s <filename>\n", argv[0]);
+ exit (-1);
}
/* create new threads to hold the elements */
/* these signals will allow us to save custom tags with the gst xml output */
g_signal_connect (G_OBJECT (thread), "object_saved",
- G_CALLBACK (object_saved),
- g_strdup ("decoder thread"));
+ G_CALLBACK (object_saved), g_strdup ("decoder thread"));
g_signal_connect (G_OBJECT (thread2), "object_saved",
- G_CALLBACK (object_saved),
- g_strdup ("render thread"));
-
+ G_CALLBACK (object_saved), g_strdup ("render thread"));
+
/* create a new bin to hold the elements */
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
exit (0);
}
-
gboolean playing;
G_GNUC_UNUSED static void
-xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data)
+xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data)
{
xmlNodePtr children = self->xmlChildrenNode;
xmlNodePtr nodes = children->xmlChildrenNode;
while (nodes) {
- if (!strcmp (nodes->name, "text")) {
- gchar *name = g_strdup (xmlNodeGetContent (nodes));
- g_print ("object %s loaded with comment '%s'\n",
- gst_object_get_name (object), name);
+ if (!strcmp (nodes->name, "text")) {
+ gchar *name = g_strdup (xmlNodeGetContent (nodes));
+
+ g_print ("object %s loaded with comment '%s'\n",
+ gst_object_get_name (object), name);
}
nodes = nodes->next;
}
}
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstXML *xml;
GstElement *pipeline;
gboolean ret;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
xml = gst_xml_new ();
/* G_CALLBACK (xml_loaded), xml); */
if (argc == 2)
- ret = gst_xml_parse_file(xml, argv[1], NULL);
+ ret = gst_xml_parse_file (xml, argv[1], NULL);
else
- ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
-
+ ret = gst_xml_parse_file (xml, "xmlTest.gst", NULL);
+
g_assert (ret == TRUE);
- pipeline = gst_xml_get_element(xml, "pipeline");
+ pipeline = gst_xml_get_element (xml, "pipeline");
g_assert (pipeline != NULL);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
- while (gst_bin_iterate(GST_BIN(pipeline)));
+ while (gst_bin_iterate (GST_BIN (pipeline)));
- gst_element_set_state(pipeline, GST_STATE_NULL);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
- exit(0);
+ exit (0);
}
-
/* tests if gst_bin_get_(all_)by_interface works */
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstBin *bin, *bin2;
GList *list;
GstElement *filesrc;
-
+
gst_init (&argc, &argv);
bin = GST_BIN (gst_bin_new (NULL));
g_assert (filesrc);
g_assert (GST_IS_URI_HANDLER (filesrc));
gst_bin_add (bin, filesrc);
-
+
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
g_assert (list->data == (gpointer) filesrc);
g_list_free (list);
-
- gst_bin_add_many (bin,
+
+ gst_bin_add_many (bin,
gst_element_factory_make ("identity", NULL),
- gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
- NULL);
+ gst_element_factory_make ("identity", NULL), NULL);
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
gst_bin_add_many (bin,
gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
- GST_ELEMENT (bin2),
- gst_element_factory_make ("identity", NULL),
- NULL);
+ GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL);
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
GstPad *srcpad;
GstByteStream *bs;
-
- gchar *accesspattern;
- guint num_patterns;
- gchar **patterns;
- guint sizemin;
- guint sizemax;
- gint count;
- gboolean silent;
+
+ gchar *accesspattern;
+ guint num_patterns;
+ gchar **patterns;
+ guint sizemin;
+ guint sizemax;
+ gint count;
+ gboolean silent;
};
struct _GstBsTestClass
GType gst_bstest_get_type (void);
-GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS (
- "ByteStreamTest",
- "Filter",
- "Test for the GstByteStream code",
- "Erik Walthinsen <omega@temple-baptist.com>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ("ByteStreamTest",
+ "Filter",
+ "Test for the GstByteStream code",
+ "Erik Walthinsen <omega@temple-baptist.com>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* BsTest signals and args */
};
-static void gst_bstest_base_init (gpointer g_class);
-static void gst_bstest_class_init (GstBsTestClass * klass);
-static void gst_bstest_init (GstBsTest * bstest);
+static void gst_bstest_base_init (gpointer g_class);
+static void gst_bstest_class_init (GstBsTestClass * klass);
+static void gst_bstest_init (GstBsTest * bstest);
-static void gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec);
-static void gst_bstest_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec);
+static void gst_bstest_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_bstest_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_bstest_change_state (GstElement *element);
-static void gst_bstest_loop (GstElement * element);
+static GstElementStateReturn gst_bstest_change_state (GstElement * element);
+static void gst_bstest_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
(GInstanceInitFunc) gst_bstest_init,
};
- bstest_type = g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0);
+ bstest_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0);
}
return bstest_type;
}
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
- g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT,
- 0, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT,
+ 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
- g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT,
- 384, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT,
+ 384, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSPATTERN,
- g_param_spec_string ("accesspattern", "accesspattern", "accesspattern",
- "r", G_PARAM_READWRITE));
+ g_param_spec_string ("accesspattern", "accesspattern", "accesspattern",
+ "r", G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COUNT,
- g_param_spec_uint ("count", "count", "count",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("count", "count", "count",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ FALSE, G_PARAM_READWRITE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_bstest_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_bstest_get_property);
}
static GstCaps *
-gst_bstest_getcaps (GstPad *pad)
+gst_bstest_getcaps (GstPad * pad)
{
GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad));
GstPad *otherpad;
}
static guint
-gst_bstest_get_size (GstBsTest *bstest, gchar *sizestring, guint prevsize)
+gst_bstest_get_size (GstBsTest * bstest, gchar * sizestring, guint prevsize)
{
guint size;
if (sizestring[0] == 0) {
size = bstest->sizemax;
- }
- else if (sizestring[0] == 'r') {
- size = bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin));
- }
- else if (sizestring[0] == '<') {
+ } else if (sizestring[0] == 'r') {
+ size =
+ bstest->sizemin +
+ (guint8) (((gfloat) bstest->sizemax) * rand () / (RAND_MAX +
+ (gfloat) bstest->sizemin));
+ } else if (sizestring[0] == '<') {
size = prevsize;
- }
- else {
+ } else {
size = atoi (sizestring);
}
- if (size == 0) size++;
+ if (size == 0)
+ size++;
return size;
}
if (bstest->patterns[i][0] == 'r') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size);
- gst_bytestream_read (bstest->bs, &buf, size);
- }
- else if (bstest->patterns[i][0] == 'f') {
+ if (!bstest->silent)
+ g_print ("bstest: ***** read %d bytes\n", size);
+ gst_bytestream_read (bstest->bs, &buf, size);
+ } else if (bstest->patterns[i][0] == 'f') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** flush %d bytes\n", size);
- gst_bytestream_flush (bstest->bs, size);
- }
- else if (!strncmp (bstest->patterns[i], "pb", 2)) {
+ if (!bstest->silent)
+ g_print ("bstest: ***** flush %d bytes\n", size);
+ gst_bytestream_flush (bstest->bs, size);
+ } else if (!strncmp (bstest->patterns[i], "pb", 2)) {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][2], size);
- if (!bstest->silent) g_print ("bstest: ***** peek bytes %d bytes\n", size);
- gst_bytestream_peek_bytes (bstest->bs, &ptr, size);
- }
- else if (bstest->patterns[i][0] == 'p') {
+ if (!bstest->silent)
+ g_print ("bstest: ***** peek bytes %d bytes\n", size);
+ gst_bytestream_peek_bytes (bstest->bs, &ptr, size);
+ } else if (bstest->patterns[i][0] == 'p') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size);
- gst_bytestream_peek (bstest->bs, &buf, size);
+ if (!bstest->silent)
+ g_print ("bstest: ***** peek %d bytes\n", size);
+ gst_bytestream_peek (bstest->bs, &buf, size);
gst_buffer_unref (buf);
buf = NULL;
}
if (buf)
- gst_pad_push (bstest->srcpad, GST_DATA (buf));
-
+ gst_pad_push (bstest->srcpad, GST_DATA (buf));
+
i++;
}
/* } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); */
}
static void
-gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstBsTest *bstest;
g_strfreev (bstest->patterns);
}
if (g_value_get_string (value) == NULL) {
- gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
- bstest->accesspattern = NULL;
- bstest->num_patterns = 0;
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ bstest->accesspattern = NULL;
+ bstest->num_patterns = 0;
} else {
guint i = 0;
- bstest->accesspattern = g_strdup (g_value_get_string (value));
- bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
- while (bstest->patterns[i++]);
- bstest->num_patterns = i-1;
+ bstest->accesspattern = g_strdup (g_value_get_string (value));
+ bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
+ while (bstest->patterns[i++]);
+ bstest->num_patterns = i - 1;
}
break;
case ARG_COUNT:
}
static void
-gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_bstest_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstBsTest *bstest;
}
static GstElementStateReturn
-gst_bstest_change_state (GstElement *element)
+gst_bstest_change_state (GstElement * element)
{
GstBsTest *bstest;
gst_bytestream_destroy (bstest->bs);
bstest->bs = NULL;
}
- }
- else {
+ } else {
if (!bstest->bs) {
bstest->bs = gst_bytestream_new (bstest->sinkpad);
}
* This consists of the name of the element, the GType identifier,
* and a pointer to the details structure at the top of the file.
*/
- return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, GST_TYPE_BSTEST);
+ return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY,
+ GST_TYPE_BSTEST);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "bstest",
- "test for the bytestream element",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "bstest",
+ "test for the bytestream element",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
static gboolean dump = FALSE;
static void
-handoff (GstElement *element, GstBuffer *buf, GstPad *pad, gpointer data)
+handoff (GstElement * element, GstBuffer * buf, GstPad * pad, gpointer data)
{
if (GST_IS_BUFFER (buf)) {
if (integrity_check) {
gint i;
guint8 *ptr = GST_BUFFER_DATA (buf);
-
- for (i=0; i<GST_BUFFER_SIZE (buf); i++) {
- if (*ptr++ != count++) {
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf); i++) {
+ if (*ptr++ != count++) {
g_print ("data error!\n");
return;
- }
+ }
}
}
- }
- else {
+ } else {
g_print ("not a buffer ! %p\n", buf);
}
}
-static gchar*
-create_desc (TestParam *param)
+static gchar *
+create_desc (TestParam * param)
{
gchar *desc;
- desc = g_strdup_printf ("%s %s, pattern %s", (param->src_sizetype == 2 ? "fixed" : "random"),
- (param->src_data == 1 ? "src" : "subbuffer"),
- param->bs_accesspattern);
+ desc =
+ g_strdup_printf ("%s %s, pattern %s",
+ (param->src_sizetype == 2 ? "fixed" : "random"),
+ (param->src_data == 1 ? "src" : "subbuffer"), param->bs_accesspattern);
return desc;
}
-static gboolean
-read_param_file (gchar *filename)
+static gboolean
+read_param_file (gchar * filename)
{
FILE *fp;
- gchar line[MAX_CONFIG_LINE+1];
+ gchar line[MAX_CONFIG_LINE + 1];
guint linenr = 0;
gchar pattern[MAX_CONFIG_PATTERN];
gint data, sizetype, integrity_check;
gboolean res = TRUE;
fp = fopen (filename, "r");
- if (fp == NULL)
+ if (fp == NULL)
return FALSE;
- scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN-1);
-
- while (fgets (line, MAX_CONFIG_LINE, fp)) {
+ scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN - 1);
+
+ while (fgets (line, MAX_CONFIG_LINE, fp)) {
linenr++;
if (line[0] == '\n' || line[0] == '#')
continue;
- if (sscanf (line, scan_str, &data, &sizetype, pattern, &integrity_check) != 4) {
+ if (sscanf (line, scan_str, &data, &sizetype, pattern,
+ &integrity_check) != 4) {
g_print ("error on line: %d\n", linenr);
res = FALSE;
break;
- }
- else {
+ } else {
TestParam *param = g_malloc (sizeof (TestParam));
param->src_data = data;
}
}
g_free (scan_str);
-
+
return res;
}
-static void
-run_test (GstBin *pipeline, gint iters)
+static void
+run_test (GstBin * pipeline, gint iters)
{
gint vm = 0;
gint maxiters = iters;
gint newvm = gst_alloc_trace_live_all ();
gint percent;
- percent = (gint)((maxiters-iters+1)*100.0/maxiters);
+ percent = (gint) ((maxiters - iters + 1) * 100.0 / maxiters);
if (percent != prev_percent || newvm - vm > VM_THRES) {
- g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, percent);
+ g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm,
+ percent);
prev_percent = percent;
vm = newvm;
}
gst_bin_iterate (pipeline);
- if (iters > 0) iters--;
+ if (iters > 0)
+ iters--;
}
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
}
-static void
+static void
usage (char *argv[])
{
- g_print ("usage: %s [--verbose] [--dump] <paramfile> <iterations>\n", argv[0]);
+ g_print ("usage: %s [--verbose] [--dump] <paramfile> <iterations>\n",
+ argv[0]);
}
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *src;
GstElement *sink;
gst_init (&argc, &argv);
arg_walk = 1;
- while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) {
+ while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) {
if (!strncmp (argv[arg_walk], "--verbose", 9))
verbose = TRUE;
else if (!strncmp (argv[arg_walk], "--dump", 6))
arg_walk++;
}
if (argc - arg_walk < 2) {
- usage(argv);
+ usage (argv);
return -1;
}
- if (!read_param_file (argv[arg_walk])) {
+ if (!read_param_file (argv[arg_walk])) {
g_print ("error reading file %s\n", argv[arg_walk]);
usage (argv);
return -1;
integrity_check = param->integrity_check;
- g_print ("\n\nrunning test %d (%d iterations):\n", testnum+1, iterations);
+ g_print ("\n\nrunning test %d (%d iterations):\n", testnum + 1, iterations);
desc = create_desc (param);
g_print ("%s\n", desc);
g_free (desc);
- g_object_set (G_OBJECT (src), "data", param->src_data,
- "sizetype", param->src_sizetype,
- "filltype", (integrity_check?5:0),
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (src), "data", param->src_data,
+ "sizetype", param->src_sizetype,
+ "filltype", (integrity_check ? 5 : 0), "silent", !verbose, NULL);
- g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern,
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern,
+ "silent", !verbose, NULL);
- g_object_set (G_OBJECT (sink), "dump", dump,
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (sink), "dump", dump, "silent", !verbose, NULL);
run_test (GST_BIN (pipeline), iterations);
static GstCaps *
-handler (GObject *object, GstCaps *caps, gpointer user_data)
+handler (GObject * object, GstCaps * caps, gpointer user_data)
{
- g_print("in handler %p, %p, %p\n", object, caps, user_data);
+ g_print ("in handler %p, %p, %p\n", object, caps, user_data);
- g_assert (GST_IS_PAD(object));
+ g_assert (GST_IS_PAD (object));
- g_print("caps: %s\n", gst_caps_to_string(caps));
+ g_print ("caps: %s\n", gst_caps_to_string (caps));
if (gst_caps_is_any (caps)) {
return gst_caps_new_simple ("application/x-foo",
GstElement *pipeline;
GstPad *pad;
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
pipeline = gst_pipeline_new (NULL);
b = gst_element_factory_make ("fakesink", NULL);
g_assert (b);
- gst_bin_add_many (GST_BIN (pipeline), a,b, NULL);
- gst_element_link (a,b);
+ gst_bin_add_many (GST_BIN (pipeline), a, b, NULL);
+ gst_element_link (a, b);
pad = gst_element_get_pad (a, "src");
g_signal_connect (G_OBJECT (pad), "fixate", G_CALLBACK (handler),
- (void *)0xdeadbeef);
+ (void *) 0xdeadbeef);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
return 0;
}
-
#include <gst/gst.h>
-void test1(void)
+void
+test1 (void)
{
GstCaps *caps;
GstCaps *caps2;
- g_print("type is %d\n", (int)gst_caps_get_type());
+ g_print ("type is %d\n", (int) gst_caps_get_type ());
- caps = gst_caps_new_empty();
- g_assert(caps != NULL);
- gst_caps_free(caps);
+ caps = gst_caps_new_empty ();
+ g_assert (caps != NULL);
+ gst_caps_free (caps);
- caps = gst_caps_new_any();
- g_assert(caps != NULL);
- gst_caps_free(caps);
+ caps = gst_caps_new_any ();
+ g_assert (caps != NULL);
+ gst_caps_free (caps);
- caps = gst_caps_new_simple("audio/raw",
- "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
- caps = gst_caps_new_simple("audio/raw",
+ caps = gst_caps_new_simple ("audio/raw",
"_double", G_TYPE_DOUBLE, 100.0, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw",
- "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC('a','b','c','d'), NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw",
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw",
+ "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'), NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw",
"_boolean", G_TYPE_BOOLEAN, TRUE, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw2", "_int", G_TYPE_INT, 100, NULL),
- NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- caps2 = gst_caps_copy(caps);
- g_assert(caps2 != NULL);
- g_assert(gst_caps_is_empty(caps2)==FALSE);
- g_assert(gst_caps_is_any(caps2)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps2)==TRUE);
- g_assert(gst_caps_is_fixed(caps2)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- g_print("%s\n", gst_caps_to_string(caps2));
- gst_caps_free(caps);
- gst_caps_free(caps2);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- gst_caps_append (caps,
- gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 200, NULL));
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- gst_caps_append_structure (caps,
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL));
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw2", "_int", G_TYPE_INT, 100,
+ NULL), NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ caps2 = gst_caps_copy (caps);
+ g_assert (caps2 != NULL);
+ g_assert (gst_caps_is_empty (caps2) == FALSE);
+ g_assert (gst_caps_is_any (caps2) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps2) == TRUE);
+ g_assert (gst_caps_is_fixed (caps2) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ g_print ("%s\n", gst_caps_to_string (caps2));
+ gst_caps_free (caps);
+ gst_caps_free (caps2);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ gst_caps_append (caps,
+ gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 200, NULL));
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ gst_caps_append_structure (caps,
+ gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, NULL));
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
}
-void test2(void)
+void
+test2 (void)
{
GstCaps *caps1;
GstCaps *caps2;
GstCaps *caps;
- caps1 = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL),
- NULL);
- caps2 = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 300, NULL),
- NULL);
- caps = gst_caps_intersect(caps1, caps2);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
- gst_caps_free(caps1);
- gst_caps_free(caps2);
+ caps1 =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200,
+ NULL), NULL);
+ caps2 =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 300,
+ NULL), NULL);
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
- test2();
+ test1 ();
+ test2 ();
return 0;
}
-
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS(
- "video/mpeg, "
- "mpegtype=(int)[1,2]"
-);
-
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS(
- "video/mpeg, "
- "mpegtype=(int)1"
-);
-
-GstStaticCaps rawcaps = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){YV12,YUY2}, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc)YUY2, "
- "height=(int)[16,256]"
-);
-
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
- "video/raw, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)[1,2]");
+
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1");
+
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
- "height=(int)[16,4096]"
-);
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc)YUY2, " "height=(int)[16,256]");
+
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, " "height=(int)[16,4096]");
#if 0
/* these caps aren't used yet */
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){\"YV12\", \"YUYV\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
- "height=(int)[16,4096]"
-);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " "height=(int)[16,4096]");
#endif
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YUYV\""
-);
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\"");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YV12\""
-);
+GstStaticCaps rawcaps7 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\"");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
gboolean testret;
gint ret = 0;
gst_static_caps_get (&rawcaps));
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
-
+
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&sinkcaps));
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
-
+
testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
#include <gst/gst.h>
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
#if 0
GstCaps *caps;
-
+
gst_init (&argc, &argv);
- caps = GST_CAPS_NEW (
- "testcaps",
- "unknown/unknown",
- NULL);
+ caps = GST_CAPS_NEW ("testcaps", "unknown/unknown", NULL);
/* newly crrated caps without props is fixed */
g_assert (GST_CAPS_IS_FIXED (caps));
-
+
entry = gst_props_entry_new ("foo", GST_PROPS_INT (5));
/* this entry is fixed */
g_assert (gst_props_entry_is_fixed (entry));
props = gst_props_empty_new ();
/* props are fixed when created */
g_assert (GST_PROPS_IS_FIXED (props));
-
+
gst_props_add_entry (props, entry);
/* props should still be fixed */
g_assert (GST_PROPS_IS_FIXED (props));
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
- gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1,5));
+ gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1, 5));
/* props should be variable again now */
g_assert (!GST_PROPS_IS_FIXED (props));
/* caps too */
#include <gst/gst.h>
-GstStaticCaps rawcaps1 = GST_STATIC_CAPS(
- "video/x-raw-yuv, "
+GstStaticCaps rawcaps1 = GST_STATIC_CAPS ("video/x-raw-yuv, "
"fourcc:fourcc=\"YUYV\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0; "
- "video/x-raw-yuv, "
+ "video/x-raw-yuv, "
"fourcc:fourcc=\"I420\", "
- "height:int=640, "
- "width:int=480, "
- "framerate:float=30.0"
-);
+ "height:int=640, " "width:int=480, " "framerate:float=30.0");
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
- "video/x-raw-yuv"
-);
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/x-raw-yuv");
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
- "video/x-raw-yuv, height=(int) [ 0, MAX ]"
-);
+GstStaticCaps rawcaps3 =
+GST_STATIC_CAPS ("video/x-raw-yuv, height=(int) [ 0, MAX ]");
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"
-);
+GstStaticCaps rawcaps4 =
+ GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY");
-GstStaticCaps rawcaps5 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"
-);
+GstStaticCaps rawcaps5 =
+ GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]");
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
-);
+GstStaticCaps rawcaps6 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps7 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]");
-GstStaticCaps rawcaps8 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
-);
+GstStaticCaps rawcaps8 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstCaps *caps1;
GstCaps *caps2;
gst_init (&argc, &argv);
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1));
- caps2 = gst_caps_new_full (gst_structure_copy ( gst_caps_get_structure (
- gst_static_caps_get (&rawcaps1), 0)), NULL);
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps1));
+ caps2 =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure
+ (gst_static_caps_get (&rawcaps1), 0)), NULL);
#if 0
- gst_caps_set(caps1, "height", GST_PROPS_INT(640));
- gst_caps_set(caps1, "width", GST_PROPS_INT(480));
- gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0));
+ gst_caps_set (caps1, "height", GST_PROPS_INT (640));
+ gst_caps_set (caps1, "width", GST_PROPS_INT (480));
+ gst_caps_set (caps1, "framerate", GST_PROPS_FLOAT (30.0));
#endif
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3));
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5));
- caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6));
- caps4 = gst_caps_intersect(caps1, caps2);
- caps = gst_caps_intersect(caps3, caps4);
- g_print("caps4 %s\n", gst_caps_to_string(caps4));
- g_print("caps %s\n", gst_caps_to_string(caps));
- gst_caps_free(caps1);
- gst_caps_free(caps2);
- gst_caps_free(caps3);
- gst_caps_free(caps4);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8));
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps2));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps3));
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps4));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps5));
+ caps3 = gst_caps_copy (gst_static_caps_get (&rawcaps6));
+ caps4 = gst_caps_intersect (caps1, caps2);
+ caps = gst_caps_intersect (caps3, caps4);
+ g_print ("caps4 %s\n", gst_caps_to_string (caps4));
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+ gst_caps_free (caps3);
+ gst_caps_free (caps4);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps7));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps8));
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
return 0;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype=(int)1, "
- "foo1=(int)[20,40], "
- "foo2=(int)[20,40], "
- "foo3=(int)[10,20]"
-);
+ "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype=(int)1, "
- "foo1=(int)30, "
- "foo2=(int)[20,30], "
- "foo3=(int)[20,30]"
-);
-
-
-
-GstStaticCaps rawcaps = GST_STATIC_CAPS (
- "video/raw, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
- "video/raw, "
- "height=(int)[16,256], "
- "depth=(int)16"
-);
-
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUY2\", \"YV12\" }, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps5 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS (
- "video/raw, "
+ "foo1=(int)30, " "foo2=(int)[20,30], " "foo3=(int)[20,30]");
+
+
+
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
+ "height=(int)[16,256], " "depth=(int)16");
+
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps5 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc)\"YUYV\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0; "
- "video/raw, "
+ "video/raw, "
"fourcc=(fourcc)\"I420\", "
- "height=(int)640, "
- "width=(int)480, "
- "framerate=(double)30.0"
-);
+ "height=(int)640, " "width=(int)480, " "framerate=(double)30.0");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS (
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps7 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]");
-GstStaticCaps rawcaps8 = GST_STATIC_CAPS (
- "video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps8 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
xmlDocPtr doc;
xmlNodePtr parent;
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
/*
- g_mem_chunk_info ();
- for (i = 0; i<100000; i++) {
- caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
- gst_caps_unref (caps);
- }
- g_mem_chunk_info ();
- */
+ g_mem_chunk_info ();
+ for (i = 0; i<100000; i++) {
+ caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
+ gst_caps_unref (caps);
+ }
+ g_mem_chunk_info ();
+ */
caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6),
- gst_caps_new_full (gst_structure_copy (
- gst_caps_get_structure (gst_static_caps_get (&rawcaps6), 0)), NULL));
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure
+ (gst_static_caps_get (&rawcaps6), 0)), NULL));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps7),
gst_static_caps_get (&rawcaps8));
- g_print("intersection: %s\n", gst_caps_to_string (caps));
+ g_print ("intersection: %s\n", gst_caps_to_string (caps));
- xmlDocDump(stdout, doc);
+ xmlDocDump (stdout, doc);
return 0;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "foo1=(int)[20,40], "
- "foo2=(int)[20,40], "
- "foo3=(int)[10,20]"
-);
+ "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "foo4=(fourcc){\"YV12\",\"YUY2\"}"
-);
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "foo4=(fourcc){\"YV12\",\"YUY2\"}");
-GstStaticCaps rawcaps = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,4096], "
- "height=(int)[16,4096], "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}"
-);
+ "height=(int)[16,4096], " "fourcc=(fourcc){\"YV12\",\"YUY2\"}");
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
- "video/raw, "
- "width=(int)[16,256], "
- "height=(int)16; "
- "video/raw, "
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,256], "
- "height=(int)16"
-);
+ "height=(int)16; " "video/raw, " "width=(int)[16,256], " "height=(int)16");
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
- "video/raw, "
+ "video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]");
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
- "x, "
- "y=(int){1,2}, "
- "z=(int){3,4}; "
- "a, "
- "b=(int){5,6}, "
- "c=(int){7,8}"
-);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("x, "
+ "y=(int){1,2}, " "z=(int){3,4}; " "a, " "b=(int){5,6}, " "c=(int){7,8}");
/* defined, not used
GST_CAPS_FACTORY (rawcaps4,
);
*/
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstCaps *caps;
#include <gst/gst.h>
#include <string.h>
-GstStaticCaps caps1 = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype=(int){1,2}"
-);
-
-GstStaticCaps caps2 = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype=(int){1}"
-);
-
-GstStaticCaps caps3 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps4 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc)\"YV12\", "
- "height=(int)[16,256]"
-);
-
-GstStaticCaps caps5 = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps caps1 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1,2}");
+
+GstStaticCaps caps2 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1}");
+
+GstStaticCaps caps3 = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps6 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps7 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps8 = GST_STATIC_CAPS (
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YUYV\""
-);
-
-GstStaticCaps caps9 = GST_STATIC_CAPS (
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YV12\""
-);
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps caps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc)\"YV12\", " "height=(int)[16,256]");
+
+GstStaticCaps caps5 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps6 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps7 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps8 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\"");
+
+GstStaticCaps caps9 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\"");
static gint test = 0;
static gint failures = 0;
} \
}G_STMT_END
static void
-test_caps_func (const GstCaps *caps)
+test_caps_func (const GstCaps * caps)
{
- gchar *str1, *str2;
+ gchar *str1, *str2;
gboolean ret = FALSE;
str1 = gst_caps_to_string (caps);
TEST_END (ret);
}
static void
-test_caps (const GstCaps *caps)
+test_caps (const GstCaps * caps)
{
TEST_START;
test_caps_func (caps);
}
static void
-test_string (gchar *str)
+test_string (gchar * str)
{
GstCaps *caps;
test_caps_func (caps);
}
static void
-test_string_fail (gchar *str)
+test_string_fail (gchar * str)
{
GstCaps *caps;
TEST_START;
g_print ("%3d, INFO : checking %s for failure\n", test, str);
caps = gst_caps_from_string (str);
-g_print("got %p\n", caps);
+ g_print ("got %p\n", caps);
TEST_END (caps == NULL);
}
-int
-main (int argc, char *argv[])
+
+int
+main (int argc, char *argv[])
{
gst_init (&argc, &argv);
-goto bla;
+ goto bla;
bla:
/* stupidity tests */
test_caps (gst_caps_new_simple ("audio/raw", NULL));
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]");
test_string ("audio/raw, test =(i) [(int)1,2]");
test_string ("audio/raw, test={(int)1,2}");
- test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
+ test_string
+ ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
test_string ("audio/raw, test= {1.0}");
test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test= {(int)1,2}");
test_string ("audio/raw, test= {(int)1,2}");
-
+
/* prop concatenations */
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1");
- test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
+ test_string
+ ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}");
- test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
+ test_string
+ ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
/* caps concatenations */
- test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
- test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
- test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
+ test_string
+ ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
+ test_string
+ ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
+ test_string
+ ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
/* mimes */
test_string_fail ("audio/raw, test= '");
if (failures) {
- g_print ("\n FAILURES : %d\n", failures);
+ g_print ("\n FAILURES : %d\n", failures);
} else {
- g_print ("\n DONE\n");
+ g_print ("\n DONE\n");
}
return failures;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype:int=1, "
- "foo1:int=[20,40], "
- "foo2:int=[20,40], "
- "foo3:int=[10,20]"
-);
+ "foo1:int=[20,40], " "foo2:int=[20,40], " "foo3:int=[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype:int=1, "
- "foo1:int=30, "
- "foo2:int=[20,30], "
- "foo3:int=[20,30]"
-);
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
+ "mpegtype:int=1, " "foo1:int=30, " "foo2:int=[20,30], " "foo3:int=[20,30]");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
xmlDocPtr doc;
xmlNodePtr parent;
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
- xmlDocDump(stdout, doc);
+ xmlDocDump (stdout, doc);
return 0;
}
#include <gst/gst.h>
#include <glib.h>
-void test1(void)
+void
+test1 (void)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
//GValue value3 = { 0 };
//gboolean ret;
- g_value_init(&value1, G_TYPE_INT);
- g_value_set_int(&value1, 10);
- g_value_init(&value2, G_TYPE_INT);
- g_value_set_int(&value2, 20);
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_INT);
+ g_value_set_int (&value1, 10);
+ g_value_init (&value2, G_TYPE_INT);
+ g_value_set_int (&value2, 20);
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, G_TYPE_DOUBLE);
- g_value_set_double(&value1, 10);
- g_value_init(&value2, G_TYPE_DOUBLE);
- g_value_set_double(&value2, 20);
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_DOUBLE);
+ g_value_set_double (&value1, 10);
+ g_value_init (&value2, G_TYPE_DOUBLE);
+ g_value_set_double (&value2, 20);
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, G_TYPE_STRING);
- g_value_set_string(&value1, "a");
- g_value_init(&value2, G_TYPE_STRING);
- g_value_set_string(&value2, "b");
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_STRING);
+ g_value_set_string (&value1, "a");
+ g_value_init (&value2, G_TYPE_STRING);
+ g_value_set_string (&value2, "b");
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&value1, GST_MAKE_FOURCC('a','b','c','d'));
- g_value_init(&value2, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&value2, GST_MAKE_FOURCC('1','2','3','4'));
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_UNORDERED);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&value1, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'));
+ g_value_init (&value2, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&value2, GST_MAKE_FOURCC ('1', '2', '3', '4'));
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
+ test1 ();
return 0;
}
-
-
#include <gst/gst.h>
-void test1(void)
+void
+test1 (void)
{
GValue dest = { 0 };
GValue src1 = { 0 };
GValue src2 = { 0 };
gboolean ret;
- g_value_init(&src1, G_TYPE_INT);
- g_value_set_int(&src1, 10);
- g_value_init(&src2, G_TYPE_INT);
- g_value_set_int(&src1, 20);
- ret = gst_value_intersect(&dest, &src1, &src2);
- g_assert(ret == 0);
- g_print("ret = %d\n",ret);
+ g_value_init (&src1, G_TYPE_INT);
+ g_value_set_int (&src1, 10);
+ g_value_init (&src2, G_TYPE_INT);
+ g_value_set_int (&src1, 20);
+ ret = gst_value_intersect (&dest, &src1, &src2);
+ g_assert (ret == 0);
+ g_print ("ret = %d\n", ret);
}
-void test2(void)
+void
+test2 (void)
{
GValue dest = { 0 };
GValue src1 = { 0 };
GValue item = { 0 };
gboolean ret;
- g_value_init(&src1, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&src1, GST_MAKE_FOURCC('Y','U','Y','2'));
- g_value_init(&src2, GST_TYPE_LIST);
- g_value_init(&item, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('Y','U','Y','2'));
+ g_value_init (&src1, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&src1, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ g_value_init (&src2, GST_TYPE_LIST);
+ g_value_init (&item, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
gst_value_list_append_value (&src2, &item);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('I','4','2','0'));
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('I', '4', '2', '0'));
gst_value_list_append_value (&src2, &item);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('A','B','C','D'));
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('A', 'B', 'C', 'D'));
gst_value_list_append_value (&src2, &item);
- ret = gst_value_intersect(&dest, &src1, &src2);
- g_print("ret = %d\n",ret);
+ ret = gst_value_intersect (&dest, &src1, &src2);
+ g_print ("ret = %d\n", ret);
- g_print("type = %s\n", g_type_name(G_VALUE_TYPE(&dest)));
- g_print("value = %s\n", g_strdup_value_contents(&dest));
+ g_print ("type = %s\n", g_type_name (G_VALUE_TYPE (&dest)));
+ g_print ("value = %s\n", g_strdup_value_contents (&dest));
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
- test2();
+ test1 ();
+ test2 ();
return 0;
}
-
-
GstElement *fakesrc, *fakesink;
GstElement *pipeline;
-
+
pipeline = gst_pipeline_new ("main_pipeline");
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 1000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
bin = gst_bin_new ("bin");
fakesink = gst_element_factory_make ("fakesink", "fakesink");
gst_bin_add (GST_BIN (bin), fakesink);
- gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), "sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"),
+ "sink");
gst_element_link (fakesrc, bin);
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 1000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
queue = gst_element_factory_make ("queue", "queue");
gst_bin_add (GST_BIN (thread), fakesink);
gst_bin_add (GST_BIN (thread), queue);
- gst_element_link (queue, fakesink);
- gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), "sink");
+ gst_element_link (queue, fakesink);
+ gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"),
+ "sink");
gst_element_link (fakesrc, thread);
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 10000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc;
gint i;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
gst_bin_add (GST_BIN (bin), fakesink);
gst_bin_add (GST_BIN (pipeline), bin);
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
#include <gst/gst.h>
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *element;
gint i = 1000;
gint step = 100;
-
- free (malloc(8)); /* -lefence */
+
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
bin = gst_pipeline_new ("pipeline");
- while (i--)
- {
+ while (i--) {
GstPad *pad;
if (i % step == 0)
fprintf (stderr, "\r%10d", i);
element = gst_element_factory_make ("tee", "tee");
- if (!element)
+ if (!element)
break;
pad = gst_element_get_request_pad (element, "src%d");
#include <gst/gst.h>
void
-gst_clock_debug (GstClock *clock)
+gst_clock_debug (GstClock * clock)
{
- g_print ("Clock info: time %"G_GUINT64_FORMAT"\n",
- gst_clock_get_time (clock));
+ g_print ("Clock info: time %" G_GUINT64_FORMAT "\n",
+ gst_clock_get_time (clock));
}
-
+
int
main (int argc, char *argv[])
{
gst_init (&argc, &argv);
- if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL)
- {
+ if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) {
g_print ("Could not create a fakesrc element !\n");
return 1;
}
- if ((id = gst_element_factory_make ("identity", "filter")) == NULL)
- {
+ if ((id = gst_element_factory_make ("identity", "filter")) == NULL) {
g_print ("Could not create a identity element !\n");
return 1;
}
- if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL)
- {
+ if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) {
g_print ("Could not create a fakesink element !\n");
return 1;
}
- if ((pipeline = gst_pipeline_new ("pipeline")) == NULL)
- {
+ if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) {
g_print ("Could not create a pipeline element !\n");
return 1;
}
#include <gst/gst.h>
void
-gst_clock_debug (GstClock *clock, GstElement *fakesink)
+gst_clock_debug (GstClock * clock, GstElement * fakesink)
{
- g_print ("Clock info: time %"G_GUINT64_FORMAT" - Element info: time %"G_GUINT64_FORMAT"\n",
- gst_clock_get_time (clock), gst_element_get_time (fakesink));
+ g_print ("Clock info: time %" G_GUINT64_FORMAT " - Element info: time %"
+ G_GUINT64_FORMAT "\n", gst_clock_get_time (clock),
+ gst_element_get_time (fakesink));
}
-
+
int
main (int argc, char *argv[])
{
gst_bin_add_many (GST_BIN (pipeline), fakesink, fakesrc, NULL);
gst_element_link (fakesrc, fakesink);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
gst_clock_debug (clock, fakesink);
g_usleep (G_USEC_PER_SEC);
gst_clock_debug (clock, fakesink);
gst_element_wait (fakesink, 2 * GST_SECOND);
gst_clock_debug (clock, fakesink);
-
+
gst_element_wait (fakesink, 5 * GST_SECOND);
gst_clock_debug (clock, fakesink);
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
#define GST_CAT_DEFAULT cat
GST_DEBUG_CATEGORY_STATIC (cat_static);
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GSList *before, *after;
unsetenv ("GST_DEBUG");
gst_init (&argc, &argv);
-
+
before = gst_debug_get_all_categories ();
- GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, "default category for this test");
- GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
- "static category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
+ "default category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
+ "static category for this test");
after = gst_debug_get_all_categories ();
g_print ("removing default log function\n");
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
- g_print ("checking, if the two new categories are put into the category list correctly...\n");
+ g_print
+ ("checking, if the two new categories are put into the category list correctly...\n");
g_assert (g_slist_length (after) - g_slist_length (before) == 2);
/* check the _get stuff */
- g_print ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
+ g_print
+ ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
- g_assert (strcmp (gst_debug_category_get_description (cat), "default category for this test") == 0);
- g_assert (gst_debug_category_get_threshold (cat) == gst_debug_get_default_threshold());
- g_assert (strcmp (gst_debug_category_get_name (cat_static), "cat_static") == 0);
+ g_assert (strcmp (gst_debug_category_get_description (cat),
+ "default category for this test") == 0);
+ g_assert (gst_debug_category_get_threshold (cat) ==
+ gst_debug_get_default_threshold ());
+ g_assert (strcmp (gst_debug_category_get_name (cat_static),
+ "cat_static") == 0);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
- g_assert (strcmp (gst_debug_category_get_description (cat_static), "static category for this test") == 0);
- g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold());
+ g_assert (strcmp (gst_debug_category_get_description (cat_static),
+ "static category for this test") == 0);
+ g_assert (gst_debug_category_get_threshold (cat_static) ==
+ gst_debug_get_default_threshold ());
/* check if setting levels for names work */
- g_print ("checking if changing threshold for names affects existing categories...\n");
+ g_print
+ ("checking if changing threshold for names affects existing categories...\n");
gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
- g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
- g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold());
+ g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
+ g_assert (gst_debug_category_get_threshold (cat_static) ==
+ gst_debug_get_default_threshold ());
gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
-
+
g_print ("everything ok.\n");
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
GST_DEBUG_CATEGORY (cat);
GST_DEBUG_CATEGORY_STATIC (cat_static);
-static const gchar* lines[] = {
+static const gchar *lines[] = {
"--gst-debug-disable",
"--gst-debug-no-color",
"--gst-debug-level=4",
"--gst-debug=cat:4,cat_*:3",
- "--gst-debug-level=4 --gst-debug=cat_*:5"
+ "--gst-debug-level=4 --gst-debug=cat_*:5"
};
static void
-debug_not_reached (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, GstDebugMessage *message,
- gpointer thread)
+debug_not_reached (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ GstDebugMessage * message, gpointer thread)
{
g_assert_not_reached ();
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
if (argc == 1) {
/* this is the main run that calls the others */
gint i, runs, exit;
gchar *command;
-
+
unsetenv ("GST_DEBUG");
gst_init (&argc, &argv);
runs = G_N_ELEMENTS (lines);
for (i = 0; i < runs; i++) {
command = g_strdup_printf ("%s %s %d", argv[0], lines[i], i);
g_print ("running \"%s\"\n", command);
- g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, NULL) == TRUE);
+ g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit,
+ NULL) == TRUE);
g_assert (exit == 0);
g_print ("\"%s\" worked as expected.\n", command);
g_free (command);
}
-
+
return 0;
} else {
gst_init (&argc, &argv);
if (argc != 2) {
- g_print ("something funny happened to the command line arguments, aborting.\n");
+ g_print
+ ("something funny happened to the command line arguments, aborting.\n");
return 1;
}
gst_debug_remove_log_function (gst_debug_log_default);
GST_ERROR ("This will not be seen");
return 0;
case '1':
- return gst_debug_is_colored () ? 1 : 0;
+ return gst_debug_is_colored ()? 1 : 0;
case '2':
g_assert (gst_debug_get_default_threshold () == 4);
g_assert (gst_debug_category_get_threshold (cat) == 4);
return -1;
}
}
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define ITERATIONS 20
/* stupid logging functions */
-static void gst_debug_log_one (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- gchar * message,
- gpointer thread) G_GNUC_NO_INSTRUMENT;
-static void gst_debug_log_two (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- gchar * message,
- gpointer thread) G_GNUC_NO_INSTRUMENT;
-
static void
-gst_debug_log_one (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, gchar *message,
- gpointer thread)
+gst_debug_log_one (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line, GObject * object, gchar * message, gpointer thread)
+ G_GNUC_NO_INSTRUMENT;
+ static void gst_debug_log_two (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line,
+ GObject * object, gchar * message, gpointer thread) G_GNUC_NO_INSTRUMENT;
+
+ static void
+ gst_debug_log_one (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ gchar * message, gpointer thread)
{
}
static void
-gst_debug_log_two (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, gchar *message,
- gpointer thread)
+gst_debug_log_two (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ gchar * message, gpointer thread)
{
}
g_print ("iteration %d of thread %d starting\n", i, num);
/* do some stuff with global settings */
gst_debug_set_default_threshold (GST_LEVEL_DEBUG);
- gst_debug_add_log_function (gst_debug_log_one, g_thread_self());
+ gst_debug_add_log_function (gst_debug_log_one, g_thread_self ());
gst_debug_add_log_function (gst_debug_log_two, NULL);
/* reset all the stuff we did */
gst_debug_set_default_threshold (GST_LEVEL_DEFAULT);
- g_assert (gst_debug_remove_log_function_by_data (g_thread_self()) == 1);
+ g_assert (gst_debug_remove_log_function_by_data (g_thread_self ()) == 1);
}
-
+
g_print ("Thread %d is done.\n", num);
return threadnum;
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
gint i;
GThread *threads[THREAD_COUNT];
-
+
g_print ("initializing GStreamer\n");
gst_init (&argc, &argv);
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
/* some checks for defaults */
g_print ("Doing startup checks\n");
g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT);
-
+
g_print ("creating %d threads\n", THREAD_COUNT);
for (i = 0; i < THREAD_COUNT; i++) {
- g_assert ((threads[i] = g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL)));
+ g_assert ((threads[i] =
+ g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL)));
}
g_print ("joining %d threads\n", THREAD_COUNT);
for (i = 0; i < THREAD_COUNT; i++) {
/* some checks if everything worked */
g_print ("Doing shutdown checks\n");
g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT);
- g_assert (gst_debug_remove_log_function (gst_debug_log_two) == THREAD_COUNT * ITERATIONS);
-
+ g_assert (gst_debug_remove_log_function (gst_debug_log_two) ==
+ THREAD_COUNT * ITERATIONS);
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
GST_DEBUG_CATEGORY_STATIC (cat_default);
static GstElement *pipeline;
static void
-check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, GstDebugMessage *message,
- gpointer unused)
+check_message (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ GstDebugMessage * message, gpointer unused)
{
gint temp;
-
+
/* these checks require count to be set right. So the order in the main
funtion is actually important. */
/* <0 means no checks */
- if (count < 0) return;
-
+ if (count < 0)
+ return;
+
g_print ("expecting \"%s\"...", (gchar *) message);
/* level */
temp = (count % 5) + 1;
g_print ("[OK]\n");
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, "default category for this test");
- GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, "second category for this test");
+
+ GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0,
+ "default category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0,
+ "second category for this test");
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
- gst_debug_add_log_function (check_message, NULL);
-
+ gst_debug_add_log_function (check_message, NULL);
+
count = 0;
GST_ERROR ("This is an error.");
++count;
++count;
GST_LOG_OBJECT (pipeline, "This is a log message with object.");
++count;
- GST_CAT_ERROR_OBJECT (cat2, pipeline, "This is an error with category and object.");
+ GST_CAT_ERROR_OBJECT (cat2, pipeline,
+ "This is an error with category and object.");
++count;
- GST_CAT_WARNING_OBJECT (cat2, pipeline, "This is a warning with category and object.");
+ GST_CAT_WARNING_OBJECT (cat2, pipeline,
+ "This is a warning with category and object.");
++count;
- GST_CAT_INFO_OBJECT (cat2, pipeline, "This is an info message with category and object.");
+ GST_CAT_INFO_OBJECT (cat2, pipeline,
+ "This is an info message with category and object.");
++count;
- GST_CAT_DEBUG_OBJECT (cat2, pipeline, "This is a debug message with category and object.");
+ GST_CAT_DEBUG_OBJECT (cat2, pipeline,
+ "This is a debug message with category and object.");
++count;
- GST_CAT_LOG_OBJECT (cat2, pipeline, "This is a log message with category and object.");
+ GST_CAT_LOG_OBJECT (cat2, pipeline,
+ "This is a log message with category and object.");
count = -1;
- g_assert (gst_debug_remove_log_function (check_message) == 1);
-
+ g_assert (gst_debug_remove_log_function (check_message) == 1);
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstCaps *caps;
GstElement *element;
int zero = 0;
gst_init (&argc, &argv);
-
+
caps = gst_caps_from_string ("audio/x-raw-int, rate=44100");
element = gst_element_factory_make ("identity", NULL);
GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL);
GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero);
//GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1);
-
+
return 0;
}
GstPad *sinkpad;
GstPad *srcpad;
GstDParamManager *dpman;
-
+
gfloat float1;
gfloat float2;
gboolean bool1;
};
-static void gst_dptest_base_init (gpointer g_class);
-static void gst_dptest_class_init (GstDpTestClass * klass);
-static void gst_dptest_init (GstDpTest * dptest);
+static void gst_dptest_base_init (gpointer g_class);
+static void gst_dptest_class_init (GstDpTestClass * klass);
+static void gst_dptest_init (GstDpTest * dptest);
-static void gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec);
+static void gst_dptest_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_dptest_change_state (GstElement *element);
-static void gst_dptest_chain (GstPad *pad, GstData *buf);
+static GstElementStateReturn gst_dptest_change_state (GstElement * element);
+static void gst_dptest_chain (GstPad * pad, GstData * buf);
static GstElementClass *parent_class = NULL;
(GInstanceInitFunc) gst_dptest_init,
};
- dptest_type = g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0);
+ dptest_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0);
}
return dptest_type;
}
static void
gst_dptest_base_init (gpointer g_class)
{
- static GstElementDetails dptest_details = GST_ELEMENT_DETAILS (
- "DParamTest",
- "Filter",
- "Test for the GstDParam code",
- "Steve Baker <stevebaker_org@yahoo.co.uk>"
- );
+ static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ("DParamTest",
+ "Filter",
+ "Test for the GstDParam code",
+ "Steve Baker <stevebaker_org@yahoo.co.uk>");
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &dptest_details);
- g_print("got here %d\n",__LINE__);
+ g_print ("got here %d\n", __LINE__);
}
static void
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad);
- gst_pad_set_chain_function(dptest->sinkpad, gst_dptest_chain);
+ gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain);
dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad);
- dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT(dptest));
+ dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest));
+
+ gst_dpman_add_required_dparam_direct (dptest->dpman,
+ g_param_spec_float ("float1", "float1", "float1",
+ 0.0, 1.0, 0.5, G_PARAM_READWRITE), "float", &(dptest->float1)
+ );
- gst_dpman_add_required_dparam_direct (
- dptest->dpman,
- g_param_spec_float("float1","float1","float1",
- 0.0, 1.0, 0.5, G_PARAM_READWRITE),
- "float",
- &(dptest->float1)
- );
-
dptest->float1 = 0.0;
}
static void
-gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstDpTest *dptest;
}
static GstElementStateReturn
-gst_dptest_change_state (GstElement *element)
+gst_dptest_change_state (GstElement * element)
{
GstDpTest *dptest;
g_return_val_if_fail (GST_IS_DPTEST (element), GST_STATE_FAILURE);
- g_print("changing state\n");
+ g_print ("changing state\n");
dptest = GST_DPTEST (element);
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
-static void
-gst_dptest_chain (GstPad *pad, GstData *data)
+static void
+gst_dptest_chain (GstPad * pad, GstData * data)
{
GstDpTest *dptest;
gint frame_countdown;
- dptest = GST_DPTEST(gst_pad_get_parent (pad));
- g_assert(dptest);
+ dptest = GST_DPTEST (gst_pad_get_parent (pad));
+ g_assert (dptest);
/* we're using a made up buffer size of 64 and a timestamp of zero */
- frame_countdown = GST_DPMAN_PREPROCESS(dptest->dpman, 64, 0LL);
-
- while(GST_DPMAN_PROCESS(dptest->dpman, frame_countdown));
-
- g_print("dp chain\n");
+ frame_countdown = GST_DPMAN_PREPROCESS (dptest->dpman, 64, 0LL);
+
+ while (GST_DPMAN_PROCESS (dptest->dpman, frame_countdown));
+
+ g_print ("dp chain\n");
}
gboolean
-gst_dptest_register_elements (GstPlugin *plugin)
+gst_dptest_register_elements (GstPlugin * plugin)
{
return gst_element_register (plugin, "dptest", GST_RANK_NONE,
GST_TYPE_DPTEST);
GST_ORIGIN
};
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *src;
GstElement *sink;
GstDParamManager *dpman;
GstDParam *dp_float1;
GValue *dp_float1_value;
-
- alarm(10);
+
+ alarm (10);
gst_init (&argc, &argv);
- gst_control_init(&argc,&argv);
+ gst_control_init (&argc, &argv);
_gst_plugin_register_static (&plugin_desc);
gst_bin_add (GST_BIN (pipeline), testelement);
gst_bin_add (GST_BIN (pipeline), sink);
- g_print("playing pipeline\n");
-
- g_object_set (G_OBJECT (src), "num_buffers", 1, NULL);
+ g_print ("playing pipeline\n");
+
+ g_object_set (G_OBJECT (src), "num_buffers", 1, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
/* test that dparam manager is accessable */
- g_print("getting dparam manager\n");
+ g_print ("getting dparam manager\n");
dpman = gst_dpman_get_manager (testelement);
- gst_dpman_set_mode(dpman, "synchronous");
-
- g_assert(dpman);
- g_assert(GST_IS_DPMAN (dpman));
-
- g_print("creating dparam for float1\n");
- dp_float1 = gst_dparam_new(G_TYPE_FLOAT);;
- g_assert(dp_float1);
- g_assert(GST_IS_DPARAM (dp_float1));
-
- g_print("attach dparam to float1\n");
- g_assert(gst_dpman_attach_dparam (dpman, "float1", dp_float1));
-
- dp_float1_value = g_new0(GValue,1);
- g_value_init(dp_float1_value, G_TYPE_FLOAT);
-
- g_value_set_float(dp_float1_value, 0.1);
- g_object_set_property(G_OBJECT(dp_float1), "value_float", dp_float1_value);
-
- g_print("iterate once\n");
+ gst_dpman_set_mode (dpman, "synchronous");
+
+ g_assert (dpman);
+ g_assert (GST_IS_DPMAN (dpman));
+
+ g_print ("creating dparam for float1\n");
+ dp_float1 = gst_dparam_new (G_TYPE_FLOAT);;
+ g_assert (dp_float1);
+ g_assert (GST_IS_DPARAM (dp_float1));
+
+ g_print ("attach dparam to float1\n");
+ g_assert (gst_dpman_attach_dparam (dpman, "float1", dp_float1));
+
+ dp_float1_value = g_new0 (GValue, 1);
+ g_value_init (dp_float1_value, G_TYPE_FLOAT);
+
+ g_value_set_float (dp_float1_value, 0.1);
+ g_object_set_property (G_OBJECT (dp_float1), "value_float", dp_float1_value);
+
+ g_print ("iterate once\n");
gst_bin_iterate (GST_BIN (pipeline));
- g_print("check that value changed\n");
- g_assert(GST_DPTEST(testelement)->float1 == 0.1F);
- g_assert(!GST_DPARAM_READY_FOR_UPDATE(dp_float1));
-
- g_print("nulling pipeline\n");
+ g_print ("check that value changed\n");
+ g_assert (GST_DPTEST (testelement)->float1 == 0.1F);
+ g_assert (!GST_DPARAM_READY_FOR_UPDATE (dp_float1));
+
+ g_print ("nulling pipeline\n");
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- g_print("playing pipeline\n");
+ g_print ("playing pipeline\n");
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
- g_print("iterate twice\n");
+ g_print ("iterate twice\n");
g_object_set (G_OBJECT (src), "num_buffers", 2, NULL);
gst_bin_iterate (GST_BIN (pipeline));
-
+
return 0;
}
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
pipeline = gst_pipeline_new ("pipeline");
g_print ("Connecting signals to pipeline\n");
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL);
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (property_change_callback), NULL);
g_print ("Creating elements\n");
- 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 (!(sink = element_create ("sink", "fakesink"))) return 1;
-
+ if (!(sink = element_create ("sink", "fakesink")))
+ return 1;
+
/* add */
g_print ("Adding elements to bin\n");
gst_bin_add (GST_BIN (pipeline), src);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* we expect this to give an error */
- if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE)
- {
- g_warning ("Iterating a bin with unlinked elements should return FALSE !\n");
+ if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) {
+ g_warning
+ ("Iterating a bin with unlinked elements should return FALSE !\n");
retval = 1;
}
gst_pad_link (gst_element_get_pad (src, "src"),
- gst_element_get_pad (sink, "sink"));
+ gst_element_get_pad (sink, "sink"));
/* set to play */
g_print ("Doing 1 iteration\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* we expect this to work */
- if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE)
- {
+ if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) {
g_error ("Iterating a bin with linked elements should return TRUE !\n");
retval = 1;
}
g_print ("Done !\n");
return retval;
}
-
/* init */
gst_init (&argc, &argv);
- for (i = 0; i < 50; ++i)
- {
+ for (i = 0; i < 50; ++i) {
/* create element */
element = gst_element_factory_make ("identity", NULL);
g_assert (GST_IS_ELEMENT (element));
g_assert (gst_element_get_name (element) != NULL);
- g_print ("Created identity element with name %s\n",
- gst_element_get_name (element));
+ g_print ("Created identity element with name %s\n",
+ gst_element_get_name (element));
}
g_print ("Done !\n");
return 0;
}
-
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
/* create */
g_print ("Creating element\n");
- if (!(src = element_create ("src", "fakesrc"))) return 1;
-
+ if (!(src = element_create ("src", "fakesrc")))
+ return 1;
+
/* set */
silent_set = TRUE;
sizemin_set = 1;
name_set = g_strdup_printf ("test");
- gst_element_set (src,
- "name", name_set,
- "sizemin", sizemin_set,
- "silent", silent_set,
- NULL);
+ gst_element_set (src,
+ "name", name_set, "sizemin", sizemin_set, "silent", silent_set, NULL);
/* get */
gst_element_get (src,
- "name", &name_get,
- "sizemin", &sizemin_get,
- "silent", &silent_get,
- NULL);
+ "name", &name_get, "sizemin", &sizemin_get, "silent", &silent_get, NULL);
/* compare */
- if (sizemin_set != sizemin_get)
- {
+ if (sizemin_set != sizemin_get) {
g_print ("sizemin: set value %d differs from returned value %d\n",
- sizemin_set, sizemin_get);
+ sizemin_set, sizemin_get);
retval = 1;
- }
- else
+ } else
g_print ("name: set right\n");
- if (silent_set != silent_get)
- {
+ if (silent_set != silent_get) {
g_print ("silent: set value %s differs from returned value %s\n",
- silent_set ? "TRUE" : "FALSE",
- silent_get ? "TRUE" : "FALSE");
+ silent_set ? "TRUE" : "FALSE", silent_get ? "TRUE" : "FALSE");
retval = 1;
- }
- else
+ } else
g_print ("silent: set right\n");
-
- if (strcmp (name_set, name_get) != 0)
- {
+
+ if (strcmp (name_set, name_get) != 0) {
g_print ("name: set value %s differs from returned value %s\n",
- name_set, name_get);
+ name_set, name_get);
retval = 1;
- }
- else
+ } else
g_print ("name: set right\n");
return retval;
}
-
/* extracted from gst-launch */
static void
-property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
+property_change_callback (GObject * object, GstObject * orig,
+ GParamSpec * pspec)
{
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
+ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0;
if (pspec->flags & G_PARAM_READABLE) {
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (G_OBJECT (orig), pspec->name, &value);
/* fix current bug with g_strdup_value_contents not working with gint64 */
if (G_IS_PARAM_SPEC_INT64 (pspec))
str = g_strdup_value_contents (&value);
g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
g_free (str);
- g_value_unset(&value);
+ g_value_unset (&value);
} else {
g_warning ("Parameter not readable. What's up with that?");
}
}
-
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
GstElement *pipeline = NULL;
GstElement *tee, *src, *sink1, *sink2;
GstPad *tee_src1, *tee_src2;
+
#if 0
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
pipeline = gst_pipeline_new ("pipeline");
g_print ("Connecting signals to pipeline\n");
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL);
-
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (property_change_callback), NULL);
+
g_print ("Creating elements\n");
- if (!(tee = element_create ("tee", "tee"))) return 1;
- if (!(src = element_create ("src", "fakesrc"))) return 1;
+ if (!(tee = element_create ("tee", "tee")))
+ 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 (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
-
+ if (!(sink1 = element_create ("sink1", "fakesink")))
+ return 1;
+ if (!(sink2 = element_create ("sink2", "fakesink")))
+ return 1;
+
/* add */
g_print ("Adding elements to bin\n");
gst_bin_add (GST_BIN (pipeline), src);
/* link input part */
g_print ("Linking input elements\n");
gst_pad_link (gst_element_get_pad (src, "src"),
- gst_element_get_pad (tee, "sink"));
-
+ gst_element_get_pad (tee, "sink"));
+
/* request one pad from tee */
g_print ("Requesting first pad\n");
tee_src1 = gst_element_get_request_pad (tee, "src%d");
tee_src2 = gst_element_get_request_pad (tee, "src%d");
gst_bin_add (GST_BIN (pipeline), sink2);
gst_pad_link (tee_src2, gst_element_get_pad (sink2, "sink"));
-
+
/* now we have two fakesinks linked, iterate */
g_print ("Doing 1 iteration\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink1, "sink"));
if (sink_caps && gst_caps_is_fixed (sink_caps)) {
structure = gst_caps_get_structure (sink_caps, 0);
- }else {
+ } else {
structure = NULL;
g_print ("sink_caps is not fixed\n");
}
if (structure == NULL || !(gst_structure_has_field (structure, "rate"))) {
- g_print ("Hm, rate has not been propagated to sink1.\n");
+ g_print ("Hm, rate has not been propagated to sink1.\n");
return 1;
} else {
int rate;
+
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink1 : %d\n", rate);
}
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink2, "sink"));
structure = gst_caps_get_structure (sink_caps, 0);
- if (structure != NULL && ! (gst_structure_has_field (structure, "rate"))) {
- g_print ("Hm, rate has not been propagated to sink2.\n");
+ if (structure != NULL && !(gst_structure_has_field (structure, "rate"))) {
+ g_print ("Hm, rate has not been propagated to sink2.\n");
return 1;
} else {
int rate;
+
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink2 : %d\n", rate);
}
#endif
-
+
/* remove the first one, iterate */
g_print ("Removing first sink\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
/* in 0.3.2 the next statement gives an assert error */
tee_src1 = gst_element_get_request_pad (tee, "src%d");
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Done !\n");
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline, *bin;
GstElement *fakesrc, *fakesink, *identity;
- GstPad *sink, *src, *real = (GstPad*)0xdeadbeef;
+ GstPad *sink, *src, *real = (GstPad *) 0xdeadbeef;
gst_init (&argc, &argv);
fakesrc = gst_element_factory_make ("fakesrc", NULL);
fakesink = gst_element_factory_make ("fakesink", NULL);
identity = gst_element_factory_make ("identity", NULL);
-
+
gst_bin_add_many (GST_BIN (pipeline), fakesrc, bin, fakesink, NULL);
gst_bin_add (GST_BIN (bin), identity);
-
+
sink = gst_element_add_ghost_pad (bin,
- gst_element_get_pad (identity, "sink"),
- "sink");
+ gst_element_get_pad (identity, "sink"), "sink");
src = gst_element_add_ghost_pad (bin,
- gst_element_get_pad (identity, "src"),
- "src");
+ gst_element_get_pad (identity, "src"), "src");
gst_element_link_many (fakesrc, bin, fakesink, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
if (!gst_bin_iterate (GST_BIN (pipeline)))
g_assert_not_reached ();
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
/* test the cleanup */
gst_object_ref (GST_OBJECT (sink));
- gst_object_unref ((GstObject*)pipeline);
+ gst_object_unref ((GstObject *) pipeline);
g_object_get (sink, "real-pad", &real, NULL);
g_assert (real == NULL);
g_assert (G_OBJECT (sink)->ref_count == 1);
gst_object_unref (GST_OBJECT (sink));
-
+
return 0;
}
#include <gst/gst.h>
static void
-lookup (GstIndex *index, GstIndexLookupMethod method,
- GstFormat src_format, gint64 src_value,
- GstFormat dest_format, gint64 expecting)
+lookup (GstIndex * index, GstIndexLookupMethod method,
+ GstFormat src_format, gint64 src_value,
+ GstFormat dest_format, gint64 expecting)
{
GstIndexEntry *entry;
gint64 result;
entry = gst_index_get_assoc_entry (index, 0, method, 0,
- src_format, src_value);
+ src_format, src_value);
if (entry) {
- gst_index_entry_assoc_map (entry, dest_format, &result);
+ gst_index_entry_assoc_map (entry, dest_format, &result);
if (result == expecting) {
g_print ("OK (%lld)\n", result);
} else {
g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
}
- }
- else {
+ } else {
const GstFormatDefinition *def = gst_format_get_details (src_format);
-
- if (expecting == -1)
+
+ if (expecting == -1)
g_print ("OK (not found)\n");
else
g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n",
- src_value, def->nick, expecting);
+ src_value, def->nick, expecting);
}
}
typedef struct _GstIndexTestCase
{
- GstIndexLookupMethod method;
- GstFormat src_format;
- gint64 src_value;
- GstFormat dest_format;
- gint64 expecting;
+ GstIndexLookupMethod method;
+ GstFormat src_format;
+ gint64 src_value;
+ GstFormat dest_format;
+ gint64 expecting;
} GstIndexTestCase;
-const static GstIndexTestCase cases[] =
-{
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
+const static GstIndexTestCase cases[] = {
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES,
+ 99999},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
};
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstElement *element;
gint i, id;
-
+
gst_init (&argc, &argv);
- if (argc != 2)
- { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
+ if (argc != 2) {
+ g_print ("usage: cache1 (memindex | fileindex)\n");
+ exit (0);
+ }
index = gst_index_factory_make (argv[1]);
g_assert (index != NULL);
g_print ("Building index...\n");
for (i = 0; i < 100000; i++) {
- gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
- (gint64) (i * 1000), 0);
+ gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64) i,
+ GST_FORMAT_TIME, (gint64) (i * 1000), 0);
}
g_print ("Testing index...\n");
for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) {
- lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting);
+ lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value,
+ cases[i].dest_format, cases[i].expecting);
}
-
+
return 0;
}
#include <gst/gst.h>
static void
-my_resolver (GstIndex *index, GstObject *_ign, gchar **writer_string,
- gpointer user_data)
-{ *writer_string = user_data; }
+my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string,
+ gpointer user_data)
+{
+ *writer_string = user_data;
+}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstObject *identity;
gint id;
gint64 cur;
-
+
gst_init (&argc, &argv);
if (argc != 3) {
g_object_set (index, "location", argv[1], NULL);
gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]);
- identity = (GstObject*) gst_element_factory_make ("identity", "element");
+ identity = (GstObject *) gst_element_factory_make ("identity", "element");
g_assert (identity);
gst_index_get_writer_id (index, identity, &id);
-
+
cur = 0;
while (1) {
gint fx;
GstIndexEntry *entry =
- gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
- GST_FORMAT_TIME, cur);
+ gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
+ GST_FORMAT_TIME, cur);
+
if (!entry)
break;
g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry));
- for (fx=0; fx < GST_INDEX_NASSOCS (entry); fx++) {
+ for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) {
GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx);
- const GstFormatDefinition* def = gst_format_get_details (fmt);
+ const GstFormatDefinition *def = gst_format_get_details (fmt);
+
if (fmt == GST_FORMAT_TIME) {
cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1;
g_print (" time %.4f",
- GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
- }
- else
+ GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
+ } else
g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx));
}
g_print ("\n");
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
gst_object_unref (GST_OBJECT (cur)); \
cur = NULL; \
g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
-}G_STMT_END
+}G_STMT_END
#define TEST_RUN G_STMT_START{ \
alarm(10); \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
} \
g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
alarm(0); \
-}G_STMT_END
+}G_STMT_END
#define PIPELINE1 "fakesrc"
#define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = yesyo data= Subbuffer\\ data"
#define PIPELINE3 "fakesrc identity fakesink"
#define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
* - first test of escaping strings
*/
TEST_START (PIPELINE2);
- g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL);
+ g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b,
+ NULL);
TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
TEST_CHECK_FAIL (i == 27);
TEST_CHECK_FAIL (b == TRUE);
* - if multiple toplevel elements exist, a pipeline is returned
*/
TEST_START (PIPELINE3);
- TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
+ TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
TEST_OK;
TEST_CHECK_FAIL (strcmp (s, "john") == 0);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - test request pads
TEST_START (PIPELINE7);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - multiple pads on 1 link
TEST_START (PIPELINE8);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.17
TEST_START (PIPELINE9);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.17
TEST_START (PIPELINE10);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.18
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
gst_object_unref (GST_OBJECT (cur)); \
cur = NULL; \
g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
-}G_STMT_END
+}G_STMT_END
#define TEST_RUN(iters) G_STMT_START{ \
gint it = iters; \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
return -test; \
} \
g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
-}G_STMT_END
+}G_STMT_END
#define TEST_FINISH G_STMT_START{ \
g_print("\n"); \
g_print("To run this test there are things required that you do not have. (see above)\n"); \
g_print("Currently the following tests will be ignored.\n"); \
g_print("\n"); \
exit (0); \
-}G_STMT_END
+}G_STMT_END
#define TEST_REQUIRE(condition, error) G_STMT_START{ \
if (condition) { \
g_print ("REQUIRE line %3d OK\n", __LINE__); \
g_print ("REQUIRE line %3d EXIT : %s\n", __LINE__, (error)); \
TEST_FINISH; \
} \
-}G_STMT_END
+}G_STMT_END
#define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \
GstElement *element = gst_element_factory_make ((element_name), NULL); \
if (element) { \
g_print ("REQUIRE line %3d EXIT : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \
TEST_FINISH; \
} \
-}G_STMT_END
+}G_STMT_END
#define PIPELINE1 "filesrc blocksize =8192 location=%s ! mad ! osssink"
#define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink"
#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink"
*/
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
-goto here;
+ goto here;
here:
/**
* - unsigned parameters
*/
audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL);
- TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory.");
+ TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS),
+ "The following tests requires a valid mp3 file music.mp3 in your home directory.");
TEST_REQUIRE_ELEMENT ("mad");
TEST_REQUIRE_ELEMENT ("osssink");
TEST_START (PIPELINE1, audio_file);
* - SOMETIMES pads
*/
video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL);
- TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory.");
+ TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS),
+ "The following tests requires a valid mpeg file video.mpeg in your home directory.");
TEST_REQUIRE_ELEMENT ("mpegdemux");
TEST_REQUIRE_ELEMENT ("mpeg2dec");
TEST_REQUIRE_ELEMENT ("xvideosink");
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_plugin_load_file (".libs/libtestplugin.so", &error);
g_assert (plugin != NULL);
- if (error)
- {
+ if (error) {
g_print ("ERROR loading plug-in: %s\n", error->message);
g_free (error);
return 1;
}
- g_print ("testplugin: %s\n", gst_plugin_get_name(plugin));
+ g_print ("testplugin: %s\n", gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
-
- loaded = gst_plugin_load (gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
+
+ loaded = gst_plugin_load (gst_plugin_get_name (plugin));
g_assert (loaded == TRUE);
numplugins = g_list_length (gst_registry_pool_plugin_list ());
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
- loaded = gst_plugin_load (gst_plugin_get_name(plugin));
+ loaded = gst_plugin_load (gst_plugin_get_name (plugin));
g_assert (loaded == TRUE);
numplugins = g_list_length (gst_registry_pool_plugin_list ());
g_print ("%d plugins loaded\n", numplugins);
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
g_mem_chunk_info ();
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %s\n", gst_plugin_get_name(plugin));
+ g_print ("testplugin: %s\n", gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
-
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
static gboolean
-plugin2_init (GstPlugin *plugin)
+plugin2_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "a second plugin for testing",
- plugin2_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
-int
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "a second plugin for testing",
+ plugin2_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
+
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "another testplugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "another testplugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "another testplugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_COPYRIGHT,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "another testplugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_COPYRIGHT,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN);
#define ITERS 100
#include <stdlib.h>
-static GstElement*
+static GstElement *
create_bin (void)
{
GstElement *bin;
return bin;
}
-static GstElement*
+static GstElement *
create_bin_ghostpads (void)
{
GstElement *bin;
element2 = gst_element_factory_make ("fakesink", NULL);
gst_bin_add (GST_BIN (bin), element2);
gst_element_link_pads (element1, "src", element2, "sink");
- gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), "ghost_sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"),
+ "ghost_sink");
return bin;
}
#endif
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *bin;
int usage1;
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
g_assert (GST_OBJECT_FLOATING (bin));
gst_object_sink (GST_OBJECT (bin));
g_assert (!GST_OBJECT_FLOATING (bin));
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/ref/sink/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_sink (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/ref/sink/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
g_assert (!GST_OBJECT_DESTROYED (bin));
g_assert (GST_OBJECT_DESTROYED (bin));
gst_object_unref (GST_OBJECT (bin));
#endif
- g_print ("create/destroy/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
#if 0
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("create/destroy/unref %d bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref %d bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/ref/unref/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/ref/unref/unref %d bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/unref/unref %d bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
#if 0
gst_object_unref (GST_OBJECT (bin));
#endif
- g_print ("craete/ref/destroy/unref/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("craete/ref/destroy/unref/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("craete/ref/destroy/unref/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_element_set_name (bin, "testing123");
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("craete/ref/destroy/unref/unref %d bins with name %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d bins with name %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (bin, "testing");
}
gst_object_unref (GST_OBJECT (bin));
- g_print ("set name %d times %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("set name %d times %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- bin = create_bin();
+ for (i = 0; i < iters; i++) {
+ bin = create_bin ();
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bin with children %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bin with children %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters/2;i++) {
- bin = create_bin_ghostpads();
+ for (i = 0; i < iters / 2; i++) {
+ bin = create_bin_ghostpads ();
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bin with children and ghostpads %d\n", iters/2, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bin with children and ghostpads %d\n", iters / 2,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test1();
+ for (i = 0; i < iters; i++) {
+ add_remove_test1 ();
}
- g_print ("add/remove test1 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/remove test1 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test2();
+ for (i = 0; i < iters; i++) {
+ add_remove_test2 ();
}
- g_print ("add/remove test2 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/remove test2 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
- for (i=0; i<iters;i++) {
- add_remove_test3();
+ for (i = 0; i < iters; i++) {
+ add_remove_test3 ();
}
- g_print ("add/destroy/remove test3 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/destroy/remove test3 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
- add_remove_test4();
+ for (i = 0; i < iters; i++) {
+ add_remove_test4 ();
}
- g_print ("add/destroy/remove test4 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/destroy/remove test4 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
- g_print ("leaked: %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1);
//gst_alloc_trace_print_all ();
- return (gst_alloc_trace_live_all ()-usage1 ? -1 : 0);
+ return (gst_alloc_trace_live_all () - usage1 ? -1 : 0);
}
#include <stdlib.h>
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *element;
int usage1;
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
- g_print ("create/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_OBJECT_FLOATING (element));
gst_object_sink (GST_OBJECT (element));
g_assert (!GST_OBJECT_FLOATING (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/ref/sink/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_sink (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/ref/sink/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/destroy/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/destroy/unref %d element %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref %d element %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/ref/unref/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/ref/unref/unref %d element %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/unref/unref %d element %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("craete/ref/destroy/unref/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_element_set_name (element, "testing123");
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
element = gst_element_factory_make ("fakesrc", NULL);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (element, "testing");
}
gst_object_unref (GST_OBJECT (element));
- g_print ("set name %d times %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("set name %d times %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- g_print ("leaked: %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1);
- return (gst_alloc_trace_live_all ()-usage1 ? -1 : 0);
+ return (gst_alloc_trace_live_all () - usage1 ? -1 : 0);
}
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *element;
GstElement *element2;
g_print ("starting element with pad test with %d iterations\n", iters);
- usage1 = vmsize();
+ usage1 = vmsize ();
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
g_assert (!GST_OBJECT_FLOATING (pad));
g_assert (gst_pad_get_parent (pad) == element);
gst_object_unref (GST_OBJECT (element));
- g_print ("create/addpad/unref new element %ld\n", vmsize()-usage1);
+ g_print ("create/addpad/unref new element %ld\n", vmsize () - usage1);
- for (i=0; i<iters; i++) {
- element = gst_element_factory_make
-("fakesink", NULL);;
+ for (i = 0; i < iters; i++) {
+ element = gst_element_factory_make ("fakesink", NULL);;
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize()-usage1);
+ g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
}
- g_print ("create/link/unref %d elements %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/link/unref %d elements %ld\n", iters / 2,
+ vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
gst_object_unref (GST_OBJECT (element2));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/link/destroy %d elements %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/link/destroy %d elements %ld\n", iters / 2,
+ vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
- g_print ("pad removal ok %ld\n", vmsize()-usage1);
- for (i=0; i<iters/2; i++) {
+ g_print ("pad removal ok %ld\n", vmsize () - usage1);
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_element_remove_pad (element, pad);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad removal loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad removal loop %d %ld\n", iters / 2, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad removal and test loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad removal and test loop %d %ld\n", iters / 2,
+ vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
- g_print ("pad destroy/removal ok %ld\n", vmsize()-usage1);
+ g_print ("pad destroy/removal ok %ld\n", vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad destroy/removal loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad destroy/removal loop %d %ld\n", iters / 2, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (pad));
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad destroy loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad destroy loop %d %ld\n", iters / 2, vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
static gboolean
quit_main (gpointer data)
{
- if (mainloop)
- {
- mainloop = FALSE;
- g_print ("-");
- gst_main_quit ();
- }
- return TRUE;
+ if (mainloop) {
+ mainloop = FALSE;
+ g_print ("-");
+ gst_main_quit ();
+ }
+ return TRUE;
}
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
int i;
g_timeout_add (1, quit_main, NULL);
- for (i = 0; i < 1000; ++i)
- {
+ for (i = 0; i < 1000; ++i) {
mainloop = TRUE;
g_print ("+");
gst_main ();
#include <fcntl.h>
#include <unistd.h>
-int vmsize() {
- int pid,fd,size,i,mem;
+int
+vmsize ()
+{
+ int pid, fd, size, i, mem;
char filename[17], buf[256], *ptr, *end;
- pid = getpid();
- snprintf(filename,17,"/proc/%d/stat",pid);
- fd = open(filename,O_RDONLY);
- size = read(fd,buf,240);
+ pid = getpid ();
+ snprintf (filename, 17, "/proc/%d/stat", pid);
+ fd = open (filename, O_RDONLY);
+ size = read (fd, buf, 240);
ptr = buf;
- for (i=0;i<22;i++)
- ptr = (char *)strchr(ptr,' ') + 1;
- end = (char *)strchr(ptr,' ');
+ for (i = 0; i < 22; i++)
+ ptr = (char *) strchr (ptr, ' ') + 1;
+ end = (char *) strchr (ptr, ' ');
*end = 0;
- sscanf(ptr,"%d",&mem);
- close(fd);
+ sscanf (ptr, "%d", &mem);
+ close (fd);
return mem;
}
-int vmsize();
+int vmsize ();
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstObject *object, *object2;
long usage1;
iters = ITERS;
g_print ("starting test with %d iterations\n", iters);
- usage1 = vmsize();
+ usage1 = vmsize ();
object = gst_object_new ();
gst_object_unref (object);
- g_print ("create/unref new object %ld\n", vmsize()-usage1);
+ g_print ("create/unref new object %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_unref (object);
}
- g_print ("create/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
g_assert (GST_OBJECT_FLOATING (object));
gst_object_sink (object);
g_assert (!GST_OBJECT_FLOATING (object));
gst_object_unref (object);
- g_print ("create/ref/sink/unref new object %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new object %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_sink (object);
gst_object_unref (object);
}
- g_print ("create/ref/sink/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
g_assert (!GST_OBJECT_DESTROYED (object));
gst_object_unref (object);
g_assert (GST_OBJECT_DESTROYED (object));
gst_object_unref (object);
- g_print ("create/destroy/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new object %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("destroy/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("destroy/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
- g_print ("create/ref/unref/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new object %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/unref/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
gst_object_unref (object);
- g_print ("create/ref/destroy/unref/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/destroy/unref/unref new object %ld\n",
+ vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/destroy/unref/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d object %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_set_name (object, "testing123");
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/destroy/unref/unref %d object with name %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d object with name %ld\n", iters,
+ vmsize () - usage1);
object = gst_object_new ();
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_object_set_name (object, "testing");
}
gst_object_unref (object);
- g_print ("create/set name/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/set name/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
object2 = gst_object_new ();
g_assert (GST_OBJECT_FLOATING (object2));
g_assert (!GST_OBJECT_FLOATING (object));
- g_print ("parentage flags set_parent ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags set_parent ok %ld\n", vmsize () - usage1);
gst_object_ref (object);
gst_object_unparent (object);
g_assert (!GST_OBJECT_FLOATING (object));
g_assert (gst_object_get_parent (object) == NULL);
- g_print ("parentage flags unparent ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags unparent ok %ld\n", vmsize () - usage1);
gst_object_set_parent (object, object2);
g_assert (GST_OBJECT_FLOATING (object2));
g_assert (gst_object_get_parent (object) == NULL);
gst_object_unref (object);
- g_print ("parentage flags destroy ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags destroy ok %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
object2 = gst_object_new ();
gst_object_set_parent (object2, object);
gst_object_unref (object);
gst_object_unref (object2);
}
- g_print ("create/unref %d 2 parented objects %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d 2 parented objects %ld\n", iters,
+ vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstPad *pad;
GstPadTemplate *padtempl;
//gst_alloc_trace_print_all ();
g_print ("starting pad test\n");
- usage1 = vmsize();
+ usage1 = vmsize ();
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/unref new pad %ld\n", vmsize()-usage1);
+ g_print ("create/unref new pad %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d pads %ld\n", iters, vmsize () - usage1);
pad = gst_pad_new ("padname", GST_PAD_SINK);
g_assert (GST_OBJECT_FLOATING (pad));
gst_object_sink (GST_OBJECT (pad));
g_assert (!GST_OBJECT_FLOATING (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/ref/sink/unref new pad %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new pad %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_sink (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize () - usage1);
#if 0
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
g_assert (GST_OBJECT_DESTROYED (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/destroy/unref pad %ld\n", vmsize()-usage1);
+ g_print ("create/destroy/unref pad %ld\n", vmsize () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize () - usage1);
#endif
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/ref/unref/unref pad %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1);
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
#if 0
gst_object_unref (GST_OBJECT (pad));
#endif
- g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize()-usage1);
-
+ g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize () - usage1);
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
//gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters,
+ vmsize () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_pad_set_name (pad, "testing123");
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters,
+ vmsize () - usage1);
#endif
pad = gst_pad_new ("padname", GST_PAD_SINK);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_pad_set_name (pad, "testing");
}
gst_object_unref (GST_OBJECT (pad));
- g_print ("set name %d times %ld\n", iters, vmsize()-usage1);
+ g_print ("set name %d times %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- padtempl = gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
+ for (i = 0; i < iters; i++) {
+ padtempl =
+ gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
gst_object_unref (GST_OBJECT (padtempl));
}
- g_print ("%d padtemplates create/unref %ld\n", iters, vmsize()-usage1);
+ g_print ("%d padtemplates create/unref %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- padtempl = gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
+ for (i = 0; i < iters; i++) {
+ padtempl =
+ gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
pad = gst_pad_new_from_template (padtempl, "sink1");
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("%d pads create/unref from padtemplate %ld\n", iters, vmsize()-usage1);
-
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("%d pads create/unref from padtemplate %ld\n", iters,
+ vmsize () - usage1);
+
+ g_print ("leaked: %ld\n", vmsize () - usage1);
//gst_alloc_trace_print_all ();
- return vmsize()-usage1;
+ return vmsize () - usage1;
}
GstPadChainFunction oss_chain;
static GstElement *
-make_and_check_element (gchar *type, gchar *name)
+make_and_check_element (gchar * type, gchar * name)
{
GstElement *element = gst_element_factory_make (type, name);
if (element == NULL) {
- g_warning ("Could not run test, because element type \"%s\" is not installed. Please retry when it is. Assuming it works for now...", type);
+ g_warning
+ ("Could not run test, because element type \"%s\" is not installed. Please retry when it is. Assuming it works for now...",
+ type);
exit (1);
}
static void
create_pipeline (void)
{
- GstElement *src;
+ GstElement *src;
GstElement *sink;
GstElement *id;
-
+
pipeline = gst_pipeline_new ("pipeline");
src = make_and_check_element ("sinesrc", "src");
/**
* Osssink (chain-based) only breaks the basic scheduler.
*/
sink = make_and_check_element ("alsasink", "sink");
-
+
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
gst_element_link (src, sink);
-
+
/**
* now make the bug appear
* I believe it has something to do with 2 chains being created in the scheduler
id = make_and_check_element ("identity", "id");
gst_bin_add (GST_BIN (pipeline), id);
gst_element_link_many (src, id, sink, NULL);
-
+
/* This pipeline will not be removed properly once we unref it */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-}
+}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
- create_pipeline();
-
+ create_pipeline ();
+
while (i < 300) {
/**
* only inc i when it works, so the program hangs when _iterate returns false,
#include <stdlib.h>
#include "mem.h"
-static GstElement*
+static GstElement *
create_thread (void)
{
GstElement *thread;
return thread;
}
-static GstElement*
+static GstElement *
create_thread_ghostpads (void)
{
GstElement *thread;
gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK));
gst_bin_add (GST_BIN (thread), element2);
gst_element_link (element1, "src1", element2, "sink1");
- gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), "sink1");
+ gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"),
+ "sink1");
return thread;
}
}
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *thread, *element;
long usage1;
iters = ITERS;
g_print ("starting test\n");
- usage1 = vmsize();
+ usage1 = vmsize ();
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/unref new thread %ld\n", vmsize()-usage1);
+ g_print ("create/unref new thread %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d threads %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
g_assert (GST_OBJECT_FLOATING (thread));
gst_object_sink (GST_OBJECT (thread));
g_assert (!GST_OBJECT_FLOATING (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/ref/sink/unref new thread %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new thread %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_sink (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/ref/sink/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d threads %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
g_assert (!GST_OBJECT_DESTROYED (thread));
gst_object_unref (GST_OBJECT (thread));
g_assert (GST_OBJECT_DESTROYED (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/destroy/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new thread %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/destroy/unref %d thread %ld\n", iters, vmsize()-usage1);
+ g_print ("create/destroy/unref %d thread %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/ref/unref/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new thread %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/ref/unref/unref %d thread %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d thread %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("craete/ref/destroy/unref/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("craete/ref/destroy/unref/unref new thread %ld\n",
+ vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("craete/ref/destroy/unref/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d threads %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_element_set_name (thread, "testing123");
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("craete/ref/destroy/unref/unref %d threads with name %ld\n", iters, vmsize()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d threads with name %ld\n", iters,
+ vmsize () - usage1);
thread = gst_thread_new ("somethread");
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (thread, "testing");
}
gst_object_unref (GST_OBJECT (thread));
- g_print ("set name %d times %ld\n", iters, vmsize()-usage1);
+ g_print ("set name %d times %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
element = gst_element_new ();
gst_element_set_name (element, "test1");
gst_bin_add (GST_BIN (thread), element);
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with one element %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d thread with one element %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
- thread = create_thread();
+ for (i = 0; i < iters; i++) {
+ thread = create_thread ();
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with children %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d thread with children %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters/2;i++) {
- thread = create_thread_ghostpads();
+ for (i = 0; i < iters / 2; i++) {
+ thread = create_thread_ghostpads ();
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with children and ghostpads %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/unref %d thread with children and ghostpads %ld\n",
+ iters / 2, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test1();
+ for (i = 0; i < iters; i++) {
+ add_remove_test1 ();
}
- g_print ("add/remove test1 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/remove test1 %d in thread %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test2();
+ for (i = 0; i < iters; i++) {
+ add_remove_test2 ();
}
- g_print ("add/remove test2 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/remove test2 %d in thread %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test3();
+ for (i = 0; i < iters; i++) {
+ add_remove_test3 ();
}
- g_print ("add/destroy/remove test3 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/destroy/remove test3 %d in thread %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test4();
+ for (i = 0; i < iters; i++) {
+ add_remove_test4 ();
}
- g_print ("add/destroy/remove test4 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/destroy/remove test4 %d in thread %ld\n", iters,
+ vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
- GstElement *fakesrc1, *fakesink1;
- GstElement *fakesrc2, *fakesink2;
+ GstElement *fakesrc1, *fakesink1;
+ GstElement *fakesrc2, *fakesink2;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
-
+
fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
-
+
gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL);
gst_element_link_pads (fakesrc1, "src", fakesink1, "sink");
gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL);
gst_element_link_pads (fakesrc2, "src", fakesink2, "sink");
- g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
-
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
/* checks that a tag contains the given values and not more values */
static void
-check (const GstTagList *list, const gchar *tag, gchar *value, ...)
+check (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
g_assert (strcmp (value, str) == 0);
g_free (str);
-
+
value = va_arg (args, gchar *);
i++;
}
g_assert (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
+
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
-
+
gst_init (&argc, &argv);
/* make sure the assumptions work */
/* we check string here only */
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
-
+
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, FTAG, NULL);
-
+
/* check merging */
- /* unfixed */
+ /* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
- /* fixed */
+ /* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, FTAG, FIXED1, NULL);
-
+
return 0;
}
int
main (int argc, char *argv[])
{
- gst_init(NULL, NULL);
- gst_init(&argc, &argv);
+ gst_init (NULL, NULL);
+ gst_init (&argc, &argv);
return 0;
}
/* handoff callback */
static void
-handoff (GstElement *element, gpointer data)
+handoff (GstElement * element, gpointer data)
{
++handoff_count;
g_print ("handoff (%d) ", handoff_count);
}
static void
-construct_pipeline (GstElement *pipeline, GstElement *thread)
+construct_pipeline (GstElement * pipeline, GstElement * thread)
{
GstElement *src, *sink, *queue;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", "sink");
- queue = gst_element_factory_make ("queue", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", "sink");
+ queue = gst_element_factory_make ("queue", NULL);
gst_bin_add_many (GST_BIN (thread), queue, sink, NULL);
gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL);
}
void
-change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline)
+change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline)
{
gst_element_set_state (pipeline, GST_STATE_NULL);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *thread = NULL;
-
+
gst_init (&argc, &argv);
pipeline = gst_thread_new ("main_pipeline");
g_print ("Pipeline done. Resetting to NULL.\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
- if (handoff_count == 0)
- {
+ if (handoff_count == 0) {
g_print ("ERROR: no buffers have passed\n");
return -1;
}
handoff_count = 0;
- g_print ("Second run: setting consumer thread to playing, then complete pipeline\n");
+ g_print
+ ("Second run: setting consumer thread to playing, then complete pipeline\n");
gst_element_set_state (thread, GST_STATE_PLAYING);
g_print ("SLEEPING 1 sec\n");
sleep (1);
g_print ("SLEEPING 2 sec\n");
sleep (2);
- if (handoff_count == 0)
- {
+ if (handoff_count == 0) {
g_print ("ERROR: no buffers have passed\n");
return -1;
}
-
+
return 0;
}
usage (void)
{
g_print ("compile this test with TESTNUM defined.\n"
- " available TESTNUMs: \n"
- " 1: stress test state change \n"
- " 2: iterate once \n"
- " 3: iterate twice \n"
- " 4: state change while running \n"
- " 5: state change in thread context\n");
+ " available TESTNUMs: \n"
+ " 1: stress test state change \n"
+ " 2: iterate once \n"
+ " 3: iterate twice \n"
+ " 4: state change while running \n"
+ " 5: state change in thread context\n");
}
static void
-construct_pipeline (GstElement *pipeline)
+construct_pipeline (GstElement * pipeline)
{
GstElement *src, *sink, *queue, *identity, *thread;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", "sink");
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", "sink");
identity = gst_element_factory_make ("identity", NULL);
- queue = gst_element_factory_make ("queue", NULL);
- thread = gst_element_factory_make ("thread", NULL);
+ queue = gst_element_factory_make ("queue", NULL);
+ thread = gst_element_factory_make ("thread", NULL);
gst_element_link_many (src, queue, identity, sink, NULL);
}
void
-change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline)
+change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline)
{
gst_element_set_state (pipeline, GST_STATE_NULL);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
-
+
gst_init (&argc, &argv);
#ifndef TESTNUM
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
g_assert (sink);
- g_signal_connect (G_OBJECT (sink), "handoff",
- G_CALLBACK (change_state), pipeline);
+ g_signal_connect (G_OBJECT (sink), "handoff",
+ G_CALLBACK (change_state), pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("running ...\n");
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
}
-
+
return 0;
}
gboolean running = FALSE;
static void
-construct_pipeline (GstElement *pipeline)
+construct_pipeline (GstElement * pipeline)
{
GstElement *src, *sink, *identity;
- src = gst_element_factory_make ("fakesrc", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
identity = gst_element_factory_make ("identity", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (identity);
g_assert (sink);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
-
- g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+
+ g_print ("element %s has changed state to %s\n",
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
if (state == GST_STATE_PAUSED && running) {
running = FALSE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = 100;
int i;
gulong id;
GstElement *thread;
-
+
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
- id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ id = g_signal_connect (G_OBJECT (thread), "state_change",
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread);
g_print ("Setting thread to play\n");
gst_element_set_state (thread, GST_STATE_PLAYING);
g_print ("Going into the main GStreamer loop\n");
- gst_main ();
+ gst_main ();
g_print ("Coming out of the main GStreamer loop\n");
g_signal_handler_disconnect (G_OBJECT (thread), id);
gst_element_set_state (thread, GST_STATE_NULL);
gboolean can_quit = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink;
GstElement *identity = NULL;
int i;
identity = NULL;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
- if (state == GST_STATE_PAUSED && running)
- {
- while (!can_quit) ;
+ if (state == GST_STATE_PAUSED && running) {
+ while (!can_quit);
can_quit = FALSE;
g_print ("quitting main loop\n");
gst_main_quit ();
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = 290;
int i;
gst_init (&argc, &argv);
- for (i = 90; i < runs; ++i)
- {
+ for (i = 90; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread, i / 10 + 1);
g_print ("Setting thread to play with %d identities\n", i / 10 + 1);
if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
g_error ("Failed setting thread to play\n");
- }
- else {
+ } else {
g_print ("Going into the main GStreamer loop\n");
- can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */
+ can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */
gst_main ();
}
running = FALSE;
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink, *identity = NULL;
GstElement *from;
int i;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
-
- g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+
+ g_print ("element %s has changed state to %s\n",
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
- if (state == GST_STATE_PAUSED && running)
+ if (state == GST_STATE_PAUSED && running)
done = TRUE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
int i;
gulong id;
GstElement *thread;
-
- alarm(10);
+
+ alarm (10);
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
- id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ id = g_signal_connect (G_OBJECT (thread), "state_change",
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread, i / RUNS_PER_IDENTITY + 1);
- g_print ("Setting thread to play with %d identities\n",
- i / RUNS_PER_IDENTITY + 1);
+ g_print ("Setting thread to play with %d identities\n",
+ i / RUNS_PER_IDENTITY + 1);
done = FALSE;
if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
g_warning ("failed to go to PLAYING");
- }
- else {
+ } else {
g_print ("Waiting for thread PLAYING->PAUSED\n");
- while (!done) /* do nothing */;
+ while (!done) /* do nothing */
+ ;
}
running = FALSE;
g_print ("Coming out of the main GStreamer loop\n");
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink, *identity = NULL;
GstElement *from;
int i;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
static void
-iterator (GstElement *bin)
+iterator (GstElement * bin)
{
gst_element_set_state (bin, GST_STATE_PLAYING);
- while (gst_bin_iterate (GST_BIN (bin))) g_print ("+");
+ while (gst_bin_iterate (GST_BIN (bin)))
+ g_print ("+");
gst_element_set_state (bin, GST_STATE_NULL);
g_print ("\n");
done = TRUE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
int i;
GstElement *pipeline;
- alarm(10);
+ alarm (10);
g_thread_init (NULL);
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
pipeline = gst_pipeline_new ("main_pipeline");
g_assert (pipeline);
g_print ("Created GThread\n");
g_print ("Waiting for thread PLAYING->PAUSED\n");
- while (!done) /* do nothing */;
+ while (!done) /* do nothing */
+ ;
running = FALSE;
g_print ("Unreffing pipeline\n");
g_object_unref (G_OBJECT (pipeline));
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink;
GstElement *identity = NULL;
int i;
identity = NULL;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
int i;
GstElement *pipeline;
- for (i = 30; i < runs; ++i)
- {
+ for (i = 30; i < runs; ++i) {
pipeline = gst_pipeline_new ("main_pipeline");
g_assert (pipeline);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
done = FALSE;
g_thread_create ((GThreadFunc) thread, NULL, FALSE, NULL);
g_print ("main: created GThread\n");
- while (!done) g_usleep (G_USEC_PER_SEC);
+ while (!done)
+ g_usleep (G_USEC_PER_SEC);
g_print ("main: done\n");
return 0;
}
-
static gint state = 0;
static gboolean
-notify (GstProbe *probe, GstData **data, gpointer user_data)
+notify (GstProbe * probe, GstData ** data, gpointer user_data)
{
switch (state) {
case 0:
if (GST_BUFFER_TIMESTAMP (*data) == 10) {
- gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
- gst_element_unlink_pads (GST_ELEMENT (src1), "src", sink, "sink");
- gst_bin_add (GST_BIN (bin), src2);
- gst_bin_remove (GST_BIN (bin), src1);
- gst_element_link_pads (GST_ELEMENT (src2), "src", sink, "sink");
- gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
+ gst_element_unlink_pads (GST_ELEMENT (src1), "src", sink, "sink");
+ gst_bin_add (GST_BIN (bin), src2);
+ gst_bin_remove (GST_BIN (bin), src1);
+ gst_element_link_pads (GST_ELEMENT (src2), "src", sink, "sink");
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
state++;
gst_data_unref (*data);
return FALSE;
if (GST_BUFFER_TIMESTAMP (*data) == 20) {
gst_data_unref (*data);
*data = GST_DATA (gst_event_new (GST_EVENT_EOS));
- gst_element_set_state (src2, GST_STATE_PAUSED);
+ gst_element_set_state (src2, GST_STATE_PAUSED);
return TRUE;
}
break;
}
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
gst_init (&argc, &argv);
gst_element_link_pads (GST_ELEMENT (src1), "src", sink, "sink");
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
- g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
-
- gst_pad_add_probe (gst_element_get_pad (src1, "src"),
- gst_probe_new (FALSE,
- notify,
- NULL));
-
- gst_pad_add_probe (gst_element_get_pad (src2, "src"),
- gst_probe_new (FALSE,
- notify,
- NULL));
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
+ NULL);
+
+ gst_pad_add_probe (gst_element_get_pad (src1, "src"),
+ gst_probe_new (FALSE, notify, NULL));
+
+ gst_pad_add_probe (gst_element_get_pad (src2, "src"),
+ gst_probe_new (FALSE, notify, NULL));
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
* cothreading that is fixed in the newer cothreads package.
*/
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2;
-
- gst_init(&argc, &argv);
-
- if (argc!=1) {
- g_print("usage: %s\n", argv[0]);
- exit(-1);
- }
-
- fakesrc = gst_element_factory_make("fakesrc", "fakesrc");
- fakesink1 = gst_element_factory_make("fakesink", "fakesink1");
- fakesink2 = gst_element_factory_make("fakesink", "fakesink2");
+ GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2;
- /* a crucial part of this test (and one that the old cothreads fails on) is
- having two active pipelines in the same thread. */
- pipe1 = gst_pipeline_new("pipe1");
- pipe2 = gst_pipeline_new("pipe2");
-
- /* make the first pipeline */
- gst_bin_add (GST_BIN(pipe1), fakesrc);
- gst_bin_add (GST_BIN(pipe1), fakesink1);
- gst_element_link_pads (fakesrc, "src", fakesink1, "sink");
-
- /* initialize cothreads */
- gst_element_set_state(pipe1, GST_STATE_PLAYING);
- gst_bin_iterate (GST_BIN (pipe1));
- gst_element_set_state(pipe1, GST_STATE_READY);
-
- /* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */
- gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink");
- gst_object_ref(GST_OBJECT(fakesrc));
- gst_bin_remove(GST_BIN(pipe1), fakesrc);
- gst_bin_remove(GST_BIN(pipe1), fakesink1);
+ gst_init (&argc, &argv);
- gst_object_unref (GST_OBJECT (pipe1));
-
- /* make a new pipeline */
- gst_bin_add (GST_BIN(pipe2), fakesink2);
-
- /* don't change the new pipeline's state, it should change on the bin_add */
- gst_bin_add (GST_BIN(pipe2), fakesrc);
- gst_element_link_pads (fakesrc, "src", fakesink2, "sink");
-
- /* show the pipeline state */
- gst_xml_write_file (GST_ELEMENT (pipe2), stdout);
-
- /* try to iterate the pipeline */
- gst_element_set_state(pipe2, GST_STATE_PLAYING);
- gst_bin_iterate(GST_BIN(pipe2));
- gst_element_set_state(pipe2, GST_STATE_NULL);
-
- return 0;
-}
+ if (argc != 1) {
+ g_print ("usage: %s\n", argv[0]);
+ exit (-1);
+ }
+
+ fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
+ fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
+ fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
+
+ /* a crucial part of this test (and one that the old cothreads fails on) is
+ having two active pipelines in the same thread. */
+ pipe1 = gst_pipeline_new ("pipe1");
+ pipe2 = gst_pipeline_new ("pipe2");
+
+ /* make the first pipeline */
+ gst_bin_add (GST_BIN (pipe1), fakesrc);
+ gst_bin_add (GST_BIN (pipe1), fakesink1);
+ gst_element_link_pads (fakesrc, "src", fakesink1, "sink");
+
+ /* initialize cothreads */
+ gst_element_set_state (pipe1, GST_STATE_PLAYING);
+ gst_bin_iterate (GST_BIN (pipe1));
+ gst_element_set_state (pipe1, GST_STATE_READY);
+
+ /* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */
+ gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink");
+ gst_object_ref (GST_OBJECT (fakesrc));
+ gst_bin_remove (GST_BIN (pipe1), fakesrc);
+ gst_bin_remove (GST_BIN (pipe1), fakesink1);
-
+ gst_object_unref (GST_OBJECT (pipe1));
+
+ /* make a new pipeline */
+ gst_bin_add (GST_BIN (pipe2), fakesink2);
+
+ /* don't change the new pipeline's state, it should change on the bin_add */
+ gst_bin_add (GST_BIN (pipe2), fakesrc);
+ gst_element_link_pads (fakesrc, "src", fakesink2, "sink");
+
+ /* show the pipeline state */
+ gst_xml_write_file (GST_ELEMENT (pipe2), stdout);
+
+ /* try to iterate the pipeline */
+ gst_element_set_state (pipe2, GST_STATE_PLAYING);
+ gst_bin_iterate (GST_BIN (pipe2));
+ gst_element_set_state (pipe2, GST_STATE_NULL);
+
+ return 0;
+}
#include <gst/gst.h>
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *sink;
gst_init (&argc, &argv);
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
thread = gst_thread_new ("thread");
-
+
queue = gst_element_factory_make ("queue", "queue");
sink = gst_element_factory_make ("fakesink", "sink");
-
+
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), sink);
gst_bin_add (GST_BIN (pipeline), thread);
#include <gst/gst.h>
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *identity, *sink;
gst_init (&argc, &argv);
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
thread = gst_thread_new ("thread");
-
+
queue = gst_element_factory_make ("queue", "queue");
identity = gst_element_factory_make ("identity", "identity");
g_object_set (G_OBJECT (identity), "loop_based", TRUE, NULL);
sink = gst_element_factory_make ("fakesink", "sink");
-
+
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), identity);
gst_bin_add (GST_BIN (thread), sink);
#include <gst/gst.h>
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *pipeline, *thread, *queue, *src, *adder, *sink;
GstPad *sinkpad;
gst_init (&argc, &argv);
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
thread = gst_thread_new ("thread");
-
+
queue = gst_element_factory_make ("queue", "queue");
adder = gst_element_factory_make ("adder", "adder");
sink = gst_element_factory_make ("fakesink", "sink");
-
+
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), adder);
gst_bin_add (GST_BIN (thread), sink);
static guint outcount, incount;
static void
-buffer_handoff_sink (GstElement *src, GstBuffer *buf, GstElement *bin)
+buffer_handoff_sink (GstElement * src, GstBuffer * buf, GstElement * bin)
{
g_print ("\n\n *** buffer arrived in sink ***\n\n");
- gst_element_set_state(bin, GST_STATE_NULL);
+ gst_element_set_state (bin, GST_STATE_NULL);
outcount++;
}
static void
-buffer_handoff_src (GstElement *src, GstBuffer *buf, GstElement *bin)
+buffer_handoff_src (GstElement * src, GstBuffer * buf, GstElement * bin)
{
g_print ("\n\n *** buffer started in src ***\n\n");
incount++;
}
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
- g_print("have eos, quitting\n");
+ g_print ("have eos, quitting\n");
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstXML *xml;
GList *toplevelelements;
gint i = 1;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc < 2) {
g_print ("usage: %s <xml file>\n", argv[0]);
g_print ("\n *** using testfile %s\n", argv[1]);
- xml = gst_xml_new();
+ xml = gst_xml_new ();
gst_xml_parse_file (xml, argv[1], NULL);
toplevelelements = gst_xml_get_topelements (xml);
while (toplevelelements) {
- GstElement *bin = (GstElement *)toplevelelements->data;
+ GstElement *bin = (GstElement *) toplevelelements->data;
GstElement *src, *sink;
g_print ("\n ***** testcase %d\n", i++);
src = gst_bin_get_by_name (GST_BIN (bin), "fakesrc");
if (src) {
- g_signal_connect (G_OBJECT(src), "handoff",
- G_CALLBACK(buffer_handoff_src), bin);
- }
- else {
+ g_signal_connect (G_OBJECT (src), "handoff",
+ G_CALLBACK (buffer_handoff_src), bin);
+ } else {
g_print ("could not find src element\n");
- exit(-1);
+ exit (-1);
}
-
+
sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink");
if (sink) {
- g_signal_connect (G_OBJECT(sink), "handoff",
- G_CALLBACK(buffer_handoff_sink), bin);
- }
- else {
+ g_signal_connect (G_OBJECT (sink), "handoff",
+ G_CALLBACK (buffer_handoff_sink), bin);
+ } else {
g_print ("could not find sink element\n");
- exit(-1);
+ exit (-1);
}
incount = 0;
outcount = 0;
/* gst_element_set_state(bin, GST_STATE_READY); */
- gst_element_set_state(bin, GST_STATE_PLAYING);
+ gst_element_set_state (bin, GST_STATE_PLAYING);
if (GST_IS_THREAD (bin)) {
g_usleep (G_USEC_PER_SEC);
- }
- else {
- gst_bin_iterate(GST_BIN(bin));
+ } else {
+ gst_bin_iterate (GST_BIN (bin));
}
if (outcount != 1 && incount != 1) {
toplevelelements = g_list_next (toplevelelements);
}
- exit(0);
+ exit (0);
}
#define TAILLE 100
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *src, *dec, *sink;
int i, j;
gst_init (&argc, &argv);
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
- for(i = 0; i < TAILLE; i++)
- {
+ for (i = 0; i < TAILLE; i++) {
bin = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "source");
dec = gst_element_factory_make ("identity", "decoder");
gst_bin_add_many (GST_BIN (bin), src, dec, sink, NULL);
gst_element_link_many (src, dec, sink, NULL);
gst_element_set_state (bin, GST_STATE_PLAYING);
- for(j = 0; j < 30; j++)
- gst_bin_iterate(GST_BIN(bin));
+ for (j = 0; j < 30; j++)
+ gst_bin_iterate (GST_BIN (bin));
gst_element_set_state (bin, GST_STATE_PAUSED);
}
return 0;
}
-
static GstPad *pad;
static void
-event_received (GObject *object, GstEvent *event, GstElement *pipeline)
+event_received (GObject * object, GstEvent * event, GstElement * pipeline)
{
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE) {
g_print ("segment done\n");
if (--looping == 1) {
event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, 20, 25);
- }
- else {
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 20, 25);
+ } else {
event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH |
- GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55);
+ GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55);
}
gst_pad_send_event (pad, event);
}
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc;
GstElement *fakesink;
guint64 value;
GstFormat format;
-
+
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
gst_element_set_state (pipeline, GST_STATE_READY);
- pad = gst_element_get_pad (fakesrc, "src");
-
+ pad = gst_element_get_pad (fakesrc, "src");
+
g_print ("doing segment seek from 5 to 10\n");
gst_pad_send_event (pad,
- gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, 5, 10));
+ gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5, 10));
format = GST_FORMAT_DEFAULT;
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
while (gst_bin_iterate (GST_BIN (pipeline)));
- g_print ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n");
+ g_print
+ ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n");
looping = 3;
event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH |
- GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55);
+ GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55);
gst_pad_send_event (pad, event);
- g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")), "event_received", G_CALLBACK (event_received), event);
+ g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")),
+ "event_received", G_CALLBACK (event_received), event);
gst_pad_query (pad, GST_QUERY_START, &format, &value);
g_print ("configured for start %" G_GINT64_FORMAT "\n", value);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
-
+
return 0;
}
typedef struct
{
GMutex *mutex;
- GCond *cond;
- gint var;
+ GCond *cond;
+ gint var;
} ThreadInfo;
-static void*
+static void *
thread_loop (void *arg)
{
ThreadInfo *info = (ThreadInfo *) arg;
return NULL;
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
ThreadInfo *info;
GThread *thread;
info->mutex = g_mutex_new ();
info->cond = g_cond_new ();
info->var = 0;
-
+
g_print ("main: lock\n");
g_mutex_lock (info->mutex);
- thread = g_thread_create (thread_loop,
- info,
- TRUE,
- &error);
+ thread = g_thread_create (thread_loop, info, TRUE, &error);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_cond_wait (info->cond, info->mutex);
g_print ("main: var == %d\n", info->var);
- if (info->var != 1)
+ if (info->var != 1)
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
g_mutex_unlock (info->mutex);
return res;
}
-
typedef struct
{
GMutex *mutex;
- GCond *cond_t;
- GCond *cond_p;
- gint var;
+ GCond *cond_t;
+ GCond *cond_p;
+ gint var;
} ThreadInfo;
-static void*
+static void *
thread_loop (void *arg)
{
ThreadInfo *info = (ThreadInfo *) arg;
return NULL;
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
ThreadInfo *info;
GThread *thread;
info->cond_t = g_cond_new ();
info->cond_p = g_cond_new ();
info->var = 0;
-
+
g_print ("main: lock\n");
g_mutex_lock (info->mutex);
- thread = g_thread_create (thread_loop,
- info,
- TRUE,
- &error);
+ thread = g_thread_create (thread_loop, info, TRUE, &error);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
return res;
}
-
*/
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread;
gint x;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
- fakesrc = gst_element_factory_make("fakesrc", "fake_source");
- g_assert(fakesrc != NULL);
+ fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
+ g_assert (fakesrc != NULL);
- fakesink = gst_element_factory_make("fakesink", "fake_sink");
- g_assert(fakesink != NULL);
+ fakesink = gst_element_factory_make ("fakesink", "fake_sink");
+ g_assert (fakesink != NULL);
- gst_bin_add_many (GST_BIN(thread), fakesrc, fakesink, NULL);
+ gst_bin_add_many (GST_BIN (thread), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
- for (x = 0 ; x < 10 ; x++){
- g_print("playing %d\n", x);
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
+ for (x = 0; x < 10; x++) {
+ g_print ("playing %d\n", x);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
- g_print("pausing %d\n", x);
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PAUSED);
+ g_print ("pausing %d\n", x);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PAUSED);
g_usleep (G_USEC_PER_SEC);
}
- exit(0);
+ exit (0);
}
*/
/* eos will be called when the src element has an end of stream */
-void eos(GstElement *element, gpointer data)
+void
+eos (GstElement * element, gpointer data)
{
GstThread *thread = GST_THREAD (data);
- g_print("have eos, quitting\n");
+
+ g_print ("have eos, quitting\n");
/* stop the bin */
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
- gst_main_quit();
+ gst_main_quit ();
}
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *filesrc, *osssink;
GstElement *thread;
GstElement *mad;
gint x;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
if (argc != 2) {
g_print ("usage: %s <filename>\n", argv[0]);
filesrc = gst_element_factory_make ("filesrc", "disk_source");
g_assert (filesrc != NULL);
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
- g_signal_connect (G_OBJECT (filesrc), "eos",
- G_CALLBACK (eos), thread);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
/* and an audio sink */
osssink = gst_element_factory_make ("osssink", "play_audio");
gst_bin_add_many (GST_BIN (thread), filesrc, mad, osssink, NULL);
gst_element_link_many (filesrc, mad, osssink, NULL);
- for (x = 0 ; x < 10 ; x++){
+ for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC * 2);
* { { fakesrc ! fakesink } }
*/
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
gint x;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
- thread2 = gst_thread_new("thread2");
- g_assert(thread2 != NULL);
+ thread2 = gst_thread_new ("thread2");
+ g_assert (thread2 != NULL);
- gst_bin_add(GST_BIN(thread), GST_ELEMENT(thread2));
+ gst_bin_add (GST_BIN (thread), GST_ELEMENT (thread2));
- fakesrc = gst_element_factory_make("fakesrc", "fake_source");
- g_assert(fakesrc != NULL);
+ fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
+ g_assert (fakesrc != NULL);
- fakesink = gst_element_factory_make("fakesink", "fake_sink");
- g_assert(fakesink != NULL);
+ fakesink = gst_element_factory_make ("fakesink", "fake_sink");
+ g_assert (fakesink != NULL);
- gst_bin_add_many (GST_BIN(thread2), fakesrc, fakesink, NULL);
+ gst_bin_add_many (GST_BIN (thread2), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
- for (x = 0 ; x < 10 ; x++){
- g_print("playing %d\n", x);
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
+ for (x = 0; x < 10; x++) {
+ g_print ("playing %d\n", x);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
- g_print("nulling %d\n", x);
- gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
+ g_print ("nulling %d\n", x);
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
- exit(0);
+ exit (0);
}
* { { fakesrc } ! queue ! fakesink }
*/
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
GstElement *queue;
gint x;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
- thread2 = gst_thread_new("thread");
- g_assert(thread2 != NULL);
+ thread2 = gst_thread_new ("thread");
+ g_assert (thread2 != NULL);
- queue = gst_element_factory_make("queue", "the_queue");
- g_assert(queue != NULL);
+ queue = gst_element_factory_make ("queue", "the_queue");
+ g_assert (queue != NULL);
- fakesrc = gst_element_factory_make("fakesrc", "fake_source");
- g_assert(fakesrc != NULL);
+ fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
+ g_assert (fakesrc != NULL);
- fakesink = gst_element_factory_make("fakesink", "fake_sink");
- g_assert(fakesink != NULL);
+ fakesink = gst_element_factory_make ("fakesink", "fake_sink");
+ g_assert (fakesink != NULL);
- gst_bin_add_many (GST_BIN(thread), thread2, queue, fakesink, NULL);
+ gst_bin_add_many (GST_BIN (thread), thread2, queue, fakesink, NULL);
- gst_bin_add(GST_BIN(thread2), fakesrc);
- gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"), "src");
+ gst_bin_add (GST_BIN (thread2), fakesrc);
+ gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"),
+ "src");
gst_element_link_many (thread2, queue, fakesink, NULL);
- for (x = 0 ; x < 10 ; x++){
- g_print("playing %d\n", x);
- gst_element_set_state(thread, GST_STATE_PLAYING);
+ for (x = 0; x < 10; x++) {
+ g_print ("playing %d\n", x);
+ gst_element_set_state (thread, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
- g_print("nulling %d\n", x);
- gst_element_set_state(thread, GST_STATE_NULL);
+ g_print ("nulling %d\n", x);
+ gst_element_set_state (thread, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
- exit(0);
+ exit (0);
}
* { fakesrc ! { queue ! fakesink } }
*/
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *thread, *thread2;
GstElement *queue;
gint x;
- gst_init(&argc,&argv);
+ gst_init (&argc, &argv);
- thread = gst_thread_new("thread");
- g_assert(thread != NULL);
+ thread = gst_thread_new ("thread");
+ g_assert (thread != NULL);
- thread2 = gst_thread_new("thread");
- g_assert(thread2 != NULL);
+ thread2 = gst_thread_new ("thread");
+ g_assert (thread2 != NULL);
- queue = gst_element_factory_make("queue", "the_queue");
- g_assert(queue != NULL);
+ queue = gst_element_factory_make ("queue", "the_queue");
+ g_assert (queue != NULL);
- fakesrc = gst_element_factory_make("fakesrc", "fake_source");
- g_assert(fakesrc != NULL);
+ fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
+ g_assert (fakesrc != NULL);
- fakesink = gst_element_factory_make("fakesink", "fake_sink");
- g_assert(fakesink != NULL);
+ fakesink = gst_element_factory_make ("fakesink", "fake_sink");
+ g_assert (fakesink != NULL);
- gst_bin_add_many (GST_BIN(thread), fakesrc, thread2, NULL);
- gst_bin_add_many (GST_BIN(thread2), queue, fakesink, NULL);
+ gst_bin_add_many (GST_BIN (thread), fakesrc, thread2, NULL);
+ gst_bin_add_many (GST_BIN (thread2), queue, fakesink, NULL);
- gst_element_add_ghost_pad (thread2, gst_element_get_pad (queue, "sink"), "sink");
+ gst_element_add_ghost_pad (thread2, gst_element_get_pad (queue, "sink"),
+ "sink");
gst_element_link_many (queue, fakesink, NULL);
gst_element_link_many (fakesrc, thread2, NULL);
- for (x = 0 ; x < 10 ; x++){
- g_print("playing %d\n", x);
- gst_element_set_state(thread, GST_STATE_PLAYING);
+ for (x = 0; x < 10; x++) {
+ g_print ("playing %d\n", x);
+ gst_element_set_state (thread, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
- g_print("nulling %d\n", x);
- gst_element_set_state(thread, GST_STATE_NULL);
+ g_print ("nulling %d\n", x);
+ gst_element_set_state (thread, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
- exit(0);
+ exit (0);
}
/* tests if gst_bin_get_(all_)by_interface works */
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstBin *bin, *bin2;
GList *list;
GstElement *filesrc;
-
+
gst_init (&argc, &argv);
bin = GST_BIN (gst_bin_new (NULL));
g_assert (filesrc);
g_assert (GST_IS_URI_HANDLER (filesrc));
gst_bin_add (bin, filesrc);
-
+
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
g_assert (list->data == (gpointer) filesrc);
g_list_free (list);
-
- gst_bin_add_many (bin,
+
+ gst_bin_add_many (bin,
gst_element_factory_make ("identity", NULL),
- gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
- NULL);
+ gst_element_factory_make ("identity", NULL), NULL);
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
gst_bin_add_many (bin,
gst_element_factory_make ("identity", NULL),
gst_element_factory_make ("identity", NULL),
- GST_ELEMENT (bin2),
- gst_element_factory_make ("identity", NULL),
- NULL);
+ GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL);
g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER);
g_assert (g_list_length (list) == 1);
GstPad *srcpad;
GstByteStream *bs;
-
- gchar *accesspattern;
- guint num_patterns;
- gchar **patterns;
- guint sizemin;
- guint sizemax;
- gint count;
- gboolean silent;
+
+ gchar *accesspattern;
+ guint num_patterns;
+ gchar **patterns;
+ guint sizemin;
+ guint sizemax;
+ gint count;
+ gboolean silent;
};
struct _GstBsTestClass
GType gst_bstest_get_type (void);
-GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS (
- "ByteStreamTest",
- "Filter",
- "Test for the GstByteStream code",
- "Erik Walthinsen <omega@temple-baptist.com>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ("ByteStreamTest",
+ "Filter",
+ "Test for the GstByteStream code",
+ "Erik Walthinsen <omega@temple-baptist.com>, "
+ "Wim Taymans <wim.taymans@chello.be>");
/* BsTest signals and args */
};
-static void gst_bstest_base_init (gpointer g_class);
-static void gst_bstest_class_init (GstBsTestClass * klass);
-static void gst_bstest_init (GstBsTest * bstest);
+static void gst_bstest_base_init (gpointer g_class);
+static void gst_bstest_class_init (GstBsTestClass * klass);
+static void gst_bstest_init (GstBsTest * bstest);
-static void gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec);
-static void gst_bstest_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec);
+static void gst_bstest_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_bstest_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_bstest_change_state (GstElement *element);
-static void gst_bstest_loop (GstElement * element);
+static GstElementStateReturn gst_bstest_change_state (GstElement * element);
+static void gst_bstest_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
(GInstanceInitFunc) gst_bstest_init,
};
- bstest_type = g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0);
+ bstest_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0);
}
return bstest_type;
}
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
- g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT,
- 0, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT,
+ 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
- g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT,
- 384, G_PARAM_READWRITE));
+ g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT,
+ 384, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSPATTERN,
- g_param_spec_string ("accesspattern", "accesspattern", "accesspattern",
- "r", G_PARAM_READWRITE));
+ g_param_spec_string ("accesspattern", "accesspattern", "accesspattern",
+ "r", G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COUNT,
- g_param_spec_uint ("count", "count", "count",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ g_param_spec_uint ("count", "count", "count",
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
- g_param_spec_boolean ("silent", "silent", "silent",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("silent", "silent", "silent",
+ FALSE, G_PARAM_READWRITE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_bstest_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_bstest_get_property);
}
static GstCaps *
-gst_bstest_getcaps (GstPad *pad)
+gst_bstest_getcaps (GstPad * pad)
{
GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad));
GstPad *otherpad;
}
static guint
-gst_bstest_get_size (GstBsTest *bstest, gchar *sizestring, guint prevsize)
+gst_bstest_get_size (GstBsTest * bstest, gchar * sizestring, guint prevsize)
{
guint size;
if (sizestring[0] == 0) {
size = bstest->sizemax;
- }
- else if (sizestring[0] == 'r') {
- size = bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin));
- }
- else if (sizestring[0] == '<') {
+ } else if (sizestring[0] == 'r') {
+ size =
+ bstest->sizemin +
+ (guint8) (((gfloat) bstest->sizemax) * rand () / (RAND_MAX +
+ (gfloat) bstest->sizemin));
+ } else if (sizestring[0] == '<') {
size = prevsize;
- }
- else {
+ } else {
size = atoi (sizestring);
}
- if (size == 0) size++;
+ if (size == 0)
+ size++;
return size;
}
if (bstest->patterns[i][0] == 'r') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size);
- gst_bytestream_read (bstest->bs, &buf, size);
- }
- else if (bstest->patterns[i][0] == 'f') {
+ if (!bstest->silent)
+ g_print ("bstest: ***** read %d bytes\n", size);
+ gst_bytestream_read (bstest->bs, &buf, size);
+ } else if (bstest->patterns[i][0] == 'f') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** flush %d bytes\n", size);
- gst_bytestream_flush (bstest->bs, size);
- }
- else if (!strncmp (bstest->patterns[i], "pb", 2)) {
+ if (!bstest->silent)
+ g_print ("bstest: ***** flush %d bytes\n", size);
+ gst_bytestream_flush (bstest->bs, size);
+ } else if (!strncmp (bstest->patterns[i], "pb", 2)) {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][2], size);
- if (!bstest->silent) g_print ("bstest: ***** peek bytes %d bytes\n", size);
- gst_bytestream_peek_bytes (bstest->bs, &ptr, size);
- }
- else if (bstest->patterns[i][0] == 'p') {
+ if (!bstest->silent)
+ g_print ("bstest: ***** peek bytes %d bytes\n", size);
+ gst_bytestream_peek_bytes (bstest->bs, &ptr, size);
+ } else if (bstest->patterns[i][0] == 'p') {
size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
- if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size);
- gst_bytestream_peek (bstest->bs, &buf, size);
+ if (!bstest->silent)
+ g_print ("bstest: ***** peek %d bytes\n", size);
+ gst_bytestream_peek (bstest->bs, &buf, size);
gst_buffer_unref (buf);
buf = NULL;
}
if (buf)
- gst_pad_push (bstest->srcpad, GST_DATA (buf));
-
+ gst_pad_push (bstest->srcpad, GST_DATA (buf));
+
i++;
}
/* } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); */
}
static void
-gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstBsTest *bstest;
g_strfreev (bstest->patterns);
}
if (g_value_get_string (value) == NULL) {
- gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
- bstest->accesspattern = NULL;
- bstest->num_patterns = 0;
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ bstest->accesspattern = NULL;
+ bstest->num_patterns = 0;
} else {
guint i = 0;
- bstest->accesspattern = g_strdup (g_value_get_string (value));
- bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
- while (bstest->patterns[i++]);
- bstest->num_patterns = i-1;
+ bstest->accesspattern = g_strdup (g_value_get_string (value));
+ bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
+ while (bstest->patterns[i++]);
+ bstest->num_patterns = i - 1;
}
break;
case ARG_COUNT:
}
static void
-gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_bstest_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstBsTest *bstest;
}
static GstElementStateReturn
-gst_bstest_change_state (GstElement *element)
+gst_bstest_change_state (GstElement * element)
{
GstBsTest *bstest;
gst_bytestream_destroy (bstest->bs);
bstest->bs = NULL;
}
- }
- else {
+ } else {
if (!bstest->bs) {
bstest->bs = gst_bytestream_new (bstest->sinkpad);
}
* This consists of the name of the element, the GType identifier,
* and a pointer to the details structure at the top of the file.
*/
- return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, GST_TYPE_BSTEST);
+ return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY,
+ GST_TYPE_BSTEST);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "bstest",
- "test for the bytestream element",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "bstest",
+ "test for the bytestream element",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
static gboolean dump = FALSE;
static void
-handoff (GstElement *element, GstBuffer *buf, GstPad *pad, gpointer data)
+handoff (GstElement * element, GstBuffer * buf, GstPad * pad, gpointer data)
{
if (GST_IS_BUFFER (buf)) {
if (integrity_check) {
gint i;
guint8 *ptr = GST_BUFFER_DATA (buf);
-
- for (i=0; i<GST_BUFFER_SIZE (buf); i++) {
- if (*ptr++ != count++) {
+
+ for (i = 0; i < GST_BUFFER_SIZE (buf); i++) {
+ if (*ptr++ != count++) {
g_print ("data error!\n");
return;
- }
+ }
}
}
- }
- else {
+ } else {
g_print ("not a buffer ! %p\n", buf);
}
}
-static gchar*
-create_desc (TestParam *param)
+static gchar *
+create_desc (TestParam * param)
{
gchar *desc;
- desc = g_strdup_printf ("%s %s, pattern %s", (param->src_sizetype == 2 ? "fixed" : "random"),
- (param->src_data == 1 ? "src" : "subbuffer"),
- param->bs_accesspattern);
+ desc =
+ g_strdup_printf ("%s %s, pattern %s",
+ (param->src_sizetype == 2 ? "fixed" : "random"),
+ (param->src_data == 1 ? "src" : "subbuffer"), param->bs_accesspattern);
return desc;
}
-static gboolean
-read_param_file (gchar *filename)
+static gboolean
+read_param_file (gchar * filename)
{
FILE *fp;
- gchar line[MAX_CONFIG_LINE+1];
+ gchar line[MAX_CONFIG_LINE + 1];
guint linenr = 0;
gchar pattern[MAX_CONFIG_PATTERN];
gint data, sizetype, integrity_check;
gboolean res = TRUE;
fp = fopen (filename, "r");
- if (fp == NULL)
+ if (fp == NULL)
return FALSE;
- scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN-1);
-
- while (fgets (line, MAX_CONFIG_LINE, fp)) {
+ scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN - 1);
+
+ while (fgets (line, MAX_CONFIG_LINE, fp)) {
linenr++;
if (line[0] == '\n' || line[0] == '#')
continue;
- if (sscanf (line, scan_str, &data, &sizetype, pattern, &integrity_check) != 4) {
+ if (sscanf (line, scan_str, &data, &sizetype, pattern,
+ &integrity_check) != 4) {
g_print ("error on line: %d\n", linenr);
res = FALSE;
break;
- }
- else {
+ } else {
TestParam *param = g_malloc (sizeof (TestParam));
param->src_data = data;
}
}
g_free (scan_str);
-
+
return res;
}
-static void
-run_test (GstBin *pipeline, gint iters)
+static void
+run_test (GstBin * pipeline, gint iters)
{
gint vm = 0;
gint maxiters = iters;
gint newvm = gst_alloc_trace_live_all ();
gint percent;
- percent = (gint)((maxiters-iters+1)*100.0/maxiters);
+ percent = (gint) ((maxiters - iters + 1) * 100.0 / maxiters);
if (percent != prev_percent || newvm - vm > VM_THRES) {
- g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, percent);
+ g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm,
+ percent);
prev_percent = percent;
vm = newvm;
}
gst_bin_iterate (pipeline);
- if (iters > 0) iters--;
+ if (iters > 0)
+ iters--;
}
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
}
-static void
+static void
usage (char *argv[])
{
- g_print ("usage: %s [--verbose] [--dump] <paramfile> <iterations>\n", argv[0]);
+ g_print ("usage: %s [--verbose] [--dump] <paramfile> <iterations>\n",
+ argv[0]);
}
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
GstElement *src;
GstElement *sink;
gst_init (&argc, &argv);
arg_walk = 1;
- while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) {
+ while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) {
if (!strncmp (argv[arg_walk], "--verbose", 9))
verbose = TRUE;
else if (!strncmp (argv[arg_walk], "--dump", 6))
arg_walk++;
}
if (argc - arg_walk < 2) {
- usage(argv);
+ usage (argv);
return -1;
}
- if (!read_param_file (argv[arg_walk])) {
+ if (!read_param_file (argv[arg_walk])) {
g_print ("error reading file %s\n", argv[arg_walk]);
usage (argv);
return -1;
integrity_check = param->integrity_check;
- g_print ("\n\nrunning test %d (%d iterations):\n", testnum+1, iterations);
+ g_print ("\n\nrunning test %d (%d iterations):\n", testnum + 1, iterations);
desc = create_desc (param);
g_print ("%s\n", desc);
g_free (desc);
- g_object_set (G_OBJECT (src), "data", param->src_data,
- "sizetype", param->src_sizetype,
- "filltype", (integrity_check?5:0),
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (src), "data", param->src_data,
+ "sizetype", param->src_sizetype,
+ "filltype", (integrity_check ? 5 : 0), "silent", !verbose, NULL);
- g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern,
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern,
+ "silent", !verbose, NULL);
- g_object_set (G_OBJECT (sink), "dump", dump,
- "silent", !verbose, NULL);
+ g_object_set (G_OBJECT (sink), "dump", dump, "silent", !verbose, NULL);
run_test (GST_BIN (pipeline), iterations);
static GstCaps *
-handler (GObject *object, GstCaps *caps, gpointer user_data)
+handler (GObject * object, GstCaps * caps, gpointer user_data)
{
- g_print("in handler %p, %p, %p\n", object, caps, user_data);
+ g_print ("in handler %p, %p, %p\n", object, caps, user_data);
- g_assert (GST_IS_PAD(object));
+ g_assert (GST_IS_PAD (object));
- g_print("caps: %s\n", gst_caps_to_string(caps));
+ g_print ("caps: %s\n", gst_caps_to_string (caps));
if (gst_caps_is_any (caps)) {
return gst_caps_new_simple ("application/x-foo",
GstElement *pipeline;
GstPad *pad;
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
pipeline = gst_pipeline_new (NULL);
b = gst_element_factory_make ("fakesink", NULL);
g_assert (b);
- gst_bin_add_many (GST_BIN (pipeline), a,b, NULL);
- gst_element_link (a,b);
+ gst_bin_add_many (GST_BIN (pipeline), a, b, NULL);
+ gst_element_link (a, b);
pad = gst_element_get_pad (a, "src");
g_signal_connect (G_OBJECT (pad), "fixate", G_CALLBACK (handler),
- (void *)0xdeadbeef);
+ (void *) 0xdeadbeef);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
return 0;
}
-
#include <gst/gst.h>
-void test1(void)
+void
+test1 (void)
{
GstCaps *caps;
GstCaps *caps2;
- g_print("type is %d\n", (int)gst_caps_get_type());
+ g_print ("type is %d\n", (int) gst_caps_get_type ());
- caps = gst_caps_new_empty();
- g_assert(caps != NULL);
- gst_caps_free(caps);
+ caps = gst_caps_new_empty ();
+ g_assert (caps != NULL);
+ gst_caps_free (caps);
- caps = gst_caps_new_any();
- g_assert(caps != NULL);
- gst_caps_free(caps);
+ caps = gst_caps_new_any ();
+ g_assert (caps != NULL);
+ gst_caps_free (caps);
- caps = gst_caps_new_simple("audio/raw",
- "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
- caps = gst_caps_new_simple("audio/raw",
+ caps = gst_caps_new_simple ("audio/raw",
"_double", G_TYPE_DOUBLE, 100.0, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw",
- "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC('a','b','c','d'), NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw",
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw",
+ "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'), NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw",
"_boolean", G_TYPE_BOOLEAN, TRUE, NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE);
- g_assert(gst_caps_is_fixed(caps)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw2", "_int", G_TYPE_INT, 100, NULL),
- NULL);
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- caps2 = gst_caps_copy(caps);
- g_assert(caps2 != NULL);
- g_assert(gst_caps_is_empty(caps2)==FALSE);
- g_assert(gst_caps_is_any(caps2)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps2)==TRUE);
- g_assert(gst_caps_is_fixed(caps2)==TRUE);
- g_print("%s\n", gst_caps_to_string(caps));
- g_print("%s\n", gst_caps_to_string(caps2));
- gst_caps_free(caps);
- gst_caps_free(caps2);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- gst_caps_append (caps,
- gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 200, NULL));
- g_assert(caps != NULL);
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
-
- caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL);
- g_assert(caps != NULL);
- gst_caps_append_structure (caps,
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL));
- g_assert(gst_caps_is_empty(caps)==FALSE);
- g_assert(gst_caps_is_any(caps)==FALSE);
- g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE);
- g_assert(gst_caps_is_fixed(caps)==FALSE);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE);
+ g_assert (gst_caps_is_fixed (caps) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw2", "_int", G_TYPE_INT, 100,
+ NULL), NULL);
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ caps2 = gst_caps_copy (caps);
+ g_assert (caps2 != NULL);
+ g_assert (gst_caps_is_empty (caps2) == FALSE);
+ g_assert (gst_caps_is_any (caps2) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps2) == TRUE);
+ g_assert (gst_caps_is_fixed (caps2) == TRUE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ g_print ("%s\n", gst_caps_to_string (caps2));
+ gst_caps_free (caps);
+ gst_caps_free (caps2);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ gst_caps_append (caps,
+ gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 200, NULL));
+ g_assert (caps != NULL);
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+
+ caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL);
+ g_assert (caps != NULL);
+ gst_caps_append_structure (caps,
+ gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, NULL));
+ g_assert (gst_caps_is_empty (caps) == FALSE);
+ g_assert (gst_caps_is_any (caps) == FALSE);
+ g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE);
+ g_assert (gst_caps_is_fixed (caps) == FALSE);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
}
-void test2(void)
+void
+test2 (void)
{
GstCaps *caps1;
GstCaps *caps2;
GstCaps *caps;
- caps1 = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL),
- NULL);
- caps2 = gst_caps_new_full(
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL),
- gst_structure_new("audio/raw", "_int", G_TYPE_INT, 300, NULL),
- NULL);
- caps = gst_caps_intersect(caps1, caps2);
- g_print("%s\n", gst_caps_to_string(caps));
- gst_caps_free(caps);
- gst_caps_free(caps1);
- gst_caps_free(caps2);
+ caps1 =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200,
+ NULL), NULL);
+ caps2 =
+ gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT,
+ 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 300,
+ NULL), NULL);
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("%s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps);
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
- test2();
+ test1 ();
+ test2 ();
return 0;
}
-
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS(
- "video/mpeg, "
- "mpegtype=(int)[1,2]"
-);
-
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS(
- "video/mpeg, "
- "mpegtype=(int)1"
-);
-
-GstStaticCaps rawcaps = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){YV12,YUY2}, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc)YUY2, "
- "height=(int)[16,256]"
-);
-
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
- "video/raw, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)[1,2]");
+
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1");
+
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc){YV12,YUY2}, "
- "height=(int)[16,4096]"
-);
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc)YUY2, " "height=(int)[16,256]");
+
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){YV12,YUY2}, " "height=(int)[16,4096]");
#if 0
/* these caps aren't used yet */
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){\"YV12\", \"YUYV\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/raw, "
- "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, "
- "height=(int)[16,4096]"
-);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " "height=(int)[16,4096]");
#endif
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YUYV\""
-);
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\"");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YV12\""
-);
+GstStaticCaps rawcaps7 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\"");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
gboolean testret;
gint ret = 0;
gst_static_caps_get (&rawcaps));
g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret);
ret = ret + (testret == FALSE) ? 0 : 1;
-
+
testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps),
gst_static_caps_get (&sinkcaps));
g_print ("4 <-> 1 == %d (valid, subset)\n", testret);
ret = ret + (testret == TRUE) ? 0 : 1;
-
+
testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
g_print ("1 <-> 4 == %d (invalid, superset)\n", testret);
#include <gst/gst.h>
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
#if 0
GstCaps *caps;
-
+
gst_init (&argc, &argv);
- caps = GST_CAPS_NEW (
- "testcaps",
- "unknown/unknown",
- NULL);
+ caps = GST_CAPS_NEW ("testcaps", "unknown/unknown", NULL);
/* newly crrated caps without props is fixed */
g_assert (GST_CAPS_IS_FIXED (caps));
-
+
entry = gst_props_entry_new ("foo", GST_PROPS_INT (5));
/* this entry is fixed */
g_assert (gst_props_entry_is_fixed (entry));
props = gst_props_empty_new ();
/* props are fixed when created */
g_assert (GST_PROPS_IS_FIXED (props));
-
+
gst_props_add_entry (props, entry);
/* props should still be fixed */
g_assert (GST_PROPS_IS_FIXED (props));
/* caps too */
g_assert (GST_CAPS_IS_FIXED (caps));
- gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1,5));
+ gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1, 5));
/* props should be variable again now */
g_assert (!GST_PROPS_IS_FIXED (props));
/* caps too */
#include <gst/gst.h>
-GstStaticCaps rawcaps1 = GST_STATIC_CAPS(
- "video/x-raw-yuv, "
+GstStaticCaps rawcaps1 = GST_STATIC_CAPS ("video/x-raw-yuv, "
"fourcc:fourcc=\"YUYV\", "
"height:int=640, "
"width:int=480, "
"framerate:float=30.0; "
- "video/x-raw-yuv, "
+ "video/x-raw-yuv, "
"fourcc:fourcc=\"I420\", "
- "height:int=640, "
- "width:int=480, "
- "framerate:float=30.0"
-);
+ "height:int=640, " "width:int=480, " "framerate:float=30.0");
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS(
- "video/x-raw-yuv"
-);
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/x-raw-yuv");
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS(
- "video/x-raw-yuv, height=(int) [ 0, MAX ]"
-);
+GstStaticCaps rawcaps3 =
+GST_STATIC_CAPS ("video/x-raw-yuv, height=(int) [ 0, MAX ]");
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"
-);
+GstStaticCaps rawcaps4 =
+ GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY");
-GstStaticCaps rawcaps5 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"
-);
+GstStaticCaps rawcaps5 =
+ GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]");
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
-);
+GstStaticCaps rawcaps6 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps7 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]");
-GstStaticCaps rawcaps8 = GST_STATIC_CAPS(
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"
-);
+GstStaticCaps rawcaps8 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstCaps *caps1;
GstCaps *caps2;
gst_init (&argc, &argv);
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1));
- caps2 = gst_caps_new_full (gst_structure_copy ( gst_caps_get_structure (
- gst_static_caps_get (&rawcaps1), 0)), NULL);
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps1));
+ caps2 =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure
+ (gst_static_caps_get (&rawcaps1), 0)), NULL);
#if 0
- gst_caps_set(caps1, "height", GST_PROPS_INT(640));
- gst_caps_set(caps1, "width", GST_PROPS_INT(480));
- gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0));
+ gst_caps_set (caps1, "height", GST_PROPS_INT (640));
+ gst_caps_set (caps1, "width", GST_PROPS_INT (480));
+ gst_caps_set (caps1, "framerate", GST_PROPS_FLOAT (30.0));
#endif
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3));
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5));
- caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6));
- caps4 = gst_caps_intersect(caps1, caps2);
- caps = gst_caps_intersect(caps3, caps4);
- g_print("caps4 %s\n", gst_caps_to_string(caps4));
- g_print("caps %s\n", gst_caps_to_string(caps));
- gst_caps_free(caps1);
- gst_caps_free(caps2);
- gst_caps_free(caps3);
- gst_caps_free(caps4);
-
- caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7));
- caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8));
- caps = gst_caps_intersect(caps1, caps2);
- g_print("caps %s\n", gst_caps_to_string(caps));
- if (gst_caps_is_empty (caps)) return 1;
- gst_caps_free(caps1);
- gst_caps_free(caps2);
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps2));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps3));
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps4));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps5));
+ caps3 = gst_caps_copy (gst_static_caps_get (&rawcaps6));
+ caps4 = gst_caps_intersect (caps1, caps2);
+ caps = gst_caps_intersect (caps3, caps4);
+ g_print ("caps4 %s\n", gst_caps_to_string (caps4));
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
+ gst_caps_free (caps3);
+ gst_caps_free (caps4);
+
+ caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps7));
+ caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps8));
+ caps = gst_caps_intersect (caps1, caps2);
+ g_print ("caps %s\n", gst_caps_to_string (caps));
+ if (gst_caps_is_empty (caps))
+ return 1;
+ gst_caps_free (caps1);
+ gst_caps_free (caps2);
return 0;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype=(int)1, "
- "foo1=(int)[20,40], "
- "foo2=(int)[20,40], "
- "foo3=(int)[10,20]"
-);
+ "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype=(int)1, "
- "foo1=(int)30, "
- "foo2=(int)[20,30], "
- "foo3=(int)[20,30]"
-);
-
-
-
-GstStaticCaps rawcaps = GST_STATIC_CAPS (
- "video/raw, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
- "video/raw, "
- "height=(int)[16,256], "
- "depth=(int)16"
-);
-
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUY2\", \"YV12\" }, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps5 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps rawcaps6 = GST_STATIC_CAPS (
- "video/raw, "
+ "foo1=(int)30, " "foo2=(int)[20,30], " "foo3=(int)[20,30]");
+
+
+
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
+ "height=(int)[16,256], " "depth=(int)16");
+
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps5 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc)\"YUYV\", "
"height=(int)640, "
"width=(int)480, "
"framerate=(double)30.0; "
- "video/raw, "
+ "video/raw, "
"fourcc=(fourcc)\"I420\", "
- "height=(int)640, "
- "width=(int)480, "
- "framerate=(double)30.0"
-);
+ "height=(int)640, " "width=(int)480, " "framerate=(double)30.0");
-GstStaticCaps rawcaps7 = GST_STATIC_CAPS (
- "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps7 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]");
-GstStaticCaps rawcaps8 = GST_STATIC_CAPS (
- "video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]"
-);
+GstStaticCaps rawcaps8 =
+GST_STATIC_CAPS
+ ("video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
xmlDocPtr doc;
xmlNodePtr parent;
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
/*
- g_mem_chunk_info ();
- for (i = 0; i<100000; i++) {
- caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
- gst_caps_unref (caps);
- }
- g_mem_chunk_info ();
- */
+ g_mem_chunk_info ();
+ for (i = 0; i<100000; i++) {
+ caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4));
+ gst_caps_unref (caps);
+ }
+ g_mem_chunk_info ();
+ */
caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps),
gst_static_caps_get (&mp1parsecaps));
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6),
- gst_caps_new_full (gst_structure_copy (
- gst_caps_get_structure (gst_static_caps_get (&rawcaps6), 0)), NULL));
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure
+ (gst_static_caps_get (&rawcaps6), 0)), NULL));
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL);
gst_caps_save_thyself (caps, parent);
caps = gst_caps_intersect (gst_static_caps_get (&rawcaps7),
gst_static_caps_get (&rawcaps8));
- g_print("intersection: %s\n", gst_caps_to_string (caps));
+ g_print ("intersection: %s\n", gst_caps_to_string (caps));
- xmlDocDump(stdout, doc);
+ xmlDocDump (stdout, doc);
return 0;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "foo1=(int)[20,40], "
- "foo2=(int)[20,40], "
- "foo3=(int)[10,20]"
-);
+ "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "foo4=(fourcc){\"YV12\",\"YUY2\"}"
-);
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "foo4=(fourcc){\"YV12\",\"YUY2\"}");
-GstStaticCaps rawcaps = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,4096], "
- "height=(int)[16,4096], "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}"
-);
+ "height=(int)[16,4096], " "fourcc=(fourcc){\"YV12\",\"YUY2\"}");
-GstStaticCaps rawcaps2 = GST_STATIC_CAPS (
- "video/raw, "
- "width=(int)[16,256], "
- "height=(int)16; "
- "video/raw, "
+GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,256], "
- "height=(int)16"
-);
+ "height=(int)16; " "video/raw, " "width=(int)[16,256], " "height=(int)16");
-GstStaticCaps rawcaps3 = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
- "video/raw, "
+ "video/raw, "
"width=(int)[16,256], "
"height=(int)16; "
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
+ "video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]");
-GstStaticCaps rawcaps4 = GST_STATIC_CAPS (
- "x, "
- "y=(int){1,2}, "
- "z=(int){3,4}; "
- "a, "
- "b=(int){5,6}, "
- "c=(int){7,8}"
-);
+GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("x, "
+ "y=(int){1,2}, " "z=(int){3,4}; " "a, " "b=(int){5,6}, " "c=(int){7,8}");
/* defined, not used
GST_CAPS_FACTORY (rawcaps4,
);
*/
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
GstCaps *caps;
#include <gst/gst.h>
#include <string.h>
-GstStaticCaps caps1 = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype=(int){1,2}"
-);
-
-GstStaticCaps caps2 = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype=(int){1}"
-);
-
-GstStaticCaps caps3 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "width=(int)[16,4096], "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps4 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc)\"YV12\", "
- "height=(int)[16,256]"
-);
-
-GstStaticCaps caps5 = GST_STATIC_CAPS (
- "video/raw, "
+GstStaticCaps caps1 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1,2}");
+
+GstStaticCaps caps2 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1}");
+
+GstStaticCaps caps3 = GST_STATIC_CAPS ("video/raw, "
"fourcc=(fourcc){\"YV12\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps6 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YV12\",\"YUYV\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps7 = GST_STATIC_CAPS (
- "video/raw, "
- "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, "
- "height=(int)[16,4096]"
-);
-
-GstStaticCaps caps8 = GST_STATIC_CAPS (
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YUYV\""
-);
-
-GstStaticCaps caps9 = GST_STATIC_CAPS (
- "video/raw, "
- "format=(fourcc)\"I420\"; "
- "video/raw, "
- "format=(fourcc)\"YV12\""
-);
+ "width=(int)[16,4096], " "height=(int)[16,4096]");
+
+GstStaticCaps caps4 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc)\"YV12\", " "height=(int)[16,256]");
+
+GstStaticCaps caps5 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps6 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps7 = GST_STATIC_CAPS ("video/raw, "
+ "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " "height=(int)[16,4096]");
+
+GstStaticCaps caps8 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\"");
+
+GstStaticCaps caps9 = GST_STATIC_CAPS ("video/raw, "
+ "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\"");
static gint test = 0;
static gint failures = 0;
} \
}G_STMT_END
static void
-test_caps_func (const GstCaps *caps)
+test_caps_func (const GstCaps * caps)
{
- gchar *str1, *str2;
+ gchar *str1, *str2;
gboolean ret = FALSE;
str1 = gst_caps_to_string (caps);
TEST_END (ret);
}
static void
-test_caps (const GstCaps *caps)
+test_caps (const GstCaps * caps)
{
TEST_START;
test_caps_func (caps);
}
static void
-test_string (gchar *str)
+test_string (gchar * str)
{
GstCaps *caps;
test_caps_func (caps);
}
static void
-test_string_fail (gchar *str)
+test_string_fail (gchar * str)
{
GstCaps *caps;
TEST_START;
g_print ("%3d, INFO : checking %s for failure\n", test, str);
caps = gst_caps_from_string (str);
-g_print("got %p\n", caps);
+ g_print ("got %p\n", caps);
TEST_END (caps == NULL);
}
-int
-main (int argc, char *argv[])
+
+int
+main (int argc, char *argv[])
{
gst_init (&argc, &argv);
-goto bla;
+ goto bla;
bla:
/* stupidity tests */
test_caps (gst_caps_new_simple ("audio/raw", NULL));
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]");
test_string ("audio/raw, test =(i) [(int)1,2]");
test_string ("audio/raw, test={(int)1,2}");
- test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
+ test_string
+ ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}");
test_string ("audio/raw, test= {1.0}");
test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}");
test_string ("audio/raw, test= {(int)1,2}");
test_string ("audio/raw, test= {(int)1,2}");
-
+
/* prop concatenations */
test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]");
test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1");
- test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
+ test_string
+ ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \"");
test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}");
- test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
+ test_string
+ ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1");
/* caps concatenations */
- test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
- test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
- test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
+ test_string
+ ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\"");
+ test_string
+ ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}");
+ test_string
+ ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]");
/* mimes */
test_string_fail ("audio/raw, test= '");
if (failures) {
- g_print ("\n FAILURES : %d\n", failures);
+ g_print ("\n FAILURES : %d\n", failures);
} else {
- g_print ("\n DONE\n");
+ g_print ("\n DONE\n");
}
return failures;
}
#include <gst/gst.h>
/* these caps all have a non empty intersection */
-GstStaticCaps sinkcaps = GST_STATIC_CAPS (
- "video/mpeg, "
+GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, "
"mpegtype:int=1, "
- "foo1:int=[20,40], "
- "foo2:int=[20,40], "
- "foo3:int=[10,20]"
-);
+ "foo1:int=[20,40], " "foo2:int=[20,40], " "foo3:int=[10,20]");
-GstStaticCaps mp1parsecaps = GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegtype:int=1, "
- "foo1:int=30, "
- "foo2:int=[20,30], "
- "foo3:int=[20,30]"
-);
+GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, "
+ "mpegtype:int=1, " "foo1:int=30, " "foo2:int=[20,30], " "foo3:int=[20,30]");
-int
-main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
xmlDocPtr doc;
xmlNodePtr parent;
parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL);
gst_caps_save_thyself (caps, parent);
- xmlDocDump(stdout, doc);
+ xmlDocDump (stdout, doc);
return 0;
}
#include <gst/gst.h>
#include <glib.h>
-void test1(void)
+void
+test1 (void)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
//GValue value3 = { 0 };
//gboolean ret;
- g_value_init(&value1, G_TYPE_INT);
- g_value_set_int(&value1, 10);
- g_value_init(&value2, G_TYPE_INT);
- g_value_set_int(&value2, 20);
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_INT);
+ g_value_set_int (&value1, 10);
+ g_value_init (&value2, G_TYPE_INT);
+ g_value_set_int (&value2, 20);
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, G_TYPE_DOUBLE);
- g_value_set_double(&value1, 10);
- g_value_init(&value2, G_TYPE_DOUBLE);
- g_value_set_double(&value2, 20);
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_DOUBLE);
+ g_value_set_double (&value1, 10);
+ g_value_init (&value2, G_TYPE_DOUBLE);
+ g_value_set_double (&value2, 20);
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, G_TYPE_STRING);
- g_value_set_string(&value1, "a");
- g_value_init(&value2, G_TYPE_STRING);
- g_value_set_string(&value2, "b");
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN);
- g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, G_TYPE_STRING);
+ g_value_set_string (&value1, "a");
+ g_value_init (&value2, G_TYPE_STRING);
+ g_value_set_string (&value2, "b");
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
+ g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
- g_value_init(&value1, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&value1, GST_MAKE_FOURCC('a','b','c','d'));
- g_value_init(&value2, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&value2, GST_MAKE_FOURCC('1','2','3','4'));
- g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_UNORDERED);
- g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL);
- g_value_unset(&value1);
- g_value_unset(&value2);
+ g_value_init (&value1, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&value1, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'));
+ g_value_init (&value2, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&value2, GST_MAKE_FOURCC ('1', '2', '3', '4'));
+ g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED);
+ g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
+ g_value_unset (&value1);
+ g_value_unset (&value2);
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
+ test1 ();
return 0;
}
-
-
#include <gst/gst.h>
-void test1(void)
+void
+test1 (void)
{
GValue dest = { 0 };
GValue src1 = { 0 };
GValue src2 = { 0 };
gboolean ret;
- g_value_init(&src1, G_TYPE_INT);
- g_value_set_int(&src1, 10);
- g_value_init(&src2, G_TYPE_INT);
- g_value_set_int(&src1, 20);
- ret = gst_value_intersect(&dest, &src1, &src2);
- g_assert(ret == 0);
- g_print("ret = %d\n",ret);
+ g_value_init (&src1, G_TYPE_INT);
+ g_value_set_int (&src1, 10);
+ g_value_init (&src2, G_TYPE_INT);
+ g_value_set_int (&src1, 20);
+ ret = gst_value_intersect (&dest, &src1, &src2);
+ g_assert (ret == 0);
+ g_print ("ret = %d\n", ret);
}
-void test2(void)
+void
+test2 (void)
{
GValue dest = { 0 };
GValue src1 = { 0 };
GValue item = { 0 };
gboolean ret;
- g_value_init(&src1, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&src1, GST_MAKE_FOURCC('Y','U','Y','2'));
- g_value_init(&src2, GST_TYPE_LIST);
- g_value_init(&item, GST_TYPE_FOURCC);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('Y','U','Y','2'));
+ g_value_init (&src1, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&src1, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
+ g_value_init (&src2, GST_TYPE_LIST);
+ g_value_init (&item, GST_TYPE_FOURCC);
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'));
gst_value_list_append_value (&src2, &item);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('I','4','2','0'));
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('I', '4', '2', '0'));
gst_value_list_append_value (&src2, &item);
- gst_value_set_fourcc(&item, GST_MAKE_FOURCC('A','B','C','D'));
+ gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('A', 'B', 'C', 'D'));
gst_value_list_append_value (&src2, &item);
- ret = gst_value_intersect(&dest, &src1, &src2);
- g_print("ret = %d\n",ret);
+ ret = gst_value_intersect (&dest, &src1, &src2);
+ g_print ("ret = %d\n", ret);
- g_print("type = %s\n", g_type_name(G_VALUE_TYPE(&dest)));
- g_print("value = %s\n", g_strdup_value_contents(&dest));
+ g_print ("type = %s\n", g_type_name (G_VALUE_TYPE (&dest)));
+ g_print ("value = %s\n", g_strdup_value_contents (&dest));
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
- gst_init(&argc, &argv);
+ gst_init (&argc, &argv);
- test1();
- test2();
+ test1 ();
+ test2 ();
return 0;
}
-
-
GstElement *fakesrc, *fakesink;
GstElement *pipeline;
-
+
pipeline = gst_pipeline_new ("main_pipeline");
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 1000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
bin = gst_bin_new ("bin");
fakesink = gst_element_factory_make ("fakesink", "fakesink");
gst_bin_add (GST_BIN (bin), fakesink);
- gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), "sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"),
+ "sink");
gst_element_link (fakesrc, bin);
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 1000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
queue = gst_element_factory_make ("queue", "queue");
gst_bin_add (GST_BIN (thread), fakesink);
gst_bin_add (GST_BIN (thread), queue);
- gst_element_link (queue, fakesink);
- gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), "sink");
+ gst_element_link (queue, fakesink);
+ gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"),
+ "sink");
gst_element_link (fakesrc, thread);
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
gint i = 10000;
gint step = 100;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
if (i % step == 0)
fprintf (stderr, "%10d\r", i);
pipeline = create_pipeline ();
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc;
gint i;
- free (malloc(8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
gst_bin_add (GST_BIN (bin), fakesink);
gst_bin_add (GST_BIN (pipeline), bin);
-
+
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
#include <gst/gst.h>
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GstElement *bin, *element;
gint i = 1000;
gint step = 100;
-
- free (malloc(8)); /* -lefence */
+
+ free (malloc (8)); /* -lefence */
gst_init (&argc, &argv);
bin = gst_pipeline_new ("pipeline");
- while (i--)
- {
+ while (i--) {
GstPad *pad;
if (i % step == 0)
fprintf (stderr, "\r%10d", i);
element = gst_element_factory_make ("tee", "tee");
- if (!element)
+ if (!element)
break;
pad = gst_element_get_request_pad (element, "src%d");
#include <gst/gst.h>
void
-gst_clock_debug (GstClock *clock)
+gst_clock_debug (GstClock * clock)
{
- g_print ("Clock info: time %"G_GUINT64_FORMAT"\n",
- gst_clock_get_time (clock));
+ g_print ("Clock info: time %" G_GUINT64_FORMAT "\n",
+ gst_clock_get_time (clock));
}
-
+
int
main (int argc, char *argv[])
{
gst_init (&argc, &argv);
- if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL)
- {
+ if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) {
g_print ("Could not create a fakesrc element !\n");
return 1;
}
- if ((id = gst_element_factory_make ("identity", "filter")) == NULL)
- {
+ if ((id = gst_element_factory_make ("identity", "filter")) == NULL) {
g_print ("Could not create a identity element !\n");
return 1;
}
- if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL)
- {
+ if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) {
g_print ("Could not create a fakesink element !\n");
return 1;
}
- if ((pipeline = gst_pipeline_new ("pipeline")) == NULL)
- {
+ if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) {
g_print ("Could not create a pipeline element !\n");
return 1;
}
#include <gst/gst.h>
void
-gst_clock_debug (GstClock *clock, GstElement *fakesink)
+gst_clock_debug (GstClock * clock, GstElement * fakesink)
{
- g_print ("Clock info: time %"G_GUINT64_FORMAT" - Element info: time %"G_GUINT64_FORMAT"\n",
- gst_clock_get_time (clock), gst_element_get_time (fakesink));
+ g_print ("Clock info: time %" G_GUINT64_FORMAT " - Element info: time %"
+ G_GUINT64_FORMAT "\n", gst_clock_get_time (clock),
+ gst_element_get_time (fakesink));
}
-
+
int
main (int argc, char *argv[])
{
gst_bin_add_many (GST_BIN (pipeline), fakesink, fakesrc, NULL);
gst_element_link (fakesrc, fakesink);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
gst_clock_debug (clock, fakesink);
g_usleep (G_USEC_PER_SEC);
gst_clock_debug (clock, fakesink);
gst_element_wait (fakesink, 2 * GST_SECOND);
gst_clock_debug (clock, fakesink);
-
+
gst_element_wait (fakesink, 5 * GST_SECOND);
gst_clock_debug (clock, fakesink);
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
#define GST_CAT_DEFAULT cat
GST_DEBUG_CATEGORY_STATIC (cat_static);
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GSList *before, *after;
unsetenv ("GST_DEBUG");
gst_init (&argc, &argv);
-
+
before = gst_debug_get_all_categories ();
- GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, "default category for this test");
- GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
- GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
- "static category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN,
+ "default category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static",
+ GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED,
+ "static category for this test");
after = gst_debug_get_all_categories ();
g_print ("removing default log function\n");
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
- g_print ("checking, if the two new categories are put into the category list correctly...\n");
+ g_print
+ ("checking, if the two new categories are put into the category list correctly...\n");
g_assert (g_slist_length (after) - g_slist_length (before) == 2);
/* check the _get stuff */
- g_print ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
+ g_print
+ ("checking, if the gst_debug_category_get_* stuff works with the categories...\n");
g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0);
g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN);
- g_assert (strcmp (gst_debug_category_get_description (cat), "default category for this test") == 0);
- g_assert (gst_debug_category_get_threshold (cat) == gst_debug_get_default_threshold());
- g_assert (strcmp (gst_debug_category_get_name (cat_static), "cat_static") == 0);
+ g_assert (strcmp (gst_debug_category_get_description (cat),
+ "default category for this test") == 0);
+ g_assert (gst_debug_category_get_threshold (cat) ==
+ gst_debug_get_default_threshold ());
+ g_assert (strcmp (gst_debug_category_get_name (cat_static),
+ "cat_static") == 0);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED);
g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD);
- g_assert (strcmp (gst_debug_category_get_description (cat_static), "static category for this test") == 0);
- g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold());
+ g_assert (strcmp (gst_debug_category_get_description (cat_static),
+ "static category for this test") == 0);
+ g_assert (gst_debug_category_get_threshold (cat_static) ==
+ gst_debug_get_default_threshold ());
/* check if setting levels for names work */
- g_print ("checking if changing threshold for names affects existing categories...\n");
+ g_print
+ ("checking if changing threshold for names affects existing categories...\n");
gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG);
- g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
- g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold());
+ g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
+ g_assert (gst_debug_category_get_threshold (cat_static) ==
+ gst_debug_get_default_threshold ());
gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO);
g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG);
g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO);
-
+
g_print ("everything ok.\n");
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
GST_DEBUG_CATEGORY (cat);
GST_DEBUG_CATEGORY_STATIC (cat_static);
-static const gchar* lines[] = {
+static const gchar *lines[] = {
"--gst-debug-disable",
"--gst-debug-no-color",
"--gst-debug-level=4",
"--gst-debug=cat:4,cat_*:3",
- "--gst-debug-level=4 --gst-debug=cat_*:5"
+ "--gst-debug-level=4 --gst-debug=cat_*:5"
};
static void
-debug_not_reached (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, GstDebugMessage *message,
- gpointer thread)
+debug_not_reached (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ GstDebugMessage * message, gpointer thread)
{
g_assert_not_reached ();
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
if (argc == 1) {
/* this is the main run that calls the others */
gint i, runs, exit;
gchar *command;
-
+
unsetenv ("GST_DEBUG");
gst_init (&argc, &argv);
runs = G_N_ELEMENTS (lines);
for (i = 0; i < runs; i++) {
command = g_strdup_printf ("%s %s %d", argv[0], lines[i], i);
g_print ("running \"%s\"\n", command);
- g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, NULL) == TRUE);
+ g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit,
+ NULL) == TRUE);
g_assert (exit == 0);
g_print ("\"%s\" worked as expected.\n", command);
g_free (command);
}
-
+
return 0;
} else {
gst_init (&argc, &argv);
if (argc != 2) {
- g_print ("something funny happened to the command line arguments, aborting.\n");
+ g_print
+ ("something funny happened to the command line arguments, aborting.\n");
return 1;
}
gst_debug_remove_log_function (gst_debug_log_default);
GST_ERROR ("This will not be seen");
return 0;
case '1':
- return gst_debug_is_colored () ? 1 : 0;
+ return gst_debug_is_colored ()? 1 : 0;
case '2':
g_assert (gst_debug_get_default_threshold () == 4);
g_assert (gst_debug_category_get_threshold (cat) == 4);
return -1;
}
}
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define ITERATIONS 20
/* stupid logging functions */
-static void gst_debug_log_one (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- gchar * message,
- gpointer thread) G_GNUC_NO_INSTRUMENT;
-static void gst_debug_log_two (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- gchar * message,
- gpointer thread) G_GNUC_NO_INSTRUMENT;
-
static void
-gst_debug_log_one (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, gchar *message,
- gpointer thread)
+gst_debug_log_one (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line, GObject * object, gchar * message, gpointer thread)
+ G_GNUC_NO_INSTRUMENT;
+ static void gst_debug_log_two (GstDebugCategory * category,
+ GstDebugLevel level,
+ const gchar * file,
+ const gchar * function,
+ gint line,
+ GObject * object, gchar * message, gpointer thread) G_GNUC_NO_INSTRUMENT;
+
+ static void
+ gst_debug_log_one (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ gchar * message, gpointer thread)
{
}
static void
-gst_debug_log_two (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, gchar *message,
- gpointer thread)
+gst_debug_log_two (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ gchar * message, gpointer thread)
{
}
g_print ("iteration %d of thread %d starting\n", i, num);
/* do some stuff with global settings */
gst_debug_set_default_threshold (GST_LEVEL_DEBUG);
- gst_debug_add_log_function (gst_debug_log_one, g_thread_self());
+ gst_debug_add_log_function (gst_debug_log_one, g_thread_self ());
gst_debug_add_log_function (gst_debug_log_two, NULL);
/* reset all the stuff we did */
gst_debug_set_default_threshold (GST_LEVEL_DEFAULT);
- g_assert (gst_debug_remove_log_function_by_data (g_thread_self()) == 1);
+ g_assert (gst_debug_remove_log_function_by_data (g_thread_self ()) == 1);
}
-
+
g_print ("Thread %d is done.\n", num);
return threadnum;
}
-gint
-main (gint argc, gchar *argv[])
+
+gint
+main (gint argc, gchar * argv[])
{
gint i;
GThread *threads[THREAD_COUNT];
-
+
g_print ("initializing GStreamer\n");
gst_init (&argc, &argv);
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
/* some checks for defaults */
g_print ("Doing startup checks\n");
g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT);
-
+
g_print ("creating %d threads\n", THREAD_COUNT);
for (i = 0; i < THREAD_COUNT; i++) {
- g_assert ((threads[i] = g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL)));
+ g_assert ((threads[i] =
+ g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL)));
}
g_print ("joining %d threads\n", THREAD_COUNT);
for (i = 0; i < THREAD_COUNT; i++) {
/* some checks if everything worked */
g_print ("Doing shutdown checks\n");
g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT);
- g_assert (gst_debug_remove_log_function (gst_debug_log_two) == THREAD_COUNT * ITERATIONS);
-
+ g_assert (gst_debug_remove_log_function (gst_debug_log_two) ==
+ THREAD_COUNT * ITERATIONS);
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
GST_DEBUG_CATEGORY_STATIC (cat_default);
static GstElement *pipeline;
static void
-check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *file,
- const gchar *function, gint line, GObject *object, GstDebugMessage *message,
- gpointer unused)
+check_message (GstDebugCategory * category, GstDebugLevel level,
+ const gchar * file, const gchar * function, gint line, GObject * object,
+ GstDebugMessage * message, gpointer unused)
{
gint temp;
-
+
/* these checks require count to be set right. So the order in the main
funtion is actually important. */
/* <0 means no checks */
- if (count < 0) return;
-
+ if (count < 0)
+ return;
+
g_print ("expecting \"%s\"...", (gchar *) message);
/* level */
temp = (count % 5) + 1;
g_print ("[OK]\n");
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
-
- GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, "default category for this test");
- GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, "second category for this test");
+
+ GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0,
+ "default category for this test");
+ GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0,
+ "second category for this test");
g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1);
- gst_debug_add_log_function (check_message, NULL);
-
+ gst_debug_add_log_function (check_message, NULL);
+
count = 0;
GST_ERROR ("This is an error.");
++count;
++count;
GST_LOG_OBJECT (pipeline, "This is a log message with object.");
++count;
- GST_CAT_ERROR_OBJECT (cat2, pipeline, "This is an error with category and object.");
+ GST_CAT_ERROR_OBJECT (cat2, pipeline,
+ "This is an error with category and object.");
++count;
- GST_CAT_WARNING_OBJECT (cat2, pipeline, "This is a warning with category and object.");
+ GST_CAT_WARNING_OBJECT (cat2, pipeline,
+ "This is a warning with category and object.");
++count;
- GST_CAT_INFO_OBJECT (cat2, pipeline, "This is an info message with category and object.");
+ GST_CAT_INFO_OBJECT (cat2, pipeline,
+ "This is an info message with category and object.");
++count;
- GST_CAT_DEBUG_OBJECT (cat2, pipeline, "This is a debug message with category and object.");
+ GST_CAT_DEBUG_OBJECT (cat2, pipeline,
+ "This is a debug message with category and object.");
++count;
- GST_CAT_LOG_OBJECT (cat2, pipeline, "This is a log message with category and object.");
+ GST_CAT_LOG_OBJECT (cat2, pipeline,
+ "This is a log message with category and object.");
count = -1;
- g_assert (gst_debug_remove_log_function (check_message) == 1);
-
+ g_assert (gst_debug_remove_log_function (check_message) == 1);
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstCaps *caps;
GstElement *element;
int zero = 0;
gst_init (&argc, &argv);
-
+
caps = gst_caps_from_string ("audio/x-raw-int, rate=44100");
element = gst_element_factory_make ("identity", NULL);
GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL);
GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero);
//GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1);
-
+
return 0;
}
GstPad *sinkpad;
GstPad *srcpad;
GstDParamManager *dpman;
-
+
gfloat float1;
gfloat float2;
gboolean bool1;
};
-static void gst_dptest_base_init (gpointer g_class);
-static void gst_dptest_class_init (GstDpTestClass * klass);
-static void gst_dptest_init (GstDpTest * dptest);
+static void gst_dptest_base_init (gpointer g_class);
+static void gst_dptest_class_init (GstDpTestClass * klass);
+static void gst_dptest_init (GstDpTest * dptest);
-static void gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value,
- GParamSpec * pspec);
+static void gst_dptest_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_dptest_change_state (GstElement *element);
-static void gst_dptest_chain (GstPad *pad, GstData *buf);
+static GstElementStateReturn gst_dptest_change_state (GstElement * element);
+static void gst_dptest_chain (GstPad * pad, GstData * buf);
static GstElementClass *parent_class = NULL;
(GInstanceInitFunc) gst_dptest_init,
};
- dptest_type = g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0);
+ dptest_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0);
}
return dptest_type;
}
static void
gst_dptest_base_init (gpointer g_class)
{
- static GstElementDetails dptest_details = GST_ELEMENT_DETAILS (
- "DParamTest",
- "Filter",
- "Test for the GstDParam code",
- "Steve Baker <stevebaker_org@yahoo.co.uk>"
- );
+ static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ("DParamTest",
+ "Filter",
+ "Test for the GstDParam code",
+ "Steve Baker <stevebaker_org@yahoo.co.uk>");
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &dptest_details);
- g_print("got here %d\n",__LINE__);
+ g_print ("got here %d\n", __LINE__);
}
static void
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad);
- gst_pad_set_chain_function(dptest->sinkpad, gst_dptest_chain);
+ gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain);
dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad);
- dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT(dptest));
+ dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest));
+
+ gst_dpman_add_required_dparam_direct (dptest->dpman,
+ g_param_spec_float ("float1", "float1", "float1",
+ 0.0, 1.0, 0.5, G_PARAM_READWRITE), "float", &(dptest->float1)
+ );
- gst_dpman_add_required_dparam_direct (
- dptest->dpman,
- g_param_spec_float("float1","float1","float1",
- 0.0, 1.0, 0.5, G_PARAM_READWRITE),
- "float",
- &(dptest->float1)
- );
-
dptest->float1 = 0.0;
}
static void
-gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstDpTest *dptest;
}
static GstElementStateReturn
-gst_dptest_change_state (GstElement *element)
+gst_dptest_change_state (GstElement * element)
{
GstDpTest *dptest;
g_return_val_if_fail (GST_IS_DPTEST (element), GST_STATE_FAILURE);
- g_print("changing state\n");
+ g_print ("changing state\n");
dptest = GST_DPTEST (element);
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
-static void
-gst_dptest_chain (GstPad *pad, GstData *data)
+static void
+gst_dptest_chain (GstPad * pad, GstData * data)
{
GstDpTest *dptest;
gint frame_countdown;
- dptest = GST_DPTEST(gst_pad_get_parent (pad));
- g_assert(dptest);
+ dptest = GST_DPTEST (gst_pad_get_parent (pad));
+ g_assert (dptest);
/* we're using a made up buffer size of 64 and a timestamp of zero */
- frame_countdown = GST_DPMAN_PREPROCESS(dptest->dpman, 64, 0LL);
-
- while(GST_DPMAN_PROCESS(dptest->dpman, frame_countdown));
-
- g_print("dp chain\n");
+ frame_countdown = GST_DPMAN_PREPROCESS (dptest->dpman, 64, 0LL);
+
+ while (GST_DPMAN_PROCESS (dptest->dpman, frame_countdown));
+
+ g_print ("dp chain\n");
}
gboolean
-gst_dptest_register_elements (GstPlugin *plugin)
+gst_dptest_register_elements (GstPlugin * plugin)
{
return gst_element_register (plugin, "dptest", GST_RANK_NONE,
GST_TYPE_DPTEST);
GST_ORIGIN
};
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *src;
GstElement *sink;
GstDParamManager *dpman;
GstDParam *dp_float1;
GValue *dp_float1_value;
-
- alarm(10);
+
+ alarm (10);
gst_init (&argc, &argv);
- gst_control_init(&argc,&argv);
+ gst_control_init (&argc, &argv);
_gst_plugin_register_static (&plugin_desc);
gst_bin_add (GST_BIN (pipeline), testelement);
gst_bin_add (GST_BIN (pipeline), sink);
- g_print("playing pipeline\n");
-
- g_object_set (G_OBJECT (src), "num_buffers", 1, NULL);
+ g_print ("playing pipeline\n");
+
+ g_object_set (G_OBJECT (src), "num_buffers", 1, NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
/* test that dparam manager is accessable */
- g_print("getting dparam manager\n");
+ g_print ("getting dparam manager\n");
dpman = gst_dpman_get_manager (testelement);
- gst_dpman_set_mode(dpman, "synchronous");
-
- g_assert(dpman);
- g_assert(GST_IS_DPMAN (dpman));
-
- g_print("creating dparam for float1\n");
- dp_float1 = gst_dparam_new(G_TYPE_FLOAT);;
- g_assert(dp_float1);
- g_assert(GST_IS_DPARAM (dp_float1));
-
- g_print("attach dparam to float1\n");
- g_assert(gst_dpman_attach_dparam (dpman, "float1", dp_float1));
-
- dp_float1_value = g_new0(GValue,1);
- g_value_init(dp_float1_value, G_TYPE_FLOAT);
-
- g_value_set_float(dp_float1_value, 0.1);
- g_object_set_property(G_OBJECT(dp_float1), "value_float", dp_float1_value);
-
- g_print("iterate once\n");
+ gst_dpman_set_mode (dpman, "synchronous");
+
+ g_assert (dpman);
+ g_assert (GST_IS_DPMAN (dpman));
+
+ g_print ("creating dparam for float1\n");
+ dp_float1 = gst_dparam_new (G_TYPE_FLOAT);;
+ g_assert (dp_float1);
+ g_assert (GST_IS_DPARAM (dp_float1));
+
+ g_print ("attach dparam to float1\n");
+ g_assert (gst_dpman_attach_dparam (dpman, "float1", dp_float1));
+
+ dp_float1_value = g_new0 (GValue, 1);
+ g_value_init (dp_float1_value, G_TYPE_FLOAT);
+
+ g_value_set_float (dp_float1_value, 0.1);
+ g_object_set_property (G_OBJECT (dp_float1), "value_float", dp_float1_value);
+
+ g_print ("iterate once\n");
gst_bin_iterate (GST_BIN (pipeline));
- g_print("check that value changed\n");
- g_assert(GST_DPTEST(testelement)->float1 == 0.1F);
- g_assert(!GST_DPARAM_READY_FOR_UPDATE(dp_float1));
-
- g_print("nulling pipeline\n");
+ g_print ("check that value changed\n");
+ g_assert (GST_DPTEST (testelement)->float1 == 0.1F);
+ g_assert (!GST_DPARAM_READY_FOR_UPDATE (dp_float1));
+
+ g_print ("nulling pipeline\n");
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
- g_print("playing pipeline\n");
+ g_print ("playing pipeline\n");
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
- g_print("iterate twice\n");
+ g_print ("iterate twice\n");
g_object_set (G_OBJECT (src), "num_buffers", 2, NULL);
gst_bin_iterate (GST_BIN (pipeline));
-
+
return 0;
}
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
pipeline = gst_pipeline_new ("pipeline");
g_print ("Connecting signals to pipeline\n");
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL);
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (property_change_callback), NULL);
g_print ("Creating elements\n");
- 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 (!(sink = element_create ("sink", "fakesink"))) return 1;
-
+ if (!(sink = element_create ("sink", "fakesink")))
+ return 1;
+
/* add */
g_print ("Adding elements to bin\n");
gst_bin_add (GST_BIN (pipeline), src);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* we expect this to give an error */
- if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE)
- {
- g_warning ("Iterating a bin with unlinked elements should return FALSE !\n");
+ if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) {
+ g_warning
+ ("Iterating a bin with unlinked elements should return FALSE !\n");
retval = 1;
}
gst_pad_link (gst_element_get_pad (src, "src"),
- gst_element_get_pad (sink, "sink"));
+ gst_element_get_pad (sink, "sink"));
/* set to play */
g_print ("Doing 1 iteration\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* we expect this to work */
- if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE)
- {
+ if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) {
g_error ("Iterating a bin with linked elements should return TRUE !\n");
retval = 1;
}
g_print ("Done !\n");
return retval;
}
-
/* init */
gst_init (&argc, &argv);
- for (i = 0; i < 50; ++i)
- {
+ for (i = 0; i < 50; ++i) {
/* create element */
element = gst_element_factory_make ("identity", NULL);
g_assert (GST_IS_ELEMENT (element));
g_assert (gst_element_get_name (element) != NULL);
- g_print ("Created identity element with name %s\n",
- gst_element_get_name (element));
+ g_print ("Created identity element with name %s\n",
+ gst_element_get_name (element));
}
g_print ("Done !\n");
return 0;
}
-
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
/* create */
g_print ("Creating element\n");
- if (!(src = element_create ("src", "fakesrc"))) return 1;
-
+ if (!(src = element_create ("src", "fakesrc")))
+ return 1;
+
/* set */
silent_set = TRUE;
sizemin_set = 1;
name_set = g_strdup_printf ("test");
- gst_element_set (src,
- "name", name_set,
- "sizemin", sizemin_set,
- "silent", silent_set,
- NULL);
+ gst_element_set (src,
+ "name", name_set, "sizemin", sizemin_set, "silent", silent_set, NULL);
/* get */
gst_element_get (src,
- "name", &name_get,
- "sizemin", &sizemin_get,
- "silent", &silent_get,
- NULL);
+ "name", &name_get, "sizemin", &sizemin_get, "silent", &silent_get, NULL);
/* compare */
- if (sizemin_set != sizemin_get)
- {
+ if (sizemin_set != sizemin_get) {
g_print ("sizemin: set value %d differs from returned value %d\n",
- sizemin_set, sizemin_get);
+ sizemin_set, sizemin_get);
retval = 1;
- }
- else
+ } else
g_print ("name: set right\n");
- if (silent_set != silent_get)
- {
+ if (silent_set != silent_get) {
g_print ("silent: set value %s differs from returned value %s\n",
- silent_set ? "TRUE" : "FALSE",
- silent_get ? "TRUE" : "FALSE");
+ silent_set ? "TRUE" : "FALSE", silent_get ? "TRUE" : "FALSE");
retval = 1;
- }
- else
+ } else
g_print ("silent: set right\n");
-
- if (strcmp (name_set, name_get) != 0)
- {
+
+ if (strcmp (name_set, name_get) != 0) {
g_print ("name: set value %s differs from returned value %s\n",
- name_set, name_get);
+ name_set, name_get);
retval = 1;
- }
- else
+ } else
g_print ("name: set right\n");
return retval;
}
-
/* extracted from gst-launch */
static void
-property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
+property_change_callback (GObject * object, GstObject * orig,
+ GParamSpec * pspec)
{
- GValue value = { 0, }; /* the important thing is that value.type = 0 */
+ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0;
if (pspec->flags & G_PARAM_READABLE) {
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (G_OBJECT (orig), pspec->name, &value);
/* fix current bug with g_strdup_value_contents not working with gint64 */
if (G_IS_PARAM_SPEC_INT64 (pspec))
str = g_strdup_value_contents (&value);
g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
g_free (str);
- g_value_unset(&value);
+ g_value_unset (&value);
} else {
g_warning ("Parameter not readable. What's up with that?");
}
}
-
GstElement *el = NULL;
el = (GstElement *) gst_element_factory_make (element, name);
- if (el == NULL)
- {
+ if (el == NULL) {
fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
return NULL;
- }
- else
+ } else
return el;
}
GstElement *pipeline = NULL;
GstElement *tee, *src, *sink1, *sink2;
GstPad *tee_src1, *tee_src2;
+
#if 0
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
pipeline = gst_pipeline_new ("pipeline");
g_print ("Connecting signals to pipeline\n");
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL);
-
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (property_change_callback), NULL);
+
g_print ("Creating elements\n");
- if (!(tee = element_create ("tee", "tee"))) return 1;
- if (!(src = element_create ("src", "fakesrc"))) return 1;
+ if (!(tee = element_create ("tee", "tee")))
+ 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 (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
-
+ if (!(sink1 = element_create ("sink1", "fakesink")))
+ return 1;
+ if (!(sink2 = element_create ("sink2", "fakesink")))
+ return 1;
+
/* add */
g_print ("Adding elements to bin\n");
gst_bin_add (GST_BIN (pipeline), src);
/* link input part */
g_print ("Linking input elements\n");
gst_pad_link (gst_element_get_pad (src, "src"),
- gst_element_get_pad (tee, "sink"));
-
+ gst_element_get_pad (tee, "sink"));
+
/* request one pad from tee */
g_print ("Requesting first pad\n");
tee_src1 = gst_element_get_request_pad (tee, "src%d");
tee_src2 = gst_element_get_request_pad (tee, "src%d");
gst_bin_add (GST_BIN (pipeline), sink2);
gst_pad_link (tee_src2, gst_element_get_pad (sink2, "sink"));
-
+
/* now we have two fakesinks linked, iterate */
g_print ("Doing 1 iteration\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink1, "sink"));
if (sink_caps && gst_caps_is_fixed (sink_caps)) {
structure = gst_caps_get_structure (sink_caps, 0);
- }else {
+ } else {
structure = NULL;
g_print ("sink_caps is not fixed\n");
}
if (structure == NULL || !(gst_structure_has_field (structure, "rate"))) {
- g_print ("Hm, rate has not been propagated to sink1.\n");
+ g_print ("Hm, rate has not been propagated to sink1.\n");
return 1;
} else {
int rate;
+
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink1 : %d\n", rate);
}
sink_caps = gst_pad_get_caps (gst_element_get_pad (sink2, "sink"));
structure = gst_caps_get_structure (sink_caps, 0);
- if (structure != NULL && ! (gst_structure_has_field (structure, "rate"))) {
- g_print ("Hm, rate has not been propagated to sink2.\n");
+ if (structure != NULL && !(gst_structure_has_field (structure, "rate"))) {
+ g_print ("Hm, rate has not been propagated to sink2.\n");
return 1;
} else {
int rate;
+
gst_structure_get_int (structure, "rate", &rate);
g_print ("Rate of pad on sink2 : %d\n", rate);
}
#endif
-
+
/* remove the first one, iterate */
g_print ("Removing first sink\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
/* in 0.3.2 the next statement gives an assert error */
tee_src1 = gst_element_get_request_pad (tee, "src%d");
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Done !\n");
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline, *bin;
GstElement *fakesrc, *fakesink, *identity;
- GstPad *sink, *src, *real = (GstPad*)0xdeadbeef;
+ GstPad *sink, *src, *real = (GstPad *) 0xdeadbeef;
gst_init (&argc, &argv);
fakesrc = gst_element_factory_make ("fakesrc", NULL);
fakesink = gst_element_factory_make ("fakesink", NULL);
identity = gst_element_factory_make ("identity", NULL);
-
+
gst_bin_add_many (GST_BIN (pipeline), fakesrc, bin, fakesink, NULL);
gst_bin_add (GST_BIN (bin), identity);
-
+
sink = gst_element_add_ghost_pad (bin,
- gst_element_get_pad (identity, "sink"),
- "sink");
+ gst_element_get_pad (identity, "sink"), "sink");
src = gst_element_add_ghost_pad (bin,
- gst_element_get_pad (identity, "src"),
- "src");
+ gst_element_get_pad (identity, "src"), "src");
gst_element_link_many (fakesrc, bin, fakesink, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-
+
if (!gst_bin_iterate (GST_BIN (pipeline)))
g_assert_not_reached ();
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
/* test the cleanup */
gst_object_ref (GST_OBJECT (sink));
- gst_object_unref ((GstObject*)pipeline);
+ gst_object_unref ((GstObject *) pipeline);
g_object_get (sink, "real-pad", &real, NULL);
g_assert (real == NULL);
g_assert (G_OBJECT (sink)->ref_count == 1);
gst_object_unref (GST_OBJECT (sink));
-
+
return 0;
}
#include <gst/gst.h>
static void
-lookup (GstIndex *index, GstIndexLookupMethod method,
- GstFormat src_format, gint64 src_value,
- GstFormat dest_format, gint64 expecting)
+lookup (GstIndex * index, GstIndexLookupMethod method,
+ GstFormat src_format, gint64 src_value,
+ GstFormat dest_format, gint64 expecting)
{
GstIndexEntry *entry;
gint64 result;
entry = gst_index_get_assoc_entry (index, 0, method, 0,
- src_format, src_value);
+ src_format, src_value);
if (entry) {
- gst_index_entry_assoc_map (entry, dest_format, &result);
+ gst_index_entry_assoc_map (entry, dest_format, &result);
if (result == expecting) {
g_print ("OK (%lld)\n", result);
} else {
g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
}
- }
- else {
+ } else {
const GstFormatDefinition *def = gst_format_get_details (src_format);
-
- if (expecting == -1)
+
+ if (expecting == -1)
g_print ("OK (not found)\n");
else
g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n",
- src_value, def->nick, expecting);
+ src_value, def->nick, expecting);
}
}
typedef struct _GstIndexTestCase
{
- GstIndexLookupMethod method;
- GstFormat src_format;
- gint64 src_value;
- GstFormat dest_format;
- gint64 expecting;
+ GstIndexLookupMethod method;
+ GstFormat src_format;
+ gint64 src_value;
+ GstFormat dest_format;
+ gint64 expecting;
} GstIndexTestCase;
-const static GstIndexTestCase cases[] =
-{
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
+const static GstIndexTestCase cases[] = {
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES,
+ 99999},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
};
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstElement *element;
gint i, id;
-
+
gst_init (&argc, &argv);
- if (argc != 2)
- { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
+ if (argc != 2) {
+ g_print ("usage: cache1 (memindex | fileindex)\n");
+ exit (0);
+ }
index = gst_index_factory_make (argv[1]);
g_assert (index != NULL);
g_print ("Building index...\n");
for (i = 0; i < 100000; i++) {
- gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
- (gint64) (i * 1000), 0);
+ gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64) i,
+ GST_FORMAT_TIME, (gint64) (i * 1000), 0);
}
g_print ("Testing index...\n");
for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) {
- lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting);
+ lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value,
+ cases[i].dest_format, cases[i].expecting);
}
-
+
return 0;
}
#include <gst/gst.h>
static void
-my_resolver (GstIndex *index, GstObject *_ign, gchar **writer_string,
- gpointer user_data)
-{ *writer_string = user_data; }
+my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string,
+ gpointer user_data)
+{
+ *writer_string = user_data;
+}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstObject *identity;
gint id;
gint64 cur;
-
+
gst_init (&argc, &argv);
if (argc != 3) {
g_object_set (index, "location", argv[1], NULL);
gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]);
- identity = (GstObject*) gst_element_factory_make ("identity", "element");
+ identity = (GstObject *) gst_element_factory_make ("identity", "element");
g_assert (identity);
gst_index_get_writer_id (index, identity, &id);
-
+
cur = 0;
while (1) {
gint fx;
GstIndexEntry *entry =
- gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
- GST_FORMAT_TIME, cur);
+ gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
+ GST_FORMAT_TIME, cur);
+
if (!entry)
break;
g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry));
- for (fx=0; fx < GST_INDEX_NASSOCS (entry); fx++) {
+ for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) {
GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx);
- const GstFormatDefinition* def = gst_format_get_details (fmt);
+ const GstFormatDefinition *def = gst_format_get_details (fmt);
+
if (fmt == GST_FORMAT_TIME) {
cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1;
g_print (" time %.4f",
- GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
- }
- else
+ GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
+ } else
g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx));
}
g_print ("\n");
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
gst_object_unref (GST_OBJECT (cur)); \
cur = NULL; \
g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
-}G_STMT_END
+}G_STMT_END
#define TEST_RUN G_STMT_START{ \
alarm(10); \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
} \
g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
alarm(0); \
-}G_STMT_END
+}G_STMT_END
#define PIPELINE1 "fakesrc"
#define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = yesyo data= Subbuffer\\ data"
#define PIPELINE3 "fakesrc identity fakesink"
#define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
* - first test of escaping strings
*/
TEST_START (PIPELINE2);
- g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL);
+ g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b,
+ NULL);
TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
TEST_CHECK_FAIL (i == 27);
TEST_CHECK_FAIL (b == TRUE);
* - if multiple toplevel elements exist, a pipeline is returned
*/
TEST_START (PIPELINE3);
- TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
+ TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
TEST_OK;
TEST_CHECK_FAIL (strcmp (s, "john") == 0);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - test request pads
TEST_START (PIPELINE7);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - multiple pads on 1 link
TEST_START (PIPELINE8);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.17
TEST_START (PIPELINE9);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.17
TEST_START (PIPELINE10);
TEST_RUN;
TEST_OK;
-
+
/**
* checks:
* - failed in grammar.y cvs version 1.18
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
gst_object_unref (GST_OBJECT (cur)); \
cur = NULL; \
g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
-}G_STMT_END
+}G_STMT_END
#define TEST_RUN(iters) G_STMT_START{ \
gint it = iters; \
g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
return -test; \
} \
g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
-}G_STMT_END
+}G_STMT_END
#define TEST_FINISH G_STMT_START{ \
g_print("\n"); \
g_print("To run this test there are things required that you do not have. (see above)\n"); \
g_print("Currently the following tests will be ignored.\n"); \
g_print("\n"); \
exit (0); \
-}G_STMT_END
+}G_STMT_END
#define TEST_REQUIRE(condition, error) G_STMT_START{ \
if (condition) { \
g_print ("REQUIRE line %3d OK\n", __LINE__); \
g_print ("REQUIRE line %3d EXIT : %s\n", __LINE__, (error)); \
TEST_FINISH; \
} \
-}G_STMT_END
+}G_STMT_END
#define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \
GstElement *element = gst_element_factory_make ((element_name), NULL); \
if (element) { \
g_print ("REQUIRE line %3d EXIT : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \
TEST_FINISH; \
} \
-}G_STMT_END
+}G_STMT_END
#define PIPELINE1 "filesrc blocksize =8192 location=%s ! mad ! osssink"
#define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink"
#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink"
*/
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
-goto here;
+ goto here;
here:
/**
* - unsigned parameters
*/
audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL);
- TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory.");
+ TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS),
+ "The following tests requires a valid mp3 file music.mp3 in your home directory.");
TEST_REQUIRE_ELEMENT ("mad");
TEST_REQUIRE_ELEMENT ("osssink");
TEST_START (PIPELINE1, audio_file);
* - SOMETIMES pads
*/
video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL);
- TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory.");
+ TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS),
+ "The following tests requires a valid mpeg file video.mpeg in your home directory.");
TEST_REQUIRE_ELEMENT ("mpegdemux");
TEST_REQUIRE_ELEMENT ("mpeg2dec");
TEST_REQUIRE_ELEMENT ("xvideosink");
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_plugin_load_file (".libs/libtestplugin.so", &error);
g_assert (plugin != NULL);
- if (error)
- {
+ if (error) {
g_print ("ERROR loading plug-in: %s\n", error->message);
g_free (error);
return 1;
}
- g_print ("testplugin: %s\n", gst_plugin_get_name(plugin));
+ g_print ("testplugin: %s\n", gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
-
- loaded = gst_plugin_load (gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
+
+ loaded = gst_plugin_load (gst_plugin_get_name (plugin));
g_assert (loaded == TRUE);
numplugins = g_list_length (gst_registry_pool_plugin_list ());
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
- loaded = gst_plugin_load (gst_plugin_get_name(plugin));
+ loaded = gst_plugin_load (gst_plugin_get_name (plugin));
g_assert (loaded == TRUE);
numplugins = g_list_length (gst_registry_pool_plugin_list ());
g_print ("%d plugins loaded\n", numplugins);
- g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin)));
+ g_print ("%d features in plugin\n",
+ g_list_length (gst_plugin_get_feature_list (plugin)));
g_mem_chunk_info ();
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false"));
+ g_print ("testplugin: %p loaded: %s\n", plugin,
+ (gst_plugin_is_loaded (plugin) ? "true" : "false"));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %s\n", gst_plugin_get_name(plugin));
+ g_print ("testplugin: %s\n", gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
-int
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
-
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
static gboolean
-plugin2_init (GstPlugin *plugin)
+plugin2_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "a second plugin for testing",
- plugin2_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
-int
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "a second plugin for testing",
+ plugin2_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
+
+int
main (int argc, char *argv[])
{
GstPlugin *plugin;
plugin = gst_registry_pool_find_plugin ("testplugin");
g_assert (plugin != NULL);
- g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin));
plugin = gst_registry_pool_find_plugin ("testplugin2");
g_assert (plugin != NULL);
- g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin));
+ g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin));
return 0;
}
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "another testplugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "another testplugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE_STATIC (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin2",
- "another testplugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_COPYRIGHT,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin2",
+ "another testplugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "testplugin",
- "a plugin for testing",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_COPYRIGHT,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "testplugin",
+ "a plugin for testing",
+ plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN);
#define ITERS 100
#include <stdlib.h>
-static GstElement*
+static GstElement *
create_bin (void)
{
GstElement *bin;
return bin;
}
-static GstElement*
+static GstElement *
create_bin_ghostpads (void)
{
GstElement *bin;
element2 = gst_element_factory_make ("fakesink", NULL);
gst_bin_add (GST_BIN (bin), element2);
gst_element_link_pads (element1, "src", element2, "sink");
- gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), "ghost_sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"),
+ "ghost_sink");
return bin;
}
#endif
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *bin;
int usage1;
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
g_assert (GST_OBJECT_FLOATING (bin));
gst_object_sink (GST_OBJECT (bin));
g_assert (!GST_OBJECT_FLOATING (bin));
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/ref/sink/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_sink (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/ref/sink/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
g_assert (!GST_OBJECT_DESTROYED (bin));
g_assert (GST_OBJECT_DESTROYED (bin));
gst_object_unref (GST_OBJECT (bin));
#endif
- g_print ("create/destroy/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_unref (GST_OBJECT (bin));
#if 0
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("create/destroy/unref %d bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref %d bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
- g_print ("create/ref/unref/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/ref/unref/unref %d bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/unref/unref %d bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
#if 0
gst_object_unref (GST_OBJECT (bin));
#endif
- g_print ("craete/ref/destroy/unref/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("craete/ref/destroy/unref/unref new bin %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("craete/ref/destroy/unref/unref %d bins %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d bins %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
bin = gst_bin_new ("somebin");
gst_object_ref (GST_OBJECT (bin));
gst_element_set_name (bin, "testing123");
gst_object_unref (GST_OBJECT (bin));
#endif
}
- g_print ("craete/ref/destroy/unref/unref %d bins with name %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d bins with name %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
bin = gst_bin_new ("somebin");
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (bin, "testing");
}
gst_object_unref (GST_OBJECT (bin));
- g_print ("set name %d times %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("set name %d times %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- bin = create_bin();
+ for (i = 0; i < iters; i++) {
+ bin = create_bin ();
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bin with children %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bin with children %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters/2;i++) {
- bin = create_bin_ghostpads();
+ for (i = 0; i < iters / 2; i++) {
+ bin = create_bin_ghostpads ();
gst_object_unref (GST_OBJECT (bin));
}
- g_print ("create/unref %d bin with children and ghostpads %d\n", iters/2, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d bin with children and ghostpads %d\n", iters / 2,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test1();
+ for (i = 0; i < iters; i++) {
+ add_remove_test1 ();
}
- g_print ("add/remove test1 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/remove test1 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test2();
+ for (i = 0; i < iters; i++) {
+ add_remove_test2 ();
}
- g_print ("add/remove test2 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/remove test2 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
- for (i=0; i<iters;i++) {
- add_remove_test3();
+ for (i = 0; i < iters; i++) {
+ add_remove_test3 ();
}
- g_print ("add/destroy/remove test3 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/destroy/remove test3 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
- add_remove_test4();
+ for (i = 0; i < iters; i++) {
+ add_remove_test4 ();
}
- g_print ("add/destroy/remove test4 %d in bin %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("add/destroy/remove test4 %d in bin %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
- g_print ("leaked: %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1);
//gst_alloc_trace_print_all ();
- return (gst_alloc_trace_live_all ()-usage1 ? -1 : 0);
+ return (gst_alloc_trace_live_all () - usage1 ? -1 : 0);
}
#include <stdlib.h>
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *element;
int usage1;
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
- g_print ("create/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_OBJECT_FLOATING (element));
gst_object_sink (GST_OBJECT (element));
g_assert (!GST_OBJECT_FLOATING (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/ref/sink/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_sink (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/ref/sink/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/sink/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/destroy/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/destroy/unref %d element %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/destroy/unref %d element %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("create/ref/unref/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
+
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/ref/unref/unref %d element %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("create/ref/unref/unref %d element %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#if 0
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
- g_print ("craete/ref/destroy/unref/unref new element %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref new element %d\n",
+ gst_alloc_trace_live_all () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d elements %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesrc", NULL);
gst_object_ref (GST_OBJECT (element));
gst_element_set_name (element, "testing123");
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d elements with name %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
#endif
element = gst_element_factory_make ("fakesrc", NULL);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (element, "testing");
}
gst_object_unref (GST_OBJECT (element));
- g_print ("set name %d times %d\n", iters, gst_alloc_trace_live_all ()-usage1);
+ g_print ("set name %d times %d\n", iters,
+ gst_alloc_trace_live_all () - usage1);
- g_print ("leaked: %d\n", gst_alloc_trace_live_all ()-usage1);
+ g_print ("leaked: %d\n", gst_alloc_trace_live_all () - usage1);
- return (gst_alloc_trace_live_all ()-usage1 ? -1 : 0);
+ return (gst_alloc_trace_live_all () - usage1 ? -1 : 0);
}
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *element;
GstElement *element2;
g_print ("starting element with pad test with %d iterations\n", iters);
- usage1 = vmsize();
+ usage1 = vmsize ();
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
g_assert (!GST_OBJECT_FLOATING (pad));
g_assert (gst_pad_get_parent (pad) == element);
gst_object_unref (GST_OBJECT (element));
- g_print ("create/addpad/unref new element %ld\n", vmsize()-usage1);
+ g_print ("create/addpad/unref new element %ld\n", vmsize () - usage1);
- for (i=0; i<iters; i++) {
- element = gst_element_factory_make
-("fakesink", NULL);;
+ for (i = 0; i < iters; i++) {
+ element = gst_element_factory_make ("fakesink", NULL);;
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize()-usage1);
+ g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
}
- g_print ("create/link/unref %d elements %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/link/unref %d elements %ld\n", iters / 2,
+ vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
gst_object_unref (GST_OBJECT (element2));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("create/link/destroy %d elements %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/link/destroy %d elements %ld\n", iters / 2,
+ vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
- g_print ("pad removal ok %ld\n", vmsize()-usage1);
- for (i=0; i<iters/2; i++) {
+ g_print ("pad removal ok %ld\n", vmsize () - usage1);
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_element_remove_pad (element, pad);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad removal loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad removal loop %d %ld\n", iters / 2, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad removal and test loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad removal and test loop %d %ld\n", iters / 2,
+ vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
- g_print ("pad destroy/removal ok %ld\n", vmsize()-usage1);
+ g_print ("pad destroy/removal ok %ld\n", vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad destroy/removal loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad destroy/removal loop %d %ld\n", iters / 2, vmsize () - usage1);
- for (i=0; i<iters/2; i++) {
+ for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (pad));
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
- g_print ("pad destroy loop %d %ld\n", iters/2, vmsize()-usage1);
+ g_print ("pad destroy loop %d %ld\n", iters / 2, vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
static gboolean
quit_main (gpointer data)
{
- if (mainloop)
- {
- mainloop = FALSE;
- g_print ("-");
- gst_main_quit ();
- }
- return TRUE;
+ if (mainloop) {
+ mainloop = FALSE;
+ g_print ("-");
+ gst_main_quit ();
+ }
+ return TRUE;
}
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
int i;
g_timeout_add (1, quit_main, NULL);
- for (i = 0; i < 1000; ++i)
- {
+ for (i = 0; i < 1000; ++i) {
mainloop = TRUE;
g_print ("+");
gst_main ();
#include <fcntl.h>
#include <unistd.h>
-int vmsize() {
- int pid,fd,size,i,mem;
+int
+vmsize ()
+{
+ int pid, fd, size, i, mem;
char filename[17], buf[256], *ptr, *end;
- pid = getpid();
- snprintf(filename,17,"/proc/%d/stat",pid);
- fd = open(filename,O_RDONLY);
- size = read(fd,buf,240);
+ pid = getpid ();
+ snprintf (filename, 17, "/proc/%d/stat", pid);
+ fd = open (filename, O_RDONLY);
+ size = read (fd, buf, 240);
ptr = buf;
- for (i=0;i<22;i++)
- ptr = (char *)strchr(ptr,' ') + 1;
- end = (char *)strchr(ptr,' ');
+ for (i = 0; i < 22; i++)
+ ptr = (char *) strchr (ptr, ' ') + 1;
+ end = (char *) strchr (ptr, ' ');
*end = 0;
- sscanf(ptr,"%d",&mem);
- close(fd);
+ sscanf (ptr, "%d", &mem);
+ close (fd);
return mem;
}
-int vmsize();
+int vmsize ();
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstObject *object, *object2;
long usage1;
iters = ITERS;
g_print ("starting test with %d iterations\n", iters);
- usage1 = vmsize();
+ usage1 = vmsize ();
object = gst_object_new ();
gst_object_unref (object);
- g_print ("create/unref new object %ld\n", vmsize()-usage1);
+ g_print ("create/unref new object %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_unref (object);
}
- g_print ("create/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
g_assert (GST_OBJECT_FLOATING (object));
gst_object_sink (object);
g_assert (!GST_OBJECT_FLOATING (object));
gst_object_unref (object);
- g_print ("create/ref/sink/unref new object %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new object %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_sink (object);
gst_object_unref (object);
}
- g_print ("create/ref/sink/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
g_assert (!GST_OBJECT_DESTROYED (object));
gst_object_unref (object);
g_assert (GST_OBJECT_DESTROYED (object));
gst_object_unref (object);
- g_print ("create/destroy/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new object %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("destroy/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("destroy/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
- g_print ("create/ref/unref/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new object %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/unref/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
gst_object_unref (object);
- g_print ("create/ref/destroy/unref/unref new object %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/destroy/unref/unref new object %ld\n",
+ vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_unref (object);
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/destroy/unref/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d object %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
gst_object_ref (object);
gst_object_set_name (object, "testing123");
gst_object_unref (object);
gst_object_unref (object);
}
- g_print ("create/ref/destroy/unref/unref %d object with name %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d object with name %ld\n", iters,
+ vmsize () - usage1);
object = gst_object_new ();
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_object_set_name (object, "testing");
}
gst_object_unref (object);
- g_print ("create/set name/unref %d object %ld\n", iters, vmsize()-usage1);
+ g_print ("create/set name/unref %d object %ld\n", iters, vmsize () - usage1);
object = gst_object_new ();
object2 = gst_object_new ();
g_assert (GST_OBJECT_FLOATING (object2));
g_assert (!GST_OBJECT_FLOATING (object));
- g_print ("parentage flags set_parent ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags set_parent ok %ld\n", vmsize () - usage1);
gst_object_ref (object);
gst_object_unparent (object);
g_assert (!GST_OBJECT_FLOATING (object));
g_assert (gst_object_get_parent (object) == NULL);
- g_print ("parentage flags unparent ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags unparent ok %ld\n", vmsize () - usage1);
gst_object_set_parent (object, object2);
g_assert (GST_OBJECT_FLOATING (object2));
g_assert (gst_object_get_parent (object) == NULL);
gst_object_unref (object);
- g_print ("parentage flags destroy ok %ld\n", vmsize()-usage1);
+ g_print ("parentage flags destroy ok %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
object = gst_object_new ();
object2 = gst_object_new ();
gst_object_set_parent (object2, object);
gst_object_unref (object);
gst_object_unref (object2);
}
- g_print ("create/unref %d 2 parented objects %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d 2 parented objects %ld\n", iters,
+ vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
#include "mem.h"
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstPad *pad;
GstPadTemplate *padtempl;
//gst_alloc_trace_print_all ();
g_print ("starting pad test\n");
- usage1 = vmsize();
+ usage1 = vmsize ();
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/unref new pad %ld\n", vmsize()-usage1);
+ g_print ("create/unref new pad %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d pads %ld\n", iters, vmsize () - usage1);
pad = gst_pad_new ("padname", GST_PAD_SINK);
g_assert (GST_OBJECT_FLOATING (pad));
gst_object_sink (GST_OBJECT (pad));
g_assert (!GST_OBJECT_FLOATING (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/ref/sink/unref new pad %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new pad %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_sink (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize () - usage1);
#if 0
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
g_assert (GST_OBJECT_DESTROYED (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/destroy/unref pad %ld\n", vmsize()-usage1);
+ g_print ("create/destroy/unref pad %ld\n", vmsize () - usage1);
#endif
-
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize () - usage1);
#endif
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
- g_print ("create/ref/unref/unref pad %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1);
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
#if 0
gst_object_unref (GST_OBJECT (pad));
#endif
- g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize()-usage1);
-
+ g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize () - usage1);
+
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
//gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters,
+ vmsize () - usage1);
#endif
#if 0
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
pad = gst_pad_new ("padname", GST_PAD_SINK);
gst_object_ref (GST_OBJECT (pad));
gst_pad_set_name (pad, "testing123");
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters, vmsize()-usage1);
+ g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters,
+ vmsize () - usage1);
#endif
pad = gst_pad_new ("padname", GST_PAD_SINK);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_pad_set_name (pad, "testing");
}
gst_object_unref (GST_OBJECT (pad));
- g_print ("set name %d times %ld\n", iters, vmsize()-usage1);
+ g_print ("set name %d times %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- padtempl = gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
+ for (i = 0; i < iters; i++) {
+ padtempl =
+ gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
gst_object_unref (GST_OBJECT (padtempl));
}
- g_print ("%d padtemplates create/unref %ld\n", iters, vmsize()-usage1);
+ g_print ("%d padtemplates create/unref %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- padtempl = gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
+ for (i = 0; i < iters; i++) {
+ padtempl =
+ gst_pad_template_new ("sink%d", GST_PAD_SINK, GST_PAD_SOMETIMES, NULL);
pad = gst_pad_new_from_template (padtempl, "sink1");
gst_object_unref (GST_OBJECT (pad));
}
- g_print ("%d pads create/unref from padtemplate %ld\n", iters, vmsize()-usage1);
-
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("%d pads create/unref from padtemplate %ld\n", iters,
+ vmsize () - usage1);
+
+ g_print ("leaked: %ld\n", vmsize () - usage1);
//gst_alloc_trace_print_all ();
- return vmsize()-usage1;
+ return vmsize () - usage1;
}
GstPadChainFunction oss_chain;
static GstElement *
-make_and_check_element (gchar *type, gchar *name)
+make_and_check_element (gchar * type, gchar * name)
{
GstElement *element = gst_element_factory_make (type, name);
if (element == NULL) {
- g_warning ("Could not run test, because element type \"%s\" is not installed. Please retry when it is. Assuming it works for now...", type);
+ g_warning
+ ("Could not run test, because element type \"%s\" is not installed. Please retry when it is. Assuming it works for now...",
+ type);
exit (1);
}
static void
create_pipeline (void)
{
- GstElement *src;
+ GstElement *src;
GstElement *sink;
GstElement *id;
-
+
pipeline = gst_pipeline_new ("pipeline");
src = make_and_check_element ("sinesrc", "src");
/**
* Osssink (chain-based) only breaks the basic scheduler.
*/
sink = make_and_check_element ("alsasink", "sink");
-
+
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
gst_element_link (src, sink);
-
+
/**
* now make the bug appear
* I believe it has something to do with 2 chains being created in the scheduler
id = make_and_check_element ("identity", "id");
gst_bin_add (GST_BIN (pipeline), id);
gst_element_link_many (src, id, sink, NULL);
-
+
/* This pipeline will not be removed properly once we unref it */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
-}
+}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
- create_pipeline();
-
+ create_pipeline ();
+
while (i < 300) {
/**
* only inc i when it works, so the program hangs when _iterate returns false,
#include <stdlib.h>
#include "mem.h"
-static GstElement*
+static GstElement *
create_thread (void)
{
GstElement *thread;
return thread;
}
-static GstElement*
+static GstElement *
create_thread_ghostpads (void)
{
GstElement *thread;
gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK));
gst_bin_add (GST_BIN (thread), element2);
gst_element_link (element1, "src1", element2, "sink1");
- gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), "sink1");
+ gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"),
+ "sink1");
return thread;
}
}
int
-main (int argc, gchar *argv[])
+main (int argc, gchar * argv[])
{
GstElement *thread, *element;
long usage1;
iters = ITERS;
g_print ("starting test\n");
- usage1 = vmsize();
+ usage1 = vmsize ();
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/unref new thread %ld\n", vmsize()-usage1);
+ g_print ("create/unref new thread %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d threads %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
g_assert (GST_OBJECT_FLOATING (thread));
gst_object_sink (GST_OBJECT (thread));
g_assert (!GST_OBJECT_FLOATING (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/ref/sink/unref new thread %ld\n", vmsize()-usage1);
+ g_print ("create/ref/sink/unref new thread %ld\n", vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_sink (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/ref/sink/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/sink/unref %d threads %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
g_assert (!GST_OBJECT_DESTROYED (thread));
gst_object_unref (GST_OBJECT (thread));
g_assert (GST_OBJECT_DESTROYED (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/destroy/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/destroy/unref new thread %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/destroy/unref %d thread %ld\n", iters, vmsize()-usage1);
+ g_print ("create/destroy/unref %d thread %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("create/ref/unref/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("create/ref/unref/unref new thread %ld\n", vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/ref/unref/unref %d thread %ld\n", iters, vmsize()-usage1);
+ g_print ("create/ref/unref/unref %d thread %ld\n", iters, vmsize () - usage1);
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
- g_print ("craete/ref/destroy/unref/unref new thread %ld\n", vmsize()-usage1);
-
- for (i=0; i<iters;i++) {
+ g_print ("craete/ref/destroy/unref/unref new thread %ld\n",
+ vmsize () - usage1);
+
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("craete/ref/destroy/unref/unref %d threads %ld\n", iters, vmsize()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d threads %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
gst_object_ref (GST_OBJECT (thread));
gst_element_set_name (thread, "testing123");
gst_object_unref (GST_OBJECT (thread));
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("craete/ref/destroy/unref/unref %d threads with name %ld\n", iters, vmsize()-usage1);
+ g_print ("craete/ref/destroy/unref/unref %d threads with name %ld\n", iters,
+ vmsize () - usage1);
thread = gst_thread_new ("somethread");
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
gst_element_set_name (thread, "testing");
}
gst_object_unref (GST_OBJECT (thread));
- g_print ("set name %d times %ld\n", iters, vmsize()-usage1);
+ g_print ("set name %d times %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
+ for (i = 0; i < iters; i++) {
thread = gst_thread_new ("somethread");
element = gst_element_new ();
gst_element_set_name (element, "test1");
gst_bin_add (GST_BIN (thread), element);
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with one element %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d thread with one element %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
- thread = create_thread();
+ for (i = 0; i < iters; i++) {
+ thread = create_thread ();
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with children %ld\n", iters, vmsize()-usage1);
+ g_print ("create/unref %d thread with children %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters/2;i++) {
- thread = create_thread_ghostpads();
+ for (i = 0; i < iters / 2; i++) {
+ thread = create_thread_ghostpads ();
gst_object_unref (GST_OBJECT (thread));
}
- g_print ("create/unref %d thread with children and ghostpads %ld\n", iters/2, vmsize()-usage1);
+ g_print ("create/unref %d thread with children and ghostpads %ld\n",
+ iters / 2, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test1();
+ for (i = 0; i < iters; i++) {
+ add_remove_test1 ();
}
- g_print ("add/remove test1 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/remove test1 %d in thread %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test2();
+ for (i = 0; i < iters; i++) {
+ add_remove_test2 ();
}
- g_print ("add/remove test2 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/remove test2 %d in thread %ld\n", iters, vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test3();
+ for (i = 0; i < iters; i++) {
+ add_remove_test3 ();
}
- g_print ("add/destroy/remove test3 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/destroy/remove test3 %d in thread %ld\n", iters,
+ vmsize () - usage1);
- for (i=0; i<iters;i++) {
- add_remove_test4();
+ for (i = 0; i < iters; i++) {
+ add_remove_test4 ();
}
- g_print ("add/destroy/remove test4 %d in thread %ld\n", iters, vmsize()-usage1);
+ g_print ("add/destroy/remove test4 %d in thread %ld\n", iters,
+ vmsize () - usage1);
- g_print ("leaked: %ld\n", vmsize()-usage1);
+ g_print ("leaked: %ld\n", vmsize () - usage1);
- return (vmsize()-usage1 ? -1 : 0);
+ return (vmsize () - usage1 ? -1 : 0);
}
#include <gst/gst.h>
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
- GstElement *fakesrc1, *fakesink1;
- GstElement *fakesrc2, *fakesink2;
+ GstElement *fakesrc1, *fakesink1;
+ GstElement *fakesrc2, *fakesink2;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
-
+
fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
-
+
gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL);
gst_element_link_pads (fakesrc1, "src", fakesink1, "sink");
gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL);
gst_element_link_pads (fakesrc2, "src", fakesink2, "sink");
- g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
-
+
return 0;
}
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <gst/gst.h>
#include <string.h>
/* checks that a tag contains the given values and not more values */
static void
-check (const GstTagList *list, const gchar *tag, gchar *value, ...)
+check (const GstTagList * list, const gchar * tag, gchar * value, ...)
{
va_list args;
gchar *str;
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
g_assert (strcmp (value, str) == 0);
g_free (str);
-
+
value = va_arg (args, gchar *);
i++;
}
g_assert (i == gst_tag_list_get_tag_size (list, tag));
va_end (args);
}
+
#define NEW_LIST_FIXED(mode) G_STMT_START{ \
if (list) gst_tag_list_free (list);\
list = gst_tag_list_new (); \
if (merge) gst_tag_list_free (merge);\
merge = gst_tag_list_merge (list, list2, mode); \
}G_STMT_END
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstTagList *list = NULL, *list2 = NULL, *merge = NULL;
-
+
gst_init (&argc, &argv);
/* make sure the assumptions work */
/* we check string here only */
g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING);
g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING);
-
+
/* check additions */
/* unfixed */
NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (list, FTAG, FIXED1, NULL);
NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (list, FTAG, NULL);
-
+
/* check merging */
- /* unfixed */
+ /* unfixed */
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, UTAG, UNFIXED3, UNFIXED4, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, UTAG, UNFIXED1, UNFIXED2, NULL);
- /* fixed */
+ /* fixed */
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL);
check (merge, FTAG, FIXED3, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE);
check (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
check (merge, FTAG, FIXED1, NULL);
-
+
return 0;
}
int
main (int argc, char *argv[])
{
- gst_init(NULL, NULL);
- gst_init(&argc, &argv);
+ gst_init (NULL, NULL);
+ gst_init (&argc, &argv);
return 0;
}
/* handoff callback */
static void
-handoff (GstElement *element, gpointer data)
+handoff (GstElement * element, gpointer data)
{
++handoff_count;
g_print ("handoff (%d) ", handoff_count);
}
static void
-construct_pipeline (GstElement *pipeline, GstElement *thread)
+construct_pipeline (GstElement * pipeline, GstElement * thread)
{
GstElement *src, *sink, *queue;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", "sink");
- queue = gst_element_factory_make ("queue", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", "sink");
+ queue = gst_element_factory_make ("queue", NULL);
gst_bin_add_many (GST_BIN (thread), queue, sink, NULL);
gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL);
}
void
-change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline)
+change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline)
{
gst_element_set_state (pipeline, GST_STATE_NULL);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *thread = NULL;
-
+
gst_init (&argc, &argv);
pipeline = gst_thread_new ("main_pipeline");
g_print ("Pipeline done. Resetting to NULL.\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
- if (handoff_count == 0)
- {
+ if (handoff_count == 0) {
g_print ("ERROR: no buffers have passed\n");
return -1;
}
handoff_count = 0;
- g_print ("Second run: setting consumer thread to playing, then complete pipeline\n");
+ g_print
+ ("Second run: setting consumer thread to playing, then complete pipeline\n");
gst_element_set_state (thread, GST_STATE_PLAYING);
g_print ("SLEEPING 1 sec\n");
sleep (1);
g_print ("SLEEPING 2 sec\n");
sleep (2);
- if (handoff_count == 0)
- {
+ if (handoff_count == 0) {
g_print ("ERROR: no buffers have passed\n");
return -1;
}
-
+
return 0;
}
usage (void)
{
g_print ("compile this test with TESTNUM defined.\n"
- " available TESTNUMs: \n"
- " 1: stress test state change \n"
- " 2: iterate once \n"
- " 3: iterate twice \n"
- " 4: state change while running \n"
- " 5: state change in thread context\n");
+ " available TESTNUMs: \n"
+ " 1: stress test state change \n"
+ " 2: iterate once \n"
+ " 3: iterate twice \n"
+ " 4: state change while running \n"
+ " 5: state change in thread context\n");
}
static void
-construct_pipeline (GstElement *pipeline)
+construct_pipeline (GstElement * pipeline)
{
GstElement *src, *sink, *queue, *identity, *thread;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", "sink");
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", "sink");
identity = gst_element_factory_make ("identity", NULL);
- queue = gst_element_factory_make ("queue", NULL);
- thread = gst_element_factory_make ("thread", NULL);
+ queue = gst_element_factory_make ("queue", NULL);
+ thread = gst_element_factory_make ("thread", NULL);
gst_element_link_many (src, queue, identity, sink, NULL);
}
void
-change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline)
+change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline)
{
gst_element_set_state (pipeline, GST_STATE_NULL);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
-
+
gst_init (&argc, &argv);
#ifndef TESTNUM
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
g_assert (sink);
- g_signal_connect (G_OBJECT (sink), "handoff",
- G_CALLBACK (change_state), pipeline);
+ g_signal_connect (G_OBJECT (sink), "handoff",
+ G_CALLBACK (change_state), pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("running ...\n");
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
}
-
+
return 0;
}
gboolean running = FALSE;
static void
-construct_pipeline (GstElement *pipeline)
+construct_pipeline (GstElement * pipeline)
{
GstElement *src, *sink, *identity;
- src = gst_element_factory_make ("fakesrc", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
identity = gst_element_factory_make ("identity", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (identity);
g_assert (sink);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
-
- g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+
+ g_print ("element %s has changed state to %s\n",
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
if (state == GST_STATE_PAUSED && running) {
running = FALSE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = 100;
int i;
gulong id;
GstElement *thread;
-
+
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
- id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ id = g_signal_connect (G_OBJECT (thread), "state_change",
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread);
g_print ("Setting thread to play\n");
gst_element_set_state (thread, GST_STATE_PLAYING);
g_print ("Going into the main GStreamer loop\n");
- gst_main ();
+ gst_main ();
g_print ("Coming out of the main GStreamer loop\n");
g_signal_handler_disconnect (G_OBJECT (thread), id);
gst_element_set_state (thread, GST_STATE_NULL);
gboolean can_quit = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink;
GstElement *identity = NULL;
int i;
identity = NULL;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
- if (state == GST_STATE_PAUSED && running)
- {
- while (!can_quit) ;
+ if (state == GST_STATE_PAUSED && running) {
+ while (!can_quit);
can_quit = FALSE;
g_print ("quitting main loop\n");
gst_main_quit ();
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = 290;
int i;
gst_init (&argc, &argv);
- for (i = 90; i < runs; ++i)
- {
+ for (i = 90; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread, i / 10 + 1);
g_print ("Setting thread to play with %d identities\n", i / 10 + 1);
if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
g_error ("Failed setting thread to play\n");
- }
- else {
+ } else {
g_print ("Going into the main GStreamer loop\n");
- can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */
+ can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */
gst_main ();
}
running = FALSE;
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink, *identity = NULL;
GstElement *from;
int i;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
void
-state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data)
+state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data)
{
GstElementState state = gst_element_get_state (el);
-
- g_print ("element %s has changed state to %s\n",
- GST_ELEMENT_NAME (el),
- gst_element_state_get_name (state));
- if (state == GST_STATE_PLAYING) running = TRUE;
+
+ g_print ("element %s has changed state to %s\n",
+ GST_ELEMENT_NAME (el), gst_element_state_get_name (state));
+ if (state == GST_STATE_PLAYING)
+ running = TRUE;
/* if we move from PLAYING to PAUSED, we're done */
- if (state == GST_STATE_PAUSED && running)
+ if (state == GST_STATE_PAUSED && running)
done = TRUE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
int i;
gulong id;
GstElement *thread;
-
- alarm(10);
+
+ alarm (10);
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
thread = gst_thread_new ("main_thread");
g_assert (thread);
/* connect state change signal */
- id = g_signal_connect (G_OBJECT (thread), "state_change",
- G_CALLBACK (state_changed), NULL);
+ id = g_signal_connect (G_OBJECT (thread), "state_change",
+ G_CALLBACK (state_changed), NULL);
construct_pipeline (thread, i / RUNS_PER_IDENTITY + 1);
- g_print ("Setting thread to play with %d identities\n",
- i / RUNS_PER_IDENTITY + 1);
+ g_print ("Setting thread to play with %d identities\n",
+ i / RUNS_PER_IDENTITY + 1);
done = FALSE;
if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
g_warning ("failed to go to PLAYING");
- }
- else {
+ } else {
g_print ("Waiting for thread PLAYING->PAUSED\n");
- while (!done) /* do nothing */;
+ while (!done) /* do nothing */
+ ;
}
running = FALSE;
g_print ("Coming out of the main GStreamer loop\n");
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink, *identity = NULL;
GstElement *from;
int i;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
}
static void
-iterator (GstElement *bin)
+iterator (GstElement * bin)
{
gst_element_set_state (bin, GST_STATE_PLAYING);
- while (gst_bin_iterate (GST_BIN (bin))) g_print ("+");
+ while (gst_bin_iterate (GST_BIN (bin)))
+ g_print ("+");
gst_element_set_state (bin, GST_STATE_NULL);
g_print ("\n");
done = TRUE;
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
int i;
GstElement *pipeline;
- alarm(10);
+ alarm (10);
g_thread_init (NULL);
gst_init (&argc, &argv);
- for (i = 0; i < runs; ++i)
- {
+ for (i = 0; i < runs; ++i) {
pipeline = gst_pipeline_new ("main_pipeline");
g_assert (pipeline);
g_print ("Created GThread\n");
g_print ("Waiting for thread PLAYING->PAUSED\n");
- while (!done) /* do nothing */;
+ while (!done) /* do nothing */
+ ;
running = FALSE;
g_print ("Unreffing pipeline\n");
g_object_unref (G_OBJECT (pipeline));
return 0;
}
-
gboolean done = FALSE;
static void
-construct_pipeline (GstElement *pipeline, gint identities)
+construct_pipeline (GstElement * pipeline, gint identities)
{
GstElement *src, *sink;
GstElement *identity = NULL;
int i;
identity = NULL;
- src = gst_element_factory_make ("fakesrc", NULL);
- sink = gst_element_factory_make ("fakesink", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
g_assert (src);
g_assert (sink);
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
from = src;
- for (i = 0; i < identities; ++i)
- {
+ for (i = 0; i < identities; ++i) {
identity = gst_element_factory_make ("identity", NULL);
g_assert (identity);
gst_bin_add (GST_BIN (pipeline), identity);
int i;
GstElement *pipeline;
- for (i = 30; i < runs; ++i)
- {
+ for (i = 30; i < runs; ++i) {
pipeline = gst_pipeline_new ("main_pipeline");
g_assert (pipeline);
}
int
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
done = FALSE;
g_thread_create ((GThreadFunc) thread, NULL, FALSE, NULL);
g_print ("main: created GThread\n");
- while (!done) g_usleep (G_USEC_PER_SEC);
+ while (!done)
+ g_usleep (G_USEC_PER_SEC);
g_print ("main: done\n");
return 0;
}
-
#include <gst/gst.h>
-typedef struct {
+typedef struct
+{
gchar *name;
GSList *srcpads;
GSList *sinkpads;
GSList *arguments;
} comp_element;
-enum {
+enum
+{
ARG_INT,
ARG_FILENAME,
ARG_ENUM
};
-typedef struct {
+typedef struct
+{
gchar *name;
int type;
GSList *enums;
} comp_argument;
-typedef struct {
+typedef struct
+{
gint value;
gchar *nick;
} enum_value;
-void print_match_list (gchar *prefix, int len, GSList *wordlist) {
+void
+print_match_list (gchar * prefix, int len, GSList * wordlist)
+{
GSList *words = wordlist;
while (words) {
- if (!len || !strncmp((gchar *)(words->data), prefix, len))
- printf("%s\n",(gchar *)(words->data));
+ if (!len || !strncmp ((gchar *) (words->data), prefix, len))
+ printf ("%s\n", (gchar *) (words->data));
words = g_slist_next (words);
}
}
-int match_element (comp_element *element, gchar *name) {
- return strcmp(element->name,name);
+int
+match_element (comp_element * element, gchar * name)
+{
+ return strcmp (element->name, name);
}
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
xmlDocPtr doc;
xmlNodePtr rootnode, elementnode, propnode, argnode;
GList *element_list = NULL;
GSList *words = NULL;
struct stat stat_buf;
-
+
setlocale (LC_ALL, "");
- if(argc<4){
- fprintf(stderr,"gst-complete called with invalid arguments\n");
- exit(1);
+ if (argc < 4) {
+ fprintf (stderr, "gst-complete called with invalid arguments\n");
+ exit (1);
}
prev_word = argv[3];
partial_word = argv[2];
- partial_len = strlen(partial_word);
+ partial_len = strlen (partial_word);
/***** Loading the completion information from the registry *****/
- if (stat (GST_CACHE_DIR"/compreg.xml", &stat_buf) == 0) {
- doc = xmlParseFile (GST_CACHE_DIR"/compreg.xml");
+ if (stat (GST_CACHE_DIR "/compreg.xml", &stat_buf) == 0) {
+ doc = xmlParseFile (GST_CACHE_DIR "/compreg.xml");
} else {
exit (1);
}
elementnode = rootnode->xmlChildrenNode;
while (elementnode) {
- if (!strcmp(elementnode->name, "element")) {
- element = g_new0(comp_element,1);
+ if (!strcmp (elementnode->name, "element")) {
+ element = g_new0 (comp_element, 1);
propnode = elementnode->xmlChildrenNode;
while (propnode) {
- if (!strcmp(propnode->name, "name")) {
- element->name = xmlNodeGetContent(propnode);
+ if (!strcmp (propnode->name, "name")) {
+ element->name = xmlNodeGetContent (propnode);
/* fprintf(stderr,element->name); */
- } else if (!strcmp(propnode->name, "srcpad")) {
- element->srcpads = g_slist_prepend(element->srcpads, xmlNodeGetContent(propnode));
+ } else if (!strcmp (propnode->name, "srcpad")) {
+ element->srcpads =
+ g_slist_prepend (element->srcpads, xmlNodeGetContent (propnode));
/* fprintf(stderr,"."); */
- } else if (!strcmp(propnode->name, "sinkpad")) {
- element->sinkpads = g_slist_prepend(element->sinkpads, xmlNodeGetContent(propnode));
- } else if (!strcmp(propnode->name, "srcpadtemplate")) {
- element->srcpadtemplates = g_slist_prepend(element->srcpadtemplates, xmlNodeGetContent(propnode));
+ } else if (!strcmp (propnode->name, "sinkpad")) {
+ element->sinkpads =
+ g_slist_prepend (element->sinkpads, xmlNodeGetContent (propnode));
+ } else if (!strcmp (propnode->name, "srcpadtemplate")) {
+ element->srcpadtemplates =
+ g_slist_prepend (element->srcpadtemplates,
+ xmlNodeGetContent (propnode));
/* fprintf(stderr,"."); */
- } else if (!strcmp(propnode->name, "sinkpad")) {
- element->sinkpadtemplates = g_slist_prepend(element->sinkpadtemplates, xmlNodeGetContent(propnode));
- } else if (!strcmp(propnode->name, "argument")) {
- argument = g_new0(comp_argument,1);
- argument->name = xmlNodeGetContent(propnode);
- argument->type = ARG_INT;
-
- /* walk through the values data */
- argnode = propnode->xmlChildrenNode;
- while (argnode) {
- if (!strcmp(argnode->name, "filename")) {
- argument->type = ARG_FILENAME;
- } else if (!strcmp(argnode->name,"option")) {
- argument->type = ARG_ENUM;
- option = g_new0(enum_value,1);
- sscanf(xmlNodeGetContent(argnode),"%d",&option->value);
- argument->enums = g_slist_prepend (argument->enums, option);
- }
- argnode = argnode->next;
- }
-
- element->arguments = g_slist_prepend(element->arguments, argument);
- }
-
- propnode = propnode->next;
+ } else if (!strcmp (propnode->name, "sinkpad")) {
+ element->sinkpadtemplates =
+ g_slist_prepend (element->sinkpadtemplates,
+ xmlNodeGetContent (propnode));
+ } else if (!strcmp (propnode->name, "argument")) {
+ argument = g_new0 (comp_argument, 1);
+ argument->name = xmlNodeGetContent (propnode);
+ argument->type = ARG_INT;
+
+ /* walk through the values data */
+ argnode = propnode->xmlChildrenNode;
+ while (argnode) {
+ if (!strcmp (argnode->name, "filename")) {
+ argument->type = ARG_FILENAME;
+ } else if (!strcmp (argnode->name, "option")) {
+ argument->type = ARG_ENUM;
+ option = g_new0 (enum_value, 1);
+ sscanf (xmlNodeGetContent (argnode), "%d", &option->value);
+ argument->enums = g_slist_prepend (argument->enums, option);
+ }
+ argnode = argnode->next;
+ }
+
+ element->arguments = g_slist_prepend (element->arguments, argument);
+ }
+
+ propnode = propnode->next;
}
- element_list = g_list_prepend(element_list, element);
- element_names = g_slist_prepend(element_names, element->name);
+ element_list = g_list_prepend (element_list, element);
+ element_names = g_slist_prepend (element_names, element->name);
}
elementnode = elementnode->next;
}
/* The bulk of the work is in deciding exactly which words are an option. */
/* if we're right at the beginning, with -launch in the first word */
- if (strstr(prev_word,"-launch")) {
+ if (strstr (prev_word, "-launch")) {
/* print out only elements with no sink pad or padtemplate */
elements = element_list;
while (elements) {
- element = (comp_element *)(elements->data);
+ element = (comp_element *) (elements->data);
if (!element->sinkpads && !element->sinkpadtemplates)
- words = g_slist_prepend (words, element->name);
- elements = g_list_next(elements);
+ words = g_slist_prepend (words, element->name);
+ elements = g_list_next (elements);
}
}
/* if the previous word is a connection */
- if (strchr(prev_word, '!')) {
+ if (strchr (prev_word, '!')) {
/* print out oly elements with a sink pad or template */
elements = element_list;
while (elements) {
- element = (comp_element *)(elements->data);
+ element = (comp_element *) (elements->data);
if (element->sinkpads || element->sinkpadtemplates)
- words = g_slist_prepend (words, element->name);
+ words = g_slist_prepend (words, element->name);
elements = g_list_next (elements);
}
}
/* if the partial word is an argument, and it's an enum */
- if (strchr(prev_word,'=')) {
- fprintf(stderr,"it's an arg, but dunno what element yet\n");
+ if (strchr (prev_word, '=')) {
+ fprintf (stderr, "it's an arg, but dunno what element yet\n");
}
- /* if the previous word is an element, we need to list both pads and arguments*/
- if ((elements = g_list_find_custom(element_list, prev_word, (GCompareFunc)match_element))) {
+ /* if the previous word is an element, we need to list both pads and arguments */
+ if ((elements =
+ g_list_find_custom (element_list, prev_word,
+ (GCompareFunc) match_element))) {
element = elements->data;
/* zero the numpads list so we can count them */
num_pads = 0;
pads = element->srcpads;
while (pads) {
num_pads++;
- words = g_slist_prepend (words, g_strdup_printf("%s!",(gchar *)(pads->data)));
+ words =
+ g_slist_prepend (words, g_strdup_printf ("%s!",
+ (gchar *) (pads->data)));
pads = g_slist_next (pads);
}
pads = element->srcpadtemplates;
while (pads) {
num_pads++;
- word = g_strdup_printf("%s!",(gchar *)(pads->data));
- if (!g_slist_find_custom(words,word,(GCompareFunc)strcmp))
- words = g_slist_prepend (words, word);
+ word = g_strdup_printf ("%s!", (gchar *) (pads->data));
+ if (!g_slist_find_custom (words, word, (GCompareFunc) strcmp))
+ words = g_slist_prepend (words, word);
pads = g_slist_next (pads);
}
/* arguments */
args = element->arguments;
while (args) {
- argument = (comp_argument *)(args->data);
- word = strstr(argument->name,"::")+2;
- words = g_slist_prepend (words, g_strdup_printf("%s=",word));
- words = g_slist_prepend (words, g_strdup_printf("%s=...",word));
+ argument = (comp_argument *) (args->data);
+ word = strstr (argument->name, "::") + 2;
+ words = g_slist_prepend (words, g_strdup_printf ("%s=", word));
+ words = g_slist_prepend (words, g_strdup_printf ("%s=...", word));
args = g_slist_next (args);
}
}
#include <gst/gst.h>
-GST_DEBUG_CATEGORY_STATIC(debug_compprep);
+GST_DEBUG_CATEGORY_STATIC (debug_compprep);
#define GST_CAT_DEFAULT debug_compprep
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
xmlDocPtr doc;
xmlNodePtr factorynode, padnode, argnode, optionnode;
GList *plugins, *features, *padtemplates;
GstPad *pad;
GstPadTemplate *padtemplate;
GParamSpec **property_specs;
- guint num_properties,i;
+ guint num_properties, i;
setlocale (LC_ALL, "");
- gst_init(&argc,&argv);
- GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD, "gst-compprep application");
+ gst_init (&argc, &argv);
+ GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD,
+ "gst-compprep application");
- doc = xmlNewDoc("1.0");
- doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL);
+ doc = xmlNewDoc ("1.0");
+ doc->xmlRootNode = xmlNewDocNode (doc, NULL, "GST-CompletionRegistry", NULL);
- plugins = g_list_copy(gst_registry_pool_plugin_list());
+ plugins = g_list_copy (gst_registry_pool_plugin_list ());
while (plugins) {
GstPlugin *plugin;
- plugin = (GstPlugin *)(plugins->data);
+ plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
- features = g_list_copy(gst_plugin_get_feature_list(plugin));
+ features = g_list_copy (gst_plugin_get_feature_list (plugin));
while (features) {
GstPluginFeature *feature;
GstElementFactory *factory;
factory = GST_ELEMENT_FACTORY (feature);
factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
- xmlNewChild (factorynode, NULL, "name",
- GST_PLUGIN_FEATURE_NAME(factory));
+ xmlNewChild (factorynode, NULL, "name",
+ GST_PLUGIN_FEATURE_NAME (factory));
- element = gst_element_factory_create(factory,NULL);
- GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME(factory));
+ element = gst_element_factory_create (factory, NULL);
+ GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME (factory));
if (element == NULL) {
- GST_ERROR ("couldn't construct element from factory %s\n",
- gst_object_get_name (GST_OBJECT (factory)));
- return 1;
+ GST_ERROR ("couldn't construct element from factory %s\n",
+ gst_object_get_name (GST_OBJECT (factory)));
+ return 1;
}
/* write out the padtemplates */
padtemplates = factory->padtemplates;
while (padtemplates) {
- padtemplate = (GstPadTemplate *)(padtemplates->data);
- padtemplates = g_list_next (padtemplates);
-
- if (padtemplate->direction == GST_PAD_SRC)
- padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template);
- else if (padtemplate->direction == GST_PAD_SINK)
- padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template);
+ padtemplate = (GstPadTemplate *) (padtemplates->data);
+ padtemplates = g_list_next (padtemplates);
+
+ if (padtemplate->direction == GST_PAD_SRC)
+ padnode =
+ xmlNewChild (factorynode, NULL, "srcpadtemplate",
+ padtemplate->name_template);
+ else if (padtemplate->direction == GST_PAD_SINK)
+ padnode =
+ xmlNewChild (factorynode, NULL, "sinkpadtemplate",
+ padtemplate->name_template);
}
pads = gst_element_get_pad_list (element);
while (pads) {
- pad = (GstPad *)(pads->data);
- pads = g_list_next (pads);
-
- if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
- padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad));
- else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
- padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad));
+ pad = (GstPad *) (pads->data);
+ pads = g_list_next (pads);
+
+ if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
+ padnode =
+ xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME (pad));
+ else if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
+ padnode =
+ xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME (pad));
}
/* write out the args */
- property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
- for (i=0;i<num_properties;i++) {
- GParamSpec *param = property_specs[i];
- argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
- if (param->value_type == GST_TYPE_URI) {
- xmlNewChild (argnode, NULL, "filename", NULL);
- } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
- GEnumValue *values;
- gint j;
-
- values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
- for (j=0;values[j].value_name;j++) {
- gchar *value = g_strdup_printf("%d",values[j].value);
- optionnode = xmlNewChild (argnode, NULL, "option", value);
- xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
- g_free(value);
- }
- }
+ property_specs =
+ g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
+ &num_properties);
+ for (i = 0; i < num_properties; i++) {
+ GParamSpec *param = property_specs[i];
+
+ argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
+ if (param->value_type == GST_TYPE_URI) {
+ xmlNewChild (argnode, NULL, "filename", NULL);
+ } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
+ GEnumValue *values;
+ gint j;
+
+ values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
+ for (j = 0; values[j].value_name; j++) {
+ gchar *value = g_strdup_printf ("%d", values[j].value);
+
+ optionnode = xmlNewChild (argnode, NULL, "option", value);
+ xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
+ g_free (value);
+ }
+ }
}
}
}
#ifdef HAVE_LIBXML2
- xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1);
+ xmlSaveFormatFile (GST_CACHE_DIR "/compreg.xml", doc, 1);
#else
- xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc);
+ xmlSaveFile (GST_CACHE_DIR "/compreg.xml", doc);
#endif
return 0;
#include <locale.h>
static void
-print_caps (const GstCaps *caps, const gchar *pfx)
+print_caps (const GstCaps * caps, const gchar * pfx)
{
char *s, *tmp;
char **v;
s = gst_caps_to_string (caps);
-
+
tmp = g_strdup_printf ("\n %s", pfx);
v = g_strsplit (s, ", ", -1);
g_free (s);
s = g_strjoinv (tmp, v);
g_strfreev (v);
g_free (tmp);
-
+
tmp = g_strdup_printf ("\n%s", pfx);
v = g_strsplit (s, "; ", -1);
g_free (s);
s = g_strjoinv (tmp, v);
g_free (tmp);
g_strfreev (v);
-
+
g_print ("%s%s\n", pfx, s);
- g_free(s);
+ g_free (s);
}
static void
-print_formats (const GstFormat *formats)
+print_formats (const GstFormat * formats)
{
while (formats && *formats) {
const GstFormatDefinition *definition;
definition = gst_format_get_details (*formats);
if (definition)
g_print ("\t\t(%d):\t%s (%s)\n", *formats,
- definition->nick, definition->description);
+ definition->nick, definition->description);
else
g_print ("\t\t(%d):\tUnknown format\n", *formats);
}
static void
-print_query_types (const GstQueryType *types)
+print_query_types (const GstQueryType * types)
{
while (types && *types) {
const GstQueryTypeDefinition *definition;
definition = gst_query_type_get_details (*types);
if (definition)
g_print ("\t\t(%d):\t%s (%s)\n", *types,
- definition->nick, definition->description);
+ definition->nick, definition->description);
else
g_print ("\t\t(%d):\tUnknown query format\n", *types);
}
static void
-print_event_masks (const GstEventMask *masks)
+print_event_masks (const GstEventMask * masks)
{
#ifndef GST_DISABLE_ENUMTYPES
GType event_type;
GType event_flags;
GFlagsClass *flags_class = NULL;
- event_type = gst_event_type_get_type();
+ event_type = gst_event_type_get_type ();
klass = (GEnumClass *) g_type_class_ref (event_type);
while (masks && masks->type) {
switch (masks->type) {
case GST_EVENT_SEEK:
- flags = masks->flags;
- event_flags = gst_seek_type_get_type ();
- flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
- break;
+ flags = masks->flags;
+ event_flags = gst_seek_type_get_type ();
+ flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
+ break;
default:
- break;
+ break;
}
value = g_enum_get_value (klass, masks->type);
GFlagsValue *value;
if (flags & 1) {
- value = g_flags_get_first_value (flags_class, 1 << index);
+ value = g_flags_get_first_value (flags_class, 1 << index);
- if (value)
- g_print ("| %s ", value->value_nick);
- else
- g_print ("| ? ");
+ if (value)
+ g_print ("| %s ", value->value_nick);
+ else
+ g_print ("| ? ");
}
flags >>= 1;
index++;
}
static void
-output_hierarchy (GType type, gint level, gint *maxlevel)
+output_hierarchy (GType type, gint level, gint * maxlevel)
{
GType parent;
gint i;
if (parent)
output_hierarchy (parent, level, maxlevel);
- for (i=1; i<*maxlevel-level; i++)
- g_print (" ");
- if (*maxlevel-level)
+ for (i = 1; i < *maxlevel - level; i++)
+ g_print (" ");
+ if (*maxlevel - level)
g_print (" +----");
g_print ("%s\n", g_type_name (type));
}
static void
-print_element_properties (GstElement *element)
+print_element_properties (GstElement * element)
{
GParamSpec **property_specs;
- gint num_properties,i;
+ gint num_properties, i;
gboolean readable;
const char *string_val;
property_specs = g_object_class_list_properties
- (G_OBJECT_GET_CLASS (element), &num_properties);
- g_print("\nElement Properties:\n");
+ (G_OBJECT_GET_CLASS (element), &num_properties);
+ g_print ("\nElement Properties:\n");
for (i = 0; i < num_properties; i++) {
GValue value = { 0, };
GParamSpec *param = property_specs[i];
+
readable = FALSE;
g_value_init (&value, param->value_type);
readable = TRUE;
}
- g_print(" %-20s: %s\n", g_param_spec_get_name (param),
- g_param_spec_get_blurb (param));
+ g_print (" %-20s: %s\n", g_param_spec_get_name (param),
+ g_param_spec_get_blurb (param));
switch (G_VALUE_TYPE (&value)) {
case G_TYPE_STRING:
- string_val = g_value_get_string (&value);
- g_print ("%-23.23s String. ", "");
- if (readable) {
- if (string_val == NULL)
- g_print ("(Default \"\")");
- else
- g_print ("(Default \"%s\")", g_value_get_string (&value));
- }
- break;
+ string_val = g_value_get_string (&value);
+ g_print ("%-23.23s String. ", "");
+ if (readable) {
+ if (string_val == NULL)
+ g_print ("(Default \"\")");
+ else
+ g_print ("(Default \"%s\")", g_value_get_string (&value));
+ }
+ break;
case G_TYPE_BOOLEAN:
- g_print ("%-23.23s Boolean. ", "");
- if (readable) g_print ("(Default %s)", (g_value_get_boolean (&value) ? "true" : "false"));
- break;
+ g_print ("%-23.23s Boolean. ", "");
+ if (readable)
+ g_print ("(Default %s)",
+ (g_value_get_boolean (&value) ? "true" : "false"));
+ break;
case G_TYPE_ULONG:
{
- GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
- g_print("%-23.23s Unsigned Long. ", "");
- if (readable) g_print("Range: %lu - %lu (Default %lu)",
- pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
- break;
+ GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
+
+ g_print ("%-23.23s Unsigned Long. ", "");
+ if (readable)
+ g_print ("Range: %lu - %lu (Default %lu)",
+ pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
+ break;
}
case G_TYPE_LONG:
{
- GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
- g_print("%-23.23s Long. ", "");
- if (readable) g_print("Range: %ld - %ld (Default %ld)",
- plong->minimum, plong->maximum, g_value_get_long (&value));
- break;
+ GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
+
+ g_print ("%-23.23s Long. ", "");
+ if (readable)
+ g_print ("Range: %ld - %ld (Default %ld)",
+ plong->minimum, plong->maximum, g_value_get_long (&value));
+ break;
}
case G_TYPE_UINT:
{
- GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
- g_print("%-23.23s Unsigned Integer. ", "");
- if (readable) g_print("Range: %u - %u (Default %u)",
- puint->minimum, puint->maximum, g_value_get_uint (&value));
- break;
+ GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
+
+ g_print ("%-23.23s Unsigned Integer. ", "");
+ if (readable)
+ g_print ("Range: %u - %u (Default %u)",
+ puint->minimum, puint->maximum, g_value_get_uint (&value));
+ break;
}
case G_TYPE_INT:
{
- GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
- g_print("%-23.23s Integer. ", "");
- if (readable) g_print("Range: %d - %d (Default %d)",
- pint->minimum, pint->maximum, g_value_get_int (&value));
- break;
+ GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
+
+ g_print ("%-23.23s Integer. ", "");
+ if (readable)
+ g_print ("Range: %d - %d (Default %d)",
+ pint->minimum, pint->maximum, g_value_get_int (&value));
+ break;
}
case G_TYPE_UINT64:
{
- GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
- g_print("%-23.23s Unsigned Integer64. ", "");
- if (readable) g_print("Range: %" G_GUINT64_FORMAT " - %"
- G_GUINT64_FORMAT " (Default %" G_GUINT64_FORMAT ")",
- puint64->minimum, puint64->maximum,
- g_value_get_uint64 (&value));
- break;
+ GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
+
+ g_print ("%-23.23s Unsigned Integer64. ", "");
+ if (readable)
+ g_print ("Range: %" G_GUINT64_FORMAT " - %"
+ G_GUINT64_FORMAT " (Default %" G_GUINT64_FORMAT ")",
+ puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
+ break;
}
case G_TYPE_INT64:
{
- GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
- g_print("%-23.23s Integer64. ", "");
- if (readable) g_print("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " (Default %" G_GINT64_FORMAT ")", pint64->minimum,
- pint64->maximum, g_value_get_int64 (&value));
- break;
+ GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
+
+ g_print ("%-23.23s Integer64. ", "");
+ if (readable)
+ g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
+ " (Default %" G_GINT64_FORMAT ")", pint64->minimum,
+ pint64->maximum, g_value_get_int64 (&value));
+ break;
}
case G_TYPE_FLOAT:
{
- GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
- g_print("%-23.23s Float. Default: %-8.8s %15.7g\n", "", "",
- g_value_get_float (&value));
- g_print("%-23.23s Range: %15.7g - %15.7g", "",
- pfloat->minimum, pfloat->maximum);
- break;
+ GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
+
+ g_print ("%-23.23s Float. Default: %-8.8s %15.7g\n", "", "",
+ g_value_get_float (&value));
+ g_print ("%-23.23s Range: %15.7g - %15.7g", "",
+ pfloat->minimum, pfloat->maximum);
+ break;
}
case G_TYPE_DOUBLE:
{
- GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
- g_print("%-23.23s Double. Default: %-8.8s %15.7g\n", "", "",
- g_value_get_double (&value));
- g_print("%-23.23s Range: %15.7g - %15.7g", "",
- pdouble->minimum, pdouble->maximum);
- break;
+ GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
+
+ g_print ("%-23.23s Double. Default: %-8.8s %15.7g\n", "", "",
+ g_value_get_double (&value));
+ g_print ("%-23.23s Range: %15.7g - %15.7g", "",
+ pdouble->minimum, pdouble->maximum);
+ break;
}
default:
- if (param->value_type == GST_TYPE_URI) {
- g_print("%-23.23s URI", "");
- }
- if (param->value_type == GST_TYPE_CAPS) {
- const GstCaps *caps = gst_value_get_caps (&value);
-
- if (!caps)
- g_print("%-23.23s Caps (NULL)", "");
- else {
- print_caps (caps, " ");
- }
- }
- else if (G_IS_PARAM_SPEC_ENUM (param)) {
- GEnumValue *values;
- guint j = 0;
- gint enum_value;
-
- values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
- enum_value = g_value_get_enum (&value);
-
- while (values[j].value_name) {
- if (values[j].value == enum_value)
- break;
- j++;
- }
-
- g_print ("%-23.23s Enum \"%s\" (default %d, \"%s\")", "",
- g_type_name (G_VALUE_TYPE (&value)),
- enum_value, values[j].value_nick);
-
- j = 0;
- while (values[j].value_name) {
- g_print("\n%-23.23s (%d): \t%s", "",
- values[j].value, values[j].value_nick);
- j++;
- }
- /* g_type_class_unref (ec); */
- }
- else if (G_IS_PARAM_SPEC_FLAGS (param)) {
- GFlagsValue *values;
- guint j = 0;
- gint flags_value;
- GString *flags = NULL;
-
- values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
- flags_value = g_value_get_flags (&value);
-
- while (values[j].value_name) {
- if (values[j].value & flags_value) {
- if (flags) {
- g_string_append_printf (flags, " | %s", values[j].value_nick);
- }
- else {
- flags = g_string_new (values[j].value_nick);
- }
- }
- j++;
- }
-
- g_print("%-23.23s Flags \"%s\" (default %d, \"%s\")", "",
- g_type_name (G_VALUE_TYPE (&value)),
- flags_value, (flags ? flags->str : "(none)"));
-
- j = 0;
- while (values[j].value_name) {
- g_print("\n%-23.23s (%d): \t%s", "",
- values[j].value, values[j].value_nick);
- j++;
- }
-
- if (flags)
- g_string_free (flags, TRUE);
- }
- else if (G_IS_PARAM_SPEC_OBJECT (param)) {
- g_print("%-23.23s Object of type \"%s\"", "",
- g_type_name(param->value_type));
- }
- else {
- g_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
- g_type_name(param->value_type));
- }
- break;
+ if (param->value_type == GST_TYPE_URI) {
+ g_print ("%-23.23s URI", "");
+ }
+ if (param->value_type == GST_TYPE_CAPS) {
+ const GstCaps *caps = gst_value_get_caps (&value);
+
+ if (!caps)
+ g_print ("%-23.23s Caps (NULL)", "");
+ else {
+ print_caps (caps, " ");
+ }
+ } else if (G_IS_PARAM_SPEC_ENUM (param)) {
+ GEnumValue *values;
+ guint j = 0;
+ gint enum_value;
+
+ values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
+ enum_value = g_value_get_enum (&value);
+
+ while (values[j].value_name) {
+ if (values[j].value == enum_value)
+ break;
+ j++;
+ }
+
+ g_print ("%-23.23s Enum \"%s\" (default %d, \"%s\")", "",
+ g_type_name (G_VALUE_TYPE (&value)),
+ enum_value, values[j].value_nick);
+
+ j = 0;
+ while (values[j].value_name) {
+ g_print ("\n%-23.23s (%d): \t%s", "",
+ values[j].value, values[j].value_nick);
+ j++;
+ }
+ /* g_type_class_unref (ec); */
+ } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
+ GFlagsValue *values;
+ guint j = 0;
+ gint flags_value;
+ GString *flags = NULL;
+
+ values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
+ flags_value = g_value_get_flags (&value);
+
+ while (values[j].value_name) {
+ if (values[j].value & flags_value) {
+ if (flags) {
+ g_string_append_printf (flags, " | %s", values[j].value_nick);
+ } else {
+ flags = g_string_new (values[j].value_nick);
+ }
+ }
+ j++;
+ }
+
+ g_print ("%-23.23s Flags \"%s\" (default %d, \"%s\")", "",
+ g_type_name (G_VALUE_TYPE (&value)),
+ flags_value, (flags ? flags->str : "(none)"));
+
+ j = 0;
+ while (values[j].value_name) {
+ g_print ("\n%-23.23s (%d): \t%s", "",
+ values[j].value, values[j].value_nick);
+ j++;
+ }
+
+ if (flags)
+ g_string_free (flags, TRUE);
+ } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
+ g_print ("%-23.23s Object of type \"%s\"", "",
+ g_type_name (param->value_type));
+ } else {
+ g_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type,
+ g_type_name (param->value_type));
+ }
+ break;
}
if (!readable)
g_print (" Write only\n");
static char *
get_rank_name (gint rank)
{
- switch(rank){
+ switch (rank) {
case GST_RANK_NONE:
return "none";
case GST_RANK_MARGINAL:
}
static gint
-print_element_info (GstElementFactory *factory)
+print_element_info (GstElementFactory * factory)
{
GstElement *element;
GstObjectClass *gstobject_class;
gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
g_print ("Factory Details:\n");
- g_print (" Long name:\t%s\n", factory->details.longname);
- g_print (" Class:\t%s\n", factory->details.klass);
+ g_print (" Long name:\t%s\n", factory->details.longname);
+ g_print (" Class:\t%s\n", factory->details.klass);
g_print (" Description:\t%s\n", factory->details.description);
- g_print (" Author(s):\t%s\n", factory->details.author);
- g_print (" Rank:\t\t%s\n", get_rank_name(GST_PLUGIN_FEATURE(factory)->rank));
+ g_print (" Author(s):\t%s\n", factory->details.author);
+ g_print (" Rank:\t\t%s\n",
+ get_rank_name (GST_PLUGIN_FEATURE (factory)->rank));
g_print ("\n");
output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
pads = factory->padtemplates;
while (pads) {
- padtemplate = (GstPadTemplate*)(pads->data);
- pads = g_list_next(pads);
+ padtemplate = (GstPadTemplate *) (pads->data);
+ pads = g_list_next (pads);
if (padtemplate->direction == GST_PAD_SRC)
- g_print (" SRC template: '%s'\n", padtemplate->name_template);
+ g_print (" SRC template: '%s'\n", padtemplate->name_template);
else if (padtemplate->direction == GST_PAD_SINK)
- g_print (" SINK template: '%s'\n", padtemplate->name_template);
+ g_print (" SINK template: '%s'\n", padtemplate->name_template);
else
- g_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
+ g_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template);
if (padtemplate->presence == GST_PAD_ALWAYS)
- g_print (" Availability: Always\n");
+ g_print (" Availability: Always\n");
else if (padtemplate->presence == GST_PAD_SOMETIMES)
- g_print (" Availability: Sometimes\n");
+ g_print (" Availability: Sometimes\n");
else if (padtemplate->presence == GST_PAD_REQUEST) {
- g_print (" Availability: On request\n");
- g_print (" Has request_new_pad() function: %s\n",
- GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
- }
- else
- g_print (" Availability: UNKNOWN!!!\n");
+ g_print (" Availability: On request\n");
+ g_print (" Has request_new_pad() function: %s\n",
+ GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
+ } else
+ g_print (" Availability: UNKNOWN!!!\n");
if (padtemplate->caps) {
- g_print (" Capabilities:\n");
- print_caps (padtemplate->caps, " ");
+ g_print (" Capabilities:\n");
+ print_caps (padtemplate->caps, " ");
}
g_print ("\n");
have_flags = TRUE;
}
if (GST_FLAG_IS_SET (element, GST_ELEMENT_EVENT_AWARE)) {
- g_print(" GST_ELEMENT_EVENT_AWARE\n");
+ g_print (" GST_ELEMENT_EVENT_AWARE\n");
have_flags = TRUE;
}
if (!have_flags)
- g_print(" no flags set\n");
+ g_print (" no flags set\n");
if (GST_IS_BIN (element)) {
g_print ("\nBin Flags:\n");
if (element->loopfunc)
g_print (" loopfunc()-based element: %s\n",
- GST_DEBUG_FUNCPTR_NAME (element->loopfunc));
+ GST_DEBUG_FUNCPTR_NAME (element->loopfunc));
else
g_print (" No loopfunc(), must be chain-based or not configured yet\n");
g_print (" Has change_state() function: %s\n",
- GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
+ GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
#ifndef GST_DISABLE_LOADSAVE
g_print (" Has custom save_thyself() function: %s\n",
- GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
+ GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
g_print (" Has custom restore_thyself() function: %s\n",
- GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
+ GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
#endif
have_flags = FALSE;
clock = gst_element_get_clock (element);
if (clock)
- g_print (" element provides a clock: %s\n", GST_OBJECT_NAME(clock));
+ g_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock));
else
g_print (" element is supposed to provide a clock but returned NULL\n");
have_flags = TRUE;
if (!have_flags) {
g_print (" none\n");
}
-
#ifndef GST_DISABLE_INDEX
g_print ("\nIndexing capabilities:\n");
if (gst_element_is_indexable (element)) {
g_print (" element can do indexing\n");
- }
- else {
+ } else {
g_print (" none\n");
}
#endif
g_print ("\nPads:\n");
if (element->numpads) {
const GList *pads;
+
pads = gst_element_get_pad_list (element);
while (pads) {
pad = GST_PAD (pads->data);
realpad = GST_PAD_REALIZE (pad);
if (gst_pad_get_direction (pad) == GST_PAD_SRC)
- g_print (" SRC: '%s'", gst_pad_get_name (pad));
+ g_print (" SRC: '%s'", gst_pad_get_name (pad));
else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
- g_print (" SINK: '%s'", gst_pad_get_name (pad));
+ g_print (" SINK: '%s'", gst_pad_get_name (pad));
else
- g_print (" UNKNOWN!!!: '%s'\n", gst_pad_get_name (pad));
+ g_print (" UNKNOWN!!!: '%s'\n", gst_pad_get_name (pad));
if (GST_IS_GHOST_PAD (pad))
- g_print (", ghost of real pad %s:%s\n", GST_DEBUG_PAD_NAME (realpad));
+ g_print (", ghost of real pad %s:%s\n", GST_DEBUG_PAD_NAME (realpad));
else
- g_print ("\n");
+ g_print ("\n");
g_print (" Implementation:\n");
if (realpad->chainfunc)
- g_print (" Has chainfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc));
+ g_print (" Has chainfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc));
if (realpad->getfunc)
- g_print (" Has getfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (realpad->getfunc));
+ g_print (" Has getfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->getfunc));
if (realpad->formatsfunc != gst_pad_get_formats_default) {
- g_print (" Supports seeking/conversion/query formats:\n");
- print_formats (gst_pad_get_formats (GST_PAD (realpad)));
+ g_print (" Supports seeking/conversion/query formats:\n");
+ print_formats (gst_pad_get_formats (GST_PAD (realpad)));
}
if (realpad->convertfunc != gst_pad_convert_default)
- g_print (" Has custom convertfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
+ g_print (" Has custom convertfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
if (realpad->eventfunc != gst_pad_event_default)
- g_print (" Has custom eventfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
+ g_print (" Has custom eventfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) {
- g_print (" Provides event masks:\n");
- print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)));
+ g_print (" Provides event masks:\n");
+ print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)));
}
if (realpad->queryfunc != gst_pad_query_default)
- g_print (" Has custom queryfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
+ g_print (" Has custom queryfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
if (realpad->querytypefunc != gst_pad_get_query_types_default) {
- g_print (" Provides query types:\n");
- print_query_types (gst_pad_get_query_types (GST_PAD (realpad)));
+ g_print (" Provides query types:\n");
+ print_query_types (gst_pad_get_query_types (GST_PAD (realpad)));
}
if (realpad->intlinkfunc != gst_pad_get_internal_links_default)
- g_print (" Has custom intconnfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc));
+ g_print (" Has custom intconnfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->intlinkfunc));
if (realpad->bufferallocfunc)
- g_print (" Has bufferallocfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc));
+ g_print (" Has bufferallocfunc(): %s\n",
+ GST_DEBUG_FUNCPTR_NAME (realpad->bufferallocfunc));
if (pad->padtemplate)
- g_print (" Pad Template: '%s'\n",
- pad->padtemplate->name_template);
+ g_print (" Pad Template: '%s'\n", pad->padtemplate->name_template);
if (realpad->caps) {
- g_print (" Capabilities:\n");
- print_caps (realpad->caps, " ");
+ g_print (" Capabilities:\n");
+ print_caps (realpad->caps, " ");
}
}
} else
/* Dynamic Parameters block */
{
- GstDParamManager* dpman;
- GParamSpec** specs;
+ GstDParamManager *dpman;
+ GParamSpec **specs;
gint x;
g_print ("\nDynamic Parameters:\n");
- if((dpman = gst_dpman_get_manager (element))) {
+ if ((dpman = gst_dpman_get_manager (element))) {
specs = gst_dpman_list_dparam_specs (dpman);
for (x = 0; specs[x] != NULL; x++) {
- g_print (" %-20.20s: ", g_param_spec_get_name (specs[x]));
-
- switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) {
- case G_TYPE_INT64:
- g_print ("64 Bit Integer (Default %" G_GINT64_FORMAT ", Range %"
- G_GINT64_FORMAT " -> %" G_GINT64_FORMAT ")",
- ((GParamSpecInt64 *) specs[x])->default_value,
- ((GParamSpecInt64 *) specs[x])->minimum,
- ((GParamSpecInt64 *) specs[x])->maximum);
- break;
- case G_TYPE_INT:
- g_print ("Integer (Default %d, Range %d -> %d)",
- ((GParamSpecInt *) specs[x])->default_value,
- ((GParamSpecInt *) specs[x])->minimum,
- ((GParamSpecInt *) specs[x])->maximum);
- break;
- case G_TYPE_FLOAT:
- g_print ("Float. Default: %-8.8s %15.7g\n", "",
- ((GParamSpecFloat *) specs[x])->default_value);
- g_print ("%-23.23s Range: %15.7g - %15.7g", "",
- ((GParamSpecFloat *) specs[x])->minimum,
- ((GParamSpecFloat *) specs[x])->maximum);
- break;
- case G_TYPE_DOUBLE:
- g_print ("Double. Default: %-8.8s %15.7g\n", "",
- ((GParamSpecDouble *) specs[x])->default_value);
- g_print ("%-23.23s Range: %15.7g - %15.7g", "",
- ((GParamSpecDouble *) specs[x])->minimum,
- ((GParamSpecDouble *) specs[x])->maximum);
- break;
- default: g_print ("unknown %ld", G_PARAM_SPEC_VALUE_TYPE (specs[x]));
- }
- g_print ("\n");
+ g_print (" %-20.20s: ", g_param_spec_get_name (specs[x]));
+
+ switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) {
+ case G_TYPE_INT64:
+ g_print ("64 Bit Integer (Default %" G_GINT64_FORMAT ", Range %"
+ G_GINT64_FORMAT " -> %" G_GINT64_FORMAT ")",
+ ((GParamSpecInt64 *) specs[x])->default_value,
+ ((GParamSpecInt64 *) specs[x])->minimum,
+ ((GParamSpecInt64 *) specs[x])->maximum);
+ break;
+ case G_TYPE_INT:
+ g_print ("Integer (Default %d, Range %d -> %d)",
+ ((GParamSpecInt *) specs[x])->default_value,
+ ((GParamSpecInt *) specs[x])->minimum,
+ ((GParamSpecInt *) specs[x])->maximum);
+ break;
+ case G_TYPE_FLOAT:
+ g_print ("Float. Default: %-8.8s %15.7g\n", "",
+ ((GParamSpecFloat *) specs[x])->default_value);
+ g_print ("%-23.23s Range: %15.7g - %15.7g", "",
+ ((GParamSpecFloat *) specs[x])->minimum,
+ ((GParamSpecFloat *) specs[x])->maximum);
+ break;
+ case G_TYPE_DOUBLE:
+ g_print ("Double. Default: %-8.8s %15.7g\n", "",
+ ((GParamSpecDouble *) specs[x])->default_value);
+ g_print ("%-23.23s Range: %15.7g - %15.7g", "",
+ ((GParamSpecDouble *) specs[x])->minimum,
+ ((GParamSpecDouble *) specs[x])->maximum);
+ break;
+ default:
+ g_print ("unknown %ld", G_PARAM_SPEC_VALUE_TYPE (specs[x]));
+ }
+ g_print ("\n");
}
g_free (specs);
- }
- else {
+ } else {
g_print (" none\n");
}
}
gint counted = 0;
if (k == 0)
- g_print ("\nElement Signals:\n");
+ g_print ("\nElement Signals:\n");
else
- g_print ("\nElement Actions:\n");
+ g_print ("\nElement Actions:\n");
- for(type = G_OBJECT_TYPE(element); type; type = g_type_parent(type)){
- signals = g_signal_list_ids (type, &nsignals);
+ for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) {
+ signals = g_signal_list_ids (type, &nsignals);
for (i = 0; i < nsignals; i++) {
gint n_params;
const GType *param_types;
gint j;
- query = g_new0 (GSignalQuery,1);
+ query = g_new0 (GSignalQuery, 1);
g_signal_query (signals[i], query);
if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
- (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
+ (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
n_params = query->n_params;
return_type = query->return_type;
param_types = query->param_types;
g_print (" \"%s\" :\t %s user_function (%s* object",
- query->signal_name, g_type_name (return_type),
- g_type_name (type));
+ query->signal_name, g_type_name (return_type),
+ g_type_name (type));
for (j = 0; j < n_params; j++) {
- g_print (",\n \t\t\t\t%s arg%d", g_type_name(param_types[j]), j);
+ g_print (",\n \t\t\t\t%s arg%d", g_type_name (param_types[j]),
+ j);
}
if (k == 0)
g_print (",\n \t\t\t\tgpointer user_data);\n");
g_free (query);
}
}
- if (counted == 0) g_print (" none\n");
+ if (counted == 0)
+ g_print (" none\n");
}
}
g_print (" none\n");
else {
while (children) {
- child = GST_ELEMENT (children->data);
- children = g_list_next (children);
+ child = GST_ELEMENT (children->data);
+ children = g_list_next (children);
- g_print (" %s\n", GST_ELEMENT_NAME (child));
+ g_print (" %s\n", GST_ELEMENT_NAME (child));
}
}
}
{
GList *plugins;
- plugins = gst_registry_pool_plugin_list();
+ plugins = gst_registry_pool_plugin_list ();
while (plugins) {
GList *features;
GstPlugin *plugin;
- plugin = (GstPlugin*)(plugins->data);
+ plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
features = gst_plugin_get_feature_list (plugin);
feature = GST_PLUGIN_FEATURE (features->data);
if (GST_IS_ELEMENT_FACTORY (feature)) {
- GstElementFactory *factory;
+ GstElementFactory *factory;
- factory = GST_ELEMENT_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory) ,factory->details.longname);
+ factory = GST_ELEMENT_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->details.longname);
}
#ifndef GST_DISABLE_INDEX
else if (GST_IS_INDEX_FACTORY (feature)) {
- GstIndexFactory *factory;
+ GstIndexFactory *factory;
- factory = GST_INDEX_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
+ factory = GST_INDEX_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
}
#endif
else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
- GstTypeFindFactory *factory;
+ GstTypeFindFactory *factory;
- factory = GST_TYPE_FIND_FACTORY (feature);
- g_print ("%s: %s: ", plugin->desc.name, gst_plugin_feature_get_name (feature));
- if (factory->extensions) {
+ factory = GST_TYPE_FIND_FACTORY (feature);
+ g_print ("%s: %s: ", plugin->desc.name,
+ gst_plugin_feature_get_name (feature));
+ if (factory->extensions) {
guint i = 0;
+
while (factory->extensions[i]) {
g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
i++;
}
- g_print ("\n");
+ g_print ("\n");
} else {
- g_print ("no extensions\n");
- }
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
- GstSchedulerFactory *factory;
-
- factory = GST_SCHEDULER_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
- }
- else {
- g_print ("%s: %s (%s)\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (feature),
- g_type_name (G_OBJECT_TYPE (feature)));
+ g_print ("no extensions\n");
+ }
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ GstSchedulerFactory *factory;
+
+ factory = GST_SCHEDULER_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
+ } else {
+ g_print ("%s: %s (%s)\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (feature),
+ g_type_name (G_OBJECT_TYPE (feature)));
}
features = g_list_next (features);
}
static void
-print_plugin_info (GstPlugin *plugin)
+print_plugin_info (GstPlugin * plugin)
{
GList *features;
gint num_features = 0;
gint num_other = 0;
g_print ("Plugin Details:\n");
- g_print (" Name:\t\t%s\n", plugin->desc.name);
- g_print (" Description:\t%s\n", plugin->desc.description);
- g_print (" Filename:\t%s\n", plugin->filename);
- g_print (" Version:\t%s\n", plugin->desc.version);
- g_print (" License:\t%s\n", plugin->desc.license);
- g_print (" Package:\t%s\n", plugin->desc.package);
- g_print (" Origin URL:\t%s\n", plugin->desc.origin);
+ g_print (" Name:\t\t%s\n", plugin->desc.name);
+ g_print (" Description:\t%s\n", plugin->desc.description);
+ g_print (" Filename:\t%s\n", plugin->filename);
+ g_print (" Version:\t%s\n", plugin->desc.version);
+ g_print (" License:\t%s\n", plugin->desc.license);
+ g_print (" Package:\t%s\n", plugin->desc.package);
+ g_print (" Origin URL:\t%s\n", plugin->desc.origin);
g_print ("\n");
features = gst_plugin_get_feature_list (plugin);
factory = GST_ELEMENT_FACTORY (feature);
g_print (" %s: %s\n", GST_OBJECT_NAME (factory),
- factory->details.longname);
+ factory->details.longname);
num_elements++;
}
#ifndef GST_DISABLE_INDEX
factory = GST_TYPE_FIND_FACTORY (feature);
if (factory->extensions) {
guint i = 0;
+
g_print ("%s type: ", plugin->desc.name);
while (factory->extensions[i]) {
g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
g_print ("%s type: N/A\n", plugin->desc.name);
num_types++;
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
GstSchedulerFactory *factory;
factory = GST_SCHEDULER_FACTORY (feature);
g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
num_schedulers++;
- }
- else {
+ } else {
g_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
- g_type_name (G_OBJECT_TYPE (feature)));
+ g_type_name (G_OBJECT_TYPE (feature)));
num_other++;
}
num_features++;
GstPlugin *plugin;
gchar *so;
struct poptOption options[] = {
- {"gst-inspect-plugin", 'p', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0,
- N_("Show plugin details"), NULL},
- {"gst-inspect-scheduler", 's', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0,
- N_("Show scheduler details"), NULL},
+ {"gst-inspect-plugin", 'p', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, 0,
+ N_("Show plugin details"), NULL},
+ {"gst-inspect-scheduler", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ 0,
+ N_("Show scheduler details"), NULL},
POPT_TABLEEND
};
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gst_init_with_popt_table (&argc, &argv, options);
/* if no arguments, print out list of elements */
if (argc == 1) {
- print_element_list();
+ print_element_list ();
- /* else we try to get a factory */
+ /* else we try to get a factory */
} else {
/* first check for help */
if (strstr (argv[1], "-help")) {
- g_print ("Usage: %s\t\t\tList all registered elements\n",argv[0]);
- g_print (" %s element-name\tShow element details\n",argv[0]);
+ g_print ("Usage: %s\t\t\tList all registered elements\n", argv[0]);
+ g_print (" %s element-name\tShow element details\n", argv[0]);
g_print (" %s plugin-name[.so]\tShow information about plugin\n",
- argv[0]);
+ argv[0]);
return 0;
}
/* only search for a factory if there's not a '.so' */
- if (! strstr (argv[1], ".so")) {
+ if (!strstr (argv[1], ".so")) {
factory = gst_element_factory_find (argv[1]);
/* if there's a factory, print out the info */
if (factory)
- return print_element_info (factory);
+ return print_element_info (factory);
else {
- GstPluginFeature* feature;
-
- /* FIXME implement other pretty print function for these */
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_SCHEDULER_FACTORY);
- if (feature) {
- g_print ("%s: a scheduler\n", argv[1]);
- return 0;
- }
+ GstPluginFeature *feature;
+
+ /* FIXME implement other pretty print function for these */
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_SCHEDULER_FACTORY);
+ if (feature) {
+ g_print ("%s: a scheduler\n", argv[1]);
+ return 0;
+ }
#ifndef GST_DISABLE_INDEX
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_INDEX_FACTORY);
- if (feature) {
- g_print ("%s: an index\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_INDEX_FACTORY);
+ if (feature) {
+ g_print ("%s: an index\n", argv[1]);
+ return 0;
+ }
#endif
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_TYPE_FIND_FACTORY);
- if (feature) {
- g_print ("%s: a typefind function\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_TYPE_FIND_FACTORY);
+ if (feature) {
+ g_print ("%s: a typefind function\n", argv[1]);
+ return 0;
+ }
#ifndef GST_DISABLE_URI
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_URI_HANDLER);
- if (feature) {
- g_print ("%s: an uri handler\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_URI_HANDLER);
+ if (feature) {
+ g_print ("%s: an uri handler\n", argv[1]);
+ return 0;
+ }
#endif
}
} else {
/* strip the .so */
- so = strstr(argv[1],".so");
+ so = strstr (argv[1], ".so");
so[0] = '\0';
}
print_plugin_info (plugin);
} else {
- g_print("no such element or plugin '%s'\n", argv[1]);
+ g_print ("no such element or plugin '%s'\n", argv[1]);
return -1;
}
}
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
-#include <locale.h> /* for LC_ALL */
+#include <locale.h> /* for LC_ALL */
#include "gst/gst-i18n-app.h"
#include <gst/gst.h>
iterations++;
g_get_current_time (&tfnow);
- diff = GST_TIMEVAL_TO_TIME (tfnow) -
- GST_TIMEVAL_TO_TIME (tfthen);
+ diff = GST_TIMEVAL_TO_TIME (tfnow) - GST_TIMEVAL_TO_TIME (tfthen);
- sum += diff;
+ sum += diff;
min = MIN (min, diff);
max = MAX (max, diff);
- if (!busy || caught_intr || (max_iterations>0 && iterations>=max_iterations)) {
+ if (!busy || caught_intr || (max_iterations > 0
+ && iterations >= max_iterations)) {
gst_main_quit ();
- g_print (_("Execution ended after %" G_GUINT64_FORMAT " iterations (sum %" G_GUINT64_FORMAT " ns, average %" G_GUINT64_FORMAT " ns, min %" G_GUINT64_FORMAT " ns, max %" G_GUINT64_FORMAT " ns).\n"),
- iterations, sum, sum/iterations, min, max);
+ g_print (_("Execution ended after %" G_GUINT64_FORMAT " iterations (sum %"
+ G_GUINT64_FORMAT " ns, average %" G_GUINT64_FORMAT " ns, min %"
+ G_GUINT64_FORMAT " ns, max %" G_GUINT64_FORMAT " ns).\n"),
+ iterations, sum, sum / iterations, min, max);
}
return busy;
}
#ifndef GST_DISABLE_LOADSAVE
-static GstElement*
-xmllaunch_parse_cmdline (const gchar **argv)
+static GstElement *
+xmllaunch_parse_cmdline (const gchar ** argv)
{
GstElement *pipeline = NULL, *e;
GstXML *xml;
gchar *element, *property, *value;
GList *l;
gint i = 0;
-
+
if (!(arg = argv[0])) {
- g_print (_("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
+ g_print (_
+ ("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
exit (1);
}
-
+
xml = gst_xml_new ();
- err = gst_xml_parse_file(xml, arg, NULL);
-
+ err = gst_xml_parse_file (xml, arg, NULL);
+
if (err != TRUE) {
fprintf (stderr, _("ERROR: parse of xml file '%s' failed.\n"), arg);
exit (1);
}
-
+
l = gst_xml_get_topelements (xml);
if (!l) {
- fprintf (stderr, _("ERROR: no toplevel pipeline element in file '%s'.\n"), arg);
+ fprintf (stderr, _("ERROR: no toplevel pipeline element in file '%s'.\n"),
+ arg);
exit (1);
}
-
+
if (l->next)
- fprintf (stderr, _("WARNING: only one toplevel element is supported at this time."));
-
+ fprintf (stderr,
+ _("WARNING: only one toplevel element is supported at this time."));
+
pipeline = GST_ELEMENT (l->data);
-
+
while ((arg = argv[++i])) {
element = g_strdup (arg);
property = strchr (element, '.');
value = strchr (element, '=');
-
+
if (!(element < property && property < value)) {
- fprintf (stderr, _("ERROR: could not parse command line argument %d: %s.\n"), i, element);
+ fprintf (stderr,
+ _("ERROR: could not parse command line argument %d: %s.\n"), i,
+ element);
g_free (element);
exit (1);
}
-
+
*property++ = '\0';
*value++ = '\0';
-
+
e = gst_bin_get_by_name (GST_BIN (pipeline), element);
if (!e) {
fprintf (stderr, _("WARNING: element named '%s' not found.\n"), element);
}
g_free (element);
}
-
+
if (!l)
return NULL;
else
#endif
#ifndef USE_SIGINFO
-static void
+static void
fault_handler_sighandler (int signum)
{
fault_restore ();
break;
}
- fault_spin();
+ fault_spin ();
}
#else
-static void
-fault_handler_sigaction (int signum, siginfo_t *si, void *misc)
+static void
+fault_handler_sigaction (int signum, siginfo_t * si, void *misc)
{
fault_restore ();
break;
}
- fault_spin();
+ fault_spin ();
}
#endif
/* FIXME how do we know if we were run by libtool? */
g_print ("Spinning. Please run 'gdb gst-launch %d' to continue debugging, "
- "Ctrl-C to quit, or Ctrl-\\ to dump core.\n",
- (gint) getpid ());
- while (spinning) g_usleep (1000000);
+ "Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ());
+ while (spinning)
+ g_usleep (1000000);
}
-static void
+static void
fault_restore (void)
{
struct sigaction action;
sigaction (SIGQUIT, &action, NULL);
}
-static void
+static void
fault_setup (void)
{
struct sigaction action;
}
static void
-print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
+print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
for (i = 0; i < count; i++) {
gchar *str;
-
+
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
- str = g_strdup_value_contents (
- gst_tag_list_get_value_index (list, tag, i));
+ str =
+ g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
-
+
if (i == 0) {
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
} else {
}
}
static void
-found_tag (GObject *pipeline, GstElement *source, GstTagList *tags)
+found_tag (GObject * pipeline, GstElement * source, GstTagList * tags)
{
g_print (_("FOUND TAG : found by element \"%s\".\n"),
- GST_STR_NULL (GST_ELEMENT_NAME (source)));
+ GST_STR_NULL (GST_ELEMENT_NAME (source)));
gst_tag_list_foreach (tags, print_tag, NULL);
}
{
g_print ("Caught interrupt.\n");
- sigint_restore();
+ sigint_restore ();
caught_intr = TRUE;
}
sigaction (SIGINT, &action, NULL);
}
-static void
+static void
sigint_restore (void)
{
struct sigaction action;
}
static void
-play_signal_setup(void)
+play_signal_setup (void)
{
struct sigaction action;
}
int
-main(int argc, char *argv[])
+main (int argc, char *argv[])
{
gint i, j;
+
/* options */
gboolean verbose = FALSE;
gboolean tags = FALSE;
gchar *savefile = NULL;
gchar *exclude_args = NULL;
struct poptOption options[] = {
- {"tags", 't', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &tags, 0,
- N_("Output tags (also known as metadata)"), NULL},
- {"verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
- N_("Output status information and property notifications"), NULL},
- {"exclude", 'X', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &exclude_args, 0,
- N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")},
+ {"tags", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &tags, 0,
+ N_("Output tags (also known as metadata)"), NULL},
+ {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
+ N_("Output status information and property notifications"), NULL},
+ {"exclude", 'X', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &exclude_args, 0,
+ N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")},
#ifndef GST_DISABLE_LOADSAVE
- {"output", 'o', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &savefile, 0,
- N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")},
+ {"output", 'o', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &savefile, 0,
+ N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")},
#endif
- {"no-fault", 'f', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &no_fault, 0,
- N_("Do not install a fault handler"), NULL},
- {"trace", 'T', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &trace, 0,
- N_("Print alloc trace (if enabled at compile time)"), NULL},
- {"iterations",'i',POPT_ARG_INT|POPT_ARGFLAG_STRIP, &max_iterations, 0,
- N_("Number of times to iterate pipeline"), NULL},
+ {"no-fault", 'f', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &no_fault, 0,
+ N_("Do not install a fault handler"), NULL},
+ {"trace", 'T', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &trace, 0,
+ N_("Print alloc trace (if enabled at compile time)"), NULL},
+ {"iterations", 'i', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &max_iterations, 0,
+ N_("Number of times to iterate pipeline"), NULL},
POPT_TABLEEND
};
GError *error = NULL;
gint res = 0;
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE);
for (i = 1; i < argc; i++) {
if (*(argv[i]) == '-') {
if (strlen (argv[i]) == 2) {
- gchar *c = argv[i];
- c++;
- if (*c == 'X' || *c == 'o') {
+ gchar *c = argv[i];
+
+ c++;
+ if (*c == 'X' || *c == 'o') {
i++;
}
}
argc = j;
if (!no_fault)
- fault_setup();
+ fault_setup ();
+
+ sigint_setup ();
+ play_signal_setup ();
- sigint_setup();
- play_signal_setup();
-
if (trace) {
- if (!gst_alloc_trace_available()) {
+ if (!gst_alloc_trace_available ()) {
g_warning ("Trace not available (recompile with trace enabled).");
}
gst_alloc_trace_print_all ();
}
/* make a null-terminated version of argv */
- argvn = g_new0 (char*, argc);
- memcpy (argvn, argv+1, sizeof (char*) * (argc-1));
+ argvn = g_new0 (char *, argc);
+ memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
#ifndef GST_DISABLE_LOADSAVE
if (strstr (argv[0], "gst-xmllaunch")) {
- pipeline = xmllaunch_parse_cmdline ((const gchar**)argvn);
- }
- else
+ pipeline = xmllaunch_parse_cmdline ((const gchar **) argvn);
+ } else
#endif
{
- pipeline = (GstElement*) gst_parse_launchv ((const gchar**)argvn, &error);
+ pipeline =
+ (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
}
g_free (argvn);
if (!pipeline) {
if (error) {
- fprintf(stderr, _("ERROR: pipeline could not be constructed: %s.\n"),
- error->message);
+ fprintf (stderr, _("ERROR: pipeline could not be constructed: %s.\n"),
+ error->message);
g_error_free (error);
} else {
- fprintf(stderr, _("ERROR: pipeline could not be constructed.\n"));
+ fprintf (stderr, _("ERROR: pipeline could not be constructed.\n"));
}
- exit(1);
+ exit (1);
} else if (error) {
- fprintf(stderr, _("WARNING: erroneous pipeline: %s\n"), error->message);
- fprintf(stderr, _(" Trying to run anyway.\n"));
+ fprintf (stderr, _("WARNING: erroneous pipeline: %s\n"), error->message);
+ fprintf (stderr, _(" Trying to run anyway.\n"));
g_error_free (error);
}
-
+
if (verbose) {
- gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL;
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), exclude_list);
+ gchar **exclude_list =
+ exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL;
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), exclude_list);
}
if (tags) {
g_signal_connect (pipeline, "found-tag", G_CALLBACK (found_tag), NULL);
}
- g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
-
+ g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
+ NULL);
+
#ifndef GST_DISABLE_LOADSAVE
if (savefile) {
gst_xml_write_file (GST_ELEMENT (pipeline), fopen (savefile, "w"));
}
#endif
-
+
if (!savefile) {
-
+
if (!GST_IS_BIN (pipeline)) {
GstElement *real_pipeline = gst_element_factory_make ("pipeline", NULL);
+
if (real_pipeline == NULL) {
- fprintf(stderr, _("ERROR: the 'pipeline' element wasn't found.\n"));
- exit(1);
+ fprintf (stderr, _("ERROR: the 'pipeline' element wasn't found.\n"));
+ exit (1);
}
gst_bin_add (GST_BIN (real_pipeline), pipeline);
pipeline = real_pipeline;
}
- fprintf(stderr, _("RUNNING pipeline ...\n"));
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
- fprintf(stderr, _("ERROR: pipeline doesn't want to play.\n"));
+ fprintf (stderr, _("RUNNING pipeline ...\n"));
+ if (gst_element_set_state (pipeline,
+ GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+ fprintf (stderr, _("ERROR: pipeline doesn't want to play.\n"));
res = -1;
goto end;
}
s_clock = gst_bin_get_clock (GST_BIN (pipeline));
if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_SCHEDULABLE)) {
- g_idle_add (idle_func, pipeline);
- gst_main ();
+ g_idle_add (idle_func, pipeline);
+ gst_main ();
} else {
- g_print ("Waiting for the state change... ");
- gst_element_wait_state_change (pipeline);
- g_print ("got the state change.\n");
+ g_print ("Waiting for the state change... ");
+ gst_element_wait_state_change (pipeline);
+ g_print ("got the state change.\n");
}
gst_element_set_state (pipeline, GST_STATE_NULL);
iterations++;
g_get_current_time (&tfnow);
- diff = GST_TIMEVAL_TO_TIME (tfnow) -
- GST_TIMEVAL_TO_TIME (tfthen);
+ diff = GST_TIMEVAL_TO_TIME (tfnow) - GST_TIMEVAL_TO_TIME (tfthen);
- sum += diff;
+ sum += diff;
min = MIN (min, diff);
max = MAX (max, diff);
if (!busy) {
gst_main_quit ();
/*
- g_print ("execution ended after %llu iterations (sum %llu ns, average %llu ns, min %llu ns, max %llu ns)\n",
- iterations, sum, sum/iterations, min, max);
- */
+ g_print ("execution ended after %llu iterations (sum %llu ns, average %llu ns, min %llu ns, max %llu ns)\n",
+ iterations, sum, sum/iterations, min, max);
+ */
}
return busy;
gboolean verbose = FALSE;
gchar *exclude_args = NULL;
struct poptOption options[] = {
- {"verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
- "do not output status information", NULL},
+ {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
+ "do not output status information", NULL},
POPT_TABLEEND
};
GstElement *md5sink;
gchar *md5string = g_malloc0 (33);
- free (malloc (8)); /* -lefence */
+ free (malloc (8)); /* -lefence */
setlocale (LC_ALL, "");
/* Check if we have an element already that is called md5sink0
in the pipeline; if not, add one */
- pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error);
+ pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
if (!pipeline) {
- if (error)
- {
+ if (error) {
g_warning ("pipeline could not be constructed: %s\n", error->message);
g_error_free (error);
- }
- else
+ } else
g_warning ("pipeline could not be constructed\n");
return 1;
}
md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
- if (md5sink == NULL)
- {
+ if (md5sink == NULL) {
g_print ("adding an md5sink element to the pipeline\n");
/* make a null-terminated version of argv with ! md5sink appended
* ! is stored in argvn[argc - 1], md5sink in argvn[argc],
memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
argvn[argc - 1] = g_strdup_printf ("!");
argvn[argc] = g_strdup_printf ("md5sink");
- pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error);
+ pipeline =
+ (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
}
if (!pipeline) {
- if (error)
- {
+ if (error) {
g_warning ("pipeline could not be constructed: %s\n", error->message);
g_error_free (error);
- }
- else
+ } else
g_warning ("pipeline could not be constructed\n");
return 1;
}
-
- if (verbose)
- {
- gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0)
- : NULL;
- g_signal_connect (pipeline, "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify),
- exclude_list);
+
+ if (verbose) {
+ gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0)
+ : NULL;
+
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), exclude_list);
}
- g_signal_connect (pipeline, "error",
- G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (pipeline, "error",
+ G_CALLBACK (gst_element_default_error), NULL);
- if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
- {
+ if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
g_warning ("pipeline doesn't want to play\n");
return 0;
}
-
+
if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_SCHEDULABLE)) {
g_idle_add (idle_func, pipeline);
gst_main ();
- } else {
+ } else {
gst_element_wait_state_change (pipeline);
}
static gint num_plugins = 0;
static void
-plugin_added_func (GstRegistry *registry, GstPlugin *plugin, gpointer user_data)
+plugin_added_func (GstRegistry * registry, GstPlugin * plugin,
+ gpointer user_data)
{
g_print ("added plugin %s with %d feature(s)\n", plugin->desc.name,
- plugin->numfeatures);
+ plugin->numfeatures);
num_features += plugin->numfeatures;
num_plugins++;
}
static void
-spawn_all_in_dir(const char *dirname)
+spawn_all_in_dir (const char *dirname)
{
char *argv[2] = { NULL, NULL };
GDir *dir;
/* g_print("spawning all in %s\n", dirname); */
dir = g_dir_open (dirname, 0, NULL);
- if (dir == NULL) return;
-
- while( (file = g_dir_read_name (dir)) ){
- argv[0] = g_build_filename(dirname, file, NULL);
- g_print("running %s\n",argv[0]);
- g_spawn_sync (NULL, argv, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL, NULL, NULL, NULL, NULL);
- g_free(argv[0]);
+ if (dir == NULL)
+ return;
+
+ while ((file = g_dir_read_name (dir))) {
+ argv[0] = g_build_filename (dirname, file, NULL);
+ g_print ("running %s\n", argv[0]);
+ g_spawn_sync (NULL, argv, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ g_free (argv[0]);
}
- g_dir_close(dir);
+ g_dir_close (dir);
}
-int main (int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
GList *registries;
- GList *path_spill = NULL; /* used for path spill from failing registries */
+ GList *path_spill = NULL; /* used for path spill from failing registries */
- setlocale(LC_ALL, "");
+ setlocale (LC_ALL, "");
- /* Init gst */
+ /* Init gst */
_gst_registry_auto_load = FALSE;
gst_init (&argc, &argv);
GList *iter;
char *dir;
- if (path_spill)
- {
+ if (path_spill) {
GList *iter;
/* add spilled paths to this registry;
* since they're spilled they probably weren't loaded correctly
* so we should give a lower priority registry the chance to do them */
- for (iter = path_spill; iter; iter = iter->next)
- {
+ for (iter = path_spill; iter; iter = iter->next) {
g_print ("added path %s to %s \n",
- (const char *) iter->data, registry->name);
+ (const char *) iter->data, registry->name);
gst_registry_add_path (registry, (const gchar *) iter->data);
}
g_list_free (path_spill);
}
g_signal_connect (G_OBJECT (registry), "plugin_added",
- G_CALLBACK (plugin_added_func), NULL);
+ G_CALLBACK (plugin_added_func), NULL);
if (registry->flags & GST_REGISTRY_WRITABLE) {
char *location;
+
g_object_get (registry, "location", &location, NULL);
g_print ("rebuilding %s (%s)\n", registry->name, location);
g_free (location);
gst_registry_rebuild (registry);
gst_registry_save (registry);
- }
- else {
+ } else {
g_print ("trying to load %s\n", registry->name);
- if (!gst_registry_load (registry))
- {
+ if (!gst_registry_load (registry)) {
g_print ("error loading %s\n", registry->name);
/* move over paths from this registry to the next one */
path_spill = g_list_concat (path_spill,
- gst_registry_get_path_list (registry));
+ gst_registry_get_path_list (registry));
g_assert (path_spill != NULL);
}
/* also move over paths if the registry wasn't writable
* FIXME: we should check if the paths that were loaded from this
- registry get removed from the path_list so we only try to
- spill paths that could not be registered */
+ registry get removed from the path_list so we only try to
+ spill paths that could not be registered */
path_spill = g_list_concat (path_spill,
- gst_registry_get_path_list (registry));
+ gst_registry_get_path_list (registry));
}
- dir_list = gst_registry_get_path_list(registry);
- for(iter = dir_list; iter; iter = iter->next) {
- dir = g_build_filename((const char *)iter->data, "register-scripts", NULL);
- spawn_all_in_dir(dir);
- g_free(dir);
+ dir_list = gst_registry_get_path_list (registry);
+ for (iter = dir_list; iter; iter = iter->next) {
+ dir =
+ g_build_filename ((const char *) iter->data, "register-scripts",
+ NULL);
+ spawn_all_in_dir (dir);
+ g_free (dir);
}
- g_list_free(dir_list);
+ g_list_free (dir_list);
registries = g_list_next (registries);
}
return (0);
}
-
/* global statics for option parsing */
static gboolean _print = FALSE;
-static gchar * _arg_mm = NULL;
+static gchar *_arg_mm = NULL;
static gboolean _arg_list_mm = FALSE;
/* callback to parse arguments */
static void
popt_callback (poptContext context, enum poptCallbackReason reason,
- const struct poptOption *option, const char *arg, void *data)
+ const struct poptOption *option, const char *arg, void *data)
{
- if (reason == POPT_CALLBACK_REASON_OPTION)
- {
- switch (option->val)
- {
+ if (reason == POPT_CALLBACK_REASON_OPTION) {
+ switch (option->val) {
case ARG_MM:
- _arg_mm = g_strdup (arg);
- break;
+ _arg_mm = g_strdup (arg);
+ break;
case ARG_LIST_MM:
- _arg_list_mm = TRUE;
- break;
+ _arg_list_mm = TRUE;
+ break;
case ARG_PRINT:
- _print = TRUE;
- break;
+ _print = TRUE;
+ break;
case ARG_HELP:
- poptPrintHelp (context, stdout, 0);
- g_print ("\n");
- break;
+ poptPrintHelp (context, stdout, 0);
+ g_print ("\n");
+ break;
}
- }
- else
- {
+ } else {
g_print ("Unknown reason for callback\n");
}
}
/* popt options table for the wrapper */
-static struct poptOption wrapper_options[] =
-{
- { NULL, '\0',
- POPT_ARG_CALLBACK,
- (void *) &popt_callback, 0, NULL, NULL },
- { "help", '\0',
- POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
- NULL, ARG_HELP, ("Show help"), NULL },
- { "?", '\0',
- POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH
- | POPT_ARGFLAG_DOC_HIDDEN,
- NULL, ARG_HELP, NULL, NULL },
+static struct poptOption wrapper_options[] = {
+ {NULL, '\0',
+ POPT_ARG_CALLBACK,
+ (void *) &popt_callback, 0, NULL, NULL},
+ {"help", '\0',
+ POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN,
+ NULL, ARG_HELP, ("Show help"), NULL},
+ {"?", '\0',
+ POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH
+ | POPT_ARGFLAG_DOC_HIDDEN,
+ NULL, ARG_HELP, NULL, NULL},
/* We cheat by specifying -p as long "p" with onedash, so that it
also gets stripped properly from our arg flags */
- { "p", '\0',
- POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH
- | POPT_ARGFLAG_DOC_HIDDEN,
- NULL, ARG_PRINT, NULL, NULL },
- { "print", '\0',
- POPT_ARG_NONE | POPT_ARGFLAG_STRIP,
- NULL, ARG_PRINT, ("Print wrapped command line"), NULL },
- { "gst-mm", '\0',
- POPT_ARG_STRING | POPT_ARGFLAG_STRIP,
- NULL, ARG_MM, ("Force major/minor version"), NULL },
- { "gst-list-mm", '\0',
- POPT_ARG_NONE | POPT_ARGFLAG_STRIP,
- NULL, ARG_LIST_MM, ("List found major/minor versions"), NULL },
+ {"p", '\0',
+ POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH
+ | POPT_ARGFLAG_DOC_HIDDEN,
+ NULL, ARG_PRINT, NULL, NULL},
+ {"print", '\0',
+ POPT_ARG_NONE | POPT_ARGFLAG_STRIP,
+ NULL, ARG_PRINT, ("Print wrapped command line"), NULL},
+ {"gst-mm", '\0',
+ POPT_ARG_STRING | POPT_ARGFLAG_STRIP,
+ NULL, ARG_MM, ("Force major/minor version"), NULL},
+ {"gst-list-mm", '\0',
+ POPT_ARG_NONE | POPT_ARGFLAG_STRIP,
+ NULL, ARG_LIST_MM, ("List found major/minor versions"), NULL},
POPT_TABLEEND
};
/* helper table including our wrapper options */
-static struct poptOption options[] =
-{
- { NULL, '\0', POPT_ARG_INCLUDE_TABLE, wrapper_options, 0,
- "Wrapper options:", NULL},
+static struct poptOption options[] = {
+ {NULL, '\0', POPT_ARG_INCLUDE_TABLE, wrapper_options, 0,
+ "Wrapper options:", NULL},
POPT_TABLEEND
};
static void
find_highest_version (gchar * key, gchar * value, gchar ** highest)
{
- if (*highest == NULL)
- {
+ if (*highest == NULL) {
/* first value, so just set it */
*highest = key;
}
- if (strcmp (key, *highest) > 0) *highest = key;
+ if (strcmp (key, *highest) > 0)
+ *highest = key;
}
/* Libtool creates shell scripts named "base" that calls actual binaries as
{
gchar *new_dir, *new_base;
- if (!*dir) return;
- if (!*base) return;
+ if (!*dir)
+ return;
+ if (!*base)
+ return;
/* we assume libtool when base starts with lt- and dir ends with .libs */
- if (!g_str_has_prefix (*base, "lt-")) return;
- if (!g_str_has_suffix (*dir, ".libs")) return;
+ if (!g_str_has_prefix (*base, "lt-"))
+ return;
+ if (!g_str_has_suffix (*dir, ".libs"))
+ return;
new_base = g_strdup (&((*base)[3]));
new_dir = g_path_get_dirname (*dir);
* specified which caused get_basename to return "." */
full = g_build_filename (dir, base, NULL);
- if (strcmp (full, binary) != 0)
- {
- if (strcmp (dir, ".") != 0)
- {
+ if (strcmp (full, binary) != 0) {
+ if (strcmp (dir, ".") != 0) {
g_warning ("This should not happen, g_path_get_dirname () has changed.");
g_free (base);
g_free (dir);
/* we know no path was specified, so search standard path for binary */
g_free (full);
full = g_find_program_in_path (base);
- if (!full)
- {
+ if (!full) {
g_warning ("This should not happen, %s not in standard path.", base);
g_free (base);
g_free (dir);
/* get all dirs from the path and prepend with given dir */
path = g_strdup_printf ("%s%c%s",
- dir, G_SEARCHPATH_SEPARATOR, g_getenv ("PATH"));
+ dir, G_SEARCHPATH_SEPARATOR, g_getenv ("PATH"));
dirs = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 0);
g_free (path);
/* check all of these in reverse order by winding to bottom and going up */
cur = &dirs[0];
- while (*cur) ++cur;
+ while (*cur)
+ ++cur;
- while (cur != &dirs[0])
- {
+ while (cur != &dirs[0]) {
--cur;
- if (! g_file_test (*cur, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
+ if (!g_file_test (*cur, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
continue;
gdir = g_dir_open (*cur, 0, &error);
- if (! gdir)
- {
+ if (!gdir) {
g_warning ("Could not open dir %s: %s", *cur, error->message);
g_error_free (error);
return NULL;
}
- while ((entry = g_dir_read_name (gdir)))
- {
- if (g_pattern_match_string (spec, entry))
- {
- gchar *full;
-
- /* is it executable ? */
- full = g_build_filename (*cur, entry, NULL);
- if (! g_file_test (full, G_FILE_TEST_IS_EXECUTABLE))
- {
- g_free (full);
- continue;
- }
- g_free (full);
-
- /* strip base and dash from it */
- suffix = g_strdup (&(entry[strlen (base) + 1]));
-
- /* stricter pattern check: check if it only contains digits or dots */
- test = g_strdup (suffix);
- g_strcanon (test, "0123456789.", 'X');
- if (strstr (test, "X"))
- {
- g_free (test);
- continue;
- }
- g_free (test);
- g_hash_table_insert (candidates, suffix, g_strdup (*cur));
+ while ((entry = g_dir_read_name (gdir))) {
+ if (g_pattern_match_string (spec, entry)) {
+ gchar *full;
+
+ /* is it executable ? */
+ full = g_build_filename (*cur, entry, NULL);
+ if (!g_file_test (full, G_FILE_TEST_IS_EXECUTABLE)) {
+ g_free (full);
+ continue;
+ }
+ g_free (full);
+
+ /* strip base and dash from it */
+ suffix = g_strdup (&(entry[strlen (base) + 1]));
+
+ /* stricter pattern check: check if it only contains digits or dots */
+ test = g_strdup (suffix);
+ g_strcanon (test, "0123456789.", 'X');
+ if (strstr (test, "X")) {
+ g_free (test);
+ continue;
+ }
+ g_free (test);
+ g_hash_table_insert (candidates, suffix, g_strdup (*cur));
}
}
}
return candidates;
}
-int main
-(int argc, char **argv)
+int main (int argc, char **argv)
{
GHashTable *candidates;
gchar *dir;
ctx = poptGetContext ("gst-run", argc, (const char **) argv, options, 0);
poptReadDefaultConfig (ctx, TRUE);
while ((nextopt = poptGetNextOpt (ctx)) > 0)
- /* keep looping to parse */;
+ /* keep looping to parse */ ;
argc = poptStrippedArgv (ctx, argc, argv);
argv[argc] = NULL;
poptFreeContext (ctx);
- /* detect stuff */
+ /* detect stuff */
dir = get_dir_of_binary (argv[0]);
base = g_path_get_basename (argv[0]);
candidates = get_candidates (dir, base);
g_free (dir);
- if (_arg_mm)
- {
+ if (_arg_mm) {
/* if a version was forced, look it up in the hash table */
dir = g_hash_table_lookup (candidates, _arg_mm);
- if (!dir)
- {
+ if (!dir) {
g_print ("ERROR: Major/minor %s of tool %s not found.\n", _arg_mm, base);
return 1;
}
binary = g_strdup_printf ("%s-%s", base, _arg_mm);
- }
- else
- {
+ } else {
highest = NULL;
/* otherwise, just look up the highest version */
- g_hash_table_foreach (candidates, (GHFunc) find_highest_version,
- &highest);
+ g_hash_table_foreach (candidates, (GHFunc) find_highest_version, &highest);
if (highest == NULL) {
g_print ("ERROR: No version of tool %s not found.\n", base);
return 1;
/* print out list of major/minors we found if asked for */
/* FIXME: do them in order by creating a GList of keys and sort them */
- if (_arg_list_mm)
- {
+ if (_arg_list_mm) {
g_hash_table_foreach (candidates, (GHFunc) hash_print_key, NULL);
g_hash_table_destroy (candidates);
return 0;
/* print out command line if asked for */
argv[0] = path;
- if (_print)
- {
+ if (_print) {
int i;
- for (i = 0; i < argc; ++i)
- {
+
+ for (i = 0; i < argc; ++i) {
g_print ("%s", argv[i]);
- if (i < argc - 1) g_print (" ");
+ if (i < argc - 1)
+ g_print (" ");
}
g_print ("\n");
}
/* execute */
- if (execv (path, argv) == -1)
- {
+ if (execv (path, argv) == -1) {
g_warning ("Error executing %s: %s (%d)", path, g_strerror (errno), errno);
}
g_free (path);
gchar *filename = NULL;
void
-gst_caps_print (const char *filename, const GstCaps *caps)
+gst_caps_print (const char *filename, const GstCaps * caps)
{
gchar *caps_str = gst_caps_to_string (caps);
+
g_print ("%s - %s\n", filename, caps_str);
g_free (caps_str);
}
void
-have_type_handler (GstElement *typefind, guint probability, const GstCaps *caps, gpointer unused)
+have_type_handler (GstElement * typefind, guint probability,
+ const GstCaps * caps, gpointer unused)
{
gst_caps_print (filename, caps);
FOUND = TRUE;
gst_init (&argc, &argv);
- if (argc < 2) {
+ if (argc < 2) {
g_print ("Please give a filename to typefind\n\n");
return 1;
}
-
+
pipeline = gst_pipeline_new (NULL);
source = gst_element_factory_make ("filesrc", "source");
g_assert (GST_IS_ELEMENT (source));
g_assert (GST_IS_ELEMENT (typefind));
gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL);
gst_element_link (source, typefind);
- g_signal_connect (G_OBJECT (typefind), "have-type",
- G_CALLBACK (have_type_handler), NULL);
+ g_signal_connect (G_OBJECT (typefind), "have-type",
+ G_CALLBACK (have_type_handler), NULL);
while (i < argc) {
FOUND = FALSE;
/* set to play */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
- while (!FOUND) {
+ while (!FOUND) {
if (!gst_bin_iterate (GST_BIN (pipeline)))
break;
}
#endif
static void
-print_caps (const GstCaps *caps, gint pfx)
+print_caps (const GstCaps * caps, gint pfx)
{
char *s;
s = gst_caps_to_string (caps);
PUT_ESCAPED (pfx, "caps", s);
- g_free(s);
+ g_free (s);
}
static void
-print_formats (const GstFormat *formats, gint pfx)
+print_formats (const GstFormat * formats, gint pfx)
{
while (formats && *formats) {
const GstFormatDefinition *definition;
definition = gst_format_get_details (*formats);
if (definition)
PUT_STRING (pfx, "<format id=\"%d\" nick=\"%s\">%s</format>",
- *formats, definition->nick, definition->description);
+ *formats, definition->nick, definition->description);
else
- PUT_STRING (pfx, "<format id=\"%d\">unknown</format>",
- *formats);
+ PUT_STRING (pfx, "<format id=\"%d\">unknown</format>", *formats);
formats++;
}
}
static void
-print_query_types (const GstQueryType *types, gint pfx)
+print_query_types (const GstQueryType * types, gint pfx)
{
while (types && *types) {
const GstQueryTypeDefinition *definition;
definition = gst_query_type_get_details (*types);
if (definition)
PUT_STRING (pfx, "<query-type id=\"%d\" nick=\"%s\">%s</query-type>",
- *types, definition->nick, definition->description);
+ *types, definition->nick, definition->description);
else
- PUT_STRING (pfx, "<query-type id=\"%d\">unknown</query-type>",
- *types);
+ PUT_STRING (pfx, "<query-type id=\"%d\">unknown</query-type>", *types);
types++;
}
}
static void
-print_event_masks (const GstEventMask *masks, gint pfx)
+print_event_masks (const GstEventMask * masks, gint pfx)
{
#ifndef GST_DISABLE_ENUMTYPES
GType event_type;
GType event_flags;
GFlagsClass *flags_class = NULL;
- event_type = gst_event_type_get_type();
+ event_type = gst_event_type_get_type ();
klass = (GEnumClass *) g_type_class_ref (event_type);
while (masks && masks->type) {
switch (masks->type) {
case GST_EVENT_SEEK:
- flags = masks->flags;
- event_flags = gst_seek_type_get_type ();
- flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
- break;
+ flags = masks->flags;
+ event_flags = gst_seek_type_get_type ();
+ flags_class = (GFlagsClass *) g_type_class_ref (event_flags);
+ break;
default:
- break;
+ break;
}
value = g_enum_get_value (klass, masks->type);
- PUT_STRING (pfx, "<event type=\"%s\">",
- value->value_nick);
+ PUT_STRING (pfx, "<event type=\"%s\">", value->value_nick);
while (flags) {
GFlagsValue *value;
if (flags & 1) {
- value = g_flags_get_first_value (flags_class, 1 << index);
+ value = g_flags_get_first_value (flags_class, 1 << index);
- if (value)
- PUT_ESCAPED (pfx + 1, "flag", value->value_nick);
- else
- PUT_ESCAPED (pfx + 1, "flag", "?");
+ if (value)
+ PUT_ESCAPED (pfx + 1, "flag", value->value_nick);
+ else
+ PUT_ESCAPED (pfx + 1, "flag", "?");
}
flags >>= 1;
index++;
}
static void
-output_hierarchy (GType type, gint level, gint *maxlevel)
+output_hierarchy (GType type, gint level, gint * maxlevel)
{
GType parent;
}
static void
-print_element_properties (GstElement *element, gint pfx)
+print_element_properties (GstElement * element, gint pfx)
{
GParamSpec **property_specs;
- gint num_properties,i;
+ gint num_properties, i;
gboolean readable;
property_specs = g_object_class_list_properties
- (G_OBJECT_GET_CLASS (element), &num_properties);
+ (G_OBJECT_GET_CLASS (element), &num_properties);
PUT_START_TAG (pfx, "element-properties");
for (i = 0; i < num_properties; i++) {
GValue value = { 0, };
GParamSpec *param = property_specs[i];
+
readable = FALSE;
g_value_init (&value, param->value_type);
}
PUT_START_TAG (pfx + 1, "element-property");
PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (param));
- PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type));
+ PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type));
PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (param));
PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (param));
if (readable) {
PUT_ESCAPED (pfx + 2, "flags", "RW");
- }
- else {
+ } else {
PUT_ESCAPED (pfx + 2, "flags", "W");
}
switch (G_VALUE_TYPE (&value)) {
case G_TYPE_STRING:
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
case G_TYPE_BOOLEAN:
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
case G_TYPE_ULONG:
{
- GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
- PUT_STRING (pfx + 2, "<range min=\"%lu\" max=\"%lu\"/>",
- pulong->minimum, pulong->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%lu\" max=\"%lu\"/>",
+ pulong->minimum, pulong->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_LONG:
{
- GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
- PUT_STRING (pfx + 2, "<range min=\"%ld\" max=\"%ld\"/>",
- plong->minimum, plong->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecLong *plong = G_PARAM_SPEC_LONG (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%ld\" max=\"%ld\"/>",
+ plong->minimum, plong->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_UINT:
{
- GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
- PUT_STRING (pfx + 2, "<range min=\"%u\" max=\"%u\"/>",
- puint->minimum, puint->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%u\" max=\"%u\"/>",
+ puint->minimum, puint->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_INT:
{
- GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
- PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
- pint->minimum, pint->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecInt *pint = G_PARAM_SPEC_INT (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
+ pint->minimum, pint->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_UINT64:
{
- GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
- PUT_STRING (pfx + 2, "<range min=\"%"G_GUINT64_FORMAT"\" max=\"%"G_GUINT64_FORMAT"\"/>",
- puint64->minimum, puint64->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param);
+
+ PUT_STRING (pfx + 2,
+ "<range min=\"%" G_GUINT64_FORMAT "\" max=\"%" G_GUINT64_FORMAT
+ "\"/>", puint64->minimum, puint64->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_INT64:
{
- GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
- PUT_STRING (pfx + 2, "<range min=\"%"G_GINT64_FORMAT"\" max=\"%"G_GINT64_FORMAT"\"/>",
- pint64->minimum, pint64->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param);
+
+ PUT_STRING (pfx + 2,
+ "<range min=\"%" G_GINT64_FORMAT "\" max=\"%" G_GINT64_FORMAT
+ "\"/>", pint64->minimum, pint64->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_FLOAT:
{
- GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
- PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
- pfloat->minimum, pfloat->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
+ pfloat->minimum, pfloat->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
case G_TYPE_DOUBLE:
{
- GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
- PUT_STRING (pfx + 2, "<range min=\"%g\" max=\"%g\"/>",
- pdouble->minimum, pdouble->maximum);
- PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
- break;
+ GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param);
+
+ PUT_STRING (pfx + 2, "<range min=\"%g\" max=\"%g\"/>",
+ pdouble->minimum, pdouble->maximum);
+ PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value));
+ break;
}
default:
- if (param->value_type == GST_TYPE_CAPS) {
- GstCaps *caps = g_value_peek_pointer (&value);
-
- if (!caps)
- PUT_ESCAPED (pfx + 2, "default", "NULL");
- else {
- print_caps (caps, 2);
- }
- }
- else if (G_IS_PARAM_SPEC_ENUM (param)) {
- GEnumValue *values;
- guint j = 0;
- gint enum_value;
-
- values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
- enum_value = g_value_get_enum (&value);
-
- while (values[j].value_name) {
- if (values[j].value == enum_value)
- break;
- j++;
- }
- PUT_STRING (pfx + 2, "<default>%d</default>", values[j].value);
-
- PUT_START_TAG (pfx + 2, "enum-values");
- j = 0;
- while (values[j].value_name) {
- PUT_STRING (pfx + 3, "<value value=\"%d\" nick=\"%s\"/>",
- values[j].value, values[j].value_nick);
- j++;
- }
- PUT_END_TAG (pfx + 2, "enum-values");
- }
- else if (G_IS_PARAM_SPEC_FLAGS (param)) {
- GFlagsValue *values;
- guint j = 0;
- gint flags_value;
-
- values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
- flags_value = g_value_get_flags (&value);
-
- PUT_STRING (pfx + 2, "<default>%d</default>", flags_value);
-
- PUT_START_TAG (pfx + 2, "flags");
- j = 0;
- while (values[j].value_name) {
- PUT_STRING (pfx + 3, "<flag value=\"%d\" nick=\"%s\"/>",
- values[j].value, values[j].value_nick);
- j++;
- }
- PUT_END_TAG (pfx + 2, "flags");
- }
- else if (G_IS_PARAM_SPEC_OBJECT (param)) {
- PUT_ESCAPED (pfx + 2, "object-type",
- g_type_name(param->value_type));
- }
- break;
+ if (param->value_type == GST_TYPE_CAPS) {
+ GstCaps *caps = g_value_peek_pointer (&value);
+
+ if (!caps)
+ PUT_ESCAPED (pfx + 2, "default", "NULL");
+ else {
+ print_caps (caps, 2);
+ }
+ } else if (G_IS_PARAM_SPEC_ENUM (param)) {
+ GEnumValue *values;
+ guint j = 0;
+ gint enum_value;
+
+ values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
+ enum_value = g_value_get_enum (&value);
+
+ while (values[j].value_name) {
+ if (values[j].value == enum_value)
+ break;
+ j++;
+ }
+ PUT_STRING (pfx + 2, "<default>%d</default>", values[j].value);
+
+ PUT_START_TAG (pfx + 2, "enum-values");
+ j = 0;
+ while (values[j].value_name) {
+ PUT_STRING (pfx + 3, "<value value=\"%d\" nick=\"%s\"/>",
+ values[j].value, values[j].value_nick);
+ j++;
+ }
+ PUT_END_TAG (pfx + 2, "enum-values");
+ } else if (G_IS_PARAM_SPEC_FLAGS (param)) {
+ GFlagsValue *values;
+ guint j = 0;
+ gint flags_value;
+
+ values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values;
+ flags_value = g_value_get_flags (&value);
+
+ PUT_STRING (pfx + 2, "<default>%d</default>", flags_value);
+
+ PUT_START_TAG (pfx + 2, "flags");
+ j = 0;
+ while (values[j].value_name) {
+ PUT_STRING (pfx + 3, "<flag value=\"%d\" nick=\"%s\"/>",
+ values[j].value, values[j].value_nick);
+ j++;
+ }
+ PUT_END_TAG (pfx + 2, "flags");
+ } else if (G_IS_PARAM_SPEC_OBJECT (param)) {
+ PUT_ESCAPED (pfx + 2, "object-type", g_type_name (param->value_type));
+ }
+ break;
}
PUT_END_TAG (pfx + 1, "element-property");
}
static void
-print_element_dynparamaters (GstElement *element, gint pfx)
+print_element_dynparamaters (GstElement * element, gint pfx)
{
- GstDParamManager* dpman;
- GParamSpec** specs;
+ GstDParamManager *dpman;
+ GParamSpec **specs;
gint x;
PUT_START_TAG (pfx, "dyn-params");
- if((dpman = gst_dpman_get_manager (element))) {
+ if ((dpman = gst_dpman_get_manager (element))) {
specs = gst_dpman_list_dparam_specs (dpman);
for (x = 0; specs[x] != NULL; x++) {
PUT_START_TAG (pfx + 1, "dyn-param");
PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (specs[x]));
- PUT_ESCAPED (pfx + 2, "type", g_type_name (specs[x]->value_type));
- PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (specs[x]));
- PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (specs[x]));
+ PUT_ESCAPED (pfx + 2, "type", g_type_name (specs[x]->value_type));
+ PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (specs[x]));
+ PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (specs[x]));
switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) {
- case G_TYPE_INT64:
- PUT_STRING (pfx + 2, "<range min=\"%"G_GINT64_FORMAT"\" max=\"%"G_GINT64_FORMAT"\"/>",
- ((GParamSpecInt64 *) specs[x])->minimum,
- ((GParamSpecInt64 *) specs[x])->maximum);
- PUT_STRING (pfx + 2, "<default>%"G_GINT64_FORMAT"</default>",
- ((GParamSpecInt64 *) specs[x])->default_value);
- break;
- case G_TYPE_INT:
- PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
- ((GParamSpecInt *) specs[x])->minimum,
- ((GParamSpecInt *) specs[x])->maximum);
- PUT_STRING (pfx + 2, "<default>%d</default>",
- ((GParamSpecInt *) specs[x])->default_value);
- break;
- case G_TYPE_FLOAT:
- PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
- ((GParamSpecFloat *) specs[x])->minimum,
- ((GParamSpecFloat *) specs[x])->maximum);
- PUT_STRING (pfx + 2, "<default>%f</default>",
- ((GParamSpecFloat *) specs[x])->default_value);
- break;
- default:
- break;
+ case G_TYPE_INT64:
+ PUT_STRING (pfx + 2,
+ "<range min=\"%" G_GINT64_FORMAT "\" max=\"%" G_GINT64_FORMAT
+ "\"/>", ((GParamSpecInt64 *) specs[x])->minimum,
+ ((GParamSpecInt64 *) specs[x])->maximum);
+ PUT_STRING (pfx + 2, "<default>%" G_GINT64_FORMAT "</default>",
+ ((GParamSpecInt64 *) specs[x])->default_value);
+ break;
+ case G_TYPE_INT:
+ PUT_STRING (pfx + 2, "<range min=\"%d\" max=\"%d\"/>",
+ ((GParamSpecInt *) specs[x])->minimum,
+ ((GParamSpecInt *) specs[x])->maximum);
+ PUT_STRING (pfx + 2, "<default>%d</default>",
+ ((GParamSpecInt *) specs[x])->default_value);
+ break;
+ case G_TYPE_FLOAT:
+ PUT_STRING (pfx + 2, "<range min=\"%f\" max=\"%f\"/>",
+ ((GParamSpecFloat *) specs[x])->minimum,
+ ((GParamSpecFloat *) specs[x])->maximum);
+ PUT_STRING (pfx + 2, "<default>%f</default>",
+ ((GParamSpecFloat *) specs[x])->default_value);
+ break;
+ default:
+ break;
}
PUT_END_TAG (pfx + 1, "dyn-param");
}
}
static void
-print_element_signals (GstElement *element, gint pfx)
+print_element_signals (GstElement * element, gint pfx)
{
guint *signals;
guint nsignals;
const GType *param_types;
gint j;
- query = g_new0 (GSignalQuery,1);
+ query = g_new0 (GSignalQuery, 1);
g_signal_query (signals[i], query);
if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) ||
- (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
- n_params = query->n_params;
- return_type = query->return_type;
- param_types = query->param_types;
-
- PUT_START_TAG (pfx + 1, "signal");
- PUT_ESCAPED (pfx + 2, "name", query->signal_name);
- PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type));
- PUT_ESCAPED (pfx + 2, "object-type", g_type_name (G_OBJECT_TYPE (element)));
-
- PUT_START_TAG (pfx + 2, "params");
- for (j = 0; j < n_params; j++) {
- PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j]));
- }
+ (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) {
+ n_params = query->n_params;
+ return_type = query->return_type;
+ param_types = query->param_types;
+
+ PUT_START_TAG (pfx + 1, "signal");
+ PUT_ESCAPED (pfx + 2, "name", query->signal_name);
+ PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type));
+ PUT_ESCAPED (pfx + 2, "object-type",
+ g_type_name (G_OBJECT_TYPE (element)));
+
+ PUT_START_TAG (pfx + 2, "params");
+ for (j = 0; j < n_params; j++) {
+ PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j]));
+ }
- PUT_END_TAG (pfx + 2, "params");
+ PUT_END_TAG (pfx + 2, "params");
- PUT_END_TAG (pfx + 1, "signal");
+ PUT_END_TAG (pfx + 1, "signal");
- counted++;
+ counted++;
}
g_free (query);
}
static gint
-print_element_info (GstElementFactory *factory)
+print_element_info (GstElementFactory * factory)
{
GstElement *element;
GstObjectClass *gstobject_class;
gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
PUT_START_TAG (1, "details");
- PUT_ESCAPED (2, "long-name", factory->details.longname);
- PUT_ESCAPED (2, "class", factory->details.klass);
- PUT_ESCAPED (2, "description",factory->details.description);
- PUT_ESCAPED (2, "authors", factory->details.author);
+ PUT_ESCAPED (2, "long-name", factory->details.longname);
+ PUT_ESCAPED (2, "class", factory->details.klass);
+ PUT_ESCAPED (2, "description", factory->details.description);
+ PUT_ESCAPED (2, "authors", factory->details.author);
PUT_END_TAG (1, "details");
output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
if (factory->numpadtemplates) {
pads = factory->padtemplates;
while (pads) {
- padtemplate = (GstPadTemplate*)(pads->data);
- pads = g_list_next(pads);
+ padtemplate = (GstPadTemplate *) (pads->data);
+ pads = g_list_next (pads);
PUT_START_TAG (2, "pad-template");
- PUT_ESCAPED (3, "name", padtemplate->name_template);
+ PUT_ESCAPED (3, "name", padtemplate->name_template);
if (padtemplate->direction == GST_PAD_SRC)
- PUT_ESCAPED (3, "direction", "src");
+ PUT_ESCAPED (3, "direction", "src");
else if (padtemplate->direction == GST_PAD_SINK)
- PUT_ESCAPED (3, "direction", "sink");
+ PUT_ESCAPED (3, "direction", "sink");
else
- PUT_ESCAPED (3, "direction", "unkown");
+ PUT_ESCAPED (3, "direction", "unkown");
if (padtemplate->presence == GST_PAD_ALWAYS)
- PUT_ESCAPED (3, "presence", "always");
+ PUT_ESCAPED (3, "presence", "always");
else if (padtemplate->presence == GST_PAD_SOMETIMES)
- PUT_ESCAPED (3, "presence", "sometimes");
+ PUT_ESCAPED (3, "presence", "sometimes");
else if (padtemplate->presence == GST_PAD_REQUEST) {
- PUT_ESCAPED (3, "presence", "request");
- PUT_ESCAPED (3, "request-function",
- GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
- }
- else
- PUT_ESCAPED (3, "presence", "unkown");
+ PUT_ESCAPED (3, "presence", "request");
+ PUT_ESCAPED (3, "request-function",
+ GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad));
+ } else
+ PUT_ESCAPED (3, "presence", "unkown");
if (padtemplate->caps) {
- print_caps (padtemplate->caps, 3);
+ print_caps (padtemplate->caps, 3);
}
PUT_END_TAG (2, "pad-template");
}
PUT_START_TAG (1, "element-implementation");
if (element->loopfunc)
PUT_STRING (2, "<loop-based function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (element->loopfunc));
+ GST_DEBUG_FUNCPTR_NAME (element->loopfunc));
PUT_STRING (2, "<state-change function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
+ GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state));
#ifndef GST_DISABLE_LOADSAVE
PUT_STRING (2, "<save function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
+ GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself));
PUT_STRING (2, "<load function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
+ GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself));
#endif
PUT_END_TAG (1, "element-implementation");
PUT_START_TAG (1, "pads");
if (element->numpads) {
const GList *pads;
+
pads = gst_element_get_pad_list (element);
while (pads) {
pad = GST_PAD (pads->data);
realpad = GST_PAD_REALIZE (pad);
PUT_START_TAG (2, "pad");
- PUT_ESCAPED (3, "name", gst_pad_get_name (pad));
+ PUT_ESCAPED (3, "name", gst_pad_get_name (pad));
if (gst_pad_get_direction (pad) == GST_PAD_SRC)
- PUT_ESCAPED (3, "direction", "src");
+ PUT_ESCAPED (3, "direction", "src");
else if (gst_pad_get_direction (pad) == GST_PAD_SINK)
- PUT_ESCAPED (3, "direction", "sink");
+ PUT_ESCAPED (3, "direction", "sink");
else
- PUT_ESCAPED (3, "direction", "unkown");
+ PUT_ESCAPED (3, "direction", "unkown");
if (GST_IS_GHOST_PAD (pad))
- PUT_ESCAPED (3, "ghost", gst_pad_get_name (pad));
+ PUT_ESCAPED (3, "ghost", gst_pad_get_name (pad));
if (pad->padtemplate)
- PUT_ESCAPED (3, "template",
- pad->padtemplate->name_template);
+ PUT_ESCAPED (3, "template", pad->padtemplate->name_template);
PUT_START_TAG (3, "implementation");
if (realpad->chainfunc)
- PUT_STRING (4, "<chain-based function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc));
+ PUT_STRING (4, "<chain-based function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc));
if (realpad->getfunc)
- PUT_STRING (4, "<get-based function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (realpad->getfunc));
+ PUT_STRING (4, "<get-based function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->getfunc));
if (realpad->formatsfunc != gst_pad_get_formats_default) {
- PUT_STRING (4, "<formats-function function=\"%s\">",
- GST_DEBUG_FUNCPTR_NAME (realpad->formatsfunc));
- print_formats (gst_pad_get_formats (GST_PAD (realpad)), 5);
- PUT_END_TAG (4, "formats-function");
+ PUT_STRING (4, "<formats-function function=\"%s\">",
+ GST_DEBUG_FUNCPTR_NAME (realpad->formatsfunc));
+ print_formats (gst_pad_get_formats (GST_PAD (realpad)), 5);
+ PUT_END_TAG (4, "formats-function");
}
if (realpad->convertfunc != gst_pad_convert_default)
- PUT_STRING (4, "<convert-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
+ PUT_STRING (4, "<convert-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
if (realpad->eventfunc != gst_pad_event_default)
- PUT_STRING (4, "<event-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
+ PUT_STRING (4, "<event-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) {
- PUT_STRING (4, "<event-mask-func function=\"%s\">",
- GST_DEBUG_FUNCPTR_NAME (realpad->eventmaskfunc));
- print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)), 5);
- PUT_END_TAG (4, "event-mask-func");
+ PUT_STRING (4, "<event-mask-func function=\"%s\">",
+ GST_DEBUG_FUNCPTR_NAME (realpad->eventmaskfunc));
+ print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)), 5);
+ PUT_END_TAG (4, "event-mask-func");
}
if (realpad->queryfunc != gst_pad_query_default)
- PUT_STRING (4, "<query-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
+ PUT_STRING (4, "<query-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
if (realpad->querytypefunc != gst_pad_get_query_types_default) {
- PUT_STRING (4, "<query-type-func function=\"%s\">",
- GST_DEBUG_FUNCPTR_NAME (realpad->querytypefunc));
- print_query_types (gst_pad_get_query_types (GST_PAD (realpad)), 5);
- PUT_END_TAG (4, "query-type-func");
+ PUT_STRING (4, "<query-type-func function=\"%s\">",
+ GST_DEBUG_FUNCPTR_NAME (realpad->querytypefunc));
+ print_query_types (gst_pad_get_query_types (GST_PAD (realpad)), 5);
+ PUT_END_TAG (4, "query-type-func");
}
if (realpad->intlinkfunc != gst_pad_get_internal_links_default)
- PUT_STRING (4, "<intlink-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc));
+ PUT_STRING (4, "<intlink-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->intlinkfunc));
if (realpad->bufferallocfunc)
- PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>",
- GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc));
+ PUT_STRING (4, "<bufferalloc-function function=\"%s\"/>",
+ GST_DEBUG_FUNCPTR_NAME (realpad->bufferallocfunc));
PUT_END_TAG (3, "implementation");
if (realpad->caps) {
- print_caps (realpad->caps, 3);
+ print_caps (realpad->caps, 3);
}
PUT_END_TAG (2, "pad");
}
{
GList *plugins;
- plugins = gst_registry_pool_plugin_list();
+ plugins = gst_registry_pool_plugin_list ();
while (plugins) {
GList *features;
GstPlugin *plugin;
- plugin = (GstPlugin*)(plugins->data);
+ plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
features = gst_plugin_get_feature_list (plugin);
feature = GST_PLUGIN_FEATURE (features->data);
if (GST_IS_ELEMENT_FACTORY (feature)) {
- GstElementFactory *factory;
+ GstElementFactory *factory;
- factory = GST_ELEMENT_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory) ,factory->details.longname);
+ factory = GST_ELEMENT_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->details.longname);
}
#ifndef GST_DISABLE_INDEX
else if (GST_IS_INDEX_FACTORY (feature)) {
- GstIndexFactory *factory;
+ GstIndexFactory *factory;
- factory = GST_INDEX_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
+ factory = GST_INDEX_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
}
#endif
else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
- GstTypeFindFactory *factory;
+ GstTypeFindFactory *factory;
factory = GST_TYPE_FIND_FACTORY (feature);
- if (factory->extensions) {
+ if (factory->extensions) {
guint i = 0;
+
g_print ("%s type: ", plugin->desc.name);
while (factory->extensions[i]) {
g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
}
} else
g_print ("%s type: N/A\n", plugin->desc.name);
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
- GstSchedulerFactory *factory;
-
- factory = GST_SCHEDULER_FACTORY (feature);
- g_print ("%s: %s: %s\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
- }
- else {
- g_print ("%s: %s (%s)\n", plugin->desc.name,
- GST_PLUGIN_FEATURE_NAME (feature),
- g_type_name (G_OBJECT_TYPE (feature)));
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ GstSchedulerFactory *factory;
+
+ factory = GST_SCHEDULER_FACTORY (feature);
+ g_print ("%s: %s: %s\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
+ } else {
+ g_print ("%s: %s (%s)\n", plugin->desc.name,
+ GST_PLUGIN_FEATURE_NAME (feature),
+ g_type_name (G_OBJECT_TYPE (feature)));
}
features = g_list_next (features);
}
static void
-print_plugin_info (GstPlugin *plugin)
+print_plugin_info (GstPlugin * plugin)
{
GList *features;
gint num_features = 0;
gint num_other = 0;
g_print ("Plugin Details:\n");
- g_print (" Name:\t\t%s\n", plugin->desc.name);
- g_print (" Description:\t%s\n", plugin->desc.description);
- g_print (" Filename:\t%s\n", plugin->filename);
- g_print (" Version:\t%s\n", plugin->desc.version);
- g_print (" License:\t%s\n", plugin->desc.license);
- g_print (" Package:\t%s\n", plugin->desc.package);
- g_print (" Origin URL:\t%s\n", plugin->desc.origin);
+ g_print (" Name:\t\t%s\n", plugin->desc.name);
+ g_print (" Description:\t%s\n", plugin->desc.description);
+ g_print (" Filename:\t%s\n", plugin->filename);
+ g_print (" Version:\t%s\n", plugin->desc.version);
+ g_print (" License:\t%s\n", plugin->desc.license);
+ g_print (" Package:\t%s\n", plugin->desc.package);
+ g_print (" Origin URL:\t%s\n", plugin->desc.origin);
g_print ("\n");
features = gst_plugin_get_feature_list (plugin);
factory = GST_ELEMENT_FACTORY (feature);
g_print (" %s: %s\n", GST_OBJECT_NAME (factory),
- factory->details.longname);
+ factory->details.longname);
num_elements++;
}
#ifndef GST_DISABLE_INDEX
factory = GST_TYPE_FIND_FACTORY (feature);
if (factory->extensions) {
guint i = 0;
+
g_print ("%s type: ", plugin->desc.name);
while (factory->extensions[i]) {
g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
} else
g_print ("%s type: N/A\n", plugin->desc.name);
num_types++;
- }
- else if (GST_IS_SCHEDULER_FACTORY (feature)) {
+ } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
GstSchedulerFactory *factory;
factory = GST_SCHEDULER_FACTORY (feature);
g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
num_schedulers++;
- }
- else {
+ } else {
g_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)),
- g_type_name (G_OBJECT_TYPE (feature)));
+ g_type_name (G_OBJECT_TYPE (feature)));
num_other++;
}
num_features++;
GstPlugin *plugin;
gchar *so;
struct poptOption options[] = {
- {"gst-inspect-plugin", 'p', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0,
- "Show plugin details", NULL},
- {"gst-inspect-scheduler", 's', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0,
- "Show scheduler details", NULL},
- POPT_TABLEEND
+ {"gst-inspect-plugin", 'p', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, 0,
+ "Show plugin details", NULL},
+ {"gst-inspect-scheduler", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
+ 0,
+ "Show scheduler details", NULL},
+ POPT_TABLEEND
};
setlocale (LC_ALL, "");
/* if no arguments, print out list of elements */
if (argc == 1) {
- print_element_list();
+ print_element_list ();
- /* else we try to get a factory */
+ /* else we try to get a factory */
} else {
/* first check for help */
if (strstr (argv[1], "-help")) {
g_print ("Usage: %s\t\t\tList all registered elements\n", argv[0]);
g_print (" %s element-name\tShow element details\n", argv[0]);
g_print (" %s plugin-name[.so]\tShow information about plugin\n",
- argv[0]);
+ argv[0]);
return 0;
}
/* only search for a factory if there's not a '.so' */
- if (! strstr (argv[1], ".so")) {
+ if (!strstr (argv[1], ".so")) {
factory = gst_element_factory_find (argv[1]);
/* if there's a factory, print out the info */
if (factory)
- return print_element_info (factory);
+ return print_element_info (factory);
else {
- GstPluginFeature* feature;
-
- /* FIXME implement other pretty print function for these */
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_SCHEDULER_FACTORY);
- if (feature) {
- g_print ("%s: a scheduler\n", argv[1]);
- return 0;
- }
+ GstPluginFeature *feature;
+
+ /* FIXME implement other pretty print function for these */
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_SCHEDULER_FACTORY);
+ if (feature) {
+ g_print ("%s: a scheduler\n", argv[1]);
+ return 0;
+ }
#ifndef GST_DISABLE_INDEX
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_INDEX_FACTORY);
- if (feature) {
- g_print ("%s: an index\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_INDEX_FACTORY);
+ if (feature) {
+ g_print ("%s: an index\n", argv[1]);
+ return 0;
+ }
#endif
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_TYPE_FIND_FACTORY);
- if (feature) {
- g_print ("%s: a type find function\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_TYPE_FIND_FACTORY);
+ if (feature) {
+ g_print ("%s: a type find function\n", argv[1]);
+ return 0;
+ }
#ifndef GST_DISABLE_URI
- feature = gst_registry_pool_find_feature (argv[1],
- GST_TYPE_URI_HANDLER);
- if (feature) {
- g_print ("%s: an uri handler\n", argv[1]);
- return 0;
- }
+ feature = gst_registry_pool_find_feature (argv[1],
+ GST_TYPE_URI_HANDLER);
+ if (feature) {
+ g_print ("%s: an uri handler\n", argv[1]);
+ return 0;
+ }
#endif
}
} else {
/* strip the .so */
- so = strstr(argv[1],".so");
+ so = strstr (argv[1], ".so");
so[0] = '\0';
}
if (plugin) {
print_plugin_info (plugin);
} else {
- g_print("no such element or plugin '%s'\n", argv[1]);
+ g_print ("no such element or plugin '%s'\n", argv[1]);
return -1;
}
}