Docs updates.

Original commit message from CVS:
Docs updates.
Added LICENSE info to headers/code where missing in gst directory
Added a bonobo wrapper for the media player (it shows up in gshell but
locks up when activating the component, anyone?)
Fixed some XML save/load problems with arguments.
This commit is contained in:
Wim Taymans 2000-11-11 15:13:50 +00:00
parent a9a7f77e07
commit ef31aa64e8
39 changed files with 1741 additions and 646 deletions

View file

@ -0,0 +1,8 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
bonobo-gstmediaplay

View file

@ -0,0 +1,32 @@
Gamesdir = $(datadir)/gnome/apps/Games
INCLUDES = -I$(top_srcdir)/gst \
-I$(top_srcdir)/gstplay \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)"\" \
-I$(includedir) \
$(BONOBOX_TEST_CFLAGS)
bin_PROGRAMS = bonobo-gstmediaplay
bonobo_gstmediaplay_SOURCES = \
bonobo-gstmediaplay.c
bonobo_gstmediaplay_CFLAGS = \
$(shell gnome-config --cflags gnomeui bonobo bonobox) $(shell libglade-config --cflags gnome) \
$(shell gstreamer-config --clfags )
bonobo_gstmediaplay_LDADD = \
$(top_srcdir)/gstplay/libgstmediaplay.la
bonobo_gstmediaplay_LDFLAGS = \
$(shell gnome-config --libs gnomeui bonobo bonobox) $(shell libglade-config --libs gnome) \
$(shell gstreamer-config --libs )
oafdir = $(datadir)/oaf
OAF_FILES = gstmediaplay.oafinfo
oaf_DATA = $(OAF_FILES)
EXTRA_DIST = gstmediaplay.desktop $(OAF_FILES) \
bonobo-gstmediaplay-ui.xml

View file

@ -0,0 +1,19 @@
<Root>
<commands>
<cmd name="NewGame" _label="New game" _tip="Start a new game"/>
<cmd name="OpenGame" _label="Open game" _tip="Load a saved game"/>
</commands>
<menu>
<submenu name="Game" _label="_Game">
<menuitem name="NewGame" verb=""/>
<menuitem name="OpenGame" verb=""/>
</submenu>
</menu>
<dockitem name="Game">
<toolitem name="NewGame" verb=""/>
</dockitem>
</Root>;

View file

@ -0,0 +1,445 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <gnome.h>
#include <liboaf/liboaf.h>
#include <bonobo.h>
#include "gstplay.h"
/*
* Number of running objects
*/
static int running_objects = 0;
static BonoboGenericFactory *factory = NULL;
/*
* BonoboControl data
*/
typedef struct {
BonoboControl *bonobo_object;
BonoboUIComponent *uic;
GstPlay *play;
} control_data_t;
/*
* This callback is invoked when the BonoboControl object
* encounters a fatal CORBA exception.
*/
static void
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)
{
g_print("control_update\n", running_objects);
gtk_widget_queue_draw (GTK_WIDGET (control_data->play));
g_print("control_update done\n", running_objects);
}
static void
load_media (BonoboPersistStream *ps,
const Bonobo_Stream stream,
Bonobo_Persist_ContentType type,
void *closure,
CORBA_Environment *ev)
{
control_data_t *control_data = closure;
GstPlay *pl;
Bonobo_Stream_iobuf *buffer;
char *str;
int bx, by, j;
g_return_if_fail (control_data != NULL);
g_return_if_fail (control_data->play != NULL);
if (*type && g_strcasecmp (type, "application/x-gstmediaplay") != 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Persist_WrongDataType, NULL);
return;
}
pl = control_data->play;
bonobo_stream_client_read_string (stream, &str, ev);
if (ev->_major != CORBA_NO_EXCEPTION || str == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Persist_WrongDataType, NULL);
return;
}
sscanf (str, "%2u%2u\n", &bx, &by);
g_free (str);
if (bx > 128 || by > 128) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Persist_WrongDataType, NULL);
return;
}
for (j = 0; j < by; j++) {
int i;
Bonobo_Stream_read (stream, bx * 2 + 1, &buffer, ev);
if (ev->_major != CORBA_NO_EXCEPTION)
return;
else if (buffer->_length != bx * 2 + 1) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Persist_WrongDataType,
NULL);
return;
}
CORBA_free (buffer);
}
control_update (control_data);
}
static void
save_media (BonoboPersistStream *ps,
const Bonobo_Stream stream,
Bonobo_Persist_ContentType type,
void *closure,
CORBA_Environment *ev)
{
control_data_t *control_data = closure;
GstPlay *pl;
char *data;
int j;
g_return_if_fail (control_data != NULL);
g_return_if_fail (control_data->play != NULL);
if (*type && g_strcasecmp (type, "application/x-gstmediaplay") != 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Persist_WrongDataType, NULL);
return;
}
pl = control_data->play;
if (ev->_major != CORBA_NO_EXCEPTION)
return;
}
static Bonobo_Persist_ContentTypeList *
content_types (BonoboPersistStream *ps, void *closure, CORBA_Environment *ev)
{
return bonobo_persist_generate_content_types (1, "application/x-gstmediaplay");
}
/*
* When one of our controls is activated, we merge our menus
* in with our container's menus.
*/
static void
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=\"NewGame\" _label=\"New game\" _tip=\"Start a new game\"/>"
" <cmd name=\"OpenGame\" _label=\"Open game\" _tip=\"Load a saved game\"/>"
" </commands>"
" <menu>"
" <submenu name=\"Game\" _label=\"_Game\">"
" <menuitem name=\"NewGame\" verb=\"\"/>"
" <menuitem name=\"OpenGame\" verb=\"\"/>"
" </submenu>"
" </menu>"
" <dockitem name=\"Game\">"
" <toolitem name=\"NewGame\" verb=\"\"/>"
" </dockitem>"
"</Root>";
/*
* Get our container's UIContainer server.
*/
remote_uic = bonobo_control_get_remote_ui_container (control);
/*
* We have to deal gracefully with containers
* which don't have a UIContainer running.
*/
if (remote_uic == CORBA_OBJECT_NIL) {
g_warning ("No UI container!");
return;
}
/*
* Give our BonoboUIComponent object a reference to the
* container's UIContainer server.
*/
bonobo_ui_component_set_container (control_data->uic, remote_uic);
/*
* Unref the UI container we have been passed.
*/
bonobo_object_release_unref (remote_uic, NULL);
/* Set up the UI from the XML string. */
{
BonoboUINode *node;
node = bonobo_ui_node_from_string (ui);
bonobo_ui_util_translate_ui (node);
bonobo_ui_util_fixup_help (control_data->uic, node,
DATADIR, "gstmediaplay");
bonobo_ui_component_set_tree (control_data->uic, "/", node, NULL);
bonobo_ui_node_free (node);
}
}
static void
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_data_t *control_data = (control_data_t *) data;
g_message ("control_destroy_cb");
control_data->play = NULL;
g_free (control_data);
running_objects--;
if (running_objects > 0)
return;
/*
* When the last object has gone, unref the factory & quit.
*/
bonobo_object_unref (BONOBO_OBJECT (factory));
gtk_main_quit ();
}
static void
control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
{
control_data_t *control_data = (control_data_t *) data;
g_message ("control_activate");
/*
* The ControlFrame has just asked the Control (that's us) to be
* activated or deactivated. We must reply to the ControlFrame
* and say whether or not we want our activation state to
* change. We are an acquiescent BonoboControl, so we just agree
* with whatever the ControlFrame told us. Most components
* should behave this way.
*/
bonobo_control_activate_notify (control, activate);
/*
* If we were just activated, we merge in our menu entries.
* If we were just deactivated, we remove them.
*/
if (activate)
control_create_menus (control_data);
else
control_remove_menus (control_data);
}
static void
control_set_frame_cb (BonoboControl *control, gpointer data)
{
g_message ("control_set frame cb");
control_create_menus ((control_data_t *) data);
g_message ("control_set frame cb done");
}
static void
update_control (GtkWidget *widget, control_data_t *control_data)
{
g_message ("update_control");
control_update (control_data);
}
static BonoboObject *
bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data)
{
BonoboControl *bonobo_object;
control_data_t *control_data;
BonoboPersistStream *stream;
GtkWidget *vbox;
/*
* Create a data structure in which we can store
* Control-object-specific data about this document.
*/
control_data = g_new0 (control_data_t, 1);
if (control_data == NULL)
return NULL;
g_print("creating\n");
control_data->play = gst_play_new ();
g_print("created\n");
vbox = gtk_vbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (control_data->play),
TRUE, TRUE, 0);
gtk_widget_show_all (vbox);
/*
* Create the BonoboControl object.
*/
bonobo_object = bonobo_control_new (vbox);
if (bonobo_object == NULL) {
gtk_widget_destroy (vbox);
g_free (control_data);
return NULL;
}
control_data->bonobo_object = bonobo_object;
control_data->uic = bonobo_control_get_ui_component (bonobo_object);
/*
* When our container wants to activate this component, we will get
* the "activate" signal.
*/
gtk_signal_connect (GTK_OBJECT (bonobo_object), "activate",
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);
/*
* 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);
/*
* 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);
/*
* Create the PersistStream object.
*/
stream = bonobo_persist_stream_new (load_media, save_media,
NULL, content_types,
control_data);
if (stream == NULL) {
bonobo_object_unref (BONOBO_OBJECT (bonobo_object));
gtk_widget_destroy (vbox);
g_free (control_data);
return NULL;
}
bonobo_object_add_interface (BONOBO_OBJECT (bonobo_object),
BONOBO_OBJECT (stream));
/*
* Add some verbs to the control.
*
* The container application will then have the programmatic
* ability to execute the verbs on the component. It will
* also provide a simple mechanism whereby the user can
* right-click on the component to create a popup menu
* listing the available verbs.
*
* We provide one simple verb whose job it is to clear the
* window.
*/
control_data->uic = bonobo_control_get_ui_component (bonobo_object);
/*
* Count the new running object
*/
running_objects++;
g_print("running objects: %d\n", running_objects);
return BONOBO_OBJECT (bonobo_object);
}
static void
init_gstmediaplay_factory (void)
{
printf("init factory\n");
factory = bonobo_generic_factory_new (
"OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18",
bonobo_gstmediaplay_factory, NULL);
}
static void
init_server_factory (int argc, char **argv)
{
CORBA_Environment ev;
CORBA_ORB orb;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
CORBA_exception_init (&ev);
gnome_init_with_popt_table("gstmediaplay", VERSION,
argc, argv,
oaf_popt_options, 0, NULL);
orb = oaf_init (argc, argv);
CORBA_exception_free (&ev);
if (bonobo_init (orb, NULL, NULL) == FALSE)
g_error (_("Could not initialize Bonobo!"));
}
int
main (int argc, char **argv)
{
gst_init (&argc, &argv);
/*
* Setup the factory.
*/
init_server_factory (argc, argv);
init_gstmediaplay_factory ();
/*
* Start processing.
*/
bonobo_main ();
return 0;
}

View file

@ -0,0 +1,20 @@
<oaf_info>
<oaf_server iid="OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18" type="exe" location="bonobo-gstmediaplay">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="GstMediaPlay control factory"/>
<oaf_attribute name="description" type="string" value="bonobo GstMediaPlay object factory"/>
</oaf_server>
<oaf_server iid="OAFIID:bonobo_gstmediaplay:b6735078-0a67-4db0-aba6-ce37ecb63ff2" type="factory" location="OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="GstMediaPlay control"/>
<oaf_attribute name="description" type="string" value="bonobo GstMediaPlay object"/>
</oaf_server>
</oaf_info>

View file

@ -467,6 +467,7 @@ plugins/vorbis/Makefile
plugins/capture/Makefile
plugins/capture/v4l/Makefile
gstplay/Makefile
components/bonobo-gstmediaplay/Makefile
test/Makefile
test/xml/Makefile
test/bindings/Makefile

View file

@ -77,12 +77,14 @@ The maximum number of cothreads we are going to support.
<!-- ##### USER_FUNCTION cothread_func ##### -->
<para>
the function that will be called when the cothread starts.
the function that will be called when the cothread starts. The function
prototype is like a main() function, so you can do whatever you want with
it.
</para>
@argc:
@argv:
@Returns:
@argc: a main-like argument count
@argv: a main-like array of arguments
@Returns: a return code
<!-- ##### MACRO COTHREAD_STARTED ##### -->

View file

@ -109,57 +109,55 @@ it, is there?
<!-- ##### MACRO GST_META_FLAGS ##### -->
<para>
Retrieve the flags of the given meta information
</para>
@meta:
<!-- # Unused Parameters # -->
@buf:
@meta: the meta information
<!-- ##### MACRO GST_META_FLAG_IS_SET ##### -->
<para>
Check if a given flag is set
</para>
@meta:
@flag:
@meta: the meta data to test
@flag: the flag to test
<!-- ##### MACRO GST_META_FLAG_SET ##### -->
<para>
Set a flag in the meta data
</para>
@meta:
@flag:
@meta: the meta data
@flag: the flag to set
<!-- ##### MACRO GST_META_FLAG_UNSET ##### -->
<para>
Clear a flag in the meta data
</para>
@meta:
@flag:
@meta: the meta data
@flag: the flag to clear
<!-- ##### ENUM GstMetaFlags ##### -->
<para>
Flags indicating properties about the meta data
</para>
@GST_META_FREEABLE:
@GST_META_FREEABLE: the meta data can be freed
<!-- ##### STRUCT GstMeta ##### -->
<para>
</para>
@lock:
@flags:
@data:
@size:
@lock: for locking purposes
@flags: the flags of the meta data
@data: the meta data
@size: the size of the meta data
<!-- ##### FUNCTION gst_meta_new_size ##### -->
<para>
@ -172,10 +170,10 @@ it, is there?
<!-- ##### MACRO gst_meta_new ##### -->
<para>
Create new meta data
</para>
@type:
@type: the type of the meta data to create
<!-- ##### FUNCTION gst_meta_ref ##### -->

View file

@ -171,13 +171,6 @@
@Returns:
<!-- ##### MACRO GST_SINESRC ##### -->
<para>
</para>
@obj:
<!-- ##### FUNCTION gst_object_get_type ##### -->
<para>
@ -185,19 +178,19 @@
@Returns:
<!-- ##### MACRO GST_SINESRC ##### -->
<para>
</para>
@obj:
<!-- ##### SECTION ./tmpl/plugin.sgml:Long_Description ##### -->
<para>
</para>
<!-- ##### MACRO GST_QUEUE_CLASS ##### -->
<para>
</para>
@klass:
<!-- ##### FUNCTION gst_audiosrc_get_type ##### -->
<para>
@ -205,6 +198,13 @@
@Returns:
<!-- ##### MACRO GST_QUEUE_CLASS ##### -->
<para>
</para>
@klass:
<!-- ##### MACRO GST_IS_QUEUE ##### -->
<para>
@ -356,6 +356,12 @@
</para>
<!-- ##### STRUCT GstFakeSink ##### -->
<para>
</para>
<!-- ##### MACRO GST_THREAD_CLASS ##### -->
<para>
@ -363,12 +369,6 @@
@klass:
<!-- ##### STRUCT GstFakeSink ##### -->
<para>
</para>
<!-- ##### MACRO GST_BIN_CLASS ##### -->
<para>
@ -403,16 +403,16 @@
@obj:
<!-- ##### SECTION ./tmpl/gstcolorspace.sgml:Title ##### -->
GstColorSpace
<!-- ##### STRUCT GstEsdSink ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/gstcolorspace.sgml:Title ##### -->
GstColorSpace
<!-- ##### MACRO GST_PAD ##### -->
<para>
@ -703,14 +703,14 @@ This macro unsets the given state on the element.
<!-- ##### MACRO GST_ESDSINK_CLASS ##### -->
<!-- ##### MACRO GST_ASYNCDISKSRC_CLASS ##### -->
<para>
</para>
@klass:
<!-- ##### MACRO GST_ASYNCDISKSRC_CLASS ##### -->
<!-- ##### MACRO GST_ESDSINK_CLASS ##### -->
<para>
</para>
@ -1366,13 +1366,6 @@ Get the size of the current file.
</para>
<!-- ##### FUNCTION gst_audiosink_get_type ##### -->
<para>
</para>
@Returns:
<!-- ##### MACRO GST_META ##### -->
<para>
@ -1380,6 +1373,13 @@ Get the size of the current file.
@meta:
<!-- ##### FUNCTION gst_audiosink_get_type ##### -->
<para>
</para>
@Returns:
<!-- ##### FUNCTION gst_httpsrc_get_type ##### -->
<para>
@ -1421,12 +1421,6 @@ Get the size of the current file.
</para>
<!-- ##### MACRO GST_TYPE_FILTER ##### -->
<para>
</para>
<!-- ##### MACRO GST_IS_SINESRC_CLASS ##### -->
<para>
@ -1434,6 +1428,12 @@ Get the size of the current file.
@obj:
<!-- ##### MACRO GST_TYPE_FILTER ##### -->
<para>
</para>
<!-- ##### MACRO GST_IS_AUDIOSRC_CLASS ##### -->
<para>
@ -1511,10 +1511,6 @@ GstElement
@obj:
<!-- ##### SECTION ./tmpl/plugin.sgml:Short_Description ##### -->
<!-- ##### FUNCTION gst_audiosrc_push ##### -->
<para>
@ -1522,6 +1518,10 @@ GstElement
@src:
<!-- ##### SECTION ./tmpl/plugin.sgml:Short_Description ##### -->
<!-- ##### MACRO GST_HTTPSRC_CLASS ##### -->
<para>
@ -1637,15 +1637,15 @@ GstElement
@name:
@Returns:
<!-- ##### MACRO GST_TYPE_ESDSINK ##### -->
<para>
</para>
<!-- ##### MACRO GST_CPU_FLAG_MMX ##### -->
<para>
A flag indicating that MMX instructions are supported.
</para>
<!-- ##### MACRO GST_TYPE_ESDSINK ##### -->
<para>
</para>

View file

@ -54,19 +54,18 @@ valid mp3 decoder, and thus the whole point of the type system.
<!-- ##### USER_FUNCTION GstTypeFindFunc ##### -->
<para>
This is the function that will be called when a typefind has to be
performed by a plugin.
</para>
@buf:
@priv:
@Returns:
<!-- # Unused Parameters # -->
@private:
@buf: the buffer with media on which to perform the typefind
@priv: private; don't touch
@Returns: a boolean indicating if the typedetection was successfull
<!-- ##### STRUCT GstType ##### -->
<para>
A type
</para>
@id:
@ -79,7 +78,7 @@ valid mp3 decoder, and thus the whole point of the type system.
<!-- ##### STRUCT GstTypeFactory ##### -->
<para>
The struct with the typefactory information
</para>
@mime:

View file

@ -6,7 +6,7 @@ Utility functions
<!-- ##### SECTION Long_Description ##### -->
<para>
Some convenience functions
</para>
<!-- ##### SECTION See_Also ##### -->

View file

@ -26,7 +26,7 @@ The different IDCT methods available
@GST_IDCT_FLOAT: accurate float version
@GST_IDCT_MMX: fast MMX (not IEEE compliant)
@GST_IDCT_MMX32: accurate MMX
@GST_IDCT_SSE:
@GST_IDCT_SSE: fast SSE optimised IDCT
<!-- ##### STRUCT GstIDCT ##### -->
<para>

View file

@ -10,6 +10,13 @@
</sect1>
<sect1>
<title>GstMediaPlay</title>
<para>
</para>
</sect1>
<sect1>
<title>GstEditor</title>
<para>

View file

@ -1,6 +1,97 @@
<chapter id="cha-cothreads">
<title>Cothreads</title>
<para>
Cothreads are user-space threads that greatly reduce context
switching overhead introduced by regular kernel threads.
Cothreads are also used to handle the more complex elements.
</para>
<para>
A cothread is created by a <classname>GstBin</classname> whenever an element is found
inside the bin that has one or more of the following properties:
<itemizedlist>
<listitem>
<para>
The element is loop-based instead of chain-based
</para>
</listitem>
<listitem>
<para>
The element has multiple input pads
</para>
</listitem>
<listitem>
<para>
The element has the MULTI_IN flag set
</para>
</listitem>
</itemizedlist>
The <classname>GstBin</classname> will create a cothread context for all the elements
in the bin so that the elements will interact in cooperative
multithreading.
</para>
<para>
Before proceding to the concept of loop-based elements we will first
explain the chain-based elements
</para>
<sect1 id="sec-chain-based">
<title>Chain-based elements</title>
<para>
Chain based elements receive a buffer of data and are supposed
to handle the data and perform a gst_pad_push.
</para>
<para>
The basic main function of a chain-based element is like:
</para>
<programlisting>
static void chain_function (GstPad *pad, GstBuffer *buffer)
{
GstBuffer *outbuffer;
....
// process the buffer, create a new outbuffer
...
gst_pad_push (srcpad, outbuffer);
}
</programlisting>
</sect1>
<sect1 id="sec-loop-based">
<title>Loop-based elements</title>
<para>
As opposed to chain-based elements, Loop-based elements enter an
infinite loop that looks like this:
<programlisting>
GstBuffer *buffer, *outbuffer;
while (1) {
buffer = gst_pad_pull (sinkpad);
...
// process buffer, create outbuffer
...
gst_pad_push (srcpad, outbuffer);
}
</programlisting>
The loop-based elements request a buffer whenever they need one.
</para>
<para>
When the request for a buffer cannot immedialty satisfied, the control
will be given to the source element of the loop-based element until it
performs a push on its source pad. At that time the control is handed back
to the loop-based element, etc... The the execution trace can get fairly
complex using cothreads when there are multiple input/output pads for the
loop-based element.
</para>
<para>
There is no problem in putting cothreaded elements into a
<classname>GstThread</classname> to create even more complex pipelines with
both user and kernel space threads.
</para>
</sect1>
</chapter>

View file

@ -66,9 +66,6 @@ int main(int argc,char *argv[])
exit(-1);
}
/* find out how to handle this bin */
gst_bin_create_plan(GST_BIN(pipeline));
/* make it ready */
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY);
/* start playing */

View file

@ -103,4 +103,11 @@ gstreamer-launch disksrc redpill.vob ! css-descramble ! private_stream_1.0 ! \
</para>
</sect1>
<sect1>
<title><command>gstmediaplay</command></title>
<para>
A sample media player.
</para>
</sect1>
</chapter>

View file

@ -1,3 +1,22 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <pthread.h>
#include <sys/time.h>
#include <linux/linkage.h>
@ -15,6 +34,14 @@
pthread_key_t _cothread_key = -1;
/**
* cothread_create:
* @ctx: the cothread context
*
* create a new cotread state in the given context
*
* Returns: the new cothread state
*/
cothread_state*
cothread_create (cothread_context *ctx)
{
@ -52,6 +79,15 @@ cothread_create (cothread_context *ctx)
return s;
}
/**
* cothread_setfunc:
* @thread: the cothread state
* @func: the function to call
* @argc: the argument count for the cothread function
* @argv: the arguments for the cothread function
*
* Set the cothread function
*/
void
cothread_setfunc (cothread_state *thread,
cothread_func func,
@ -64,6 +100,13 @@ cothread_setfunc (cothread_state *thread,
thread->pc = (int *)func;
}
/**
* cothread_init:
*
* create and initialize a new cotread context
*
* Returns: the new cothread context
*/
cothread_context*
cothread_init (void)
{
@ -99,6 +142,12 @@ cothread_init (void)
return ctx;
}
/**
* cothread_main:
* @ctx: the cothread context
*
* Returns: the new cothread state
*/
cothread_state*
cothread_main(cothread_context *ctx)
{
@ -123,6 +172,14 @@ cothread_stub (void)
//printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
}
/**
* cothread_set_data:
* @thread: the cothread state
* @key: a key for the data
* @data: the data
*
* adds data to a cothread
*/
void
cothread_set_data (cothread_state *thread,
gchar *key,
@ -133,6 +190,15 @@ cothread_set_data (cothread_state *thread,
g_hash_table_insert(ctx->data, key, data);
}
/**
* cothread_get_data:
* @thread: the cothread state
* @key: a key for the data
*
* get data from the cothread
*
* Returns: the data assiciated with the key
*/
gpointer
cothread_get_data (cothread_state *thread,
gchar *key)
@ -142,6 +208,12 @@ cothread_get_data (cothread_state *thread,
return g_hash_table_lookup(ctx->data, key);
}
/**
* cothread_switch:
* @thread: the cothread state
*
* switches to the given cothread state
*/
void
cothread_switch (cothread_state *thread)
{

View file

@ -1,6 +1,26 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __COTHREADS_H__
#define __COTHREADS_H__
#include <glib.h>
#include <setjmp.h>
#include <pthread.h>

View file

@ -139,14 +139,15 @@ GstElement *gst_queue_new(gchar *name) {
return queue;
}
static void gst_queue_cleanup_buffers(gpointer data, gpointer user_data)
static void gst_queue_cleanup_buffers(gpointer data, const gpointer user_data)
{
DEBUG("queue: %s cleaning buffer %p\n", (gchar *)user_data, data);
gst_buffer_unref(GST_BUFFER(data));
gst_buffer_unref (GST_BUFFER (data));
}
static void gst_queue_flush(GstQueue *queue) {
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, gst_element_get_name(GST_ELEMENT(queue)));
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, (char *)gst_element_get_name(GST_ELEMENT(queue)));
g_slist_free(queue->queue);
queue->queue = NULL;
queue->level_buffers = 0;
@ -155,7 +156,7 @@ static void gst_queue_flush(GstQueue *queue) {
static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
GstQueue *queue;
gboolean tosignal = FALSE;
guchar *name;
const guchar *name;
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
@ -215,7 +216,7 @@ static void gst_queue_push(GstConnection *connection) {
GstBuffer *buf = NULL;
GSList *front;
gboolean tosignal = FALSE;
guchar *name;
const guchar *name;
name = gst_element_get_name(GST_ELEMENT(queue));

View file

@ -1,3 +1,22 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GST_HGUARD_GSTARCH_H
#define GST_HGUARD_GSTARCH_H

View file

@ -516,7 +516,7 @@ gst_bin_loopfunc_wrapper (int argc,char *argv[])
GList *pads;
GstPad *pad;
GstBuffer *buf;
G_GNUC_UNUSED gchar *name = gst_element_get_name (element);
G_GNUC_UNUSED const gchar *name = gst_element_get_name (element);
DEBUG("** gst_bin_loopfunc_wrapper(%d,\"%s\")\n",
argc,gst_element_get_name (element));

View file

@ -18,22 +18,20 @@
*/
//#define DEBUG_ENABLED
#include <gst/gst.h>
#include <gst/gstbuffer.h>
//#define DEBUG(format,args...) g_print("DEBUG: " format, ##args)
#define DEBUG(format,args...)
GMemChunk *_gst_buffer_chunk;
void _gst_buffer_initialize() {
_gst_buffer_chunk = g_mem_chunk_new("GstBuffer",sizeof(GstBuffer),
sizeof(GstBuffer)*16,G_ALLOC_AND_FREE);
void
_gst_buffer_initialize (void)
{
_gst_buffer_chunk = g_mem_chunk_new ("GstBuffer", sizeof(GstBuffer),
sizeof(GstBuffer) * 16, G_ALLOC_AND_FREE);
}
/**
* gst_buffer_new:
*
@ -41,16 +39,18 @@ void _gst_buffer_initialize() {
*
* Returns: new buffer
*/
GstBuffer *gst_buffer_new() {
GstBuffer*
gst_buffer_new(void)
{
GstBuffer *buffer;
buffer = g_mem_chunk_alloc(_gst_buffer_chunk);
buffer = g_mem_chunk_alloc (_gst_buffer_chunk);
DEBUG("BUF: allocating new buffer %p\n",buffer);
// g_print("allocating new mutex\n");
buffer->lock = g_mutex_new();
buffer->lock = g_mutex_new ();
#ifdef HAVE_ATOMIC_H
atomic_set(&buffer->refcount,1);
atomic_set (&buffer->refcount, 1);
#else
buffer->refcount = 1;
#endif
@ -64,6 +64,7 @@ GstBuffer *gst_buffer_new() {
buffer->metas = NULL;
buffer->parent = NULL;
buffer->pool = NULL;
return buffer;
}
@ -75,9 +76,10 @@ GstBuffer *gst_buffer_new() {
*
* Returns: new buffer
*/
GstBuffer *gst_buffer_new_from_pool(GstBufferPool *pool)
GstBuffer*
gst_buffer_new_from_pool (GstBufferPool *pool)
{
return gst_buffer_pool_new_buffer(pool);
return gst_buffer_pool_new_buffer (pool);
}
/**
@ -90,19 +92,23 @@ GstBuffer *gst_buffer_new_from_pool(GstBufferPool *pool)
*
* Returns: new buffer
*/
GstBuffer *gst_buffer_create_sub(GstBuffer *parent,guint32 offset,guint32 size) {
GstBuffer*
gst_buffer_create_sub (GstBuffer *parent,
guint32 offset,
guint32 size)
{
GstBuffer *buffer;
g_return_val_if_fail(parent != NULL, NULL);
g_return_val_if_fail(size > 0, NULL);
g_return_val_if_fail((offset+size) <= parent->size, NULL);
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (size > 0, NULL);
g_return_val_if_fail ((offset+size) <= parent->size, NULL);
buffer = g_mem_chunk_alloc(_gst_buffer_chunk);
DEBUG("BUF: allocating new subbuffer %p, parent %p\n",buffer,parent);
buffer = g_mem_chunk_alloc (_gst_buffer_chunk);
DEBUG("BUF: allocating new subbuffer %p, parent %p\n", buffer, parent);
buffer->lock = g_mutex_new();
buffer->lock = g_mutex_new ();
#ifdef HAVE_ATOMIC_H
atomic_set(&buffer->refcount,1);
atomic_set (&buffer->refcount, 1);
#else
buffer->refcount = 1;
#endif
@ -125,7 +131,7 @@ GstBuffer *gst_buffer_create_sub(GstBuffer *parent,guint32 offset,guint32 size)
// set parentage and reference the parent
buffer->parent = parent;
gst_buffer_ref(parent);
gst_buffer_ref (parent);
buffer->pool = NULL;
// return the new subbuffer
@ -142,33 +148,36 @@ GstBuffer *gst_buffer_create_sub(GstBuffer *parent,guint32 offset,guint32 size)
*
* Returns: new buffer
*/
GstBuffer *gst_buffer_append(GstBuffer *buffer, GstBuffer *append) {
GstBuffer*
gst_buffer_append (GstBuffer *buffer,
GstBuffer *append)
{
guint size;
GstBuffer *newbuf;
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(append != NULL, NULL);
g_return_val_if_fail(buffer->pool == NULL, NULL);
g_return_val_if_fail (buffer != NULL, NULL);
g_return_val_if_fail (append != NULL, NULL);
g_return_val_if_fail (buffer->pool == NULL, NULL);
GST_BUFFER_LOCK(buffer);
GST_BUFFER_LOCK (buffer);
// the buffer is not used by anyone else
if (GST_BUFFER_REFCOUNT(buffer) == 1 && buffer->parent == NULL) {
if (GST_BUFFER_REFCOUNT (buffer) == 1 && buffer->parent == NULL) {
// save the old size
size = buffer->size;
buffer->size += append->size;
buffer->data = g_realloc(buffer->data, buffer->size);
buffer->data = g_realloc (buffer->data, buffer->size);
memcpy(buffer->data + size, append->data, append->size);
GST_BUFFER_UNLOCK(buffer);
GST_BUFFER_UNLOCK (buffer);
}
// the buffer is used, create a new one
else {
newbuf = gst_buffer_new();
newbuf = gst_buffer_new ();
newbuf->size = buffer->size+append->size;
newbuf->data = g_malloc(newbuf->size);
memcpy(newbuf->data, buffer->data, buffer->size);
memcpy(newbuf->data+buffer->size, append->data, append->size);
GST_BUFFER_UNLOCK(buffer);
gst_buffer_unref(buffer);
newbuf->data = g_malloc (newbuf->size);
memcpy (newbuf->data, buffer->data, buffer->size);
memcpy (newbuf->data+buffer->size, append->data, append->size);
GST_BUFFER_UNLOCK (buffer);
gst_buffer_unref (buffer);
buffer = newbuf;
}
return buffer;
@ -180,43 +189,44 @@ GstBuffer *gst_buffer_append(GstBuffer *buffer, GstBuffer *append) {
*
* destroy the buffer
*/
void gst_buffer_destroy(GstBuffer *buffer) {
void gst_buffer_destroy (GstBuffer *buffer)
{
GSList *metas;
g_return_if_fail(buffer != NULL);
g_return_if_fail (buffer != NULL);
if (buffer->parent != NULL) {
DEBUG("BUF: freeing subbuffer %p\n",buffer);
DEBUG("BUF: freeing subbuffer %p\n", buffer);
}
else {
DEBUG("BUF: freeing buffer %p\n",buffer);
DEBUG("BUF: freeing buffer %p\n", buffer);
}
// free the data only if there is some, DONTFREE isn't set, and not sub
if (GST_BUFFER_DATA(buffer) &&
!GST_BUFFER_FLAG_IS_SET(buffer,GST_BUFFER_DONTFREE) &&
if (GST_BUFFER_DATA (buffer) &&
!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE) &&
(buffer->parent == NULL)) {
g_free(GST_BUFFER_DATA(buffer));
g_free (GST_BUFFER_DATA (buffer));
// g_print("freed data in buffer\n");
}
// unreference any metadata attached to this buffer
metas = buffer->metas;
while (metas) {
gst_meta_unref((GstMeta *)(metas->data));
metas = g_slist_next(metas);
gst_meta_unref ((GstMeta *)(metas->data));
metas = g_slist_next (metas);
}
g_slist_free(buffer->metas);
g_slist_free (buffer->metas);
// unreference the parent if there is one
if (buffer->parent != NULL)
gst_buffer_unref(buffer->parent);
gst_buffer_unref (buffer->parent);
g_mutex_free(buffer->lock);
g_mutex_free (buffer->lock);
//g_print("freed mutex\n");
// remove it entirely from memory
g_mem_chunk_free(_gst_buffer_chunk,buffer);
g_mem_chunk_free (_gst_buffer_chunk,buffer);
}
/**
@ -225,19 +235,21 @@ void gst_buffer_destroy(GstBuffer *buffer) {
*
* increment the refcount of this buffer
*/
void gst_buffer_ref(GstBuffer *buffer) {
g_return_if_fail(buffer != NULL);
void
gst_buffer_ref (GstBuffer *buffer)
{
g_return_if_fail (buffer != NULL);
DEBUG("BUF: referencing buffer %p\n",buffer);
DEBUG("BUF: referencing buffer %p\n", buffer);
#ifdef HAVE_ATOMIC_H
//g_return_if_fail(atomic_read(&(buffer->refcount)) > 0);
atomic_inc(&(buffer->refcount))
atomic_inc (&(buffer->refcount))
#else
g_return_if_fail(buffer->refcount > 0);
GST_BUFFER_LOCK(buffer);
g_return_if_fail (buffer->refcount > 0);
GST_BUFFER_LOCK (buffer);
buffer->refcount++;
GST_BUFFER_UNLOCK(buffer);
GST_BUFFER_UNLOCK (buffer);
#endif
}
@ -248,18 +260,20 @@ void gst_buffer_ref(GstBuffer *buffer) {
*
* increment the refcount of this buffer with count
*/
void gst_buffer_ref_by_count(GstBuffer *buffer,int count) {
g_return_if_fail(buffer != NULL);
g_return_if_fail(count > 0);
void
gst_buffer_ref_by_count (GstBuffer *buffer, int count)
{
g_return_if_fail (buffer != NULL);
g_return_if_fail (count > 0);
#ifdef HAVE_ATOMIC_H
g_return_if_fail(atomic_read(&(buffer->refcount)) > 0);
atomic_add(count,&(buffer->refcount))
g_return_if_fail (atomic_read (&(buffer->refcount)) > 0);
atomic_add (count, &(buffer->refcount))
#else
g_return_if_fail(buffer->refcount > 0);
GST_BUFFER_LOCK(buffer);
g_return_if_fail (buffer->refcount > 0);
GST_BUFFER_LOCK (buffer);
buffer->refcount += count;
GST_BUFFER_UNLOCK(buffer);
GST_BUFFER_UNLOCK (buffer);
#endif
}
@ -270,33 +284,35 @@ void gst_buffer_ref_by_count(GstBuffer *buffer,int count) {
* decrement the refcount of this buffer. If the refcount is
* zero, the buffer will be destroyed.
*/
void gst_buffer_unref(GstBuffer *buffer) {
int zero;
void
gst_buffer_unref (GstBuffer *buffer)
{
gint zero;
g_return_if_fail(buffer != NULL);
g_return_if_fail (buffer != NULL);
DEBUG("BUF: unreferencing buffer %p\n",buffer);
DEBUG("BUF: unreferencing buffer %p\n", buffer);
#ifdef HAVE_ATOMIC_H
g_return_if_fail(atomic_read(&(buffer->refcount)) > 0);
zero = atomic_dec_and_test(&(buffer->refcount))
g_return_if_fail (atomic_read (&(buffer->refcount)) > 0);
zero = atomic_dec_and_test (&(buffer->refcount))
#else
g_return_if_fail(buffer->refcount > 0);
GST_BUFFER_LOCK(buffer);
g_return_if_fail (buffer->refcount > 0);
GST_BUFFER_LOCK (buffer);
buffer->refcount--;
zero = (buffer->refcount == 0);
GST_BUFFER_UNLOCK(buffer);
GST_BUFFER_UNLOCK (buffer);
#endif
/* if we ended up with the refcount at zero, destroy the buffer */
if (zero) {
// if it came from a pool, give it back
if (buffer->pool != NULL) {
gst_buffer_pool_destroy_buffer(buffer->pool, buffer);
gst_buffer_pool_destroy_buffer (buffer->pool, buffer);
return;
}
else {
gst_buffer_destroy(buffer);
gst_buffer_destroy (buffer);
}
}
}
@ -308,12 +324,14 @@ void gst_buffer_unref(GstBuffer *buffer) {
*
* add the meta data to the buffer
*/
void gst_buffer_add_meta(GstBuffer *buffer,GstMeta *meta) {
g_return_if_fail(buffer != NULL);
g_return_if_fail(meta != NULL);
void
gst_buffer_add_meta (GstBuffer *buffer, GstMeta *meta)
{
g_return_if_fail (buffer != NULL);
g_return_if_fail (meta != NULL);
gst_meta_ref(meta);
buffer->metas = g_slist_append(buffer->metas,meta);
gst_meta_ref (meta);
buffer->metas = g_slist_append (buffer->metas,meta);
}
/**
@ -324,8 +342,10 @@ void gst_buffer_add_meta(GstBuffer *buffer,GstMeta *meta) {
*
* Returns: a GSList of metadata
*/
GSList *gst_buffer_get_metas(GstBuffer *buffer) {
g_return_val_if_fail(buffer != NULL, NULL);
GSList*
gst_buffer_get_metas (GstBuffer *buffer)
{
g_return_val_if_fail (buffer != NULL, NULL);
return buffer->metas;
}
@ -338,12 +358,14 @@ GSList *gst_buffer_get_metas(GstBuffer *buffer) {
*
* Returns: the first metadata from the buffer
*/
GstMeta *gst_buffer_get_first_meta(GstBuffer *buffer) {
g_return_val_if_fail(buffer != NULL, NULL);
GstMeta*
gst_buffer_get_first_meta (GstBuffer *buffer)
{
g_return_val_if_fail (buffer != NULL, NULL);
if (buffer->metas == NULL)
return NULL;
return GST_META(buffer->metas->data);
return GST_META (buffer->metas->data);
}
/**
@ -353,10 +375,12 @@ GstMeta *gst_buffer_get_first_meta(GstBuffer *buffer) {
*
* remove the given metadata from the buffer
*/
void gst_buffer_remove_meta(GstBuffer *buffer,GstMeta *meta) {
g_return_if_fail(buffer != NULL);
g_return_if_fail(meta != NULL);
void
gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *meta)
{
g_return_if_fail (buffer != NULL);
g_return_if_fail (meta != NULL);
buffer->metas = g_slist_remove(buffer->metas,meta);
gst_meta_unref(meta);
buffer->metas = g_slist_remove (buffer->metas, meta);
gst_meta_unref (meta);
}

View file

@ -30,15 +30,17 @@
*
* Returns: new buffer pool
*/
GstBufferPool *gst_buffer_pool_new()
GstBufferPool*
gst_buffer_pool_new (void)
{
GstBufferPool *pool;
pool = g_malloc(sizeof(GstBufferPool));
pool = g_malloc (sizeof(GstBufferPool));
DEBUG("BUF: allocating new buffer pool %p\n", pool);
pool->new_buffer = NULL;
pool->destroy_buffer = NULL;
return pool;
}
@ -51,9 +53,12 @@ GstBufferPool *gst_buffer_pool_new()
* Sets the function that will be called when a buffer is created
* from this pool.
*/
void gst_buffer_pool_set_create_function(GstBufferPool *pool, GstBufferPoolCreateFunction create, gpointer user_data)
void
gst_buffer_pool_set_create_function (GstBufferPool *pool,
GstBufferPoolCreateFunction create,
gpointer user_data)
{
g_return_if_fail(pool != NULL);
g_return_if_fail (pool != NULL);
pool->new_buffer = create;
pool->new_user_data = user_data;
@ -68,9 +73,12 @@ void gst_buffer_pool_set_create_function(GstBufferPool *pool, GstBufferPoolCreat
* Sets the function that will be called when a buffer is destroyed
* from this pool.
*/
void gst_buffer_pool_set_destroy_function(GstBufferPool *pool, GstBufferPoolDestroyFunction destroy, gpointer user_data)
void
gst_buffer_pool_set_destroy_function (GstBufferPool *pool,
GstBufferPoolDestroyFunction destroy,
gpointer user_data)
{
g_return_if_fail(pool != NULL);
g_return_if_fail (pool != NULL);
pool->destroy_buffer = destroy;
pool->destroy_user_data = user_data;
@ -82,9 +90,10 @@ void gst_buffer_pool_set_destroy_function(GstBufferPool *pool, GstBufferPoolDest
*
* frees the memory for this bufferpool
*/
void gst_buffer_pool_destroy(GstBufferPool *pool)
void
gst_buffer_pool_destroy (GstBufferPool *pool)
{
g_return_if_fail(pool != NULL);
g_return_if_fail (pool != NULL);
g_free(pool);
}
@ -97,13 +106,14 @@ void gst_buffer_pool_destroy(GstBufferPool *pool)
*
* Returns: The new buffer
*/
GstBuffer *gst_buffer_pool_new_buffer(GstBufferPool *pool)
GstBuffer*
gst_buffer_pool_new_buffer (GstBufferPool *pool)
{
GstBuffer *buffer;
g_return_val_if_fail(pool != NULL, NULL);
g_return_val_if_fail (pool != NULL, NULL);
buffer = pool->new_buffer(pool, pool->new_user_data);
buffer = pool->new_buffer (pool, pool->new_user_data);
buffer->pool = pool;
return buffer;
@ -116,10 +126,12 @@ GstBuffer *gst_buffer_pool_new_buffer(GstBufferPool *pool)
*
* Gives a buffer back to the given pool.
*/
void gst_buffer_pool_destroy_buffer(GstBufferPool *pool, GstBuffer *buffer)
void
gst_buffer_pool_destroy_buffer (GstBufferPool *pool,
GstBuffer *buffer)
{
g_return_if_fail(pool != NULL);
g_return_if_fail(buffer != NULL);
g_return_if_fail (pool != NULL);
g_return_if_fail (buffer != NULL);
pool->destroy_buffer(pool, buffer, pool->new_user_data);
pool->destroy_buffer (pool, buffer, pool->new_user_data);
}

View file

@ -31,93 +31,103 @@ static GstClock *the_system_clock = NULL;
*
* Returns: the new clock element
*/
GstClock *gst_clock_new(gchar *name) {
GstClock*
gst_clock_new (gchar *name)
{
GstClock *clock = (GstClock *) g_malloc(sizeof(GstClock));
clock->name = g_strdup(name);
clock->name = g_strdup (name);
clock->sinkobjects = NULL;
clock->sinkmutex = g_mutex_new();
clock->lock = g_mutex_new();
g_mutex_lock(clock->sinkmutex);
clock->sinkmutex = g_mutex_new ();
clock->lock = g_mutex_new ();
g_mutex_lock (clock->sinkmutex);
clock->num = 0;
clock->num_locked = 0;
clock->locking = FALSE;
return clock;
}
GstClock *gst_clock_get_system() {
GstClock*
gst_clock_get_system(void)
{
if (the_system_clock == NULL) {
the_system_clock = gst_clock_new("system_clock");
gst_clock_reset(the_system_clock);
the_system_clock = gst_clock_new ("system_clock");
gst_clock_reset (the_system_clock);
}
return the_system_clock;
}
void gst_clock_register(GstClock *clock, GstObject *obj) {
if (GST_IS_SINK(obj)) {
void
gst_clock_register (GstClock *clock, GstObject *obj)
{
if (GST_IS_SINK (obj)) {
DEBUG("gst_clock: setting registered sink object 0x%p\n", obj);
clock->sinkobjects = g_list_append(clock->sinkobjects, obj);
clock->sinkobjects = g_list_append (clock->sinkobjects, obj);
clock->num++;
}
}
void gst_clock_set(GstClock *clock, GstClockTime time) {
struct timeval tfnow;
GstClockTime now;
gettimeofday(&tfnow, (struct timezone *)NULL);
now = tfnow.tv_sec*1000000LL+tfnow.tv_usec;
g_mutex_lock(clock->lock);
clock->start_time = now - time;
g_mutex_unlock(clock->lock);
DEBUG("gst_clock: setting clock to %llu %llu %llu\n", time, now, clock->start_time);
}
GstClockTimeDiff gst_clock_current_diff(GstClock *clock, GstClockTime time)
void
gst_clock_set (GstClock *clock, GstClockTime time)
{
struct timeval tfnow;
GstClockTime now;
gettimeofday(&tfnow, (struct timezone *)NULL);
g_mutex_lock(clock->lock);
now = ((guint64)tfnow.tv_sec*1000000LL+tfnow.tv_usec) - (guint64)clock->start_time;
//if (clock->locking) now = 0;
g_mutex_unlock(clock->lock);
//DEBUG("gst_clock: diff with for time %08llu %08lld %08lld %08llu\n", time, now, GST_CLOCK_DIFF(time, now), clock->start_time);
return GST_CLOCK_DIFF(time, now);
gettimeofday (&tfnow, (struct timezone *)NULL);
now = tfnow.tv_sec*1000000LL+tfnow.tv_usec;
g_mutex_lock (clock->lock);
clock->start_time = now - time;
g_mutex_unlock (clock->lock);
DEBUG("gst_clock: setting clock to %llu %llu %llu\n", time, now, clock->start_time);
}
void gst_clock_reset(GstClock *clock) {
GstClockTimeDiff
gst_clock_current_diff (GstClock *clock, GstClockTime time)
{
struct timeval tfnow;
GstClockTime now;
gettimeofday (&tfnow, (struct timezone *)NULL);
g_mutex_lock (clock->lock);
now = ((guint64)tfnow.tv_sec*1000000LL+tfnow.tv_usec) - (guint64)clock->start_time;
g_mutex_unlock (clock->lock);
return GST_CLOCK_DIFF (time, now);
}
void
gst_clock_reset (GstClock *clock)
{
struct timeval tfnow;
gettimeofday(&tfnow, (struct timezone *)NULL);
g_mutex_lock(clock->lock);
gettimeofday (&tfnow, (struct timezone *)NULL);
g_mutex_lock (clock->lock);
clock->start_time = ((guint64)tfnow.tv_sec)*1000000LL+tfnow.tv_usec;
clock->current_time = clock->start_time;
clock->adjust = 0LL;
DEBUG("gst_clock: setting start clock %llu\n", clock->start_time);
//clock->locking = TRUE;
g_mutex_unlock(clock->lock);
g_mutex_unlock (clock->lock);
}
void gst_clock_wait(GstClock *clock, GstClockTime time, GstObject *obj) {
void
gst_clock_wait (GstClock *clock, GstClockTime time, GstObject *obj)
{
struct timeval tfnow;
GstClockTime now;
GstClockTimeDiff diff;
//DEBUG("gst_clock: requesting clock object 0x%p %08llu %08llu\n", obj, time, clock->current_time);
gettimeofday(&tfnow, (struct timezone *)NULL);
g_mutex_lock(clock->lock);
gettimeofday (&tfnow, (struct timezone *)NULL);
g_mutex_lock (clock->lock);
now = tfnow.tv_sec*1000000LL+tfnow.tv_usec - clock->start_time;
//now = clock->current_time + clock->adjust;
diff = GST_CLOCK_DIFF(time, now);
diff = GST_CLOCK_DIFF (time, now);
// if we are not behind wait a bit
DEBUG("gst_clock: %s waiting for time %08llu %08llu %08lld\n", gst_element_get_name(GST_ELEMENT(obj)), time, now, diff);
g_mutex_unlock(clock->lock);
g_mutex_unlock (clock->lock);
if (diff > 10000 ) {
tfnow.tv_usec = (diff % 1000000);
tfnow.tv_sec = diff / 1000000;
@ -125,14 +135,8 @@ void gst_clock_wait(GstClock *clock, GstClockTime time, GstObject *obj) {
if (!tfnow.tv_sec) {
select(0, NULL, NULL, NULL, &tfnow);
}
else printf("gst_clock: %s waiting %u %llu %llu %llu seconds\n", gst_element_get_name(GST_ELEMENT(obj)),
else DEBUG("gst_clock: %s waiting %u %llu %llu %llu seconds\n", gst_element_get_name(GST_ELEMENT(obj)),
(int)tfnow.tv_sec, now, diff, time);
//DEBUG("gst_clock: 0x%p waiting for time %llu %llu %lld %llu\n", obj, time, target, diff, now);
//DEBUG("waiting %d.%08d\n",tfnow.tv_sec, tfnow.tv_usec);
//DEBUG("gst_clock: 0x%p waiting done time %llu \n", obj, time);
}
DEBUG("gst_clock: %s waiting for time %08llu %08llu %08lld done \n", gst_element_get_name(GST_ELEMENT(obj)), time, now, diff);
// clock->current_time = clock->start_time + time;
//gst_clock_set(clock, time);
}

View file

@ -32,8 +32,8 @@ enum {
};
static void gst_connection_class_init(GstConnectionClass *klass);
static void gst_connection_init(GstConnection *connection);
static void gst_connection_class_init (GstConnectionClass *klass);
static void gst_connection_init (GstConnection *connection);
static GstElementClass *parent_class = NULL;
@ -54,21 +54,24 @@ gst_connection_get_type(void) {
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
connection_type = gtk_type_unique(GST_TYPE_ELEMENT,&connection_info);
connection_type = gtk_type_unique (GST_TYPE_ELEMENT, &connection_info);
}
return connection_type;
}
static void
gst_connection_class_init(GstConnectionClass *klass) {
gst_connection_class_init (GstConnectionClass *klass)
{
GtkObjectClass *gtkobject_class;
gtkobject_class = (GtkObjectClass*)klass;
parent_class = gtk_type_class(GST_TYPE_ELEMENT);
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
}
static void gst_connection_init(GstConnection *connection) {
static void
gst_connection_init (GstConnection *connection)
{
}
/**
@ -79,9 +82,13 @@ static void gst_connection_init(GstConnection *connection) {
*
* Returns: new connection
*/
GstElement *gst_connection_new(gchar *name) {
GstElement *connection = GST_ELEMENT(gtk_type_new(gst_connection_get_type()));
gst_element_set_name(GST_ELEMENT(connection),name);
GstElement*
gst_connection_new (gchar *name)
{
GstElement *connection = GST_ELEMENT (gtk_type_new (gst_connection_get_type ()));
gst_element_set_name (GST_ELEMENT (connection), name);
return connection;
}
@ -91,15 +98,17 @@ GstElement *gst_connection_new(gchar *name) {
*
* Push a buffer along a connection
*/
void gst_connection_push(GstConnection *connection) {
void
gst_connection_push (GstConnection *connection)
{
GstConnectionClass *oclass;
g_return_if_fail(connection != NULL);
g_return_if_fail(GST_IS_CONNECTION(connection));
g_return_if_fail (connection != NULL);
g_return_if_fail (GST_IS_CONNECTION (connection));
oclass = (GstConnectionClass *)(GTK_OBJECT(connection)->klass);
oclass = (GstConnectionClass *)(GTK_OBJECT (connection)->klass);
g_return_if_fail(oclass->push != NULL);
g_return_if_fail (oclass->push != NULL);
(oclass->push)(connection);
}

View file

@ -31,7 +31,8 @@ void gst_cpuid_i386(int,long *,long *,long *,long *);
#define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c);
#endif
void _gst_cpu_initialize(void)
void
_gst_cpu_initialize (void)
{
long eax=0, ebx=0, ecx=0, edx=0;
@ -55,7 +56,8 @@ void _gst_cpu_initialize(void)
}
GstCPUFlags gst_cpu_get_flags(void)
GstCPUFlags
gst_cpu_get_flags (void)
{
return _gst_cpu_flags;
}

View file

@ -18,6 +18,7 @@
*/
#include <gst/gstelement.h>
#include <gst/gstextratypes.h>
#include <gst/gstxml.h>
/* Element signals and args */
@ -35,12 +36,12 @@ enum {
};
static void gst_element_class_init(GstElementClass *klass);
static void gst_element_init(GstElement *element);
static void gst_element_real_destroy(GtkObject *object);
static void gst_element_class_init (GstElementClass *klass);
static void gst_element_init (GstElement *element);
GstElementStateReturn gst_element_change_state(GstElement *element);
static void gst_element_real_destroy (GtkObject *object);
static GstElementStateReturn gst_element_change_state(GstElement *element);
static GstObjectClass *parent_class = NULL;
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
@ -64,7 +65,9 @@ GtkType gst_element_get_type(void) {
return element_type;
}
static void gst_element_class_init(GstElementClass *klass) {
static void
gst_element_class_init (GstElementClass *klass)
{
GtkObjectClass *gtkobject_class;
gtkobject_class = (GtkObjectClass*)klass;
@ -72,35 +75,37 @@ static void gst_element_class_init(GstElementClass *klass) {
parent_class = gtk_type_class(GST_TYPE_OBJECT);
gst_element_signals[STATE_CHANGE] =
gtk_signal_new("state_change",GTK_RUN_LAST,gtkobject_class->type,
GTK_SIGNAL_OFFSET(GstElementClass,state_change),
gtk_marshal_NONE__INT,GTK_TYPE_NONE,1,
GTK_TYPE_INT);
gtk_signal_new ("state_change", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstElementClass, state_change),
gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1,
GTK_TYPE_INT);
gst_element_signals[NEW_PAD] =
gtk_signal_new("new_pad",GTK_RUN_LAST,gtkobject_class->type,
GTK_SIGNAL_OFFSET(GstElementClass,new_pad),
gtk_marshal_NONE__POINTER,GTK_TYPE_NONE,1,
GST_TYPE_PAD);
gtk_signal_new ("new_pad", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstElementClass, new_pad),
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
GST_TYPE_PAD);
gst_element_signals[NEW_GHOST_PAD] =
gtk_signal_new("new_ghost_pad",GTK_RUN_LAST,gtkobject_class->type,
GTK_SIGNAL_OFFSET(GstElementClass,new_ghost_pad),
gtk_marshal_NONE__POINTER,GTK_TYPE_NONE,1,
GST_TYPE_PAD);
gtk_signal_new ("new_ghost_pad", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstElementClass, new_ghost_pad),
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
GST_TYPE_PAD);
gst_element_signals[ERROR] =
gtk_signal_new("error",GTK_RUN_LAST,gtkobject_class->type,
GTK_SIGNAL_OFFSET(GstElementClass,error),
gtk_marshal_NONE__STRING,GTK_TYPE_NONE,1,
GTK_TYPE_STRING);
gtk_signal_new ("error", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstElementClass, error),
gtk_marshal_NONE__STRING, GTK_TYPE_NONE,1,
GTK_TYPE_STRING);
gtk_object_class_add_signals(gtkobject_class,gst_element_signals,LAST_SIGNAL);
gtk_object_class_add_signals (gtkobject_class, gst_element_signals, LAST_SIGNAL);
klass->change_state = gst_element_change_state;
gtkobject_class->destroy = gst_element_real_destroy;
}
static void gst_element_init(GstElement *element) {
static void
gst_element_init (GstElement *element)
{
element->current_state = GST_STATE_NULL;
element->pending_state = -1;
element->numpads = 0;
@ -115,8 +120,10 @@ static void gst_element_init(GstElement *element) {
*
* Returns: new element
*/
GstElement *gst_element_new() {
return GST_ELEMENT(gtk_type_new(GST_TYPE_ELEMENT));
GstElement*
gst_element_new(void)
{
return GST_ELEMENT (gtk_type_new (GST_TYPE_ELEMENT));
}
/**
@ -127,22 +134,24 @@ GstElement *gst_element_new() {
* Add a pad (connection point) to the element, setting the parent of the
* pad to the element (and thus adding a reference).
*/
void gst_element_add_pad(GstElement *element,GstPad *pad) {
g_return_if_fail(element != NULL);
g_return_if_fail(GST_IS_ELEMENT(element));
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
void
gst_element_add_pad (GstElement *element, GstPad *pad)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
/* set the pad's parent */
gst_pad_set_parent(pad,GST_OBJECT(element));
gst_pad_set_parent (pad,GST_OBJECT (element));
/* add it to the list */
element->pads = g_list_append(element->pads,pad);
element->pads = g_list_append (element->pads, pad);
element->numpads++;
/* emit the NEW_PAD signal */
// g_print("emitting NEW_PAD signal, \"%s\"!\n",gst_pad_get_name(pad));
gtk_signal_emit(GTK_OBJECT(element),gst_element_signals[NEW_PAD],pad);
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[NEW_PAD], pad);
}
/**
@ -153,21 +162,23 @@ void gst_element_add_pad(GstElement *element,GstPad *pad) {
* Add a ghost pad to the element, setting the ghost parent of the pad to
* the element (and thus adding a reference).
*/
void gst_element_add_ghost_pad(GstElement *element,GstPad *pad) {
g_return_if_fail(element != NULL);
g_return_if_fail(GST_IS_ELEMENT(element));
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
void
gst_element_add_ghost_pad (GstElement *element, GstPad *pad)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
/* set the pad's parent */
gst_pad_add_ghost_parent(pad,GST_OBJECT(element));
gst_pad_add_ghost_parent (pad,GST_OBJECT (element));
/* add it to the list */
element->pads = g_list_append(element->pads,pad);
element->pads = g_list_append (element->pads, pad);
element->numpads++;
/* emit the NEW_PAD signal */
gtk_signal_emit(GTK_OBJECT(element),gst_element_signals[NEW_GHOST_PAD],pad);
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[NEW_GHOST_PAD], pad);
}
/**
@ -179,11 +190,14 @@ void gst_element_add_ghost_pad(GstElement *element,GstPad *pad) {
*
* Returns: requested pad if found, otherwise NULL.
*/
GstPad *gst_element_get_pad(GstElement *element,gchar *name) {
GstPad*
gst_element_get_pad (GstElement *element, 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 (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
if (name == NULL)
return NULL;
if (!element->numpads)
@ -191,9 +205,9 @@ GstPad *gst_element_get_pad(GstElement *element,gchar *name) {
walk = element->pads;
while (walk) {
if (!strcmp(((GstPad *)(walk->data))->name,name))
if (!strcmp (((GstPad *)(walk->data))->name, name))
return (GstPad *)(walk->data);
walk = g_list_next(walk);
walk = g_list_next (walk);
}
return NULL;
@ -207,9 +221,11 @@ GstPad *gst_element_get_pad(GstElement *element,gchar *name) {
*
* Returns: GList of pads
*/
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);
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);
return element->pads;
}
@ -226,26 +242,29 @@ GList *gst_element_get_pad_list(GstElement *element) {
* child of the parent of the other element. If they have different
* parents, the connection fails.
*/
void gst_element_connect(GstElement *src,gchar *srcpadname,
GstElement *dest,gchar *destpadname) {
void
gst_element_connect (GstElement *src, gchar *srcpadname,
GstElement *dest, gchar *destpadname)
{
GstPad *srcpad,*destpad;
GstObject *srcparent,*destparent;
g_return_if_fail(src != NULL);
g_return_if_fail(GST_IS_ELEMENT(src));
g_return_if_fail(srcpadname != NULL);
g_return_if_fail(dest != NULL);
g_return_if_fail(GST_IS_ELEMENT(dest));
g_return_if_fail(destpadname != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (GST_IS_ELEMENT(src));
g_return_if_fail (srcpadname != NULL);
g_return_if_fail (dest != NULL);
g_return_if_fail (GST_IS_ELEMENT(dest));
g_return_if_fail (destpadname != NULL);
srcpad = gst_element_get_pad(src,srcpadname);
destpad = gst_element_get_pad(dest,destpadname);
srcpad = gst_element_get_pad (src, srcpadname);
destpad = gst_element_get_pad (dest, destpadname);
g_return_if_fail(srcpad != NULL);
g_return_if_fail(destpad != NULL);
g_return_if_fail (srcpad != NULL);
g_return_if_fail (destpad != NULL);
srcparent = gst_object_get_parent(GST_OBJECT(src));
destparent = gst_object_get_parent(GST_OBJECT(dest));
srcparent = gst_object_get_parent (GST_OBJECT (src));
destparent = gst_object_get_parent (GST_OBJECT (dest));
/* we can't do anything if neither have parents */
if ((srcparent == NULL) && (destparent == NULL))
return;
@ -265,10 +284,12 @@ void gst_element_connect(GstElement *src,gchar *srcpadname,
* This function is used internally by elements to signal an error
* condition. It results in the "error" signal.
*/
void gst_element_error(GstElement *element,gchar *error) {
g_error("GstElement: error in element '%s': %s\n",element->name,error);
void
gst_element_error (GstElement *element, gchar *error)
{
g_error("GstElement: error in element '%s': %s\n", element->name, error);
gtk_signal_emit(GTK_OBJECT(element),gst_element_signals[ERROR],error);
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[ERROR], error);
}
@ -282,22 +303,24 @@ void gst_element_error(GstElement *element,gchar *error) {
*
* Returns: whether or not the state was successfully set.
*/
gint gst_element_set_state(GstElement *element,GstElementState state) {
gint
gst_element_set_state (GstElement *element, GstElementState state)
{
GstElementClass *oclass;
GstElementStateReturn return_val = GST_STATE_SUCCESS;
// g_print("gst_element_set_state(\"%s\",%08lx)\n",
// element->name,state);
g_return_val_if_fail(element != NULL, GST_STATE_FAILURE);
g_return_val_if_fail(GST_IS_ELEMENT(element), GST_STATE_FAILURE);
g_return_val_if_fail (element != NULL, GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
// first we set the pending state variable
// FIXME should probably check to see that we don't already have one
GST_STATE_PENDING(element) = state;
GST_STATE_PENDING (element) = state;
// now we call the state change function so it can set the state
oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
if (oclass->change_state)
return_val = (oclass->change_state)(element);
@ -312,13 +335,15 @@ gint gst_element_set_state(GstElement *element,GstElementState state) {
*
* Returns: the factory used for creating this element
*/
GstElementFactory *gst_element_get_factory(GstElement *element) {
GstElementFactory*
gst_element_get_factory (GstElement *element)
{
GstElementClass *oclass;
g_return_val_if_fail(element != NULL, NULL);
g_return_val_if_fail(GST_IS_ELEMENT(element), NULL);
g_return_val_if_fail (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
return oclass->elementfactory;
}
@ -333,18 +358,20 @@ GstElementFactory *gst_element_get_factory(GstElement *element) {
*
* Returns: whether or not the state change was successfully set.
*/
GstElementStateReturn gst_element_change_state(GstElement *element) {
g_return_val_if_fail(element != NULL, GST_STATE_FAILURE);
g_return_val_if_fail(GST_IS_ELEMENT(element), GST_STATE_FAILURE);
GstElementStateReturn
gst_element_change_state (GstElement *element)
{
g_return_val_if_fail (element != NULL, GST_STATE_FAILURE);
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
// g_print("gst_element_change_state(\"%s\",%d)\n",
// element->name,state);
GST_STATE(element) = GST_STATE_PENDING(element);
GST_STATE_PENDING(element) = GST_STATE_NONE_PENDING;
GST_STATE (element) = GST_STATE_PENDING (element);
GST_STATE_PENDING (element) = GST_STATE_NONE_PENDING;
gtk_signal_emit(GTK_OBJECT(element),gst_element_signals[STATE_CHANGE],
GST_STATE(element));
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[STATE_CHANGE],
GST_STATE (element));
return TRUE;
}
@ -356,15 +383,17 @@ GstElementStateReturn gst_element_change_state(GstElement *element) {
* Set the name of the element, getting rid of the old name if there was
* one.
*/
void gst_element_set_name(GstElement *element,gchar *name) {
g_return_if_fail(element != NULL);
g_return_if_fail(GST_IS_ELEMENT(element));
g_return_if_fail(name != NULL);
void
gst_element_set_name (GstElement *element, gchar *name)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (name != NULL);
if (element->name != NULL)
g_free(element->name);
element->name = g_strdup(name);
element->name = g_strdup (name);
}
/**
@ -375,31 +404,35 @@ void gst_element_set_name(GstElement *element,gchar *name) {
*
* Returns: name of the element
*/
gchar *gst_element_get_name(GstElement *element) {
g_return_val_if_fail(element != NULL, NULL);
g_return_val_if_fail(GST_IS_ELEMENT(element), NULL);
const gchar*
gst_element_get_name (GstElement *element)
{
g_return_val_if_fail (element != NULL, NULL);
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
return element->name;
}
static void gst_element_real_destroy(GtkObject *object) {
GstElement *element = GST_ELEMENT(object);
static void
gst_element_real_destroy (GtkObject *object)
{
GstElement *element = GST_ELEMENT (object);
GList *pads;
GstPad *pad;
// g_print("in gst_element_real_destroy()\n");
if (element->name)
g_free(element->name);
g_free (element->name);
pads = element->pads;
while (pads) {
pad = GST_PAD(pads->data);
gst_pad_destroy(pad);
pads = g_list_next(pads);
pad = GST_PAD (pads->data);
gst_pad_destroy (pad);
pads = g_list_next (pads);
}
g_list_free(element->pads);
g_list_free (element->pads);
}
/*
@ -428,7 +461,10 @@ static gchar *_gst_element_type_names[] = {
*
* Returns: the new xml node
*/
xmlNodePtr gst_element_save_thyself(GstElement *element,xmlNodePtr parent) {
xmlNodePtr
gst_element_save_thyself (GstElement *element,
xmlNodePtr parent)
{
xmlNodePtr self;
GList *pads;
GstPad *pad;
@ -436,86 +472,92 @@ xmlNodePtr gst_element_save_thyself(GstElement *element,xmlNodePtr parent) {
GstElementFactory *factory;
GtkType type;
oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
self = xmlNewChild(parent,NULL,"element",NULL);
xmlNewChild(self,NULL,"name",element->name);
self = xmlNewChild (parent, NULL, "element", NULL);
xmlNewChild(self, NULL, "name", element->name);
if (oclass->elementfactory != NULL) {
factory = (GstElementFactory *)oclass->elementfactory;
xmlNewChild(self,NULL,"type",factory->name);
xmlNewChild(self,NULL,"version",factory->details->version);
xmlNewChild (self, NULL, "type", factory->name);
xmlNewChild (self, NULL, "version", factory->details->version);
}
pads = element->pads;
while (pads) {
xmlNodePtr padtag = xmlNewChild(self,NULL,"pad",NULL);
pad = GST_PAD(pads->data);
xmlNodePtr padtag = xmlNewChild (self, NULL, "pad", NULL);
pad = GST_PAD (pads->data);
// figure out if it's a direct pad or a ghostpad
if (GST_ELEMENT(pad->parent) == element)
gst_pad_save_thyself(pad,padtag);
pads = g_list_next(pads);
if (GST_ELEMENT (pad->parent) == element)
gst_pad_save_thyself (pad, padtag);
pads = g_list_next (pads);
}
// output all args to the element
type = GTK_OBJECT_TYPE(element);
type = GTK_OBJECT_TYPE (element);
while (type != GTK_TYPE_INVALID) {
GtkArg *args;
guint32 *flags;
guint num_args,i;
args = gtk_object_query_args(type,&flags,&num_args);
for (i=0;i<num_args;i++) {
args = gtk_object_query_args (type, &flags, &num_args);
for (i=0; i<num_args; i++) {
if ((args[i].type > GTK_TYPE_NONE) &&
(args[i].type <= GTK_TYPE_STRING) &&
(flags && GTK_ARG_READABLE)) {
//(args[i].type <= GTK_TYPE_STRING) &&
(flags[i] & GTK_ARG_READABLE)) {
xmlNodePtr arg;
gtk_object_getv(GTK_OBJECT(element),1,&args[i]);
arg = xmlNewChild(self,NULL,"arg",NULL);
xmlNewChild(arg,NULL,"name",args[i].name);
gtk_object_getv (GTK_OBJECT (element), 1, &args[i]);
arg = xmlNewChild (self, NULL, "arg", NULL);
xmlNewChild (arg, NULL, "name", args[i].name);
switch (args[i].type) {
case GTK_TYPE_CHAR:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%c",GTK_VALUE_CHAR(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%c", GTK_VALUE_CHAR (args[i])));
break;
case GTK_TYPE_UCHAR:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%d",GTK_VALUE_UCHAR(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%d", GTK_VALUE_UCHAR (args[i])));
break;
case GTK_TYPE_BOOL:
xmlNewChild(arg,NULL,"value",
GTK_VALUE_BOOL(args[1])?"true":"false");
xmlNewChild (arg, NULL, "value",
GTK_VALUE_BOOL (args[i]) ? "true" : "false");
break;
case GTK_TYPE_INT:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%d",GTK_VALUE_INT(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%d", GTK_VALUE_INT (args[i])));
break;
case GTK_TYPE_LONG:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%ld",GTK_VALUE_LONG(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%ld", GTK_VALUE_LONG (args[i])));
break;
case GTK_TYPE_ULONG:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%lu",GTK_VALUE_ULONG(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%lu", GTK_VALUE_ULONG (args[i])));
break;
case GTK_TYPE_FLOAT:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%f",GTK_VALUE_FLOAT(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%f", GTK_VALUE_FLOAT (args[i])));
break;
case GTK_TYPE_DOUBLE:
xmlNewChild(arg,NULL,"value",
g_strdup_printf("%g",GTK_VALUE_DOUBLE(args[i])));
xmlNewChild (arg, NULL, "value",
g_strdup_printf ("%g", GTK_VALUE_DOUBLE (args[i])));
break;
case GTK_TYPE_STRING:
xmlNewChild(arg,NULL,"value",GTK_VALUE_STRING(args[i]));
xmlNewChild (arg, NULL, "value", GTK_VALUE_STRING (args[i]));
break;
default:
if (args[i].type == GST_TYPE_FILENAME) {
xmlNewChild (arg, NULL, "value", GTK_VALUE_STRING (args[i]));
}
break;
}
}
}
type = gtk_type_parent(type);
type = gtk_type_parent (type);
}
if (oclass->save_thyself)
(oclass->save_thyself)(element,self);
(oclass->save_thyself)(element, self);
return self;
}
@ -530,7 +572,10 @@ xmlNodePtr gst_element_save_thyself(GstElement *element,xmlNodePtr parent) {
*
* Returns: the new element
*/
GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements) {
GstElement*
gst_element_load_thyself (xmlNodePtr parent,
GHashTable *elements)
{
xmlNodePtr children = parent->childs;
GstElement *element;
GstElementClass *oclass;
@ -540,50 +585,50 @@ GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements) {
// first get the needed tags to cunstruct the element
while (children) {
if (!strcmp(children->name, "name")) {
name = g_strdup(xmlNodeGetContent(children));
if (!strcmp (children->name, "name")) {
name = g_strdup (xmlNodeGetContent (children));
}
else if (!strcmp(children->name, "type")) {
type = g_strdup(xmlNodeGetContent(children));
else if (!strcmp (children->name, "type")) {
type = g_strdup (xmlNodeGetContent (children));
}
children = children->next;
}
g_assert(name != NULL);
g_assert(type != NULL);
g_assert (name != NULL);
g_assert (type != NULL);
g_print("gstelement: loading \"%s\" of type \"%s\"\n", name, type);
g_print ("gstelement: loading \"%s\" of type \"%s\"\n", name, type);
element = gst_elementfactory_make(type, name);
element = gst_elementfactory_make (type, name);
g_assert(element != NULL);
g_assert (element != NULL);
g_hash_table_insert(elements, gst_element_get_name(element), element);
g_hash_table_insert (elements, g_strdup (gst_element_get_name (element)), element);
// we have the element now, set the arguments and pads
children = parent->childs;
while (children) {
if (!strcmp(children->name, "pad")) {
gst_pad_load_and_connect(children, GST_OBJECT(element), elements);
if (!strcmp (children->name, "pad")) {
gst_pad_load_and_connect (children, GST_OBJECT(element), elements);
}
else if (!strcmp(children->name, "arg")) {
else if (!strcmp (children->name, "arg")) {
xmlNodePtr child = children->childs;
while (child) {
if (!strcmp(child->name, "name")) {
name = g_strdup(xmlNodeGetContent(child));
if (!strcmp (child->name, "name")) {
name = g_strdup (xmlNodeGetContent (child));
}
else if (!strcmp(child->name, "value")) {
value = g_strdup(xmlNodeGetContent(child));
else if (!strcmp (child->name, "value")) {
value = g_strdup (xmlNodeGetContent (child));
}
child = child->next;
}
if (name && value) {
GtkType type = GTK_OBJECT_TYPE(element);
GtkType type = GTK_OBJECT_TYPE (element);
GtkArgInfo *info;
gchar *result;
result = gtk_object_arg_get_info(type, name, &info);
result = gtk_object_arg_get_info (type, name, &info);
if (result) {
g_print("gstelement: %s\n", result);
@ -591,57 +636,60 @@ GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements) {
else if (info->arg_flags & GTK_ARG_WRITABLE) {
switch (info->type) {
case GTK_TYPE_STRING:
gtk_object_set(GTK_OBJECT(element), name, value, NULL);
gtk_object_set (GTK_OBJECT (element), name, value, NULL);
break;
case GTK_TYPE_INT: {
gint i;
sscanf(value, "%d", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%d", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_LONG: {
glong i;
sscanf(value, "%ld", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%ld", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_ULONG: {
gulong i;
sscanf(value, "%lu", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%lu", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_BOOL: {
gboolean i = FALSE;
if (!strcmp("true", value)) i = TRUE;
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
if (!strcmp ("true", value)) i = TRUE;
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_CHAR: {
gchar i;
sscanf(value, "%c", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%c", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_UCHAR: {
guchar i;
sscanf(value, "%c", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%c", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_FLOAT: {
gfloat i;
sscanf(value, "%f", &i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%f", &i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
case GTK_TYPE_DOUBLE: {
gdouble i;
sscanf(value, "%g", (float *)&i);
gtk_object_set(GTK_OBJECT(element), name, i, NULL);
sscanf (value, "%g", (float *)&i);
gtk_object_set (GTK_OBJECT (element), name, i, NULL);
break;
}
default:
if (info->type == GST_TYPE_FILENAME) {
gtk_object_set (GTK_OBJECT (element), name, value, NULL);
}
break;
}
@ -651,10 +699,10 @@ GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements) {
children = children->next;
}
oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
oclass = GST_ELEMENT_CLASS (GTK_OBJECT (element)->klass);
if (oclass->restore_thyself)
(oclass->restore_thyself)(element, parent, elements);
(oclass->restore_thyself) (element, parent, elements);
return element;
}
@ -667,7 +715,10 @@ GstElement *gst_element_load_thyself(xmlNodePtr parent, GHashTable *elements) {
* Sets the manager of the element. For internal use only, unless you're
* writing a new bin subclass.
*/
void gst_element_set_manager(GstElement *element,GstElement *manager) {
void
gst_element_set_manager (GstElement *element,
GstElement *manager)
{
element->manager = manager;
}
@ -679,14 +730,18 @@ void gst_element_set_manager(GstElement *element,GstElement *manager) {
*
* Returns: Element's manager
*/
GstElement *gst_element_get_manager(GstElement *element) {
GstElement*
gst_element_get_manager (GstElement *element)
{
return element->manager;
}
// note that this casts a char ** to a GstElement *. Ick.
int gst_element_loopfunc_wrapper(int argc,char **argv) {
GstElement *element = GST_ELEMENT(argv);
element->loopfunc(element);
int
gst_element_loopfunc_wrapper (int argc, char **argv)
{
GstElement *element = GST_ELEMENT (argv);
element->loopfunc (element);
return 0;
}
@ -699,11 +754,14 @@ int gst_element_loopfunc_wrapper(int argc,char **argv) {
* can deviate from the GstElementLoopFunction definition in type of
* pointer only.
*/
void gst_element_set_loop_function(GstElement *element,
GstElementLoopFunction loop) {
void
gst_element_set_loop_function(GstElement *element,
GstElementLoopFunction loop)
{
element->loopfunc = loop;
if (element->threadstate != NULL)
// note that this casts a GstElement * to a char **. Ick.
cothread_setfunc(element->threadstate,gst_element_loopfunc_wrapper,
0,(char **)element);
cothread_setfunc (element->threadstate, gst_element_loopfunc_wrapper,
0, (char **)element);
}

View file

@ -160,7 +160,7 @@ void gst_element_set_loop_function (GstElement *element,
GstElementLoopFunction loop);
void gst_element_set_name (GstElement *element, gchar *name);
gchar* gst_element_get_name (GstElement *element);
const gchar* gst_element_get_name (GstElement *element);
void gst_element_set_manager (GstElement *element, GstElement *manager);
GstElement* gst_element_get_manager (GstElement *element);

View file

@ -19,7 +19,9 @@
#include <gst/gstextratypes.h>
GtkType gst_extra_get_filename_type(void) {
GtkType
gst_extra_get_filename_type (void)
{
static GtkType filename_type = 0;
if (!filename_type) {
@ -33,7 +35,7 @@ GtkType gst_extra_get_filename_type(void) {
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
filename_type = gtk_type_unique(GTK_TYPE_STRING,&filename_info);
filename_type = gtk_type_unique (GTK_TYPE_STRING, &filename_info);
}
return filename_type;
}

View file

@ -32,9 +32,8 @@ enum {
};
static void gst_filter_class_init(GstFilterClass *klass);
static void gst_filter_init(GstFilter *filter);
static void gst_filter_class_init (GstFilterClass *klass);
static void gst_filter_init (GstFilter *filter);
static GstElementClass *parent_class = NULL;
//static guint gst_filter_signals[LAST_SIGNAL] = { 0 };
@ -60,15 +59,18 @@ gst_filter_get_type(void) {
}
static void
gst_filter_class_init(GstFilterClass *klass) {
gst_filter_class_init (GstFilterClass *klass)
{
GtkObjectClass *gtkobject_class;
gtkobject_class = (GtkObjectClass*)klass;
parent_class = gtk_type_class(GST_TYPE_ELEMENT);
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
}
static void gst_filter_init(GstFilter *filter) {
static void
gst_filter_init (GstFilter *filter)
{
}
/**
@ -79,8 +81,12 @@ static void gst_filter_init(GstFilter *filter) {
*
* Returns: new filter
*/
GstElement *gst_filter_new(gchar *name) {
GstElement *filter = GST_ELEMENT(gtk_type_new(gst_filter_get_type()));
gst_element_set_name(GST_ELEMENT(filter),name);
GstElement*
gst_filter_new (gchar *name)
{
GstElement *filter = GST_ELEMENT (gtk_type_new (gst_filter_get_type()));
gst_element_set_name (GST_ELEMENT (filter), name);
return filter;
}

View file

@ -1,3 +1,22 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GST_HGUARD_GSTI386_H
#define GST_HGUARD_GSTI386_H

View file

@ -30,11 +30,13 @@
*
* Returns: new meta object
*/
GstMeta *gst_meta_new_size(gint size) {
GstMeta*
gst_meta_new_size (gint size)
{
GstMeta *meta;
meta = g_malloc0(size);
gst_meta_ref(meta);
meta = g_malloc0 (size);
gst_meta_ref (meta);
return meta;
}
@ -45,10 +47,13 @@ GstMeta *gst_meta_new_size(gint size) {
*
* increases the refcount of a meta object
*/
void gst_meta_ref(GstMeta *meta) {
g_return_if_fail(meta != NULL);
void
gst_meta_ref (GstMeta *meta)
{
g_return_if_fail (meta != NULL);
gst_trace_add_entry(NULL,0,meta,"ref meta");
gst_trace_add_entry (NULL, 0, meta, "ref meta");
meta->refcount++;
}
@ -59,15 +64,17 @@ void gst_meta_ref(GstMeta *meta) {
* decreases the refcount of a meta object. if the refcount is zero, the
* meta object is freed.
*/
void gst_meta_unref(GstMeta *meta) {
g_return_if_fail(meta != NULL);
void
gst_meta_unref (GstMeta *meta)
{
g_return_if_fail (meta != NULL);
gst_trace_add_entry(NULL,0,meta,"unref meta");
gst_trace_add_entry (NULL, 0, meta, "unref meta");
meta->refcount--;
if (meta->refcount == 0) {
// gst_trace_add_entry(NULL,0,meta,"destroy meta");
g_free(meta);
g_free (meta);
// g_print("freeing metadata\n");
}
}
@ -82,7 +89,10 @@ void gst_meta_unref(GstMeta *meta) {
*
* Returns: the meta object or a copy.
*/
GstMeta *gst_meta_cow(GstMeta *meta) {
g_return_val_if_fail(meta != NULL, NULL);
return NULL;
GstMeta*
gst_meta_cow (GstMeta *meta)
{
g_return_val_if_fail (meta != NULL, NULL);
return NULL;
}

View file

@ -1,3 +1,22 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GST_HGUARD_GSTPPC_H
#define GST_HGUARD_GSTPPC_H

View file

@ -33,15 +33,15 @@ enum {
};
static void gst_sink_class_init(GstSinkClass *klass);
static void gst_sink_init(GstSink *sink);
static void gst_sink_class_init (GstSinkClass *klass);
static void gst_sink_init (GstSink *sink);
static GstElementClass *parent_class = NULL;
//static guint gst_sink_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_sink_get_type(void) {
gst_sink_get_type (void)
{
static GtkType sink_type = 0;
if (!sink_type) {
@ -55,21 +55,24 @@ gst_sink_get_type(void) {
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
sink_type = gtk_type_unique(GST_TYPE_ELEMENT,&sink_info);
sink_type = gtk_type_unique (GST_TYPE_ELEMENT, &sink_info);
}
return sink_type;
}
static void
gst_sink_class_init(GstSinkClass *klass) {
gst_sink_class_init (GstSinkClass *klass)
{
GtkObjectClass *gtkobject_class;
gtkobject_class = (GtkObjectClass*)klass;
parent_class = gtk_type_class(GST_TYPE_ELEMENT);
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
}
static void gst_sink_init(GstSink *sink) {
static void
gst_sink_init (GstSink *sink)
{
}
/**
@ -81,8 +84,11 @@ static void gst_sink_init(GstSink *sink) {
* Returns: new sink
*/
GstObject *gst_sink_new(gchar *name) {
GstObject *sink = GST_OBJECT(gtk_type_new(GST_TYPE_SINK));
gst_element_set_name(GST_ELEMENT(sink),name);
GstObject*
gst_sink_new (gchar *name)
{
GstObject *sink = GST_OBJECT (gtk_type_new (GST_TYPE_SINK));
gst_element_set_name (GST_ELEMENT (sink), name);
return sink;
}

View file

@ -35,12 +35,12 @@ enum {
static void gst_src_class_init(GstSrcClass *klass);
static void gst_src_init(GstSrc *src);
static GstElementClass *parent_class = NULL;
static guint gst_src_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_src_get_type(void) {
gst_src_get_type(void)
{
static GtkType src_type = 0;
if (!src_type) {
@ -54,28 +54,31 @@ gst_src_get_type(void) {
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
src_type = gtk_type_unique(GST_TYPE_ELEMENT,&src_info);
src_type = gtk_type_unique (GST_TYPE_ELEMENT, &src_info);
}
return src_type;
}
static void
gst_src_class_init(GstSrcClass *klass) {
gst_src_class_init (GstSrcClass *klass)
{
GtkObjectClass *gtkobject_class;
gtkobject_class = (GtkObjectClass*)klass;
parent_class = gtk_type_class(GST_TYPE_ELEMENT);
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
gst_src_signals[EOS] =
gtk_signal_new("eos",GTK_RUN_LAST,gtkobject_class->type,
GTK_SIGNAL_OFFSET(GstSrcClass,eos),
gtk_marshal_NONE__NONE,GTK_TYPE_NONE,0,
GST_TYPE_SRC);
gtk_object_class_add_signals(gtkobject_class,gst_src_signals,LAST_SIGNAL);
gtk_signal_new ("eos", GTK_RUN_LAST, gtkobject_class->type,
GTK_SIGNAL_OFFSET (GstSrcClass,eos),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (gtkobject_class, gst_src_signals, LAST_SIGNAL);
}
static void gst_src_init(GstSrc *src) {
static void
gst_src_init (GstSrc *src)
{
src->flags = 0;
}
@ -86,11 +89,13 @@ static void gst_src_init(GstSrc *src) {
* singals the eos signal to indicate that the end of the stream
* is reached.
*/
void gst_src_signal_eos(GstSrc *src) {
g_return_if_fail(src != NULL);
g_return_if_fail(GST_IS_SRC(src));
void
gst_src_signal_eos (GstSrc *src)
{
g_return_if_fail (src != NULL);
g_return_if_fail (GST_IS_SRC (src));
gtk_signal_emit(GTK_OBJECT(src),gst_src_signals[EOS]);
gtk_signal_emit (GTK_OBJECT (src), gst_src_signals[EOS]);
}
/**
@ -99,15 +104,17 @@ void gst_src_signal_eos(GstSrc *src) {
*
* Push a buffer from the source.
*/
void gst_src_push(GstSrc *src) {
void
gst_src_push (GstSrc *src)
{
GstSrcClass *oclass;
g_return_if_fail(src != NULL);
g_return_if_fail(GST_IS_SRC(src));
g_return_if_fail (src != NULL);
g_return_if_fail (GST_IS_SRC (src));
oclass = (GstSrcClass *)(GTK_OBJECT(src)->klass);
oclass = (GstSrcClass *)(GTK_OBJECT (src)->klass);
g_return_if_fail(oclass->push != NULL);
g_return_if_fail (oclass->push != NULL);
(oclass->push)(src);
}
@ -120,16 +127,18 @@ void gst_src_push(GstSrc *src) {
*
* Push a buffer of a given size from the source.
*/
void gst_src_push_region(GstSrc *src,gulong offset,gulong size) {
void
gst_src_push_region (GstSrc *src, gulong offset, gulong size)
{
GstSrcClass *oclass;
g_return_if_fail(src != NULL);
g_return_if_fail(GST_IS_SRC(src));
g_return_if_fail (src != NULL);
g_return_if_fail (GST_IS_SRC (src));
oclass = (GstSrcClass *)(GTK_OBJECT(src)->klass);
oclass = (GstSrcClass *)(GTK_OBJECT (src)->klass);
g_return_if_fail(oclass->push_region != NULL);
g_return_if_fail (oclass->push_region != NULL);
(oclass->push_region)(src,offset,size);
(oclass->push_region)(src, offset, size);
}

View file

@ -165,8 +165,9 @@ gst_thread_get_arg (GtkObject *object,
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_THREAD (object));
switch(id) {
switch (id) {
case ARG_CREATE_THREAD:
g_print("gstthread: query thread %d\n", GST_FLAG_IS_SET (object, GST_THREAD_CREATE));
GTK_VALUE_BOOL (*arg) = GST_FLAG_IS_SET (object, GST_THREAD_CREATE);
break;
default:
@ -327,7 +328,7 @@ gst_thread_restore_thyself (GstElement *element,
xmlNodePtr parent,
GHashTable *elements)
{
g_print("gstthread: restore\n");
g_print("gstthread: restore\n");
if (GST_ELEMENT_CLASS (parent_class)->restore_thyself)
GST_ELEMENT_CLASS (parent_class)->restore_thyself (element,parent, elements);

View file

@ -24,7 +24,6 @@
* I'm not overly worried yet...
*/
#include <gst/gst.h>
#include <string.h>
@ -41,9 +40,10 @@ struct _gst_type_node
int iDist;
int iPrev;
};
typedef struct _gst_type_node gst_type_node;
static gboolean gst_type_typefind_dummy(GstBuffer *buffer, gpointer priv);
static gboolean gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv);
/* we keep a (spase) matrix in the hashtable like:
*
@ -59,38 +59,48 @@ static gboolean gst_type_typefind_dummy(GstBuffer *buffer, gpointer priv);
*
**/
void _gst_type_initialize() {
void
_gst_type_initialize (void)
{
_gst_types = NULL;
_gst_maxtype = 1; /* type 0 is undefined */
// gst_type_audio_register();
}
guint16 gst_type_register(GstTypeFactory *factory) {
/**
* gst_type_register:
* @factory: the type factory to register
*
* register a new type factory to the system
*
* Returns: the new type id
*/
guint16
gst_type_register (GstTypeFactory *factory)
{
guint16 id;
GstType *type;
g_return_val_if_fail(factory != NULL, 0);
g_return_val_if_fail (factory != NULL, 0);
//g_print("gsttype: type register %s\n", factory->mime);
id = gst_type_find_by_mime(factory->mime);
id = gst_type_find_by_mime (factory->mime);
if (!id) {
type = g_new0(GstType, 1);
type = g_new0 (GstType, 1);
type->id = _gst_maxtype++;
type->mime = factory->mime;
type->exts = factory->exts;
type->id = _gst_maxtype++;
type->mime = factory->mime;
type->exts = factory->exts;
type->typefindfunc = factory->typefindfunc;
type->srcs = NULL;
type->sinks = NULL;
type->converters = g_hash_table_new(NULL, NULL);
_gst_types = g_list_prepend(_gst_types,type);
type->srcs = NULL;
type->sinks = NULL;
type->converters = g_hash_table_new (NULL, NULL);
_gst_types = g_list_prepend (_gst_types, type);
id = type->id;
} else {
type = gst_type_find_by_id(id);
type = gst_type_find_by_id (id);
/* now we want to try to merge the types and return the original */
/* FIXME: do extension merging here, not that easy */
@ -104,23 +114,24 @@ guint16 gst_type_register(GstTypeFactory *factory) {
return id;
}
static guint16 gst_type_find_by_mime_func(gchar *mime) {
static
guint16 gst_type_find_by_mime_func (gchar *mime)
{
GList *walk;
GstType *type;
gint typelen,mimelen;
gchar *search, *found;
walk = _gst_types;
// DEBUG("searching for '%s'\n",mime);
mimelen = strlen(mime);
mimelen = strlen (mime);
while (walk) {
type = (GstType *)walk->data;
search = type->mime;
// DEBUG("checking against '%s'\n",search);
typelen = strlen(search);
typelen = strlen (search);
while ((search - type->mime) < typelen) {
found = strstr(search,mime);
found = strstr (search, mime);
/* if the requested mime is in the list */
if (found) {
if ((*(found + mimelen) == ' ') ||
@ -133,25 +144,61 @@ static guint16 gst_type_find_by_mime_func(gchar *mime) {
} else
search += mimelen;
}
walk = g_list_next(walk);
walk = g_list_next (walk);
}
return 0;
}
guint16 gst_type_find_by_mime(gchar *mime) {
/**
* gst_type_find_by_mime:
* @mime: the mime type to find
*
* find the type id of a given mime type
*
* Returns: the type id
*/
guint16
gst_type_find_by_mime (gchar *mime)
{
guint16 typeid;
typeid = gst_type_find_by_mime_func(mime);
typeid = gst_type_find_by_mime_func (mime);
if (!typeid) {
gst_plugin_load_typefactory(mime);
gst_plugin_load_typefactory (mime);
}
return gst_type_find_by_mime_func(mime);
return gst_type_find_by_mime_func (mime);
}
GstType *gst_type_find_by_id(guint16 id) {
/**
* gst_type_find_by_ext:
* @ext: the extension to find
*
* find the type id of a given extention
*
* Returns: the type id
*/
guint16
gst_type_find_by_ext (gchar *ext)
{
//FIXME
g_warning ("gsttype: find_by_ext not implemented");
return 0;
}
/**
* gst_type_find_by_id:
* @id: the type id to lookup
*
* find the type of a given type id
*
* Returns: the type
*/
GstType*
gst_type_find_by_id (guint16 id)
{
GList *walk = _gst_types;
GstType *type;
@ -159,122 +206,175 @@ GstType *gst_type_find_by_id(guint16 id) {
type = (GstType *)walk->data;
if (type->id == id)
return type;
walk = g_list_next(walk);
walk = g_list_next (walk);
}
return NULL;
}
static void gst_type_dump_converter(gpointer key, gpointer value, gpointer data) {
static void
gst_type_dump_converter (gpointer key,
gpointer value,
gpointer data)
{
GList *walk = (GList *)value;
GstElementFactory *factory;
g_print("gsttype: %u, (", GPOINTER_TO_UINT(key));
g_print ("gsttype: %u, (", GPOINTER_TO_UINT (key));
while (walk) {
factory = (GstElementFactory *) walk->data;
g_print("%s, ", factory->name);
walk = g_list_next(walk);
walk = g_list_next (walk);
}
g_print("NULL)), ");
g_print ("NULL)), ");
}
void gst_type_dump() {
/**
* gst_type_dump:
*
* dumps the current type system
*/
void
gst_type_dump(void)
{
GList *walk = _gst_types;
GstType *type;
g_print("gst_type_dump() : \n");
g_print ("gst_type_dump() : \n");
while (walk) {
type = (GstType *)walk->data;
g_print("gst_type: %d (%s) -> (", type->id, type->mime);
g_hash_table_foreach(type->converters, gst_type_dump_converter, NULL);
g_print("NULL)\n");
g_print ("gst_type: %d (%s) -> (", type->id, type->mime);
g_hash_table_foreach (type->converters, gst_type_dump_converter, NULL);
g_print ("NULL)\n");
walk = g_list_next(walk);
walk = g_list_next (walk);
}
}
void gst_type_add_src(guint16 id,GstElementFactory *src) {
/**
* gst_type_add_src:
* @id: the type id to add the source factory to
* @src: the source factory for the type
*
* register the src factory as being a source for the
* given type id
*/
void
gst_type_add_src (guint16 id, GstElementFactory *src)
{
GList *walk;
GstType *type = gst_type_find_by_id(id);
GstType *type = gst_type_find_by_id (id);
g_return_if_fail(type != NULL);
g_return_if_fail(src != NULL);
g_return_if_fail (type != NULL);
g_return_if_fail (src != NULL);
type->srcs = g_list_prepend(type->srcs,src);
gst_elementfactory_add_src(src, id);
type->srcs = g_list_prepend (type->srcs, src);
gst_elementfactory_add_src (src, id);
// find out if the element has to be indexed in the matrix
walk = src->sink_types;
while (walk) {
GstType *type2 = gst_type_find_by_id(GPOINTER_TO_UINT(walk->data));
GList *converters = (GList *)g_hash_table_lookup(type2->converters, GUINT_TO_POINTER((guint)id));
GstType *type2 = gst_type_find_by_id (GPOINTER_TO_UINT (walk->data));
GList *converters = (GList *)g_hash_table_lookup (type2->converters, GUINT_TO_POINTER ((guint)id));
GList *orig = converters;
while (converters) {
if (converters->data == src) {
break;
}
converters = g_list_next(converters);
converters = g_list_next (converters);
}
if (!converters) {
orig = g_list_prepend(orig, src);
g_hash_table_insert(type2->converters, GUINT_TO_POINTER((guint)id), orig);
orig = g_list_prepend (orig, src);
g_hash_table_insert (type2->converters, GUINT_TO_POINTER ((guint)id), orig);
}
walk = g_list_next(walk);
walk = g_list_next (walk);
}
}
void gst_type_add_sink(guint16 id,GstElementFactory *sink) {
/**
* gst_type_add_sink:
* @id: the type id to add the sink factory to
* @sink: the sink factory for the type
*
* register the sink factory as being a sink for the
* given type id
*/
void
gst_type_add_sink (guint16 id, GstElementFactory *sink)
{
GList *walk;
GstType *type = gst_type_find_by_id(id);
GstType *type = gst_type_find_by_id (id);
g_return_if_fail(type != NULL);
g_return_if_fail(sink != NULL);
g_return_if_fail (type != NULL);
g_return_if_fail (sink != NULL);
type->sinks = g_list_prepend(type->sinks,sink);
gst_elementfactory_add_sink(sink, id);
type->sinks = g_list_prepend (type->sinks, sink);
gst_elementfactory_add_sink (sink, id);
// find out if the element has to be indexed in the matrix
walk = sink->src_types;
while (walk) {
GList *converters = (GList *)g_hash_table_lookup(type->converters, walk->data);
GList *converters = (GList *)g_hash_table_lookup (type->converters, walk->data);
GList *orig = converters;
while (converters) {
if (converters->data == sink) {
break;
}
converters = g_list_next(converters);
converters = g_list_next (converters);
}
if (!converters) {
orig = g_list_prepend(orig, sink);
g_hash_table_insert(type->converters, walk->data, orig);
orig = g_list_prepend (orig, sink);
g_hash_table_insert (type->converters, walk->data, orig);
}
walk = g_list_next(walk);
walk = g_list_next (walk);
}
}
GList *gst_type_get_srcs(guint16 id) {
GstType *type = gst_type_find_by_id(id);
/**
* gst_type_get_srcs:
* @id: the id to fetch the source factories for
*
* return a list of elementfactories that source
* the given type id
*
* Returns: a list of elementfactories
*/
GList*
gst_type_get_srcs (guint16 id)
{
GstType *type = gst_type_find_by_id (id);
g_return_val_if_fail(type != NULL, NULL);
g_return_val_if_fail (type != NULL, NULL);
return type->srcs;
}
GList *gst_type_get_sinks(guint16 id) {
GstType *type = gst_type_find_by_id(id);
/**
* gst_type_get_sinks:
* @id: the id to fetch the sink factories for
*
* return a list of elementfactories that sink
* the given type id
*
* Returns: a list of elementfactories
*/
GList*
gst_type_get_sinks (guint16 id)
{
GstType *type = gst_type_find_by_id (id);
g_return_val_if_fail(type != 0, NULL);
g_return_val_if_fail (type != 0, NULL);
return type->sinks;
}
@ -285,37 +385,41 @@ GList *gst_type_get_sinks(guint16 id) {
* to connnect two GstTypes
*
**/
static GList *gst_type_enqueue(GList *queue, gint iNode, gint iDist, gint iPrev) {
gst_type_node *node = g_malloc(sizeof(gst_type_node));
static GList*
gst_type_enqueue (GList *queue, gint iNode, gint iDist, gint iPrev)
{
gst_type_node *node = g_malloc (sizeof (gst_type_node));
node->iNode = iNode;
node->iDist = iDist;
node->iPrev = iPrev;
queue = g_list_append(queue, node);
queue = g_list_append (queue, node);
return queue;
}
static GList *gst_type_dequeue(GList *queue, gint *iNode, gint *iDist, gint *iPrev) {
static GList*
gst_type_dequeue (GList *queue, gint *iNode, gint *iDist, gint *iPrev)
{
GList *head;
gst_type_node *node;
head = g_list_first(queue);
head = g_list_first (queue);
if (head) {
node = (gst_type_node *)head->data;
*iNode = node->iNode;
*iPrev = node->iPrev;
*iDist = node->iDist;
head = g_list_remove(queue, node);
head = g_list_remove (queue, node);
}
return head;
}
static GList *construct_path (gst_type_node *rgnNodes, gint chNode)
static GList*
construct_path (gst_type_node *rgnNodes, gint chNode)
{
guint src = chNode;
guint current = rgnNodes[chNode].iPrev;
@ -323,14 +427,14 @@ static GList *construct_path (gst_type_node *rgnNodes, gint chNode)
GstType *type;
GList *converters;
g_print("gsttype: constructed mime path ");
g_print ("gsttype: constructed mime path ");
while (current != MAX_COST)
{
type = gst_type_find_by_id(current);
converters = (GList *)g_hash_table_lookup(type->converters, GUINT_TO_POINTER(src));
type = gst_type_find_by_id (current);
converters = (GList *)g_hash_table_lookup (type->converters, GUINT_TO_POINTER (src));
g_print("(%d %d)", src, current);
factories = g_list_prepend(factories, converters->data);
g_print ("(%d %d)", src, current);
factories = g_list_prepend (factories, converters->data);
src = current;
current = rgnNodes[current].iPrev;
}
@ -338,17 +442,31 @@ static GList *construct_path (gst_type_node *rgnNodes, gint chNode)
return factories;
}
static guint gst_type_find_cost(gint src, gint dest) {
GstType *type = gst_type_find_by_id(src);
static guint
gst_type_find_cost (gint src, gint dest)
{
GstType *type = gst_type_find_by_id (src);
GList *converters = (GList *)g_hash_table_lookup(type->converters, GUINT_TO_POINTER(dest));
GList *converters = (GList *)g_hash_table_lookup (type->converters, GUINT_TO_POINTER (dest));
// FIXME do something very clever here...
if (converters) return 1;
return MAX_COST;
}
GList *gst_type_get_sink_to_src(guint16 sinkid, guint16 srcid) {
/**
* gst_type_get_sink_to_src:
* @sinkid: the id of the sink
* @srcid: the id of the source
*
* return a list of elementfactories that convert the source
* type id to the sink type id
*
* Returns: a list of elementfactories
*/
GList*
gst_type_get_sink_to_src (guint16 sinkid, guint16 srcid)
{
gst_type_node *rgnNodes;
GList *queue = NULL;
gint iNode, iDist, iPrev, i, iCost;
@ -358,7 +476,7 @@ GList *gst_type_get_sink_to_src(guint16 sinkid, guint16 srcid) {
return NULL;
}
else {
rgnNodes = g_malloc(sizeof(gst_type_node) * _gst_maxtype);
rgnNodes = g_malloc (sizeof (gst_type_node) * _gst_maxtype);
for (i=0; i< _gst_maxtype; i++) {
rgnNodes[i].iNode = i;
@ -368,53 +486,82 @@ GList *gst_type_get_sink_to_src(guint16 sinkid, guint16 srcid) {
rgnNodes[sinkid].iDist = 0;
rgnNodes[sinkid].iPrev = MAX_COST;
queue = gst_type_enqueue(queue, sinkid, 0, MAX_COST);
queue = gst_type_enqueue (queue, sinkid, 0, MAX_COST);
while (g_list_length(queue) > 0) {
while (g_list_length (queue) > 0) {
queue = gst_type_dequeue(queue, &iNode, &iDist, &iPrev);
queue = gst_type_dequeue (queue, &iNode, &iDist, &iPrev);
for (i=0; i< _gst_maxtype; i++) {
iCost = gst_type_find_cost(iNode, i);
iCost = gst_type_find_cost (iNode, i);
if (iCost != MAX_COST) {
if((MAX_COST == rgnNodes[i].iDist) ||
(rgnNodes[i].iDist > (iCost + iDist))) {
rgnNodes[i].iDist = iDist + iCost;
rgnNodes[i].iPrev = iNode;
queue = gst_type_enqueue(queue, i, iDist + iCost, iNode);
queue = gst_type_enqueue (queue, i, iDist + iCost, iNode);
}
}
}
}
}
return construct_path(rgnNodes, srcid);
return construct_path (rgnNodes, srcid);
}
GList *gst_type_get_list() {
/**
* gst_type_get_list:
*
* return a list of all registered types
*
* Returns: a list of GstTypes
*/
GList*
gst_type_get_list (void)
{
return _gst_types;
}
xmlNodePtr gst_type_save_thyself(GstType *type, xmlNodePtr parent) {
xmlNewChild(parent, NULL, "mime", type->mime);
/**
* gst_type_save_thyself:
* @type: the type to save
* @parent: the parent node to save into
*
* save a type into an XML representation
*
* Returns: the new xmlNodePtr
*/
xmlNodePtr
gst_type_save_thyself (GstType *type, xmlNodePtr parent)
{
xmlNewChild (parent, NULL, "mime", type->mime);
return parent;
}
guint16 gst_type_load_thyself(xmlNodePtr parent) {
/**
* gst_type_load_thyself:
* @parent: the parent node with the xml information
*
* load a type from an XML representation
*
* Returns: the loaded type id
*/
guint16
gst_type_load_thyself (xmlNodePtr parent)
{
xmlNodePtr field = parent->childs;
guint16 typeid = 0;
while (field) {
if (!strcmp(field->name, "mime")) {
typeid = gst_type_find_by_mime(xmlNodeGetContent(field));
if (!strcmp (field->name, "mime")) {
typeid = gst_type_find_by_mime (xmlNodeGetContent (field));
if (!typeid) {
GstTypeFactory *factory = g_new0(GstTypeFactory, 1);
GstTypeFactory *factory = g_new0 (GstTypeFactory, 1);
factory->mime = g_strdup(xmlNodeGetContent(field));
typeid = gst_type_register(factory);
factory->mime = g_strdup (xmlNodeGetContent (field));
typeid = gst_type_register (factory);
}
return typeid;
}
@ -424,52 +571,72 @@ guint16 gst_type_load_thyself(xmlNodePtr parent) {
return typeid;
}
xmlNodePtr gst_typefactory_save_thyself(GstTypeFactory *factory, xmlNodePtr parent) {
xmlNewChild(parent, NULL, "mime", factory->mime);
/**
* gst_typefactory_save_thyself:
* @factory: the type factory to save
* @parent: the parent node to save into
*
* save a typefactory into an XML representation
*
* Returns: the new xmlNodePtr
*/
xmlNodePtr
gst_typefactory_save_thyself (GstTypeFactory *factory, xmlNodePtr parent)
{
xmlNewChild (parent, NULL, "mime", factory->mime);
if (factory->exts) {
xmlNewChild(parent, NULL, "extensions", factory->exts);
xmlNewChild (parent, NULL, "extensions", factory->exts);
}
if (factory->typefindfunc) {
xmlNewChild(parent, NULL, "typefind", NULL);
xmlNewChild (parent, NULL, "typefind", NULL);
}
return parent;
}
static gboolean gst_type_typefind_dummy(GstBuffer *buffer, gpointer priv)
static gboolean
gst_type_typefind_dummy (GstBuffer *buffer, gpointer priv)
{
GstType *type = (GstType *)priv;
guint16 typeid;
g_print("gsttype: need to load typefind function\n");
g_print ("gsttype: need to load typefind function\n");
type->typefindfunc = NULL;
gst_plugin_load_typefactory(type->mime);
typeid = gst_type_find_by_mime(type->mime);
type = gst_type_find_by_id(typeid);
gst_plugin_load_typefactory (type->mime);
typeid = gst_type_find_by_mime (type->mime);
type = gst_type_find_by_id (typeid);
if (type->typefindfunc) {
return type->typefindfunc(buffer, type);
return type->typefindfunc (buffer, type);
}
return FALSE;
}
GstTypeFactory *gst_typefactory_load_thyself(xmlNodePtr parent) {
/**
* gst_typefactory_load_thyself:
* @parent: the parent node to load from
*
* load a typefactory from an XML representation
*
* Returns: the new typefactory
*/
GstTypeFactory*
gst_typefactory_load_thyself (xmlNodePtr parent)
{
GstTypeFactory *factory = g_new0(GstTypeFactory, 1);
GstTypeFactory *factory = g_new0 (GstTypeFactory, 1);
xmlNodePtr field = parent->childs;
factory->typefindfunc = NULL;
while (field) {
if (!strcmp(field->name, "mime")) {
factory->mime = g_strdup(xmlNodeGetContent(field));
if (!strcmp (field->name, "mime")) {
factory->mime = g_strdup (xmlNodeGetContent (field));
}
else if (!strcmp(field->name, "extensions")) {
factory->exts = g_strdup(xmlNodeGetContent(field));
else if (!strcmp (field->name, "extensions")) {
factory->exts = g_strdup (xmlNodeGetContent (field));
}
else if (!strcmp(field->name, "typefind")) {
else if (!strcmp (field->name, "typefind")) {
factory->typefindfunc = gst_type_typefind_dummy;
}
field = field->next;

View file

@ -4,23 +4,31 @@ INCLUDES = $(GLIB_CFLAGS) $(GTK_CFLAGS) -I$(top_srcdir) \
$(shell gnome-config --cflags gnomeui) $(shell gstreamer-config --cflags)
bin_PROGRAMS = gstmediaplay
bin_PROGRAMS = gstmediaplay
lib_LTLIBRARIES = libgstmediaplay.la
gladedir = $(datadir)/gstmediaplay
glade_DATA = gstmediaplay.glade play.xpm stop.xpm pause.xpm
gstmediaplay_SOURCES = \
gstplay.c main.c \
libgstmediaplay_la_SOURCES = \
gstplay.c \
gstmediaplay.c gstmediaplay.h \
gststatusarea.c gststatusarea.h \
callbacks.c callbacks.h
gstmediaplay_SOURCES = \
main.c
CFLAGS += -O2 -Wall -DDATADIR=\""$(gladedir)/"\"
gstmediaplay_CFLAGS = $(shell gnome-config --cflags gnomeui) $(shell libglade-config --cflags gnome) \
$(shell gstreamer-config --cflags )
gstmediaplay_LDFLAGS = $(shell gnome-config --libs gnomeui) $(shell libglade-config --libs gnome) \
$(shell gstreamer-config --libs )
$(shell gstreamer-config --libs ) ./libgstmediaplay.la
if HAVE_LIBXV
xvlibs=-lXv

View file

@ -139,14 +139,15 @@ GstElement *gst_queue_new(gchar *name) {
return queue;
}
static void gst_queue_cleanup_buffers(gpointer data, gpointer user_data)
static void gst_queue_cleanup_buffers(gpointer data, const gpointer user_data)
{
DEBUG("queue: %s cleaning buffer %p\n", (gchar *)user_data, data);
gst_buffer_unref(GST_BUFFER(data));
gst_buffer_unref (GST_BUFFER (data));
}
static void gst_queue_flush(GstQueue *queue) {
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, gst_element_get_name(GST_ELEMENT(queue)));
g_slist_foreach(queue->queue, gst_queue_cleanup_buffers, (char *)gst_element_get_name(GST_ELEMENT(queue)));
g_slist_free(queue->queue);
queue->queue = NULL;
queue->level_buffers = 0;
@ -155,7 +156,7 @@ static void gst_queue_flush(GstQueue *queue) {
static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
GstQueue *queue;
gboolean tosignal = FALSE;
guchar *name;
const guchar *name;
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
@ -215,7 +216,7 @@ static void gst_queue_push(GstConnection *connection) {
GstBuffer *buf = NULL;
GSList *front;
gboolean tosignal = FALSE;
guchar *name;
const guchar *name;
name = gst_element_get_name(GST_ELEMENT(queue));