don't mix tabs and spaces

Original commit message from CVS:
don't mix tabs and spaces
This commit is contained in:
Thomas Vander Stichele 2004-03-15 19:27:17 +00:00
parent 84f49e604d
commit 7baa6c18e7
189 changed files with 5170 additions and 5041 deletions

View file

@ -1,3 +1,7 @@
2004-03-15 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c,*.h: don't mix tabs and spaces
2004-03-15 Johan Dahlin <johan@gnome.org> 2004-03-15 Johan Dahlin <johan@gnome.org>
* gst/schedulers/gstoptimalscheduler.c * gst/schedulers/gstoptimalscheduler.c

View file

@ -44,7 +44,8 @@ typedef struct
BonoboUIComponent *uic; BonoboUIComponent *uic;
GstPlay *play; GstPlay *play;
} control_data_t; }
control_data_t;
/* /*
* This callback is invoked when the BonoboControl object * This callback is invoked when the BonoboControl object
@ -94,7 +95,8 @@ typedef struct
{ {
control_data_t *control_data; control_data_t *control_data;
GtkFileSelection *selector; GtkFileSelection *selector;
} file_select_struct; }
file_select_struct;
static void static void
filename_selected (GtkButton * ok, gpointer user_data) filename_selected (GtkButton * ok, gpointer user_data)
@ -127,14 +129,14 @@ verb_Open_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname)
data->control_data = control_data; data->control_data = control_data;
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
ok_button), "clicked", GTK_SIGNAL_FUNC (filename_selected), data); ok_button), "clicked", GTK_SIGNAL_FUNC (filename_selected), data);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
ok_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), ok_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector); (gpointer) file_selector);
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->
cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
(gpointer) file_selector); (gpointer) file_selector);
gtk_widget_show (file_selector); gtk_widget_show (file_selector);
@ -208,7 +210,7 @@ control_create_menus (control_data_t * control_data)
node = bonobo_ui_node_from_string (ui); node = bonobo_ui_node_from_string (ui);
bonobo_ui_util_translate_ui (node); bonobo_ui_util_translate_ui (node);
bonobo_ui_util_fixup_help (control_data->uic, node, bonobo_ui_util_fixup_help (control_data->uic, node,
DATADIR, "gstmediaplay"); DATADIR, "gstmediaplay");
bonobo_ui_component_set_tree (control_data->uic, "/", node, NULL); bonobo_ui_component_set_tree (control_data->uic, "/", node, NULL);

View file

@ -20,7 +20,7 @@ gboolean playing = TRUE;
gboolean cut_start_signalled = FALSE; gboolean cut_start_signalled = FALSE;
gboolean cut_stop_signalled = FALSE; gboolean cut_stop_signalled = FALSE;
int id = 0; /* increment this for each new cut */ int id = 0; /* increment this for each new cut */
GstElement *main_bin; GstElement *main_bin;
GstElement *audiosrc; GstElement *audiosrc;
GstElement *queue; GstElement *queue;
@ -51,9 +51,9 @@ cut_start (GstElement * element)
ct = localtime (&seconds); ct = localtime (&seconds);
/* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */ /* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */
sprintf (buffer, sprintf (buffer,
"/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav", "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav",
ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min, ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min,
ct->tm_sec); ct->tm_sec);
} }
g_print ("DEBUG: cut_start: setting new location to %s\n", buffer); g_print ("DEBUG: cut_start: setting new location to %s\n", buffer);
g_object_set (G_OBJECT (disksink), "location", buffer, NULL); g_object_set (G_OBJECT (disksink), "location", buffer, NULL);

View file

@ -15,8 +15,7 @@ main (int argc, char *argv[])
return -1; return -1;
} }
pipeline = pipeline = (GstElement *)
(GstElement *)
gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
if (!pipeline) { if (!pipeline) {
fprintf (stderr, "Parse error: %s", error->message); fprintf (stderr, "Parse error: %s", error->message);

View file

@ -88,7 +88,7 @@ main (int argc, char *argv[])
char buffer[20]; char buffer[20];
GList *input_channels; /* structure holding all the input channels */ GList *input_channels; /* structure holding all the input channels */
input_channel_t *channel_in; input_channel_t *channel_in;
@ -96,7 +96,7 @@ main (int argc, char *argv[])
GstElement *adder; GstElement *adder;
GstElement *audiosink; GstElement *audiosink;
GstPad *pad; /* to request pads for the adder */ GstPad *pad; /* to request pads for the adder */
gst_init (&argc, &argv); gst_init (&argc, &argv);
@ -167,17 +167,17 @@ main (int argc, char *argv[])
/* first song gets special treatment for end style */ /* first song gets special treatment for end style */
env_register_cp (channel_in->volenv, 0.0, 1.0); env_register_cp (channel_in->volenv, 0.0, 1.0);
} else { } else {
env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */ env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */
env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */ env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */
env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0); env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0);
} }
env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */ env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */
if (i != num_channels) { if (i != num_channels) {
env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */ env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */
env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */ env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */
} }
env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */ env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */
#ifndef GST_DISABLE_LOADSAVE #ifndef GST_DISABLE_LOADSAVE
gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w")); gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w"));
@ -230,7 +230,7 @@ create_input_channel (int id, char *location)
input_channel_t *channel; input_channel_t *channel;
char buffer[20]; /* hold the names */ char buffer[20]; /* hold the names */
/* GstAutoplug *autoplug; /* GstAutoplug *autoplug;
GstCaps *srccaps; */ GstCaps *srccaps; */

View file

@ -58,13 +58,13 @@ enum
* can have. They can be quite complex, but for this example plugin * can have. They can be quite complex, but for this example plugin
* they are rather simple. * they are rather simple.
*/ */
GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */ GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */
GST_PAD_SINK, /* Direction of the pad */ GST_PAD_SINK, /* Direction of the pad */
GST_PAD_ALWAYS, /* The pad exists for every instance */ GST_PAD_ALWAYS, /* The pad exists for every instance */
GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */ GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */
"foo:int=1, " /* an integer property */ "foo:int=1, " /* an integer property */
"bar:boolean=true, " /* a boolean property */ "bar:boolean=true, " /* a boolean property */
"baz:int={ 1, 3 }" /* a list of values */ "baz:int={ 1, 3 }" /* a list of values */
) )
); );
@ -120,9 +120,10 @@ gst_example_get_type (void)
0, 0,
(GInstanceInitFunc) gst_example_init, (GInstanceInitFunc) gst_example_init,
}; };
example_type = example_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info, g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info,
0); 0);
} }
return example_type; return example_type;
} }
@ -152,7 +153,7 @@ gst_example_class_init (GstExampleClass * klass)
/* Here we add an argument to the object. This argument is an integer, /* Here we add an argument to the object. This argument is an integer,
* and can be both read and written. * and can be both read and written.
*/ */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
/* Here we add a signal to the object. This is avery useless signal /* Here we add a signal to the object. This is avery useless signal
* called asdf. The signal will also pass a pointer to the listeners * called asdf. The signal will also pass a pointer to the listeners
@ -261,7 +262,7 @@ gst_example_chain (GstPad * pad, GstData * _data)
/* Then copy the data in the incoming buffer into the new buffer. */ /* Then copy the data in the incoming buffer into the new buffer. */
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (outbuf)); GST_BUFFER_SIZE (outbuf));
/* we don't need the incomming buffer anymore so we unref it. When we are /* we don't need the incomming buffer anymore so we unref it. When we are
* the last plugin with a handle to the buffer, its memory will be freed */ * the last plugin with a handle to the buffer, its memory will be freed */
@ -392,7 +393,7 @@ plugin_init (GstPlugin * plugin)
* when compared to similar plugins and the GType identifier. * when compared to similar plugins and the GType identifier.
*/ */
if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL,
GST_TYPE_EXAMPLE)) GST_TYPE_EXAMPLE))
return FALSE; return FALSE;
/* Now we can return successfully. */ /* Now we can return successfully. */
@ -410,16 +411,16 @@ plugin_init (GstPlugin * plugin)
* The symbol pointing to this structure is the only symbol looked up when * The symbol pointing to this structure is the only symbol looked up when
* loading the plugin. * loading the plugin.
*/ */
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */
GST_VERSION_MINOR, /* The minor version of the core that this was built with */ GST_VERSION_MINOR, /* The minor version of the core that this was built with */
"example", /* The name of the plugin. This must be unique: plugins with "example", /* The name of the plugin. This must be unique: plugins with
* the same name will be assumed to be identical, and only * the same name will be assumed to be identical, and only
* one will be loaded. */ * one will be loaded. */
"an example plugin", /* a short description of the plugin in English */ "an example plugin", /* a short description of the plugin in English */
plugin_init, /* Pointer to the initialisation function for the plugin. */ plugin_init, /* Pointer to the initialisation function for the plugin. */
"0.1", /* The version number of the plugin */ "0.1", /* The version number of the plugin */
"LGPL", /* ieffective license the plugin can be shipped with. Must be "LGPL", /* ieffective license the plugin can be shipped with. Must be
* valid for all libraries it links to, too. */ * valid for all libraries it links to, too. */
"my nifty plugin package", "my nifty plugin package",
/* package this plugin belongs to. */ /* package this plugin belongs to. */
"http://www.mydomain.com" "http://www.mydomain.com"

View file

@ -67,7 +67,7 @@ main (int argc, char *argv[])
g_assert (filesink); g_assert (filesink);
/* set the filenames */ /* set the filenames */
filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */ filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL);

View file

@ -75,7 +75,7 @@ main (int argc, char *argv[])
g_assert (filesink); g_assert (filesink);
/* set the filenames */ /* set the filenames */
filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */ filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
g_object_set (G_OBJECT (filesink), "location", filename, NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL);
g_free (filename); g_free (filename);

View file

@ -14,13 +14,13 @@ xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data)
xmlNodePtr nodes = children->xmlChildrenNode; xmlNodePtr nodes = children->xmlChildrenNode;
while (nodes) { while (nodes) {
if (!strcmp (nodes->name, "text")) { if (!strcmp (nodes->name, "text")) {
gchar *name = g_strdup (xmlNodeGetContent (nodes)); gchar *name = g_strdup (xmlNodeGetContent (nodes));
g_print ("object %s loaded with comment '%s'\n", g_print ("object %s loaded with comment '%s'\n",
gst_object_get_name (object), name); gst_object_get_name (object), name);
} }
nodes = nodes->next; nodes = nodes->next;
} }
} }
children = children->next; children = children->next;

View file

@ -92,8 +92,8 @@ gst_autoplug_can_connect_src (GstElementFactory * fac, const GstCaps * src)
while (templs) { while (templs) {
if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) &&
gst_autoplug_caps_intersect (src, gst_autoplug_caps_intersect (src,
GST_PAD_TEMPLATE_CAPS (templs->data))) { GST_PAD_TEMPLATE_CAPS (templs->data))) {
return GST_PAD_TEMPLATE (templs->data); return GST_PAD_TEMPLATE (templs->data);
} }
templs = g_list_next (templs); templs = g_list_next (templs);
@ -122,7 +122,7 @@ gst_autoplug_can_connect_sink (GstElementFactory * fac, const GstCaps * sink)
GstCaps *caps = GST_PAD_TEMPLATE_CAPS (templs->data); GstCaps *caps = GST_PAD_TEMPLATE_CAPS (templs->data);
if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) && if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) &&
gst_autoplug_caps_intersect (caps, sink)) { gst_autoplug_caps_intersect (caps, sink)) {
return GST_PAD_TEMPLATE (templs->data); return GST_PAD_TEMPLATE (templs->data);
} }
templs = g_list_next (templs); templs = g_list_next (templs);
@ -147,13 +147,13 @@ gst_autoplug_can_match (GstElementFactory * src, GstElementFactory * dest)
GstPadTemplate *desttemp = (GstPadTemplate *) desttemps->data; GstPadTemplate *desttemp = (GstPadTemplate *) desttemps->data;
if (srctemp->direction == GST_PAD_SRC && if (srctemp->direction == GST_PAD_SRC &&
desttemp->direction == GST_PAD_SINK) { desttemp->direction == GST_PAD_SINK) {
if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp), if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp),
gst_pad_template_get_caps (desttemp))) { gst_pad_template_get_caps (desttemp))) {
GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"", GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"",
GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest)); GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
return desttemp; return desttemp;
} }
} }
desttemps = g_list_next (desttemps); desttemps = g_list_next (desttemps);
@ -219,7 +219,7 @@ gst_autoplug_factories_filters (GList * factories)
while (factories) { while (factories) {
/* if you want it faster do src/sink check at once, don't call two functions */ /* if you want it faster do src/sink check at once, don't call two functions */
if (gst_autoplug_factory_has_src (factories->data) if (gst_autoplug_factory_has_src (factories->data)
&& gst_autoplug_factory_has_sink (factories->data)) && gst_autoplug_factory_has_sink (factories->data))
ret = g_list_prepend (ret, factories->data); ret = g_list_prepend (ret, factories->data);
factories = g_list_next (factories); factories = g_list_next (factories);
} }
@ -256,18 +256,18 @@ gst_autoplug_factories_filters_with_sink_caps (GList * factories)
gboolean have_sink = FALSE; gboolean have_sink = FALSE;
while (templs) { while (templs) {
if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) { if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) {
have_src = TRUE; have_src = TRUE;
} }
if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK)
&& (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL)) { && (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL)) {
have_sink = TRUE; have_sink = TRUE;
} }
if (have_src && have_sink) { if (have_src && have_sink) {
ret = g_list_prepend (ret, factory); ret = g_list_prepend (ret, factory);
break; break;
} }
templs = g_list_next (templs); templs = g_list_next (templs);
} }
} }
factories = g_list_next (factories); factories = g_list_next (factories);
@ -291,10 +291,10 @@ gst_autoplug_factories_at_most_templates (GList * factories,
while (templs) { while (templs) {
if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) { if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
count++; count++;
} }
if (count > maxtemplates) if (count > maxtemplates)
break; break;
templs = g_list_next (templs); templs = g_list_next (templs);
} }
if (count <= maxtemplates) if (count <= maxtemplates)
@ -326,8 +326,8 @@ gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps,
GList * factories) GList * factories)
{ {
GList *factory_nodes = NULL; GList *factory_nodes = NULL;
guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */ guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */
GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */ GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */
g_return_val_if_fail (srccaps != NULL, NULL); g_return_val_if_fail (srccaps != NULL, NULL);
g_return_val_if_fail (sinkcaps != NULL, NULL); g_return_val_if_fail (sinkcaps != NULL, NULL);
@ -345,15 +345,15 @@ gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps,
GST_DEBUG ("trying with %s", node->fac->details.longname); GST_DEBUG ("trying with %s", node->fac->details.longname);
node->templ = gst_autoplug_can_connect_src (node->fac, srccaps); node->templ = gst_autoplug_can_connect_src (node->fac, srccaps);
node->cost = (node->templ ? gst_autoplug_get_cost (node->fac) node->cost = (node->templ ? gst_autoplug_get_cost (node->fac)
: GST_AUTOPLUG_MAX_COST); : GST_AUTOPLUG_MAX_COST);
node->endpoint = gst_autoplug_can_connect_sink (node->fac, sinkcaps); node->endpoint = gst_autoplug_can_connect_sink (node->fac, sinkcaps);
if (node->templ && node->endpoint) if (node->templ && node->endpoint)
GST_DEBUG ("%s makes connection possible", node->fac->details.longname); GST_DEBUG ("%s makes connection possible", node->fac->details.longname);
else else
GST_DEBUG ("direct connection with %s not possible", GST_DEBUG ("direct connection with %s not possible",
node->fac->details.longname); node->fac->details.longname);
if ((node->endpoint != NULL) && if ((node->endpoint != NULL) &&
((bestnode == NULL) || (node->cost < bestnode->cost))) { ((bestnode == NULL) || (node->cost < bestnode->cost))) {
bestnode = node; bestnode = node;
} }
factory_nodes = g_list_prepend (factory_nodes, node); factory_nodes = g_list_prepend (factory_nodes, node);
@ -372,22 +372,22 @@ gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps,
/* iterate until we found the best path */ /* iterate until we found the best path */
while (curcost < GST_AUTOPLUG_MAX_COST) { while (curcost < GST_AUTOPLUG_MAX_COST) {
GList *nodes = factory_nodes; GList *nodes = factory_nodes;
guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */ guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */
GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost, GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost,
GST_OBJECT_NAME (bestnode->fac), bestnode->cost); GST_OBJECT_NAME (bestnode->fac), bestnode->cost);
/* check if we already have a valid best connection to the sink */ /* check if we already have a valid best connection to the sink */
if (bestnode->cost <= curcost) { if (bestnode->cost <= curcost) {
GList *ret; GList *ret;
GST_DEBUG ("found a way to connect via %s", GST_DEBUG ("found a way to connect via %s",
GST_OBJECT_NAME ((GstObject *) bestnode->fac)); GST_OBJECT_NAME ((GstObject *) bestnode->fac));
/* enter all factories into the return list */ /* enter all factories into the return list */
ret = g_list_prepend (NULL, bestnode->fac); ret = g_list_prepend (NULL, bestnode->fac);
bestnode = bestnode->prev; bestnode = bestnode->prev;
while (bestnode != NULL) { while (bestnode != NULL) {
ret = g_list_prepend (ret, bestnode->fac); ret = g_list_prepend (ret, bestnode->fac);
bestnode = bestnode->prev; bestnode = bestnode->prev;
} }
g_list_free_list_and_elements (factory_nodes); g_list_free_list_and_elements (factory_nodes);
return ret; return ret;
@ -399,36 +399,35 @@ gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps,
*/ */
while (nodes) { while (nodes) {
if (((GstAutoplugNode *) nodes->data)->cost == curcost) { if (((GstAutoplugNode *) nodes->data)->cost == curcost) {
/* now check all elements if we got a shorter path */ /* now check all elements if we got a shorter path */
GList *sinknodes = factory_nodes; GList *sinknodes = factory_nodes;
GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data; GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data;
while (sinknodes) { while (sinknodes) {
GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data; GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data;
GstPadTemplate *templ; GstPadTemplate *templ;
if ((sinknode->cost > if ((sinknode->cost >
srcnode->cost + gst_autoplug_get_cost (sinknode->fac)) srcnode->cost + gst_autoplug_get_cost (sinknode->fac))
&& (templ = && (templ = gst_autoplug_can_match (srcnode->fac, sinknode->fac))) {
gst_autoplug_can_match (srcnode->fac, sinknode->fac))) { /* we got a shorter path
/* we got a shorter path * now enter that path to that node */
* now enter that path to that node */ sinknode->prev = srcnode;
sinknode->prev = srcnode; sinknode->templ = templ;
sinknode->templ = templ; sinknode->cost =
sinknode->cost = srcnode->cost + gst_autoplug_get_cost (sinknode->fac);
srcnode->cost + gst_autoplug_get_cost (sinknode->fac); /* make sure to set which cost to view next */
/* make sure to set which cost to view next */ nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost;
nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost; /* did we get a new best node? */
/* did we get a new best node? */ if (sinknode->endpoint && (sinknode->cost < bestnode->cost)) {
if (sinknode->endpoint && (sinknode->cost < bestnode->cost)) { bestnode = sinknode;
bestnode = sinknode; }
} }
} sinknodes = g_list_next (sinknodes);
sinknodes = g_list_next (sinknodes); }
} /* FIXME: for speed remove the item we just iterated with from the factory_nodes
/* FIXME: for speed remove the item we just iterated with from the factory_nodes * but don't free it yet and don't forget to free it.
* but don't free it yet and don't forget to free it. */
*/
} }
nodes = g_list_next (nodes); nodes = g_list_next (nodes);
} }

View file

@ -138,8 +138,9 @@ gst_spider_get_type (void)
0, 0,
(GInstanceInitFunc) gst_spider_init, (GInstanceInitFunc) gst_spider_init,
}; };
spider_type = spider_type =
g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0); g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0);
} }
return spider_type; return spider_type;
} }
@ -158,7 +159,7 @@ gst_spider_class_init (GstSpiderClass * klass)
/* properties */ /* properties */
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FACTORIES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FACTORIES,
g_param_spec_pointer ("factories", "allowed factories", g_param_spec_pointer ("factories", "allowed factories",
"allowed factories for autoplugging", G_PARAM_READWRITE)); "allowed factories for autoplugging", G_PARAM_READWRITE));
gobject_class->set_property = gst_spider_set_property; gobject_class->set_property = gst_spider_set_property;
gobject_class->get_property = gst_spider_get_property; gobject_class->get_property = gst_spider_get_property;
@ -251,9 +252,9 @@ gst_spider_set_property (GObject * object, guint prop_id, const GValue * value,
case ARG_FACTORIES: case ARG_FACTORIES:
list = (GList *) g_value_get_pointer (value); list = (GList *) g_value_get_pointer (value);
while (list) { while (list) {
g_return_if_fail (list->data != NULL); g_return_if_fail (list->data != NULL);
g_return_if_fail (GST_IS_ELEMENT_FACTORY (list->data)); g_return_if_fail (GST_IS_ELEMENT_FACTORY (list->data));
list = g_list_next (list); list = g_list_next (list);
} }
g_list_free (spider->factories); g_list_free (spider->factories);
spider->factories = (GList *) g_value_get_pointer (value); spider->factories = (GList *) g_value_get_pointer (value);
@ -304,7 +305,7 @@ gst_spider_link_sometimes (GstElement * src, GstPad * pad,
/* try to autoplug the elements */ /* try to autoplug the elements */
if (gst_spider_plug_from_srcpad (conn, pad) != GST_PAD_LINK_REFUSED) { if (gst_spider_plug_from_srcpad (conn, pad) != GST_PAD_LINK_REFUSED) {
GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback", GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink)); GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink));
g_signal_handler_disconnect (src, signal_id); g_signal_handler_disconnect (src, signal_id);
signal_id = 0; signal_id = 0;
} }
@ -425,24 +426,24 @@ gst_spider_identity_plug (GstSpiderIdentity * ident)
factories = spider->factories; factories = spider->factories;
while (factories) { while (factories) {
if ((padtemp = if ((padtemp =
gst_autoplug_can_connect_src (factories->data, src_caps))) { gst_autoplug_can_connect_src (factories->data, src_caps))) {
const GstCaps *caps = gst_pad_template_get_caps (padtemp); const GstCaps *caps = gst_pad_template_get_caps (padtemp);
GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps); GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps);
found = TRUE; found = TRUE;
} }
factories = factories->next; factories = factories->next;
} }
if (!found) { if (!found) {
const char *mime; const char *mime;
mime = gst_structure_get_name (gst_caps_get_structure (src_caps, 0)); mime = gst_structure_get_name (gst_caps_get_structure (src_caps, 0));
GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND, GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND,
(_("There is no element present to handle the stream's mime type %s."), mime), (NULL)); (_("There is no element present to handle the stream's mime type %s."), mime), (NULL));
gst_caps_free (src_caps); gst_caps_free (src_caps);
return; return;
} }
} }
gst_caps_free (src_caps); gst_caps_free (src_caps);
@ -482,15 +483,15 @@ gst_spider_identity_plug (GstSpiderIdentity * ident)
if (dir != GST_PAD_DIRECTION (otherpad)) { if (dir != GST_PAD_DIRECTION (otherpad)) {
/* we only link to plugged in elements */ /* we only link to plugged in elements */
if (peer->plugged == TRUE) { if (peer->plugged == TRUE) {
/* plug in the right direction */ /* plug in the right direction */
if (dir == GST_PAD_SINK) { if (dir == GST_PAD_SINK) {
conn = gst_spider_link_get (peer); conn = gst_spider_link_get (peer);
} else { } else {
conn = gst_spider_link_get (ident); conn = gst_spider_link_get (ident);
} }
if ((GstElement *) spider->sink_ident == conn->current) { if ((GstElement *) spider->sink_ident == conn->current) {
gst_spider_plug (conn); gst_spider_plug (conn);
} }
} }
} }
padlist = g_list_next (padlist); padlist = g_list_next (padlist);
@ -536,9 +537,9 @@ gst_spider_create_and_plug (GstSpiderConnection * conn, GList * plugpath)
templist = g_list_last (plugpath); templist = g_list_last (plugpath);
element = (GstElement *) conn->src; element = (GstElement *) conn->src;
while ((plugpath != NULL) while ((plugpath != NULL)
&& (element = && (element =
gst_spider_find_element_to_plug (element, gst_spider_find_element_to_plug (element,
(GstElementFactory *) plugpath->data, GST_PAD_SINK))) { (GstElementFactory *) plugpath->data, GST_PAD_SINK))) {
GList *cur = templist; GList *cur = templist;
endelements = g_list_prepend (endelements, element); endelements = g_list_prepend (endelements, element);
@ -549,18 +550,18 @@ gst_spider_create_and_plug (GstSpiderConnection * conn, GList * plugpath)
/* do the linking */ /* do the linking */
while (conn->current != (GstElement *) (endelements == while (conn->current != (GstElement *) (endelements ==
NULL ? conn->src : endelements->data)) { NULL ? conn->src : endelements->data)) {
/* get sink element to plug, src is conn->current */ /* get sink element to plug, src is conn->current */
if (plugpath == NULL) { if (plugpath == NULL) {
element = element =
(GstElement *) (endelements == NULL ? conn->src : endelements->data); (GstElement *) (endelements == NULL ? conn->src : endelements->data);
} else { } else {
element = element =
gst_element_factory_create ((GstElementFactory *) plugpath->data, gst_element_factory_create ((GstElementFactory *) plugpath->data,
NULL); NULL);
GST_DEBUG GST_DEBUG
("Adding element %s of type %s and syncing state with autoplugger", ("Adding element %s of type %s and syncing state with autoplugger",
GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data)); GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data));
gst_bin_add (GST_BIN (spider), element); gst_bin_add (GST_BIN (spider), element);
} }
/* insert and link new element */ /* insert and link new element */
@ -572,30 +573,30 @@ gst_spider_create_and_plug (GstSpiderConnection * conn, GList * plugpath)
/* remove element that couldn't be linked, if it wasn't the endpoint */ /* remove element that couldn't be linked, if it wasn't the endpoint */
if (element != (GstElement *) conn->src) if (element != (GstElement *) conn->src)
gst_bin_remove (GST_BIN (spider), element); gst_bin_remove (GST_BIN (spider), element);
while (templs) { while (templs) {
GstPadTemplate *templ = (GstPadTemplate *) templs->data; GstPadTemplate *templ = (GstPadTemplate *) templs->data;
if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC)
&& (GST_PAD_TEMPLATE_PRESENCE (templ) == GST_PAD_SOMETIMES)) { && (GST_PAD_TEMPLATE_PRESENCE (templ) == GST_PAD_SOMETIMES)) {
GST_DEBUG ("adding callback to link element %s to %s", GST_DEBUG ("adding callback to link element %s to %s",
GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
conn->signal_id = conn->signal_id =
g_signal_connect (G_OBJECT (conn->current), "new_pad", g_signal_connect (G_OBJECT (conn->current), "new_pad",
G_CALLBACK (gst_spider_link_sometimes), conn); G_CALLBACK (gst_spider_link_sometimes), conn);
g_list_free (plugpath); g_list_free (plugpath);
return GST_PAD_LINK_DELAYED; return GST_PAD_LINK_DELAYED;
} }
templs = g_list_next (templs); templs = g_list_next (templs);
} }
GST_DEBUG ("no chance to link element %s to %s", GST_DEBUG ("no chance to link element %s to %s",
GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
g_list_free (plugpath); g_list_free (plugpath);
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
GST_DEBUG ("added element %s and attached it to element %s", GST_DEBUG ("added element %s and attached it to element %s",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current)); GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current));
gst_spider_link_add (conn, element); gst_spider_link_add (conn, element);
if (plugpath != NULL) if (plugpath != NULL)
plugpath = g_list_delete_link (plugpath, plugpath); plugpath = g_list_delete_link (plugpath, plugpath);
@ -622,13 +623,13 @@ gst_spider_find_element_to_plug (GstElement * src, GstElementFactory * fac,
/* is the pad on the right side and is it linked? */ /* is the pad on the right side and is it linked? */
if ((GST_PAD_DIRECTION (pad) == dir) if ((GST_PAD_DIRECTION (pad) == dir)
&& (pad = (GstPad *) (GST_RPAD_PEER (pad)))) { && (pad = (GstPad *) (GST_RPAD_PEER (pad)))) {
/* is the element the pad is linked to of the right type? */ /* is the element the pad is linked to of the right type? */
GstElement *element = GST_PAD_PARENT (pad); GstElement *element = GST_PAD_PARENT (pad);
if (G_TYPE_FROM_INSTANCE (element) == if (G_TYPE_FROM_INSTANCE (element) ==
gst_element_factory_get_element_type (fac)) { gst_element_factory_get_element_type (fac)) {
return element; return element;
} }
} }
padlist = g_list_next (padlist); padlist = g_list_next (padlist);
@ -671,7 +672,7 @@ gst_spider_plug_from_srcpad (GstSpiderConnection * conn, GstPad * srcpad)
/* see if they match already */ /* see if they match already */
if (gst_pad_link (srcpad, conn->src->sink)) { if (gst_pad_link (srcpad, conn->src->sink)) {
GST_DEBUG ("%s:%s and %s:%s can link directly", GST_DEBUG ("%s:%s and %s:%s can link directly",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink));
gst_pad_unlink (srcpad, conn->src->sink); gst_pad_unlink (srcpad, conn->src->sink);
gst_spider_create_and_plug (conn, NULL); gst_spider_create_and_plug (conn, NULL);
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
@ -696,7 +697,7 @@ gst_spider_plug_from_srcpad (GstSpiderConnection * conn, GstPad * srcpad)
/* if there is no way to plug: return */ /* if there is no way to plug: return */
if (plugpath == NULL) { if (plugpath == NULL) {
GST_DEBUG ("no chance to plug from %s to %s", GST_DEBUG ("no chance to plug from %s to %s",
GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src));
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
GST_DEBUG ("found a link that needs %d elements", g_list_length (plugpath)); GST_DEBUG ("found a link that needs %d elements", g_list_length (plugpath));
@ -708,8 +709,8 @@ gst_spider_plug_from_srcpad (GstSpiderConnection * conn, GstPad * srcpad)
element = conn->current; element = conn->current;
while ((plugpath != NULL) while ((plugpath != NULL)
&& (element = && (element =
gst_spider_find_element_to_plug (element, gst_spider_find_element_to_plug (element,
(GstElementFactory *) plugpath->data, GST_PAD_SRC))) { (GstElementFactory *) plugpath->data, GST_PAD_SRC))) {
gst_spider_link_add (conn, element); gst_spider_link_add (conn, element);
plugpath = g_list_delete_link (plugpath, plugpath); plugpath = g_list_delete_link (plugpath, plugpath);
} }
@ -739,10 +740,10 @@ plugin_init (GstPlugin * plugin)
"spider autoplugging element"); "spider autoplugging element");
if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY, if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY,
GST_TYPE_SPIDER)) GST_TYPE_SPIDER))
return FALSE; return FALSE;
if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE, if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE,
GST_TYPE_SPIDER_IDENTITY)) GST_TYPE_SPIDER_IDENTITY))
return FALSE; return FALSE;
return TRUE; return TRUE;

View file

@ -109,11 +109,12 @@ gst_spider_identity_get_type (void)
0, 0,
(GInstanceInitFunc) gst_spider_identity_init, (GInstanceInitFunc) gst_spider_identity_init,
}; };
spider_identity_type = spider_identity_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity", g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity",
&spider_identity_info, 0); &spider_identity_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", 0, GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", 0,
"spider autoplugging proxy element"); "spider autoplugging proxy element");
} }
return spider_identity_type; return spider_identity_type;
} }
@ -189,16 +190,16 @@ gst_spider_identity_chain (GstPad * pad, GstBuffer * buf)
GList *list = spider->links; GList *list = spider->links;
while (list) { while (list) {
GstSpiderConnection *conn = (GstSpiderConnection *) list->data; GstSpiderConnection *conn = (GstSpiderConnection *) list->data;
list = g_list_next (list); list = g_list_next (list);
if (conn->current != (GstElement *) conn->src) { if (conn->current != (GstElement *) conn->src) {
GST_DEBUG ("sending EOS to unconnected element %s from %s", GST_DEBUG ("sending EOS to unconnected element %s from %s",
GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident)); GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident));
gst_pad_push (conn->src->src, gst_pad_push (conn->src->src,
GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS)))); GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS))));
gst_element_set_eos (GST_ELEMENT (conn->src)); gst_element_set_eos (GST_ELEMENT (conn->src));
} }
} }
} }
/* end hack for current event stuff here */ /* end hack for current event stuff here */
@ -221,8 +222,7 @@ gst_spider_identity_new_src (gchar * name)
GstSpiderIdentity *ret = GstSpiderIdentity *ret =
(GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
/* set the right functions */ /* set the right functions */
gst_element_set_loop_function (GST_ELEMENT (ret), gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction)
(GstElementLoopFunction)
GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop)); GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop));
return ret; return ret;
@ -235,8 +235,7 @@ gst_spider_identity_new_sink (gchar * name)
(GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name);
/* set the right functions */ /* set the right functions */
gst_element_set_loop_function (GST_ELEMENT (ret), gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction)
(GstElementLoopFunction)
GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
return ret; return ret;
@ -278,10 +277,10 @@ gst_spider_identity_getcaps (GstPad * pad)
GstCaps *ret = gst_pad_get_allowed_caps (otherpad); GstCaps *ret = gst_pad_get_allowed_caps (otherpad);
if (ident->caps) { if (ident->caps) {
GstCaps *ret2 = gst_caps_intersect (ident->caps, ret); GstCaps *ret2 = gst_caps_intersect (ident->caps, ret);
gst_caps_free (ret); gst_caps_free (ret);
ret = ret2; ret = ret2;
} }
return ret; return ret;
} }
@ -308,29 +307,29 @@ gst_spider_identity_request_new_pad (GstElement * element,
switch (GST_PAD_TEMPLATE_DIRECTION (templ)) { switch (GST_PAD_TEMPLATE_DIRECTION (templ)) {
case GST_PAD_SINK: case GST_PAD_SINK:
if (ident->sink != NULL) if (ident->sink != NULL)
break; break;
/* sink */ /* sink */
GST_DEBUG ("element %s requests new sink pad", GST_ELEMENT_NAME (ident)); GST_DEBUG ("element %s requests new sink pad", GST_ELEMENT_NAME (ident));
ident->sink = gst_pad_new ("sink", GST_PAD_SINK); ident->sink = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (ident), ident->sink); gst_element_add_pad (GST_ELEMENT (ident), ident->sink);
gst_pad_set_link_function (ident->sink, gst_pad_set_link_function (ident->sink,
GST_DEBUG_FUNCPTR (gst_spider_identity_link)); GST_DEBUG_FUNCPTR (gst_spider_identity_link));
gst_pad_set_getcaps_function (ident->sink, gst_pad_set_getcaps_function (ident->sink,
GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
return ident->sink; return ident->sink;
case GST_PAD_SRC: case GST_PAD_SRC:
/* src */ /* src */
if (ident->src != NULL) if (ident->src != NULL)
break; break;
GST_DEBUG ("element %s requests new src pad", GST_ELEMENT_NAME (ident)); GST_DEBUG ("element %s requests new src pad", GST_ELEMENT_NAME (ident));
ident->src = gst_pad_new ("src", GST_PAD_SRC); ident->src = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (ident), ident->src); gst_element_add_pad (GST_ELEMENT (ident), ident->src);
gst_pad_set_link_function (ident->src, gst_pad_set_link_function (ident->src,
GST_DEBUG_FUNCPTR (gst_spider_identity_link)); GST_DEBUG_FUNCPTR (gst_spider_identity_link));
gst_pad_set_getcaps_function (ident->src, gst_pad_set_getcaps_function (ident->src,
GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps));
gst_pad_set_event_function (ident->src, gst_pad_set_event_function (ident->src,
GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event)); GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event));
return ident->src; return ident->src;
default: default:
break; break;
@ -370,22 +369,22 @@ gst_spider_identity_change_state (GstElement * element)
/* start typefinding or plugging */ /* start typefinding or plugging */
if ((GST_RPAD_PEER (ident->sink) != NULL) if ((GST_RPAD_PEER (ident->sink) != NULL)
&& (GST_RPAD_PEER (ident->src) == NULL)) { && (GST_RPAD_PEER (ident->src) == NULL)) {
GstCaps *caps = GstCaps *caps =
gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)); gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink));
if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) { if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) {
gst_spider_identity_start_type_finding (ident); gst_spider_identity_start_type_finding (ident);
gst_caps_free (caps); gst_caps_free (caps);
break; break;
} else { } else {
gst_spider_identity_plug (ident); gst_spider_identity_plug (ident);
} }
gst_caps_free (caps); gst_caps_free (caps);
} }
/* autoplug on src */ /* autoplug on src */
if ((GST_RPAD_PEER (ident->src) != NULL) if ((GST_RPAD_PEER (ident->src) != NULL)
&& (GST_RPAD_PEER (ident->sink) == NULL)) { && (GST_RPAD_PEER (ident->sink) == NULL)) {
gst_spider_identity_plug (ident); gst_spider_identity_plug (ident);
} }
default: default:
break; break;
@ -408,17 +407,16 @@ gst_spider_identity_start_type_finding (GstSpiderIdentity * ident)
GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME (ident)); GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME (ident));
if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING) { if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)),
GST_STATE_PAUSED); GST_STATE_PAUSED);
restart = TRUE; restart = TRUE;
} }
gst_element_set_loop_function (GST_ELEMENT (ident), gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction)
(GstElementLoopFunction)
GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding)); GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding));
if (restart) { if (restart) {
gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)),
GST_STATE_PLAYING); GST_STATE_PLAYING);
} }
} }
@ -450,9 +448,8 @@ gst_spider_identity_src_loop (GstSpiderIdentity * ident)
/* we don't want a loop function if we're plugged */ /* we don't want a loop function if we're plugged */
if (ident->sink && GST_PAD_PEER (ident->sink)) { if (ident->sink && GST_PAD_PEER (ident->sink)) {
gst_element_set_loop_function (GST_ELEMENT (ident), gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction)
(GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
gst_spider_identity_dumb_loop (ident); gst_spider_identity_dumb_loop (ident);
return; return;
} }
@ -466,7 +463,8 @@ typedef struct
GstBuffer *buffer; GstBuffer *buffer;
guint best_probability; guint best_probability;
GstCaps *caps; GstCaps *caps;
} SpiderTypeFind; }
SpiderTypeFind;
guint8 * guint8 *
spider_find_peek (gpointer data, gint64 offset, guint size) spider_find_peek (gpointer data, gint64 offset, guint size)
{ {
@ -532,7 +530,7 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity * ident)
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data); GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
GST_DEBUG ("trying typefind function %s", GST_DEBUG ("trying typefind function %s",
GST_PLUGIN_FEATURE_NAME (factory)); GST_PLUGIN_FEATURE_NAME (factory));
gst_type_find_factory_call_function (factory, &gst_find); gst_type_find_factory_call_function (factory, &gst_find);
if (find.best_probability >= GST_TYPE_FIND_MAXIMUM) if (find.best_probability >= GST_TYPE_FIND_MAXIMUM)
goto plug; goto plug;
@ -545,8 +543,7 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity * ident)
end: end:
/* remove loop function */ /* remove loop function */
gst_element_set_loop_function (GST_ELEMENT (ident), gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction)
(GstElementLoopFunction)
GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop));
/* push the buffer */ /* push the buffer */

View file

@ -15,10 +15,10 @@ gst_factories_at_most_templates (GList * factories, GstPadDirection dir,
while (templs) { while (templs) {
if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) { if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
count++; count++;
} }
if (count > maxtemplates) if (count > maxtemplates)
break; break;
templs = g_list_next (templs); templs = g_list_next (templs);
} }
if (count <= maxtemplates) if (count <= maxtemplates)
@ -33,7 +33,7 @@ static void
property_change_callback (GObject * object, GstObject * orig, property_change_callback (GObject * object, GstObject * orig,
GParamSpec * pspec) GParamSpec * pspec)
{ {
GValue value = { 0, }; /* the important thing is that value.type = 0 */ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0; gchar *str = 0;
if (pspec->flags & G_PARAM_READABLE) { if (pspec->flags & G_PARAM_READABLE) {
@ -121,8 +121,8 @@ main (int argc, char *argv[])
/* link objects */ /* link objects */
if (!(gst_element_link (filesrc, decoder) && if (!(gst_element_link (filesrc, decoder) &&
gst_element_link (decoder, osssink) && gst_element_link (decoder, osssink) &&
gst_element_link (decoder, videosink))) { gst_element_link (decoder, videosink))) {
g_print ("the pipeline could not be linked\n"); g_print ("the pipeline could not be linked\n");
exit (-4); exit (-4);
} }

View file

@ -63,7 +63,7 @@ static void cothread_destroy (cothread_state * cothread);
struct _cothread_context struct _cothread_context
{ {
cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */ cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */
int ncothreads; int ncothreads;
int current; int current;
unsigned long stack_top; unsigned long stack_top;
@ -112,7 +112,7 @@ cothread_context *
cothread_context_init (void) cothread_context_init (void)
{ {
char __csf; char __csf;
void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */ void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */
cothread_context *ctx; cothread_context *ctx;
/* if there already is a cotread context for this thread, /* if there already is a cotread context for this thread,
@ -120,7 +120,7 @@ cothread_context_init (void)
ctx = g_static_private_get (&_cothread_ctx_key); ctx = g_static_private_get (&_cothread_ctx_key);
if (ctx) { if (ctx) {
GST_CAT_INFO (GST_CAT_COTHREADS, GST_CAT_INFO (GST_CAT_COTHREADS,
"returning private _cothread_ctx_key %p", ctx); "returning private _cothread_ctx_key %p", ctx);
return ctx; return ctx;
} }
@ -243,7 +243,7 @@ cothread_create (cothread_context * ctx)
if (ctx->cothreads[slot] == NULL) if (ctx->cothreads[slot] == NULL)
break; break;
else if (ctx->cothreads[slot]->flags & COTHREAD_DESTROYED && else if (ctx->cothreads[slot]->flags & COTHREAD_DESTROYED &&
slot != ctx->current) { slot != ctx->current) {
cothread_destroy (ctx->cothreads[slot]); cothread_destroy (ctx->cothreads[slot]);
break; break;
} }
@ -263,7 +263,7 @@ cothread_create (cothread_context * ctx)
unsigned long ptr; unsigned long ptr;
for (ptr = ctx->stack_top - 4096; ptr > (unsigned long) cothread; for (ptr = ctx->stack_top - 4096; ptr > (unsigned long) cothread;
ptr -= 4096) { ptr -= 4096) {
GST_CAT_DEBUG (GST_CAT_COTHREADS, "touching location 0x%08lx", ptr); GST_CAT_DEBUG (GST_CAT_COTHREADS, "touching location 0x%08lx", ptr);
*(volatile unsigned int *) ptr = *(volatile unsigned int *) ptr; *(volatile unsigned int *) ptr = *(volatile unsigned int *) ptr;
GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *) ptr); GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *) ptr);
@ -478,11 +478,11 @@ cothread_stub (void)
cothread->func (cothread->argc, cothread->argv); cothread->func (cothread->argc, cothread->argv);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited", GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited",
ctx->current); ctx->current);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "sp=%p", current_stack_frame); GST_CAT_DEBUG (GST_CAT_COTHREADS, "sp=%p", current_stack_frame);
GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx, GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,
cothread_get_current_context ()); cothread_get_current_context ());
g_assert (ctx == cothread_get_current_context ()); g_assert (ctx == cothread_get_current_context ());
g_assert (ctx->current != 0); g_assert (ctx->current != 0);
@ -623,8 +623,8 @@ cothread_switch (cothread_state * cothread)
enter = setjmp (current->jmp); enter = setjmp (current->jmp);
if (enter != 0) { if (enter != 0) {
GST_CAT_DEBUG (GST_CAT_COTHREADS, GST_CAT_DEBUG (GST_CAT_COTHREADS,
"enter cothread #%d %d sp=%p jmpbuf=%p", "enter cothread #%d %d sp=%p jmpbuf=%p",
current->cothreadnum, enter, current->sp, current->jmp); current->cothreadnum, enter, current->sp, current->jmp);
return; return;
} }
GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p", GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p",

View file

@ -69,9 +69,10 @@ gst_aggregator_sched_get_type (void)
{AGGREGATOR_CHAIN, "4", "Chain Based"}, {AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!aggregator_sched_type) { if (!aggregator_sched_type) {
aggregator_sched_type = aggregator_sched_type =
g_enum_register_static ("GstAggregatorSched", aggregator_sched); g_enum_register_static ("GstAggregatorSched", aggregator_sched);
} }
return aggregator_sched_type; return aggregator_sched_type;
} }
@ -117,17 +118,17 @@ gst_aggregator_class_init (GstAggregatorClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "Num pads", "The number of source pads", g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce messages", g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED,
g_param_spec_enum ("sched", "Scheduling", g_param_spec_enum ("sched", "Scheduling",
"The type of scheduling this element should use", "The type of scheduling this element should use",
GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last message", g_param_spec_string ("last_message", "Last message",
"The current state of the element", NULL, G_PARAM_READABLE)); "The current state of the element", NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
@ -192,7 +193,7 @@ gst_aggregator_update_functions (GstAggregator * aggregator)
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_element_set_loop_function (GST_ELEMENT (aggregator), gst_element_set_loop_function (GST_ELEMENT (aggregator),
GST_DEBUG_FUNCPTR (gst_aggregator_loop)); GST_DEBUG_FUNCPTR (gst_aggregator_loop));
} else { } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
} }
@ -271,9 +272,9 @@ gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf,
g_free (aggregator->last_message); g_free (aggregator->last_message);
aggregator->last_message = aggregator->last_message =
g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad), G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (aggregator), "last_message"); g_object_notify (G_OBJECT (aggregator), "last_message");
} }
@ -306,11 +307,11 @@ gst_aggregator_loop (GstElement * element)
* and that the peer pad is also enabled. * and that the peer pad is also enabled.
*/ */
if (GST_PAD_IS_USABLE (pad)) { if (GST_PAD_IS_USABLE (pad)) {
buf = GST_BUFFER (gst_pad_pull (pad)); buf = GST_BUFFER (gst_pad_pull (pad));
debug = "loop"; debug = "loop";
/* then push it forward */ /* then push it forward */
gst_aggregator_push (aggregator, pad, buf, debug); gst_aggregator_push (aggregator, pad, buf, debug);
} }
} }
} else { } else {

View file

@ -64,7 +64,7 @@ debug_buffers (GstBufferStore * store)
g_printerr ("BUFFERS in store:\n"); g_printerr ("BUFFERS in store:\n");
while (walk) { while (walk) {
g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data), g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data),
GST_BUFFER_SIZE (walk->data)); GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk); walk = g_list_next (walk);
} }
g_printerr ("\n"); g_printerr ("\n");
@ -127,14 +127,14 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* we assumed valid offsets, but suddenly they are not anymore */ /* we assumed valid offsets, but suddenly they are not anymore */
GST_DEBUG_OBJECT (store, GST_DEBUG_OBJECT (store,
"attempting to add buffer %p with invalid offset to store with valid offset, abort", "attempting to add buffer %p with invalid offset to store with valid offset, abort",
buffer); buffer);
return FALSE; return FALSE;
} else if (!store->buffers } else if (!store->buffers
|| !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* the starting buffer had an invalid offset, in that case we assume continuous buffers */ /* the starting buffer had an invalid offset, in that case we assume continuous buffers */
GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u", GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u",
buffer, GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_SIZE (buffer));
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
store->buffers = g_list_append (store->buffers, buffer); store->buffers = g_list_append (store->buffers, buffer);
return TRUE; return TRUE;
@ -145,9 +145,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer)); g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer));
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"attempting to add buffer %p with offset %" G_GUINT64_FORMAT "attempting to add buffer %p with offset %" G_GUINT64_FORMAT
" and size %u", buffer, GST_BUFFER_OFFSET (buffer), " and size %u", buffer, GST_BUFFER_OFFSET (buffer),
GST_BUFFER_SIZE (buffer)); GST_BUFFER_SIZE (buffer));
/* we keep a sorted list of non-overlapping buffers */ /* we keep a sorted list of non-overlapping buffers */
walk = store->buffers; walk = store->buffers;
while (walk) { while (walk) {
@ -155,88 +155,88 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
current_list = walk; current_list = walk;
walk = g_list_next (walk); walk = g_list_next (walk);
if (GST_BUFFER_OFFSET (current) < GST_BUFFER_OFFSET (buffer)) { if (GST_BUFFER_OFFSET (current) < GST_BUFFER_OFFSET (buffer)) {
continue; continue;
} else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) { } else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) {
guint needed_size; guint needed_size;
if (walk) { if (walk) {
needed_size = MIN (GST_BUFFER_SIZE (buffer), needed_size = MIN (GST_BUFFER_SIZE (buffer),
GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
} else { } else {
needed_size = GST_BUFFER_SIZE (buffer); needed_size = GST_BUFFER_SIZE (buffer);
} }
if (needed_size <= GST_BUFFER_SIZE (current)) { if (needed_size <= GST_BUFFER_SIZE (current)) {
buffer = NULL; buffer = NULL;
break; break;
} else { } else {
if (needed_size < GST_BUFFER_SIZE (buffer)) { if (needed_size < GST_BUFFER_SIZE (buffer)) {
/* need to create subbuffer to not have overlapping data */ /* need to create subbuffer to not have overlapping data */
GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size); GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size);
g_assert (sub); g_assert (sub);
buffer = sub; buffer = sub;
} else { } else {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
} }
/* replace current buffer with new one */ /* replace current buffer with new one */
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT
" and size %u", current_list->data, buffer, " and size %u", current_list->data, buffer,
GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
gst_data_unref (GST_DATA (current_list->data)); gst_data_unref (GST_DATA (current_list->data));
current_list->data = buffer; current_list->data = buffer;
buffer = NULL; buffer = NULL;
break; break;
} }
} else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) { } else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) {
GList *previous = g_list_previous (current_list); GList *previous = g_list_previous (current_list);
guint64 start_offset = previous ? guint64 start_offset = previous ?
GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_OFFSET (previous->data) +
GST_BUFFER_SIZE (previous->data) : 0; GST_BUFFER_SIZE (previous->data) : 0;
if (start_offset == GST_BUFFER_OFFSET (current)) { if (start_offset == GST_BUFFER_OFFSET (current)) {
buffer = NULL; buffer = NULL;
break; break;
} else { } else {
/* we have data to insert */ /* we have data to insert */
if (start_offset > GST_BUFFER_OFFSET (buffer) || if (start_offset > GST_BUFFER_OFFSET (buffer) ||
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) >
GST_BUFFER_OFFSET (current)) { GST_BUFFER_OFFSET (current)) {
GstBuffer *sub; GstBuffer *sub;
/* need a subbuffer */ /* need a subbuffer */
start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
start_offset - GST_BUFFER_OFFSET (buffer); start_offset - GST_BUFFER_OFFSET (buffer);
sub = gst_buffer_create_sub (buffer, start_offset, sub = gst_buffer_create_sub (buffer, start_offset,
MIN (GST_BUFFER_SIZE (buffer), MIN (GST_BUFFER_SIZE (buffer),
GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (current) - start_offset -
GST_BUFFER_OFFSET (buffer))); GST_BUFFER_OFFSET (buffer)));
g_assert (sub); g_assert (sub);
GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer); GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer);
buffer = sub; buffer = sub;
} else { } else {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
} }
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
store->buffers = store->buffers =
g_list_insert_before (store->buffers, current_list, buffer); g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL; buffer = NULL;
break; break;
} }
} }
} }
if (buffer) { if (buffer) {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
if (current_list) { if (current_list) {
g_list_append (current_list, buffer); g_list_append (current_list, buffer);
} else { } else {
g_assert (store->buffers == NULL); g_assert (store->buffers == NULL);
store->buffers = g_list_prepend (NULL, buffer); store->buffers = g_list_prepend (NULL, buffer);
} }
} }
return TRUE; return TRUE;
@ -352,47 +352,47 @@ gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size)
do_nothing_loop (); */ do_nothing_loop (); */
} else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) { } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) {
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"found matching buffer %p for offset %" G_GUINT64_FORMAT "found matching buffer %p for offset %" G_GUINT64_FORMAT
" and size %u", current, offset, size); " and size %u", current, offset, size);
ret = current; ret = current;
gst_data_ref (GST_DATA (ret)); gst_data_ref (GST_DATA (ret));
GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret)); GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret));
break; break;
} else if (cur_offset + GST_BUFFER_SIZE (current) > offset) { } else if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) { if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) {
ret = gst_buffer_create_sub (current, offset - cur_offset, size); ret = gst_buffer_create_sub (current, offset - cur_offset, size);
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"created subbuffer %p from buffer %p for offset %llu and size %u", "created subbuffer %p from buffer %p for offset %llu and size %u",
ret, current, offset, size); ret, current, offset, size);
break; break;
} }
/* uh, the requested data spans some buffers */ /* uh, the requested data spans some buffers */
ret = gst_buffer_new_and_alloc (size); ret = gst_buffer_new_and_alloc (size);
GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT
" and size %u, will fill with data now", ret, offset, size); " and size %u, will fill with data now", ret, offset, size);
data = GST_BUFFER_DATA (ret); data = GST_BUFFER_DATA (ret);
tmp = GST_BUFFER_SIZE (current) - offset + cur_offset; tmp = GST_BUFFER_SIZE (current) - offset + cur_offset;
memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp); memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp);
data += tmp; data += tmp;
size -= tmp; size -= tmp;
while (size) { while (size) {
if (walk == NULL || if (walk == NULL ||
(have_offset && (have_offset &&
GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) !=
GST_BUFFER_OFFSET (walk->data))) { GST_BUFFER_OFFSET (walk->data))) {
GST_DEBUG_OBJECT (store, GST_DEBUG_OBJECT (store,
"not all data for offset %" G_GUINT64_FORMAT "not all data for offset %" G_GUINT64_FORMAT
" and remaining size %u available, aborting", offset, size); " and remaining size %u available, aborting", offset, size);
gst_data_unref (GST_DATA (ret)); gst_data_unref (GST_DATA (ret));
ret = NULL; ret = NULL;
goto out; goto out;
} }
current = GST_BUFFER (walk->data); current = GST_BUFFER (walk->data);
walk = g_list_next (walk); walk = g_list_next (walk);
tmp = MIN (GST_BUFFER_SIZE (current), size); tmp = MIN (GST_BUFFER_SIZE (current), size);
memcpy (data, GST_BUFFER_DATA (current), tmp); memcpy (data, GST_BUFFER_DATA (current), tmp);
data += tmp; data += tmp;
size -= tmp; size -= tmp;
} }
} }
if (!have_offset) { if (!have_offset) {
@ -437,8 +437,8 @@ gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
} }
while (walk) { while (walk) {
if (have_offset && counting && if (have_offset && counting &&
cur_offset + GST_BUFFER_SIZE (current) != cur_offset + GST_BUFFER_SIZE (current) !=
GST_BUFFER_OFFSET (walk->data)) { GST_BUFFER_OFFSET (walk->data)) {
break; break;
} }
current = GST_BUFFER (walk->data); current = GST_BUFFER (walk->data);
@ -450,11 +450,11 @@ gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
ret += GST_BUFFER_SIZE (current); ret += GST_BUFFER_SIZE (current);
} else { } else {
if (cur_offset > offset) if (cur_offset > offset)
return 0; return 0;
if (cur_offset + GST_BUFFER_SIZE (current) > offset) { if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
/* we have at least some bytes */ /* we have at least some bytes */
ret = cur_offset + GST_BUFFER_SIZE (current) - offset; ret = cur_offset + GST_BUFFER_SIZE (current) - offset;
counting = TRUE; counting = TRUE;
} }
} }
if (!have_offset) { if (!have_offset) {

View file

@ -81,7 +81,7 @@ plugin_init (GstPlugin * plugin)
while ((*my_elements).name) { while ((*my_elements).name) {
if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank,
((*my_elements).type) ())) ((*my_elements).type) ()))
return FALSE; return FALSE;
my_elements++; my_elements++;
} }

View file

@ -70,22 +70,23 @@ gst_fakesink_state_error_get_type (void)
static GEnumValue fakesink_state_error[] = { static GEnumValue fakesink_state_error[] = {
{FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
{FAKESINK_STATE_ERROR_NULL_READY, "1", {FAKESINK_STATE_ERROR_NULL_READY, "1",
"Fail state change from NULL to READY"}, "Fail state change from NULL to READY"},
{FAKESINK_STATE_ERROR_READY_PAUSED, "2", {FAKESINK_STATE_ERROR_READY_PAUSED, "2",
"Fail state change from READY to PAUSED"}, "Fail state change from READY to PAUSED"},
{FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3",
"Fail state change from PAUSED to PLAYING"}, "Fail state change from PAUSED to PLAYING"},
{FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4",
"Fail state change from PLAYING to PAUSED"}, "Fail state change from PLAYING to PAUSED"},
{FAKESINK_STATE_ERROR_PAUSED_READY, "5", {FAKESINK_STATE_ERROR_PAUSED_READY, "5",
"Fail state change from PAUSED to READY"}, "Fail state change from PAUSED to READY"},
{FAKESINK_STATE_ERROR_READY_NULL, "6", {FAKESINK_STATE_ERROR_READY_NULL, "6",
"Fail state change from READY to NULL"}, "Fail state change from READY to NULL"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesink_state_error_type) { if (!fakesink_state_error_type) {
fakesink_state_error_type = fakesink_state_error_type =
g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
} }
return fakesink_state_error_type; return fakesink_state_error_type;
} }
@ -133,27 +134,27 @@ gst_fakesink_class_init (GstFakeSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
g_param_spec_int ("num_sinks", "Number of sinks", g_param_spec_int ("num_sinks", "Number of sinks",
"The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE)); "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR,
g_param_spec_enum ("state_error", "State Error", g_param_spec_enum ("state_error", "State Error",
"Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR, "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR,
FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last Message", g_param_spec_string ("last_message", "Last Message",
"The message describing current status", NULL, G_PARAM_READABLE)); "The message describing current status", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE, g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
"Send a signal before unreffing the buffer", FALSE, "Send a signal before unreffing the buffer", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", g_param_spec_boolean ("silent", "Silent",
"Don't produce last_message events", FALSE, G_PARAM_READWRITE)); "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -316,22 +317,22 @@ gst_fakesink_chain (GstPad * pad, GstData * _data)
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = fakesink->last_message =
g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
g_object_notify (G_OBJECT (fakesink), "last_message"); g_object_notify (G_OBJECT (fakesink), "last_message");
} }
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
if (fakesink->sync && fakesink->clock) { if (fakesink->sync && fakesink->clock) {
gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
gst_element_set_time (GST_ELEMENT (fakesink), value); gst_element_set_time (GST_ELEMENT (fakesink), value);
} }
default: default:
gst_pad_event_default (pad, event); gst_pad_event_default (pad, event);
break; break;
} }
return; return;
} }
@ -344,19 +345,19 @@ gst_fakesink_chain (GstPad * pad, GstData * _data)
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = fakesink->last_message =
g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %" G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %"
G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad), G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf),
GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf), GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf),
GST_BUFFER_FLAGS (buf), buf); GST_BUFFER_FLAGS (buf), buf);
g_object_notify (G_OBJECT (fakesink), "last_message"); g_object_notify (G_OBJECT (fakesink), "last_message");
} }
if (fakesink->signal_handoffs) if (fakesink->signal_handoffs)
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
buf, pad); buf, pad);
if (fakesink->dump) { if (fakesink->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
@ -373,27 +374,27 @@ gst_fakesink_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
if (fakesink->state_error == FAKESINK_STATE_ERROR_NULL_READY) if (fakesink->state_error == FAKESINK_STATE_ERROR_NULL_READY)
goto error; goto error;
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_PAUSED) if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_PAUSED)
goto error; goto error;
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_PLAYING) if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_PLAYING)
goto error; goto error;
break; break;
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PLAYING_PAUSED) if (fakesink->state_error == FAKESINK_STATE_ERROR_PLAYING_PAUSED)
goto error; goto error;
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_READY) if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_READY)
goto error; goto error;
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL) if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL)
goto error; goto error;
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = NULL; fakesink->last_message = NULL;
break; break;

View file

@ -95,9 +95,10 @@ gst_fakesrc_output_get_type (void)
{FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_output_type) { if (!fakesrc_output_type) {
fakesrc_output_type = fakesrc_output_type =
g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
} }
return fakesrc_output_type; return fakesrc_output_type;
} }
@ -112,6 +113,7 @@ gst_fakesrc_data_get_type (void)
{FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_data_type) { if (!fakesrc_data_type) {
fakesrc_data_type = g_enum_register_static ("GstFakeSrcData", fakesrc_data); fakesrc_data_type = g_enum_register_static ("GstFakeSrcData", fakesrc_data);
} }
@ -127,12 +129,13 @@ gst_fakesrc_sizetype_get_type (void)
{FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
{FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
{FAKESRC_SIZETYPE_RANDOM, "3", {FAKESRC_SIZETYPE_RANDOM, "3",
"Random sized buffers (sizemin <= size <= sizemax)"}, "Random sized buffers (sizemin <= size <= sizemax)"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_sizetype_type) { if (!fakesrc_sizetype_type) {
fakesrc_sizetype_type = fakesrc_sizetype_type =
g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
} }
return fakesrc_sizetype_type; return fakesrc_sizetype_type;
} }
@ -148,12 +151,13 @@ gst_fakesrc_filltype_get_type (void)
{FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
{FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
{FAKESRC_FILLTYPE_PATTERN_CONT, "5", {FAKESRC_FILLTYPE_PATTERN_CONT, "5",
"Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_filltype_type) { if (!fakesrc_filltype_type) {
fakesrc_filltype_type = fakesrc_filltype_type =
g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
} }
return fakesrc_filltype_type; return fakesrc_filltype_type;
} }
@ -201,56 +205,56 @@ gst_fakesrc_class_init (GstFakeSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int ("num-sources", "num-sources", "Number of sources", g_param_spec_int ("num-sources", "num-sources", "Number of sources",
1, G_MAXINT, 1, G_PARAM_READABLE)); 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
g_param_spec_boolean ("loop-based", "loop-based", g_param_spec_boolean ("loop-based", "loop-based",
"Enable loop-based operation", FALSE, G_PARAM_READWRITE)); "Enable loop-based operation", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
g_param_spec_enum ("output", "output", "Output method (currently unused)", g_param_spec_enum ("output", "output", "Output method (currently unused)",
GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
g_param_spec_enum ("data", "data", "Data allocation method", g_param_spec_enum ("data", "data", "Data allocation method",
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE,
g_param_spec_enum ("sizetype", "sizetype", g_param_spec_enum ("sizetype", "sizetype",
"How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE, "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE,
FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0, g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0,
G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0, g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0,
G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
g_param_spec_int ("parentsize", "parentsize", g_param_spec_int ("parentsize", "parentsize",
"Size of parent buffer for sub-buffered allocation", 0, G_MAXINT, "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT,
DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
g_param_spec_enum ("filltype", "filltype", g_param_spec_enum ("filltype", "filltype",
"How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE, "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE,
FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
g_param_spec_string ("pattern", "pattern", "pattern", NULL, g_param_spec_string ("pattern", "pattern", "pattern", NULL,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
g_param_spec_int ("num-buffers", "num-buffers", g_param_spec_int ("num-buffers", "num-buffers",
"Number of buffers to output before sending EOS", G_MININT, G_MAXINT, "Number of buffers to output before sending EOS", G_MININT, G_MAXINT,
0, G_PARAM_READWRITE)); 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE, g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", g_param_spec_string ("last-message", "last-message",
"The last status message", NULL, G_PARAM_READABLE)); "The last status message", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", g_param_spec_boolean ("silent", "Silent",
"Don't produce last_message events", FALSE, G_PARAM_READWRITE)); "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
"Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE)); "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] = gst_fakesrc_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -334,6 +338,7 @@ gst_fakesrc_get_formats (GstPad * pad)
GST_FORMAT_DEFAULT, GST_FORMAT_DEFAULT,
0, 0,
}; };
return formats; return formats;
} }
@ -347,6 +352,7 @@ gst_fakesrc_get_query_types (GstPad * pad)
GST_QUERY_SEGMENT_END, GST_QUERY_SEGMENT_END,
0, 0,
}; };
return types; return types;
} }
@ -384,6 +390,7 @@ gst_fakesrc_get_event_mask (GstPad * pad)
{GST_EVENT_FLUSH, 0}, {GST_EVENT_FLUSH, 0},
{0, 0}, {0, 0},
}; };
return masks; return masks;
} }
@ -399,7 +406,7 @@ gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
src->buffer_count = GST_EVENT_SEEK_OFFSET (event); src->buffer_count = GST_EVENT_SEEK_OFFSET (event);
if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
break; break;
} }
/* else we do a flush too */ /* else we do a flush too */
case GST_EVENT_SEEK_SEGMENT: case GST_EVENT_SEEK_SEGMENT:
@ -407,7 +414,7 @@ gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event); src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
src->buffer_count = src->segment_start; src->buffer_count = src->segment_start;
src->segment_loop = src->segment_loop =
GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
break; break;
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
src->need_flush = TRUE; src->need_flush = TRUE;
@ -427,7 +434,7 @@ gst_fakesrc_update_functions (GstFakeSrc * src)
if (src->loop_based) { if (src->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (src), gst_element_set_loop_function (GST_ELEMENT (src),
GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
} else { } else {
gst_element_set_loop_function (GST_ELEMENT (src), NULL); gst_element_set_loop_function (GST_ELEMENT (src), NULL);
} }
@ -485,13 +492,13 @@ gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value,
src->data = g_value_get_enum (value); src->data = g_value_get_enum (value);
if (src->data == FAKESRC_DATA_SUBBUFFER) { if (src->data == FAKESRC_DATA_SUBBUFFER) {
if (!src->parent) if (!src->parent)
gst_fakesrc_alloc_parent (src); gst_fakesrc_alloc_parent (src);
} else { } else {
if (src->parent) { if (src->parent) {
gst_buffer_unref (src->parent); gst_buffer_unref (src->parent);
src->parent = NULL; src->parent = NULL;
} }
} }
break; break;
case ARG_SIZETYPE: case ARG_SIZETYPE:
@ -614,7 +621,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
guint8 *ptr = GST_BUFFER_DATA (buf); guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) { for (i = GST_BUFFER_SIZE (buf); i; i--) {
*ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX)); *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX));
} }
break; break;
} }
@ -626,7 +633,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
guint8 *ptr = GST_BUFFER_DATA (buf); guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) { for (i = GST_BUFFER_SIZE (buf); i; i--) {
*ptr++ = src->pattern_byte++; *ptr++ = src->pattern_byte++;
} }
break; break;
} }
@ -647,18 +654,18 @@ gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size)
if (size != 0) { if (size != 0) {
switch (src->filltype) { switch (src->filltype) {
case FAKESRC_FILLTYPE_NOTHING: case FAKESRC_FILLTYPE_NOTHING:
GST_BUFFER_DATA (buf) = g_malloc (size); GST_BUFFER_DATA (buf) = g_malloc (size);
break; break;
case FAKESRC_FILLTYPE_NULL: case FAKESRC_FILLTYPE_NULL:
GST_BUFFER_DATA (buf) = g_malloc0 (size); GST_BUFFER_DATA (buf) = g_malloc0 (size);
break; break;
case FAKESRC_FILLTYPE_RANDOM: case FAKESRC_FILLTYPE_RANDOM:
case FAKESRC_FILLTYPE_PATTERN: case FAKESRC_FILLTYPE_PATTERN:
case FAKESRC_FILLTYPE_PATTERN_CONT: case FAKESRC_FILLTYPE_PATTERN_CONT:
default: default:
GST_BUFFER_DATA (buf) = g_malloc (size); GST_BUFFER_DATA (buf) = g_malloc (size);
gst_fakesrc_prepare_buffer (src, buf); gst_fakesrc_prepare_buffer (src, buf);
break; break;
} }
} }
@ -676,9 +683,9 @@ gst_fakesrc_get_size (GstFakeSrc * src)
break; break;
case FAKESRC_SIZETYPE_RANDOM: case FAKESRC_SIZETYPE_RANDOM:
size = size =
src->sizemin + src->sizemin +
(guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX + (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX +
(gfloat) src->sizemin)); (gfloat) src->sizemin));
break; break;
case FAKESRC_SIZETYPE_NULL: case FAKESRC_SIZETYPE_NULL:
default: default:
@ -707,19 +714,19 @@ gst_fakesrc_create_buffer (GstFakeSrc * src)
case FAKESRC_DATA_SUBBUFFER: case FAKESRC_DATA_SUBBUFFER:
/* see if we have a parent to subbuffer */ /* see if we have a parent to subbuffer */
if (!src->parent) { if (!src->parent) {
gst_fakesrc_alloc_parent (src); gst_fakesrc_alloc_parent (src);
g_assert (src->parent); g_assert (src->parent);
} }
/* see if it's large enough */ /* see if it's large enough */
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) { if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
src->parentoffset += size; src->parentoffset += size;
} else { } else {
/* the parent is useless now */ /* the parent is useless now */
gst_buffer_unref (src->parent); gst_buffer_unref (src->parent);
src->parent = NULL; src->parent = NULL;
/* try again (this will allocate a new parent) */ /* try again (this will allocate a new parent) */
return gst_fakesrc_create_buffer (src); return gst_fakesrc_create_buffer (src);
} }
gst_fakesrc_prepare_buffer (src, buf); gst_fakesrc_prepare_buffer (src, buf);
break; break;
@ -781,9 +788,9 @@ gst_fakesrc_get (GstPad * pad)
g_free (src->last_message); g_free (src->last_message);
src->last_message = src->last_message =
g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad), G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (src), "last_message"); g_object_notify (G_OBJECT (src), "last_message");
} }
@ -791,7 +798,7 @@ gst_fakesrc_get (GstPad * pad)
if (src->signal_handoffs) { if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit"); GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf, pad); buf, pad);
GST_LOG_OBJECT (src, "post handoff emit"); GST_LOG_OBJECT (src, "post handoff emit");
} }
@ -856,8 +863,8 @@ gst_fakesrc_change_state (GstElement * element)
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (fakesrc->parent) { if (fakesrc->parent) {
gst_buffer_unref (fakesrc->parent); gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL; fakesrc->parent = NULL;
} }
g_free (fakesrc->last_message); g_free (fakesrc->last_message);
fakesrc->last_message = NULL; fakesrc->last_message = NULL;

View file

@ -82,7 +82,7 @@ gst_fdsink_class_init (GstFdSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to write to", g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
0, G_MAXINT, 1, G_PARAM_READWRITE)); 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property; gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property; gobject_class->get_property = gst_fdsink_get_property;
@ -114,7 +114,7 @@ gst_fdsink_chain (GstPad * pad, GstData * _data)
if (GST_BUFFER_DATA (buf)) { if (GST_BUFFER_DATA (buf)) {
GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf), GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf),
fdsink->fd); fdsink->fd);
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
} }

View file

@ -92,14 +92,14 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to read from", g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", g_param_spec_ulong ("blocksize", "Block size",
"Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT,
g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
gst_fdsrc_signals[SIGNAL_TIMEOUT] = gst_fdsrc_signals[SIGNAL_TIMEOUT] =
g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -204,11 +204,11 @@ gst_fdsrc_get (GstPad * pad)
do { do {
retval = select (1, &readfds, NULL, NULL, tp); retval = select (1, &readfds, NULL, NULL, tp);
} while (retval == -1 && errno == EINTR); /* retry if interrupted */ } while (retval == -1 && errno == EINTR); /* retry if interrupted */
if (retval == -1) { if (retval == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("select on file descriptor: %s.", g_strerror (errno))); ("select on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else if (retval == 0) { } else if (retval == 0) {
@ -219,7 +219,7 @@ gst_fdsrc_get (GstPad * pad)
do { do {
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize); readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize);
} while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
if (readbytes > 0) { if (readbytes > 0) {
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
@ -234,7 +234,7 @@ gst_fdsrc_get (GstPad * pad)
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else { } else {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("read on file descriptor: %s.", g_strerror (errno))); ("read on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }

View file

@ -66,6 +66,7 @@ gst_filesink_get_formats (GstPad * pad)
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
0, 0,
}; };
return formats; return formats;
} }
@ -77,6 +78,7 @@ gst_filesink_get_query_types (GstPad * pad)
GST_QUERY_POSITION, GST_QUERY_POSITION,
0 0
}; };
return types; return types;
} }
@ -110,6 +112,7 @@ _do_init (GType filesink_type)
NULL, NULL,
NULL NULL
}; };
g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER,
&urihandler_info); &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0,
@ -136,7 +139,7 @@ gst_filesink_class_init (GstFileSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "File Location", g_param_spec_string ("location", "File Location",
"Location of the file to write", NULL, G_PARAM_READWRITE)); "Location of the file to write", NULL, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] = gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -251,15 +254,15 @@ gst_filesink_open_file (GstFileSink * sink)
/* open the file */ /* open the file */
if (sink->filename == NULL || sink->filename[0] == '\0') { if (sink->filename == NULL || sink->filename[0] == '\0') {
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
(_("No file name specified for writing.")), (NULL)); (_("No file name specified for writing.")), (NULL));
return FALSE; return FALSE;
} }
sink->file = fopen (sink->filename, "w"); sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) { if (sink->file == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
(_("Could not open file \"%s\" for writing."), sink->filename), (_("Could not open file \"%s\" for writing."), sink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} }
@ -277,7 +280,7 @@ gst_filesink_close_file (GstFileSink * sink)
if (fclose (sink->file) != 0) { if (fclose (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
(_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM); (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
} else { } else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN); GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
} }
@ -292,25 +295,25 @@ gst_filesink_pad_query (GstPad * pad, GstQueryType type,
switch (type) { switch (type) {
case GST_QUERY_TOTAL: case GST_QUERY_TOTAL:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
*value = sink->data_written; /* FIXME - doesn't the kernel provide *value = sink->data_written; /* FIXME - doesn't the kernel provide
such a function? */ such a function? */
break; break;
} }
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
*value = ftell (sink->file); *value = ftell (sink->file);
break; break;
} }
default: default:
return FALSE; return FALSE;
} }
break; break;
default: default:
@ -336,27 +339,27 @@ gst_filesink_handle_event (GstPad * pad, GstEvent * event)
switch (type) { switch (type) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES, g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES,
FALSE); FALSE);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
if (fflush (filesink->file)) if (fflush (filesink->file))
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
switch (GST_EVENT_SEEK_METHOD (event)) { switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET: case GST_SEEK_METHOD_SET:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
break; break;
default: default:
g_warning ("unknown seek method!"); g_warning ("unknown seek method!");
break; break;
} }
break; break;
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
@ -364,16 +367,16 @@ gst_filesink_handle_event (GstPad * pad, GstEvent * event)
gint64 offset; gint64 offset;
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset)) if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset))
fseek (filesink->file, offset, SEEK_SET); fseek (filesink->file, offset, SEEK_SET);
gst_event_unref (event); gst_event_unref (event);
break; break;
} }
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
if (fflush (filesink->file)) { if (fflush (filesink->file)) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
} }
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
@ -419,15 +422,15 @@ gst_filesink_chain (GstPad * pad, GstData * _data)
back_pending = filesink->data_written - ftell (filesink->file); back_pending = filesink->data_written - ftell (filesink->file);
while (bytes_written < GST_BUFFER_SIZE (buf)) { while (bytes_written < GST_BUFFER_SIZE (buf)) {
size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
GST_BUFFER_SIZE (buf) - bytes_written, GST_BUFFER_SIZE (buf) - bytes_written,
filesink->file); filesink->file);
if (wrote <= 0) { if (wrote <= 0) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
("Only %d of %d bytes written: %s", ("Only %d of %d bytes written: %s",
bytes_written, GST_BUFFER_SIZE (buf), strerror (errno))); bytes_written, GST_BUFFER_SIZE (buf), strerror (errno)));
break; break;
} }
bytes_written += wrote; bytes_written += wrote;
} }
@ -449,13 +452,13 @@ gst_filesink_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN))
gst_filesink_close_file (GST_FILESINK (element)); gst_filesink_close_file (GST_FILESINK (element));
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) {
if (!gst_filesink_open_file (GST_FILESINK (element))) if (!gst_filesink_open_file (GST_FILESINK (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
break; break;
} }
@ -477,6 +480,7 @@ static gchar **
gst_filesink_uri_get_protocols (void) gst_filesink_uri_get_protocols (void)
{ {
static gchar *protocols[] = { "file", NULL }; static gchar *protocols[] = { "file", NULL };
return protocols; return protocols;
} }
static const gchar * static const gchar *

View file

@ -107,11 +107,12 @@ gst_filesrc_get_event_mask (GstPad * pad)
{ {
static const GstEventMask masks[] = { static const GstEventMask masks[] = {
{GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{GST_EVENT_FLUSH, 0}, {GST_EVENT_FLUSH, 0},
{GST_EVENT_SIZE, 0}, {GST_EVENT_SIZE, 0},
{0, 0} {0, 0}
}; };
return masks; return masks;
} }
@ -123,6 +124,7 @@ gst_filesrc_get_query_types (GstPad * pad)
GST_QUERY_POSITION, GST_QUERY_POSITION,
0 0
}; };
return types; return types;
} }
@ -133,6 +135,7 @@ gst_filesrc_get_formats (GstPad * pad)
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
0, 0,
}; };
return formats; return formats;
} }
@ -162,6 +165,7 @@ _do_init (GType filesrc_type)
NULL, NULL,
NULL NULL
}; };
g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER,
&urihandler_info); &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element"); GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element");
@ -188,22 +192,22 @@ gst_filesrc_class_init (GstFileSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "File-descriptor", g_param_spec_int ("fd", "File-descriptor",
"File-descriptor for the file being mmap()d", 0, G_MAXINT, 0, "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "File Location", g_param_spec_string ("location", "File Location",
"Location of the file to read", NULL, G_PARAM_READWRITE)); "Location of the file to read", NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", g_param_spec_ulong ("blocksize", "Block size",
"Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
g_param_spec_ulong ("mmapsize", "mmap() Block Size", g_param_spec_ulong ("mmapsize", "mmap() Block Size",
"Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE, "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
g_param_spec_boolean ("touch", "Touch read data", g_param_spec_boolean ("touch", "Touch read data",
"Touch data to force disk read", FALSE, G_PARAM_READWRITE)); "Touch data to force disk read", FALSE, G_PARAM_READWRITE));
gobject_class->dispose = gst_filesrc_dispose; gobject_class->dispose = gst_filesrc_dispose;
gobject_class->set_property = gst_filesrc_set_property; gobject_class->set_property = gst_filesrc_set_property;
@ -235,7 +239,7 @@ gst_filesrc_init (GstFileSrc * src)
src->touch = FALSE; src->touch = FALSE;
src->mapbuf = NULL; src->mapbuf = NULL;
src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->seek_happened = FALSE; src->seek_happened = FALSE;
} }
@ -301,12 +305,12 @@ gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value,
break; break;
case ARG_MMAPSIZE: case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) { if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO_OBJECT (src, GST_INFO_OBJECT (src,
"invalid mapsize, must be a multiple of pagesize, which is %d", "invalid mapsize, must be a multiple of pagesize, which is %d",
src->pagesize); src->pagesize);
} }
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -390,7 +394,7 @@ gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size)
return NULL; return NULL;
} else if (mmapregion == MAP_FAILED) { } else if (mmapregion == MAP_FAILED) {
GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s", GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
(unsigned long) size, src->fd, offset, strerror (errno)); (unsigned long) size, src->fd, offset, strerror (errno));
return NULL; return NULL;
} }
GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
@ -435,7 +439,7 @@ gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size)
mapbase = offset - mod; mapbase = offset - mod;
mapsize = mapsize =
((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/ /* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
map = gst_filesrc_map_region (src, mapbase, mapsize); map = gst_filesrc_map_region (src, mapbase, mapsize);
if (map == NULL) if (map == NULL)
@ -468,10 +472,10 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* calculate end pointers so we don't have to do so repeatedly later */ /* calculate end pointers so we don't have to do so repeatedly later */
readsize = src->block_size; readsize = src->block_size;
readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
mapstart = GST_BUFFER_OFFSET (src->mapbuf); mapstart = GST_BUFFER_OFFSET (src->mapbuf);
mapsize = GST_BUFFER_SIZE (src->mapbuf); mapsize = GST_BUFFER_SIZE (src->mapbuf);
mapend = mapstart + mapsize; /* note this is the byte *after* the map */ mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */ /* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) { if (readend > src->filelen) {
@ -491,22 +495,22 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* ('cause by definition if readend is in the buffer, so's readstart) */ /* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) { if (readend <= mapend) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
src->curoffset, (int) readsize, mapstart, mapsize); src->curoffset, (int) readsize, mapstart, mapsize);
buf = buf =
gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
readsize); readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
/* if the start actually is within the current mmap region, map an overlap buffer */ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) { } else if (src->curoffset < mapend) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
(unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
(gint) mapsize); (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
} }
/* the only other option is that buffer is totally outside, which means we search for it */ /* the only other option is that buffer is totally outside, which means we search for it */
@ -518,9 +522,9 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* or the read buffer fully contains the current mmap region */ /* or the read buffer fully contains the current mmap region */
/* either way, it's really not relevant, we just create a new region anyway */ /* either way, it's really not relevant, we just create a new region anyway */
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
(unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
(gint) mapsize); (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -530,16 +534,16 @@ gst_filesrc_get_mmap (GstFileSrc * src)
if (buf == NULL) { if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */ /* first check to see if there's a map that covers the right region already */
GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d", GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",
src->curoffset, (int) readsize); src->curoffset, (int) readsize);
/* if the read buffer crosses a mmap region boundary, create a one-off region */ /* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d crosses a %d-byte boundary, creating a one-off", "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
src->curoffset, (int) readsize, (int) src->mapsize); src->curoffset, (int) readsize, (int) src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
/* otherwise we will create a new mmap region and set it to the default */ /* otherwise we will create a new mmap region and set it to the default */
} else { } else {
@ -548,29 +552,29 @@ gst_filesrc_get_mmap (GstFileSrc * src)
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
src->curoffset, readsize, nextmap, src->mapsize); src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */ /* first, we're done with the old mapbuf */
gst_buffer_unref (src->mapbuf); gst_buffer_unref (src->mapbuf);
mapsize = src->mapsize; mapsize = src->mapsize;
/* double the mapsize as long as the readsize is smaller */ /* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) { while (readsize - (src->curoffset - nextmap) > mapsize) {
GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d",
readsize, (int) mapsize); readsize, (int) mapsize);
mapsize <<= 1; mapsize <<= 1;
} }
/* create a new one */ /* create a new one */
src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize); src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize);
if (src->mapbuf == NULL) if (src->mapbuf == NULL)
return NULL; return NULL;
/* subbuffer it */ /* subbuffer it */
buf = buf =
gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap,
readsize); readsize);
GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (buf) =
GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
} }
} }
@ -598,7 +602,7 @@ gst_filesrc_get_read (GstFileSrc * src)
readsize = src->block_size; readsize = src->block_size;
if (src->curoffset + readsize > src->filelen) { if (src->curoffset + readsize > src->filelen) {
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| src->curoffset + readsize > src->filelen) { || src->curoffset + readsize > src->filelen) {
readsize = src->filelen - src->curoffset; readsize = src->filelen - src->curoffset;
} }
} }
@ -613,7 +617,7 @@ gst_filesrc_get_read (GstFileSrc * src)
} }
if (ret < readsize) { if (ret < readsize) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("unexpected end of file.")); ("unexpected end of file."));
return NULL; return NULL;
} }
@ -648,8 +652,8 @@ gst_filesrc_get (GstPad * pad)
src->seek_happened = FALSE; src->seek_happened = FALSE;
GST_DEBUG_OBJECT (src, "sending discont"); GST_DEBUG_OBJECT (src, "sending discont");
event = event =
gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
NULL); NULL);
return GST_DATA (event); return GST_DATA (event);
} }
@ -658,7 +662,7 @@ gst_filesrc_get (GstPad * pad)
if (src->curoffset == src->filelen) { if (src->curoffset == src->filelen) {
if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) { if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) {
GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
src->curoffset, src->filelen); src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }
@ -697,7 +701,7 @@ gst_filesrc_open_file (GstFileSrc * src)
if (src->filename == NULL || src->filename[0] == '\0') { if (src->filename == NULL || src->filename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
(_("No file name specified for reading.")), (NULL)); (_("No file name specified for reading.")), (NULL));
return FALSE; return FALSE;
} }
@ -711,8 +715,8 @@ gst_filesrc_open_file (GstFileSrc * src)
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL)); GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL));
else else
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open file \"%s\" for reading."), src->filename), (_("Could not open file \"%s\" for reading."), src->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} else { } else {
/* check if it is a regular file, otherwise bail out */ /* check if it is a regular file, otherwise bail out */
@ -722,7 +726,7 @@ gst_filesrc_open_file (GstFileSrc * src)
if (!S_ISREG (stat_results.st_mode)) { if (!S_ISREG (stat_results.st_mode)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("File \"%s\" isn't a regular file."), src->filename), (NULL)); (_("File \"%s\" isn't a regular file."), src->filename), (NULL));
close (src->fd); close (src->fd);
return FALSE; return FALSE;
} }
@ -780,13 +784,13 @@ gst_filesrc_change_state (GstElement * element)
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) {
if (!gst_filesrc_open_file (GST_FILESRC (element))) if (!gst_filesrc_open_file (GST_FILESRC (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN))
gst_filesrc_close_file (GST_FILESRC (element)); gst_filesrc_close_file (GST_FILESRC (element));
src->seek_happened = TRUE; src->seek_happened = TRUE;
break; break;
default: default:
@ -808,23 +812,23 @@ gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
switch (type) { switch (type) {
case GST_QUERY_TOTAL: case GST_QUERY_TOTAL:
if (*format != GST_FORMAT_BYTES) { if (*format != GST_FORMAT_BYTES) {
return FALSE; return FALSE;
} }
gst_filesrc_check_filesize (src); gst_filesrc_check_filesize (src);
*value = src->filelen; *value = src->filelen;
break; break;
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
*value = src->curoffset; *value = src->curoffset;
break; break;
case GST_FORMAT_PERCENT: case GST_FORMAT_PERCENT:
if (src->filelen == 0) if (src->filelen == 0)
return FALSE; return FALSE;
*value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
break; break;
default: default:
return FALSE; return FALSE;
} }
break; break;
default: default:
@ -847,44 +851,44 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
gint64 offset; gint64 offset;
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) { if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) {
goto error; goto error;
} }
offset = GST_EVENT_SEEK_OFFSET (event); offset = GST_EVENT_SEEK_OFFSET (event);
switch (GST_EVENT_SEEK_METHOD (event)) { switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET: case GST_SEEK_METHOD_SET:
if (offset > src->filelen && (!gst_filesrc_check_filesize (src) if (offset > src->filelen && (!gst_filesrc_check_filesize (src)
|| offset > src->filelen)) { || offset > src->filelen)) {
goto error; goto error;
} }
src->curoffset = offset; src->curoffset = offset;
GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
if (offset + src->curoffset > src->filelen) if (offset + src->curoffset > src->filelen)
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| offset + src->curoffset > src->filelen) || offset + src->curoffset > src->filelen)
goto error; goto error;
src->curoffset += offset; src->curoffset += offset;
GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
if (ABS (offset) > src->filelen) { if (ABS (offset) > src->filelen) {
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| ABS (offset) > src->filelen) || ABS (offset) > src->filelen)
goto error; goto error;
goto error; goto error;
} }
src->curoffset = src->filelen - ABS (offset); src->curoffset = src->filelen - ABS (offset);
GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
default: default:
goto error; goto error;
break; break;
} }
src->seek_happened = TRUE; src->seek_happened = TRUE;
src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
@ -892,7 +896,7 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
} }
case GST_EVENT_SIZE: case GST_EVENT_SIZE:
if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) { if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
goto error; goto error;
} }
src->block_size = GST_EVENT_SIZE_VALUE (event); src->block_size = GST_EVENT_SIZE_VALUE (event);
g_object_notify (G_OBJECT (src), "blocksize"); g_object_notify (G_OBJECT (src), "blocksize");
@ -923,6 +927,7 @@ static gchar **
gst_filesrc_uri_get_protocols (void) gst_filesrc_uri_get_protocols (void)
{ {
static gchar *protocols[] = { "file", NULL }; static gchar *protocols[] = { "file", NULL };
return protocols; return protocols;
} }
static const gchar * static const gchar *

View file

@ -94,31 +94,31 @@ gst_identity_class_init (GstIdentityClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
g_param_spec_boolean ("loop-based", "Loop-based", g_param_spec_boolean ("loop-based", "Loop-based",
"Set to TRUE to use loop-based rather than chain-based scheduling", "Set to TRUE to use loop-based rather than chain-based scheduling",
TRUE, G_PARAM_READWRITE)); TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME,
g_param_spec_uint ("sleep-time", "Sleep time", g_param_spec_uint ("sleep-time", "Sleep time",
"Microseconds to sleep between processing", 0, G_MAXUINT, 0, "Microseconds to sleep between processing", 0, G_MAXUINT, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE,
g_param_spec_uint ("duplicate", "Duplicate Buffers", g_param_spec_uint ("duplicate", "Duplicate Buffers",
"Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE)); "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
g_param_spec_int ("error_after", "Error After", "Error after N buffers", g_param_spec_int ("error_after", "Error After", "Error after N buffers",
G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
g_param_spec_float ("drop_probability", "Drop Probability", g_param_spec_float ("drop_probability", "Drop Probability",
"The Probability a buffer is dropped", 0.0, 1.0, 0.0, "The Probability a buffer is dropped", 0.0, 1.0, 0.0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", FALSE, g_param_spec_boolean ("silent", "silent", "silent", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "last-message", NULL, g_param_spec_string ("last-message", "last-message", "last-message", NULL,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE, g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gst_identity_signals[SIGNAL_HANDOFF] = gst_identity_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -173,7 +173,7 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (identity->error_after == 0) { if (identity->error_after == 0) {
gst_buffer_unref (buf); gst_buffer_unref (buf);
GST_ELEMENT_ERROR (identity, CORE, FAILED, GST_ELEMENT_ERROR (identity, CORE, FAILED,
(_("Failed after iterations as requested.")), (NULL)); (_("Failed after iterations as requested.")), (NULL));
return; return;
} }
} }
@ -181,12 +181,12 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (identity->drop_probability > 0.0) { if (identity->drop_probability > 0.0) {
if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) { if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
if (identity->last_message != NULL) { if (identity->last_message != NULL) {
g_free (identity->last_message); g_free (identity->last_message);
} }
identity->last_message = identity->last_message =
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message"); g_object_notify (G_OBJECT (identity), "last-message");
gst_buffer_unref (buf); gst_buffer_unref (buf);
return; return;
@ -200,14 +200,14 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (!identity->silent) { if (!identity->silent) {
g_free (identity->last_message); g_free (identity->last_message);
identity->last_message = identity->last_message =
g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message"); g_object_notify (G_OBJECT (identity), "last-message");
} }
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf); buf);
if (i > 1) if (i > 1)
gst_buffer_ref (buf); gst_buffer_ref (buf);
@ -259,12 +259,12 @@ gst_identity_set_property (GObject * object, guint prop_id,
case ARG_LOOP_BASED: case ARG_LOOP_BASED:
identity->loop_based = g_value_get_boolean (value); identity->loop_based = g_value_get_boolean (value);
if (identity->loop_based) { if (identity->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (identity), gst_element_set_loop_function (GST_ELEMENT (identity),
gst_identity_loop); gst_identity_loop);
gst_pad_set_chain_function (identity->sinkpad, NULL); gst_pad_set_chain_function (identity->sinkpad, NULL);
} else { } else {
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
gst_element_set_loop_function (GST_ELEMENT (identity), NULL); gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
} }
break; break;
case ARG_SLEEP_TIME: case ARG_SLEEP_TIME:

View file

@ -397,7 +397,7 @@ gst_md5sink_class_init (GstMD5SinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5,
g_param_spec_string ("md5", "md5", "current value of the md5 sum", g_param_spec_string ("md5", "md5", "current value of the md5 sum",
"", G_PARAM_READABLE)); "", G_PARAM_READABLE));
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state);
} }
@ -467,7 +467,7 @@ gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value,
guchar *md5string = g_malloc0 (33); guchar *md5string = g_malloc0 (33);
for (i = 0; i < 16; ++i) for (i = 0; i < 16; ++i)
sprintf (md5string + i * 2, "%02x", sink->md5[i]); sprintf (md5string + i * 2, "%02x", sink->md5[i]);
g_value_set_string (value, md5string); g_value_set_string (value, md5string);
g_free (md5string); g_free (md5string);
} }

View file

@ -105,7 +105,7 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property; gobject_class->get_property = gst_multifilesrc_get_property;
@ -149,11 +149,11 @@ gst_multifilesrc_set_property (GObject * object, guint prop_id,
/* clear the filename if we get a NULL */ /* clear the filename if we get a NULL */
if (g_value_get_pointer (value) == NULL) { if (g_value_get_pointer (value) == NULL) {
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->listptr = NULL; src->listptr = NULL;
/* otherwise set the new filenames */ /* otherwise set the new filenames */
} else { } else {
src->listptr = g_value_get_pointer (value); src->listptr = g_value_get_pointer (value);
} }
break; break;
default: default:
@ -244,7 +244,7 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
if (src->currentfilename == NULL || src->currentfilename[0] == '\0') { if (src->currentfilename == NULL || src->currentfilename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
(_("No file name specified for reading.")), (NULL)); (_("No file name specified for reading.")), (NULL));
return FALSE; return FALSE;
} }
@ -252,8 +252,8 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
src->fd = open ((const char *) src->currentfilename, O_RDONLY); src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) { if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open file \"%s\" for reading."), src->currentfilename), (_("Could not open file \"%s\" for reading."), src->currentfilename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} else { } else {
@ -267,7 +267,7 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
if (src->map == NULL) { if (src->map == NULL) {
close (src->fd); close (src->fd);
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
("mmap call failed.")); ("mmap call failed."));
return FALSE; return FALSE;
} }
GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN); GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN);

View file

@ -98,7 +98,7 @@ gst_pipefilter_class_init (GstPipefilterClass * klass)
gobject_class->set_property = gst_pipefilter_set_property; gobject_class->set_property = gst_pipefilter_set_property;
gobject_class->get_property = gst_pipefilter_get_property; gobject_class->get_property = gst_pipefilter_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_pipefilter_change_state; gstelement_class->change_state = gst_pipefilter_change_state;
} }
@ -134,9 +134,9 @@ gst_pipefilter_handle_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
if (close (pipefilter->fdin[1]) < 0) if (close (pipefilter->fdin[1]) < 0)
perror ("close"); perror ("close");
if (close (pipefilter->fdout[0]) < 0) if (close (pipefilter->fdout[0]) < 0)
perror ("close"); perror ("close");
break; break;
default: default:
break; break;
@ -279,8 +279,8 @@ gst_pipefilter_open_file (GstPipefilter * src)
close (src->fdin[1]); close (src->fdin[1]);
close (src->fdout[0]); close (src->fdout[0]);
/* child */ /* child */
dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */ dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */
dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
execvp (src->command[0], &src->command[0]); execvp (src->command[0], &src->command[0]);
/* will only be reached if execvp has an error */ /* will only be reached if execvp has an error */
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
@ -327,7 +327,7 @@ gst_pipefilter_change_state (GstElement * element)
} else { } else {
if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) {
if (!gst_pipefilter_open_file (GST_PIPEFILTER (element))) if (!gst_pipefilter_open_file (GST_PIPEFILTER (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
} }

View file

@ -58,7 +58,8 @@ typedef struct
GstPad *sinkpad; GstPad *sinkpad;
GstPad *srcpad; GstPad *srcpad;
GstBuffer *buffer; GstBuffer *buffer;
} GstShaperConnection; }
GstShaperConnection;
GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
GST_PAD_SRC, GST_PAD_SRC,
@ -80,9 +81,10 @@ gst_shaper_policy_get_type (void)
{SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!shaper_policy_type) { if (!shaper_policy_type) {
shaper_policy_type = shaper_policy_type =
g_enum_register_static ("GstShaperPolicy", shaper_policy); g_enum_register_static ("GstShaperPolicy", shaper_policy);
} }
return shaper_policy_type; return shaper_policy_type;
} }
@ -128,13 +130,13 @@ gst_shaper_class_init (GstShaperClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY,
g_param_spec_enum ("policy", "Policy", "Shaper policy", g_param_spec_enum ("policy", "Policy", "Shaper policy",
GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "last-message", g_param_spec_string ("last-message", "last-message", "last-message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property);
@ -279,30 +281,30 @@ gst_shaper_loop (GstElement * element)
/* events are simply pushed ASAP */ /* events are simply pushed ASAP */
if (GST_IS_EVENT (buffer)) { if (GST_IS_EVENT (buffer)) {
/* save event type as it will be unreffed after the next push */ /* save event type as it will be unreffed after the next push */
GstEventType type = GST_EVENT_TYPE (buffer); GstEventType type = GST_EVENT_TYPE (buffer);
gst_pad_push (connection->srcpad, GST_DATA (buffer)); gst_pad_push (connection->srcpad, GST_DATA (buffer));
switch (type) { switch (type) {
/* on EOS we disable the pad so that we don't pull on /* on EOS we disable the pad so that we don't pull on
* it again and never get more data */ * it again and never get more data */
case GST_EVENT_EOS: case GST_EVENT_EOS:
gst_pad_set_active (connection->sinkpad, FALSE); gst_pad_set_active (connection->sinkpad, FALSE);
break; break;
default: default:
break; break;
} }
} else { } else {
/* we store the buffer */ /* we store the buffer */
connection->buffer = buffer; connection->buffer = buffer;
} }
} }
/* FIXME policy stuff goes here */ /* FIXME policy stuff goes here */
/* find connection with lowest timestamp */ /* find connection with lowest timestamp */
if (min == NULL || (connection->buffer != NULL && if (min == NULL || (connection->buffer != NULL &&
(GST_BUFFER_TIMESTAMP (connection->buffer) < (GST_BUFFER_TIMESTAMP (connection->buffer) <
GST_BUFFER_TIMESTAMP (min->buffer)))) { GST_BUFFER_TIMESTAMP (min->buffer)))) {
min = connection; min = connection;
} }
connections = g_slist_next (connections); connections = g_slist_next (connections);

View file

@ -95,34 +95,34 @@ gst_statistics_class_init (GstStatisticsClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS,
g_param_spec_int64 ("buffers", "buffers", "total buffers count", g_param_spec_int64 ("buffers", "buffers", "total buffers count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES,
g_param_spec_int64 ("bytes", "bytes", "total bytes count", g_param_spec_int64 ("bytes", "bytes", "total bytes count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS,
g_param_spec_int64 ("events", "events", "total event count", g_param_spec_int64 ("events", "events", "total event count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq", ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq",
"buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0, "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq", ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq",
"bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0, "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq", ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq",
"event update freq", "event update frequency", 0, G_MAXINT64, 0, "event update freq", "event update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS,
g_param_spec_boolean ("update_on_eos", "update on EOS", g_param_spec_boolean ("update_on_eos", "update on EOS",
"update on EOS event", TRUE, G_PARAM_READWRITE)); "update on EOS event", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE,
g_param_spec_boolean ("update", "update", "update", TRUE, g_param_spec_boolean ("update", "update", "update", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", TRUE, g_param_spec_boolean ("silent", "silent", "silent", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gst_statistics_signals[SIGNAL_UPDATE] = gst_statistics_signals[SIGNAL_UPDATE] =
g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -253,14 +253,14 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
gst_element_set_eos (GST_ELEMENT (statistics)); gst_element_set_eos (GST_ELEMENT (statistics));
if (statistics->update_on_eos) { if (statistics->update_on_eos) {
update = TRUE; update = TRUE;
} }
} }
if (statistics->update_freq.events) { if (statistics->update_freq.events) {
statistics->update_count.events += 1; statistics->update_count.events += 1;
if (statistics->update_count.events == statistics->update_freq.events) { if (statistics->update_count.events == statistics->update_freq.events) {
statistics->update_count.events = 0; statistics->update_count.events = 0;
update = TRUE; update = TRUE;
} }
} }
} else { } else {
@ -268,8 +268,8 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update_freq.buffers) { if (statistics->update_freq.buffers) {
statistics->update_count.buffers += 1; statistics->update_count.buffers += 1;
if (statistics->update_count.buffers == statistics->update_freq.buffers) { if (statistics->update_count.buffers == statistics->update_freq.buffers) {
statistics->update_count.buffers = 0; statistics->update_count.buffers = 0;
update = TRUE; update = TRUE;
} }
} }
@ -277,8 +277,8 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update_freq.bytes) { if (statistics->update_freq.bytes) {
statistics->update_count.bytes += GST_BUFFER_SIZE (buf); statistics->update_count.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_count.bytes >= statistics->update_freq.bytes) { if (statistics->update_count.bytes >= statistics->update_freq.bytes) {
statistics->update_count.bytes = 0; statistics->update_count.bytes = 0;
update = TRUE; update = TRUE;
} }
} }
} }
@ -287,7 +287,7 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update) { if (statistics->update) {
GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics)); GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics));
g_signal_emit (G_OBJECT (statistics), g_signal_emit (G_OBJECT (statistics),
gst_statistics_signals[SIGNAL_UPDATE], 0); gst_statistics_signals[SIGNAL_UPDATE], 0);
GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics)); GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics));
} }
if (!statistics->silent) { if (!statistics->silent) {

View file

@ -95,13 +95,13 @@ gst_tee_class_init (GstTeeClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "num_pads", "num_pads", g_param_spec_int ("num_pads", "num_pads", "num_pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "last_message", "last_message", g_param_spec_string ("last_message", "last_message", "last_message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
@ -134,7 +134,7 @@ name_pad_compare (gconstpointer a, gconstpointer b)
g_assert (GST_IS_PAD (pad)); g_assert (GST_IS_PAD (pad));
return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
} }
static GstPad * static GstPad *
@ -163,7 +163,7 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
while (!name) { while (!name) {
name = g_strdup_printf ("src%d", i); name = g_strdup_printf ("src%d", i);
if (g_list_find_custom ((GList *) pads, (gconstpointer) name, if (g_list_find_custom ((GList *) pads, (gconstpointer) name,
name_pad_compare) != NULL) { name_pad_compare) != NULL) {
/* this name is taken, use the next one */ /* this name is taken, use the next one */
++i; ++i;
g_free (name); g_free (name);
@ -276,9 +276,9 @@ gst_tee_chain (GstPad * pad, GstData * _data)
if (!tee->silent) { if (!tee->silent) {
g_free (tee->last_message); g_free (tee->last_message);
tee->last_message = tee->last_message =
g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad), G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (tee), "last_message"); g_object_notify (G_OBJECT (tee), "last_message");
} }

View file

@ -83,8 +83,8 @@ enum
}; };
enum enum
{ {
MODE_NORMAL, /* act as identity */ MODE_NORMAL, /* act as identity */
MODE_TYPEFIND, /* do typefinding */ MODE_TYPEFIND, /* do typefinding */
}; };
@ -146,16 +146,16 @@ gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
g_object_class_install_property (gobject_class, ARG_CAPS, g_object_class_install_property (gobject_class, ARG_CAPS,
g_param_spec_boxed ("caps", _("caps"), g_param_spec_boxed ("caps", _("caps"),
_("detected capabilities in stream"), gst_caps_get_type (), _("detected capabilities in stream"), gst_caps_get_type (),
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MINIMUM, g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"), g_param_spec_uint ("minimum", _("minimum"),
"minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM, "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM,
GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE)); GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MINIMUM, g_object_class_install_property (gobject_class, ARG_MINIMUM,
g_param_spec_uint ("maximum", _("maximum"), g_param_spec_uint ("maximum", _("maximum"),
"probability to stop typefinding", GST_TYPE_FIND_MINIMUM, "probability to stop typefinding", GST_TYPE_FIND_MINIMUM,
GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE)); GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE));
gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type",
G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST, G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST,
@ -259,8 +259,8 @@ gst_type_find_element_src_event_mask (GstPad * pad)
{ {
static const GstEventMask mask[] = { static const GstEventMask mask[] = {
{GST_EVENT_SEEK, {GST_EVENT_SEEK,
GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH}, GST_SEEK_FLAG_FLUSH},
/* add more if you want, event masks suck and need to die anyway */ /* add more if you want, event masks suck and need to die anyway */
{0,} {0,}
}; };
@ -290,7 +290,8 @@ typedef struct
GList *buffers; GList *buffers;
GstTypeFindElement *self; GstTypeFindElement *self;
} TypeFindEntry; }
TypeFindEntry;
static inline TypeFindEntry * static inline TypeFindEntry *
new_entry (void) new_entry (void)
@ -336,7 +337,7 @@ stop_typefinding (GstTypeFindElement * typefind)
if (typefind->possibilities != NULL) { if (typefind->possibilities != NULL) {
/* this should only happen on PAUSED => READY or EOS */ /* this should only happen on PAUSED => READY or EOS */
GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions",
g_list_length (typefind->possibilities)); g_list_length (typefind->possibilities));
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL); g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities); g_list_free (typefind->possibilities);
typefind->possibilities = NULL; typefind->possibilities = NULL;
@ -349,7 +350,7 @@ stop_typefinding (GstTypeFindElement * typefind)
guint size = gst_buffer_store_get_size (typefind->store, 0); guint size = gst_buffer_store_get_size (typefind->store, 0);
if (size if (size
&& (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) { && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) {
GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size); GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size);
gst_pad_push (typefind->src, GST_DATA (buffer)); gst_pad_push (typefind->src, GST_DATA (buffer));
} else { } else {
@ -357,10 +358,10 @@ stop_typefinding (GstTypeFindElement * typefind)
} }
GST_LOG_OBJECT (typefind, "seeking back to current position %u", size); GST_LOG_OBJECT (typefind, "seeking back to current position %u", size);
if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink), if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink),
gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES,
size))) { size))) {
GST_WARNING_OBJECT (typefind, GST_WARNING_OBJECT (typefind,
"could not seek to required position %u, hope for the best", size); "could not seek to required position %u, hope for the best", size);
} }
} }
gst_buffer_store_clear (typefind->store); gst_buffer_store_clear (typefind->store);
@ -375,25 +376,25 @@ find_element_get_length (gpointer data)
if (!typefind->stream_length_available) { if (!typefind->stream_length_available) {
GST_LOG_OBJECT (entry->self, GST_LOG_OBJECT (entry->self,
"'%s' called get_length () but we know it's not available", "'%s' called get_length () but we know it's not available",
GST_PLUGIN_FEATURE_NAME (entry->factory)); GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0; return 0;
} }
if (entry->self->stream_length == 0) { if (entry->self->stream_length == 0) {
typefind->stream_length_available = typefind->stream_length_available =
gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL, gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
&format, &entry->self->stream_length); &format, &entry->self->stream_length);
if (format != GST_FORMAT_BYTES) if (format != GST_FORMAT_BYTES)
typefind->stream_length_available = FALSE; typefind->stream_length_available = FALSE;
if (!typefind->stream_length_available) { if (!typefind->stream_length_available) {
GST_DEBUG_OBJECT (entry->self, GST_DEBUG_OBJECT (entry->self,
"'%s' called get_length () but it's not available", "'%s' called get_length () but it's not available",
GST_PLUGIN_FEATURE_NAME (entry->factory)); GST_PLUGIN_FEATURE_NAME (entry->factory));
return 0; return 0;
} else { } else {
GST_DEBUG_OBJECT (entry->self, GST_DEBUG_OBJECT (entry->self,
"'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes", "'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length); GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
} }
} }
@ -409,23 +410,23 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
/* need to do more? */ /* need to do more? */
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
/* this should only happen when we got all available data */ /* this should only happen when we got all available data */
entry = entry =
(TypeFindEntry *) typefind->possibilities ? typefind-> (TypeFindEntry *) typefind->possibilities ? typefind->
possibilities->data : NULL; possibilities->data : NULL;
if (entry && entry->probability >= typefind->min_probability) { if (entry && entry->probability >= typefind->min_probability) {
GST_INFO_OBJECT (typefind, GST_INFO_OBJECT (typefind,
"'%s' is the best typefind left after we got all data, using it now (probability %u)", "'%s' is the best typefind left after we got all data, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
entry->probability, entry->caps); entry->probability, entry->caps);
} }
stop_typefinding (typefind); stop_typefinding (typefind);
gst_pad_event_default (pad, event); gst_pad_event_default (pad, event);
break; break;
default: default:
gst_data_unref (GST_DATA (event)); gst_data_unref (GST_DATA (event));
break; break;
} }
} else { } else {
gst_pad_event_default (pad, event); gst_pad_event_default (pad, event);
@ -449,8 +450,8 @@ find_peek (gpointer data, gint64 offset, guint size)
buf = NULL; buf = NULL;
} else { } else {
buf = buf =
gst_buffer_store_get_buffer (entry->self->store, length + offset, gst_buffer_store_get_buffer (entry->self->store, length + offset,
size); size);
} }
} }
@ -460,8 +461,8 @@ find_peek (gpointer data, gint64 offset, guint size)
} else { } else {
if (entry->requested_size == 0) { if (entry->requested_size == 0) {
GST_LOG_OBJECT (entry->self, GST_LOG_OBJECT (entry->self,
"setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset, "setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset,
size, GST_PLUGIN_FEATURE_NAME (entry->factory)); size, GST_PLUGIN_FEATURE_NAME (entry->factory));
entry->requested_offset = offset; entry->requested_offset = offset;
entry->requested_size = size; entry->requested_size = size;
} }
@ -521,160 +522,160 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data)); gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data));
current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ?
GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) :
gst_buffer_store_get_size (typefind->store, 0); gst_buffer_store_get_size (typefind->store, 0);
gst_data_unref (data); gst_data_unref (data);
if (typefind->possibilities == NULL) { if (typefind->possibilities == NULL) {
/* not yet started, get all typefinding functions into our "queue" */ /* not yet started, get all typefinding functions into our "queue" */
GList *all_factories = gst_type_find_factory_get_list (); GList *all_factories = gst_type_find_factory_get_list ();
GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", GST_INFO_OBJECT (typefind, "starting with %u typefinding functions",
g_list_length ((GList *) all_factories)); g_list_length ((GList *) all_factories));
all_factories = g_list_sort (all_factories, compare_type_find_factory); all_factories = g_list_sort (all_factories, compare_type_find_factory);
walk = all_factories; walk = all_factories;
while (all_factories) { while (all_factories) {
entry = new_entry (); entry = new_entry ();
entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data); entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data);
entry->self = typefind; entry->self = typefind;
entry->probability = 0; entry->probability = 0;
typefind->possibilities = typefind->possibilities =
g_list_prepend (typefind->possibilities, entry); g_list_prepend (typefind->possibilities, entry);
all_factories = g_list_next (all_factories); all_factories = g_list_next (all_factories);
} }
g_list_free (all_factories); g_list_free (all_factories);
} }
/* call every typefind function once */ /* call every typefind function once */
walk = entries = typefind->possibilities; walk = entries = typefind->possibilities;
GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", GST_INFO_OBJECT (typefind, "iterating %u typefinding functions",
g_list_length (entries)); g_list_length (entries));
typefind->possibilities = NULL; typefind->possibilities = NULL;
while (walk) { while (walk) {
find.data = entry = (TypeFindEntry *) walk->data; find.data = entry = (TypeFindEntry *) walk->data;
walk = g_list_next (walk); walk = g_list_next (walk);
entry->probability = 0; entry->probability = 0;
entry->requested_offset = 0; entry->requested_offset = 0;
entry->requested_size = 0; entry->requested_size = 0;
gst_type_find_factory_call_function (entry->factory, &find); gst_type_find_factory_call_function (entry->factory, &find);
free_entry_buffers (entry); free_entry_buffers (entry);
if (entry->probability == 0 && entry->requested_size == 0) { if (entry->probability == 0 && entry->requested_size == 0) {
GST_DEBUG_OBJECT (typefind, GST_DEBUG_OBJECT (typefind,
"'%s' was removed - no chance of being the right plugin", "'%s' was removed - no chance of being the right plugin",
GST_PLUGIN_FEATURE_NAME (entry->factory)); GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry); free_entry (entry);
} else if (entry->probability >= typefind->max_probability) { } else if (entry->probability >= typefind->max_probability) {
/* wooha, got caps */ /* wooha, got caps */
GstCaps *found_caps = entry->caps; GstCaps *found_caps = entry->caps;
guint probability = entry->probability; guint probability = entry->probability;
GST_INFO_OBJECT (typefind, GST_INFO_OBJECT (typefind,
"'%s' returned %u/%u probability, using it NOW", "'%s' returned %u/%u probability, using it NOW",
GST_PLUGIN_FEATURE_NAME (entry->factory), probability, GST_PLUGIN_FEATURE_NAME (entry->factory), probability,
typefind->max_probability); typefind->max_probability);
while (walk) { while (walk) {
free_entry ((TypeFindEntry *) walk->data); free_entry ((TypeFindEntry *) walk->data);
walk = g_list_next (walk); walk = g_list_next (walk);
} }
walk = typefind->possibilities; walk = typefind->possibilities;
while (walk) { while (walk) {
free_entry (walk->data); free_entry (walk->data);
walk = g_list_next (walk); walk = g_list_next (walk);
} }
typefind->possibilities = NULL; typefind->possibilities = NULL;
g_list_free (typefind->possibilities); g_list_free (typefind->possibilities);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0,
probability, found_caps); probability, found_caps);
free_entry (entry); free_entry (entry);
} else { } else {
typefind->possibilities = typefind->possibilities =
g_list_prepend (typefind->possibilities, entry); g_list_prepend (typefind->possibilities, entry);
} }
} }
g_list_free (entries); g_list_free (entries);
/* we may now already have caps or we might be left without functions to try */ /* we may now already have caps or we might be left without functions to try */
if (typefind->caps) { if (typefind->caps) {
stop_typefinding (typefind); stop_typefinding (typefind);
} else if (typefind->possibilities == NULL) { } else if (typefind->possibilities == NULL) {
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
} else { } else {
/* set up typefind element for next iteration */ /* set up typefind element for next iteration */
typefind->possibilities = typefind->possibilities =
g_list_sort (typefind->possibilities, compare_type_find_entry); g_list_sort (typefind->possibilities, compare_type_find_entry);
/* look for typefind functions that require data without seeking */ /* look for typefind functions that require data without seeking */
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) { for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data; entry = (TypeFindEntry *) walk->data;
if (entry->requested_offset <= current_offset && if (entry->requested_offset <= current_offset &&
entry->requested_offset + entry->requested_size > current_offset) entry->requested_offset + entry->requested_size > current_offset)
break; break;
} }
if (!walk) { if (!walk) {
/* find out if we should seek */ /* find out if we should seek */
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) { for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data; entry = (TypeFindEntry *) walk->data;
if (entry->requested_size > 0) { if (entry->requested_size > 0) {
/* FIXME: need heuristic to find out if we should seek */ /* FIXME: need heuristic to find out if we should seek */
gint64 seek_offset; gint64 seek_offset;
GstEvent *event; GstEvent *event;
seek_offset = seek_offset =
entry->requested_offset > entry->requested_offset >
0 ? entry-> 0 ? entry->
requested_offset : find_element_get_length (entry) + requested_offset : find_element_get_length (entry) +
entry->requested_offset; entry->requested_offset;
seek_offset += seek_offset +=
gst_buffer_store_get_size (typefind->store, seek_offset); gst_buffer_store_get_size (typefind->store, seek_offset);
event = event =
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET,
seek_offset); seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) { if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */ /* done seeking */
GST_DEBUG_OBJECT (typefind, GST_DEBUG_OBJECT (typefind,
"'%s' was reset - seeked to %" G_GINT64_FORMAT, "'%s' was reset - seeked to %" G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break; break;
} else if (entry->requested_offset < 0) { } else if (entry->requested_offset < 0) {
/* impossible to seek */ /* impossible to seek */
GST_DEBUG_OBJECT (typefind, GST_DEBUG_OBJECT (typefind,
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT, "'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0; entry->requested_size = 0;
entry->requested_offset = 0; entry->requested_offset = 0;
} }
} }
} }
} }
/* throw out all entries that can't get more data */ /* throw out all entries that can't get more data */
walk = g_list_next (typefind->possibilities); walk = g_list_next (typefind->possibilities);
while (walk) { while (walk) {
GList *cur = walk; GList *cur = walk;
entry = (TypeFindEntry *) walk->data; entry = (TypeFindEntry *) walk->data;
walk = g_list_next (walk); walk = g_list_next (walk);
if (entry->requested_size == 0) { if (entry->requested_size == 0) {
GST_DEBUG_OBJECT (typefind, GST_DEBUG_OBJECT (typefind,
"'%s' was removed - higher possibilities available", "'%s' was removed - higher possibilities available",
GST_PLUGIN_FEATURE_NAME (entry->factory)); GST_PLUGIN_FEATURE_NAME (entry->factory));
free_entry (entry); free_entry (entry);
typefind->possibilities = typefind->possibilities =
g_list_delete_link (typefind->possibilities, cur); g_list_delete_link (typefind->possibilities, cur);
} }
} }
if (g_list_next (typefind->possibilities) == NULL) { if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data; entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > typefind->min_probability) { if (entry->probability > typefind->min_probability) {
GST_INFO_OBJECT (typefind, GST_INFO_OBJECT (typefind,
"'%s' is the only typefind left, using it now (probability %u)", "'%s' is the only typefind left, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
0, entry->probability, entry->caps); 0, entry->probability, entry->caps);
free_entry (entry); free_entry (entry);
g_list_free (typefind->possibilities); g_list_free (typefind->possibilities);
typefind->possibilities = NULL; typefind->possibilities = NULL;
stop_typefinding (typefind); stop_typefinding (typefind);
} }
} }
} }
break; break;
} }

240
gst/gst.c
View file

@ -25,7 +25,7 @@
#include "gst_private.h" #include "gst_private.h"
#include "gst-i18n-lib.h" #include "gst-i18n-lib.h"
#include <locale.h> /* for LC_ALL */ #include <locale.h> /* for LC_ALL */
#include "gst.h" #include "gst.h"
#include "gstqueue.h" #include "gstqueue.h"
@ -114,55 +114,55 @@ enum
*/ */
static const GstPoptOption gstreamer_options[] = { static const GstPoptOption gstreamer_options[] = {
{NULL, NUL, POPT_ARG_CALLBACK | POPT_CBFLAG_PRE | POPT_CBFLAG_POST, {NULL, NUL, POPT_ARG_CALLBACK | POPT_CBFLAG_PRE | POPT_CBFLAG_POST,
(void *) &init_popt_callback, 0, NULL, NULL}, (void *) &init_popt_callback, 0, NULL, NULL},
/* make sure we use our GETTEXT_PACKAGE as the domain for popt translations */ /* make sure we use our GETTEXT_PACKAGE as the domain for popt translations */
{NULL, NUL, POPT_ARG_INTL_DOMAIN, GETTEXT_PACKAGE, 0, NULL, NULL}, {NULL, NUL, POPT_ARG_INTL_DOMAIN, GETTEXT_PACKAGE, 0, NULL, NULL},
{"gst-version", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, {"gst-version", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, ARG_VERSION,
N_("Print the GStreamer version"), NULL}, N_("Print the GStreamer version"), NULL},
{"gst-fatal-warnings", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-fatal-warnings", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL}, ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL},
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
{"gst-debug-help", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-debug-help", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL}, ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL},
{"gst-debug-level", NUL, POPT_ARG_INT | POPT_ARGFLAG_STRIP, NULL, {"gst-debug-level", NUL, POPT_ARG_INT | POPT_ARGFLAG_STRIP, NULL,
ARG_DEBUG_LEVEL, ARG_DEBUG_LEVEL,
N_ N_
("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"), ("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"),
N_("LEVEL")}, N_("LEVEL")},
{"gst-debug", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, {"gst-debug", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG,
N_ N_
("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), ("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"),
N_("LIST")}, N_("LIST")},
{"gst-debug-no-color", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-debug-no-color", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL}, ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL},
{"gst-debug-disable", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-debug-disable", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_DEBUG_DISABLE, N_("Disable debugging")}, ARG_DEBUG_DISABLE, N_("Disable debugging")},
#endif #endif
{"gst-disable-cpu-opt", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-disable-cpu-opt", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_DISABLE_CPU_OPT, N_("Disable accelerated CPU instructions"), NULL}, ARG_DISABLE_CPU_OPT, N_("Disable accelerated CPU instructions"), NULL},
{"gst-plugin-spew", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-plugin-spew", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL}, ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL},
{"gst-plugin-path", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, {"gst-plugin-path", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
ARG_PLUGIN_PATH, ARG_PLUGIN_PATH,
N_("path list for loading plugins (separated by '" N_("path list for loading plugins (separated by '"
G_SEARCHPATH_SEPARATOR_S "')"), N_("PATHS")}, G_SEARCHPATH_SEPARATOR_S "')"), N_("PATHS")},
{"gst-plugin-load", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, {"gst-plugin-load", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
ARG_PLUGIN_LOAD, ARG_PLUGIN_LOAD,
N_ N_
("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"), ("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"),
N_("PLUGINS")}, N_("PLUGINS")},
{"gst-disable-segtrap", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, {"gst-disable-segtrap", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL,
ARG_SEGTRAP_DISABLE, ARG_SEGTRAP_DISABLE,
N_("Disable trapping of segmentation faults during plugin loading"), N_("Disable trapping of segmentation faults during plugin loading"),
NULL}, NULL},
{"gst-scheduler", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, {"gst-scheduler", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
ARG_SCHEDULER, ARG_SCHEDULER,
N_("Scheduler to use ('" GST_SCHEDULER_DEFAULT_NAME N_("Scheduler to use ('" GST_SCHEDULER_DEFAULT_NAME
"' is the default)"), N_("SCHEDULER")}, "' is the default)"), N_("SCHEDULER")},
{"gst-registry", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, {"gst-registry", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL,
ARG_REGISTRY, N_("Registry to use"), N_("REGISTRY")}, ARG_REGISTRY, N_("Registry to use"), N_("REGISTRY")},
POPT_TABLEEND POPT_TABLEEND
}; };
@ -269,18 +269,18 @@ gst_init_check_with_popt_table (int *argc, char **argv[],
GstPoptOption *options; GstPoptOption *options;
GstPoptOption options_with[] = { GstPoptOption options_with[] = {
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:",
NULL}, NULL},
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0,
"GStreamer options:", NULL}, "GStreamer options:", NULL},
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0, {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0,
"Application options:", NULL}, "Application options:", NULL},
POPT_TABLEEND POPT_TABLEEND
}; };
GstPoptOption options_without[] = { GstPoptOption options_without[] = {
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:",
NULL}, NULL},
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0,
"GStreamer options:", NULL}, "GStreamer options:", NULL},
POPT_TABLEEND POPT_TABLEEND
}; };
@ -317,8 +317,8 @@ gst_init_check_with_popt_table (int *argc, char **argv[],
if (nextopt != -1) { if (nextopt != -1) {
g_print ("Error on option %s: %s.\nRun '%s --help' " g_print ("Error on option %s: %s.\nRun '%s --help' "
"to see a full list of available command line options.\n", "to see a full list of available command line options.\n",
poptBadOption (context, 0), poptStrerror (nextopt), (*argv)[0]); poptBadOption (context, 0), poptStrerror (nextopt), (*argv)[0]);
poptFreeContext (context); poptFreeContext (context);
return FALSE; return FALSE;
@ -368,9 +368,9 @@ parse_debug_list (const gchar * list)
g_strstrip (values[1]); g_strstrip (values[1]);
level = strtol (values[1], NULL, 0); level = strtol (values[1], NULL, 0);
if (level >= 0 && level < GST_LEVEL_COUNT) { if (level >= 0 && level < GST_LEVEL_COUNT) {
GST_DEBUG ("setting debugging to level %d for name \"%s\"", GST_DEBUG ("setting debugging to level %d for name \"%s\"",
level, values[0]); level, values[0]);
gst_debug_set_threshold_for_name (values[0], level); gst_debug_set_threshold_for_name (values[0], level);
} }
} }
g_strfreev (values); g_strfreev (values);
@ -415,10 +415,10 @@ split_and_iterate (const gchar * stringlist, gchar * separator, GFunc iterator,
while (strings[j]) { while (strings[j]) {
iterator (strings[j], user_data); iterator (strings[j], user_data);
if (++j == MAX_PATH_SPLIT) { if (++j == MAX_PATH_SPLIT) {
lastlist = g_strdup (strings[j]); lastlist = g_strdup (strings[j]);
g_strfreev (strings); g_strfreev (strings);
j = 0; j = 0;
break; break;
} }
} }
} }
@ -463,7 +463,7 @@ init_pre (void)
const gchar *homedir; const gchar *homedir;
_global_registry = _global_registry =
gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE); gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE);
#ifdef PLUGINS_USE_BUILDDIR #ifdef PLUGINS_USE_BUILDDIR
/* location libgstelements.so */ /* location libgstelements.so */
@ -472,7 +472,7 @@ init_pre (void)
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types");
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug");
gst_registry_add_path (_global_registry, gst_registry_add_path (_global_registry,
PLUGINS_BUILDDIR "/gst/schedulers"); PLUGINS_BUILDDIR "/gst/schedulers");
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers");
#else #else
/* add the main (installed) library path */ /* add the main (installed) library path */
@ -499,13 +499,13 @@ gst_register_core_elements (GstPlugin * plugin)
{ {
/* register some standard builtin types */ /* register some standard builtin types */
g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY, g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY,
GST_TYPE_BIN)); GST_TYPE_BIN));
g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY, g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY,
GST_TYPE_PIPELINE)); GST_TYPE_PIPELINE));
g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY, g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY,
GST_TYPE_THREAD)); GST_TYPE_THREAD));
g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY, g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY,
GST_TYPE_QUEUE)); GST_TYPE_QUEUE));
return TRUE; return TRUE;
} }
@ -593,7 +593,7 @@ init_post (void)
/* don't override command-line options */ /* don't override command-line options */
if (g_getenv ("GST_REGISTRY")) { if (g_getenv ("GST_REGISTRY")) {
g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"), g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"),
NULL); NULL);
_gst_registry_fixed = TRUE; _gst_registry_fixed = TRUE;
} }
} }
@ -655,12 +655,12 @@ gst_debug_help (void)
if (!gst_plugin_is_loaded (plugin)) { if (!gst_plugin_is_loaded (plugin)) {
#ifndef GST_DISABLE_REGISTRY #ifndef GST_DISABLE_REGISTRY
if (GST_IS_REGISTRY (plugin->manager)) { if (GST_IS_REGISTRY (plugin->manager)) {
GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s", GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s",
plugin->desc.name); plugin->desc.name);
if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager),
plugin) != GST_REGISTRY_OK) plugin) != GST_REGISTRY_OK)
GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed", GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed",
plugin->desc.name); plugin->desc.name);
} }
#endif /* GST_DISABLE_REGISTRY */ #endif /* GST_DISABLE_REGISTRY */
} }
@ -681,17 +681,17 @@ gst_debug_help (void)
gchar *color = gst_debug_construct_term_color (cat->color); gchar *color = gst_debug_construct_term_color (cat->color);
g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n", g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n",
color, color,
gst_debug_category_get_name (cat), gst_debug_category_get_name (cat),
gst_debug_category_get_threshold (cat), gst_debug_category_get_threshold (cat),
gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
color, gst_debug_category_get_description (cat)); color, gst_debug_category_get_description (cat));
g_free (color); g_free (color);
} else { } else {
g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat), g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat),
gst_debug_category_get_threshold (cat), gst_debug_category_get_threshold (cat),
gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), gst_debug_level_get_name (gst_debug_category_get_threshold (cat)),
gst_debug_category_get_description (cat)); gst_debug_category_get_description (cat));
} }
walk = g_slist_next (walk); walk = g_slist_next (walk);
} }
@ -711,75 +711,75 @@ init_popt_callback (poptContext context, enum poptCallbackReason reason,
switch (reason) { switch (reason) {
case POPT_CALLBACK_REASON_PRE: case POPT_CALLBACK_REASON_PRE:
if (!init_pre ()) if (!init_pre ())
_gst_initialization_failure = TRUE; _gst_initialization_failure = TRUE;
break; break;
case POPT_CALLBACK_REASON_OPTION: case POPT_CALLBACK_REASON_OPTION:
switch (option->val) { switch (option->val) {
case ARG_VERSION: case ARG_VERSION:
g_print ("GStreamer Core Library version %s\n", GST_VERSION); g_print ("GStreamer Core Library version %s\n", GST_VERSION);
exit (0); exit (0);
case ARG_FATAL_WARNINGS: case ARG_FATAL_WARNINGS:
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask); g_log_set_always_fatal (fatal_mask);
break; break;
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
case ARG_DEBUG_LEVEL:{ case ARG_DEBUG_LEVEL:{
gint tmp = 0; gint tmp = 0;
tmp = strtol (arg, NULL, 0); tmp = strtol (arg, NULL, 0);
if (tmp >= 0 && tmp < GST_LEVEL_COUNT) { if (tmp >= 0 && tmp < GST_LEVEL_COUNT) {
gst_debug_set_default_threshold (tmp); gst_debug_set_default_threshold (tmp);
} }
break; break;
} }
case ARG_DEBUG: case ARG_DEBUG:
parse_debug_list (arg); parse_debug_list (arg);
break; break;
case ARG_DEBUG_NO_COLOR: case ARG_DEBUG_NO_COLOR:
gst_debug_set_colored (FALSE); gst_debug_set_colored (FALSE);
break; break;
case ARG_DEBUG_DISABLE: case ARG_DEBUG_DISABLE:
gst_debug_set_active (FALSE); gst_debug_set_active (FALSE);
break; break;
case ARG_DEBUG_HELP: case ARG_DEBUG_HELP:
gst_debug_help (); gst_debug_help ();
exit (0); exit (0);
#endif #endif
case ARG_DISABLE_CPU_OPT: case ARG_DISABLE_CPU_OPT:
_gst_enable_cpu_opt = FALSE; _gst_enable_cpu_opt = FALSE;
break; break;
case ARG_PLUGIN_SPEW: case ARG_PLUGIN_SPEW:
break; break;
case ARG_PLUGIN_PATH: case ARG_PLUGIN_PATH:
#ifndef GST_DISABLE_REGISTRY #ifndef GST_DISABLE_REGISTRY
split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func, split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func,
_user_registry); _user_registry);
#endif /* GST_DISABLE_REGISTRY */ #endif /* GST_DISABLE_REGISTRY */
break; break;
case ARG_PLUGIN_LOAD: case ARG_PLUGIN_LOAD:
split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL); split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL);
break; break;
case ARG_SEGTRAP_DISABLE: case ARG_SEGTRAP_DISABLE:
_gst_disable_segtrap = TRUE; _gst_disable_segtrap = TRUE;
break; break;
case ARG_SCHEDULER: case ARG_SCHEDULER:
gst_scheduler_factory_set_default_name (arg); gst_scheduler_factory_set_default_name (arg);
break; break;
case ARG_REGISTRY: case ARG_REGISTRY:
#ifndef GST_DISABLE_REGISTRY #ifndef GST_DISABLE_REGISTRY
g_object_set (G_OBJECT (_user_registry), "location", arg, NULL); g_object_set (G_OBJECT (_user_registry), "location", arg, NULL);
_gst_registry_fixed = TRUE; _gst_registry_fixed = TRUE;
#endif /* GST_DISABLE_REGISTRY */ #endif /* GST_DISABLE_REGISTRY */
break; break;
default: default:
g_warning ("option %d not recognized", option->val); g_warning ("option %d not recognized", option->val);
break; break;
} }
break; break;
case POPT_CALLBACK_REASON_POST: case POPT_CALLBACK_REASON_POST:
if (!init_post ()) if (!init_post ())
_gst_initialization_failure = TRUE; _gst_initialization_failure = TRUE;
gst_initialized = TRUE; gst_initialized = TRUE;
break; break;
} }

View file

@ -107,7 +107,7 @@ gst_bin_get_type (void)
}; };
_gst_bin_type = _gst_bin_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0); g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
} }
return _gst_bin_type; return _gst_bin_type;
} }
@ -292,19 +292,19 @@ gst_bin_set_element_sched (GstElement * element, GstScheduler * sched)
if (GST_IS_BIN (element)) { if (GST_IS_BIN (element)) {
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) { if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
"child is already a manager, not resetting sched"); "child is already a manager, not resetting sched");
if (GST_ELEMENT_SCHED (element)) if (GST_ELEMENT_SCHED (element))
gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element)); gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element));
return; return;
} }
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
"setting child bin's scheduler to be the same as the parent's"); "setting child bin's scheduler to be the same as the parent's");
gst_scheduler_add_element (sched, element); gst_scheduler_add_element (sched, element);
/* set the children's schedule */ /* set the children's schedule */
g_list_foreach (GST_BIN (element)->children, g_list_foreach (GST_BIN (element)->children,
(GFunc) gst_bin_set_element_sched, sched); (GFunc) gst_bin_set_element_sched, sched);
} }
/* otherwise, if it's just a regular old element */ /* otherwise, if it's just a regular old element */
else { else {
@ -322,19 +322,19 @@ gst_bin_set_element_sched (GstElement * element, GstScheduler * sched)
/* we only operate on real pads */ /* we only operate on real pads */
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
/* if the peer element exists and is a candidate */ /* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
GST_CAT_LOG (GST_CAT_SCHEDULING, GST_CAT_LOG (GST_CAT_SCHEDULING,
"peer is in same scheduler, telling scheduler"); "peer is in same scheduler, telling scheduler");
if (GST_PAD_IS_SRC (pad)) if (GST_PAD_IS_SRC (pad))
gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad)); gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad));
else else
gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad); gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad);
} }
} }
} }
} }
@ -346,7 +346,7 @@ gst_bin_unset_element_sched (GstElement * element, GstScheduler * sched)
{ {
if (GST_ELEMENT_SCHED (element) == NULL) { if (GST_ELEMENT_SCHED (element) == NULL) {
GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler", GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
return; return;
} }
@ -359,15 +359,15 @@ gst_bin_unset_element_sched (GstElement * element, GstScheduler * sched)
if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) { if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element,
"child is already a manager, not unsetting sched"); "child is already a manager, not unsetting sched");
if (sched) { if (sched) {
gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element)); gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element));
} }
return; return;
} }
/* for each child, remove them from their schedule */ /* for each child, remove them from their schedule */
g_list_foreach (GST_BIN (element)->children, g_list_foreach (GST_BIN (element)->children,
(GFunc) gst_bin_unset_element_sched, sched); (GFunc) gst_bin_unset_element_sched, sched);
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element); gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
} }
@ -385,19 +385,19 @@ gst_bin_unset_element_sched (GstElement * element, GstScheduler * sched)
/* we only operate on real pads */ /* we only operate on real pads */
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
/* if the peer element exists and is a candidate */ /* if the peer element exists and is a candidate */
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) {
GST_CAT_LOG (GST_CAT_SCHEDULING, GST_CAT_LOG (GST_CAT_SCHEDULING,
"peer is in same scheduler, telling scheduler"); "peer is in same scheduler, telling scheduler");
if (GST_PAD_IS_SRC (pad)) if (GST_PAD_IS_SRC (pad))
gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad)); gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad));
else else
gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad); gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad);
} }
} }
} }
gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element); gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element);
@ -444,9 +444,9 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
/* then check to see if the element's name is already taken in the bin */ /* then check to see if the element's name is already taken in the bin */
if (gst_object_check_uniqueness (bin->children, if (gst_object_check_uniqueness (bin->children,
GST_ELEMENT_NAME (element)) == FALSE) { GST_ELEMENT_NAME (element)) == FALSE) {
g_warning ("Name %s is not unique in bin %s, not adding\n", g_warning ("Name %s is not unique in bin %s, not adding\n",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)); GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin));
return; return;
} }
@ -501,8 +501,8 @@ gst_bin_add (GstBin * bin, GstElement * element)
bclass->add_element (bin, element); bclass->add_element (bin, element);
} else { } else {
GST_ELEMENT_ERROR (bin, CORE, FAILED, (NULL), GST_ELEMENT_ERROR (bin, CORE, FAILED, (NULL),
("cannot add element %s to bin %s", ("cannot add element %s to bin %s",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin))); GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)));
} }
} }
@ -518,7 +518,7 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
/* the element must be in the bin's list of children */ /* the element must be in the bin's list of children */
if (g_list_find (bin->children, element) == NULL) { if (g_list_find (bin->children, element) == NULL) {
g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element), g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element),
GST_ELEMENT_NAME (bin)); GST_ELEMENT_NAME (bin));
return; return;
} }
@ -642,7 +642,7 @@ gst_bin_child_state_change (GstBin * bin, GstElementState oldstate,
bclass->child_state_change (bin, oldstate, newstate, child); bclass->child_state_change (bin, oldstate, newstate, child);
} else { } else {
g_warning ("cannot signal state change of child %s to bin %s\n", g_warning ("cannot signal state change of child %s to bin %s\n",
GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin)); GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin));
} }
} }
@ -666,17 +666,17 @@ gst_bin_child_state_change_func (GstBin * bin, GstElementState oldstate,
gint state = (1 << i); gint state = (1 << i);
if (GST_STATE (bin) != state) { if (GST_STATE (bin) != state) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin,
"highest child state is %s, changing bin state accordingly", "highest child state is %s, changing bin state accordingly",
gst_element_state_get_name (state)); gst_element_state_get_name (state));
GST_STATE_PENDING (bin) = state; GST_STATE_PENDING (bin) = state;
GST_UNLOCK (bin); GST_UNLOCK (bin);
gst_bin_change_state_norecurse (bin); gst_bin_change_state_norecurse (bin);
if (state != GST_STATE (bin)) { if (state != GST_STATE (bin)) {
g_warning ("%s: state change in callback %d %d", g_warning ("%s: state change in callback %d %d",
GST_ELEMENT_NAME (bin), state, GST_STATE (bin)); GST_ELEMENT_NAME (bin), state, GST_STATE (bin));
} }
return; return;
} }
break; break;
} }
@ -713,8 +713,8 @@ gst_bin_change_state (GstElement * element)
if (old_state == pending) { if (old_state == pending) {
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
"old and pending state are both %s, returning", "old and pending state are both %s, returning",
gst_element_state_get_name (pending)); gst_element_state_get_name (pending));
return GST_STATE_SUCCESS; return GST_STATE_SUCCESS;
} }
@ -732,38 +732,38 @@ gst_bin_change_state (GstElement * element)
old_child_state = GST_STATE (child); old_child_state = GST_STATE (child);
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"changing state of child %s from current %s to pending %s", "changing state of child %s from current %s to pending %s",
GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state), GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state),
gst_element_state_get_name (pending)); gst_element_state_get_name (pending));
switch (gst_element_set_state (child, pending)) { switch (gst_element_set_state (child, pending)) {
case GST_STATE_FAILURE: case GST_STATE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' failed to go to state %d(%s)", "child '%s' failed to go to state %d(%s)",
GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (child),
pending, gst_element_state_get_name (pending)); pending, gst_element_state_get_name (pending));
gst_element_set_state (child, old_child_state); gst_element_set_state (child, old_child_state);
/* There was a check for elements being in the same scheduling group /* There was a check for elements being in the same scheduling group
here. Removed by dolphy <julien@moutte.net>. No matter the here. Removed by dolphy <julien@moutte.net>. No matter the
scheduling group we should always return a failure. This change scheduling group we should always return a failure. This change
seems to work on my machine and fixes tons of issues. If anyone seems to work on my machine and fixes tons of issues. If anyone
want to revert please tell me what it breaks first, Thanks. */ want to revert please tell me what it breaks first, Thanks. */
GST_STATE_PENDING (element) = old_state; GST_STATE_PENDING (element) = old_state;
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
break; break;
case GST_STATE_ASYNC: case GST_STATE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"child '%s' is changing state asynchronously", "child '%s' is changing state asynchronously",
GST_ELEMENT_NAME (child)); GST_ELEMENT_NAME (child));
have_async = TRUE; have_async = TRUE;
break; break;
case GST_STATE_SUCCESS: case GST_STATE_SUCCESS:
GST_CAT_DEBUG (GST_CAT_STATES, GST_CAT_DEBUG (GST_CAT_STATES,
"child '%s' changed state to %d(%s) successfully", "child '%s' changed state to %d(%s) successfully",
GST_ELEMENT_NAME (child), pending, GST_ELEMENT_NAME (child), pending,
gst_element_state_get_name (pending)); gst_element_state_get_name (pending));
break; break;
} }
} }
@ -858,7 +858,7 @@ gst_bin_get_by_name (GstBin * bin, const gchar * name)
GstElement *res = gst_bin_get_by_name (GST_BIN (child), name); GstElement *res = gst_bin_get_by_name (GST_BIN (child), name);
if (res) if (res)
return res; return res;
} }
children = g_list_next (children); children = g_list_next (children);
} }
@ -945,7 +945,7 @@ gst_bin_get_by_interface (GstBin * bin, GType interface)
ret = gst_bin_get_by_interface (GST_BIN (walk->data), interface); ret = gst_bin_get_by_interface (GST_BIN (walk->data), interface);
if (ret) if (ret)
return ret; return ret;
} }
walk = g_list_next (walk); walk = g_list_next (walk);
} }
@ -979,7 +979,7 @@ gst_bin_get_all_by_interface (GstBin * bin, GType interface)
ret = g_list_prepend (ret, walk->data); ret = g_list_prepend (ret, walk->data);
if (GST_IS_BIN (walk->data)) { if (GST_IS_BIN (walk->data)) {
ret = g_list_concat (ret, ret = g_list_concat (ret,
gst_bin_get_all_by_interface (GST_BIN (walk->data), interface)); gst_bin_get_all_by_interface (GST_BIN (walk->data), interface));
} }
walk = g_list_next (walk); walk = g_list_next (walk);
} }
@ -1020,17 +1020,17 @@ gst_bin_sync_children_state (GstBin * bin)
children = children->next; children = children->next;
if (GST_STATE (element) != state) { if (GST_STATE (element) != state) {
switch (gst_element_set_state (element, state)) { switch (gst_element_set_state (element, state)) {
case GST_STATE_SUCCESS: case GST_STATE_SUCCESS:
break; break;
case GST_STATE_ASYNC: case GST_STATE_ASYNC:
if (ret == GST_STATE_SUCCESS) if (ret == GST_STATE_SUCCESS)
ret = GST_STATE_ASYNC; ret = GST_STATE_ASYNC;
break; break;
case GST_STATE_FAILURE: case GST_STATE_FAILURE:
ret = GST_STATE_FAILURE; ret = GST_STATE_FAILURE;
default: default:
/* make sure gst_element_set_state never returns this */ /* make sure gst_element_set_state never returns this */
g_assert_not_reached (); g_assert_not_reached ();
} }
} }
} }
@ -1075,21 +1075,21 @@ gst_bin_restore_thyself (GstObject * object, xmlNodePtr self)
while (field) { while (field) {
if (!strcmp (field->name, "children")) { if (!strcmp (field->name, "children")) {
GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children", GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children",
GST_ELEMENT_NAME (object)); GST_ELEMENT_NAME (object));
childlist = field->xmlChildrenNode; childlist = field->xmlChildrenNode;
while (childlist) { while (childlist) {
if (!strcmp (childlist->name, "element")) { if (!strcmp (childlist->name, "element")) {
GstElement *element = GstElement *element =
gst_xml_make_element (childlist, GST_OBJECT (bin)); gst_xml_make_element (childlist, GST_OBJECT (bin));
/* it had to be parented to find the pads, now we ref and unparent so /* it had to be parented to find the pads, now we ref and unparent so
* we can add it to the bin */ * we can add it to the bin */
gst_object_ref (GST_OBJECT (element)); gst_object_ref (GST_OBJECT (element));
gst_object_unparent (GST_OBJECT (element)); gst_object_unparent (GST_OBJECT (element));
gst_bin_add (bin, element); gst_bin_add (bin, element);
} }
childlist = childlist->next; childlist = childlist->next;
} }
} }
@ -1115,7 +1115,7 @@ gst_bin_iterate_func (GstBin * bin)
} }
} else { } else {
g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n", g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n",
GST_ELEMENT_NAME (bin)); GST_ELEMENT_NAME (bin));
} }
return FALSE; return FALSE;
@ -1149,10 +1149,10 @@ gst_bin_iterate (GstBin * bin)
if (!running) { if (!running) {
if (GST_STATE (bin) == GST_STATE_PLAYING && if (GST_STATE (bin) == GST_STATE_PLAYING &&
GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) { GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) {
GST_CAT_DEBUG (GST_CAT_DATAFLOW, GST_CAT_DEBUG (GST_CAT_DATAFLOW,
"[%s]: polling for child shutdown after useless iteration", "[%s]: polling for child shutdown after useless iteration",
GST_ELEMENT_NAME (bin)); GST_ELEMENT_NAME (bin));
g_usleep (1); g_usleep (1);
running = TRUE; running = TRUE;
} }

View file

@ -397,10 +397,10 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
/* we simply create a subbuffer of the common parent */ /* we simply create a subbuffer of the common parent */
newbuf = gst_buffer_create_sub (parent, newbuf = gst_buffer_create_sub (parent,
buf1->data - parent->data + offset, len); buf1->data - parent->data + offset, len);
} else { } else {
GST_CAT_DEBUG (GST_CAT_BUFFER, GST_CAT_DEBUG (GST_CAT_BUFFER,
"slow path taken while spanning buffers %p and %p", buf1, buf2); "slow path taken while spanning buffers %p and %p", buf1, buf2);
/* otherwise we simply have to brute-force copy the buffers */ /* otherwise we simply have to brute-force copy the buffers */
newbuf = gst_buffer_new_and_alloc (len); newbuf = gst_buffer_new_and_alloc (len);
@ -408,7 +408,7 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
memcpy (newbuf->data, buf1->data + offset, buf1->size - offset); memcpy (newbuf->data, buf1->data + offset, buf1->size - offset);
/* copy the second buffer's data across */ /* copy the second buffer's data across */
memcpy (newbuf->data + (buf1->size - offset), buf2->data, memcpy (newbuf->data + (buf1->size - offset), buf2->data,
len - (buf1->size - offset)); len - (buf1->size - offset));
/* if the offset is 0, the new buffer has the same timestamp as buf1 */ /* if the offset is 0, the new buffer has the same timestamp as buf1 */
if (offset == 0) { if (offset == 0) {
GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1); GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1);
@ -420,10 +420,10 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
* invalid DURATIONS */ * invalid DURATIONS */
if (offset == 0 && buf1->size + buf2->size == len) { if (offset == 0 && buf1->size + buf2->size == len) {
if (GST_BUFFER_DURATION_IS_VALID (buf1) && if (GST_BUFFER_DURATION_IS_VALID (buf1) &&
GST_BUFFER_DURATION_IS_VALID (buf2)) { GST_BUFFER_DURATION_IS_VALID (buf2)) {
/* add duration */ /* add duration */
GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) +
GST_BUFFER_DURATION (buf2); GST_BUFFER_DURATION (buf2);
} }
if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) { if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) {
/* add offset_end */ /* add offset_end */

View file

@ -53,11 +53,11 @@ gst_caps_get_type (void)
if (!gst_caps_type) { if (!gst_caps_type) {
gst_caps_type = g_boxed_type_register_static ("GstCaps", gst_caps_type = g_boxed_type_register_static ("GstCaps",
(GBoxedCopyFunc) gst_caps_copy_conditional, (GBoxedCopyFunc) gst_caps_copy_conditional,
(GBoxedFreeFunc) gst_caps_free); (GBoxedFreeFunc) gst_caps_free);
g_value_register_transform_func (gst_caps_type, g_value_register_transform_func (gst_caps_type,
G_TYPE_STRING, gst_caps_transform_to_string); G_TYPE_STRING, gst_caps_transform_to_string);
} }
return gst_caps_type; return gst_caps_type;
@ -680,7 +680,8 @@ typedef struct
GstStructure *dest; GstStructure *dest;
const GstStructure *intersect; const GstStructure *intersect;
gboolean first_run; gboolean first_run;
} IntersectData; }
IntersectData;
static gboolean static gboolean
gst_caps_structure_intersect_field (GQuark id, GValue * val1, gpointer data) gst_caps_structure_intersect_field (GQuark id, GValue * val1, gpointer data)
@ -719,13 +720,13 @@ gst_caps_structure_intersect (const GstStructure * struct1,
data.intersect = struct2; data.intersect = struct2;
data.first_run = TRUE; data.first_run = TRUE;
if (!gst_structure_foreach ((GstStructure *) struct1, if (!gst_structure_foreach ((GstStructure *) struct1,
gst_caps_structure_intersect_field, &data)) gst_caps_structure_intersect_field, &data))
goto error; goto error;
data.intersect = struct1; data.intersect = struct1;
data.first_run = FALSE; data.first_run = FALSE;
if (!gst_structure_foreach ((GstStructure *) struct2, if (!gst_structure_foreach ((GstStructure *) struct2,
gst_caps_structure_intersect_field, &data)) gst_caps_structure_intersect_field, &data))
goto error; goto error;
return data.dest; return data.dest;
@ -763,10 +764,10 @@ gst_caps_structure_union (const GstStructure * struct1,
continue; continue;
} else { } else {
if (gst_value_union (&dest_value, &field1->value, &field2->value)) { if (gst_value_union (&dest_value, &field1->value, &field2->value)) {
gst_structure_set_value (dest, g_quark_to_string (field1->name), gst_structure_set_value (dest, g_quark_to_string (field1->name),
&dest_value); &dest_value);
} else { } else {
ret = gst_value_compare (&field1->value, &field2->value); ret = gst_value_compare (&field1->value, &field2->value);
} }
} }
} }
@ -862,7 +863,8 @@ typedef struct _NormalizeForeach
{ {
GstCaps *caps; GstCaps *caps;
GstStructure *structure; GstStructure *structure;
} NormalizeForeach; }
NormalizeForeach;
static gboolean static gboolean
gst_caps_normalize_foreach (GQuark field_id, GValue * value, gpointer ptr) gst_caps_normalize_foreach (GQuark field_id, GValue * value, gpointer ptr)
@ -915,7 +917,7 @@ gst_caps_normalize (const GstCaps * caps)
nf.structure = gst_caps_get_structure (newcaps, i); nf.structure = gst_caps_get_structure (newcaps, i);
while (!gst_structure_foreach (nf.structure, while (!gst_structure_foreach (nf.structure,
gst_caps_normalize_foreach, &nf)); gst_caps_normalize_foreach, &nf));
} }
return newcaps; return newcaps;
@ -982,7 +984,7 @@ gst_caps_simplify (const GstCaps * caps)
for (j = 0; j < gst_caps_get_size (newcaps); j++) { for (j = 0; j < gst_caps_get_size (newcaps); j++) {
struct2 = gst_caps_get_structure (caps, i); struct2 = gst_caps_get_structure (caps, i);
if (gst_caps_structure_simplify (struct2, structure)) { if (gst_caps_structure_simplify (struct2, structure)) {
break; break;
} }
} }
if (j == gst_caps_get_size (newcaps)) { if (j == gst_caps_get_size (newcaps)) {
@ -1023,7 +1025,7 @@ gst_caps_load_thyself (xmlNodePtr parent)
void void
gst_caps_replace (GstCaps ** caps, GstCaps * newcaps) gst_caps_replace (GstCaps ** caps, GstCaps * newcaps)
{ {
#if 0 /* disable this, since too many plugins rely on undefined behavior */ #if 0 /* disable this, since too many plugins rely on undefined behavior */
#ifdef USE_POISONING #ifdef USE_POISONING
//if (newcaps) CAPS_POISON (newcaps); //if (newcaps) CAPS_POISON (newcaps);
#endif #endif
@ -1203,12 +1205,12 @@ gst_caps_structure_fixate_field_nearest_int (GstStructure * structure,
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
list_value = gst_value_list_get_value (value, i); list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_INT) { if (G_VALUE_TYPE (list_value) == G_TYPE_INT) {
int x = g_value_get_int (list_value); int x = g_value_get_int (list_value);
if (best_index == -1 || (ABS (target - x) < ABS (best - x))) { if (best_index == -1 || (ABS (target - x) < ABS (best - x))) {
best_index = i; best_index = i;
best = x; best = x;
} }
} }
} }
if (best_index != -1) { if (best_index != -1) {
@ -1255,12 +1257,12 @@ gst_caps_structure_fixate_field_nearest_double (GstStructure * structure,
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
list_value = gst_value_list_get_value (value, i); list_value = gst_value_list_get_value (value, i);
if (G_VALUE_TYPE (list_value) == G_TYPE_DOUBLE) { if (G_VALUE_TYPE (list_value) == G_TYPE_DOUBLE) {
double x = g_value_get_double (list_value); double x = g_value_get_double (list_value);
if (best_index == -1 || (ABS (target - x) < ABS (best - x))) { if (best_index == -1 || (ABS (target - x) < ABS (best - x))) {
best_index = i; best_index = i;
best = x; best = x;
} }
} }
} }
if (best_index != -1) { if (best_index != -1) {

View file

@ -346,8 +346,9 @@ gst_clock_get_type (void)
(GInstanceInitFunc) gst_clock_init, (GInstanceInitFunc) gst_clock_init,
NULL NULL
}; };
clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock", clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock",
&clock_info, G_TYPE_FLAG_ABSTRACT); &clock_info, G_TYPE_FLAG_ABSTRACT);
} }
return clock_type; return clock_type;
} }
@ -380,16 +381,16 @@ gst_clock_class_init (GstClockClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATS,
g_param_spec_boolean ("stats", "Stats", "Enable clock stats", g_param_spec_boolean ("stats", "Stats", "Enable clock stats",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DIFF, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DIFF,
g_param_spec_int64 ("max-diff", "Max diff", g_param_spec_int64 ("max-diff", "Max diff",
"The maximum amount of time to wait in nanoseconds", 0, G_MAXINT64, "The maximum amount of time to wait in nanoseconds", 0, G_MAXINT64,
DEFAULT_MAX_DIFF, G_PARAM_READWRITE)); DEFAULT_MAX_DIFF, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_DIFF, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_DIFF,
g_param_spec_uint64 ("event-diff", "event diff", g_param_spec_uint64 ("event-diff", "event diff",
"The amount of time that may elapse until 2 events are treated as happening at different times", "The amount of time that may elapse until 2 events are treated as happening at different times",
0, G_MAXUINT64, DEFAULT_EVENT_DIFF, 0, G_MAXUINT64, DEFAULT_EVENT_DIFF,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
} }
static void static void
@ -475,7 +476,7 @@ gst_clock_set_resolution (GstClock * clock, guint64 resolution)
if (cclass->change_resolution) if (cclass->change_resolution)
clock->resolution = clock->resolution =
cclass->change_resolution (clock, clock->resolution, resolution); cclass->change_resolution (clock, clock->resolution, resolution);
return clock->resolution; return clock->resolution;
} }
@ -642,10 +643,10 @@ gst_clock_get_event_time (GstClock * clock)
if (clock->last_event + clock->max_event_diff >= time) { if (clock->last_event + clock->max_event_diff >= time) {
GST_LOG_OBJECT (clock, "reporting last event time %" G_GUINT64_FORMAT, GST_LOG_OBJECT (clock, "reporting last event time %" G_GUINT64_FORMAT,
clock->last_event); clock->last_event);
} else { } else {
GST_LOG_OBJECT (clock, "reporting new event time %" G_GUINT64_FORMAT, GST_LOG_OBJECT (clock, "reporting new event time %" G_GUINT64_FORMAT,
clock->last_event); clock->last_event);
clock->last_event = time; clock->last_event = time;
} }

View file

@ -94,12 +94,12 @@ _gst_cpu_initialize_i386 (gulong * flags, GString * featurelist)
gst_cpuid_i386 (0x80000001, &eax, &ebx, &ecx, &edx); gst_cpuid_i386 (0x80000001, &eax, &ebx, &ecx, &edx);
if (edx & (1 << 31)) { if (edx & (1 << 31)) {
_gst_cpu_flags |= GST_CPU_FLAG_3DNOW; _gst_cpu_flags |= GST_CPU_FLAG_3DNOW;
g_string_append (featurelist, "3DNOW "); g_string_append (featurelist, "3DNOW ");
} }
if (AMD && (edx & (1 << 22))) { if (AMD && (edx & (1 << 22))) {
_gst_cpu_flags |= GST_CPU_FLAG_MMXEXT; _gst_cpu_flags |= GST_CPU_FLAG_MMXEXT;
g_string_append (featurelist, "MMXEXT "); g_string_append (featurelist, "MMXEXT ");
} }
} }
} }

View file

@ -34,7 +34,7 @@ gst_data_get_type (void)
if (!type) if (!type)
type = g_boxed_type_register_static ("GstData", type = g_boxed_type_register_static ("GstData",
(GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref); (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref);
return type; return type;
} }

View file

@ -103,8 +103,9 @@ gst_element_get_type (void)
(GInstanceInitFunc) gst_element_init, (GInstanceInitFunc) gst_element_init,
NULL NULL
}; };
_gst_element_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement", _gst_element_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement",
&element_info, G_TYPE_FLAG_ABSTRACT); &element_info, G_TYPE_FLAG_ABSTRACT);
} }
return _gst_element_type; return _gst_element_type;
} }
@ -260,7 +261,8 @@ typedef struct
{ {
const GParamSpec *pspec; const GParamSpec *pspec;
GValue value; GValue value;
} prop_value_t; }
prop_value_t;
static void static void
element_set_property (GstElement * element, const GParamSpec * pspec, element_set_property (GstElement * element, const GParamSpec * pspec,
@ -352,7 +354,7 @@ gst_element_set_pending_properties (GstElement * element)
while ((prop_value = g_async_queue_try_pop (element->prop_value_queue))) { while ((prop_value = g_async_queue_try_pop (element->prop_value_queue))) {
g_object_set_property ((GObject *) element, prop_value->pspec->name, g_object_set_property ((GObject *) element, prop_value->pspec->name,
&prop_value->value); &prop_value->value);
g_value_unset (&prop_value->value); g_value_unset (&prop_value->value);
g_free (prop_value); g_free (prop_value);
} }
@ -446,12 +448,12 @@ gst_element_set_valist (GstElement * element, const gchar * first_property_name,
if (!pspec) { if (!pspec) {
g_warning ("%s: object class `%s' has no property named `%s'", g_warning ("%s: object class `%s' has no property named `%s'",
G_STRLOC, G_OBJECT_TYPE_NAME (object), name); G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
break; break;
} }
if (!(pspec->flags & G_PARAM_WRITABLE)) { if (!(pspec->flags & G_PARAM_WRITABLE)) {
g_warning ("%s: property `%s' of object class `%s' is not writable", g_warning ("%s: property `%s' of object class `%s' is not writable",
G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object)); G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
break; break;
} }
@ -515,12 +517,12 @@ gst_element_get_valist (GstElement * element, const gchar * first_property_name,
if (!pspec) { if (!pspec) {
g_warning ("%s: object class `%s' has no property named `%s'", g_warning ("%s: object class `%s' has no property named `%s'",
G_STRLOC, G_OBJECT_TYPE_NAME (object), name); G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
break; break;
} }
if (!(pspec->flags & G_PARAM_READABLE)) { if (!(pspec->flags & G_PARAM_READABLE)) {
g_warning ("%s: property `%s' of object class `%s' is not readable", g_warning ("%s: property `%s' of object class `%s' is not readable",
G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object)); G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
break; break;
} }
@ -580,7 +582,7 @@ gst_element_set_property (GstElement * element, const gchar * property_name,
if (!pspec) if (!pspec)
g_warning ("%s: object class `%s' has no property named `%s'", g_warning ("%s: object class `%s' has no property named `%s'",
G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name); G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name);
else else
element_set_property (element, pspec, value); element_set_property (element, pspec, value);
@ -621,7 +623,7 @@ gst_element_get_property (GstElement * element, const gchar * property_name,
if (!pspec) if (!pspec)
g_warning ("%s: object class `%s' has no property named `%s'", g_warning ("%s: object class `%s' has no property named `%s'",
G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name); G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name);
else { else {
GValue *prop_value, tmp_value = { 0, }; GValue *prop_value, tmp_value = { 0, };
@ -631,11 +633,11 @@ gst_element_get_property (GstElement * element, const gchar * property_name,
g_value_reset (value); g_value_reset (value);
prop_value = value; prop_value = value;
} else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), } else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec),
G_VALUE_TYPE (value))) { G_VALUE_TYPE (value))) {
g_warning g_warning
("can't retrieve property `%s' of type `%s' as value of type `%s'", ("can't retrieve property `%s' of type `%s' as value of type `%s'",
pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
g_object_unref (object); g_object_unref (object);
return; return;
} else { } else {
@ -787,8 +789,8 @@ gst_element_clock_wait (GstElement * element, GstClockID id,
if (GST_ELEMENT_SCHED (element)) { if (GST_ELEMENT_SCHED (element)) {
GST_CAT_DEBUG (GST_CAT_CLOCK, "waiting on scheduler clock"); GST_CAT_DEBUG (GST_CAT_CLOCK, "waiting on scheduler clock");
res = res =
gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id, gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id,
jitter); jitter);
} else { } else {
GST_CAT_DEBUG (GST_CAT_CLOCK, "no scheduler, returning GST_CLOCK_TIMEOUT"); GST_CAT_DEBUG (GST_CAT_CLOCK, "no scheduler, returning GST_CLOCK_TIMEOUT");
res = GST_CLOCK_TIMEOUT; res = GST_CLOCK_TIMEOUT;
@ -894,7 +896,7 @@ gst_element_set_time (GstElement * element, GstClockTime time)
case GST_STATE_PLAYING: case GST_STATE_PLAYING:
event_time = gst_clock_get_event_time (element->clock); event_time = gst_clock_get_event_time (element->clock);
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element,
"clock time %llu: setting element time to %llu", event_time, time); "clock time %llu: setting element time to %llu", event_time, time);
element->base_time = event_time - time; element->base_time = event_time - time;
break; break;
default: default:
@ -925,21 +927,21 @@ gst_element_adjust_time (GstElement * element, GstClockTimeDiff diff)
switch (element->current_state) { switch (element->current_state) {
case GST_STATE_PAUSED: case GST_STATE_PAUSED:
if (diff < 0 && element->base_time < abs (diff)) { if (diff < 0 && element->base_time < abs (diff)) {
g_warning ("attempted to set the current time of element %s below 0", g_warning ("attempted to set the current time of element %s below 0",
GST_OBJECT_NAME (element)); GST_OBJECT_NAME (element));
element->base_time = 0; element->base_time = 0;
} else { } else {
element->base_time += diff; element->base_time += diff;
} }
break; break;
case GST_STATE_PLAYING: case GST_STATE_PLAYING:
time = gst_clock_get_time (element->clock); time = gst_clock_get_time (element->clock);
if (time < element->base_time - diff) { if (time < element->base_time - diff) {
g_warning ("attempted to set the current time of element %s below 0", g_warning ("attempted to set the current time of element %s below 0",
GST_OBJECT_NAME (element)); GST_OBJECT_NAME (element));
element->base_time = time; element->base_time = time;
} else { } else {
element->base_time -= diff; element->base_time -= diff;
} }
break; break;
default: default:
@ -1059,7 +1061,7 @@ gst_element_add_pad (GstElement * element, GstPad * pad)
/* then check to see if there's already a pad by that name here */ /* then check to see if there's already a pad by that name here */
g_return_if_fail (gst_object_check_uniqueness (element->pads, g_return_if_fail (gst_object_check_uniqueness (element->pads,
GST_PAD_NAME (pad)) == TRUE); GST_PAD_NAME (pad)) == TRUE);
GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, "adding pad '%s'", GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, "adding pad '%s'",
GST_STR_NULL (GST_OBJECT_NAME (pad))); GST_STR_NULL (GST_OBJECT_NAME (pad)));
@ -1114,7 +1116,7 @@ gst_element_add_ghost_pad (GstElement * element, GstPad * pad,
/* then check to see if there's already a pad by that name here */ /* then check to see if there's already a pad by that name here */
g_return_val_if_fail (gst_object_check_uniqueness (element->pads, g_return_val_if_fail (gst_object_check_uniqueness (element->pads,
name) == TRUE, NULL); name) == TRUE, NULL);
ghostpad = gst_ghost_pad_new (name, pad); ghostpad = gst_ghost_pad_new (name, pad);
@ -1244,7 +1246,7 @@ gst_element_get_static_pad (GstElement * element, const gchar * name)
pad = GST_PAD (walk->data); pad = GST_PAD (walk->data);
if (strcmp (GST_PAD_NAME (pad), name) == 0) { if (strcmp (GST_PAD_NAME (pad), name) == 0) {
GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s", GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return pad; return pad;
} }
walk = g_list_next (walk); walk = g_list_next (walk);
@ -1291,31 +1293,31 @@ gst_element_get_request_pad (GstElement * element, const gchar * name)
while (!templ_found && list) { while (!templ_found && list) {
templ = (GstPadTemplate *) list->data; templ = (GstPadTemplate *) list->data;
if (templ->presence == GST_PAD_REQUEST) { if (templ->presence == GST_PAD_REQUEST) {
/* Because of sanity checks in gst_pad_template_new(), we know that %s /* Because of sanity checks in gst_pad_template_new(), we know that %s
and %d, occurring at the end of the name_template, are the only and %d, occurring at the end of the name_template, are the only
possibilities. */ possibilities. */
GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name,
templ->name_template); templ->name_template);
if ((str = strchr (templ->name_template, '%')) if ((str = strchr (templ->name_template, '%'))
&& strncmp (templ->name_template, name, && strncmp (templ->name_template, name,
str - templ->name_template) == 0 str - templ->name_template) == 0
&& strlen (name) > str - templ->name_template) { && strlen (name) > str - templ->name_template) {
data = name + (str - templ->name_template); data = name + (str - templ->name_template);
if (*(str + 1) == 'd') { if (*(str + 1) == 'd') {
/* it's an int */ /* it's an int */
n = (gint) strtol (data, &endptr, 10); n = (gint) strtol (data, &endptr, 10);
if (endptr && *endptr == '\0') { if (endptr && *endptr == '\0') {
templ_found = TRUE; templ_found = TRUE;
req_name = name; req_name = name;
break; break;
} }
} else { } else {
/* it's a string */ /* it's a string */
templ_found = TRUE; templ_found = TRUE;
req_name = name; req_name = name;
break; break;
} }
} }
} }
list = list->next; list = list->next;
} }
@ -1365,7 +1367,7 @@ gst_element_class_add_pad_template (GstElementClass * klass,
/* avoid registering pad templates with the same name */ /* avoid registering pad templates with the same name */
g_return_if_fail (gst_element_class_get_pad_template (klass, g_return_if_fail (gst_element_class_get_pad_template (klass,
templ->name_template) == NULL); templ->name_template) == NULL);
klass->padtemplates = g_list_append (klass->padtemplates, klass->padtemplates = g_list_append (klass->padtemplates,
gst_object_ref (GST_OBJECT (templ))); gst_object_ref (GST_OBJECT (templ)));
@ -1521,21 +1523,21 @@ gst_element_get_compatible_pad_template (GstElement * element,
*/ */
if (padtempl->direction != compattempl->direction) { if (padtempl->direction != compattempl->direction) {
GST_CAT_DEBUG (GST_CAT_CAPS, GST_CAT_DEBUG (GST_CAT_CAPS,
"compatible direction: found %s pad template \"%s\"", "compatible direction: found %s pad template \"%s\"",
padtempl->direction == GST_PAD_SRC ? "src" : "sink", padtempl->direction == GST_PAD_SRC ? "src" : "sink",
padtempl->name_template); padtempl->name_template);
intersection = gst_caps_intersect (GST_PAD_TEMPLATE_CAPS (compattempl), intersection = gst_caps_intersect (GST_PAD_TEMPLATE_CAPS (compattempl),
GST_PAD_TEMPLATE_CAPS (padtempl)); GST_PAD_TEMPLATE_CAPS (padtempl));
GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible", GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible",
(intersection ? "" : "not ")); (intersection ? "" : "not "));
if (!gst_caps_is_empty (intersection)) if (!gst_caps_is_empty (intersection))
newtempl = padtempl; newtempl = padtempl;
gst_caps_free (intersection); gst_caps_free (intersection);
if (newtempl) if (newtempl)
break; break;
} }
padlist = g_list_next (padlist); padlist = g_list_next (padlist);
@ -1572,9 +1574,9 @@ gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ)
case GST_PAD_SOMETIMES: case GST_PAD_SOMETIMES:
ret = gst_element_get_static_pad (element, templ->name_template); ret = gst_element_get_static_pad (element, templ->name_template);
if (!ret && presence == GST_PAD_ALWAYS) if (!ret && presence == GST_PAD_ALWAYS)
g_warning g_warning
("Element %s has an ALWAYS template %s, but no pad of the same name", ("Element %s has an ALWAYS template %s, but no pad of the same name",
GST_OBJECT_NAME (element), templ->name_template); GST_OBJECT_NAME (element), templ->name_template);
break; break;
case GST_PAD_REQUEST: case GST_PAD_REQUEST:
@ -1658,7 +1660,7 @@ gst_element_get_compatible_pad_filtered (GstElement * element, GstPad * pad,
GstPad *current = GST_PAD (pads->data); GstPad *current = GST_PAD (pads->data);
if (GST_PAD_PEER (current) == NULL && if (GST_PAD_PEER (current) == NULL &&
gst_pad_can_link_filtered (pad, current, filtercaps)) { gst_pad_can_link_filtered (pad, current, filtercaps)) {
return current; return current;
} }
pads = g_list_next (pads); pads = g_list_next (pads);
@ -1745,18 +1747,18 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
srcpad = gst_element_get_pad (src, srcpadname); srcpad = gst_element_get_pad (src, srcpadname);
if (!srcpad) { if (!srcpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
GST_ELEMENT_NAME (src), srcpadname); GST_ELEMENT_NAME (src), srcpadname);
return FALSE; return FALSE;
} else { } else {
if (!(GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC)) { if (!(GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad",
GST_DEBUG_PAD_NAME (srcpad)); GST_DEBUG_PAD_NAME (srcpad));
return FALSE; return FALSE;
} }
if (GST_PAD_PEER (srcpad) != NULL) { if (GST_PAD_PEER (srcpad) != NULL) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked",
GST_DEBUG_PAD_NAME (srcpad)); GST_DEBUG_PAD_NAME (srcpad));
return FALSE; return FALSE;
} }
} }
srcpads = NULL; srcpads = NULL;
@ -1768,18 +1770,18 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
destpad = gst_element_get_pad (dest, destpadname); destpad = gst_element_get_pad (dest, destpadname);
if (!destpad) { if (!destpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
GST_ELEMENT_NAME (dest), destpadname); GST_ELEMENT_NAME (dest), destpadname);
return FALSE; return FALSE;
} else { } else {
if (!(GST_PAD_DIRECTION (destpad) == GST_PAD_SINK)) { if (!(GST_PAD_DIRECTION (destpad) == GST_PAD_SINK)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad",
GST_DEBUG_PAD_NAME (destpad)); GST_DEBUG_PAD_NAME (destpad));
return FALSE; return FALSE;
} }
if (GST_PAD_PEER (destpad) != NULL) { if (GST_PAD_PEER (destpad) != NULL) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked",
GST_DEBUG_PAD_NAME (destpad)); GST_DEBUG_PAD_NAME (destpad));
return FALSE; return FALSE;
} }
} }
destpads = NULL; destpads = NULL;
@ -1796,60 +1798,60 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
/* loop through the allowed pads in the source, trying to find a /* loop through the allowed pads in the source, trying to find a
* compatible destination pad */ * compatible destination pad */
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
"looping through allowed src and dest pads"); "looping through allowed src and dest pads");
do { do {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s",
GST_DEBUG_PAD_NAME (srcpad)); GST_DEBUG_PAD_NAME (srcpad));
if ((GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC) && if ((GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC) &&
(GST_PAD_PEER (srcpad) == NULL)) { (GST_PAD_PEER (srcpad) == NULL)) {
GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad, GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad,
filtercaps); filtercaps);
if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) { if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp));
return TRUE; return TRUE;
} }
} }
/* find a better way for this mess */ /* find a better way for this mess */
if (srcpads) { if (srcpads) {
srcpads = g_list_next (srcpads); srcpads = g_list_next (srcpads);
if (srcpads) if (srcpads)
srcpad = (GstPad *) GST_PAD_REALIZE (srcpads->data); srcpad = (GstPad *) GST_PAD_REALIZE (srcpads->data);
} }
} while (srcpads); } while (srcpads);
} }
if (srcpadname) { if (srcpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s",
GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest)); GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest));
return FALSE; return FALSE;
} }
if (destpad) { if (destpad) {
/* loop through the existing pads in the destination */ /* loop through the existing pads in the destination */
do { do {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s",
GST_DEBUG_PAD_NAME (destpad)); GST_DEBUG_PAD_NAME (destpad));
if ((GST_PAD_DIRECTION (destpad) == GST_PAD_SINK) && if ((GST_PAD_DIRECTION (destpad) == GST_PAD_SINK) &&
(GST_PAD_PEER (destpad) == NULL)) { (GST_PAD_PEER (destpad) == NULL)) {
GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad, GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad,
filtercaps); filtercaps);
if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) { if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad)); GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad));
return TRUE; return TRUE;
} }
} }
if (destpads) { if (destpads) {
destpads = g_list_next (destpads); destpads = g_list_next (destpads);
if (destpads) if (destpads)
destpad = (GstPad *) GST_PAD_REALIZE (destpads->data); destpad = (GstPad *) GST_PAD_REALIZE (destpads->data);
} }
} while (destpads); } while (destpads);
} }
if (destpadname) { if (destpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s",
GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad)); GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad));
return FALSE; return FALSE;
} }
@ -1862,28 +1864,28 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
while (srctempls) { while (srctempls) {
srctempl = (GstPadTemplate *) srctempls->data; srctempl = (GstPadTemplate *) srctempls->data;
if (srctempl->presence == GST_PAD_REQUEST) { if (srctempl->presence == GST_PAD_REQUEST) {
for (l = desttempls; l; l = l->next) { for (l = desttempls; l; l = l->next) {
desttempl = (GstPadTemplate *) l->data; desttempl = (GstPadTemplate *) l->data;
if (desttempl->presence == GST_PAD_REQUEST && if (desttempl->presence == GST_PAD_REQUEST &&
desttempl->direction != srctempl->direction) { desttempl->direction != srctempl->direction) {
if (gst_caps_is_always_compatible (gst_pad_template_get_caps if (gst_caps_is_always_compatible (gst_pad_template_get_caps
(srctempl), gst_pad_template_get_caps (desttempl))) { (srctempl), gst_pad_template_get_caps (desttempl))) {
srcpad = srcpad =
gst_element_get_request_pad (src, srctempl->name_template); gst_element_get_request_pad (src, srctempl->name_template);
destpad = destpad =
gst_element_get_request_pad (dest, desttempl->name_template); gst_element_get_request_pad (dest, desttempl->name_template);
if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) { if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
"linked pad %s:%s to pad %s:%s", "linked pad %s:%s to pad %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad));
return TRUE; return TRUE;
} }
/* it failed, so we release the request pads */ /* it failed, so we release the request pads */
gst_element_release_request_pad (src, srcpad); gst_element_release_request_pad (src, srcpad);
gst_element_release_request_pad (dest, destpad); gst_element_release_request_pad (dest, destpad);
} }
} }
} }
} }
srctempls = srctempls->next; srctempls = srctempls->next;
} }
@ -2017,7 +2019,7 @@ gst_element_unlink_pads (GstElement * src, const gchar * srcpadname,
destpad = gst_element_get_pad (dest, destpadname); destpad = gst_element_get_pad (dest, destpadname);
if (srcpad == NULL) { if (srcpad == NULL) {
GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"", GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"",
destpadname); destpadname);
return; return;
} }
@ -2085,7 +2087,7 @@ gst_element_unlink (GstElement * src, GstElement * dest)
/* see if the pad is connected and is really a pad /* see if the pad is connected and is really a pad
* of dest */ * of dest */
if (peerpad && (GST_OBJECT_PARENT (peerpad) == (GstObject *) dest)) { if (peerpad && (GST_OBJECT_PARENT (peerpad) == (GstObject *) dest)) {
gst_pad_unlink (pad, peerpad); gst_pad_unlink (pad, peerpad);
} }
} }
@ -2100,17 +2102,17 @@ gst_element_error_func (GstElement * element, GstElement * source,
/* tell the parent */ /* tell the parent */
if (GST_OBJECT_PARENT (element)) { if (GST_OBJECT_PARENT (element)) {
GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM,
"forwarding error \"%s\" from %s to %s", error->message, "forwarding error \"%s\" from %s to %s", error->message,
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (element),
GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
gst_object_ref (GST_OBJECT (element)); gst_object_ref (GST_OBJECT (element));
g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)), g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)),
gst_element_signals[ERROR], 0, source, error, debug); gst_element_signals[ERROR], 0, source, error, debug);
gst_object_unref (GST_OBJECT (element)); gst_object_unref (GST_OBJECT (element));
GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s", GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s",
error->message, GST_ELEMENT_NAME (element), error->message, GST_ELEMENT_NAME (element),
GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
} }
} }
@ -2124,18 +2126,18 @@ gst_element_get_random_pad (GstElement * element, GstPadDirection dir)
GstPad *pad = GST_PAD (pads->data); GstPad *pad = GST_PAD (pads->data);
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "checking pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "checking pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
if (GST_PAD_DIRECTION (pad) == dir) { if (GST_PAD_DIRECTION (pad) == dir) {
if (GST_PAD_IS_LINKED (pad)) { if (GST_PAD_IS_LINKED (pad)) {
return pad; return pad;
} else { } else {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
} }
} else { } else {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is in wrong direction", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is in wrong direction",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
} }
pads = g_list_next (pads); pads = g_list_next (pads);
@ -2203,7 +2205,7 @@ gst_element_send_event (GstElement * element, GstEvent * event)
if (pad) { if (pad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "sending event to random pad %s:%s", GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "sending event to random pad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return gst_pad_send_event (GST_PAD_PEER (pad), event); return gst_pad_send_event (GST_PAD_PEER (pad), event);
} }
} }
@ -2371,13 +2373,13 @@ gst_element_convert (GstElement * element,
if (oclass->convert) if (oclass->convert)
return oclass->convert (element, return oclass->convert (element,
src_format, src_value, dest_format, dest_value); src_format, src_value, dest_format, dest_value);
else { else {
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
if (pad) if (pad)
return gst_pad_convert (GST_PAD_PEER (pad), return gst_pad_convert (GST_PAD_PEER (pad),
src_format, src_value, dest_format, dest_value); src_format, src_value, dest_format, dest_value);
} }
return FALSE; return FALSE;
@ -2456,7 +2458,7 @@ void gst_element_error_full
/* if the element was already in error, stop now */ /* if the element was already in error, stop now */
if (GST_FLAG_IS_SET (element, GST_ELEMENT_IN_ERROR)) { if (GST_FLAG_IS_SET (element, GST_ELEMENT_IN_ERROR)) {
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "recursive ERROR detected in %s", GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "recursive ERROR detected in %s",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
g_free (sent_message); g_free (sent_message);
if (debug) if (debug)
g_free (debug); g_free (debug);
@ -2470,7 +2472,7 @@ void gst_element_error_full
name = gst_object_get_path_string (GST_OBJECT (element)); name = gst_object_get_path_string (GST_OBJECT (element));
if (debug) if (debug)
sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s", sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s",
file, line, function, name, debug ? debug : ""); file, line, function, name, debug ? debug : "");
else else
sent_debug = NULL; sent_debug = NULL;
g_free (debug); g_free (debug);
@ -2491,7 +2493,7 @@ void gst_element_error_full
ret = gst_element_set_state (element, GST_STATE_PAUSED); ret = gst_element_set_state (element, GST_STATE_PAUSED);
if (ret != GST_STATE_SUCCESS) { if (ret != GST_STATE_SUCCESS) {
g_warning ("could not PAUSE element \"%s\" after error, help!", g_warning ("could not PAUSE element \"%s\" after error, help!",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} }
} }
@ -2546,11 +2548,11 @@ gst_element_set_locked_state (GstElement * element, gboolean locked_state)
if (locked_state) { if (locked_state) {
GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s", GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
GST_FLAG_SET (element, GST_ELEMENT_LOCKED_STATE); GST_FLAG_SET (element, GST_ELEMENT_LOCKED_STATE);
} else { } else {
GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s", GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
GST_FLAG_UNSET (element, GST_ELEMENT_LOCKED_STATE); GST_FLAG_UNSET (element, GST_ELEMENT_LOCKED_STATE);
} }
} }
@ -2640,8 +2642,8 @@ gst_element_set_state (GstElement * element, GstElementState state)
if (state == curpending) { if (state == curpending) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"element is already in requested state %s", "element is already in requested state %s",
gst_element_state_get_name (state)); gst_element_state_get_name (state));
return (GST_STATE_SUCCESS); return (GST_STATE_SUCCESS);
} }
@ -2664,9 +2666,9 @@ gst_element_set_state (GstElement * element, GstElementState state)
if (curpending != state) { if (curpending != state) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"intermediate: setting state from %s to %s", "intermediate: setting state from %s to %s",
gst_element_state_get_name (GST_STATE (element)), gst_element_state_get_name (GST_STATE (element)),
gst_element_state_get_name (curpending)); gst_element_state_get_name (curpending));
} }
/* call the state change function so it can set the state */ /* call the state change function so it can set the state */
@ -2676,31 +2678,31 @@ gst_element_set_state (GstElement * element, GstElementState state)
switch (return_val) { switch (return_val) {
case GST_STATE_FAILURE: case GST_STATE_FAILURE:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"have failed change_state return"); "have failed change_state return");
goto exit; goto exit;
case GST_STATE_ASYNC: case GST_STATE_ASYNC:
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"element will change state async"); "element will change state async");
goto exit; goto exit;
case GST_STATE_SUCCESS: case GST_STATE_SUCCESS:
/* Last thing we do is verify that a successful state change really /* Last thing we do is verify that a successful state change really
* did change the state... */ * did change the state... */
/* if it did not, this is an error - fix the element that does this */ /* if it did not, this is an error - fix the element that does this */
if (GST_STATE (element) != curpending) { if (GST_STATE (element) != curpending) {
g_warning ("element %s claimed state-change success," g_warning ("element %s claimed state-change success,"
"but state didn't change to %s. State is %s (%s pending), fix the element", "but state didn't change to %s. State is %s (%s pending), fix the element",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (element),
gst_element_state_get_name (curpending), gst_element_state_get_name (curpending),
gst_element_state_get_name (GST_STATE (element)), gst_element_state_get_name (GST_STATE (element)),
gst_element_state_get_name (GST_STATE_PENDING (element))); gst_element_state_get_name (GST_STATE_PENDING (element)));
return_val = GST_STATE_FAILURE; return_val = GST_STATE_FAILURE;
goto exit; goto exit;
} }
break; break;
default: default:
/* somebody added a GST_STATE_ and forgot to do stuff here ! */ /* somebody added a GST_STATE_ and forgot to do stuff here ! */
g_assert_not_reached (); g_assert_not_reached ();
} }
} }
exit: exit:
@ -2738,35 +2740,35 @@ gst_element_negotiate_pads (GstElement * element)
/* check the parent of the peer pad, if there is no parent do nothing */ /* check the parent of the peer pad, if there is no parent do nothing */
parent = GST_PAD_PARENT (sinkpad); parent = GST_PAD_PARENT (sinkpad);
if (!parent) if (!parent)
continue; continue;
/* skips pads that were already negotiating */ /* skips pads that were already negotiating */
if (GST_FLAG_IS_SET (sinkpad, GST_PAD_NEGOTIATING) || if (GST_FLAG_IS_SET (sinkpad, GST_PAD_NEGOTIATING) ||
GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING)) GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING))
continue; continue;
otherstate = GST_STATE (parent); otherstate = GST_STATE (parent);
/* swap pads if needed */ /* swap pads if needed */
if (!GST_PAD_IS_SRC (srcpad)) { if (!GST_PAD_IS_SRC (srcpad)) {
GstRealPad *temp; GstRealPad *temp;
temp = srcpad; temp = srcpad;
srcpad = sinkpad; srcpad = sinkpad;
sinkpad = temp; sinkpad = temp;
} }
/* only try to negotiate if the peer element is in PAUSED or higher too */ /* only try to negotiate if the peer element is in PAUSED or higher too */
if (otherstate >= GST_STATE_READY) { if (otherstate >= GST_STATE_READY) {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
"perform negotiate for %s:%s and %s:%s", "perform negotiate for %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED) if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED)
return FALSE; return FALSE;
} else { } else {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element,
"not negotiating %s:%s and %s:%s, not in READY yet", "not negotiating %s:%s and %s:%s, not in READY yet",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
} }
} }
} }
@ -2826,8 +2828,8 @@ gst_element_change_state (GstElement * element)
if (old_pending == GST_STATE_VOID_PENDING || if (old_pending == GST_STATE_VOID_PENDING ||
old_state == GST_STATE_PENDING (element)) { old_state == GST_STATE_PENDING (element)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
"element is already in the %s state", "element is already in the %s state",
gst_element_state_get_name (old_state)); gst_element_state_get_name (old_state));
return GST_STATE_SUCCESS; return GST_STATE_SUCCESS;
} }
@ -2843,30 +2845,30 @@ gst_element_change_state (GstElement * element)
switch (old_transition) { switch (old_transition) {
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
if (element->clock) { if (element->clock) {
GstClockTime time = gst_clock_get_event_time (element->clock); GstClockTime time = gst_clock_get_event_time (element->clock);
g_assert (time >= element->base_time); g_assert (time >= element->base_time);
element->base_time = time - element->base_time; element->base_time = time - element->base_time;
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %" GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %"
G_GINT64_FORMAT, element->base_time); G_GINT64_FORMAT, element->base_time);
} }
gst_element_pads_activate (element, FALSE); gst_element_pads_activate (element, FALSE);
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
gst_element_pads_activate (element, TRUE); gst_element_pads_activate (element, TRUE);
if (element->clock) { if (element->clock) {
GstClockTime time = gst_clock_get_event_time (element->clock); GstClockTime time = gst_clock_get_event_time (element->clock);
element->base_time = time - element->base_time; element->base_time = time - element->base_time;
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %" GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %"
G_GINT64_FORMAT, element->base_time); G_GINT64_FORMAT, element->base_time);
} }
break; break;
/* if we are going to paused, we try to negotiate the pads */ /* if we are going to paused, we try to negotiate the pads */
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
g_assert (element->base_time == 0); g_assert (element->base_time == 0);
if (!gst_element_negotiate_pads (element)) if (!gst_element_negotiate_pads (element))
goto failure; goto failure;
break; break;
/* going to the READY state clears all pad caps */ /* going to the READY state clears all pad caps */
/* FIXME: Why doesn't this happen on READY => NULL? -- Company */ /* FIXME: Why doesn't this happen on READY => NULL? -- Company */
@ -2888,9 +2890,9 @@ gst_element_change_state (GstElement * element)
/* tell the scheduler if we have one */ /* tell the scheduler if we have one */
if (element->sched) { if (element->sched) {
if (gst_scheduler_state_transition (element->sched, element, if (gst_scheduler_state_transition (element->sched, element,
old_transition) != GST_STATE_SUCCESS) { old_transition) != GST_STATE_SUCCESS) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"scheduler could not change state"); "scheduler could not change state");
goto failure; goto failure;
} }
} }
@ -2898,7 +2900,7 @@ gst_element_change_state (GstElement * element)
/* tell our parent about the state change */ /* tell our parent about the state change */
if (parent && GST_IS_BIN (parent)) { if (parent && GST_IS_BIN (parent)) {
gst_bin_child_state_change (GST_BIN (parent), old_state, gst_bin_child_state_change (GST_BIN (parent), old_state,
GST_STATE (element), element); GST_STATE (element), element);
} }
/* at this point the state of the element could have changed again */ /* at this point the state of the element could have changed again */
@ -2956,9 +2958,9 @@ gst_element_dispose (GObject * object)
pad = GST_PAD (pads->data); pad = GST_PAD (pads->data);
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'", GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'",
GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad))))); GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad)))));
gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad))); gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad)));
} }
gst_element_remove_pad (element, pad); gst_element_remove_pad (element, pad);
@ -3046,14 +3048,14 @@ gst_element_save_thyself (GstObject * object, xmlNodePtr parent)
xmlNewChild (param, NULL, "name", spec->name); xmlNewChild (param, NULL, "name", spec->name);
if (G_IS_PARAM_SPEC_STRING (spec)) if (G_IS_PARAM_SPEC_STRING (spec))
contents = g_value_dup_string (&value); contents = g_value_dup_string (&value);
else if (G_IS_PARAM_SPEC_ENUM (spec)) else if (G_IS_PARAM_SPEC_ENUM (spec))
contents = g_strdup_printf ("%d", g_value_get_enum (&value)); contents = g_strdup_printf ("%d", g_value_get_enum (&value));
else if (G_IS_PARAM_SPEC_INT64 (spec)) else if (G_IS_PARAM_SPEC_INT64 (spec))
contents = g_strdup_printf ("%" G_GINT64_FORMAT, contents = g_strdup_printf ("%" G_GINT64_FORMAT,
g_value_get_int64 (&value)); g_value_get_int64 (&value));
else else
contents = g_strdup_value_contents (&value); contents = g_strdup_value_contents (&value);
xmlNewChild (param, NULL, "value", contents); xmlNewChild (param, NULL, "value", contents);
g_free (contents); g_free (contents);
@ -3097,12 +3099,12 @@ gst_element_restore_thyself (GstObject * object, xmlNodePtr self)
xmlNodePtr child = children->xmlChildrenNode; xmlNodePtr child = children->xmlChildrenNode;
while (child) { while (child) {
if (!strcmp (child->name, "name")) { if (!strcmp (child->name, "name")) {
name = xmlNodeGetContent (child); name = xmlNodeGetContent (child);
} else if (!strcmp (child->name, "value")) { } else if (!strcmp (child->name, "value")) {
value = xmlNodeGetContent (child); value = xmlNodeGetContent (child);
} }
child = child->next; child = child->next;
} }
/* FIXME: can this just be g_object_set ? */ /* FIXME: can this just be g_object_set ? */
gst_util_set_object_arg (G_OBJECT (element), name, value); gst_util_set_object_arg (G_OBJECT (element), name, value);
@ -3250,9 +3252,9 @@ gst_element_found_tag_func (GstElement * element, GstElement * source,
/* tell the parent */ /* tell the parent */
if (GST_OBJECT_PARENT (element)) { if (GST_OBJECT_PARENT (element)) {
GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s", GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s",
GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)), gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)),
source, tag_list); source, tag_list);
} }
} }
@ -3439,45 +3441,45 @@ gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name,
if (prop_id == fd_id) { if (prop_id == fd_id) {
pspec = g_param_spec_int ("fd", "File-descriptor", pspec = g_param_spec_int ("fd", "File-descriptor",
"File-descriptor for the file being read", 0, G_MAXINT, 0, flags); "File-descriptor for the file being read", 0, G_MAXINT, 0, flags);
} else if (prop_id == blocksize_id) { } else if (prop_id == blocksize_id) {
pspec = g_param_spec_ulong ("blocksize", "Block Size", pspec = g_param_spec_ulong ("blocksize", "Block Size",
"Block size to read per buffer", 0, G_MAXULONG, 4096, flags); "Block size to read per buffer", 0, G_MAXULONG, 4096, flags);
} else if (prop_id == bytesperread_id) { } else if (prop_id == bytesperread_id) {
pspec = g_param_spec_int ("bytesperread", "Bytes per read", pspec = g_param_spec_int ("bytesperread", "Bytes per read",
"Number of bytes to read per buffer", G_MININT, G_MAXINT, 0, flags); "Number of bytes to read per buffer", G_MININT, G_MAXINT, 0, flags);
} else if (prop_id == dump_id) { } else if (prop_id == dump_id) {
pspec = g_param_spec_boolean ("dump", "Dump", pspec = g_param_spec_boolean ("dump", "Dump",
"Dump bytes to stdout", FALSE, flags); "Dump bytes to stdout", FALSE, flags);
} else if (prop_id == filesize_id) { } else if (prop_id == filesize_id) {
pspec = g_param_spec_int64 ("filesize", "File Size", pspec = g_param_spec_int64 ("filesize", "File Size",
"Size of the file being read", 0, G_MAXINT64, 0, flags); "Size of the file being read", 0, G_MAXINT64, 0, flags);
} else if (prop_id == mmapsize_id) { } else if (prop_id == mmapsize_id) {
pspec = g_param_spec_ulong ("mmapsize", "mmap() Block Size", pspec = g_param_spec_ulong ("mmapsize", "mmap() Block Size",
"Size in bytes of mmap()d regions", 0, G_MAXULONG, 4 * 1048576, flags); "Size in bytes of mmap()d regions", 0, G_MAXULONG, 4 * 1048576, flags);
} else if (prop_id == location_id) { } else if (prop_id == location_id) {
pspec = g_param_spec_string ("location", "File Location", pspec = g_param_spec_string ("location", "File Location",
"Location of the file to read", NULL, flags); "Location of the file to read", NULL, flags);
} else if (prop_id == offset_id) { } else if (prop_id == offset_id) {
pspec = g_param_spec_int64 ("offset", "File Offset", pspec = g_param_spec_int64 ("offset", "File Offset",
"Byte offset of current read pointer", 0, G_MAXINT64, 0, flags); "Byte offset of current read pointer", 0, G_MAXINT64, 0, flags);
} else if (prop_id == silent_id) { } else if (prop_id == silent_id) {
pspec = g_param_spec_boolean ("silent", "Silent", "Don't produce events", pspec = g_param_spec_boolean ("silent", "Silent", "Don't produce events",
FALSE, flags); FALSE, flags);
} else if (prop_id == touch_id) { } else if (prop_id == touch_id) {
pspec = g_param_spec_boolean ("touch", "Touch read data", pspec = g_param_spec_boolean ("touch", "Touch read data",
"Touch data to force disk read before " "push ()", TRUE, flags); "Touch data to force disk read before " "push ()", TRUE, flags);
} else { } else {
g_warning ("Unknown - 'standard' property '%s' id %d from klass %s", g_warning ("Unknown - 'standard' property '%s' id %d from klass %s",
prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass))); prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass)));
pspec = NULL; pspec = NULL;
} }
@ -3517,7 +3519,7 @@ gst_element_class_install_std_props (GstElementClass * klass,
int flags = va_arg (args, int); int flags = va_arg (args, int);
gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id, gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id,
flags); flags);
name = va_arg (args, char *); name = va_arg (args, char *);
} }

View file

@ -58,11 +58,12 @@ gst_element_factory_get_type (void)
(GInstanceInitFunc) gst_element_factory_init, (GInstanceInitFunc) gst_element_factory_init,
NULL NULL
}; };
elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstElementFactory", &elementfactory_info, 0); "GstElementFactory", &elementfactory_info, 0);
GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY",
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
"element factories keep information about installed elements"); "element factories keep information about installed elements");
} }
return elementfactory_type; return elementfactory_type;
} }
@ -202,16 +203,16 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
if (!factory) { if (!factory) {
klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
factory = factory =
GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL)); GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
g_type_name (type)); g_type_name (type));
} else { } else {
g_return_val_if_fail (factory->type == 0, FALSE); g_return_val_if_fail (factory->type == 0, FALSE);
klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
gst_element_factory_cleanup (factory); gst_element_factory_cleanup (factory);
GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s", GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s",
g_type_name (type)); g_type_name (type));
} }
factory->type = type; factory->type = type;
@ -223,7 +224,7 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
/* special stuff for URI handling */ /* special stuff for URI handling */
if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) { if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) {
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) GstURIHandlerInterface *iface = (GstURIHandlerInterface *)
g_type_interface_peek (klass, GST_TYPE_URI_HANDLER); g_type_interface_peek (klass, GST_TYPE_URI_HANDLER);
if (!iface || !iface->get_type || !iface->get_protocols) if (!iface || !iface->get_type || !iface->get_protocols)
goto error; goto error;
@ -277,13 +278,13 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
if (name) if (name)
GST_INFO ("creating \"%s\" named \"%s\"", GST_PLUGIN_FEATURE_NAME (factory), GST_INFO ("creating \"%s\" named \"%s\"", GST_PLUGIN_FEATURE_NAME (factory),
GST_STR_NULL (name)); GST_STR_NULL (name));
else else
GST_INFO ("creating \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); GST_INFO ("creating \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
if (factory->type == 0) { if (factory->type == 0) {
g_critical ("Factory for `%s' has no type", g_critical ("Factory for `%s' has no type",
GST_PLUGIN_FEATURE_NAME (factory)); GST_PLUGIN_FEATURE_NAME (factory));
return NULL; return NULL;
} }
@ -464,7 +465,7 @@ __gst_element_factory_add_interface (GstElementFactory * elementfactory,
{ {
g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory)); g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory));
g_return_if_fail (interfacename != NULL); g_return_if_fail (interfacename != NULL);
g_return_if_fail (interfacename[0] != '\0'); /* no empty string */ g_return_if_fail (interfacename[0] != '\0'); /* no empty string */
elementfactory->interfaces = elementfactory->interfaces =
g_list_prepend (elementfactory->interfaces, g_strdup (interfacename)); g_list_prepend (elementfactory->interfaces, g_strdup (interfacename));
@ -545,8 +546,8 @@ gst_element_factory_can_src_caps (GstElementFactory * factory,
if (template->direction == GST_PAD_SRC) { if (template->direction == GST_PAD_SRC) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template),
caps)) caps))
return TRUE; return TRUE;
} }
templates = g_list_next (templates); templates = g_list_next (templates);
} }
@ -579,8 +580,8 @@ gst_element_factory_can_sink_caps (GstElementFactory * factory,
if (template->direction == GST_PAD_SINK) { if (template->direction == GST_PAD_SINK) {
if (gst_caps_is_always_compatible (caps, if (gst_caps_is_always_compatible (caps,
GST_PAD_TEMPLATE_CAPS (template))) GST_PAD_TEMPLATE_CAPS (template)))
return TRUE; return TRUE;
} }
templates = g_list_next (templates); templates = g_list_next (templates);
} }

View file

@ -40,7 +40,7 @@ gst_g_error_get_type (void)
if (!type) if (!type)
type = g_boxed_type_register_static ("GstGError", type = g_boxed_type_register_static ("GstGError",
(GBoxedCopyFunc) g_error_copy, (GBoxedFreeFunc) g_error_free); (GBoxedCopyFunc) g_error_copy, (GBoxedFreeFunc) g_error_free);
return type; return type;
} }
@ -56,7 +56,7 @@ _gst_core_errors_init ()
N_("GStreamer encountered a general core library error.")); N_("GStreamer encountered a general core library error."));
TABLE (t, CORE, TOO_LAZY, TABLE (t, CORE, TOO_LAZY,
N_("GStreamer developers were too lazy to assign an error code " N_("GStreamer developers were too lazy to assign an error code "
"to this error. Please file a bug.")); "to this error. Please file a bug."));
TABLE (t, CORE, NOT_IMPLEMENTED, TABLE (t, CORE, NOT_IMPLEMENTED,
N_("Internal GStreamer error: code not implemented. File a bug.")); N_("Internal GStreamer error: code not implemented. File a bug."));
TABLE (t, CORE, STATE_CHANGE, TABLE (t, CORE, STATE_CHANGE,
@ -93,7 +93,7 @@ _gst_library_errors_init ()
N_("GStreamer encountered a general supporting library error.")); N_("GStreamer encountered a general supporting library error."));
TABLE (t, LIBRARY, TOO_LAZY, TABLE (t, LIBRARY, TOO_LAZY,
N_("GStreamer developers were too lazy to assign an error code " N_("GStreamer developers were too lazy to assign an error code "
"to this error. Please file a bug.")); "to this error. Please file a bug."));
TABLE (t, LIBRARY, INIT, N_("Could not initialize supporting library.")); TABLE (t, LIBRARY, INIT, N_("Could not initialize supporting library."));
TABLE (t, LIBRARY, SHUTDOWN, N_("Could not close supporting library.")); TABLE (t, LIBRARY, SHUTDOWN, N_("Could not close supporting library."));
TABLE (t, LIBRARY, SETTINGS, N_("Could not close supporting library.")); TABLE (t, LIBRARY, SETTINGS, N_("Could not close supporting library."));
@ -113,7 +113,7 @@ _gst_resource_errors_init ()
N_("GStreamer encountered a general supporting library error.")); N_("GStreamer encountered a general supporting library error."));
TABLE (t, RESOURCE, TOO_LAZY, TABLE (t, RESOURCE, TOO_LAZY,
N_("GStreamer developers were too lazy to assign an error code " N_("GStreamer developers were too lazy to assign an error code "
"to this error. Please file a bug.")); "to this error. Please file a bug."));
TABLE (t, RESOURCE, NOT_FOUND, N_("Resource not found.")); TABLE (t, RESOURCE, NOT_FOUND, N_("Resource not found."));
TABLE (t, RESOURCE, BUSY, N_("Resource busy or not available.")); TABLE (t, RESOURCE, BUSY, N_("Resource busy or not available."));
TABLE (t, RESOURCE, OPEN_READ, N_("Could not open resource for reading.")); TABLE (t, RESOURCE, OPEN_READ, N_("Could not open resource for reading."));
@ -143,10 +143,10 @@ _gst_stream_errors_init ()
N_("GStreamer encountered a general supporting library error.")); N_("GStreamer encountered a general supporting library error."));
TABLE (t, STREAM, TOO_LAZY, TABLE (t, STREAM, TOO_LAZY,
N_("GStreamer developers were too lazy to assign an error code " N_("GStreamer developers were too lazy to assign an error code "
"to this error. Please file a bug.")); "to this error. Please file a bug."));
TABLE (t, STREAM, NOT_IMPLEMENTED, TABLE (t, STREAM, NOT_IMPLEMENTED,
N_("Element doesn't implement handling of this stream. " N_("Element doesn't implement handling of this stream. "
"Please file a bug.")); "Please file a bug."));
TABLE (t, STREAM, TYPE_NOT_FOUND, N_("Could not determine type of stream.")); TABLE (t, STREAM, TYPE_NOT_FOUND, N_("Could not determine type of stream."));
TABLE (t, STREAM, WRONG_TYPE, TABLE (t, STREAM, WRONG_TYPE,
N_("The stream is of a different type than handled by this element.")); N_("The stream is of a different type than handled by this element."));
@ -205,13 +205,13 @@ QUARK_FUNC (core)
else { else {
g_warning ("No error messages for domain %s", g_quark_to_string (domain)); g_warning ("No error messages for domain %s", g_quark_to_string (domain));
return g_strdup_printf (_("No error message for domain %s."), return g_strdup_printf (_("No error message for domain %s."),
g_quark_to_string (domain)); g_quark_to_string (domain));
} }
if (message) if (message)
return g_strdup (_(message)); return g_strdup (_(message));
else else
return return
g_strdup_printf (_ g_strdup_printf (_
("No standard error message for domain %s and code %d."), ("No standard error message for domain %s and code %d."),
g_quark_to_string (domain), code); g_quark_to_string (domain), code);
} }

View file

@ -20,7 +20,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include <string.h> /* memcpy */ #include <string.h> /* memcpy */
#include "gst_private.h" #include "gst_private.h"
#include "gstdata_private.h" #include "gstdata_private.h"
@ -74,12 +74,12 @@ _gst_event_copy (GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG: case GST_EVENT_TAG:
copy->event_data.structure.structure = copy->event_data.structure.structure =
gst_tag_list_copy ((GstTagList *) event->event_data.structure. gst_tag_list_copy ((GstTagList *) event->event_data.structure.
structure); structure);
break; break;
case GST_EVENT_NAVIGATION: case GST_EVENT_NAVIGATION:
copy->event_data.structure.structure = copy->event_data.structure.structure =
gst_structure_copy (event->event_data.structure.structure); gst_structure_copy (event->event_data.structure.structure);
default: default:
break; break;
} }
@ -98,10 +98,10 @@ _gst_event_free (GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_TAG: case GST_EVENT_TAG:
if (GST_IS_TAG_LIST (event->event_data.structure.structure)) { if (GST_IS_TAG_LIST (event->event_data.structure.structure)) {
gst_tag_list_free (event->event_data.structure.structure); gst_tag_list_free (event->event_data.structure.structure);
} else { } else {
g_warning ("tag event %p didn't contain a valid tag list!", event); g_warning ("tag event %p didn't contain a valid tag list!", event);
GST_ERROR ("tag event %p didn't contain a valid tag list!", event); GST_ERROR ("tag event %p didn't contain a valid tag list!", event);
} }
break; break;
case GST_EVENT_NAVIGATION: case GST_EVENT_NAVIGATION:
@ -136,7 +136,7 @@ gst_event_masks_contains (const GstEventMask * masks, GstEventMask * mask)
while (masks->type) { while (masks->type) {
if (masks->type == mask->type && if (masks->type == mask->type &&
(masks->flags & mask->flags) == mask->flags) (masks->flags & mask->flags) == mask->flags)
return TRUE; return TRUE;
masks++; masks++;
@ -233,7 +233,7 @@ gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1,
while (format1 != GST_FORMAT_UNDEFINED && count < 8) { while (format1 != GST_FORMAT_UNDEFINED && count < 8) {
GST_EVENT_DISCONT_OFFSET (event, count).format = GST_EVENT_DISCONT_OFFSET (event, count).format =
format1 & GST_SEEK_FORMAT_MASK; format1 & GST_SEEK_FORMAT_MASK;
GST_EVENT_DISCONT_OFFSET (event, count).value = va_arg (var_args, gint64); GST_EVENT_DISCONT_OFFSET (event, count).value = va_arg (var_args, gint64);
format1 = va_arg (var_args, GstFormat); format1 = va_arg (var_args, GstFormat);

View file

@ -39,7 +39,7 @@ gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
result = g_list_prepend (result, data); result = g_list_prepend (result, data);
if (first) if (first)
break; break;
} }
} }

View file

@ -29,7 +29,7 @@
static GList *_gst_formats = NULL; static GList *_gst_formats = NULL;
static GHashTable *_nick_to_format = NULL; static GHashTable *_nick_to_format = NULL;
static GHashTable *_format_to_nick = NULL; static GHashTable *_format_to_nick = NULL;
static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */ static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */
static GstFormatDefinition standard_definitions[] = { static GstFormatDefinition standard_definitions[] = {
{GST_FORMAT_DEFAULT, "default", "Default format for the media type"}, {GST_FORMAT_DEFAULT, "default", "Default format for the media type"},
@ -53,7 +53,7 @@ _gst_format_initialize (void)
while (standards->nick) { while (standards->nick) {
g_hash_table_insert (_nick_to_format, standards->nick, standards); g_hash_table_insert (_nick_to_format, standards->nick, standards);
g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value), g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value),
standards); standards);
_gst_formats = g_list_append (_gst_formats, standards); _gst_formats = g_list_append (_gst_formats, standards);
standards++; standards++;

View file

@ -66,7 +66,8 @@ typedef struct
GstIndexResolverMethod method; GstIndexResolverMethod method;
GstIndexResolver resolver; GstIndexResolver resolver;
gpointer user_data; gpointer user_data;
} ResolverEntry; }
ResolverEntry;
static const ResolverEntry resolvers[] = { static const ResolverEntry resolvers[] = {
{GST_INDEX_RESOLVER_CUSTOM, NULL, NULL}, {GST_INDEX_RESOLVER_CUSTOM, NULL, NULL},
@ -81,16 +82,17 @@ gst_index_resolver_get_type (void)
static GType index_resolver_type = 0; static GType index_resolver_type = 0;
static GEnumValue index_resolver[] = { static GEnumValue index_resolver[] = {
{GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", {GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM",
"Use a custom resolver"}, "Use a custom resolver"},
{GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", {GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE",
"Resolve an object to its GType[.padname]"}, "Resolve an object to its GType[.padname]"},
{GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", {GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH",
"Resolve an object to its path in the pipeline"}, "Resolve an object to its path in the pipeline"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!index_resolver_type) { if (!index_resolver_type) {
index_resolver_type = index_resolver_type =
g_enum_register_static ("GstIndexResolver", index_resolver); g_enum_register_static ("GstIndexResolver", index_resolver);
} }
return index_resolver_type; return index_resolver_type;
} }
@ -102,8 +104,8 @@ gst_index_entry_get_type (void)
if (!index_entry_type) { if (!index_entry_type) {
index_entry_type = g_boxed_type_register_static ("GstIndexEntry", index_entry_type = g_boxed_type_register_static ("GstIndexEntry",
(GBoxedCopyFunc) gst_index_entry_copy, (GBoxedCopyFunc) gst_index_entry_copy,
(GBoxedFreeFunc) gst_index_entry_free); (GBoxedFreeFunc) gst_index_entry_free);
} }
return index_entry_type; return index_entry_type;
} }
@ -127,8 +129,9 @@ gst_index_get_type (void)
(GInstanceInitFunc) gst_index_init, (GInstanceInitFunc) gst_index_init,
NULL NULL
}; };
index_type = index_type =
g_type_register_static (GST_TYPE_OBJECT, "GstIndex", &index_info, 0); g_type_register_static (GST_TYPE_OBJECT, "GstIndex", &index_info, 0);
} }
return index_type; return index_type;
} }
@ -154,8 +157,8 @@ gst_index_class_init (GstIndexClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RESOLVER, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RESOLVER,
g_param_spec_enum ("resolver", "Resolver", g_param_spec_enum ("resolver", "Resolver",
"Select a predefined object to string mapper", "Select a predefined object to string mapper",
GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE)); GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE));
} }
static void static void
@ -513,10 +516,10 @@ gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
GstElement *element = gst_pad_get_parent (GST_PAD (writer)); GstElement *element = gst_pad_get_parent (GST_PAD (writer));
*writer_string = g_strdup_printf ("%s.%s", *writer_string = g_strdup_printf ("%s.%s",
g_type_name (G_OBJECT_TYPE (element)), gst_object_get_name (writer)); g_type_name (G_OBJECT_TYPE (element)), gst_object_get_name (writer));
} else { } else {
*writer_string = *writer_string =
g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer))); g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer)));
} }
return TRUE; return TRUE;
@ -563,10 +566,10 @@ gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id)
gboolean res; gboolean res;
res = res =
index->resolver (index, writer, &writer_string, index->resolver (index, writer, &writer_string,
index->resolver_user_data); index->resolver_user_data);
if (!res) if (!res)
return FALSE; return FALSE;
} else { } else {
g_warning ("no resolver found"); g_warning ("no resolver found");
return FALSE; return FALSE;
@ -800,7 +803,7 @@ gst_index_get_assoc_entry_full (GstIndex * index, gint id,
if (iclass->get_assoc_entry) if (iclass->get_assoc_entry)
return iclass->get_assoc_entry (index, id, method, flags, format, value, return iclass->get_assoc_entry (index, id, method, flags, format, value,
func, user_data); func, user_data);
return NULL; return NULL;
} }
@ -860,8 +863,9 @@ gst_index_factory_get_type (void)
(GInstanceInitFunc) gst_index_factory_init, (GInstanceInitFunc) gst_index_factory_init,
NULL NULL
}; };
indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstIndexFactory", &indexfactory_info, 0); "GstIndexFactory", &indexfactory_info, 0);
} }
return indexfactory_type; return indexfactory_type;
} }

View file

@ -33,9 +33,9 @@
#ifdef HAVE_PRINTF_EXTENSION #ifdef HAVE_PRINTF_EXTENSION
#include <printf.h> #include <printf.h>
#endif #endif
#include <stdio.h> /* fprintf */ #include <stdio.h> /* fprintf */
#include <unistd.h> #include <unistd.h>
#include <string.h> /* G_VA_COPY */ #include <string.h> /* G_VA_COPY */
#include "gstinfo.h" #include "gstinfo.h"
#include "gstlog.h" #include "gstlog.h"
#include "gst_private.h" #include "gst_private.h"
@ -58,7 +58,8 @@ typedef struct DL_INFO
int dli_version; int dli_version;
int dli_reserved1; int dli_reserved1;
long dli_reserved[4]; long dli_reserved[4];
} Dl_info; }
Dl_info;
#define _RLD_DLADDR 14 #define _RLD_DLADDR 14
int dladdr (void *address, Dl_info * dl); int dladdr (void *address, Dl_info * dl);
@ -100,7 +101,8 @@ typedef struct
{ {
GPatternSpec *pat; GPatternSpec *pat;
GstDebugLevel level; GstDebugLevel level;
} LevelNameEntry; }
LevelNameEntry;
/* list of all categories */ /* list of all categories */
static GStaticMutex __cat_mutex = G_STATIC_MUTEX_INIT; static GStaticMutex __cat_mutex = G_STATIC_MUTEX_INIT;
@ -111,7 +113,8 @@ typedef struct
{ {
GstLogFunction func; GstLogFunction func;
gpointer user_data; gpointer user_data;
} LogFuncEntry; }
LogFuncEntry;
static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT; static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
static GSList *__log_functions = NULL; static GSList *__log_functions = NULL;
@ -304,7 +307,7 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
entry = handler->data; entry = handler->data;
handler = g_slist_next (handler); handler = g_slist_next (handler);
entry->func (category, level, file, function, line, object, &message, entry->func (category, level, file, function, line, object, &message,
entry->user_data); entry->user_data);
} }
g_free (message.message); g_free (message.message);
va_end (message.arguments); va_end (message.arguments);
@ -402,7 +405,7 @@ gst_debug_construct_term_color (guint colorinfo)
} }
if (colorinfo & GST_DEBUG_BG_MASK) { if (colorinfo & GST_DEBUG_BG_MASK) {
g_string_append_printf (color, ";4%1d", g_string_append_printf (color, ";4%1d",
(colorinfo & GST_DEBUG_BG_MASK) >> 4); (colorinfo & GST_DEBUG_BG_MASK) >> 4);
} }
g_string_append (color, "m"); g_string_append (color, "m");
@ -448,8 +451,8 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level,
/* color info */ /* color info */
if (gst_debug_is_colored ()) { if (gst_debug_is_colored ()) {
color = color =
gst_debug_construct_term_color (gst_debug_category_get_color gst_debug_construct_term_color (gst_debug_category_get_color
(category)); (category));
clear = "\033[00m"; clear = "\033[00m";
pidcolor = g_strdup_printf ("\033[3%1dm", pid % 6 + 31); pidcolor = g_strdup_printf ("\033[3%1dm", pid % 6 + 31);
} else { } else {
@ -717,7 +720,7 @@ gst_debug_reset_threshold (gpointer category, gpointer unused)
walk = g_slist_next (walk); walk = g_slist_next (walk);
if (g_pattern_match_string (entry->pat, cat->name)) { if (g_pattern_match_string (entry->pat, cat->name)) {
GST_LOG ("category %s matches pattern %p - gets set to level %d", GST_LOG ("category %s matches pattern %p - gets set to level %d",
cat->name, entry->pat, entry->level); cat->name, entry->pat, entry->level);
gst_debug_category_set_threshold (cat, entry->level); gst_debug_category_set_threshold (cat, entry->level);
goto exit; goto exit;
} }
@ -742,7 +745,7 @@ for_each_threshold_by_entry (gpointer data, gpointer user_data)
if (g_pattern_match_string (entry->pat, cat->name)) { if (g_pattern_match_string (entry->pat, cat->name)) {
GST_LOG ("category %s matches pattern %p - gets set to level %d", GST_LOG ("category %s matches pattern %p - gets set to level %d",
cat->name, entry->pat, entry->level); cat->name, entry->pat, entry->level);
gst_debug_category_set_threshold (cat, entry->level); gst_debug_category_set_threshold (cat, entry->level);
} }
} }
@ -1076,7 +1079,7 @@ __cyg_profile_func_enter (void *this_fn, void *call_site)
site); site);
stack_trace = stack_trace =
g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)", g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)",
this_fn, name, call_site, site)); this_fn, name, call_site, site));
g_free (name); g_free (name);
g_free (site); g_free (site);

View file

@ -54,7 +54,7 @@ gst_implements_interface_get_type (void)
}; };
gst_interface_type = g_type_register_static (G_TYPE_INTERFACE, gst_interface_type = g_type_register_static (G_TYPE_INTERFACE,
"GstImplementsInterface", &gst_interface_info, 0); "GstImplementsInterface", &gst_interface_info, 0);
g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT); g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT);
} }
@ -97,11 +97,11 @@ gst_element_implements_interface (GstElement * element, GType iface_type)
GstImplementsInterfaceClass *ifclass; GstImplementsInterfaceClass *ifclass;
iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element), iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element),
iface_type, GstImplementsInterface); iface_type, GstImplementsInterface);
ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface); ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface);
if (ifclass->supported != NULL && if (ifclass->supported != NULL &&
ifclass->supported (iface, iface_type) == TRUE) { ifclass->supported (iface, iface_type) == TRUE) {
return TRUE; return TRUE;
} }
} }
@ -127,7 +127,7 @@ gst_implements_interface_cast (gpointer from, GType iface_type)
/* check cast, give warning+fail if it's invalid */ /* check cast, give warning+fail if it's invalid */
if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type, if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type,
GstImplementsInterface))) { GstImplementsInterface))) {
return NULL; return NULL;
} }
@ -135,7 +135,7 @@ gst_implements_interface_cast (gpointer from, GType iface_type)
* is actually implemented */ * is actually implemented */
if (GST_IS_ELEMENT (from)) { if (GST_IS_ELEMENT (from)) {
g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from), g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from),
iface_type), NULL); iface_type), NULL);
} }
return iface; return iface;

View file

@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include <string.h> /* memset */ #include <string.h> /* memset */
#include "gstlog.h" #include "gstlog.h"
#include "gstutils.h" #include "gstutils.h"
@ -32,8 +32,8 @@ typedef struct _GstMemChunkElement GstMemChunkElement;
struct _GstMemChunkElement struct _GstMemChunkElement
{ {
GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */ GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */
gpointer area; /* pointer to data areas */ gpointer area; /* pointer to data areas */
}; };
struct _GstMemChunk struct _GstMemChunk

View file

@ -113,9 +113,10 @@ gst_object_get_type (void)
(GInstanceInitFunc) gst_object_init, (GInstanceInitFunc) gst_object_init,
NULL NULL
}; };
_gst_object_type = _gst_object_type =
g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info,
G_TYPE_FLAG_ABSTRACT); G_TYPE_FLAG_ABSTRACT);
} }
return _gst_object_type; return _gst_object_type;
} }
@ -134,7 +135,7 @@ gst_object_class_init (GstObjectClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME,
g_param_spec_string ("name", "Name", "The name of the object", g_param_spec_string ("name", "Name", "The name of the object",
NULL, G_PARAM_READWRITE)); NULL, G_PARAM_READWRITE));
gst_object_signals[PARENT_SET] = gst_object_signals[PARENT_SET] =
g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -361,11 +362,11 @@ gst_object_dispatch_properties_changed (GObject * object,
/* need own category? */ /* need own category? */
for (i = 0; i < n_pspecs; i++) { for (i = 0; i < n_pspecs; i++) {
GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)", GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)",
GST_OBJECT_NAME (object), GST_OBJECT_NAME (gst_object), GST_OBJECT_NAME (object), GST_OBJECT_NAME (gst_object),
pspecs[i]->name); pspecs[i]->name);
g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY], g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY],
g_quark_from_string (pspecs[i]->name), (GstObject *) object, g_quark_from_string (pspecs[i]->name), (GstObject *) object,
pspecs[i]); pspecs[i]);
} }
gst_object = GST_OBJECT_PARENT (gst_object); gst_object = GST_OBJECT_PARENT (gst_object);
@ -390,7 +391,7 @@ void
gst_object_default_deep_notify (GObject * object, GstObject * orig, gst_object_default_deep_notify (GObject * object, GstObject * orig,
GParamSpec * pspec, gchar ** excluded_props) GParamSpec * pspec, gchar ** excluded_props)
{ {
GValue value = { 0, }; /* the important thing is that value.type = 0 */ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0; gchar *str = 0;
gchar *name = NULL; gchar *name = NULL;
@ -398,7 +399,7 @@ gst_object_default_deep_notify (GObject * object, GstObject * orig,
/* let's not print these out for excluded properties... */ /* let's not print these out for excluded properties... */
while (excluded_props != NULL && *excluded_props != NULL) { while (excluded_props != NULL && *excluded_props != NULL) {
if (strcmp (pspec->name, *excluded_props) == 0) if (strcmp (pspec->name, *excluded_props) == 0)
return; return;
excluded_props++; excluded_props++;
} }
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
@ -408,11 +409,11 @@ gst_object_default_deep_notify (GObject * object, GstObject * orig,
GEnumValue *enum_value; GEnumValue *enum_value;
enum_value = enum_value =
g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)), g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)),
g_value_get_enum (&value)); g_value_get_enum (&value));
str = g_strdup_printf ("%s (%d)", enum_value->value_nick, str = g_strdup_printf ("%s (%d)", enum_value->value_nick,
enum_value->value); enum_value->value);
} else { } else {
str = g_strdup_value_contents (&value); str = g_strdup_value_contents (&value);
} }
@ -443,7 +444,7 @@ gst_object_set_name_default (GstObject * object)
if (!object_name_counts) { if (!object_name_counts) {
object_name_counts = g_hash_table_new_full (g_str_hash, g_str_equal, object_name_counts = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL); g_free, NULL);
} }
count = GPOINTER_TO_INT (g_hash_table_lookup (object_name_counts, type_name)); count = GPOINTER_TO_INT (g_hash_table_lookup (object_name_counts, type_name));
@ -785,7 +786,7 @@ struct _GstSignalObjectClass
#ifndef GST_DISABLE_LOADSAVE_REGISTRY #ifndef GST_DISABLE_LOADSAVE_REGISTRY
void (*object_loaded) (GstSignalObject * object, GstObject * new, void (*object_loaded) (GstSignalObject * object, GstObject * new,
xmlNodePtr self); xmlNodePtr self);
#endif /* GST_DISABLE_LOADSAVE_REGISTRY */ #endif /* GST_DISABLE_LOADSAVE_REGISTRY */
}; };
static GType static GType
@ -806,9 +807,10 @@ gst_signal_object_get_type (void)
(GInstanceInitFunc) gst_signal_object_init, (GInstanceInitFunc) gst_signal_object_init,
NULL NULL
}; };
signal_object_type = signal_object_type =
g_type_register_static (G_TYPE_OBJECT, "GstSignalObject", g_type_register_static (G_TYPE_OBJECT, "GstSignalObject",
&signal_object_info, 0); &signal_object_info, 0);
} }
return signal_object_type; return signal_object_type;
} }

View file

@ -77,8 +77,9 @@ gst_pad_get_type (void)
32, 32,
(GInstanceInitFunc) gst_pad_init, NULL (GInstanceInitFunc) gst_pad_init, NULL
}; };
_gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad", _gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad",
&pad_info, 0); &pad_info, 0);
} }
return _gst_pad_type; return _gst_pad_type;
} }
@ -158,8 +159,9 @@ gst_real_pad_get_type (void)
32, 32,
(GInstanceInitFunc) gst_real_pad_init, NULL (GInstanceInitFunc) gst_real_pad_init, NULL
}; };
_gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad", _gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad",
&pad_info, 0); &pad_info, 0);
} }
return _gst_real_pad_type; return _gst_real_pad_type;
} }
@ -198,10 +200,10 @@ gst_real_pad_class_init (GstRealPadClass * klass)
/* GTK_ARG_READWRITE, REAL_ARG_ACTIVE); */ /* GTK_ARG_READWRITE, REAL_ARG_ACTIVE); */
g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_ACTIVE, g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_ACTIVE,
g_param_spec_boolean ("active", "Active", "Whether the pad is active.", g_param_spec_boolean ("active", "Active", "Whether the pad is active.",
TRUE, G_PARAM_READWRITE)); TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_CAPS, g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_CAPS,
g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad", g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad",
GST_TYPE_CAPS, G_PARAM_READABLE)); GST_TYPE_CAPS, G_PARAM_READABLE));
#ifndef GST_DISABLE_LOADSAVE #ifndef GST_DISABLE_LOADSAVE
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_pad_save_thyself); gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_pad_save_thyself);
@ -422,11 +424,11 @@ gst_pad_set_active (GstPad * pad, gboolean active)
if (active) { if (active) {
GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s", GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s",
GST_DEBUG_PAD_NAME (realpad)); GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_UNSET (realpad, GST_PAD_DISABLED); GST_FLAG_UNSET (realpad, GST_PAD_DISABLED);
} else { } else {
GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s", GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s",
GST_DEBUG_PAD_NAME (realpad)); GST_DEBUG_PAD_NAME (realpad));
GST_FLAG_SET (realpad, GST_PAD_DISABLED); GST_FLAG_SET (realpad, GST_PAD_DISABLED);
} }
@ -1104,13 +1106,13 @@ gst_pad_link_ready_for_negotiation (GstPadLink * link)
parent = GST_PAD_PARENT (link->srcpad); parent = GST_PAD_PARENT (link->srcpad);
if (!parent || GST_STATE (parent) < GST_STATE_READY) { if (!parent || GST_STATE (parent) < GST_STATE_READY) {
GST_DEBUG ("parent %s of pad %s:%s is not READY", GST_DEBUG ("parent %s of pad %s:%s is not READY",
GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad)); GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad));
return FALSE; return FALSE;
} }
parent = GST_PAD_PARENT (link->sinkpad); parent = GST_PAD_PARENT (link->sinkpad);
if (!parent || GST_STATE (parent) < GST_STATE_READY) { if (!parent || GST_STATE (parent) < GST_STATE_READY) {
GST_DEBUG ("parent %s of pad %s:%s is not READY", GST_DEBUG ("parent %s of pad %s:%s is not READY",
GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad)); GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad));
return FALSE; return FALSE;
} }
@ -1136,48 +1138,48 @@ gst_pad_link_fixate (GstPadLink * link)
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
newcaps = NULL; newcaps = NULL;
switch (i) { switch (i) {
case 0: case 0:
g_signal_emit (G_OBJECT (link->srcpad), g_signal_emit (G_OBJECT (link->srcpad),
gst_real_pad_signals[REAL_FIXATE], 0, caps, &newcaps); gst_real_pad_signals[REAL_FIXATE], 0, caps, &newcaps);
GST_DEBUG ("app srcpad signal fixated to %" GST_PTR_FORMAT, newcaps); GST_DEBUG ("app srcpad signal fixated to %" GST_PTR_FORMAT, newcaps);
break; break;
case 1: case 1:
g_signal_emit (G_OBJECT (link->sinkpad), g_signal_emit (G_OBJECT (link->sinkpad),
gst_real_pad_signals[REAL_FIXATE], 0, caps, &newcaps); gst_real_pad_signals[REAL_FIXATE], 0, caps, &newcaps);
GST_DEBUG ("app sinkpad signal fixated to %" GST_PTR_FORMAT, newcaps); GST_DEBUG ("app sinkpad signal fixated to %" GST_PTR_FORMAT, newcaps);
break; break;
case 2: case 2:
if (GST_RPAD_FIXATEFUNC (link->srcpad)) { if (GST_RPAD_FIXATEFUNC (link->srcpad)) {
newcaps = newcaps =
GST_RPAD_FIXATEFUNC (link->srcpad) (GST_PAD (link->srcpad), GST_RPAD_FIXATEFUNC (link->srcpad) (GST_PAD (link->srcpad),
caps); caps);
GST_DEBUG ("srcpad %s:%s fixated to %" GST_PTR_FORMAT, GST_DEBUG ("srcpad %s:%s fixated to %" GST_PTR_FORMAT,
GST_DEBUG_PAD_NAME (link->srcpad), newcaps); GST_DEBUG_PAD_NAME (link->srcpad), newcaps);
} else } else
GST_DEBUG ("srcpad %s:%s doesn't have a fixate function", GST_DEBUG ("srcpad %s:%s doesn't have a fixate function",
GST_DEBUG_PAD_NAME (link->srcpad)); GST_DEBUG_PAD_NAME (link->srcpad));
break; break;
case 3: case 3:
if (GST_RPAD_FIXATEFUNC (link->sinkpad)) { if (GST_RPAD_FIXATEFUNC (link->sinkpad)) {
newcaps = newcaps =
GST_RPAD_FIXATEFUNC (link->sinkpad) (GST_PAD (link->sinkpad), GST_RPAD_FIXATEFUNC (link->sinkpad) (GST_PAD (link->sinkpad),
caps); caps);
GST_DEBUG ("sinkpad %s:%s fixated to %" GST_PTR_FORMAT, GST_DEBUG ("sinkpad %s:%s fixated to %" GST_PTR_FORMAT,
GST_DEBUG_PAD_NAME (link->sinkpad), newcaps); GST_DEBUG_PAD_NAME (link->sinkpad), newcaps);
} else } else
GST_DEBUG ("sinkpad %s:%s doesn't have a fixate function", GST_DEBUG ("sinkpad %s:%s doesn't have a fixate function",
GST_DEBUG_PAD_NAME (link->sinkpad)); GST_DEBUG_PAD_NAME (link->sinkpad));
break; break;
case 4: case 4:
newcaps = _gst_pad_default_fixate_func (GST_PAD (link->srcpad), caps); newcaps = _gst_pad_default_fixate_func (GST_PAD (link->srcpad), caps);
GST_DEBUG ("core fixated to %" GST_PTR_FORMAT, newcaps); GST_DEBUG ("core fixated to %" GST_PTR_FORMAT, newcaps);
break; break;
} }
if (newcaps) { if (newcaps) {
gst_caps_free (caps); gst_caps_free (caps);
caps = newcaps; caps = newcaps;
break; break;
} }
} }
} }
@ -1193,7 +1195,7 @@ gst_pad_link_call_link_functions (GstPadLink * link)
if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)) { if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)) {
GST_DEBUG ("calling link function on pad %s:%s", GST_DEBUG ("calling link function on pad %s:%s",
GST_DEBUG_PAD_NAME (link->srcpad)); GST_DEBUG_PAD_NAME (link->srcpad));
negotiating = GST_FLAG_IS_SET (link->srcpad, GST_PAD_NEGOTIATING); negotiating = GST_FLAG_IS_SET (link->srcpad, GST_PAD_NEGOTIATING);
@ -1209,18 +1211,18 @@ gst_pad_link_call_link_functions (GstPadLink * link)
GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING); GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING);
GST_DEBUG ("got reply %d from link function on pad %s:%s", GST_DEBUG ("got reply %d from link function on pad %s:%s",
res, GST_DEBUG_PAD_NAME (link->srcpad)); res, GST_DEBUG_PAD_NAME (link->srcpad));
if (GST_PAD_LINK_FAILED (res)) { if (GST_PAD_LINK_FAILED (res)) {
GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps",
GST_DEBUG_PAD_NAME (link->srcpad)); GST_DEBUG_PAD_NAME (link->srcpad));
return res; return res;
} }
} }
if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)) { if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)) {
GST_DEBUG ("calling link function on pad %s:%s", GST_DEBUG ("calling link function on pad %s:%s",
GST_DEBUG_PAD_NAME (link->sinkpad)); GST_DEBUG_PAD_NAME (link->sinkpad));
negotiating = GST_FLAG_IS_SET (link->sinkpad, GST_PAD_NEGOTIATING); negotiating = GST_FLAG_IS_SET (link->sinkpad, GST_PAD_NEGOTIATING);
@ -1230,18 +1232,18 @@ gst_pad_link_call_link_functions (GstPadLink * link)
/* call the link function */ /* call the link function */
res = GST_RPAD_LINKFUNC (link->sinkpad) (GST_PAD (link->sinkpad), res = GST_RPAD_LINKFUNC (link->sinkpad) (GST_PAD (link->sinkpad),
link->caps); link->caps);
/* unset again after negotiating only if we set it */ /* unset again after negotiating only if we set it */
if (!negotiating) if (!negotiating)
GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING); GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING);
GST_DEBUG ("got reply %d from link function on pad %s:%s", GST_DEBUG ("got reply %d from link function on pad %s:%s",
res, GST_DEBUG_PAD_NAME (link->sinkpad)); res, GST_DEBUG_PAD_NAME (link->sinkpad));
if (GST_PAD_LINK_FAILED (res)) { if (GST_PAD_LINK_FAILED (res)) {
GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps",
GST_DEBUG_PAD_NAME (link->sinkpad)); GST_DEBUG_PAD_NAME (link->sinkpad));
return res; return res;
} }
} }
@ -1406,10 +1408,10 @@ gst_pad_try_set_caps (GstPad * pad, const GstCaps * caps)
/* setting non-fixed caps on a pad is not allowed */ /* setting non-fixed caps on a pad is not allowed */
if (!gst_caps_is_fixed (caps)) { if (!gst_caps_is_fixed (caps)) {
GST_CAT_INFO (GST_CAT_CAPS, GST_CAT_INFO (GST_CAT_CAPS,
"trying to set unfixed caps on pad %s:%s, not allowed", "trying to set unfixed caps on pad %s:%s, not allowed",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
g_warning ("trying to set non fixed caps on pad %s:%s, not allowed", g_warning ("trying to set non fixed caps on pad %s:%s, not allowed",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
GST_DEBUG ("unfixed caps %" GST_PTR_FORMAT, caps); GST_DEBUG ("unfixed caps %" GST_PTR_FORMAT, caps);
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
@ -1564,33 +1566,33 @@ gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad,
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
} }
/* FIXME: shouldn't we convert this to g_return_val_if_fail? */ /* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_RPAD_PEER (realsrc) != NULL) { if (GST_RPAD_PEER (realsrc) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed", GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (GST_RPAD_PEER (realsink) != NULL) { if (GST_RPAD_PEER (realsink) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (realsink)); GST_DEBUG_PAD_NAME (realsink));
return FALSE; return FALSE;
} }
if (GST_PAD_PARENT (realsrc) == NULL) { if (GST_PAD_PARENT (realsrc) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed", GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (GST_PAD_PARENT (realsink) == NULL) { if (GST_PAD_PARENT (realsink) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (!gst_pad_check_schedulers (realsrc, realsink)) { if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires " g_warning ("linking pads with different scheds requires "
"exactly one decoupled element (such as queue)"); "exactly one decoupled element (such as queue)");
return FALSE; return FALSE;
} }
@ -1609,14 +1611,14 @@ gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad,
if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) { if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) {
GST_CAT_INFO (GST_CAT_PADS, GST_CAT_INFO (GST_CAT_PADS,
"Real src pad %s:%s is not a source pad, failed", "Real src pad %s:%s is not a source pad, failed",
GST_DEBUG_PAD_NAME (link->srcpad)); GST_DEBUG_PAD_NAME (link->srcpad));
gst_pad_link_free (link); gst_pad_link_free (link);
return FALSE; return FALSE;
} }
if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) { if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed",
GST_DEBUG_PAD_NAME (link->sinkpad)); GST_DEBUG_PAD_NAME (link->sinkpad));
gst_pad_link_free (link); gst_pad_link_free (link);
return FALSE; return FALSE;
} }
@ -1685,33 +1687,33 @@ gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad,
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
} }
/* FIXME: shouldn't we convert this to g_return_val_if_fail? */ /* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_RPAD_PEER (realsrc) != NULL) { if (GST_RPAD_PEER (realsrc) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed", GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (GST_RPAD_PEER (realsink) != NULL) { if (GST_RPAD_PEER (realsink) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (realsink)); GST_DEBUG_PAD_NAME (realsink));
return FALSE; return FALSE;
} }
if (GST_PAD_PARENT (realsrc) == NULL) { if (GST_PAD_PARENT (realsrc) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed", GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (GST_PAD_PARENT (realsink) == NULL) { if (GST_PAD_PARENT (realsink) == NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed",
GST_DEBUG_PAD_NAME (realsrc)); GST_DEBUG_PAD_NAME (realsrc));
return FALSE; return FALSE;
} }
if (!gst_pad_check_schedulers (realsrc, realsink)) { if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires " g_warning ("linking pads with different scheds requires "
"exactly one decoupled element (such as queue)"); "exactly one decoupled element (such as queue)");
return FALSE; return FALSE;
} }
@ -1730,14 +1732,14 @@ gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad,
if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) { if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) {
GST_CAT_INFO (GST_CAT_PADS, GST_CAT_INFO (GST_CAT_PADS,
"Real src pad %s:%s is not a source pad, failed", "Real src pad %s:%s is not a source pad, failed",
GST_DEBUG_PAD_NAME (link->srcpad)); GST_DEBUG_PAD_NAME (link->srcpad));
gst_pad_link_free (link); gst_pad_link_free (link);
return FALSE; return FALSE;
} }
if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) { if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) {
GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed", GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed",
GST_DEBUG_PAD_NAME (link->sinkpad)); GST_DEBUG_PAD_NAME (link->sinkpad));
gst_pad_link_free (link); gst_pad_link_free (link);
return FALSE; return FALSE;
} }
@ -1762,12 +1764,12 @@ gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad,
/* now tell the scheduler */ /* now tell the scheduler */
if (src_sched && src_sched == sink_sched) { if (src_sched && src_sched == sink_sched) {
gst_scheduler_pad_link (src_sched, gst_scheduler_pad_link (src_sched,
GST_PAD (link->srcpad), GST_PAD (link->sinkpad)); GST_PAD (link->srcpad), GST_PAD (link->sinkpad));
} else { } else {
GST_CAT_INFO (GST_CAT_PADS, GST_CAT_INFO (GST_CAT_PADS,
"not telling link to scheduler %s:%s and %s:%s, %p %p", "not telling link to scheduler %s:%s and %s:%s, %p %p",
GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad), GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad),
src_sched, sink_sched); src_sched, sink_sched);
} }
GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful", GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful",
@ -1838,7 +1840,7 @@ gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ)
if (templ) if (templ)
g_signal_emit (G_OBJECT (templ), g_signal_emit (G_OBJECT (templ),
gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad); gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
} }
/** /**
@ -1885,8 +1887,8 @@ gst_pad_get_scheduler (GstPad * pad)
GstRealPad *peer = GST_RPAD_PEER (pad); GstRealPad *peer = GST_RPAD_PEER (pad);
if (peer) { if (peer) {
scheduler = scheduler =
gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer))); gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer)));
} }
} else { } else {
scheduler = gst_element_get_scheduler (parent); scheduler = gst_element_get_scheduler (parent);
@ -1993,17 +1995,17 @@ _gst_pad_default_fixate_foreach (GQuark field_id, GValue * value, gpointer s)
if (type == GST_TYPE_INT_RANGE) { if (type == GST_TYPE_INT_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id), gst_structure_set (structure, g_quark_to_string (field_id),
G_TYPE_INT, gst_value_get_int_range_min (value), NULL); G_TYPE_INT, gst_value_get_int_range_min (value), NULL);
return FALSE; return FALSE;
} }
if (type == GST_TYPE_DOUBLE_RANGE) { if (type == GST_TYPE_DOUBLE_RANGE) {
gst_structure_set (structure, g_quark_to_string (field_id), gst_structure_set (structure, g_quark_to_string (field_id),
G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL); G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL);
return FALSE; return FALSE;
} }
if (type == GST_TYPE_LIST) { if (type == GST_TYPE_LIST) {
gst_structure_set_value (structure, g_quark_to_string (field_id), gst_structure_set_value (structure, g_quark_to_string (field_id),
gst_value_list_get_value (value, 0)); gst_value_list_get_value (value, 0));
return FALSE; return FALSE;
} }
@ -2028,7 +2030,7 @@ _gst_pad_default_fixate_func (GstPad * pad, const GstCaps * caps)
if (caps->structs->len > 1) { if (caps->structs->len > 1) {
return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps,
0)), NULL); 0)), NULL);
} }
newcaps = gst_caps_copy (caps); newcaps = gst_caps_copy (caps);
@ -2110,7 +2112,7 @@ gst_pad_link_prepare (GstPad * srcpad, GstPad * sinkpad,
if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) {
GST_CAT_DEBUG (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", GST_CAT_DEBUG (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink));
} }
g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL); g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL);
@ -2120,14 +2122,14 @@ gst_pad_link_prepare (GstPad * srcpad, GstPad * sinkpad,
if (!gst_pad_check_schedulers (realsrc, realsink)) { if (!gst_pad_check_schedulers (realsrc, realsink)) {
g_warning ("linking pads with different scheds requires " g_warning ("linking pads with different scheds requires "
"exactly one decoupled element (such as queue)"); "exactly one decoupled element (such as queue)");
return NULL; return NULL;
} }
if (GST_RPAD_DIRECTION (realsrc) == GST_RPAD_DIRECTION (realsink)) { if (GST_RPAD_DIRECTION (realsrc) == GST_RPAD_DIRECTION (realsink)) {
g_warning ("%s:%s and %s:%s are both %s pads, failed", g_warning ("%s:%s and %s:%s are both %s pads, failed",
GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink), GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink),
GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink"); GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink");
return NULL; return NULL;
} }
@ -2175,7 +2177,7 @@ gst_pad_try_relink_filtered (GstPad * srcpad, GstPad * sinkpad,
if (GST_RPAD_PEER (link->srcpad) != (GstRealPad *) link->sinkpad) { if (GST_RPAD_PEER (link->srcpad) != (GstRealPad *) link->sinkpad) {
g_warning ("Pads %s:%s and %s:%s were never linked", g_warning ("Pads %s:%s and %s:%s were never linked",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
gst_pad_link_free (link); gst_pad_link_free (link);
return FALSE; return FALSE;
} }
@ -2289,7 +2291,7 @@ gst_pad_proxy_pad_link (GstPad * pad, const GstCaps * caps)
if (otherpad != pad) { if (otherpad != pad) {
ret = gst_pad_try_set_caps (otherpad, caps); ret = gst_pad_try_set_caps (otherpad, caps);
if (GST_PAD_LINK_FAILED (ret)) { if (GST_PAD_LINK_FAILED (ret)) {
return ret; return ret;
} }
} }
pads = g_list_next (pads); pads = g_list_next (pads);
@ -2333,14 +2335,14 @@ gst_pad_proxy_fixate (GstPad * pad, const GstCaps * caps)
othercaps = gst_pad_get_negotiated_caps (otherpad); othercaps = gst_pad_get_negotiated_caps (otherpad);
if (othercaps) { if (othercaps) {
GstCaps *icaps; GstCaps *icaps;
icaps = gst_caps_intersect (othercaps, caps); icaps = gst_caps_intersect (othercaps, caps);
if (!gst_caps_is_empty (icaps)) { if (!gst_caps_is_empty (icaps)) {
return icaps; return icaps;
} else { } else {
gst_caps_free (icaps); gst_caps_free (icaps);
} }
} }
} }
pads = g_list_next (pads); pads = g_list_next (pads);
@ -2389,7 +2391,7 @@ gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps)
link_ret = gst_pad_try_set_caps (pad, caps); link_ret = gst_pad_try_set_caps (pad, caps);
if (link_ret == GST_PAD_LINK_REFUSED) { if (link_ret == GST_PAD_LINK_REFUSED) {
GST_ELEMENT_ERROR (gst_pad_get_parent (pad), CORE, PAD, (NULL), GST_ELEMENT_ERROR (gst_pad_get_parent (pad), CORE, PAD, (NULL),
("failed to negotiate (try_set_caps returned REFUSED)")); ("failed to negotiate (try_set_caps returned REFUSED)"));
return FALSE; return FALSE;
} }
@ -2530,8 +2532,8 @@ gst_pad_get_caps (GstPad * pad)
if (caps == NULL) { if (caps == NULL) {
g_critical ("pad %s:%s returned NULL caps from getcaps function\n", g_critical ("pad %s:%s returned NULL caps from getcaps function\n",
GST_ELEMENT_NAME (GST_PAD_PARENT (GST_PAD (realpad))), GST_ELEMENT_NAME (GST_PAD_PARENT (GST_PAD (realpad))),
GST_PAD_NAME (realpad)); GST_PAD_NAME (realpad));
caps = gst_caps_new_any (); caps = gst_caps_new_any ();
} }
@ -2542,15 +2544,15 @@ gst_pad_get_caps (GstPad * pad)
caps = GST_PAD_TEMPLATE_CAPS (templ); caps = GST_PAD_TEMPLATE_CAPS (templ);
GST_CAT_DEBUG (GST_CAT_CAPS, GST_CAT_DEBUG (GST_CAT_CAPS,
"using pad template %p with caps %" GST_PTR_FORMAT, templ, caps); "using pad template %p with caps %" GST_PTR_FORMAT, templ, caps);
#if 0 #if 0
/* FIXME we should enable something like this someday, but this is /* FIXME we should enable something like this someday, but this is
* a bit buggy */ * a bit buggy */
if (!gst_caps_is_fixed (caps)) { if (!gst_caps_is_fixed (caps)) {
g_warning g_warning
("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n", ("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n",
GST_DEBUG_PAD_NAME (realpad), realpad); GST_DEBUG_PAD_NAME (realpad), realpad);
} }
#endif #endif
@ -2644,16 +2646,16 @@ gst_pad_check_compatibility (GstPad * srcpad, GstPad * sinkpad)
if (GST_PAD_CAPS (srcpad) && GST_PAD_CAPS (sinkpad)) { if (GST_PAD_CAPS (srcpad) && GST_PAD_CAPS (sinkpad)) {
if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad), if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad),
GST_PAD_CAPS (sinkpad))) { GST_PAD_CAPS (sinkpad))) {
return FALSE; return FALSE;
} else { } else {
return TRUE; return TRUE;
} }
} else { } else {
GST_CAT_DEBUG (GST_CAT_PADS, GST_CAT_DEBUG (GST_CAT_PADS,
"could not check capabilities of pads (%s:%s) and (%s:%s) %p %p", "could not check capabilities of pads (%s:%s) and (%s:%s) %p %p",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad),
GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad)); GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad));
return TRUE; return TRUE;
} }
} }
@ -2778,9 +2780,9 @@ gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size)
if (peer->bufferallocfunc) { if (peer->bufferallocfunc) {
GST_CAT_DEBUG (GST_CAT_PADS, GST_CAT_DEBUG (GST_CAT_PADS,
"calling bufferallocfunc &%s (@%p) of peer pad %s:%s", "calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc), GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
&peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer))); &peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer)));
return (peer->bufferallocfunc) (GST_PAD (peer), offset, size); return (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
} else { } else {
return gst_buffer_new_and_alloc (size); return gst_buffer_new_and_alloc (size);
@ -2813,15 +2815,15 @@ gst_real_pad_dispose (GObject * object)
GstPad *ghostpad = GST_PAD (ghostpads->data); GstPad *ghostpad = GST_PAD (ghostpads->data);
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (ghostpad))) { if (GST_IS_ELEMENT (GST_OBJECT_PARENT (ghostpad))) {
GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad)); GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad));
GST_CAT_DEBUG (GST_CAT_REFCOUNTING, GST_CAT_DEBUG (GST_CAT_REFCOUNTING,
"removing ghost pad from element '%s'", GST_OBJECT_NAME (parent)); "removing ghost pad from element '%s'", GST_OBJECT_NAME (parent));
gst_element_remove_pad (parent, ghostpad); gst_element_remove_pad (parent, ghostpad);
} else { } else {
/* handle the case where we have some floating ghost pad that was never /* handle the case where we have some floating ghost pad that was never
added to an element */ added to an element */
g_object_set (ghostpad, "real-pad", NULL, NULL); g_object_set (ghostpad, "real-pad", NULL, NULL);
} }
ghostpads = g_list_next (ghostpads); ghostpads = g_list_next (ghostpads);
} }
@ -2833,14 +2835,14 @@ gst_real_pad_dispose (GObject * object)
if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad))) { if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad))) {
GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing pad from element '%s'", GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing pad from element '%s'",
GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad))))); GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad)))));
gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad); gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad);
} }
if (GST_RPAD_EXPLICIT_CAPS (pad)) { if (GST_RPAD_EXPLICIT_CAPS (pad)) {
GST_ERROR_OBJECT (pad, "still explicit caps %" GST_PTR_FORMAT " set", GST_ERROR_OBJECT (pad, "still explicit caps %" GST_PTR_FORMAT " set",
GST_RPAD_EXPLICIT_CAPS (pad)); GST_RPAD_EXPLICIT_CAPS (pad));
g_warning ("pad %p has still explicit caps set", pad); g_warning ("pad %p has still explicit caps set", pad);
gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL); gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL);
} }
@ -2871,7 +2873,7 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
while (field) { while (field) {
if (!strcmp (field->name, "name")) { if (!strcmp (field->name, "name")) {
pad = gst_element_get_pad (GST_ELEMENT (parent), pad = gst_element_get_pad (GST_ELEMENT (parent),
xmlNodeGetContent (field)); xmlNodeGetContent (field));
} else if (!strcmp (field->name, "peer")) { } else if (!strcmp (field->name, "peer")) {
peer = xmlNodeGetContent (field); peer = xmlNodeGetContent (field);
} }
@ -2886,8 +2888,8 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
if (split[0] == NULL || split[1] == NULL) { if (split[0] == NULL || split[1] == NULL) {
GST_CAT_DEBUG (GST_CAT_XML, GST_CAT_DEBUG (GST_CAT_XML,
"Could not parse peer '%s' for pad %s:%s, leaving unlinked", "Could not parse peer '%s' for pad %s:%s, leaving unlinked",
peer, GST_DEBUG_PAD_NAME (pad)); peer, GST_DEBUG_PAD_NAME (pad));
return; return;
} }
@ -2942,7 +2944,7 @@ gst_pad_save_thyself (GstObject * object, xmlNodePtr parent)
/* first check to see if the peer's parent's parent is the same */ /* first check to see if the peer's parent's parent is the same */
/* we just save it off */ /* we just save it off */
content = g_strdup_printf ("%s.%s", content = g_strdup_printf ("%s.%s",
GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer)); GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer));
xmlNewChild (parent, NULL, "peer", content); xmlNewChild (parent, NULL, "peer", content);
g_free (content); g_free (content);
} else } else
@ -3002,7 +3004,7 @@ gst_pad_push (GstPad * pad, GstData * data)
if (!GST_PAD_IS_LINKED (pad)) { if (!GST_PAD_IS_LINKED (pad)) {
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
"not pushing data %p as pad is unconnected", data); "not pushing data %p as pad is unconnected", data);
gst_data_unref (data); gst_data_unref (data);
return; return;
} }
@ -3012,33 +3014,33 @@ gst_pad_push (GstPad * pad, GstData * data)
if (!peer) { if (!peer) {
g_warning ("push on pad %s:%s but it is unlinked", g_warning ("push on pad %s:%s but it is unlinked",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
} else { } else {
if (!GST_IS_EVENT (data) && !GST_PAD_IS_ACTIVE (peer)) { if (!GST_IS_EVENT (data) && !GST_PAD_IS_ACTIVE (peer)) {
g_warning ("push on peer of pad %s:%s but peer is not active", g_warning ("push on peer of pad %s:%s but peer is not active",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
return; return;
} }
if (peer->chainhandler) { if (peer->chainhandler) {
if (data) { if (data) {
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
"calling chainhandler &%s of peer pad %s:%s", "calling chainhandler &%s of peer pad %s:%s",
GST_DEBUG_FUNCPTR_NAME (peer->chainhandler), GST_DEBUG_FUNCPTR_NAME (peer->chainhandler),
GST_DEBUG_PAD_NAME (GST_PAD (peer))); GST_DEBUG_PAD_NAME (GST_PAD (peer)));
if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
return; return;
(peer->chainhandler) (GST_PAD (peer), data); (peer->chainhandler) (GST_PAD (peer), data);
return; return;
} else { } else {
g_warning ("trying to push a NULL buffer on pad %s:%s", g_warning ("trying to push a NULL buffer on pad %s:%s",
GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (peer));
return; return;
} }
} else { } else {
g_warning ("internal error: push on pad %s:%s but it has no chainhandler", g_warning ("internal error: push on pad %s:%s but it has no chainhandler",
GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (peer));
} }
} }
/* clean up the mess here */ /* clean up the mess here */
@ -3069,31 +3071,31 @@ gst_pad_pull (GstPad * pad)
if (!peer) { if (!peer) {
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad))); ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad)));
} else { } else {
restart: restart:
if (peer->gethandler) { if (peer->gethandler) {
GstData *data; GstData *data;
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad,
"calling gethandler %s of peer pad %s:%s", "calling gethandler %s of peer pad %s:%s",
GST_DEBUG_FUNCPTR_NAME (peer->gethandler), GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_FUNCPTR_NAME (peer->gethandler), GST_DEBUG_PAD_NAME (peer));
data = (peer->gethandler) (GST_PAD (peer)); data = (peer->gethandler) (GST_PAD (peer));
if (data) { if (data) {
if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data))
goto restart; goto restart;
return data; return data;
} }
/* no null buffers allowed */ /* no null buffers allowed */
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad))); ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad)));
} else { } else {
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
("pull on pad %s:%s but the peer pad %s:%s has no gethandler", ("pull on pad %s:%s but the peer pad %s:%s has no gethandler",
GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer))); GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)));
} }
} }
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
@ -3199,9 +3201,10 @@ gst_pad_template_get_type (void)
32, 32,
(GInstanceInitFunc) gst_pad_template_init, NULL (GInstanceInitFunc) gst_pad_template_init, NULL
}; };
padtemplate_type = padtemplate_type =
g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate", g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate",
&padtemplate_info, 0); &padtemplate_info, 0);
} }
return padtemplate_type; return padtemplate_type;
} }
@ -3261,23 +3264,23 @@ name_is_valid (const gchar * name, GstPadPresence presence)
if (presence == GST_PAD_ALWAYS) { if (presence == GST_PAD_ALWAYS) {
if (strchr (name, '%')) { if (strchr (name, '%')) {
g_warning ("invalid name template %s: conversion specifications are not" g_warning ("invalid name template %s: conversion specifications are not"
" allowed for GST_PAD_ALWAYS padtemplates", name); " allowed for GST_PAD_ALWAYS padtemplates", name);
return FALSE; return FALSE;
} }
} else if (presence == GST_PAD_REQUEST) { } else if (presence == GST_PAD_REQUEST) {
if ((str = strchr (name, '%')) && strchr (str + 1, '%')) { if ((str = strchr (name, '%')) && strchr (str + 1, '%')) {
g_warning ("invalid name template %s: only one conversion specification" g_warning ("invalid name template %s: only one conversion specification"
" allowed in GST_PAD_REQUEST padtemplate", name); " allowed in GST_PAD_REQUEST padtemplate", name);
return FALSE; return FALSE;
} }
if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) { if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) {
g_warning ("invalid name template %s: conversion specification must be of" g_warning ("invalid name template %s: conversion specification must be of"
" type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name); " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name);
return FALSE; return FALSE;
} }
if (str && (*(str + 2) != '\0')) { if (str && (*(str + 2) != '\0')) {
g_warning ("invalid name template %s: conversion specification must" g_warning ("invalid name template %s: conversion specification must"
" appear at the end of the GST_PAD_REQUEST padtemplate name", name); " appear at the end of the GST_PAD_REQUEST padtemplate name", name);
return FALSE; return FALSE;
} }
} }
@ -3438,8 +3441,9 @@ gst_ghost_pad_get_type (void)
(GInstanceInitFunc) gst_ghost_pad_init, (GInstanceInitFunc) gst_ghost_pad_init,
NULL NULL
}; };
_gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad", _gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad",
&pad_info, 0); &pad_info, 0);
} }
return _gst_ghost_pad_type; return _gst_ghost_pad_type;
} }
@ -3459,7 +3463,7 @@ gst_ghost_pad_class_init (GstGhostPadClass * klass)
g_object_class_install_property (gobject_class, GPAD_ARG_REAL_PAD, g_object_class_install_property (gobject_class, GPAD_ARG_REAL_PAD,
g_param_spec_object ("real-pad", "Real pad", g_param_spec_object ("real-pad", "Real pad",
"The real pad for the ghost pad", GST_TYPE_PAD, G_PARAM_READWRITE)); "The real pad for the ghost pad", GST_TYPE_PAD, G_PARAM_READWRITE));
} }
static void static void
@ -3489,14 +3493,14 @@ gst_ghost_pad_set_property (GObject * object, guint prop_id,
realpad = g_value_get_object (value); realpad = g_value_get_object (value);
if (oldrealpad) { if (oldrealpad) {
if (realpad == oldrealpad) if (realpad == oldrealpad)
return; return;
else else
gst_pad_remove_ghost_pad (oldrealpad, ghostpad); gst_pad_remove_ghost_pad (oldrealpad, ghostpad);
} }
if (realpad) if (realpad)
gst_pad_add_ghost_pad (realpad, ghostpad); gst_pad_add_ghost_pad (realpad, ghostpad);
break; break;
default: default:
@ -3633,16 +3637,16 @@ gst_pad_event_default_dispatch (GstPad * pad, GstElement * element,
/* for all of the internally-linked pads that are actually linked */ /* for all of the internally-linked pads that are actually linked */
if (GST_PAD_IS_LINKED (eventpad)) { if (GST_PAD_IS_LINKED (eventpad)) {
if (GST_PAD_DIRECTION (eventpad) == GST_PAD_SRC) { if (GST_PAD_DIRECTION (eventpad) == GST_PAD_SRC) {
/* increase the refcount */ /* increase the refcount */
gst_event_ref (event); gst_event_ref (event);
gst_pad_push (eventpad, GST_DATA (event)); gst_pad_push (eventpad, GST_DATA (event));
} else { } else {
GstPad *peerpad = GST_PAD (GST_RPAD_PEER (eventpad)); GstPad *peerpad = GST_PAD (GST_RPAD_PEER (eventpad));
/* we only send the event on one pad, multi-sinkpad elements /* we only send the event on one pad, multi-sinkpad elements
* should implement a handler */ * should implement a handler */
g_list_free (orig); g_list_free (orig);
return gst_pad_send_event (peerpad, event); return gst_pad_send_event (peerpad, event);
} }
} }
} }
@ -3684,24 +3688,24 @@ gst_pad_event_default (GstPad * pad, GstEvent * event)
guint64 time; guint64 time;
if (gst_element_requires_clock (element) && element->clock) { if (gst_element_requires_clock (element) && element->clock) {
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) { if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) {
gst_element_set_time (element, time); gst_element_set_time (element, time);
} else { } else {
GstFormat format = GST_FORMAT_TIME; GstFormat format = GST_FORMAT_TIME;
guint i; guint i;
for (i = 0; i < event->event_data.discont.noffsets; i++) { for (i = 0; i < event->event_data.discont.noffsets; i++) {
if (gst_pad_convert (pad, if (gst_pad_convert (pad,
event->event_data.discont.offsets[i].format, event->event_data.discont.offsets[i].format,
event->event_data.discont.offsets[i].value, &format, event->event_data.discont.offsets[i].value, &format,
&time)) { &time)) {
gst_element_set_time (element, time); gst_element_set_time (element, time);
} else if (i == event->event_data.discont.noffsets) { } else if (i == event->event_data.discont.noffsets) {
g_warning g_warning
("can't adjust clock to new time when time not provided"); ("can't adjust clock to new time when time not provided");
} }
} }
} }
} }
} }
default: default:
@ -3742,7 +3746,7 @@ gst_pad_dispatcher (GstPad * pad, GstPadDispatcherFunction dispatch,
if (int_peer) { if (int_peer) {
res = dispatch (GST_PAD (int_peer), data); res = dispatch (GST_PAD (int_peer), data);
if (res) if (res)
break; break;
} }
int_pads = g_list_next (int_pads); int_pads = g_list_next (int_pads);
} }
@ -3794,7 +3798,8 @@ typedef struct
gint64 src_value; gint64 src_value;
GstFormat *dest_format; GstFormat *dest_format;
gint64 *dest_value; gint64 *dest_value;
} GstPadConvertData; }
GstPadConvertData;
static gboolean static gboolean
gst_pad_convert_dispatcher (GstPad * pad, GstPadConvertData * data) gst_pad_convert_dispatcher (GstPad * pad, GstPadConvertData * data)
@ -3870,7 +3875,7 @@ gst_pad_convert (GstPad * pad,
if (GST_RPAD_CONVERTFUNC (rpad)) { if (GST_RPAD_CONVERTFUNC (rpad)) {
return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format, return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format,
src_value, dest_format, dest_value); src_value, dest_format, dest_value);
} }
return FALSE; return FALSE;
@ -3881,7 +3886,8 @@ typedef struct
GstQueryType type; GstQueryType type;
GstFormat *format; GstFormat *format;
gint64 *value; gint64 *value;
} GstPadQueryData; }
GstPadQueryData;
static gboolean static gboolean
gst_pad_query_dispatcher (GstPad * pad, GstPadQueryData * data) gst_pad_query_dispatcher (GstPad * pad, GstPadQueryData * data)

View file

@ -76,8 +76,9 @@ gst_pipeline_get_type (void)
gst_pipeline_init, gst_pipeline_init,
NULL NULL
}; };
pipeline_type = pipeline_type =
g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0); g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0);
} }
return pipeline_type; return pipeline_type;
} }
@ -122,8 +123,8 @@ gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
const gchar *name = gst_scheduler_factory_get_default_name (); const gchar *name = gst_scheduler_factory_get_default_name ();
g_error ("Critical error: could not get scheduler \"%s\"\n" g_error ("Critical error: could not get scheduler \"%s\"\n"
"Are you sure you have a registry ?\n" "Are you sure you have a registry ?\n"
"Run gst-register as root if you haven't done so yet.", name); "Run gst-register as root if you haven't done so yet.", name);
} }
} }
@ -168,7 +169,7 @@ gst_pipeline_change_state (GstElement * element)
* might not be in cothread 0 */ * might not be in cothread 0 */
#if 0 #if 0
if (GST_ELEMENT_SCHED (element)) { if (GST_ELEMENT_SCHED (element)) {
gst_scheduler_reset (GST_ELEMENT_SCHED (element)); gst_scheduler_reset (GST_ELEMENT_SCHED (element));
} }
#endif #endif
break; break;

View file

@ -43,7 +43,7 @@ static GList *_gst_plugin_static = NULL;
/* static variables for segfault handling of plugin loading */ /* static variables for segfault handling of plugin loading */
static char *_gst_plugin_fault_handler_filename = NULL; static char *_gst_plugin_fault_handler_filename = NULL;
extern gboolean *_gst_disable_segtrap; /* see gst.c */ extern gboolean *_gst_disable_segtrap; /* see gst.c */
static gboolean *_gst_plugin_fault_handler_is_setup = FALSE; static gboolean *_gst_plugin_fault_handler_is_setup = FALSE;
/* list of valid licenses. /* list of valid licenses.
@ -56,11 +56,11 @@ static gboolean *_gst_plugin_fault_handler_is_setup = FALSE;
* QPL: http://www.trolltech.com/licenses/qpl.html * QPL: http://www.trolltech.com/licenses/qpl.html
*/ */
static gchar *valid_licenses[] = { static gchar *valid_licenses[] = {
"LGPL", /* GNU Lesser General Public License */ "LGPL", /* GNU Lesser General Public License */
"GPL", /* GNU General Public License */ "GPL", /* GNU General Public License */
"QPL", /* Trolltech Qt Public License */ "QPL", /* Trolltech Qt Public License */
"GPL/QPL", /* Combi-license of GPL + QPL */ "GPL/QPL", /* Combi-license of GPL + QPL */
GST_LICENSE_UNKNOWN, /* some other license */ GST_LICENSE_UNKNOWN, /* some other license */
NULL NULL
}; };
@ -83,7 +83,7 @@ gst_plugin_get_type (void)
if (plugin_type == 0) { if (plugin_type == 0) {
plugin_type = g_boxed_type_register_static ("GstPlugin", plugin_type = g_boxed_type_register_static ("GstPlugin",
(GBoxedCopyFunc) gst_plugin_copy, g_free); (GBoxedCopyFunc) gst_plugin_copy, g_free);
} }
return plugin_type; return plugin_type;
@ -111,7 +111,7 @@ _gst_plugin_register_static (GstPluginDesc * desc)
if (main_module == NULL) { if (main_module == NULL) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_LOG ("queueing static plugin \"%s\" for loading later on", GST_LOG ("queueing static plugin \"%s\" for loading later on",
desc->name); desc->name);
_gst_plugin_static = g_list_prepend (_gst_plugin_static, desc); _gst_plugin_static = g_list_prepend (_gst_plugin_static, desc);
} else { } else {
GstPlugin *plugin; GstPlugin *plugin;
@ -121,7 +121,7 @@ _gst_plugin_register_static (GstPluginDesc * desc)
plugin = g_new0 (GstPlugin, 1); plugin = g_new0 (GstPlugin, 1);
if (gst_plugin_register_func (plugin, main_module, desc)) { if (gst_plugin_register_func (plugin, main_module, desc)) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_INFO ("loaded static plugin \"%s\"", desc->name); GST_INFO ("loaded static plugin \"%s\"", desc->name);
gst_registry_pool_add_plugin (plugin); gst_registry_pool_add_plugin (plugin);
} }
} }
@ -176,21 +176,21 @@ gst_plugin_register_func (GstPlugin * plugin, GModule * module,
if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) { if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_INFO ("plugin \"%s\" has incompatible version, not loading", GST_INFO ("plugin \"%s\" has incompatible version, not loading",
plugin->filename); plugin->filename);
return FALSE; return FALSE;
} }
if (!desc->license || !desc->description || !desc->package || !desc->origin) { if (!desc->license || !desc->description || !desc->package || !desc->origin) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading", GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading",
plugin->filename); plugin->filename);
return FALSE; return FALSE;
} }
if (!gst_plugin_check_license (desc->license)) { if (!gst_plugin_check_license (desc->license)) {
if (GST_CAT_DEFAULT) if (GST_CAT_DEFAULT)
GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading", GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading",
plugin->filename, desc->license); plugin->filename, desc->license);
return FALSE; return FALSE;
} }
@ -300,15 +300,15 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
if (g_module_supported () == FALSE) { if (g_module_supported () == FALSE) {
g_set_error (error, g_set_error (error,
GST_PLUGIN_ERROR, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported"); GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported");
return NULL; return NULL;
} }
if (stat (filename, &file_status)) { if (stat (filename, &file_status)) {
g_set_error (error, g_set_error (error,
GST_PLUGIN_ERROR, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, "Problem opening file %s\n", filename); GST_PLUGIN_ERROR_MODULE, "Problem opening file %s\n", filename);
return NULL; return NULL;
} }
@ -322,40 +322,40 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
plugin = gst_registry_pool_find_plugin (desc->name); plugin = gst_registry_pool_find_plugin (desc->name);
if (!plugin) { if (!plugin) {
free_plugin = TRUE; free_plugin = TRUE;
plugin = g_new0 (GstPlugin, 1); plugin = g_new0 (GstPlugin, 1);
plugin->filename = g_strdup (filename); plugin->filename = g_strdup (filename);
GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin,
filename); filename);
} else { } else {
free_plugin = FALSE; free_plugin = FALSE;
if (gst_plugin_is_loaded (plugin)) { if (gst_plugin_is_loaded (plugin)) {
if (strcmp (plugin->filename, filename) != 0) { if (strcmp (plugin->filename, filename) != 0) {
GST_WARNING GST_WARNING
("plugin %p from file \"%s\" with same name %s is already " ("plugin %p from file \"%s\" with same name %s is already "
"loaded, aborting loading of \"%s\"", plugin, plugin->filename, "loaded, aborting loading of \"%s\"", plugin, plugin->filename,
plugin->desc.name, filename); plugin->desc.name, filename);
g_set_error (error, GST_PLUGIN_ERROR, g_set_error (error, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_NAME_MISMATCH, GST_PLUGIN_ERROR_NAME_MISMATCH,
"already a plugin with name \"%s\" loaded", desc->name); "already a plugin with name \"%s\" loaded", desc->name);
if (free_plugin) if (free_plugin)
g_free (plugin); g_free (plugin);
return NULL; return NULL;
} }
GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now",
plugin, filename); plugin, filename);
return plugin; return plugin;
} }
} }
GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...",
plugin, filename); plugin, filename);
if (g_module_symbol (module, "plugin_init", &ptr)) { if (g_module_symbol (module, "plugin_init", &ptr)) {
g_print g_print
("plugin %p from file \"%s\" exports a symbol named plugin_init\n", ("plugin %p from file \"%s\" exports a symbol named plugin_init\n",
plugin, plugin->filename); plugin, plugin->filename);
g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_NAME_MISMATCH, g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_NAME_MISMATCH,
"plugin \"%s\" exports a symbol named plugin_init", desc->name); "plugin \"%s\" exports a symbol named plugin_init", desc->name);
} }
/* this is where we load the actual .so, so let's trap SIGSEGV */ /* this is where we load the actual .so, so let's trap SIGSEGV */
@ -363,38 +363,38 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
_gst_plugin_fault_handler_filename = plugin->filename; _gst_plugin_fault_handler_filename = plugin->filename;
if (gst_plugin_register_func (plugin, module, desc)) { if (gst_plugin_register_func (plugin, module, desc)) {
/* remove signal handler */ /* remove signal handler */
_gst_plugin_fault_handler_restore (); _gst_plugin_fault_handler_restore ();
_gst_plugin_fault_handler_filename = NULL; _gst_plugin_fault_handler_filename = NULL;
GST_INFO ("plugin \"%s\" loaded", plugin->filename); GST_INFO ("plugin \"%s\" loaded", plugin->filename);
return plugin; return plugin;
} else { } else {
/* remove signal handler */ /* remove signal handler */
_gst_plugin_fault_handler_restore (); _gst_plugin_fault_handler_restore ();
GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"", GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"",
filename); filename);
/* plugin == NULL */ /* plugin == NULL */
g_set_error (error, g_set_error (error,
GST_PLUGIN_ERROR, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, GST_PLUGIN_ERROR_MODULE,
"gst_plugin_register_func failed for plugin \"%s\"", filename); "gst_plugin_register_func failed for plugin \"%s\"", filename);
if (free_plugin) if (free_plugin)
g_free (plugin); g_free (plugin);
return NULL; return NULL;
} }
} else { } else {
GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename); GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
g_set_error (error, g_set_error (error,
GST_PLUGIN_ERROR, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, GST_PLUGIN_ERROR_MODULE,
"Could not find plugin entry point in \"%s\"", filename); "Could not find plugin entry point in \"%s\"", filename);
} }
return NULL; return NULL;
} else { } else {
GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename, GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename,
g_module_error ()); g_module_error ());
g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE, g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE,
"Error loading plugin %s, reason: %s\n", filename, g_module_error ()); "Error loading plugin %s, reason: %s\n", filename, g_module_error ());
return NULL; return NULL;
} }
} }
@ -454,11 +454,11 @@ gst_plugin_unload_plugin (GstPlugin * plugin)
if (g_module_close (plugin->module)) { if (g_module_close (plugin->module)) {
plugin->module = NULL; plugin->module = NULL;
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded", GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded",
plugin->filename); plugin->filename);
return TRUE; return TRUE;
} else { } else {
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"", GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"",
plugin->filename); plugin->filename);
return FALSE; return FALSE;
} }
} }

View file

@ -54,9 +54,10 @@ gst_plugin_feature_get_type (void)
(GInstanceInitFunc) gst_plugin_feature_init, (GInstanceInitFunc) gst_plugin_feature_init,
NULL NULL
}; };
plugin_feature_type = plugin_feature_type =
g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature", g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature",
&plugin_feature_info, G_TYPE_FLAG_ABSTRACT); &plugin_feature_info, G_TYPE_FLAG_ABSTRACT);
} }
return plugin_feature_type; return plugin_feature_type;
} }
@ -100,11 +101,11 @@ gst_plugin_feature_ensure_loaded (GstPluginFeature * feature)
#ifndef GST_DISABLE_REGISTRY #ifndef GST_DISABLE_REGISTRY
if (GST_IS_REGISTRY (plugin->manager)) { if (GST_IS_REGISTRY (plugin->manager)) {
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING,
"loading plugin %s for feature", plugin->desc.name); "loading plugin %s for feature", plugin->desc.name);
if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager),
plugin) != GST_REGISTRY_OK) plugin) != GST_REGISTRY_OK)
return FALSE; return FALSE;
} else } else
#endif /* GST_DISABLE_REGISTRY */ #endif /* GST_DISABLE_REGISTRY */
return FALSE; return FALSE;
@ -139,7 +140,7 @@ gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
{ {
return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) && return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
(data->name == NULL (data->name == NULL
|| !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature)))); || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
} }
/** /**

View file

@ -29,7 +29,7 @@
static GList *_gst_queries = NULL; static GList *_gst_queries = NULL;
static GHashTable *_nick_to_query = NULL; static GHashTable *_nick_to_query = NULL;
static GHashTable *_query_type_to_nick = NULL; static GHashTable *_query_type_to_nick = NULL;
static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */ static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */
static GstQueryTypeDefinition standard_definitions[] = { static GstQueryTypeDefinition standard_definitions[] = {
{GST_QUERY_TOTAL, "total", "Total length"}, {GST_QUERY_TOTAL, "total", "Total length"},
@ -55,7 +55,7 @@ _gst_query_type_initialize (void)
while (standards->nick) { while (standards->nick) {
g_hash_table_insert (_nick_to_query, standards->nick, standards); g_hash_table_insert (_nick_to_query, standards->nick, standards);
g_hash_table_insert (_query_type_to_nick, g_hash_table_insert (_query_type_to_nick,
GINT_TO_POINTER (standards->value), standards); GINT_TO_POINTER (standards->value), standards);
_gst_queries = g_list_append (_gst_queries, standards); _gst_queries = g_list_append (_gst_queries, standards);
standards++; standards++;

View file

@ -69,7 +69,8 @@ typedef struct _GstQueueEventResponse
{ {
GstEvent *event; GstEvent *event;
gboolean ret, handled; gboolean ret, handled;
} GstQueueEventResponse; }
GstQueueEventResponse;
static void gst_queue_base_init (GstQueueClass * klass); static void gst_queue_base_init (GstQueueClass * klass);
static void gst_queue_class_init (GstQueueClass * klass); static void gst_queue_class_init (GstQueueClass * klass);
@ -106,6 +107,7 @@ queue_leaky_get_type (void)
{GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"}, {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!queue_leaky_type) { if (!queue_leaky_type) {
queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky); queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
} }
@ -135,7 +137,7 @@ gst_queue_get_type (void)
}; };
queue_type = g_type_register_static (GST_TYPE_ELEMENT, queue_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstQueue", &queue_info, 0); "GstQueue", &queue_info, 0);
} }
return queue_type; return queue_type;
@ -174,56 +176,56 @@ gst_queue_class_init (GstQueueClass * klass)
/* properties */ /* properties */
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES,
g_param_spec_uint ("current-level-bytes", "Current level (kB)", g_param_spec_uint ("current-level-bytes", "Current level (kB)",
"Current amount of data in the queue (bytes)", "Current amount of data in the queue (bytes)",
0, G_MAXUINT, 0, G_PARAM_READABLE)); 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS,
g_param_spec_uint ("current-level-buffers", "Current level (buffers)", g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
"Current number of buffers in the queue", "Current number of buffers in the queue",
0, G_MAXUINT, 0, G_PARAM_READABLE)); 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME,
g_param_spec_uint64 ("current-level-time", "Current level (ns)", g_param_spec_uint64 ("current-level-time", "Current level (ns)",
"Current amount of data in the queue (in ns)", "Current amount of data in the queue (in ns)",
0, G_MAXUINT64, 0, G_PARAM_READABLE)); 0, G_MAXUINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES,
g_param_spec_uint ("max-size-bytes", "Max. size (kB)", g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
"Max. amount of data in the queue (bytes, 0=disable)", "Max. amount of data in the queue (bytes, 0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS,
g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
"Max. number of buffers in the queue (0=disable)", "Max. number of buffers in the queue (0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME,
g_param_spec_uint64 ("max-size-time", "Max. size (ns)", g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
"Max. amount of data in the queue (in ns, 0=disable)", "Max. amount of data in the queue (in ns, 0=disable)",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES,
g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
"Min. amount of data in the queue to allow reading (bytes, 0=disable)", "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS,
g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
"Min. number of buffers in the queue to allow reading (0=disable)", "Min. number of buffers in the queue to allow reading (0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME,
g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
"Min. amount of data in the queue to allow reading (in ns, 0=disable)", "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_LEAKY, g_object_class_install_property (gobject_class, ARG_LEAKY,
g_param_spec_enum ("leaky", "Leaky", g_param_spec_enum ("leaky", "Leaky",
"Where the queue leaks, if at all", "Where the queue leaks, if at all",
GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK, g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK,
g_param_spec_boolean ("may_deadlock", "May Deadlock", g_param_spec_boolean ("may_deadlock", "May Deadlock",
"The queue may deadlock if it's full and not PLAYING", "The queue may deadlock if it's full and not PLAYING",
TRUE, G_PARAM_READWRITE)); TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT, g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT,
g_param_spec_uint64 ("block_timeout", "Timeout for Block", g_param_spec_uint64 ("block_timeout", "Timeout for Block",
"Nanoseconds until blocked queue times out and returns filler event. " "Nanoseconds until blocked queue times out and returns filler event. "
"Value of -1 disables timeout", "Value of -1 disables timeout",
0, G_MAXUINT64, -1, G_PARAM_READWRITE)); 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
/* set several parent class virtual functions */ /* set several parent class virtual functions */
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
@ -261,15 +263,15 @@ gst_queue_init (GstQueue * queue)
GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
gst_pad_set_active (queue->srcpad, TRUE); gst_pad_set_active (queue->srcpad, TRUE);
queue->cur_level.buffers = 0; /* no content */ queue->cur_level.buffers = 0; /* no content */
queue->cur_level.bytes = 0; /* no content */ queue->cur_level.bytes = 0; /* no content */
queue->cur_level.time = 0; /* no content */ queue->cur_level.time = 0; /* no content */
queue->max_size.buffers = 100; /* 100 buffers */ queue->max_size.buffers = 100; /* 100 buffers */
queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
queue->max_size.time = GST_SECOND; /* 1 s. */ queue->max_size.time = GST_SECOND; /* 1 s. */
queue->min_threshold.buffers = 0; /* no threshold */ queue->min_threshold.buffers = 0; /* no threshold */
queue->min_threshold.bytes = 0; /* no threshold */ queue->min_threshold.bytes = 0; /* no threshold */
queue->min_threshold.time = 0; /* no threshold */ queue->min_threshold.time = 0; /* no threshold */
queue->leaky = GST_QUEUE_NO_LEAK; queue->leaky = GST_QUEUE_NO_LEAK;
queue->may_deadlock = TRUE; queue->may_deadlock = TRUE;
@ -437,163 +439,163 @@ restart:
if (GST_IS_EVENT (data)) { if (GST_IS_EVENT (data)) {
switch (GST_EVENT_TYPE (data)) { switch (GST_EVENT_TYPE (data)) {
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
STATUS (queue, "received flush event"); STATUS (queue, "received flush event");
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
STATUS (queue, "after flush"); STATUS (queue, "after flush");
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
STATUS (queue, "received EOS"); STATUS (queue, "received EOS");
break; break;
default: default:
/* we put the event in the queue, we don't have to act ourselves */ /* we put the event in the queue, we don't have to act ourselves */
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding event %p of type %d", data, GST_EVENT_TYPE (data)); "adding event %p of type %d", data, GST_EVENT_TYPE (data));
break; break;
} }
} }
if (GST_IS_BUFFER (data)) if (GST_IS_BUFFER (data))
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding buffer %p of size %d", data, GST_BUFFER_SIZE (data)); "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
/* We make space available if we're "full" according to whatever /* We make space available if we're "full" according to whatever
* the user defined as "full". Note that this only applies to buffers. * the user defined as "full". Note that this only applies to buffers.
* We always handle events and they don't count in our statistics. */ * We always handle events and they don't count in our statistics. */
if (GST_IS_BUFFER (data) && if (GST_IS_BUFFER (data) &&
((queue->max_size.buffers > 0 && ((queue->max_size.buffers > 0 &&
queue->cur_level.buffers >= queue->max_size.buffers) || queue->cur_level.buffers >= queue->max_size.buffers) ||
(queue->max_size.bytes > 0 && (queue->max_size.bytes > 0 &&
queue->cur_level.bytes >= queue->max_size.bytes) || queue->cur_level.bytes >= queue->max_size.bytes) ||
(queue->max_size.time > 0 && (queue->max_size.time > 0 &&
queue->cur_level.time >= queue->max_size.time))) { queue->cur_level.time >= queue->max_size.time))) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
/* how are we going to make space for this buffer? */ /* how are we going to make space for this buffer? */
switch (queue->leaky) { switch (queue->leaky) {
/* leak current buffer */ /* leak current buffer */
case GST_QUEUE_LEAK_UPSTREAM: case GST_QUEUE_LEAK_UPSTREAM:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue is full, leaking buffer on upstream end"); "queue is full, leaking buffer on upstream end");
/* now we can clean up and exit right away */ /* now we can clean up and exit right away */
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
goto out_unref; goto out_unref;
/* leak first buffer in the queue */ /* leak first buffer in the queue */
case GST_QUEUE_LEAK_DOWNSTREAM:{ case GST_QUEUE_LEAK_DOWNSTREAM:{
/* this is a bit hacky. We'll manually iterate the list /* this is a bit hacky. We'll manually iterate the list
* and find the first buffer from the head on. We'll * and find the first buffer from the head on. We'll
* unref that and "fix up" the GQueue object... */ * unref that and "fix up" the GQueue object... */
GList *item; GList *item;
GstData *leak = NULL; GstData *leak = NULL;
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue is full, leaking buffer on downstream end"); "queue is full, leaking buffer on downstream end");
for (item = queue->queue->head; item != NULL; item = item->next) { for (item = queue->queue->head; item != NULL; item = item->next) {
if (GST_IS_BUFFER (item->data)) { if (GST_IS_BUFFER (item->data)) {
leak = item->data; leak = item->data;
break; break;
} }
} }
/* if we didn't find anything, it means we have no buffers /* if we didn't find anything, it means we have no buffers
* in here. That cannot happen, since we had >= 1 bufs */ * in here. That cannot happen, since we had >= 1 bufs */
g_assert (leak); g_assert (leak);
/* Now remove it from the list, fixing up the GQueue /* Now remove it from the list, fixing up the GQueue
* CHECKME: is a queue->head the first or the last item? */ * CHECKME: is a queue->head the first or the last item? */
item = g_list_delete_link (queue->queue->head, item); item = g_list_delete_link (queue->queue->head, item);
queue->queue->head = g_list_first (item); queue->queue->head = g_list_first (item);
queue->queue->tail = g_list_last (item); queue->queue->tail = g_list_last (item);
queue->queue->length--; queue->queue->length--;
/* and unref the data at the end. Twice, because we keep a ref /* and unref the data at the end. Twice, because we keep a ref
* to make things read-only. Also keep our list uptodate. */ * to make things read-only. Also keep our list uptodate. */
queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
queue->cur_level.buffers--; queue->cur_level.buffers--;
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time -= GST_BUFFER_DURATION (data); queue->cur_level.time -= GST_BUFFER_DURATION (data);
gst_data_unref (data); gst_data_unref (data);
gst_data_unref (data); gst_data_unref (data);
break; break;
} }
default: default:
g_warning ("Unknown leaky type, using default"); g_warning ("Unknown leaky type, using default");
/* fall-through */ /* fall-through */
/* don't leak. Instead, wait for space to be available */ /* don't leak. Instead, wait for space to be available */
case GST_QUEUE_NO_LEAK: case GST_QUEUE_NO_LEAK:
STATUS (queue, "pre-full wait"); STATUS (queue, "pre-full wait");
while ((queue->max_size.buffers > 0 && while ((queue->max_size.buffers > 0 &&
queue->cur_level.buffers >= queue->max_size.buffers) || queue->cur_level.buffers >= queue->max_size.buffers) ||
(queue->max_size.bytes > 0 && (queue->max_size.bytes > 0 &&
queue->cur_level.bytes >= queue->max_size.bytes) || queue->cur_level.bytes >= queue->max_size.bytes) ||
(queue->max_size.time > 0 && (queue->max_size.time > 0 &&
queue->cur_level.time >= queue->max_size.time)) { queue->cur_level.time >= queue->max_size.time)) {
/* if there's a pending state change for this queue /* if there's a pending state change for this queue
* or its manager, switch back to iterator so bottom * or its manager, switch back to iterator so bottom
* half of state change executes */ * half of state change executes */
if (queue->interrupt) { if (queue->interrupt) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
GST_ELEMENT (queue))) { GST_ELEMENT (queue))) {
goto out_unref; goto out_unref;
} }
/* if we got here because we were unlocked after a /* if we got here because we were unlocked after a
* flush, we don't need to add the buffer to the * flush, we don't need to add the buffer to the
* queue again */ * queue again */
if (queue->flush) { if (queue->flush) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"not adding pending buffer after flush"); "not adding pending buffer after flush");
goto out_unref; goto out_unref;
} }
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding pending buffer after interrupt"); "adding pending buffer after interrupt");
goto restart; goto restart;
} }
if (GST_STATE (queue) != GST_STATE_PLAYING) { if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down. Try to /* this means the other end is shut down. Try to
* signal to resolve the error */ * signal to resolve the error */
if (!queue->may_deadlock) { if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
gst_data_unref (data); gst_data_unref (data);
GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
("deadlock found, shutting down source pad elements")); ("deadlock found, shutting down source pad elements"));
/* we don't go to out_unref here, since we want to /* we don't go to out_unref here, since we want to
* unref the buffer *before* calling GST_ELEMENT_ERROR */ * unref the buffer *before* calling GST_ELEMENT_ERROR */
return; return;
} else { } else {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"%s: waiting for the app to restart " "%s: waiting for the app to restart "
"source pad elements", GST_ELEMENT_NAME (queue)); "source pad elements", GST_ELEMENT_NAME (queue));
} }
} }
/* OK, we've got a serious issue here. Imagine the situation /* OK, we've got a serious issue here. Imagine the situation
* where the puller (next element) is sending an event here, * where the puller (next element) is sending an event here,
* so it cannot pull events from the queue, and we cannot * so it cannot pull events from the queue, and we cannot
* push data further because the queue is 'full' and therefore, * push data further because the queue is 'full' and therefore,
* we wait here (and do not handle events): deadlock! to solve * we wait here (and do not handle events): deadlock! to solve
* that, we handle pending upstream events here, too. */ * that, we handle pending upstream events here, too. */
gst_queue_handle_pending_events (queue); gst_queue_handle_pending_events (queue);
STATUS (queue, "waiting for item_del signal"); STATUS (queue, "waiting for item_del signal");
g_cond_wait (queue->item_del, queue->qlock); g_cond_wait (queue->item_del, queue->qlock);
STATUS (queue, "received item_del signal"); STATUS (queue, "received item_del signal");
} }
STATUS (queue, "post-full wait"); STATUS (queue, "post-full wait");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
break; break;
} }
} }
@ -645,63 +647,63 @@ restart:
if (queue->queue->length == 0 || if (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 && (queue->min_threshold.buffers > 0 &&
queue->cur_level.buffers < queue->min_threshold.buffers) || queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 && (queue->min_threshold.bytes > 0 &&
queue->cur_level.bytes < queue->min_threshold.bytes) || queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 && (queue->min_threshold.time > 0 &&
queue->cur_level.time < queue->min_threshold.time)) { queue->cur_level.time < queue->min_threshold.time)) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
STATUS (queue, "pre-empty wait"); STATUS (queue, "pre-empty wait");
while (queue->queue->length == 0 || while (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 && (queue->min_threshold.buffers > 0 &&
queue->cur_level.buffers < queue->min_threshold.buffers) || queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 && (queue->min_threshold.bytes > 0 &&
queue->cur_level.bytes < queue->min_threshold.bytes) || queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 && (queue->min_threshold.time > 0 &&
queue->cur_level.time < queue->min_threshold.time)) { queue->cur_level.time < queue->min_threshold.time)) {
/* if there's a pending state change for this queue or its /* if there's a pending state change for this queue or its
* manager, switch back to iterator so bottom half of state * manager, switch back to iterator so bottom half of state
* change executes. */ * change executes. */
if (queue->interrupt) { if (queue->interrupt) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
GST_ELEMENT (queue))) GST_ELEMENT (queue)))
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
goto restart; goto restart;
} }
if (GST_STATE (queue) != GST_STATE_PLAYING) { if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down */ /* this means the other end is shut down */
if (!queue->may_deadlock) { if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
("deadlock found, shutting down sink pad elements")); ("deadlock found, shutting down sink pad elements"));
goto restart; goto restart;
} else { } else {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"%s: waiting for the app to restart " "%s: waiting for the app to restart "
"source pad elements", GST_ELEMENT_NAME (queue)); "source pad elements", GST_ELEMENT_NAME (queue));
} }
} }
STATUS (queue, "waiting for item_add"); STATUS (queue, "waiting for item_add");
if (queue->block_timeout != GST_CLOCK_TIME_NONE) { if (queue->block_timeout != GST_CLOCK_TIME_NONE) {
GTimeVal timeout; GTimeVal timeout;
g_get_current_time (&timeout); g_get_current_time (&timeout);
g_time_val_add (&timeout, queue->block_timeout / 1000); g_time_val_add (&timeout, queue->block_timeout / 1000);
if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) { if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"Sending filler event"); "Sending filler event");
return GST_DATA (gst_event_new_filler ()); return GST_DATA (gst_event_new_filler ());
} }
} else { } else {
g_cond_wait (queue->item_add, queue->qlock); g_cond_wait (queue->item_add, queue->qlock);
} }
STATUS (queue, "got item_add signal"); STATUS (queue, "got item_add signal");
} }
@ -746,12 +748,12 @@ restart:
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue \"%s\" eos", GST_ELEMENT_NAME (queue)); "queue \"%s\" eos", GST_ELEMENT_NAME (queue));
gst_element_set_eos (GST_ELEMENT (queue)); gst_element_set_eos (GST_ELEMENT (queue));
break; break;
default: default:
break; break;
} }
} }
@ -775,26 +777,26 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
er.handled = FALSE; er.handled = FALSE;
g_queue_push_tail (queue->events, &er); g_queue_push_tail (queue->events, &er);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"Preparing for loop for event handler"); "Preparing for loop for event handler");
/* see the chain function on why this is here - it prevents a deadlock */ /* see the chain function on why this is here - it prevents a deadlock */
g_cond_signal (queue->item_del); g_cond_signal (queue->item_del);
while (!er.handled) { while (!er.handled) {
GTimeVal timeout; GTimeVal timeout;
g_get_current_time (&timeout); g_get_current_time (&timeout);
g_time_val_add (&timeout, 500 * 1000); /* half a second */ g_time_val_add (&timeout, 500 * 1000); /* half a second */
if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) && if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) &&
!er.handled) { !er.handled) {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"timeout in upstream event handling"); "timeout in upstream event handling");
/* remove ourselves from the pending list. Since we're /* remove ourselves from the pending list. Since we're
* locked, others cannot reference this anymore. */ * locked, others cannot reference this anymore. */
queue->queue->head = g_list_remove (queue->queue->head, &er); queue->queue->head = g_list_remove (queue->queue->head, &er);
queue->queue->head = g_list_first (queue->queue->head); queue->queue->head = g_list_first (queue->queue->head);
queue->queue->tail = g_list_last (queue->queue->head); queue->queue->tail = g_list_last (queue->queue->head);
queue->queue->length--; queue->queue->length--;
res = FALSE; res = FALSE;
goto handled; goto handled;
} }
} }
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled"); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled");
@ -804,16 +806,16 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"FLUSH event, flushing queue\n"); "FLUSH event, flushing queue\n");
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
break; break;
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
} }
default: default:
break; break;
} }
} }
handled: handled:
@ -859,30 +861,30 @@ gst_queue_change_state (GstElement * element)
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
if (!GST_PAD_IS_LINKED (queue->sinkpad)) { if (!GST_PAD_IS_LINKED (queue->sinkpad)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
"queue %s is not linked", GST_ELEMENT_NAME (queue)); "queue %s is not linked", GST_ELEMENT_NAME (queue));
/* FIXME can this be? */ /* FIXME can this be? */
g_cond_signal (queue->item_add); g_cond_signal (queue->item_add);
ret = GST_STATE_FAILURE; ret = GST_STATE_FAILURE;
goto error; goto error;
} else { } else {
GstScheduler *src_sched, *sink_sched; GstScheduler *src_sched, *sink_sched;
src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
if (src_sched == sink_sched) { if (src_sched == sink_sched) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
"queue %s does not connect different schedulers", "queue %s does not connect different schedulers",
GST_ELEMENT_NAME (queue)); GST_ELEMENT_NAME (queue));
g_warning ("queue %s does not connect different schedulers", g_warning ("queue %s does not connect different schedulers",
GST_ELEMENT_NAME (queue)); GST_ELEMENT_NAME (queue));
ret = GST_STATE_FAILURE; ret = GST_STATE_FAILURE;
goto error; goto error;
} }
} }
queue->interrupt = FALSE; queue->interrupt = FALSE;
break; break;

View file

@ -69,7 +69,7 @@ gst_registry_get_type (void)
}; };
registry_type = g_type_register_static (G_TYPE_OBJECT, "GstRegistry", registry_type = g_type_register_static (G_TYPE_OBJECT, "GstRegistry",
&registry_info, G_TYPE_FLAG_ABSTRACT); &registry_info, G_TYPE_FLAG_ABSTRACT);
} }
return registry_type; return registry_type;
} }

View file

@ -306,8 +306,7 @@ gst_registry_pool_find_feature (const gchar * name, GType type)
data.type = type; data.type = type;
data.name = name; data.name = name;
walk = walk = gst_registry_pool_feature_filter ((GstPluginFeatureFilter)
gst_registry_pool_feature_filter ((GstPluginFeatureFilter)
gst_plugin_feature_type_name_filter, TRUE, &data); gst_plugin_feature_type_name_filter, TRUE, &data);
if (walk) if (walk)

View file

@ -55,8 +55,8 @@ gst_scheduler_get_type (void)
}; };
_gst_scheduler_type = _gst_scheduler_type =
g_type_register_static (GST_TYPE_OBJECT, "GstScheduler", g_type_register_static (GST_TYPE_OBJECT, "GstScheduler",
&scheduler_info, G_TYPE_FLAG_ABSTRACT); &scheduler_info, G_TYPE_FLAG_ABSTRACT);
} }
return _gst_scheduler_type; return _gst_scheduler_type;
} }
@ -229,7 +229,7 @@ gst_scheduler_add_element (GstScheduler * sched, GstElement * element)
/* if it's already in this scheduler, don't bother doing anything */ /* if it's already in this scheduler, don't bother doing anything */
if (GST_ELEMENT_SCHED (element) == sched) { if (GST_ELEMENT_SCHED (element) == sched) {
GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p", GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p",
GST_ELEMENT_NAME (element), sched); GST_ELEMENT_NAME (element), sched);
return; return;
} }
@ -239,12 +239,12 @@ gst_scheduler_add_element (GstScheduler * sched, GstElement * element)
if (gst_element_provides_clock (element)) { if (gst_element_provides_clock (element)) {
sched->clock_providers = g_list_prepend (sched->clock_providers, element); sched->clock_providers = g_list_prepend (sched->clock_providers, element);
GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} }
if (gst_element_requires_clock (element)) { if (gst_element_requires_clock (element)) {
sched->clock_receivers = g_list_prepend (sched->clock_receivers, element); sched->clock_receivers = g_list_prepend (sched->clock_receivers, element);
GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} }
gst_element_set_scheduler (element, sched); gst_element_set_scheduler (element, sched);
@ -305,14 +305,14 @@ gst_scheduler_state_transition (GstScheduler * sched, GstElement * element,
switch (transition) { switch (transition) {
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
{ {
GstClock *clock = gst_scheduler_get_clock (sched); GstClock *clock = gst_scheduler_get_clock (sched);
GST_CAT_DEBUG (GST_CAT_CLOCK, GST_CAT_DEBUG (GST_CAT_CLOCK,
"scheduler READY to PAUSED clock is %p (%s)", clock, "scheduler READY to PAUSED clock is %p (%s)", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil")); (clock ? GST_OBJECT_NAME (clock) : "nil"));
gst_scheduler_set_clock (sched, clock); gst_scheduler_set_clock (sched, clock);
break; break;
} }
} }
} }
@ -541,7 +541,7 @@ gst_scheduler_get_clock (GstScheduler * sched)
clock = sched->clock; clock = sched->clock;
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil")); (clock ? GST_OBJECT_NAME (clock) : "nil"));
} else { } else {
GList *schedulers = sched->schedulers; GList *schedulers = sched->schedulers;
GList *providers = sched->clock_providers; GList *providers = sched->clock_providers;
@ -552,7 +552,7 @@ gst_scheduler_get_clock (GstScheduler * sched)
clock = gst_scheduler_get_clock (scheduler); clock = gst_scheduler_get_clock (scheduler);
if (clock) if (clock)
break; break;
schedulers = g_list_next (schedulers); schedulers = g_list_next (schedulers);
} }
@ -623,8 +623,8 @@ gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock)
GstElement *element = GST_ELEMENT (receivers->data); GstElement *element = GST_ELEMENT (receivers->data);
GST_CAT_DEBUG (GST_CAT_CLOCK, GST_CAT_DEBUG (GST_CAT_CLOCK,
"scheduler setting clock %p (%s) on element %s", clock, "scheduler setting clock %p (%s) on element %s", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element)); (clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element));
gst_element_set_clock (element, clock); gst_element_set_clock (element, clock);
receivers = g_list_next (receivers); receivers = g_list_next (receivers);
@ -633,8 +633,8 @@ gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock)
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data); GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
GST_CAT_DEBUG (GST_CAT_CLOCK, GST_CAT_DEBUG (GST_CAT_CLOCK,
"scheduler setting clock %p (%s) on scheduler %p", clock, "scheduler setting clock %p (%s) on scheduler %p", clock,
(clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler); (clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler);
gst_scheduler_set_clock (scheduler, clock); gst_scheduler_set_clock (scheduler, clock);
schedulers = g_list_next (schedulers); schedulers = g_list_next (schedulers);
} }
@ -764,8 +764,9 @@ gst_scheduler_factory_get_type (void)
(GInstanceInitFunc) gst_scheduler_factory_init, (GInstanceInitFunc) gst_scheduler_factory_init,
NULL NULL
}; };
schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstSchedulerFactory", &schedulerfactory_info, 0); "GstSchedulerFactory", &schedulerfactory_info, 0);
} }
return schedulerfactory_type; return schedulerfactory_type;
} }
@ -821,7 +822,7 @@ gst_scheduler_factory_new (const gchar * name, const gchar * longdesc,
if (!factory) { if (!factory) {
factory = factory =
GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL)); GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL));
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name); GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
} else { } else {
g_free (factory->longdesc); g_free (factory->longdesc);

View file

@ -60,11 +60,11 @@ gst_structure_get_type (void)
if (!gst_structure_type) { if (!gst_structure_type) {
gst_structure_type = g_boxed_type_register_static ("GstStructure", gst_structure_type = g_boxed_type_register_static ("GstStructure",
(GBoxedCopyFunc) gst_structure_copy_conditional, (GBoxedCopyFunc) gst_structure_copy_conditional,
(GBoxedFreeFunc) gst_structure_free); (GBoxedFreeFunc) gst_structure_free);
g_value_register_transform_func (gst_structure_type, G_TYPE_STRING, g_value_register_transform_func (gst_structure_type, G_TYPE_STRING,
gst_structure_transform_to_string); gst_structure_transform_to_string);
} }
return gst_structure_type; return gst_structure_type;
@ -362,54 +362,54 @@ gst_structure_set_valist (GstStructure * structure,
switch (type) { switch (type) {
case G_TYPE_INT: case G_TYPE_INT:
i = va_arg (varargs, int); i = va_arg (varargs, int);
g_value_init (&field.value, G_TYPE_INT); g_value_init (&field.value, G_TYPE_INT);
g_value_set_int (&field.value, i); g_value_set_int (&field.value, i);
break; break;
case G_TYPE_DOUBLE: case G_TYPE_DOUBLE:
d = va_arg (varargs, double); d = va_arg (varargs, double);
g_value_init (&field.value, G_TYPE_DOUBLE); g_value_init (&field.value, G_TYPE_DOUBLE);
g_value_set_double (&field.value, d); g_value_set_double (&field.value, d);
break; break;
case G_TYPE_BOOLEAN: case G_TYPE_BOOLEAN:
i = va_arg (varargs, int); i = va_arg (varargs, int);
g_value_init (&field.value, G_TYPE_BOOLEAN); g_value_init (&field.value, G_TYPE_BOOLEAN);
g_value_set_boolean (&field.value, i); g_value_set_boolean (&field.value, i);
break; break;
case G_TYPE_STRING: case G_TYPE_STRING:
s = va_arg (varargs, char *); s = va_arg (varargs, char *);
g_value_init (&field.value, G_TYPE_STRING); g_value_init (&field.value, G_TYPE_STRING);
g_value_set_string (&field.value, s); g_value_set_string (&field.value, s);
break; break;
default: default:
if (type == GST_TYPE_FOURCC) { if (type == GST_TYPE_FOURCC) {
i = va_arg (varargs, int); i = va_arg (varargs, int);
g_value_init (&field.value, GST_TYPE_FOURCC); g_value_init (&field.value, GST_TYPE_FOURCC);
gst_value_set_fourcc (&field.value, i); gst_value_set_fourcc (&field.value, i);
} else if (type == GST_TYPE_INT_RANGE) { } else if (type == GST_TYPE_INT_RANGE) {
int min, max; int min, max;
min = va_arg (varargs, int); min = va_arg (varargs, int);
max = va_arg (varargs, int); max = va_arg (varargs, int);
g_value_init (&field.value, GST_TYPE_INT_RANGE); g_value_init (&field.value, GST_TYPE_INT_RANGE);
gst_value_set_int_range (&field.value, min, max); gst_value_set_int_range (&field.value, min, max);
} else if (type == GST_TYPE_DOUBLE_RANGE) { } else if (type == GST_TYPE_DOUBLE_RANGE) {
double min, max; double min, max;
min = va_arg (varargs, double); min = va_arg (varargs, double);
max = va_arg (varargs, double); max = va_arg (varargs, double);
g_value_init (&field.value, GST_TYPE_DOUBLE_RANGE); g_value_init (&field.value, GST_TYPE_DOUBLE_RANGE);
gst_value_set_double_range (&field.value, min, max); gst_value_set_double_range (&field.value, min, max);
} else { } else {
g_critical ("unimplemented vararg field type %d\n", (int) type); g_critical ("unimplemented vararg field type %d\n", (int) type);
return; return;
} }
break; break;
} }
gst_structure_set_field (structure, &field); gst_structure_set_field (structure, &field);
@ -573,7 +573,7 @@ gst_structure_remove_field (GstStructure * structure, const gchar * fieldname)
if (field->name == id) { if (field->name == id) {
if (G_IS_VALUE (&field->value)) { if (G_IS_VALUE (&field->value)) {
g_value_unset (&field->value); g_value_unset (&field->value);
} }
structure->fields = g_array_remove_index (structure->fields, i); structure->fields = g_array_remove_index (structure->fields, i);
return; return;
@ -951,7 +951,8 @@ typedef struct _GstStructureAbbreviation
{ {
char *type_name; char *type_name;
GType type; GType type;
} GstStructureAbbreviation; }
GstStructureAbbreviation;
static GstStructureAbbreviation gst_structure_abbrs[] = { static GstStructureAbbreviation gst_structure_abbrs[] = {
{"int", G_TYPE_INT}, {"int", G_TYPE_INT},
@ -1054,11 +1055,11 @@ gst_structure_to_string (const GstStructure * structure)
GArray *array = g_value_peek_pointer (&field->value); GArray *array = g_value_peek_pointer (&field->value);
if (array->len > 0) { if (array->len > 0) {
GValue *value = &g_array_index (array, GValue, 0); GValue *value = &g_array_index (array, GValue, 0);
type = G_VALUE_TYPE (value); type = G_VALUE_TYPE (value);
} else { } else {
type = G_TYPE_INT; type = G_TYPE_INT;
} }
} else if (G_VALUE_TYPE (&field->value) == GST_TYPE_INT_RANGE) { } else if (G_VALUE_TYPE (&field->value) == GST_TYPE_INT_RANGE) {
type = G_TYPE_INT; type = G_TYPE_INT;
@ -1066,7 +1067,7 @@ gst_structure_to_string (const GstStructure * structure)
type = G_TYPE_DOUBLE; type = G_TYPE_DOUBLE;
} }
g_string_append_printf (s, ", %s=(%s)%s", g_quark_to_string (field->name), g_string_append_printf (s, ", %s=(%s)%s", g_quark_to_string (field->name),
gst_structure_to_abbr (type), t); gst_structure_to_abbr (type), t);
g_free (t); g_free (t);
} }
return g_string_free (s, FALSE); return g_string_free (s, FALSE);
@ -1171,10 +1172,10 @@ gst_structure_parse_range (gchar * s, gchar ** after, GValue * value,
g_value_init (value, range_type); g_value_init (value, range_type);
if (range_type == GST_TYPE_DOUBLE_RANGE) { if (range_type == GST_TYPE_DOUBLE_RANGE) {
gst_value_set_double_range (value, g_value_get_double (&value1), gst_value_set_double_range (value, g_value_get_double (&value1),
g_value_get_double (&value2)); g_value_get_double (&value2));
} else { } else {
gst_value_set_int_range (value, g_value_get_int (&value1), gst_value_set_int_range (value, g_value_get_int (&value1),
g_value_get_int (&value2)); g_value_get_int (&value2));
} }
*after = s; *after = s;
@ -1351,11 +1352,11 @@ gst_structure_parse_value (gchar * str,
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
g_value_init (value, try_types[i]); g_value_init (value, try_types[i]);
ret = gst_value_deserialize (value, value_s); ret = gst_value_deserialize (value, value_s);
if (ret) if (ret)
break; break;
g_value_unset (value); g_value_unset (value);
} }
} else { } else {
g_value_init (value, type); g_value_init (value, type);

View file

@ -63,8 +63,9 @@ gst_system_clock_get_type (void)
(GInstanceInitFunc) gst_system_clock_init, (GInstanceInitFunc) gst_system_clock_init,
NULL NULL
}; };
clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock", clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock",
&clock_info, 0); &clock_info, 0);
} }
return clock_type; return clock_type;
} }
@ -182,7 +183,7 @@ gst_system_clock_wait (GstClock * clock, GstClockEntry * entry)
if (diff + clock->max_diff < 0) { if (diff + clock->max_diff < 0) {
GST_WARNING_OBJECT (clock, "clock is way behind: %" G_GINT64_FORMAT GST_WARNING_OBJECT (clock, "clock is way behind: %" G_GINT64_FORMAT
"s (max allowed is %" G_GINT64_FORMAT "s", -diff, clock->max_diff); "s (max allowed is %" G_GINT64_FORMAT "s", -diff, clock->max_diff);
return GST_CLOCK_ENTRY_EARLY; return GST_CLOCK_ENTRY_EARLY;
} }

View file

@ -36,14 +36,15 @@
typedef struct typedef struct
{ {
GType type; /* type the data is in */ GType type; /* type the data is in */
gchar *nick; /* translated name */ gchar *nick; /* translated name */
gchar *blurb; /* translated description of type */ gchar *blurb; /* translated description of type */
GstTagMergeFunc merge_func; /* functions to merge the values */ GstTagMergeFunc merge_func; /* functions to merge the values */
GstTagFlag flag; /* type of tag */ GstTagFlag flag; /* type of tag */
} GstTagInfo; }
GstTagInfo;
#define TAGLIST "taglist" #define TAGLIST "taglist"
static GQuark gst_tag_list_quark; static GQuark gst_tag_list_quark;
@ -60,11 +61,11 @@ gst_tag_list_get_type (void)
if (_gst_tag_list_type == 0) { if (_gst_tag_list_type == 0) {
_gst_tag_list_type = g_boxed_type_register_static ("GstTagList", _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
(GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free); (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
#if 0 #if 0
g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING, g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
_gst_structure_transform_to_string); _gst_structure_transform_to_string);
#endif #endif
} }
@ -89,7 +90,7 @@ _gst_tag_initialize (void)
G_TYPE_STRING, G_TYPE_STRING,
_("album"), _("album"),
_("album containing this data"), gst_tag_merge_strings_with_comma); _("album containing this data"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */ gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */
_("date"), _("date"),
_("date the data was created (in Julian calendar days)"), NULL); _("date the data was created (in Julian calendar days)"), NULL);
gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META, gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
@ -136,7 +137,7 @@ _gst_tag_initialize (void)
_ _
("International Standard Recording Code - see http://www.ifpi.org/isrc/"), ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
NULL); NULL);
gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */ gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */
gst_tag_merge_strings_with_comma); gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL); G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
@ -227,8 +228,8 @@ gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
/* seperator between two string */ /* seperator between two string */
str = g_string_append (str, _(", ")); str = g_string_append (str, _(", "));
str = str =
g_string_append (str, g_value_get_string (gst_value_list_get_value (src, g_string_append (str, g_value_get_string (gst_value_list_get_value (src,
1))); 1)));
} }
g_value_init (dest, G_TYPE_STRING); g_value_init (dest, G_TYPE_STRING);
@ -439,7 +440,8 @@ typedef struct
{ {
GstStructure *list; GstStructure *list;
GstTagMergeMode mode; GstTagMergeMode mode;
} GstTagCopyData; }
GstTagCopyData;
static void static void
gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode, gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
GQuark tag, GValue * value) GQuark tag, GValue * value)
@ -452,45 +454,46 @@ gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
if (info->merge_func if (info->merge_func
&& (value2 = gst_structure_id_get_value (list, tag)) != NULL) { && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, }; GValue dest = { 0, };
switch (mode) { switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL: case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE: case GST_TAG_MERGE_REPLACE:
gst_structure_id_set_value (list, tag, value); gst_structure_id_set_value (list, tag, value);
break; break;
case GST_TAG_MERGE_PREPEND: case GST_TAG_MERGE_PREPEND:
gst_value_list_concat (&dest, value, value2); gst_value_list_concat (&dest, value, value2);
gst_structure_id_set_value (list, tag, &dest); gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest); g_value_unset (&dest);
break; break;
case GST_TAG_MERGE_APPEND: case GST_TAG_MERGE_APPEND:
gst_value_list_concat (&dest, value2, value); gst_value_list_concat (&dest, value2, value);
gst_structure_id_set_value (list, tag, &dest); gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest); g_value_unset (&dest);
break; break;
case GST_TAG_MERGE_KEEP: case GST_TAG_MERGE_KEEP:
case GST_TAG_MERGE_KEEP_ALL: case GST_TAG_MERGE_KEEP_ALL:
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
} else { } else {
switch (mode) { switch (mode) {
case GST_TAG_MERGE_APPEND: case GST_TAG_MERGE_APPEND:
case GST_TAG_MERGE_KEEP: case GST_TAG_MERGE_KEEP:
if (gst_structure_id_get_value (list, tag) != NULL) if (gst_structure_id_get_value (list, tag) != NULL)
break; break;
/* fall through */ /* fall through */
case GST_TAG_MERGE_REPLACE_ALL: case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE: case GST_TAG_MERGE_REPLACE:
case GST_TAG_MERGE_PREPEND: case GST_TAG_MERGE_PREPEND:
gst_structure_id_set_value (list, tag, value); gst_structure_id_set_value (list, tag, value);
break; break;
case GST_TAG_MERGE_KEEP_ALL: case GST_TAG_MERGE_KEEP_ALL:
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
} }
} }
@ -690,6 +693,7 @@ gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
while (tag != NULL) { while (tag != NULL) {
GValue value = { 0, }; GValue value = { 0, };
quark = g_quark_from_string (tag); quark = g_quark_from_string (tag);
info = gst_tag_lookup (quark); info = gst_tag_lookup (quark);
if (info == NULL) if (info == NULL)
@ -736,7 +740,7 @@ gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
info = gst_tag_lookup (quark); info = gst_tag_lookup (quark);
g_return_if_fail (info != NULL); g_return_if_fail (info != NULL);
gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
GValue *)); GValue *));
tag = va_arg (var_args, gchar *); tag = va_arg (var_args, gchar *);
} }
} }
@ -761,7 +765,8 @@ typedef struct
GstTagForeachFunc func; GstTagForeachFunc func;
GstTagList *tag_list; GstTagList *tag_list;
gpointer data; gpointer data;
} TagForeachData; }
TagForeachData;
static int static int
structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data) structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data)
{ {

View file

@ -37,7 +37,8 @@ typedef struct
{ {
GstTagMergeMode mode; GstTagMergeMode mode;
GstTagList *list; GstTagList *list;
} GstTagData; }
GstTagData;
GType GType
gst_tag_setter_get_type (void) gst_tag_setter_get_type (void)
@ -46,22 +47,22 @@ gst_tag_setter_get_type (void)
if (!tag_setter_type) { if (!tag_setter_type) {
static const GTypeInfo tag_setter_info = { static const GTypeInfo tag_setter_info = {
sizeof (GstTagSetterIFace), /* class_size */ sizeof (GstTagSetterIFace), /* class_size */
NULL, /* base_init */ NULL, /* base_init */
NULL, /* base_finalize */ NULL, /* base_finalize */
NULL, NULL,
NULL, /* class_finalize */ NULL, /* class_finalize */
NULL, /* class_data */ NULL, /* class_data */
0, 0,
0, 0,
NULL NULL
}; };
GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0,
"interfaces for tagging"); "interfaces for tagging");
tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter", tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
&tag_setter_info, 0); &tag_setter_info, 0);
g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT); g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT);
@ -91,7 +92,7 @@ gst_tag_setter_get_data (GstTagSetter * setter)
data->list = NULL; data->list = NULL;
data->mode = GST_TAG_MERGE_KEEP; data->mode = GST_TAG_MERGE_KEEP;
g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data,
gst_tag_data_free); gst_tag_data_free);
} }
return data; return data;

View file

@ -36,14 +36,15 @@
typedef struct typedef struct
{ {
GType type; /* type the data is in */ GType type; /* type the data is in */
gchar *nick; /* translated name */ gchar *nick; /* translated name */
gchar *blurb; /* translated description of type */ gchar *blurb; /* translated description of type */
GstTagMergeFunc merge_func; /* functions to merge the values */ GstTagMergeFunc merge_func; /* functions to merge the values */
GstTagFlag flag; /* type of tag */ GstTagFlag flag; /* type of tag */
} GstTagInfo; }
GstTagInfo;
#define TAGLIST "taglist" #define TAGLIST "taglist"
static GQuark gst_tag_list_quark; static GQuark gst_tag_list_quark;
@ -60,11 +61,11 @@ gst_tag_list_get_type (void)
if (_gst_tag_list_type == 0) { if (_gst_tag_list_type == 0) {
_gst_tag_list_type = g_boxed_type_register_static ("GstTagList", _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
(GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free); (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
#if 0 #if 0
g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING, g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
_gst_structure_transform_to_string); _gst_structure_transform_to_string);
#endif #endif
} }
@ -89,7 +90,7 @@ _gst_tag_initialize (void)
G_TYPE_STRING, G_TYPE_STRING,
_("album"), _("album"),
_("album containing this data"), gst_tag_merge_strings_with_comma); _("album containing this data"), gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */ gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */
_("date"), _("date"),
_("date the data was created (in Julian calendar days)"), NULL); _("date the data was created (in Julian calendar days)"), NULL);
gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META, gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
@ -136,7 +137,7 @@ _gst_tag_initialize (void)
_ _
("International Standard Recording Code - see http://www.ifpi.org/isrc/"), ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
NULL); NULL);
gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */ gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */
gst_tag_merge_strings_with_comma); gst_tag_merge_strings_with_comma);
gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL); G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
@ -227,8 +228,8 @@ gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
/* seperator between two string */ /* seperator between two string */
str = g_string_append (str, _(", ")); str = g_string_append (str, _(", "));
str = str =
g_string_append (str, g_value_get_string (gst_value_list_get_value (src, g_string_append (str, g_value_get_string (gst_value_list_get_value (src,
1))); 1)));
} }
g_value_init (dest, G_TYPE_STRING); g_value_init (dest, G_TYPE_STRING);
@ -439,7 +440,8 @@ typedef struct
{ {
GstStructure *list; GstStructure *list;
GstTagMergeMode mode; GstTagMergeMode mode;
} GstTagCopyData; }
GstTagCopyData;
static void static void
gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode, gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
GQuark tag, GValue * value) GQuark tag, GValue * value)
@ -452,45 +454,46 @@ gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
if (info->merge_func if (info->merge_func
&& (value2 = gst_structure_id_get_value (list, tag)) != NULL) { && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
GValue dest = { 0, }; GValue dest = { 0, };
switch (mode) { switch (mode) {
case GST_TAG_MERGE_REPLACE_ALL: case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE: case GST_TAG_MERGE_REPLACE:
gst_structure_id_set_value (list, tag, value); gst_structure_id_set_value (list, tag, value);
break; break;
case GST_TAG_MERGE_PREPEND: case GST_TAG_MERGE_PREPEND:
gst_value_list_concat (&dest, value, value2); gst_value_list_concat (&dest, value, value2);
gst_structure_id_set_value (list, tag, &dest); gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest); g_value_unset (&dest);
break; break;
case GST_TAG_MERGE_APPEND: case GST_TAG_MERGE_APPEND:
gst_value_list_concat (&dest, value2, value); gst_value_list_concat (&dest, value2, value);
gst_structure_id_set_value (list, tag, &dest); gst_structure_id_set_value (list, tag, &dest);
g_value_unset (&dest); g_value_unset (&dest);
break; break;
case GST_TAG_MERGE_KEEP: case GST_TAG_MERGE_KEEP:
case GST_TAG_MERGE_KEEP_ALL: case GST_TAG_MERGE_KEEP_ALL:
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
} else { } else {
switch (mode) { switch (mode) {
case GST_TAG_MERGE_APPEND: case GST_TAG_MERGE_APPEND:
case GST_TAG_MERGE_KEEP: case GST_TAG_MERGE_KEEP:
if (gst_structure_id_get_value (list, tag) != NULL) if (gst_structure_id_get_value (list, tag) != NULL)
break; break;
/* fall through */ /* fall through */
case GST_TAG_MERGE_REPLACE_ALL: case GST_TAG_MERGE_REPLACE_ALL:
case GST_TAG_MERGE_REPLACE: case GST_TAG_MERGE_REPLACE:
case GST_TAG_MERGE_PREPEND: case GST_TAG_MERGE_PREPEND:
gst_structure_id_set_value (list, tag, value); gst_structure_id_set_value (list, tag, value);
break; break;
case GST_TAG_MERGE_KEEP_ALL: case GST_TAG_MERGE_KEEP_ALL:
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
} }
} }
@ -690,6 +693,7 @@ gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
while (tag != NULL) { while (tag != NULL) {
GValue value = { 0, }; GValue value = { 0, };
quark = g_quark_from_string (tag); quark = g_quark_from_string (tag);
info = gst_tag_lookup (quark); info = gst_tag_lookup (quark);
if (info == NULL) if (info == NULL)
@ -736,7 +740,7 @@ gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
info = gst_tag_lookup (quark); info = gst_tag_lookup (quark);
g_return_if_fail (info != NULL); g_return_if_fail (info != NULL);
gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
GValue *)); GValue *));
tag = va_arg (var_args, gchar *); tag = va_arg (var_args, gchar *);
} }
} }
@ -761,7 +765,8 @@ typedef struct
GstTagForeachFunc func; GstTagForeachFunc func;
GstTagList *tag_list; GstTagList *tag_list;
gpointer data; gpointer data;
} TagForeachData; }
TagForeachData;
static int static int
structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data) structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data)
{ {

View file

@ -37,7 +37,8 @@ typedef struct
{ {
GstTagMergeMode mode; GstTagMergeMode mode;
GstTagList *list; GstTagList *list;
} GstTagData; }
GstTagData;
GType GType
gst_tag_setter_get_type (void) gst_tag_setter_get_type (void)
@ -46,22 +47,22 @@ gst_tag_setter_get_type (void)
if (!tag_setter_type) { if (!tag_setter_type) {
static const GTypeInfo tag_setter_info = { static const GTypeInfo tag_setter_info = {
sizeof (GstTagSetterIFace), /* class_size */ sizeof (GstTagSetterIFace), /* class_size */
NULL, /* base_init */ NULL, /* base_init */
NULL, /* base_finalize */ NULL, /* base_finalize */
NULL, NULL,
NULL, /* class_finalize */ NULL, /* class_finalize */
NULL, /* class_data */ NULL, /* class_data */
0, 0,
0, 0,
NULL NULL
}; };
GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0,
"interfaces for tagging"); "interfaces for tagging");
tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter", tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
&tag_setter_info, 0); &tag_setter_info, 0);
g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT); g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT);
@ -91,7 +92,7 @@ gst_tag_setter_get_data (GstTagSetter * setter)
data->list = NULL; data->list = NULL;
data->mode = GST_TAG_MERGE_KEEP; data->mode = GST_TAG_MERGE_KEEP;
g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data,
gst_tag_data_free); gst_tag_data_free);
} }
return data; return data;

View file

@ -98,9 +98,10 @@ gst_thread_priority_get_type (void)
{G_THREAD_PRIORITY_URGENT, "URGENT", "Urgent Scheduling"}, {G_THREAD_PRIORITY_URGENT, "URGENT", "Urgent Scheduling"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!thread_priority_type) { if (!thread_priority_type) {
thread_priority_type = thread_priority_type =
g_enum_register_static ("GstThreadPriority", thread_priority); g_enum_register_static ("GstThreadPriority", thread_priority);
} }
return thread_priority_type; return thread_priority_type;
} }
@ -127,8 +128,9 @@ gst_thread_get_type (void)
gst_thread_init, gst_thread_init,
NULL NULL
}; };
thread_type = g_type_register_static (GST_TYPE_BIN, "GstThread", thread_type = g_type_register_static (GST_TYPE_BIN, "GstThread",
&thread_info, 0); &thread_info, 0);
} }
return thread_type; return thread_type;
} }
@ -163,8 +165,8 @@ gst_thread_class_init (gpointer g_class, gpointer class_data)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PRIORITY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PRIORITY,
g_param_spec_enum ("priority", "Scheduling Policy", g_param_spec_enum ("priority", "Scheduling Policy",
"The scheduling priority of the thread", GST_TYPE_THREAD_PRIORITY, "The scheduling priority of the thread", GST_TYPE_THREAD_PRIORITY,
G_THREAD_PRIORITY_NORMAL, G_PARAM_READWRITE)); G_THREAD_PRIORITY_NORMAL, G_PARAM_READWRITE));
gst_thread_signals[SHUTDOWN] = gst_thread_signals[SHUTDOWN] =
g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -207,7 +209,7 @@ gst_thread_init (GTypeInstance * instance, gpointer g_class)
thread->lock = g_mutex_new (); thread->lock = g_mutex_new ();
thread->cond = g_cond_new (); thread->cond = g_cond_new ();
thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */ thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */
thread->priority = G_THREAD_PRIORITY_NORMAL; thread->priority = G_THREAD_PRIORITY_NORMAL;
} }
@ -321,39 +323,39 @@ gst_thread_release_children_locks (GstThread * thread)
g_assert (element); g_assert (element);
GST_DEBUG_OBJECT (thread, "waking element \"%s\"", GST_DEBUG_OBJECT (thread, "waking element \"%s\"",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
elements = g_list_next (elements); elements = g_list_next (elements);
if (!gst_element_release_locks (element)) if (!gst_element_release_locks (element))
g_warning ("element %s could not release locks", g_warning ("element %s could not release locks",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
pads = GST_ELEMENT_PADS (element); pads = GST_ELEMENT_PADS (element);
while (pads) { while (pads) {
if (GST_PAD_PEER (pads->data)) { if (GST_PAD_PEER (pads->data)) {
peer = GST_REAL_PAD (GST_PAD_PEER (pads->data)); peer = GST_REAL_PAD (GST_PAD_PEER (pads->data));
pads = g_list_next (pads); pads = g_list_next (pads);
} else { } else {
pads = g_list_next (pads); pads = g_list_next (pads);
continue; continue;
} }
if (!peer) if (!peer)
continue; continue;
peerelement = GST_PAD_PARENT (peer); peerelement = GST_PAD_PARENT (peer);
if (!peerelement) if (!peerelement)
continue; /* FIXME: deal with case where there's no peer */ continue; /* FIXME: deal with case where there's no peer */
if (GST_ELEMENT_SCHED (peerelement) != GST_ELEMENT_SCHED (thread)) { if (GST_ELEMENT_SCHED (peerelement) != GST_ELEMENT_SCHED (thread)) {
GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary", GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
GST_LOG_OBJECT (thread, "waking element \"%s\"", GST_LOG_OBJECT (thread, "waking element \"%s\"",
GST_ELEMENT_NAME (peerelement)); GST_ELEMENT_NAME (peerelement));
if (!gst_element_release_locks (peerelement)) if (!gst_element_release_locks (peerelement))
g_warning ("element %s could not release locks", g_warning ("element %s could not release locks",
GST_ELEMENT_NAME (peerelement)); GST_ELEMENT_NAME (peerelement));
} }
} }
} }
@ -385,7 +387,7 @@ gst_thread_catch (GstThread * thread)
g_cond_signal (thread->cond); g_cond_signal (thread->cond);
gst_thread_release_children_locks (thread); gst_thread_release_children_locks (thread);
g_get_current_time (&tv); g_get_current_time (&tv);
g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */ g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */
wait = g_cond_timed_wait (thread->cond, thread->lock, &tv); wait = g_cond_timed_wait (thread->cond, thread->lock, &tv);
} }
GST_LOG_OBJECT (thread, "caught thread"); GST_LOG_OBJECT (thread, "caught thread");
@ -432,10 +434,10 @@ gst_thread_change_state (GstElement * element)
/* create the thread */ /* create the thread */
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING); GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
thread->thread_id = g_thread_create_full (gst_thread_main_loop, thread->thread_id = g_thread_create_full (gst_thread_main_loop,
thread, STACK_SIZE, FALSE, TRUE, thread->priority, NULL); thread, STACK_SIZE, FALSE, TRUE, thread->priority, NULL);
if (!thread->thread_id) { if (!thread->thread_id) {
GST_ERROR_OBJECT (element, "g_thread_create_full failed"); GST_ERROR_OBJECT (element, "g_thread_create_full failed");
goto error_out; goto error_out;
} }
GST_LOG_OBJECT (element, "GThread created"); GST_LOG_OBJECT (element, "GThread created");
@ -450,13 +452,13 @@ gst_thread_change_state (GstElement * element)
GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread)); GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread));
while (elements) { while (elements) {
gst_element_enable_threadsafe_properties ((GstElement *) elements-> gst_element_enable_threadsafe_properties ((GstElement *) elements->
data); data);
elements = g_list_next (elements); elements = g_list_next (elements);
} }
/* reset self to spinning */ /* reset self to spinning */
if (thread == gst_thread_get_current ()) if (thread == gst_thread_get_current ())
GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING); GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
break; break;
} }
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
@ -464,9 +466,9 @@ gst_thread_change_state (GstElement * element)
GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread)); GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread));
while (elements) { while (elements) {
gst_element_disable_threadsafe_properties ((GstElement *) elements-> gst_element_disable_threadsafe_properties ((GstElement *) elements->
data); data);
elements = g_list_next (elements); elements = g_list_next (elements);
} }
break; break;
} }
@ -479,20 +481,20 @@ gst_thread_change_state (GstElement * element)
GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING); GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING);
thread->thread_id = NULL; thread->thread_id = NULL;
if (thread == gst_thread_get_current ()) { if (thread == gst_thread_get_current ()) {
/* or should we continue? */ /* or should we continue? */
g_warning g_warning
("Thread %s is destroying itself. Function call will not return!", ("Thread %s is destroying itself. Function call will not return!",
GST_ELEMENT_NAME (thread)); GST_ELEMENT_NAME (thread));
gst_scheduler_reset (GST_ELEMENT_SCHED (thread)); gst_scheduler_reset (GST_ELEMENT_SCHED (thread));
/* unlock and signal - we are out */ /* unlock and signal - we are out */
gst_thread_release (thread); gst_thread_release (thread);
GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self ()); GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self ());
g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
g_thread_exit (NULL); g_thread_exit (NULL);
} }
/* now wait for the thread to destroy itself */ /* now wait for the thread to destroy itself */
g_cond_signal (thread->cond); g_cond_signal (thread->cond);
@ -501,10 +503,10 @@ gst_thread_change_state (GstElement * element)
break; break;
default: default:
GST_ERROR_OBJECT (element, "unhandled state change! %x", GST_ERROR_OBJECT (element, "unhandled state change! %x",
GST_STATE_TRANSITION (element)); GST_STATE_TRANSITION (element));
g_warning ("thread %s: UNHANDLED STATE CHANGE! %x", g_warning ("thread %s: UNHANDLED STATE CHANGE! %x",
GST_STR_NULL (GST_OBJECT_NAME (element)), GST_STR_NULL (GST_OBJECT_NAME (element)),
GST_STATE_TRANSITION (element)); GST_STATE_TRANSITION (element));
/* FIXME: not doable with current threading mess: /* FIXME: not doable with current threading mess:
g_assert_not_reached (); g_assert_not_reached ();
*/ */
@ -581,13 +583,13 @@ gst_thread_main_loop (void *arg)
status = TRUE; status = TRUE;
GST_LOG_OBJECT (thread, "starting to iterate"); GST_LOG_OBJECT (thread, "starting to iterate");
while (status && GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) { while (status && GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) {
g_mutex_unlock (thread->lock); g_mutex_unlock (thread->lock);
status = gst_bin_iterate (GST_BIN (thread)); status = gst_bin_iterate (GST_BIN (thread));
if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) { if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) {
GST_FLAG_UNSET (thread, GST_THREAD_MUTEX_LOCKED); GST_FLAG_UNSET (thread, GST_THREAD_MUTEX_LOCKED);
} else { } else {
g_mutex_lock (thread->lock); g_mutex_lock (thread->lock);
} }
} }
GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING);
} }

View file

@ -36,7 +36,7 @@ gst_mutex_new_dummy_impl (void)
static void static void
gst_mutex_dummy_impl (GMutex * mutex) gst_mutex_dummy_impl (GMutex * mutex)
{ /* NOP */ { /* NOP */
} }
static gboolean static gboolean
@ -56,7 +56,7 @@ gst_cond_new_dummy_impl (void)
static void static void
gst_cond_dummy_impl (GCond * cond) gst_cond_dummy_impl (GCond * cond)
{ /* NOP */ { /* NOP */
} }
static gboolean static gboolean
@ -118,17 +118,17 @@ gst_thread_create_dummy_impl (GThreadFunc func, gpointer data,
static void static void
gst_thread_dummy_impl (void) gst_thread_dummy_impl (void)
{ /* NOP */ { /* NOP */
} }
static void static void
gst_thread_dummy_impl_1 (gpointer thread) gst_thread_dummy_impl_1 (gpointer thread)
{ /* NOP */ { /* NOP */
} }
static void static void
gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority) gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority)
{ /* NOP */ { /* NOP */
} }
static gboolean static gboolean
@ -138,23 +138,24 @@ gst_thread_equal_dummy_impl (gpointer thread1, gpointer thread2)
} }
GThreadFunctions gst_thread_dummy_functions = { GThreadFunctions gst_thread_dummy_functions = {
gst_mutex_new_dummy_impl, gst_mutex_new_dummy_impl,
(void (*)(GMutex *)) gst_mutex_dummy_impl, (void (*)(GMutex *)) gst_mutex_dummy_impl,
gst_mutex_trylock_dummy_impl, gst_mutex_trylock_dummy_impl,
(void (*)(GMutex *)) gst_mutex_dummy_impl, (void (*)(GMutex *)) gst_mutex_dummy_impl,
gst_mutex_dummy_impl, gst_mutex_dummy_impl,
gst_cond_new_dummy_impl, gst_cond_new_dummy_impl,
(void (*)(GCond *)) gst_cond_dummy_impl, (void (*)(GCond *)) gst_cond_dummy_impl,
(void (*)(GCond *)) gst_cond_dummy_impl, (void (*)(GCond *)) gst_cond_dummy_impl,
(void (*)(GCond *, GMutex *)) gst_cond_dummy_impl, (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl,
gst_cond_timed_wait_dummy_impl, gst_cond_timed_wait_dummy_impl,
gst_cond_dummy_impl, gst_cond_dummy_impl,
gst_private_new_dummy_impl, gst_private_new_dummy_impl,
gst_private_get_dummy_impl, gst_private_get_dummy_impl,
gst_private_set_dummy_impl, gst_private_set_dummy_impl,
gst_thread_create_dummy_impl, gst_thread_create_dummy_impl,
gst_thread_dummy_impl, gst_thread_dummy_impl,
gst_thread_dummy_impl_1, gst_thread_dummy_impl_1,
gst_thread_dummy_impl, gst_thread_dummy_impl,
gst_thread_set_priority_dummy_impl, gst_thread_set_priority_dummy_impl,
gst_thread_dummy_impl_1, gst_thread_equal_dummy_impl}; gst_thread_dummy_impl_1, gst_thread_equal_dummy_impl
};

View file

@ -121,8 +121,8 @@ gst_trace_text_flush (GstTrace * trace)
for (i = 0; i < trace->bufoffset; i++) { for (i = 0; i < trace->bufoffset; i++) {
snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n", snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n",
trace->buf[i].timestamp, trace->buf[i].timestamp,
trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message); trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message);
write (trace->fd, str, strlen (str)); write (trace->fd, str, strlen (str));
} }
trace->bufoffset = 0; trace->bufoffset = 0;
@ -340,8 +340,8 @@ gst_alloc_trace_print (const GstAllocTrace * trace)
g_print (", dumping live memory: "); g_print (", dumping live memory: ");
while (mem_live) { while (mem_live) {
g_print ("%p ", mem_live->data); g_print ("%p ", mem_live->data);
mem_live = g_slist_next (mem_live); mem_live = g_slist_next (mem_live);
} }
g_print ("\ntotal %d", g_slist_length (trace->mem_live)); g_print ("\ntotal %d", g_slist_length (trace->mem_live));
} }

View file

@ -56,10 +56,11 @@ gst_type_find_factory_get_type (void)
gst_type_find_factory_init, gst_type_find_factory_init,
NULL NULL
}; };
typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstTypeFindFactory", &typefind_info, 0); "GstTypeFindFactory", &typefind_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND", GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND",
GST_DEBUG_FG_GREEN, "typefinding subsystem"); GST_DEBUG_FG_GREEN, "typefinding subsystem");
} }
return typefind_type; return typefind_type;
@ -120,7 +121,7 @@ gst_type_find_load_plugin (GstTypeFind * find, gpointer data)
if (factory->function == gst_type_find_load_plugin) { if (factory->function == gst_type_find_load_plugin) {
/* looks like we didn't get a real typefind function */ /* looks like we didn't get a real typefind function */
g_warning ("could not load valid typefind function for feature '%s'\n", g_warning ("could not load valid typefind function for feature '%s'\n",
GST_PLUGIN_FEATURE_NAME (factory)); GST_PLUGIN_FEATURE_NAME (factory));
} else { } else {
g_assert (factory->function); g_assert (factory->function);
gst_type_find_factory_call_function (factory, find); gst_type_find_factory_call_function (factory, find);
@ -231,7 +232,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
GST_INFO ("registering typefind function for %s", name); GST_INFO ("registering typefind function for %s", name);
factory = factory =
GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name, GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name,
GST_TYPE_TYPE_FIND_FACTORY)); GST_TYPE_TYPE_FIND_FACTORY));
if (!factory) { if (!factory) {
factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL); factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name); GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);

View file

@ -54,11 +54,12 @@ gst_uri_handler_get_type (void)
NULL, NULL,
NULL NULL
}; };
urihandler_type = g_type_register_static (G_TYPE_INTERFACE, urihandler_type = g_type_register_static (G_TYPE_INTERFACE,
"GstURIHandler", &urihandler_info, 0); "GstURIHandler", &urihandler_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD, GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD,
"handling of URIs"); "handling of URIs");
} }
return urihandler_type; return urihandler_type;
} }
@ -69,8 +70,8 @@ gst_uri_handler_base_init (gpointer g_class)
if (!initialized) { if (!initialized) {
g_signal_new ("new-uri", GST_TYPE_URI_HANDLER, G_SIGNAL_RUN_LAST, g_signal_new ("new-uri", GST_TYPE_URI_HANDLER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL, G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL,
gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
initialized = TRUE; initialized = TRUE;
} }
} }
@ -200,7 +201,8 @@ typedef struct
{ {
GstURIType type; GstURIType type;
gchar *protocol; gchar *protocol;
} SearchEntry; }
SearchEntry;
static gboolean static gboolean
search_by_entry (GstPluginFeature * feature, gpointer search_entry) search_by_entry (GstPluginFeature * feature, gpointer search_entry)
{ {
@ -265,7 +267,7 @@ gst_element_make_from_uri (const GstURIType type, const gchar * uri,
if (!possibilities) { if (!possibilities) {
GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source", GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source",
uri); uri);
return NULL; return NULL;
} }
@ -273,11 +275,11 @@ gst_element_make_from_uri (const GstURIType type, const gchar * uri,
walk = possibilities; walk = possibilities;
while (walk) { while (walk) {
if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data), if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data),
elementname)) != NULL) { elementname)) != NULL) {
GstURIHandler *handler = GST_URI_HANDLER (ret); GstURIHandler *handler = GST_URI_HANDLER (ret);
if (gst_uri_handler_set_uri (handler, uri)) if (gst_uri_handler_set_uri (handler, uri))
break; break;
g_object_unref (ret); g_object_unref (ret);
ret = NULL; ret = NULL;
} }

View file

@ -56,7 +56,7 @@ gst_util_dump_mem (guchar * mem, guint size)
if (j == 16 || i == size) { if (j == 16 || i == size) {
g_print ("%08x (%p): %-48.48s %-16.16s\n", i - j, mem + i - j, g_print ("%08x (%p): %-48.48s %-16.16s\n", i - j, mem + i - j,
string->str, chars->str); string->str, chars->str);
g_string_set_size (string, 0); g_string_set_size (string, 0);
g_string_set_size (chars, 0); g_string_set_size (chars, 0);
j = 0; j = 0;
@ -122,7 +122,7 @@ gst_util_set_value_from_string (GValue * value, const gchar * value_str)
gboolean i = FALSE; gboolean i = FALSE;
if (!strncmp ("true", value_str, 4)) if (!strncmp ("true", value_str, 4))
i = TRUE; i = TRUE;
g_value_set_boolean (value, i); g_value_set_boolean (value, i);
break; break;
} }
@ -176,95 +176,95 @@ gst_util_set_object_arg (GObject * object, const gchar * name,
GParamSpec *paramspec; GParamSpec *paramspec;
paramspec = paramspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
if (!paramspec) { if (!paramspec) {
return; return;
} }
GST_DEBUG ("paramspec->flags is %d, paramspec->value_type is %d", GST_DEBUG ("paramspec->flags is %d, paramspec->value_type is %d",
paramspec->flags, (gint) paramspec->value_type); paramspec->flags, (gint) paramspec->value_type);
if (paramspec->flags & G_PARAM_WRITABLE) { if (paramspec->flags & G_PARAM_WRITABLE) {
switch (paramspec->value_type) { switch (paramspec->value_type) {
case G_TYPE_STRING: case G_TYPE_STRING:
g_object_set (G_OBJECT (object), name, value, NULL); g_object_set (G_OBJECT (object), name, value, NULL);
break; break;
case G_TYPE_ENUM: case G_TYPE_ENUM:
case G_TYPE_INT:{ case G_TYPE_INT:{
gint i; gint i;
sscanf (value, "%d", &i); sscanf (value, "%d", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_UINT:{ case G_TYPE_UINT:{
guint i; guint i;
sscanf (value, "%u", &i); sscanf (value, "%u", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_LONG:{ case G_TYPE_LONG:{
glong i; glong i;
sscanf (value, "%ld", &i); sscanf (value, "%ld", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_ULONG:{ case G_TYPE_ULONG:{
gulong i; gulong i;
sscanf (value, "%lu", &i); sscanf (value, "%lu", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_BOOLEAN:{ case G_TYPE_BOOLEAN:{
gboolean i = FALSE; gboolean i = FALSE;
if (!g_ascii_strncasecmp ("true", value, 4)) if (!g_ascii_strncasecmp ("true", value, 4))
i = TRUE; i = TRUE;
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_CHAR:{ case G_TYPE_CHAR:{
gchar i; gchar i;
sscanf (value, "%c", &i); sscanf (value, "%c", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_UCHAR:{ case G_TYPE_UCHAR:{
guchar i; guchar i;
sscanf (value, "%c", &i); sscanf (value, "%c", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_FLOAT:{ case G_TYPE_FLOAT:{
gfloat i; gfloat i;
sscanf (value, "%f", &i); sscanf (value, "%f", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
break; break;
} }
case G_TYPE_DOUBLE:{ case G_TYPE_DOUBLE:{
gfloat i; gfloat i;
sscanf (value, "%g", &i); sscanf (value, "%g", &i);
g_object_set (G_OBJECT (object), name, (gdouble) i, NULL); g_object_set (G_OBJECT (object), name, (gdouble) i, NULL);
break; break;
} }
default: default:
if (G_IS_PARAM_SPEC_ENUM (paramspec)) { if (G_IS_PARAM_SPEC_ENUM (paramspec)) {
gint i; gint i;
sscanf (value, "%d", &i); sscanf (value, "%d", &i);
g_object_set (G_OBJECT (object), name, i, NULL); g_object_set (G_OBJECT (object), name, i, NULL);
} else if (paramspec->value_type == GST_TYPE_URI) { } else if (paramspec->value_type == GST_TYPE_URI) {
g_object_set (G_OBJECT (object), name, value, NULL); g_object_set (G_OBJECT (object), name, value, NULL);
} }
break; break;
} }
} }
} }
@ -308,7 +308,7 @@ gst_print_pad_caps (GString * buf, gint indent, GstPad * pad)
if (!caps) { if (!caps) {
string_append_indent (buf, indent); string_append_indent (buf, indent);
g_string_printf (buf, "%s:%s has no capabilities", g_string_printf (buf, "%s:%s has no capabilities",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
} else { } else {
char *s; char *s;
@ -331,7 +331,7 @@ void
gst_print_element_args (GString * buf, gint indent, GstElement * element) gst_print_element_args (GString * buf, gint indent, GstElement * element)
{ {
guint width; guint width;
GValue value = { 0, }; /* the important thing is that value.type = 0 */ GValue value = { 0, }; /* the important thing is that value.type = 0 */
gchar *str = 0; gchar *str = 0;
GParamSpec *spec, **specs, **walk; GParamSpec *spec, **specs, **walk;

View file

@ -71,7 +71,7 @@ gst_value_list_array_copy (const GArray * src)
g_array_set_size (dest, src->len); g_array_set_size (dest, src->len);
for (i = 0; i < src->len; i++) { for (i = 0; i < src->len; i++) {
gst_value_init_and_copy (&g_array_index (dest, GValue, i), gst_value_init_and_copy (&g_array_index (dest, GValue, i),
&g_array_index (src, GValue, i)); &g_array_index (src, GValue, i));
} }
return dest; return dest;
@ -113,7 +113,7 @@ gst_value_collect_list (GValue * value, guint n_collect_values,
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
} else { } else {
value->data[0].v_pointer = value->data[0].v_pointer =
gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer); gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer);
} }
return NULL; return NULL;
} }
@ -126,10 +126,10 @@ gst_value_lcopy_list (const GValue * value, guint n_collect_values,
if (!dest) if (!dest)
return g_strdup_printf ("value location for `%s' passed as NULL", return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
if (!value->data[0].v_pointer) if (!value->data[0].v_pointer)
return g_strdup_printf ("invalid value given for `%s'", return g_strdup_printf ("invalid value given for `%s'",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
if (collect_flags & G_VALUE_NOCOPY_CONTENTS) { if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
*dest = (GArray *) value->data[0].v_pointer; *dest = (GArray *) value->data[0].v_pointer;
} else { } else {
@ -220,7 +220,7 @@ gst_value_list_concat (GValue * dest, const GValue * value1,
if (GST_VALUE_HOLDS_LIST (value1)) { if (GST_VALUE_HOLDS_LIST (value1)) {
for (i = 0; i < value1_length; i++) { for (i = 0; i < value1_length; i++) {
gst_value_init_and_copy (&g_array_index (array, GValue, i), gst_value_init_and_copy (&g_array_index (array, GValue, i),
gst_value_list_get_value (value1, i)); gst_value_list_get_value (value1, i));
} }
} else { } else {
gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1); gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1);
@ -229,11 +229,11 @@ gst_value_list_concat (GValue * dest, const GValue * value1,
if (GST_VALUE_HOLDS_LIST (value2)) { if (GST_VALUE_HOLDS_LIST (value2)) {
for (i = 0; i < value2_length; i++) { for (i = 0; i < value2_length; i++) {
gst_value_init_and_copy (&g_array_index (array, GValue, gst_value_init_and_copy (&g_array_index (array, GValue,
i + value1_length), gst_value_list_get_value (value2, i)); i + value1_length), gst_value_list_get_value (value2, i));
} }
} else { } else {
gst_value_init_and_copy (&g_array_index (array, GValue, value1_length), gst_value_init_and_copy (&g_array_index (array, GValue, value1_length),
value2); value2);
} }
} }
@ -281,7 +281,7 @@ gst_value_compare_list (const GValue * value1, const GValue * value2)
for (j = 0; j < array1->len; j++) { for (j = 0; j < array1->len; j++) {
v2 = &g_array_index (array2, GValue, j); v2 = &g_array_index (array2, GValue, j);
if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL) if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL)
break; break;
} }
if (j == array1->len) { if (j == array1->len) {
return GST_VALUE_UNORDERED; return GST_VALUE_UNORDERED;
@ -353,7 +353,7 @@ gst_value_lcopy_fourcc (const GValue * value, guint n_collect_values,
if (!fourcc_p) if (!fourcc_p)
return g_strdup_printf ("value location for `%s' passed as NULL", return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
*fourcc_p = value->data[0].v_int; *fourcc_p = value->data[0].v_int;
@ -395,7 +395,7 @@ gst_value_transform_fourcc_string (const GValue * src_value,
g_ascii_isprint ((fourcc >> 16) & 0xff) && g_ascii_isprint ((fourcc >> 16) & 0xff) &&
g_ascii_isprint ((fourcc >> 24) & 0xff)) { g_ascii_isprint ((fourcc >> 24) & 0xff)) {
dest_value->data[0].v_pointer = dest_value->data[0].v_pointer =
g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc)); g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
} else { } else {
dest_value->data[0].v_pointer = g_strdup_printf ("0x%08x", fourcc); dest_value->data[0].v_pointer = g_strdup_printf ("0x%08x", fourcc);
} }
@ -482,10 +482,10 @@ gst_value_lcopy_int_range (const GValue * value, guint n_collect_values,
if (!int_range_start) if (!int_range_start)
return g_strdup_printf ("start value location for `%s' passed as NULL", return g_strdup_printf ("start value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
if (!int_range_end) if (!int_range_end)
return g_strdup_printf ("end value location for `%s' passed as NULL", return g_strdup_printf ("end value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
*int_range_start = value->data[0].v_int; *int_range_start = value->data[0].v_int;
*int_range_end = value->data[1].v_int; *int_range_end = value->data[1].v_int;
@ -597,10 +597,10 @@ gst_value_lcopy_double_range (const GValue * value, guint n_collect_values,
if (!double_range_start) if (!double_range_start)
return g_strdup_printf ("start value location for `%s' passed as NULL", return g_strdup_printf ("start value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
if (!double_range_end) if (!double_range_end)
return g_strdup_printf ("end value location for `%s' passed as NULL", return g_strdup_printf ("end value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
*double_range_start = value->data[0].v_double; *double_range_start = value->data[0].v_double;
*double_range_end = value->data[1].v_double; *double_range_end = value->data[1].v_double;
@ -653,9 +653,9 @@ gst_value_transform_double_range_string (const GValue * src_value,
dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]", dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]",
g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE, g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE,
src_value->data[0].v_double), src_value->data[0].v_double),
g_ascii_dtostr (s2, G_ASCII_DTOSTR_BUF_SIZE, g_ascii_dtostr (s2, G_ASCII_DTOSTR_BUF_SIZE,
src_value->data[1].v_double)); src_value->data[1].v_double));
} }
static int static int
@ -1059,16 +1059,16 @@ gst_value_intersect_list (GValue * dest, const GValue * value1,
if (gst_value_intersect (&intersection, cur, value2)) { if (gst_value_intersect (&intersection, cur, value2)) {
/* append value */ /* append value */
if (!ret) { if (!ret) {
gst_value_init_and_copy (dest, &intersection); gst_value_init_and_copy (dest, &intersection);
ret = TRUE; ret = TRUE;
} else if (GST_VALUE_HOLDS_LIST (dest)) { } else if (GST_VALUE_HOLDS_LIST (dest)) {
gst_value_list_append_value (dest, &intersection); gst_value_list_append_value (dest, &intersection);
} else { } else {
GValue temp = { 0, }; GValue temp = { 0, };
gst_value_init_and_copy (&temp, dest); gst_value_init_and_copy (&temp, dest);
g_value_unset (dest); g_value_unset (dest);
gst_value_list_concat (dest, &temp, &intersection); gst_value_list_concat (dest, &temp, &intersection);
} }
g_value_unset (&intersection); g_value_unset (&intersection);
} }
@ -1142,7 +1142,7 @@ gst_value_can_union (const GValue * value1, const GValue * value2)
for (i = 0; i < gst_value_union_funcs->len; i++) { for (i = 0; i < gst_value_union_funcs->len; i++) {
union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
if (union_info->type1 == G_VALUE_TYPE (value1) && if (union_info->type1 == G_VALUE_TYPE (value1) &&
union_info->type2 == G_VALUE_TYPE (value2)) union_info->type2 == G_VALUE_TYPE (value2))
return TRUE; return TRUE;
} }
@ -1162,7 +1162,7 @@ gst_value_union (GValue * dest, const GValue * value1, const GValue * value2)
for (i = 0; i < gst_value_union_funcs->len; i++) { for (i = 0; i < gst_value_union_funcs->len; i++) {
union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i);
if (union_info->type1 == G_VALUE_TYPE (value1) && if (union_info->type1 == G_VALUE_TYPE (value1) &&
union_info->type2 == G_VALUE_TYPE (value2)) { union_info->type2 == G_VALUE_TYPE (value2)) {
return union_info->func (dest, value1, value2); return union_info->func (dest, value1, value2);
} }
} }
@ -1205,9 +1205,9 @@ gst_value_can_intersect (const GValue * value1, const GValue * value2)
for (i = 0; i < gst_value_intersect_funcs->len; i++) { for (i = 0; i < gst_value_intersect_funcs->len; i++) {
intersect_info = &g_array_index (gst_value_intersect_funcs, intersect_info = &g_array_index (gst_value_intersect_funcs,
GstValueIntersectInfo, i); GstValueIntersectInfo, i);
if (intersect_info->type1 == G_VALUE_TYPE (value1) && if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
intersect_info->type2 == G_VALUE_TYPE (value2)) intersect_info->type2 == G_VALUE_TYPE (value2))
return TRUE; return TRUE;
} }
@ -1234,14 +1234,14 @@ gst_value_intersect (GValue * dest, const GValue * value1,
for (i = 0; i < gst_value_intersect_funcs->len; i++) { for (i = 0; i < gst_value_intersect_funcs->len; i++) {
intersect_info = &g_array_index (gst_value_intersect_funcs, intersect_info = &g_array_index (gst_value_intersect_funcs,
GstValueIntersectInfo, i); GstValueIntersectInfo, i);
if (intersect_info->type1 == G_VALUE_TYPE (value1) && if (intersect_info->type1 == G_VALUE_TYPE (value1) &&
intersect_info->type2 == G_VALUE_TYPE (value2)) { intersect_info->type2 == G_VALUE_TYPE (value2)) {
ret = intersect_info->func (dest, value1, value2); ret = intersect_info->func (dest, value1, value2);
return ret; return ret;
} }
if (intersect_info->type1 == G_VALUE_TYPE (value2) && if (intersect_info->type1 == G_VALUE_TYPE (value2) &&
intersect_info->type2 == G_VALUE_TYPE (value1)) { intersect_info->type2 == G_VALUE_TYPE (value1)) {
ret = intersect_info->func (dest, value2, value1); ret = intersect_info->func (dest, value2, value1);
return ret; return ret;
} }
@ -1357,6 +1357,7 @@ _gst_value_initialize (void)
NULL, NULL,
NULL, NULL,
}; };
//const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, }; //const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
gst_value_table = g_array_new (FALSE, FALSE, sizeof (GstValueTable)); gst_value_table = g_array_new (FALSE, FALSE, sizeof (GstValueTable));
@ -1382,9 +1383,10 @@ _gst_value_initialize (void)
gst_value_serialize_fourcc, gst_value_serialize_fourcc,
gst_value_deserialize_fourcc, gst_value_deserialize_fourcc,
}; };
info.value_table = &value_table; info.value_table = &value_table;
gst_type_fourcc = gst_type_fourcc =
g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0); g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0);
gst_value.type = gst_type_fourcc; gst_value.type = gst_type_fourcc;
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1406,9 +1408,10 @@ _gst_value_initialize (void)
gst_value_serialize_int_range, gst_value_serialize_int_range,
gst_value_deserialize_int_range, gst_value_deserialize_int_range,
}; };
info.value_table = &value_table; info.value_table = &value_table;
gst_type_int_range = gst_type_int_range =
g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0); g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0);
gst_value.type = gst_type_int_range; gst_value.type = gst_type_int_range;
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1430,9 +1433,10 @@ _gst_value_initialize (void)
gst_value_serialize_double_range, gst_value_serialize_double_range,
gst_value_deserialize_double_range, gst_value_deserialize_double_range,
}; };
info.value_table = &value_table; info.value_table = &value_table;
gst_type_double_range = gst_type_double_range =
g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0); g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0);
gst_value.type = gst_type_double_range; gst_value.type = gst_type_double_range;
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1454,9 +1458,10 @@ _gst_value_initialize (void)
gst_value_serialize_list, gst_value_serialize_list,
gst_value_deserialize_list, gst_value_deserialize_list,
}; };
info.value_table = &value_table; info.value_table = &value_table;
gst_type_list = gst_type_list =
g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0); g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0);
gst_value.type = gst_type_list; gst_value.type = gst_type_list;
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1468,6 +1473,7 @@ _gst_value_initialize (void)
gst_value_serialize_int, gst_value_serialize_int,
gst_value_deserialize_int, gst_value_deserialize_int,
}; };
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1478,6 +1484,7 @@ _gst_value_initialize (void)
gst_value_serialize_double, gst_value_serialize_double,
gst_value_deserialize_double, gst_value_deserialize_double,
}; };
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1488,6 +1495,7 @@ _gst_value_initialize (void)
gst_value_serialize_string, gst_value_serialize_string,
gst_value_deserialize_string, gst_value_deserialize_string,
}; };
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }
@ -1498,6 +1506,7 @@ _gst_value_initialize (void)
gst_value_serialize_boolean, gst_value_serialize_boolean,
gst_value_deserialize_boolean, gst_value_deserialize_boolean,
}; };
gst_value_register (&gst_value); gst_value_register (&gst_value);
} }

View file

@ -60,6 +60,7 @@ gst_xml_get_type (void)
(GInstanceInitFunc) gst_xml_init, (GInstanceInitFunc) gst_xml_init,
NULL NULL
}; };
xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0); xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0);
} }
return xml_type; return xml_type;
@ -168,14 +169,14 @@ gst_xml_write_file (GstElement * element, FILE * out)
if (cur->charset != XML_CHAR_ENCODING_UTF8) { if (cur->charset != XML_CHAR_ENCODING_UTF8) {
xmlGenericError (xmlGenericErrorContext, xmlGenericError (xmlGenericErrorContext,
"xmlDocDump: document not in UTF8\n"); "xmlDocDump: document not in UTF8\n");
return -1; return -1;
} }
if (enc != XML_CHAR_ENCODING_UTF8) { if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler (encoding); handler = xmlFindCharEncodingHandler (encoding);
if (handler == NULL) { if (handler == NULL) {
xmlFree ((char *) cur->encoding); xmlFree ((char *) cur->encoding);
cur->encoding = NULL; cur->encoding = NULL;
} }
} }
} }
@ -368,10 +369,10 @@ gst_xml_get_element (GstXML * xml, const guchar * name)
return top; return top;
} else { } else {
if (GST_IS_BIN (top)) { if (GST_IS_BIN (top)) {
element = gst_bin_get_by_name (GST_BIN (top), name); element = gst_bin_get_by_name (GST_BIN (top), name);
if (element) if (element)
return element; return element;
} }
} }
topelements = g_list_next (topelements); topelements = g_list_next (topelements);

View file

@ -78,7 +78,8 @@ typedef struct
gint nformats; gint nformats;
GstFormat *format; GstFormat *format;
GArray *array; GArray *array;
} GstFileIndexId; }
GstFileIndexId;
typedef struct _GstFileIndex GstFileIndex; typedef struct _GstFileIndex GstFileIndex;
typedef struct _GstFileIndexClass GstFileIndexClass; typedef struct _GstFileIndexClass GstFileIndexClass;
@ -106,7 +107,7 @@ struct _GstFileIndex
gint next_id; gint next_id;
GHashTable *id_index; GHashTable *id_index;
GstIndexEntry *ret_entry; /* hack to avoid leaking memory */ GstIndexEntry *ret_entry; /* hack to avoid leaking memory */
}; };
struct _GstFileIndexClass struct _GstFileIndexClass
@ -164,9 +165,10 @@ gst_file_index_get_type (void)
(GInstanceInitFunc) gst_file_index_init, (GInstanceInitFunc) gst_file_index_init,
NULL NULL
}; };
file_index_type = file_index_type =
g_type_register_static (GST_TYPE_INDEX, "GstFileIndex", g_type_register_static (GST_TYPE_INDEX, "GstFileIndex",
&file_index_info, 0); &file_index_info, 0);
} }
return file_index_type; return file_index_type;
} }
@ -193,7 +195,7 @@ gst_file_index_class_init (GstFileIndexClass * klass)
g_object_class_install_property (gobject_class, ARG_LOCATION, g_object_class_install_property (gobject_class, ARG_LOCATION,
g_param_spec_string ("location", "File Location", g_param_spec_string ("location", "File Location",
"Location of the index file", NULL, G_PARAM_READWRITE)); "Location of the index file", NULL, G_PARAM_READWRITE));
} }
static void static void
@ -251,7 +253,7 @@ gst_file_index_dispose (GObject * object)
g_hash_table_destroy (index->id_index); g_hash_table_destroy (index->id_index);
index->id_index = NULL; index->id_index = NULL;
gst_index_entry_free (index->ret_entry); /* hack */ gst_index_entry_free (index->ret_entry); /* hack */
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -299,7 +301,7 @@ gst_file_index_get_writer_id (GstIndex * _index,
if (match) { if (match) {
GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'", GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'",
writer_string); writer_string);
continue; continue;
} }
@ -320,10 +322,10 @@ gst_file_index_get_writer_id (GstIndex * _index,
if (cx.ii) { if (cx.ii) {
match = TRUE; match = TRUE;
GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again", GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again",
writer_string); writer_string);
} else } else
GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'", GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'",
writer_string); writer_string);
} }
return match; return match;
@ -384,73 +386,73 @@ gst_file_index_load (GstFileIndex * index)
xmlNodePtr writer; xmlNodePtr writer;
for (writer = part->children; writer; writer = writer->next) { for (writer = part->children; writer; writer = writer->next) {
xmlChar *datafile = xmlGetProp (writer, "datafile"); xmlChar *datafile = xmlGetProp (writer, "datafile");
gchar *path = g_strdup_printf ("%s/%s", index->location, datafile); gchar *path = g_strdup_printf ("%s/%s", index->location, datafile);
int fd; int fd;
GstFileIndexId *id_index; GstFileIndexId *id_index;
xmlNodePtr wpart; xmlNodePtr wpart;
xmlChar *entries_str; xmlChar *entries_str;
gpointer array_data; gpointer array_data;
free (datafile); free (datafile);
fd = open (path, O_RDONLY); fd = open (path, O_RDONLY);
g_free (path); g_free (path);
if (fd < 0) { if (fd < 0) {
GST_CAT_ERROR_OBJECT (DC, index, GST_CAT_ERROR_OBJECT (DC, index,
"Can't open '%s': %s", path, strerror (errno)); "Can't open '%s': %s", path, strerror (errno));
continue; continue;
} }
id_index = g_new0 (GstFileIndexId, 1); id_index = g_new0 (GstFileIndexId, 1);
id_index->id_desc = xmlGetProp (writer, "id"); id_index->id_desc = xmlGetProp (writer, "id");
for (wpart = writer->children; wpart; wpart = wpart->next) { for (wpart = writer->children; wpart; wpart = wpart->next) {
if (strcmp (wpart->name, "formats") == 0) { if (strcmp (wpart->name, "formats") == 0) {
xmlChar *count_str = xmlGetProp (wpart, "count"); xmlChar *count_str = xmlGetProp (wpart, "count");
gint fx = 0; gint fx = 0;
xmlNodePtr format; xmlNodePtr format;
id_index->nformats = atoi (count_str); id_index->nformats = atoi (count_str);
free (count_str); free (count_str);
id_index->format = g_new (GstFormat, id_index->nformats); id_index->format = g_new (GstFormat, id_index->nformats);
for (format = wpart->children; format; format = format->next) { for (format = wpart->children; format; format = format->next) {
xmlChar *nick = xmlGetProp (format, "nick"); xmlChar *nick = xmlGetProp (format, "nick");
GstFormat fmt = gst_format_get_by_nick (nick); GstFormat fmt = gst_format_get_by_nick (nick);
if (fmt == GST_FORMAT_UNDEFINED) if (fmt == GST_FORMAT_UNDEFINED)
GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick); GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick);
g_assert (fx < id_index->nformats); g_assert (fx < id_index->nformats);
id_index->format[fx++] = fmt; id_index->format[fx++] = fmt;
free (nick); free (nick);
} }
} else } else
GST_CAT_INFO_OBJECT (DC, index, "unknown wpart '%s'", wpart->name); GST_CAT_INFO_OBJECT (DC, index, "unknown wpart '%s'", wpart->name);
} }
g_assert (id_index->nformats > 0); g_assert (id_index->nformats > 0);
_fc_alloc_array (id_index); _fc_alloc_array (id_index);
g_assert (id_index->array->data == NULL); /* little bit risky */ g_assert (id_index->array->data == NULL); /* little bit risky */
entries_str = xmlGetProp (writer, "entries"); entries_str = xmlGetProp (writer, "entries");
id_index->array->len = atoi (entries_str); id_index->array->len = atoi (entries_str);
free (entries_str); free (entries_str);
array_data = array_data =
mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd,
0); 0);
close (fd); close (fd);
if (array_data == MAP_FAILED) { if (array_data == MAP_FAILED) {
GST_CAT_ERROR_OBJECT (DC, index, GST_CAT_ERROR_OBJECT (DC, index,
"mmap %s failed: %s", path, strerror (errno)); "mmap %s failed: %s", path, strerror (errno));
continue; continue;
} }
id_index->array->data = array_data; id_index->array->data = array_data;
index->unresolved = g_slist_prepend (index->unresolved, id_index); index->unresolved = g_slist_prepend (index->unresolved, id_index);
} }
} else } else
GST_CAT_INFO_OBJECT (DC, index, "unknown part '%s'", part->name); GST_CAT_INFO_OBJECT (DC, index, "unknown part '%s'", part->name);
@ -472,11 +474,11 @@ gst_file_index_set_property (GObject * object,
switch (prop_id) { switch (prop_id) {
case ARG_LOCATION: case ARG_LOCATION:
if (index->location) if (index->location)
g_free (index->location); g_free (index->location);
index->location = g_value_dup_string (value); index->location = g_value_dup_string (value);
if (index->location && !g_hash_table_size (index->id_index)) if (index->location && !g_hash_table_size (index->id_index))
gst_file_index_load (index); gst_file_index_load (index);
break; break;
} }
} }
@ -512,7 +514,7 @@ _file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers)
xmlSetProp (writer, "id", ii->id_desc); xmlSetProp (writer, "id", ii->id_desc);
g_snprintf (buf, bufsize, "%d", ii->array->len); g_snprintf (buf, bufsize, "%d", ii->array->len);
xmlSetProp (writer, "entries", buf); xmlSetProp (writer, "entries", buf);
g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */
xmlSetProp (writer, "datafile", buf); xmlSetProp (writer, "datafile", buf);
formats = xmlNewChild (writer, NULL, "formats", NULL); formats = xmlNewChild (writer, NULL, "formats", NULL);
@ -604,7 +606,7 @@ gst_file_index_commit (GstIndex * _index, gint _writer_id)
if (mkdir (index->location, 0777) && errno != EEXIST) { if (mkdir (index->location, 0777) && errno != EEXIST) {
GST_CAT_ERROR_OBJECT (DC, index, GST_CAT_ERROR_OBJECT (DC, index,
"mkdir %s: %s", index->location, strerror (errno)); "mkdir %s: %s", index->location, strerror (errno));
return; return;
} }
@ -705,11 +707,11 @@ _fc_bsearch (GArray * ary,
if (cmp == 0) { if (cmp == 0) {
/* if there are multiple matches then scan for the first match */ /* if there are multiple matches then scan for the first match */
while (mid > 0 && while (mid > 0 &&
(*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0) (*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0)
--mid; --mid;
if (ret) if (ret)
*ret = mid; *ret = mid;
return TRUE; return TRUE;
} }
@ -726,12 +728,12 @@ _fc_bsearch (GArray * ary,
if (cmp < 0) { if (cmp < 0) {
if (ret) if (ret)
*ret = tx; *ret = tx;
return FALSE; return FALSE;
} }
if (cmp == 0) { if (cmp == 0) {
if (ret) if (ret)
*ret = tx; *ret = tx;
return TRUE; return TRUE;
} }
} }
@ -772,7 +774,7 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
id_index->nformats = GST_INDEX_NASSOCS (entry); id_index->nformats = GST_INDEX_NASSOCS (entry);
GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d", GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d",
id_index->nformats, entry->id); id_index->nformats, entry->id);
id_index->format = g_new (GstFormat, id_index->nformats); id_index->format = g_new (GstFormat, id_index->nformats);
for (fx = 0; fx < id_index->nformats; fx++) for (fx = 0; fx < id_index->nformats; fx++)
id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx); id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx);
@ -781,14 +783,14 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
/* only sanity checking */ /* only sanity checking */
if (id_index->nformats != GST_INDEX_NASSOCS (entry)) if (id_index->nformats != GST_INDEX_NASSOCS (entry))
GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d", GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d",
id_index->nformats, GST_INDEX_NASSOCS (entry)); id_index->nformats, GST_INDEX_NASSOCS (entry));
else { else {
gint fx; gint fx;
for (fx = 0; fx < id_index->nformats; fx++) for (fx = 0; fx < id_index->nformats; fx++)
if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx)) if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx))
GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d", GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d",
fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx)); fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx));
} }
} }
@ -803,8 +805,8 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
if (exact) { if (exact) {
/* maybe overwrite instead? */ /* maybe overwrite instead? */
GST_CAT_DEBUG_OBJECT (DC, index, GST_CAT_DEBUG_OBJECT (DC, index,
"Ignoring duplicate index association at %lld", "Ignoring duplicate index association at %lld",
GST_INDEX_ASSOC_VALUE (entry, 0)); GST_INDEX_ASSOC_VALUE (entry, 0));
return; return;
} }
@ -872,7 +874,7 @@ gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry)
break; break;
case GST_INDEX_ENTRY_OBJECT: case GST_INDEX_ENTRY_OBJECT:
GST_CAT_ERROR_OBJECT (DC, index, GST_CAT_ERROR_OBJECT (DC, index,
"gst_file_index_add_object not implemented"); "gst_file_index_add_object not implemented");
break; break;
case GST_INDEX_ENTRY_FORMAT: case GST_INDEX_ENTRY_FORMAT:
/* /*
@ -880,7 +882,7 @@ gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry)
GST_INDEX_ENTRY_* can probably go away. GST_INDEX_ENTRY_* can probably go away.
*/ */
GST_CAT_DEBUG_OBJECT (DC, index, GST_CAT_DEBUG_OBJECT (DC, index,
"gst_file_index_add_format not implemented"); "gst_file_index_add_format not implemented");
break; break;
default: default:
break; break;
@ -922,7 +924,7 @@ gst_file_index_get_assoc_entry (GstIndex * index,
if (formatx == -1) { if (formatx == -1) {
GST_CAT_WARNING_OBJECT (DC, fileindex, GST_CAT_WARNING_OBJECT (DC, fileindex,
"%s, format %d not available", __FUNCTION__, format); "%s, format %d not available", __FUNCTION__, format);
return NULL; return NULL;
} }
@ -938,11 +940,11 @@ gst_file_index_get_assoc_entry (GstIndex * index,
return NULL; return NULL;
else if (method == GST_INDEX_LOOKUP_BEFORE) { else if (method == GST_INDEX_LOOKUP_BEFORE) {
if (mx == 0) if (mx == 0)
return NULL; return NULL;
mx -= 1; mx -= 1;
} else if (method == GST_INDEX_LOOKUP_AFTER) { } else if (method == GST_INDEX_LOOKUP_AFTER) {
if (mx == id_index->array->len) if (mx == id_index->array->len)
return NULL; return NULL;
} }
} }
@ -952,11 +954,11 @@ gst_file_index_get_assoc_entry (GstIndex * index,
if (method != GST_INDEX_LOOKUP_EXACT) if (method != GST_INDEX_LOOKUP_EXACT)
while ((GINT32_FROM_BE (ARRAY_ROW_FLAGS (row_data)) & flags) != flags) { while ((GINT32_FROM_BE (ARRAY_ROW_FLAGS (row_data)) & flags) != flags) {
if (method == GST_INDEX_LOOKUP_BEFORE) if (method == GST_INDEX_LOOKUP_BEFORE)
mx -= 1; mx -= 1;
else if (method == GST_INDEX_LOOKUP_AFTER) else if (method == GST_INDEX_LOOKUP_AFTER)
mx += 1; mx += 1;
if (mx < 0 || mx >= id_index->array->len) if (mx < 0 || mx >= id_index->array->len)
return NULL; return NULL;
row_data = id_index->array->data + mx * ARRAY_ROW_SIZE (id_index); row_data = id_index->array->data + mx * ARRAY_ROW_SIZE (id_index);
} }

View file

@ -66,13 +66,15 @@ typedef struct
GstFormat format; GstFormat format;
gint offset; gint offset;
GTree *tree; GTree *tree;
} GstMemIndexFormatIndex; }
GstMemIndexFormatIndex;
typedef struct typedef struct
{ {
gint id; gint id;
GHashTable *format_index; GHashTable *format_index;
} GstMemIndexId; }
GstMemIndexId;
typedef struct _GstMemIndex GstMemIndex; typedef struct _GstMemIndex GstMemIndex;
typedef struct _GstMemIndexClass GstMemIndexClass; typedef struct _GstMemIndexClass GstMemIndexClass;
@ -136,9 +138,10 @@ gst_mem_index_get_type (void)
(GInstanceInitFunc) gst_mem_index_init, (GInstanceInitFunc) gst_mem_index_init,
NULL NULL
}; };
mem_index_type = mem_index_type =
g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info,
0); 0);
} }
return mem_index_type; return mem_index_type;
} }
@ -293,7 +296,8 @@ typedef struct
gint64 low_diff; gint64 low_diff;
GstIndexEntry *higher; GstIndexEntry *higher;
gint64 high_diff; gint64 high_diff;
} GstMemIndexSearchData; }
GstMemIndexSearchData;
static gint static gint
mem_index_search (gconstpointer a, gconstpointer b) mem_index_search (gconstpointer a, gconstpointer b)
@ -382,16 +386,16 @@ gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
entry = NULL; entry = NULL;
while (l_entry) { while (l_entry) {
entry = (GstIndexEntry *) l_entry->data; entry = (GstIndexEntry *) l_entry->data;
if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags) if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
break; break;
if (method == GST_INDEX_LOOKUP_BEFORE) if (method == GST_INDEX_LOOKUP_BEFORE)
l_entry = g_list_next (l_entry); l_entry = g_list_next (l_entry);
else if (method == GST_INDEX_LOOKUP_AFTER) { else if (method == GST_INDEX_LOOKUP_AFTER) {
l_entry = g_list_previous (l_entry); l_entry = g_list_previous (l_entry);
} }
} }
} }
} }

View file

@ -143,7 +143,7 @@ gst_xml_registry_get_type (void)
}; };
xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY, xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY,
"GstXMLRegistry", &xml_registry_info, 0); "GstXMLRegistry", &xml_registry_info, 0);
} }
return xml_registry_type; return xml_registry_type;
} }
@ -168,7 +168,7 @@ gst_xml_registry_class_init (GstXMLRegistryClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION, g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION,
g_param_spec_string ("location", "Location", g_param_spec_string ("location", "Location",
"Location of the registry file", NULL, G_PARAM_READWRITE)); "Location of the registry file", NULL, G_PARAM_READWRITE));
gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load); gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load);
gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save); gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save);
@ -236,21 +236,21 @@ gst_xml_registry_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_LOCATION: case PROP_LOCATION:
if (registry->open) { if (registry->open) {
CLASS (object)->close_func (registry); CLASS (object)->close_func (registry);
g_return_if_fail (registry->open == FALSE); g_return_if_fail (registry->open == FALSE);
} }
if (registry->location) if (registry->location)
g_free (registry->location); g_free (registry->location);
registry->location = g_strdup (g_value_get_string (value)); registry->location = g_strdup (g_value_get_string (value));
GST_REGISTRY (registry)->flags = 0x0; GST_REGISTRY (registry)->flags = 0x0;
if (CLASS (object)->get_perms_func) if (CLASS (object)->get_perms_func)
CLASS (object)->get_perms_func (registry); CLASS (object)->get_perms_func (registry);
if (CLASS (object)->add_path_list_func) if (CLASS (object)->add_path_list_func)
CLASS (object)->add_path_list_func (registry); CLASS (object)->add_path_list_func (registry);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -311,11 +311,11 @@ make_dir (gchar * filename)
if (stat (dirname, &dirstat) == -1 && errno == ENOENT) { if (stat (dirname, &dirstat) == -1 && errno == ENOENT) {
if (mkdir (dirname, dirmode) != 0) { if (mkdir (dirname, dirmode) != 0) {
if (make_dir (dirname) != TRUE) { if (make_dir (dirname) != TRUE) {
g_free (dirname); g_free (dirname);
return FALSE; return FALSE;
} else { } else {
if (mkdir (dirname, dirmode) != 0) if (mkdir (dirname, dirmode) != 0)
return FALSE; return FALSE;
} }
} }
} }
@ -395,7 +395,7 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry * registry)
if (error) { if (error) {
GST_ERROR ("parsing registry %s: %s\n", GST_ERROR ("parsing registry %s: %s\n",
registry->location, error->message); registry->location, error->message);
goto finished; goto finished;
} }
@ -426,8 +426,8 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
if (pathtime > regtime) { if (pathtime > regtime) {
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
"time for %s was %ld; more recent than registry time of %ld\n", "time for %s was %ld; more recent than registry time of %ld\n",
path, (long) pathtime, (long) regtime); path, (long) pathtime, (long) regtime);
return FALSE; return FALSE;
} }
@ -436,13 +436,13 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
while ((dirent = readdir (dir))) { while ((dirent = readdir (dir))) {
/* don't want to recurse in place or backwards */ /* don't want to recurse in place or backwards */
if (strcmp (dirent->d_name, ".") && strcmp (dirent->d_name, "..")) { if (strcmp (dirent->d_name, ".") && strcmp (dirent->d_name, "..")) {
pluginname = g_strjoin ("/", path, dirent->d_name, NULL); pluginname = g_strjoin ("/", path, dirent->d_name, NULL);
if (!plugin_times_older_than_recurse (pluginname, regtime)) { if (!plugin_times_older_than_recurse (pluginname, regtime)) {
g_free (pluginname); g_free (pluginname);
closedir (dir); closedir (dir);
return FALSE; return FALSE;
} }
g_free (pluginname); g_free (pluginname);
} }
} }
closedir (dir); closedir (dir);
@ -459,8 +459,8 @@ plugin_times_older_than (GList * paths, time_t regtime)
while (paths) { while (paths) {
GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, GST_CAT_LOG (GST_CAT_PLUGIN_LOADING,
"comparing plugin times from %s with %ld", "comparing plugin times from %s with %ld",
(gchar *) paths->data, (long) regtime); (gchar *) paths->data, (long) regtime);
if (!plugin_times_older_than_recurse (paths->data, regtime)) if (!plugin_times_older_than_recurse (paths->data, regtime))
return FALSE; return FALSE;
paths = g_list_next (paths); paths = g_list_next (paths);
@ -487,16 +487,16 @@ gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) { if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
/* if it's not writable, then don't bother */ /* if it's not writable, then don't bother */
if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) { if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) {
GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable"); GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable");
return FALSE; return FALSE;
} }
GST_CAT_INFO (GST_CAT_GST_INIT, GST_CAT_INFO (GST_CAT_GST_INIT,
"Registry doesn't exist, trying to build..."); "Registry doesn't exist, trying to build...");
gst_registry_rebuild (gst_registry); gst_registry_rebuild (gst_registry);
gst_registry_save (gst_registry); gst_registry_save (gst_registry);
/* FIXME: verify that the flags actually get updated ! */ /* FIXME: verify that the flags actually get updated ! */
if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) { if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
return FALSE; return FALSE;
} }
} }
/* at this point we know it exists */ /* at this point we know it exists */
@ -504,32 +504,32 @@ gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
if (!plugin_times_older_than (paths, get_time (registry->location))) { if (!plugin_times_older_than (paths, get_time (registry->location))) {
if (gst_registry->flags & GST_REGISTRY_WRITABLE) { if (gst_registry->flags & GST_REGISTRY_WRITABLE) {
GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding..."); GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding...");
gst_registry_rebuild (gst_registry); gst_registry_rebuild (gst_registry);
gst_registry_save (gst_registry); gst_registry_save (gst_registry);
if (!plugin_times_older_than (paths, get_time (registry->location))) { if (!plugin_times_older_than (paths, get_time (registry->location))) {
GST_CAT_INFO (GST_CAT_GST_INIT, GST_CAT_INFO (GST_CAT_GST_INIT,
"Registry still out of date, something is wrong..."); "Registry still out of date, something is wrong...");
return FALSE; return FALSE;
} }
} else { } else {
GST_CAT_INFO (GST_CAT_GST_INIT, GST_CAT_INFO (GST_CAT_GST_INIT,
"Can't write to this registry and it's out of date, ignoring it"); "Can't write to this registry and it's out of date, ignoring it");
return FALSE; return FALSE;
} }
} }
GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for reading", GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for reading",
registry->location); registry->location);
registry->regfile = fopen (registry->location, "r"); registry->regfile = fopen (registry->location, "r");
} else if (mode == GST_XML_REGISTRY_WRITE) { } else if (mode == GST_XML_REGISTRY_WRITE) {
g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_WRITABLE, FALSE); g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_WRITABLE, FALSE);
GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for writing", GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for writing",
registry->location); registry->location);
registry->regfile = fopen (registry->location, "w"); registry->regfile = fopen (registry->location, "w");
} }
@ -644,7 +644,7 @@ gst_xml_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin)
if (!plugin) { if (!plugin) {
if (error) { if (error) {
g_warning ("could not load plugin %s: %s", plugin->desc.name, g_warning ("could not load plugin %s: %s", plugin->desc.name,
error->message); error->message);
g_error_free (error); g_error_free (error);
} }
return GST_REGISTRY_PLUGIN_LOAD_ERROR; return GST_REGISTRY_PLUGIN_LOAD_ERROR;
@ -842,7 +842,7 @@ gst_xml_registry_parse_padtemplate (GMarkupParseContext * context,
registry->caps = gst_caps_from_string (s); registry->caps = gst_caps_from_string (s);
if (registry->caps == NULL) { if (registry->caps == NULL) {
g_critical ("Could not parse caps: length %d, content: %*s\n", text_len, g_critical ("Could not parse caps: length %d, content: %*s\n", text_len,
text_len, text); text_len, text);
} }
g_free (s); g_free (s);
return TRUE; return TRUE;
@ -864,62 +864,62 @@ gst_xml_registry_start_element (GMarkupParseContext * context,
switch (xmlregistry->state) { switch (xmlregistry->state) {
case GST_XML_REGISTRY_NONE: case GST_XML_REGISTRY_NONE:
if (!strcmp (element_name, "GST-PluginRegistry")) { if (!strcmp (element_name, "GST-PluginRegistry")) {
xmlregistry->state = GST_XML_REGISTRY_TOP; xmlregistry->state = GST_XML_REGISTRY_TOP;
} }
break; break;
case GST_XML_REGISTRY_TOP: case GST_XML_REGISTRY_TOP:
if (!strncmp (element_name, "plugin", 6)) { if (!strncmp (element_name, "plugin", 6)) {
xmlregistry->state = GST_XML_REGISTRY_PLUGIN; xmlregistry->state = GST_XML_REGISTRY_PLUGIN;
xmlregistry->parser = gst_xml_registry_parse_plugin; xmlregistry->parser = gst_xml_registry_parse_plugin;
xmlregistry->current_plugin = (GstPlugin *) g_new0 (GstPlugin, 1); xmlregistry->current_plugin = (GstPlugin *) g_new0 (GstPlugin, 1);
} }
break; break;
case GST_XML_REGISTRY_PLUGIN: case GST_XML_REGISTRY_PLUGIN:
if (!strncmp (element_name, "feature", 7)) { if (!strncmp (element_name, "feature", 7)) {
gint i = 0; gint i = 0;
GstPluginFeature *feature = NULL; GstPluginFeature *feature = NULL;
xmlregistry->state = GST_XML_REGISTRY_FEATURE; xmlregistry->state = GST_XML_REGISTRY_FEATURE;
while (attribute_names[i]) { while (attribute_names[i]) {
if (!strncmp (attribute_names[i], "typename", 8)) { if (!strncmp (attribute_names[i], "typename", 8)) {
feature = feature =
GST_PLUGIN_FEATURE (g_object_new (g_type_from_name GST_PLUGIN_FEATURE (g_object_new (g_type_from_name
(attribute_values[i]), NULL)); (attribute_values[i]), NULL));
break; break;
} }
i++; i++;
} }
if (feature) { if (feature) {
xmlregistry->current_feature = feature; xmlregistry->current_feature = feature;
if (GST_IS_ELEMENT_FACTORY (feature)) { if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature); GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
factory->padtemplates = NULL; factory->padtemplates = NULL;
xmlregistry->parser = gst_xml_registry_parse_element_factory; xmlregistry->parser = gst_xml_registry_parse_element_factory;
break; break;
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) { } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_type_find_factory; xmlregistry->parser = gst_xml_registry_parse_type_find_factory;
} else if (GST_IS_SCHEDULER_FACTORY (feature)) { } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_scheduler_factory; xmlregistry->parser = gst_xml_registry_parse_scheduler_factory;
GST_SCHEDULER_FACTORY (feature)->type = 0; GST_SCHEDULER_FACTORY (feature)->type = 0;
} else if (GST_IS_INDEX_FACTORY (feature)) { } else if (GST_IS_INDEX_FACTORY (feature)) {
xmlregistry->parser = gst_xml_registry_parse_index_factory; xmlregistry->parser = gst_xml_registry_parse_index_factory;
} else { } else {
g_warning ("unknown feature type"); g_warning ("unknown feature type");
} }
} }
} }
break; break;
case GST_XML_REGISTRY_FEATURE: case GST_XML_REGISTRY_FEATURE:
if (!strncmp (element_name, "padtemplate", 11)) { if (!strncmp (element_name, "padtemplate", 11)) {
xmlregistry->state = GST_XML_REGISTRY_PADTEMPLATE; xmlregistry->state = GST_XML_REGISTRY_PADTEMPLATE;
xmlregistry->parser = gst_xml_registry_parse_padtemplate; xmlregistry->parser = gst_xml_registry_parse_padtemplate;
xmlregistry->name_template = NULL; xmlregistry->name_template = NULL;
xmlregistry->direction = 0; xmlregistry->direction = 0;
xmlregistry->presence = 0; xmlregistry->presence = 0;
xmlregistry->caps = NULL; xmlregistry->caps = NULL;
} }
break; break;
default: default:
@ -940,41 +940,41 @@ gst_xml_registry_end_element (GMarkupParseContext * context,
switch (xmlregistry->state) { switch (xmlregistry->state) {
case GST_XML_REGISTRY_TOP: case GST_XML_REGISTRY_TOP:
if (!strcmp (element_name, "GST-PluginRegistry")) { if (!strcmp (element_name, "GST-PluginRegistry")) {
xmlregistry->state = GST_XML_REGISTRY_NONE; xmlregistry->state = GST_XML_REGISTRY_NONE;
} }
break; break;
case GST_XML_REGISTRY_PLUGIN: case GST_XML_REGISTRY_PLUGIN:
if (!strcmp (element_name, "plugin")) { if (!strcmp (element_name, "plugin")) {
xmlregistry->state = GST_XML_REGISTRY_TOP; xmlregistry->state = GST_XML_REGISTRY_TOP;
xmlregistry->parser = NULL; xmlregistry->parser = NULL;
gst_registry_add_plugin (GST_REGISTRY (xmlregistry), gst_registry_add_plugin (GST_REGISTRY (xmlregistry),
xmlregistry->current_plugin); xmlregistry->current_plugin);
} }
break; break;
case GST_XML_REGISTRY_FEATURE: case GST_XML_REGISTRY_FEATURE:
if (!strcmp (element_name, "feature")) { if (!strcmp (element_name, "feature")) {
xmlregistry->state = GST_XML_REGISTRY_PLUGIN; xmlregistry->state = GST_XML_REGISTRY_PLUGIN;
xmlregistry->parser = gst_xml_registry_parse_plugin; xmlregistry->parser = gst_xml_registry_parse_plugin;
gst_plugin_add_feature (xmlregistry->current_plugin, gst_plugin_add_feature (xmlregistry->current_plugin,
xmlregistry->current_feature); xmlregistry->current_feature);
xmlregistry->current_feature = NULL; xmlregistry->current_feature = NULL;
} }
break; break;
case GST_XML_REGISTRY_PADTEMPLATE: case GST_XML_REGISTRY_PADTEMPLATE:
if (!strcmp (element_name, "padtemplate")) { if (!strcmp (element_name, "padtemplate")) {
GstPadTemplate *template; GstPadTemplate *template;
template = gst_pad_template_new (xmlregistry->name_template, template = gst_pad_template_new (xmlregistry->name_template,
xmlregistry->direction, xmlregistry->presence, xmlregistry->caps); xmlregistry->direction, xmlregistry->presence, xmlregistry->caps);
g_free (xmlregistry->name_template); g_free (xmlregistry->name_template);
xmlregistry->name_template = NULL; xmlregistry->name_template = NULL;
xmlregistry->caps = NULL; xmlregistry->caps = NULL;
__gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY __gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY
(xmlregistry->current_feature), template); (xmlregistry->current_feature), template);
xmlregistry->state = GST_XML_REGISTRY_FEATURE; xmlregistry->state = GST_XML_REGISTRY_FEATURE;
xmlregistry->parser = gst_xml_registry_parse_element_factory; xmlregistry->parser = gst_xml_registry_parse_element_factory;
} }
break; break;
default: default:
@ -996,7 +996,7 @@ gst_xml_registry_text (GMarkupParseContext * context, const gchar * text,
//gst_plugin_add_path (g_strndup (text, text_len)); //gst_plugin_add_path (g_strndup (text, text_len));
} else if (xmlregistry->parser) { } else if (xmlregistry->parser) {
xmlregistry->parser (context, open_tag, text, text_len, xmlregistry, xmlregistry->parser (context, open_tag, text, text_len, xmlregistry,
error); error);
} }
} }
} }
@ -1026,17 +1026,17 @@ gst_xml_registry_paths_start_element (GMarkupParseContext * context,
switch (xmlregistry->state) { switch (xmlregistry->state) {
case GST_XML_REGISTRY_NONE: case GST_XML_REGISTRY_NONE:
if (!strcmp (element_name, "GST-PluginRegistry")) { if (!strcmp (element_name, "GST-PluginRegistry")) {
xmlregistry->state = GST_XML_REGISTRY_TOP; xmlregistry->state = GST_XML_REGISTRY_TOP;
} }
break; break;
case GST_XML_REGISTRY_TOP: case GST_XML_REGISTRY_TOP:
if (!strcmp (element_name, "gst-registry-paths")) { if (!strcmp (element_name, "gst-registry-paths")) {
xmlregistry->state = GST_XML_REGISTRY_PATHS; xmlregistry->state = GST_XML_REGISTRY_PATHS;
} }
break; break;
case GST_XML_REGISTRY_PATHS: case GST_XML_REGISTRY_PATHS:
if (!strcmp (element_name, "path")) { if (!strcmp (element_name, "path")) {
xmlregistry->state = GST_XML_REGISTRY_PATH; xmlregistry->state = GST_XML_REGISTRY_PATH;
} }
break; break;
default: default:
@ -1053,12 +1053,12 @@ gst_xml_registry_paths_end_element (GMarkupParseContext * context,
switch (xmlregistry->state) { switch (xmlregistry->state) {
case GST_XML_REGISTRY_PATH: case GST_XML_REGISTRY_PATH:
if (!strcmp (element_name, "path")) { if (!strcmp (element_name, "path")) {
xmlregistry->state = GST_XML_REGISTRY_PATHS; xmlregistry->state = GST_XML_REGISTRY_PATHS;
} }
break; break;
case GST_XML_REGISTRY_PATHS: case GST_XML_REGISTRY_PATHS:
if (!strcmp (element_name, "gst-plugin-paths")) { if (!strcmp (element_name, "gst-plugin-paths")) {
xmlregistry->state = GST_XML_REGISTRY_PATHS_DONE; xmlregistry->state = GST_XML_REGISTRY_PATHS_DONE;
} }
break; break;
default: default:
@ -1074,7 +1074,7 @@ gst_xml_registry_paths_text (GMarkupParseContext * context, const gchar * text,
if (xmlregistry->state == GST_XML_REGISTRY_PATH) if (xmlregistry->state == GST_XML_REGISTRY_PATH)
gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text, gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text,
text_len)); text_len));
} }
/* /*
@ -1183,12 +1183,12 @@ gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry,
gchar **protocol; gchar **protocol;
PUT_ESCAPED ("uri_type", PUT_ESCAPED ("uri_type",
factory->uri_type == GST_URI_SINK ? "sink" : "source"); factory->uri_type == GST_URI_SINK ? "sink" : "source");
g_assert (factory->uri_protocols); g_assert (factory->uri_protocols);
protocol = factory->uri_protocols; protocol = factory->uri_protocols;
while (*protocol) { while (*protocol) {
PUT_ESCAPED ("uri_protocol", *protocol); PUT_ESCAPED ("uri_protocol", *protocol);
protocol++; protocol++;
} }
} }
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) { } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
@ -1200,8 +1200,8 @@ gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry,
} }
if (factory->extensions) { if (factory->extensions) {
while (factory->extensions[i]) { while (factory->extensions[i]) {
PUT_ESCAPED ("extension", factory->extensions[i]); PUT_ESCAPED ("extension", factory->extensions[i]);
i++; i++;
} }
} }
} else if (GST_IS_SCHEDULER_FACTORY (feature)) { } else if (GST_IS_SCHEDULER_FACTORY (feature)) {
@ -1231,7 +1231,7 @@ gst_xml_registry_save_plugin (GstXMLRegistry * xmlregistry, GstPlugin * plugin)
GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data); GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
CLASS (xmlregistry)->save_func (xmlregistry, "<feature typename=\"%s\">\n", CLASS (xmlregistry)->save_func (xmlregistry, "<feature typename=\"%s\">\n",
g_type_name (G_OBJECT_TYPE (feature))); g_type_name (G_OBJECT_TYPE (feature)));
gst_xml_registry_save_feature (xmlregistry, feature); gst_xml_registry_save_feature (xmlregistry, feature);
CLASS (xmlregistry)->save_func (xmlregistry, "</feature>\n"); CLASS (xmlregistry)->save_func (xmlregistry, "</feature>\n");
@ -1305,20 +1305,20 @@ gst_xml_registry_rebuild_recurse (GstXMLRegistry * registry,
gchar *dirname; gchar *dirname;
if (*dirent == '=') { if (*dirent == '=') {
/* =build, =inst, etc. -- automake distcheck directories */ /* =build, =inst, etc. -- automake distcheck directories */
continue; continue;
} }
dirname = g_strjoin ("/", directory, dirent, NULL); dirname = g_strjoin ("/", directory, dirent, NULL);
ret = ret =
g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry, g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry,
dirname)); dirname));
g_free (dirname); g_free (dirname);
} }
g_dir_close (dir); g_dir_close (dir);
} else { } else {
if ((temp = strstr (directory, G_MODULE_SUFFIX)) && if ((temp = strstr (directory, G_MODULE_SUFFIX)) &&
(!strcmp (temp, G_MODULE_SUFFIX))) { (!strcmp (temp, G_MODULE_SUFFIX))) {
ret = g_list_prepend (ret, g_strdup (directory)); ret = g_list_prepend (ret, g_strdup (directory));
} }
} }
@ -1341,10 +1341,10 @@ gst_xml_registry_rebuild (GstRegistry * registry)
gchar *path = (gchar *) walk->data; gchar *path = (gchar *) walk->data;
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
"Rebuilding registry %p in directory %s...", registry, path); "Rebuilding registry %p in directory %s...", registry, path);
plugins = g_list_concat (plugins, plugins = g_list_concat (plugins,
gst_xml_registry_rebuild_recurse (xmlregistry, path)); gst_xml_registry_rebuild_recurse (xmlregistry, path));
walk = g_list_next (walk); walk = g_list_next (walk);
} }
@ -1359,8 +1359,8 @@ gst_xml_registry_rebuild (GstRegistry * registry)
g_assert (walk->data); g_assert (walk->data);
plugin = gst_plugin_load_file ((gchar *) walk->data, NULL); plugin = gst_plugin_load_file ((gchar *) walk->data, NULL);
if (plugin) { if (plugin) {
prune = g_list_prepend (prune, walk->data); prune = g_list_prepend (prune, walk->data);
gst_registry_add_plugin (registry, plugin); gst_registry_add_plugin (registry, plugin);
} }
walk = g_list_next (walk); walk = g_list_next (walk);
@ -1380,11 +1380,11 @@ gst_xml_registry_rebuild (GstRegistry * registry)
while (walk) { while (walk) {
if ((plugin = gst_plugin_load_file ((gchar *) walk->data, &error))) { if ((plugin = gst_plugin_load_file ((gchar *) walk->data, &error))) {
g_warning ("Bizarre behavior: plugin %s actually loaded", g_warning ("Bizarre behavior: plugin %s actually loaded",
(gchar *) walk->data); (gchar *) walk->data);
gst_registry_add_plugin (registry, plugin); gst_registry_add_plugin (registry, plugin);
} else { } else {
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s", GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s",
(gchar *) walk->data, error->message); (gchar *) walk->data, error->message);
g_free (walk->data); g_free (walk->data);
g_error_free (error); g_error_free (error);

View file

@ -83,13 +83,15 @@ typedef enum
GST_BASIC_SCHEDULER_STATE_STOPPED, GST_BASIC_SCHEDULER_STATE_STOPPED,
GST_BASIC_SCHEDULER_STATE_ERROR, GST_BASIC_SCHEDULER_STATE_ERROR,
GST_BASIC_SCHEDULER_STATE_RUNNING, GST_BASIC_SCHEDULER_STATE_RUNNING,
} GstBasicSchedulerState; }
GstBasicSchedulerState;
typedef enum typedef enum
{ {
/* something important has changed inside the scheduler */ /* something important has changed inside the scheduler */
GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST, GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST,
} GstBasicSchedulerFlags; }
GstBasicSchedulerFlags;
struct _GstBasicScheduler struct _GstBasicScheduler
{ {
@ -198,8 +200,8 @@ gst_basic_scheduler_get_type (void)
}; };
_gst_basic_scheduler_type = _gst_basic_scheduler_type =
g_type_register_static (GST_TYPE_SCHEDULER, g_type_register_static (GST_TYPE_SCHEDULER,
"Gst" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0); "Gst" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0);
} }
return _gst_basic_scheduler_type; return _gst_basic_scheduler_type;
} }
@ -302,7 +304,7 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
gst_object_ref (GST_OBJECT (element)); gst_object_ref (GST_OBJECT (element));
do { do {
GST_CAT_DEBUG (debug_dataflow, "calling loopfunc %s for element %s", GST_CAT_DEBUG (debug_dataflow, "calling loopfunc %s for element %s",
GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name); GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name);
(element->loopfunc) (element); (element->loopfunc) (element);
GST_CAT_DEBUG (debug_dataflow, "element %s ended loop function", name); GST_CAT_DEBUG (debug_dataflow, "element %s ended loop function", name);
@ -343,38 +345,38 @@ gst_basic_scheduler_chain_wrapper (int argc, char **argv)
pads = element->pads; pads = element->pads;
while (pads) { while (pads) {
GstPad *pad = GST_PAD (pads->data); GstPad *pad = GST_PAD (pads->data);
GstRealPad *realpad; GstRealPad *realpad;
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
realpad = GST_REAL_PAD (pad); realpad = GST_REAL_PAD (pad);
if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK && if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK &&
GST_PAD_IS_LINKED (realpad) && GST_PAD_IS_LINKED (realpad) &&
g_slist_find (already_iterated, pad) == NULL) { g_slist_find (already_iterated, pad) == NULL) {
GstData *data; GstData *data;
GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name, GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name,
GST_PAD_NAME (pad)); GST_PAD_NAME (pad));
data = gst_pad_pull (pad); data = gst_pad_pull (pad);
if (data) { if (data) {
if (GST_IS_EVENT (data) && !GST_ELEMENT_IS_EVENT_AWARE (element)) { if (GST_IS_EVENT (data) && !GST_ELEMENT_IS_EVENT_AWARE (element)) {
gst_pad_send_event (pad, GST_EVENT (data)); gst_pad_send_event (pad, GST_EVENT (data));
} else { } else {
GST_CAT_DEBUG (debug_dataflow, GST_CAT_DEBUG (debug_dataflow,
"calling chain function of %s:%s %p", name, "calling chain function of %s:%s %p", name,
GST_PAD_NAME (pad), data); GST_PAD_NAME (pad), data);
GST_RPAD_CHAINFUNC (realpad) (pad, data); GST_RPAD_CHAINFUNC (realpad) (pad, data);
GST_CAT_DEBUG (debug_dataflow, GST_CAT_DEBUG (debug_dataflow,
"calling chain function of element %s done", name); "calling chain function of element %s done", name);
} }
} }
already_iterated = g_slist_prepend (already_iterated, pad); already_iterated = g_slist_prepend (already_iterated, pad);
break; break;
} }
pads = g_list_next (pads); pads = g_list_next (pads);
} }
} while (pads != NULL); } while (pads != NULL);
g_slist_free (already_iterated); g_slist_free (already_iterated);
@ -414,22 +416,22 @@ gst_basic_scheduler_src_wrapper (int argc, char **argv)
while (pads) { while (pads) {
if (!GST_IS_REAL_PAD (pads->data)) if (!GST_IS_REAL_PAD (pads->data))
continue; continue;
realpad = GST_REAL_PAD (pads->data); realpad = GST_REAL_PAD (pads->data);
pads = g_list_next (pads); pads = g_list_next (pads);
if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC
&& GST_PAD_IS_USABLE (realpad)) { && GST_PAD_IS_USABLE (realpad)) {
GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s", GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s",
GST_DEBUG_PAD_NAME (realpad)); GST_DEBUG_PAD_NAME (realpad));
g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0); g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0);
data = GST_RPAD_GETFUNC (realpad) (GST_PAD (realpad)); data = GST_RPAD_GETFUNC (realpad) (GST_PAD (realpad));
if (data) { if (data) {
GST_CAT_DEBUG (debug_dataflow, "calling gst_pad_push on pad %s:%s %p", GST_CAT_DEBUG (debug_dataflow, "calling gst_pad_push on pad %s:%s %p",
GST_DEBUG_PAD_NAME (realpad), data); GST_DEBUG_PAD_NAME (realpad), data);
gst_pad_push (GST_PAD (realpad), data); gst_pad_push (GST_PAD (realpad), data);
} }
} }
} }
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
@ -466,7 +468,7 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstData * data)
*/ */
while (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) != NULL && --loop_count) { while (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) != NULL && --loop_count) {
GST_CAT_DEBUG (debug_dataflow, "switching to %p to empty bufpen %d", GST_CAT_DEBUG (debug_dataflow, "switching to %p to empty bufpen %d",
GST_ELEMENT_THREADSTATE (parent), loop_count); GST_ELEMENT_THREADSTATE (parent), loop_count);
do_element_switch (parent); do_element_switch (parent);
@ -481,7 +483,7 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstData * data)
if (loop_count == 0) { if (loop_count == 0) {
GST_ELEMENT_ERROR (parent, CORE, SCHEDULER, (NULL), GST_ELEMENT_ERROR (parent, CORE, SCHEDULER, (NULL),
("(internal error) basic: maximum number of switches exceeded")); ("(internal error) basic: maximum number of switches exceeded"));
return; return;
} }
@ -538,7 +540,7 @@ gst_basic_scheduler_gethandler_proxy (GstPad * pad)
while (GST_RPAD_BUFPEN (pad) == NULL) { while (GST_RPAD_BUFPEN (pad) == NULL) {
GST_CAT_DEBUG (debug_dataflow, "switching to \"%s\": %p to fill bufpen", GST_CAT_DEBUG (debug_dataflow, "switching to \"%s\": %p to fill bufpen",
GST_ELEMENT_NAME (parent), GST_ELEMENT_THREADSTATE (parent)); GST_ELEMENT_NAME (parent), GST_ELEMENT_THREADSTATE (parent));
do_element_switch (parent); do_element_switch (parent);
@ -547,7 +549,7 @@ gst_basic_scheduler_gethandler_proxy (GstPad * pad)
GST_CAT_DEBUG (debug_dataflow, "new pad in mid-switch!"); GST_CAT_DEBUG (debug_dataflow, "new pad in mid-switch!");
pad = (GstPad *) GST_RPAD_PEER (peer); pad = (GstPad *) GST_RPAD_PEER (peer);
if (!pad) { if (!pad) {
GST_ELEMENT_ERROR (parent, CORE, PAD, (NULL), ("pad unlinked")); GST_ELEMENT_ERROR (parent, CORE, PAD, (NULL), ("pad unlinked"));
} }
parent = GST_PAD_PARENT (pad); parent = GST_PAD_PARENT (pad);
peer = GST_RPAD_PEER (pad); peer = GST_RPAD_PEER (pad);
@ -630,25 +632,25 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
/* if the element has a loopfunc... */ /* if the element has a loopfunc... */
if (element->loopfunc != NULL) { if (element->loopfunc != NULL) {
wrapper_function = wrapper_function =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper); GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper);
GST_DEBUG ("element '%s' is a loop-based", GST_ELEMENT_NAME (element)); GST_DEBUG ("element '%s' is a loop-based", GST_ELEMENT_NAME (element));
} else { } else {
/* otherwise we need to decide what kind of cothread /* otherwise we need to decide what kind of cothread
* if it's not DECOUPLED, we decide based on * if it's not DECOUPLED, we decide based on
* whether it's a source or not */ * whether it's a source or not */
if (!decoupled) { if (!decoupled) {
/* if it doesn't have any sinks, it must be a source (duh) */ /* if it doesn't have any sinks, it must be a source (duh) */
if (element->numsinkpads == 0) { if (element->numsinkpads == 0) {
wrapper_function = wrapper_function =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper); GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper);
GST_DEBUG ("element '%s' is a source, using _src_wrapper", GST_DEBUG ("element '%s' is a source, using _src_wrapper",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} else { } else {
wrapper_function = wrapper_function =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper); GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper);
GST_DEBUG ("element '%s' is a filter, using _chain_wrapper", GST_DEBUG ("element '%s' is a filter, using _chain_wrapper",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} }
} }
} }
@ -661,108 +663,108 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
pads = g_list_next (pads); pads = g_list_next (pads);
if (!GST_IS_REAL_PAD (pad)) if (!GST_IS_REAL_PAD (pad))
continue; continue;
peerpad = GST_PAD_PEER (pad); peerpad = GST_PAD_PEER (pad);
if (peerpad) { if (peerpad) {
GstElement *peerelement = GST_ELEMENT (GST_PAD_PARENT (peerpad)); GstElement *peerelement = GST_ELEMENT (GST_PAD_PARENT (peerpad));
gboolean different_sched = gboolean different_sched =
(peerelement->sched != GST_SCHEDULER (chain->sched)); (peerelement->sched != GST_SCHEDULER (chain->sched));
gboolean peer_decoupled = gboolean peer_decoupled =
GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED); GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED);
GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad)); GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad));
/* we don't need to check this for decoupled elements */ /* we don't need to check this for decoupled elements */
if (!decoupled) { if (!decoupled) {
/* if the peer element is in another schedule, /* if the peer element is in another schedule,
* it's not decoupled and we are not decoupled * it's not decoupled and we are not decoupled
* either, we have an error */ * either, we have an error */
if (different_sched && !peer_decoupled) { if (different_sched && !peer_decoupled) {
GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL), GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL),
("element \"%s\" is not decoupled but has pads in different schedulers", ("element \"%s\" is not decoupled but has pads in different schedulers",
GST_ELEMENT_NAME (element))); GST_ELEMENT_NAME (element)));
return FALSE; return FALSE;
} }
/* ok, the peer is in a different scheduler and is decoupled, /* ok, the peer is in a different scheduler and is decoupled,
* we need to set the * we need to set the
* handlers so we can talk with it */ * handlers so we can talk with it */
else if (different_sched) { else if (different_sched) {
if (GST_RPAD_DIRECTION (peerpad) == GST_PAD_SINK) { if (GST_RPAD_DIRECTION (peerpad) == GST_PAD_SINK) {
GST_DEBUG ("copying chain func into push proxy for peer %s:%s", GST_DEBUG ("copying chain func into push proxy for peer %s:%s",
GST_DEBUG_PAD_NAME (peerpad)); GST_DEBUG_PAD_NAME (peerpad));
GST_RPAD_CHAINHANDLER (peerpad) = GST_RPAD_CHAINFUNC (peerpad); GST_RPAD_CHAINHANDLER (peerpad) = GST_RPAD_CHAINFUNC (peerpad);
} else { } else {
GST_DEBUG ("copying get func into pull proxy for peer %s:%s", GST_DEBUG ("copying get func into pull proxy for peer %s:%s",
GST_DEBUG_PAD_NAME (peerpad)); GST_DEBUG_PAD_NAME (peerpad));
GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad); GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad);
} }
} }
} }
/* in any case we need to copy the eventfunc into the handler */ /* in any case we need to copy the eventfunc into the handler */
GST_RPAD_EVENTHANDLER (peerpad) = GST_RPAD_EVENTFUNC (peerpad); GST_RPAD_EVENTHANDLER (peerpad) = GST_RPAD_EVENTFUNC (peerpad);
} }
/* if the element is DECOUPLED or outside the manager, we have to chain */ /* if the element is DECOUPLED or outside the manager, we have to chain */
if (decoupled) { if (decoupled) {
/* set the chain proxies */ /* set the chain proxies */
if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) {
GST_DEBUG ("copying chain function into push proxy for %s:%s", GST_DEBUG ("copying chain function into push proxy for %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad); GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad);
} else { } else {
GST_DEBUG ("copying get function into pull proxy for %s:%s", GST_DEBUG ("copying get function into pull proxy for %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETFUNC (pad); GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETFUNC (pad);
} }
} }
/* otherwise we really are a cothread */ /* otherwise we really are a cothread */
else { else {
if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) {
GST_DEBUG ("setting cothreaded push proxy for sinkpad %s:%s", GST_DEBUG ("setting cothreaded push proxy for sinkpad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINHANDLER (pad) =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy); GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy);
GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad); GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad);
} else { } else {
GST_DEBUG ("setting cothreaded pull proxy for srcpad %s:%s", GST_DEBUG ("setting cothreaded pull proxy for srcpad %s:%s",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETHANDLER (pad) =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy); GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy);
/* the gethandler proxy function can queue a buffer in the bufpen, we need /* the gethandler proxy function can queue a buffer in the bufpen, we need
* to remove this buffer when a flush event is sent on the pad */ * to remove this buffer when a flush event is sent on the pad */
GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTHANDLER (pad) =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy); GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy);
} }
} }
} }
/* need to set up the cothread now */ /* need to set up the cothread now */
if (wrapper_function != NULL) { if (wrapper_function != NULL) {
if (GST_ELEMENT_THREADSTATE (element) == NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) {
GST_DEBUG ("about to create a cothread, wrapper for '%s' is &%s", GST_DEBUG ("about to create a cothread, wrapper for '%s' is &%s",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (element),
GST_DEBUG_FUNCPTR_NAME (wrapper_function)); GST_DEBUG_FUNCPTR_NAME (wrapper_function));
do_cothread_create (GST_ELEMENT_THREADSTATE (element), do_cothread_create (GST_ELEMENT_THREADSTATE (element),
chain->sched->context, wrapper_function, 0, (char **) element); chain->sched->context, wrapper_function, 0, (char **) element);
if (GST_ELEMENT_THREADSTATE (element) == NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) {
GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL), GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL),
("could not create cothread for \"%s\"", ("could not create cothread for \"%s\"",
GST_ELEMENT_NAME (element))); GST_ELEMENT_NAME (element)));
return FALSE; return FALSE;
} }
GST_DEBUG ("created cothread %p for '%s'", GST_DEBUG ("created cothread %p for '%s'",
GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element)); GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element));
} else { } else {
/* set the cothread wrapper function */ /* set the cothread wrapper function */
GST_DEBUG ("about to set the wrapper function for '%s' to &%s", GST_DEBUG ("about to set the wrapper function for '%s' to &%s",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (element),
GST_DEBUG_FUNCPTR_NAME (wrapper_function)); GST_DEBUG_FUNCPTR_NAME (wrapper_function));
do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element),
chain->sched->context, wrapper_function, 0, (char **) element); chain->sched->context, wrapper_function, 0, (char **) element);
GST_DEBUG ("set wrapper function for '%s' to &%s", GST_DEBUG ("set wrapper function for '%s' to &%s",
GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (element),
GST_DEBUG_FUNCPTR_NAME (wrapper_function)); GST_DEBUG_FUNCPTR_NAME (wrapper_function));
} }
} }
} }
@ -807,8 +809,8 @@ gst_basic_scheduler_chain_destroy (GstSchedulerChain * chain)
sched->num_chains--; sched->num_chains--;
/* destroy the chain */ /* destroy the chain */
g_list_free (chain->disabled); /* should be empty... */ g_list_free (chain->disabled); /* should be empty... */
g_list_free (chain->elements); /* ditto */ g_list_free (chain->elements); /* ditto */
GST_INFO ("destroyed chain %p, now are %d chains in sched %p", chain, GST_INFO ("destroyed chain %p, now are %d chains in sched %p", chain,
sched->num_chains, sched); sched->num_chains, sched);
@ -829,11 +831,11 @@ gst_basic_scheduler_chain_add_element (GstSchedulerChain * chain,
/* add the element to either the main list or the disabled list */ /* add the element to either the main list or the disabled list */
if (GST_STATE (element) == GST_STATE_PLAYING) { if (GST_STATE (element) == GST_STATE_PLAYING) {
GST_INFO ("adding element \"%s\" to chain %p enabled", GST_INFO ("adding element \"%s\" to chain %p enabled",
GST_ELEMENT_NAME (element), chain); GST_ELEMENT_NAME (element), chain);
chain->elements = g_list_prepend (chain->elements, element); chain->elements = g_list_prepend (chain->elements, element);
} else { } else {
GST_INFO ("adding element \"%s\" to chain %p disabled", GST_INFO ("adding element \"%s\" to chain %p disabled",
GST_ELEMENT_NAME (element), chain); GST_ELEMENT_NAME (element), chain);
chain->disabled = g_list_prepend (chain->disabled, element); chain->disabled = g_list_prepend (chain->disabled, element);
} }
chain->num_elements++; chain->num_elements++;
@ -861,7 +863,7 @@ gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain,
/* reschedule the chain */ /* reschedule the chain */
return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain-> return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain->
sched)->parent), chain); sched)->parent), chain);
} }
static void static void
@ -962,9 +964,9 @@ gst_basic_scheduler_chain_elements (GstBasicScheduler * sched,
GST_INFO ("merging chain %p into chain %p", chain2, chain1); GST_INFO ("merging chain %p into chain %p", chain2, chain1);
/* take the contents of chain2 and merge them into chain1 */ /* take the contents of chain2 and merge them into chain1 */
chain1->disabled = chain1->disabled =
g_list_concat (chain1->disabled, g_list_copy (chain2->disabled)); g_list_concat (chain1->disabled, g_list_copy (chain2->disabled));
chain1->elements = chain1->elements =
g_list_concat (chain1->elements, g_list_copy (chain2->elements)); g_list_concat (chain1->elements, g_list_copy (chain2->elements));
chain1->num_elements += chain2->num_elements; chain1->num_elements += chain2->num_elements;
/* FIXME chain changed here */ /* FIXME chain changed here */
/* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */ /* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */
@ -1042,16 +1044,16 @@ gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain,
pads = g_list_next (pads); pads = g_list_next (pads);
GST_DEBUG ("have pad %s:%s, checking for valid peer", GST_DEBUG ("have pad %s:%s, checking for valid peer",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
/* if the peer exists and could be in the same chain */ /* if the peer exists and could be in the same chain */
if (GST_PAD_PEER (pad)) { if (GST_PAD_PEER (pad)) {
GST_DEBUG ("has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad))); GST_DEBUG ("has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad)));
peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad)); peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad));
if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) ==
GST_ELEMENT_SCHED (peerelement)) { GST_ELEMENT_SCHED (peerelement)) {
GST_DEBUG ("peer \"%s\" is valid for same chain", GST_DEBUG ("peer \"%s\" is valid for same chain",
GST_ELEMENT_NAME (peerelement)); GST_ELEMENT_NAME (peerelement));
gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove); gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove);
} }
} }
} }
@ -1124,13 +1126,13 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element)
if (g_list_find (bsched->elements, element)) { if (g_list_find (bsched->elements, element)) {
GST_INFO ("removing element \"%s\" from scheduler", GST_INFO ("removing element \"%s\" from scheduler",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
/* if we are removing the currently scheduled element */ /* if we are removing the currently scheduled element */
if (bsched->current == element) { if (bsched->current == element) {
GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING);
if (element->post_run_func) if (element->post_run_func)
element->post_run_func (element); element->post_run_func (element);
bsched->current = NULL; bsched->current = NULL;
} }
/* find what chain the element is in */ /* find what chain the element is in */
@ -1176,17 +1178,17 @@ gst_basic_scheduler_state_transition (GstScheduler * sched,
/* remove it from the chain */ /* remove it from the chain */
if (chain) { if (chain) {
if (transition == GST_STATE_PLAYING_TO_PAUSED) { if (transition == GST_STATE_PLAYING_TO_PAUSED) {
gst_basic_scheduler_chain_disable_element (chain, element); gst_basic_scheduler_chain_disable_element (chain, element);
} else if (transition == GST_STATE_PAUSED_TO_PLAYING) { } else if (transition == GST_STATE_PAUSED_TO_PLAYING) {
if (!gst_basic_scheduler_chain_enable_element (chain, element)) { if (!gst_basic_scheduler_chain_enable_element (chain, element)) {
GST_INFO ("could not enable element \"%s\"", GST_INFO ("could not enable element \"%s\"",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
} }
} else { } else {
GST_INFO ("element \"%s\" not found in any chain, no state change", GST_INFO ("element \"%s\" not found in any chain, no state change",
GST_ELEMENT_NAME (element)); GST_ELEMENT_NAME (element));
} }
} }
@ -1266,7 +1268,7 @@ gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad,
if (GST_ELEMENT_SCHED (srcelement) == GST_ELEMENT_SCHED (sinkelement)) { if (GST_ELEMENT_SCHED (srcelement) == GST_ELEMENT_SCHED (sinkelement)) {
GST_INFO ("peer %s:%s is in same scheduler, chaining together", GST_INFO ("peer %s:%s is in same scheduler, chaining together",
GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG_PAD_NAME (sinkpad));
gst_basic_scheduler_chain_elements (bsched, srcelement, sinkelement); gst_basic_scheduler_chain_elements (bsched, srcelement, sinkelement);
} }
} }
@ -1352,7 +1354,7 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist)
pad = GST_PAD (padlist->data); pad = GST_PAD (padlist->data);
GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINHANDLER (pad) =
GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy); GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy);
padlist = g_list_next (padlist); padlist = g_list_next (padlist);
} }
@ -1397,71 +1399,71 @@ gst_basic_scheduler_iterate (GstScheduler * sched)
/* all we really have to do is switch to the first child */ /* all we really have to do is switch to the first child */
/* FIXME this should be lots more intelligent about where to start */ /* FIXME this should be lots more intelligent about where to start */
GST_CAT_DEBUG (debug_dataflow, GST_CAT_DEBUG (debug_dataflow,
"starting iteration via cothreads using %s scheduler", _SCHEDULER_NAME); "starting iteration via cothreads using %s scheduler", _SCHEDULER_NAME);
if (chain->elements) { if (chain->elements) {
entry = NULL; /*MattH ADDED? */ entry = NULL; /*MattH ADDED? */
GST_DEBUG ("there are %d elements in this chain", chain->num_elements); GST_DEBUG ("there are %d elements in this chain", chain->num_elements);
elements = chain->elements; elements = chain->elements;
while (elements) { while (elements) {
entry = GST_ELEMENT (elements->data); entry = GST_ELEMENT (elements->data);
elements = g_list_next (elements); elements = g_list_next (elements);
if (GST_FLAG_IS_SET (entry, GST_ELEMENT_DECOUPLED)) { if (GST_FLAG_IS_SET (entry, GST_ELEMENT_DECOUPLED)) {
GST_DEBUG ("entry \"%s\" is DECOUPLED, skipping", GST_DEBUG ("entry \"%s\" is DECOUPLED, skipping",
GST_ELEMENT_NAME (entry)); GST_ELEMENT_NAME (entry));
entry = NULL; entry = NULL;
} else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) { } else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) {
GST_DEBUG ("entry \"%s\" is not valid, skipping", GST_DEBUG ("entry \"%s\" is not valid, skipping",
GST_ELEMENT_NAME (entry)); GST_ELEMENT_NAME (entry));
entry = NULL; entry = NULL;
} else } else
break; break;
} }
if (entry) { if (entry) {
GstSchedulerState state; GstSchedulerState state;
GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING);
GST_CAT_DEBUG (debug_dataflow, GST_CAT_DEBUG (debug_dataflow,
"set COTHREAD_STOPPING flag on \"%s\"(@%p)", "set COTHREAD_STOPPING flag on \"%s\"(@%p)",
GST_ELEMENT_NAME (entry), entry); GST_ELEMENT_NAME (entry), entry);
if (GST_ELEMENT_THREADSTATE (entry)) { if (GST_ELEMENT_THREADSTATE (entry)) {
do_switch_from_main (entry); do_switch_from_main (entry);
state = GST_SCHEDULER_STATE (sched); state = GST_SCHEDULER_STATE (sched);
/* if something changed, return - go on else */ /* if something changed, return - go on else */
if (GST_FLAG_IS_SET (bsched, GST_BASIC_SCHEDULER_CHANGE) && if (GST_FLAG_IS_SET (bsched, GST_BASIC_SCHEDULER_CHANGE) &&
state != GST_SCHEDULER_STATE_ERROR) state != GST_SCHEDULER_STATE_ERROR)
return GST_SCHEDULER_STATE_RUNNING; return GST_SCHEDULER_STATE_RUNNING;
} else { } else {
GST_CAT_DEBUG (debug_dataflow, GST_CAT_DEBUG (debug_dataflow,
"cothread switch not possible, element has no threadstate"); "cothread switch not possible, element has no threadstate");
return GST_SCHEDULER_STATE_ERROR; return GST_SCHEDULER_STATE_ERROR;
} }
/* following is a check to see if the chain was interrupted due to a /* following is a check to see if the chain was interrupted due to a
* top-half state_change(). (i.e., if there's a pending state.) * top-half state_change(). (i.e., if there's a pending state.)
* *
* if it was, return to gstthread.c::gst_thread_main_loop() to * if it was, return to gstthread.c::gst_thread_main_loop() to
* execute the state change. * execute the state change.
*/ */
GST_CAT_DEBUG (debug_dataflow, "cothread switch ended or interrupted"); GST_CAT_DEBUG (debug_dataflow, "cothread switch ended or interrupted");
if (state != GST_SCHEDULER_STATE_RUNNING) { if (state != GST_SCHEDULER_STATE_RUNNING) {
GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d", GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d",
state); state);
return state; return state;
} }
scheduled++; scheduled++;
} else { } else {
GST_CAT_INFO (debug_dataflow, GST_CAT_INFO (debug_dataflow,
"no entry in this chain, trying the next one"); "no entry in this chain, trying the next one");
} }
} else { } else {
GST_CAT_INFO (debug_dataflow, GST_CAT_INFO (debug_dataflow,
"no enabled elements in this chain, trying the next one"); "no enabled elements in this chain, trying the next one");
} }
} }

View file

@ -186,7 +186,7 @@ gst_bytestream_get_next_buf (GstByteStream * bs)
/* have to check to see if we merged with the head buffer */ /* have to check to see if we merged with the head buffer */
if (end == bs->buflist) { if (end == bs->buflist) {
bs->headbufavail += GST_BUFFER_SIZE (nextbuf); bs->headbufavail += GST_BUFFER_SIZE (nextbuf);
} }
gst_buffer_unref (lastbuf); gst_buffer_unref (lastbuf);
@ -226,7 +226,7 @@ gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len)
/* as long as we don't have enough, we get more buffers */ /* as long as we don't have enough, we get more buffers */
while (bs->listavail < len) { while (bs->listavail < len) {
GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d", GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d",
bs->listavail, len); bs->listavail, len);
if (!gst_bytestream_get_next_buf (bs)) if (!gst_bytestream_get_next_buf (bs))
return FALSE; return FALSE;
} }
@ -267,12 +267,12 @@ gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len)
if (!gst_bytestream_fill_bytes (bs, len)) { if (!gst_bytestream_fill_bytes (bs, len)) {
/* we must have an event coming up */ /* we must have an event coming up */
if (bs->listavail > 0) { if (bs->listavail > 0) {
/* we have some data left, len will be shrunk to the amount of data available */ /* we have some data left, len will be shrunk to the amount of data available */
len = bs->listavail; len = bs->listavail;
} else { } else {
/* there is no data */ /* there is no data */
*buf = retbuf; *buf = retbuf;
return 0; return 0;
} }
} }
GST_DEBUG ("peek: there are now %d bytes in the list", bs->listavail); GST_DEBUG ("peek: there are now %d bytes in the list", bs->listavail);
@ -286,14 +286,14 @@ gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len)
GST_DEBUG ("peek: headbufavail is %d", bs->headbufavail); GST_DEBUG ("peek: headbufavail is %d", bs->headbufavail);
if (len <= bs->headbufavail) { if (len <= bs->headbufavail) {
GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)", GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)",
len, bs->headbufavail); len, bs->headbufavail);
/* create a sub-buffer of the headbuf */ /* create a sub-buffer of the headbuf */
retbuf = retbuf =
gst_buffer_create_sub (headbuf, gst_buffer_create_sub (headbuf,
GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len); GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len);
GST_BUFFER_OFFSET (retbuf) = GST_BUFFER_OFFSET (retbuf) =
GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) - GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) -
bs->headbufavail; bs->headbufavail;
} }
/* otherwise we need to figure out how to assemble one */ /* otherwise we need to figure out how to assemble one */
@ -351,12 +351,12 @@ gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, guint32 len)
if (!gst_bytestream_fill_bytes (bs, len)) { if (!gst_bytestream_fill_bytes (bs, len)) {
/* we must have an event coming up */ /* we must have an event coming up */
if (bs->listavail > 0) { if (bs->listavail > 0) {
/* we have some data left, len will be shrunk to the amount of data available */ /* we have some data left, len will be shrunk to the amount of data available */
len = bs->listavail; len = bs->listavail;
} else { } else {
/* there is no data */ /* there is no data */
*data = NULL; *data = NULL;
return 0; return 0;
} }
} }
GST_DEBUG ("peek_bytes: there are now %d bytes in the list", bs->listavail); GST_DEBUG ("peek_bytes: there are now %d bytes in the list", bs->listavail);
@ -370,12 +370,12 @@ gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, guint32 len)
GST_DEBUG ("peek_bytes: headbufavail is %d", bs->headbufavail); GST_DEBUG ("peek_bytes: headbufavail is %d", bs->headbufavail);
if (len <= bs->headbufavail) { if (len <= bs->headbufavail) {
GST_DEBUG GST_DEBUG
("peek_bytes: there are enough bytes in headbuf (need %d, have %d)", ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)",
len, bs->headbufavail); len, bs->headbufavail);
/* create a sub-buffer of the headbuf */ /* create a sub-buffer of the headbuf */
*data = *data =
GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) - GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) -
bs->headbufavail); bs->headbufavail);
} }
/* otherwise we need to figure out how to assemble one */ /* otherwise we need to figure out how to assemble one */
@ -413,12 +413,12 @@ gst_bytestream_assemble (GstByteStream * bs, guint32 len)
buf = GST_BUFFER (walk->data); buf = GST_BUFFER (walk->data);
if (GST_BUFFER_SIZE (buf) < (len - copied)) { if (GST_BUFFER_SIZE (buf) < (len - copied)) {
GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
GST_BUFFER_SIZE (buf), copied); GST_BUFFER_SIZE (buf), copied);
memcpy (data + copied, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); memcpy (data + copied, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
copied += GST_BUFFER_SIZE (buf); copied += GST_BUFFER_SIZE (buf);
} else { } else {
GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d",
len - copied, copied); len - copied, copied);
memcpy (data + copied, GST_BUFFER_DATA (buf), len - copied); memcpy (data + copied, GST_BUFFER_DATA (buf), len - copied);
copied = len; copied = len;
} }
@ -496,8 +496,8 @@ gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
headbuf = GST_BUFFER (bs->buflist->data); headbuf = GST_BUFFER (bs->buflist->data);
GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %" GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %"
G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf), G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf),
GST_BUFFER_OFFSET (headbuf)); GST_BUFFER_OFFSET (headbuf));
/* if there's enough to complete the flush */ /* if there's enough to complete the flush */
if (bs->headbufavail > len) { if (bs->headbufavail > len) {
@ -521,10 +521,10 @@ gst_bytestream_flush_fast (GstByteStream * bs, guint32 len)
/* record the new headbufavail */ /* record the new headbufavail */
if (bs->buflist) { if (bs->buflist) {
bs->headbufavail = GST_BUFFER_SIZE (GST_BUFFER (bs->buflist->data)); bs->headbufavail = GST_BUFFER_SIZE (GST_BUFFER (bs->buflist->data));
GST_DEBUG ("flush: next headbuf is %d bytes", bs->headbufavail); GST_DEBUG ("flush: next headbuf is %d bytes", bs->headbufavail);
} else { } else {
GST_DEBUG ("flush: no more bytes at all"); GST_DEBUG ("flush: no more bytes at all");
} }
} }
@ -557,8 +557,8 @@ gst_bytestream_seek (GstByteStream * bs, gint64 offset, GstSeekType method)
GST_DEBUG ("bs: send event\n"); GST_DEBUG ("bs: send event\n");
if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (GST_FORMAT_BYTES | if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (GST_FORMAT_BYTES |
(method & GST_SEEK_METHOD_MASK) | (method & GST_SEEK_METHOD_MASK) |
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) { GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) {
gst_bytestream_flush_fast (bs, bs->listavail); gst_bytestream_flush_fast (bs, bs->listavail);
/* we set the seek flag here. We cannot pull the pad here /* we set the seek flag here. We cannot pull the pad here
@ -590,7 +590,7 @@ gst_bytestream_tell (GstByteStream * bs)
format = GST_FORMAT_BYTES; format = GST_FORMAT_BYTES;
if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format, if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format,
&value)) { &value)) {
return value - bs->listavail; return value - bs->listavail;
} }
@ -753,8 +753,8 @@ gst_bytestream_print_status (GstByteStream * bs)
walk = g_slist_next (walk); walk = g_slist_next (walk);
GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT
" and is %d bytes long", GST_BUFFER_OFFSET (buf), " and is %d bytes long", GST_BUFFER_OFFSET (buf),
GST_BUFFER_SIZE (buf)); GST_BUFFER_SIZE (buf));
} }
} }

View file

@ -75,8 +75,9 @@ gst_dparam_get_type (void)
0, 0,
(GInstanceInitFunc) gst_dparam_init, (GInstanceInitFunc) gst_dparam_init,
}; };
dparam_type = dparam_type =
g_type_register_static (GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0); g_type_register_static (GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0);
} }
return dparam_type; return dparam_type;
} }
@ -97,20 +98,20 @@ gst_dparam_class_init (GstDParamClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_FLOAT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_FLOAT,
g_param_spec_float ("value_float", "Float Value", g_param_spec_float ("value_float", "Float Value",
"The value that should be changed if gfloat is the type", "The value that should be changed if gfloat is the type",
-G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE)); -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_DOUBLE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_DOUBLE,
g_param_spec_double ("value_double", "Double Value", g_param_spec_double ("value_double", "Double Value",
"The value that should be changed if gdouble is the type", "The value that should be changed if gdouble is the type",
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE)); -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT,
g_param_spec_int ("value_int", "Integer Value", g_param_spec_int ("value_int", "Integer Value",
"The value that should be changed if gint is the type", "The value that should be changed if gint is the type",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT64, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT64,
g_param_spec_int64 ("value_int64", "64 bit Integer Value", g_param_spec_int64 ("value_int64", "64 bit Integer Value",
"The value that should be changed if gint64 is the type", "The value that should be changed if gint64 is the type",
G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE)); G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE));
gobject_class->dispose = gst_dparam_dispose; gobject_class->dispose = gst_dparam_dispose;
@ -197,38 +198,38 @@ gst_dparam_set_property (GObject * object, guint prop_id, const GValue * value,
switch (prop_id) { switch (prop_id) {
case ARG_VALUE_FLOAT: case ARG_VALUE_FLOAT:
GST_DEBUG ("setting value from %g to %g", dparam->value_float, GST_DEBUG ("setting value from %g to %g", dparam->value_float,
g_value_get_float (value)); g_value_get_float (value));
dparam->value_float = g_value_get_float (value); dparam->value_float = g_value_get_float (value);
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
break; break;
case ARG_VALUE_DOUBLE: case ARG_VALUE_DOUBLE:
GST_DEBUG ("setting value from %g to %g", GST_DEBUG ("setting value from %g to %g",
dparam->value_double, g_value_get_double (value)); dparam->value_double, g_value_get_double (value));
dparam->value_double = g_value_get_double (value); dparam->value_double = g_value_get_double (value);
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
break; break;
case ARG_VALUE_INT: case ARG_VALUE_INT:
GST_DEBUG ("setting value from %d to %d", dparam->value_int, GST_DEBUG ("setting value from %d to %d", dparam->value_int,
g_value_get_int (value)); g_value_get_int (value));
dparam->value_int = g_value_get_int (value); dparam->value_int = g_value_get_int (value);
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
break; break;
case ARG_VALUE_INT64: case ARG_VALUE_INT64:
GST_DEBUG ("setting value from %" GST_DEBUG ("setting value from %"
G_GINT64_FORMAT " to %" G_GINT64_FORMAT " to %"
G_GINT64_FORMAT, dparam->value_int64, g_value_get_int64 (value)); G_GINT64_FORMAT, dparam->value_int64, g_value_get_int64 (value));
dparam->value_int64 = g_value_get_int64 (value); dparam->value_int64 = g_value_get_int64 (value);
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam);
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
break; break;

View file

@ -73,9 +73,10 @@ gst_dpsmooth_get_type (void)
0, 0,
(GInstanceInitFunc) gst_dpsmooth_init, (GInstanceInitFunc) gst_dpsmooth_init,
}; };
dpsmooth_type = dpsmooth_type =
g_type_register_static (GST_TYPE_DPARAM, "GstDParamSmooth", g_type_register_static (GST_TYPE_DPARAM, "GstDParamSmooth",
&dpsmooth_info, 0); &dpsmooth_info, 0);
} }
return dpsmooth_type; return dpsmooth_type;
} }
@ -96,27 +97,27 @@ gst_dpsmooth_class_init (GstDParamSmoothClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_PERIOD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_PERIOD,
g_param_spec_int64 ("update_period", g_param_spec_int64 ("update_period",
"Update Period (nanoseconds)", "Update Period (nanoseconds)",
"Number of nanoseconds between updates", "Number of nanoseconds between updates",
0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE)); 0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLOPE_TIME, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLOPE_TIME,
g_param_spec_int64 ("slope_time", g_param_spec_int64 ("slope_time",
"Slope Time (nanoseconds)", "Slope Time (nanoseconds)",
"The time period to define slope_delta by", "The time period to define slope_delta by",
0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE)); 0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_SLOPE_DELTA_FLOAT, ARG_SLOPE_DELTA_FLOAT,
g_param_spec_float ("slope_delta_float", "Slope Delta float", g_param_spec_float ("slope_delta_float", "Slope Delta float",
"The amount a float value can change for a given slope_time", "The amount a float value can change for a given slope_time",
0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE)); 0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_SLOPE_DELTA_DOUBLE, ARG_SLOPE_DELTA_DOUBLE,
g_param_spec_double ("slope_delta_double", "Slope Delta double", g_param_spec_double ("slope_delta_double", "Slope Delta double",
"The amount a double value can change for a given slope_time", "The amount a double value can change for a given slope_time",
0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE)); 0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE));
/*gstobject_class->save_thyself = gst_dparam_save_thyself; */ /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
@ -149,13 +150,13 @@ gst_dpsmooth_new (GType type)
case G_TYPE_FLOAT:{ case G_TYPE_FLOAT:{
dparam->do_update_func = gst_dpsmooth_do_update_float; dparam->do_update_func = gst_dpsmooth_do_update_float;
g_signal_connect (G_OBJECT (dpsmooth), "value_changed", g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
G_CALLBACK (gst_dpsmooth_value_changed_float), NULL); G_CALLBACK (gst_dpsmooth_value_changed_float), NULL);
break; break;
} }
case G_TYPE_DOUBLE:{ case G_TYPE_DOUBLE:{
dparam->do_update_func = gst_dpsmooth_do_update_double; dparam->do_update_func = gst_dpsmooth_do_update_double;
g_signal_connect (G_OBJECT (dpsmooth), "value_changed", g_signal_connect (G_OBJECT (dpsmooth), "value_changed",
G_CALLBACK (gst_dpsmooth_value_changed_double), NULL); G_CALLBACK (gst_dpsmooth_value_changed_double), NULL);
break; break;
} }
default: default:
@ -189,7 +190,7 @@ gst_dpsmooth_set_property (GObject * object, guint prop_id,
case ARG_SLOPE_TIME: case ARG_SLOPE_TIME:
dpsmooth->slope_time = g_value_get_int64 (value); dpsmooth->slope_time = g_value_get_int64 (value);
GST_DEBUG ("dpsmooth->slope_time:%" GST_DEBUG ("dpsmooth->slope_time:%"
G_GINT64_FORMAT, dpsmooth->slope_time); G_GINT64_FORMAT, dpsmooth->slope_time);
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
break; break;
@ -309,7 +310,7 @@ gst_dpsmooth_do_update_float (GstDParam * dparam, gint64 timestamp,
} }
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
dpsmooth->start_interp + dpsmooth->update_period; dpsmooth->start_interp + dpsmooth->update_period;
GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);
@ -420,7 +421,7 @@ gst_dpsmooth_do_update_double (GstDParam * dparam, gint64 timestamp,
} }
GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp;
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) =
dpsmooth->start_interp + dpsmooth->update_period; dpsmooth->start_interp + dpsmooth->update_period;
GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp);

View file

@ -92,9 +92,10 @@ gst_dpman_get_type (void)
0, 0,
(GInstanceInitFunc) gst_dpman_init, (GInstanceInitFunc) gst_dpman_init,
}; };
dpman_type = dpman_type =
g_type_register_static (GST_TYPE_OBJECT, "GstDParamManager", g_type_register_static (GST_TYPE_OBJECT, "GstDParamManager",
&dpman_info, 0); &dpman_info, 0);
} }
return dpman_type; return dpman_type;
} }
@ -127,7 +128,7 @@ gst_dpman_class_init (GstDParamManagerClass * klass)
gst_dpman_signals[NEW_REQUIRED_DPARAM] = gst_dpman_signals[NEW_REQUIRED_DPARAM] =
g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS (klass), g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamManagerClass, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamManagerClass,
new_required_dparam), NULL, NULL, gst_marshal_VOID__STRING, new_required_dparam), NULL, NULL, gst_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING); G_TYPE_NONE, 1, G_TYPE_STRING);
} }
@ -590,7 +591,7 @@ gst_dpman_bypass_dparam (GstDParamManager * dpman, gchar * dparam_name)
if (dpwrap->dparam != NULL) { if (dpwrap->dparam != NULL) {
g_warning ("Bypassing attached dparam '%s'. It will be detached", g_warning ("Bypassing attached dparam '%s'. It will be detached",
dparam_name); dparam_name);
gst_dpman_detach_dparam (dpman, dparam_name); gst_dpman_detach_dparam (dpman, dparam_name);
} }
} }
@ -659,8 +660,8 @@ gst_dpman_state_change (GstElement * element, gint old_state, gint new_state,
dparam = dpwrap->dparam; dparam = dpwrap->dparam;
if (dparam) { if (dparam) {
GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE;
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL; GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL;
} }
/* some dparams treat the first update after the pipeline starts differently */ /* some dparams treat the first update after the pipeline starts differently */
dpwrap->update_info = GST_DPARAM_UPDATE_FIRST; dpwrap->update_info = GST_DPARAM_UPDATE_FIRST;
@ -709,39 +710,39 @@ gst_dpman_preprocess_synchronous (GstDParamManager * dpman, guint frames,
dpwrap = (GstDParamWrapper *) dwraps->data; dpwrap = (GstDParamWrapper *) dwraps->data;
if (dpwrap->dparam && if (dpwrap->dparam &&
GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) && GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) &&
GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam) <= timestamp) { GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam) <= timestamp) {
switch (dpwrap->update_method) { switch (dpwrap->update_method) {
/* direct method - set the value directly in the struct of the element */ /* direct method - set the value directly in the struct of the element */
case GST_DPMAN_DIRECT: case GST_DPMAN_DIRECT:
GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value, GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
dpwrap->update_info); dpwrap->update_info);
GST_DEBUG ("doing direct update"); GST_DEBUG ("doing direct update");
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
break; break;
/* callback method - call the element's callback so it can do what it likes */ /* callback method - call the element's callback so it can do what it likes */
case GST_DPMAN_CALLBACK: case GST_DPMAN_CALLBACK:
GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value, GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value,
dpwrap->update_info); dpwrap->update_info);
GST_DEBUG ("doing callback update"); GST_DEBUG ("doing callback update");
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
break; break;
case GST_DPMAN_ARRAY: case GST_DPMAN_ARRAY:
/* FIXME do array method checking here */ /* FIXME do array method checking here */
break; break;
default: default:
break; break;
} }
if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) { if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
/* it is not the first update anymore */ /* it is not the first update anymore */
dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
} }
} }
dwraps = g_list_next (dwraps); dwraps = g_list_next (dwraps);
@ -796,68 +797,68 @@ gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, guint frames,
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
if (current_time > dpman->time_buffer_ends) { if (current_time > dpman->time_buffer_ends) {
/* not due for an update in this buffer */ /* not due for an update in this buffer */
dwraps = g_list_next (dwraps); dwraps = g_list_next (dwraps);
continue; continue;
} }
if (current_time < timestamp) { if (current_time < timestamp) {
current_time = timestamp; current_time = timestamp;
} }
if (current_time == timestamp) { if (current_time == timestamp) {
/* we are overdue for an update. lets do it now */ /* we are overdue for an update. lets do it now */
GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value, GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
dpwrap->update_info); dpwrap->update_info);
if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) { if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) {
/* it is not the first update anymore */ /* it is not the first update anymore */
dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL;
} }
switch (dpwrap->update_method) { switch (dpwrap->update_method) {
/* direct method - set the value directly in the struct of the element */ /* direct method - set the value directly in the struct of the element */
case GST_DPMAN_DIRECT: case GST_DPMAN_DIRECT:
GST_DEBUG ("doing direct update"); GST_DEBUG ("doing direct update");
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
break; break;
/* callback method - call the element's callback so it can do what it likes */ /* callback method - call the element's callback so it can do what it likes */
case GST_DPMAN_CALLBACK: case GST_DPMAN_CALLBACK:
GST_DEBUG ("doing callback update"); GST_DEBUG ("doing callback update");
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
break; break;
default: default:
break; break;
} }
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
if (!GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) || if (!GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) ||
current_time > dpman->time_buffer_ends) { current_time > dpman->time_buffer_ends) {
/* not due for an update in this buffer */ /* not due for an update in this buffer */
dwraps = g_list_next (dwraps); dwraps = g_list_next (dwraps);
continue; continue;
} }
} }
dpwrap->next_update_frame = dpwrap->next_update_frame =
(guint) (current_time - timestamp) / dpman->rate_ratio; (guint) (current_time - timestamp) / dpman->rate_ratio;
updates_pending = TRUE; updates_pending = TRUE;
GST_DEBUG ("timestamp start: %" GST_DEBUG ("timestamp start: %"
G_GINT64_FORMAT " end: %" G_GINT64_FORMAT " end: %"
G_GINT64_FORMAT " current: %" G_GINT64_FORMAT " current: %"
G_GINT64_FORMAT, timestamp, dpman->time_buffer_ends, current_time); G_GINT64_FORMAT, timestamp, dpman->time_buffer_ends, current_time);
} }
dwraps = g_list_next (dwraps); dwraps = g_list_next (dwraps);
} }
if (updates_pending) { if (updates_pending) {
GST_DPMAN_DPARAMS_LIST (dpman) = GST_DPMAN_DPARAMS_LIST (dpman) =
g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman), g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
(GCompareFunc) gst_dpman_dpwrap_compare); (GCompareFunc) gst_dpman_dpwrap_compare);
dwraps = GST_DPMAN_DPARAMS_LIST (dpman); dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
dpwrap = (GstDParamWrapper *) dwraps->data; dpwrap = (GstDParamWrapper *) dwraps->data;
@ -865,7 +866,7 @@ gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, guint frames,
dpman->frames_to_process = dpman->next_update_frame; dpman->frames_to_process = dpman->next_update_frame;
GST_DEBUG ("next update frame %u, frames to process %u", GST_DEBUG ("next update frame %u, frames to process %u",
dpman->next_update_frame, dpman->frames_to_process); dpman->next_update_frame, dpman->frames_to_process);
return TRUE; return TRUE;
} }
@ -896,29 +897,29 @@ gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
if (frame_count != dpwrap->next_update_frame) { if (frame_count != dpwrap->next_update_frame) {
g_warning ("frame count %u does not match update frame %u", g_warning ("frame count %u does not match update frame %u",
frame_count, dpwrap->next_update_frame); frame_count, dpwrap->next_update_frame);
} }
while (dpwrap) { while (dpwrap) {
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value, GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value,
dpwrap->update_info); dpwrap->update_info);
switch (dpwrap->update_method) { switch (dpwrap->update_method) {
/* direct method - set the value directly in the struct of the element */ /* direct method - set the value directly in the struct of the element */
case GST_DPMAN_DIRECT: case GST_DPMAN_DIRECT:
GST_DEBUG ("doing direct update"); GST_DEBUG ("doing direct update");
gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data);
break; break;
/* callback method - call the element's callback so it can do what it likes */ /* callback method - call the element's callback so it can do what it likes */
case GST_DPMAN_CALLBACK: case GST_DPMAN_CALLBACK:
GST_DEBUG ("doing callback update"); GST_DEBUG ("doing callback update");
GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value);
break; break;
default: default:
break; break;
} }
dpwrap->next_update_frame = dpman->num_frames; dpwrap->next_update_frame = dpman->num_frames;
@ -927,16 +928,16 @@ gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
if (GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) { if (GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) {
current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam);
if (current_time <= dpman->time_buffer_ends) { if (current_time <= dpman->time_buffer_ends) {
dpwrap->next_update_frame = dpwrap->next_update_frame =
(guint) (current_time - (guint) (current_time -
dpman->time_buffer_starts) / dpman->rate_ratio; dpman->time_buffer_starts) / dpman->rate_ratio;
} }
} }
if ((dwraps = g_list_next (dwraps))) { if ((dwraps = g_list_next (dwraps))) {
dpwrap = (GstDParamWrapper *) dwraps->data; dpwrap = (GstDParamWrapper *) dwraps->data;
if (frame_count == dpwrap->next_update_frame) { if (frame_count == dpwrap->next_update_frame) {
continue; continue;
} }
} }
dpwrap = NULL; dpwrap = NULL;
@ -944,8 +945,8 @@ gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
if (needs_resort && g_list_length (GST_DPMAN_DPARAMS_LIST (dpman)) > 1) { if (needs_resort && g_list_length (GST_DPMAN_DPARAMS_LIST (dpman)) > 1) {
GST_DPMAN_DPARAMS_LIST (dpman) = GST_DPMAN_DPARAMS_LIST (dpman) =
g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman), g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman),
(GCompareFunc) gst_dpman_dpwrap_compare); (GCompareFunc) gst_dpman_dpwrap_compare);
} }
dwraps = GST_DPMAN_DPARAMS_LIST (dpman); dwraps = GST_DPMAN_DPARAMS_LIST (dpman);
@ -955,12 +956,12 @@ gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count)
dpman->next_update_frame = dpman->num_frames; dpman->next_update_frame = dpman->num_frames;
dpman->frames_to_process = dpman->num_frames - frame_count; dpman->frames_to_process = dpman->num_frames - frame_count;
GST_DEBUG ("no more updates, frames to process %u", GST_DEBUG ("no more updates, frames to process %u",
dpman->frames_to_process); dpman->frames_to_process);
} else { } else {
dpman->next_update_frame = dpwrap->next_update_frame; dpman->next_update_frame = dpwrap->next_update_frame;
dpman->frames_to_process = dpman->next_update_frame - frame_count; dpman->frames_to_process = dpman->next_update_frame - frame_count;
GST_DEBUG ("next update frame %u, frames to process %u", GST_DEBUG ("next update frame %u, frames to process %u",
dpman->next_update_frame, dpman->frames_to_process); dpman->next_update_frame, dpman->frames_to_process);
} }
return TRUE; return TRUE;

View file

@ -42,9 +42,10 @@ gst_dp_linint_get_type (void)
0, 0,
(GInstanceInitFunc) gst_dp_linint_init, (GInstanceInitFunc) gst_dp_linint_init,
}; };
dp_linint_type = dp_linint_type =
g_type_register_static (GST_TYPE_DPARAM, "GstDParamLinInterp", g_type_register_static (GST_TYPE_DPARAM, "GstDParamLinInterp",
&dp_linint_info, 0); &dp_linint_info, 0);
} }
return dp_linint_type; return dp_linint_type;
} }

View file

@ -65,9 +65,10 @@ gst_unitconv_get_type (void)
0, 0,
(GInstanceInitFunc) gst_unitconv_init, (GInstanceInitFunc) gst_unitconv_init,
}; };
unitconv_type = unitconv_type =
g_type_register_static (GST_TYPE_OBJECT, "GstUnitConvert", g_type_register_static (GST_TYPE_OBJECT, "GstUnitConvert",
&unitconv_info, 0); &unitconv_info, 0);
} }
return unitconv_type; return unitconv_type;
} }
@ -223,68 +224,68 @@ _gst_unitconv_initialize (void)
gst_unitconv_register_unit ("frequency", TRUE, TRUE, gst_unitconv_register_unit ("frequency", TRUE, TRUE,
g_param_spec_float ("hertz", "Hz", "Frequency in hertz", g_param_spec_float ("hertz", "Hz", "Frequency in hertz",
0, G_MAXFLOAT, 0, 0)); 0, G_MAXFLOAT, 0, 0));
gst_unitconv_register_unit ("frequency", FALSE, TRUE, gst_unitconv_register_unit ("frequency", FALSE, TRUE,
g_param_spec_float ("hertz-rate-bound", "Hz", g_param_spec_float ("hertz-rate-bound", "Hz",
"Frequency in hertz, bound by the sample rate", 0.0, G_MAXFLOAT, 0.0, "Frequency in hertz, bound by the sample rate", 0.0, G_MAXFLOAT, 0.0,
0)); 0));
gst_unitconv_register_unit ("frequency", FALSE, FALSE, gst_unitconv_register_unit ("frequency", FALSE, FALSE,
g_param_spec_string ("twelve-tone-scale", "note", g_param_spec_string ("twelve-tone-scale", "note",
"Name of the note from the western twelve tone scale", "C", 0)); "Name of the note from the western twelve tone scale", "C", 0));
gst_unitconv_register_unit ("frequency", FALSE, FALSE, gst_unitconv_register_unit ("frequency", FALSE, FALSE,
g_param_spec_int ("midi-note", "midi note", g_param_spec_int ("midi-note", "midi note",
"MIDI note value of the frequency", 1, 127, 1, 0)); "MIDI note value of the frequency", 1, 127, 1, 0));
/* time based units */ /* time based units */
gst_unitconv_register_unit ("time", TRUE, FALSE, gst_unitconv_register_unit ("time", TRUE, FALSE,
g_param_spec_float ("seconds", "s", "Time in seconds", g_param_spec_float ("seconds", "s", "Time in seconds",
-G_MAXFLOAT, G_MAXFLOAT, 0, 0)); -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
gst_unitconv_register_unit ("time", FALSE, FALSE, gst_unitconv_register_unit ("time", FALSE, FALSE,
g_param_spec_int64 ("nanoseconds", "ns", "Time in nanoseconds", g_param_spec_int64 ("nanoseconds", "ns", "Time in nanoseconds",
G_MININT64, G_MAXINT64, 0, 0)); G_MININT64, G_MAXINT64, 0, 0));
gst_unitconv_register_unit ("time", FALSE, FALSE, gst_unitconv_register_unit ("time", FALSE, FALSE,
g_param_spec_int64 ("samples", "samples", "Time in number of samples", g_param_spec_int64 ("samples", "samples", "Time in number of samples",
G_MININT64, G_MAXINT64, 0, 0)); G_MININT64, G_MAXINT64, 0, 0));
gst_unitconv_register_convert_property ("samples", gst_unitconv_register_convert_property ("samples",
g_param_spec_int ("samplerate", "samplerate", "samplerate", g_param_spec_int ("samplerate", "samplerate", "samplerate",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
/* magnitude based units */ /* magnitude based units */
gst_unitconv_register_unit ("magnitude", TRUE, FALSE, gst_unitconv_register_unit ("magnitude", TRUE, FALSE,
g_param_spec_float ("scalar", "scalar", "Magnitude as a scalar", g_param_spec_float ("scalar", "scalar", "Magnitude as a scalar",
-G_MAXFLOAT, G_MAXFLOAT, 0, 0)); -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
gst_unitconv_register_unit ("magnitude", FALSE, FALSE, gst_unitconv_register_unit ("magnitude", FALSE, FALSE,
g_param_spec_int ("scalar-int", "scalar int", g_param_spec_int ("scalar-int", "scalar int",
"Magnitude as an integer scalar", G_MININT, G_MAXINT, 0, 0)); "Magnitude as an integer scalar", G_MININT, G_MAXINT, 0, 0));
gst_unitconv_register_unit ("magnitude", FALSE, TRUE, gst_unitconv_register_unit ("magnitude", FALSE, TRUE,
g_param_spec_float ("decibel", "dB", "Magnitude in decibels", g_param_spec_float ("decibel", "dB", "Magnitude in decibels",
-G_MAXFLOAT, G_MAXFLOAT, 0, 0)); -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
gst_unitconv_register_unit ("magnitude", FALSE, FALSE, gst_unitconv_register_unit ("magnitude", FALSE, FALSE,
g_param_spec_float ("percent", "%", "Magnitude in percent", g_param_spec_float ("percent", "%", "Magnitude in percent",
-G_MAXFLOAT, G_MAXFLOAT, 0, 0)); -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
/* generic units */ /* generic units */
gst_unitconv_register_unit ("float_default", TRUE, FALSE, gst_unitconv_register_unit ("float_default", TRUE, FALSE,
g_param_spec_float ("float", "float", "Float value", g_param_spec_float ("float", "float", "Float value",
-G_MAXFLOAT, G_MAXFLOAT, 0, 0)); -G_MAXFLOAT, G_MAXFLOAT, 0, 0));
gst_unitconv_register_unit ("int_default", TRUE, FALSE, gst_unitconv_register_unit ("int_default", TRUE, FALSE,
g_param_spec_int ("int", "int", "Integer value", g_param_spec_int ("int", "int", "Integer value",
G_MININT, G_MAXINT, 0, 0)); G_MININT, G_MAXINT, 0, 0));
gst_unitconv_register_unit ("int64_default", TRUE, FALSE, gst_unitconv_register_unit ("int64_default", TRUE, FALSE,
g_param_spec_int64 ("int64", "int64", "64 bit integer value", g_param_spec_int64 ("int64", "int64", "64 bit integer value",
G_MININT, G_MAXINT, 0, 0)); G_MININT, G_MAXINT, 0, 0));
gst_unitconv_add_core_converters (); gst_unitconv_add_core_converters ();
@ -312,7 +313,7 @@ gst_unitconv_register_unit (const gchar * domain_name,
if (is_domain_default) { if (is_domain_default) {
/* check if an default unit already exists for this domain */ /* check if an default unit already exists for this domain */
g_return_val_if_fail (g_hash_table_lookup (_gst_unit_domain_defaults, g_return_val_if_fail (g_hash_table_lookup (_gst_unit_domain_defaults,
domain_name) == NULL, FALSE); domain_name) == NULL, FALSE);
} }
GST_DEBUG ("creating unit: %s", unit_name); GST_DEBUG ("creating unit: %s", unit_name);
@ -330,7 +331,7 @@ gst_unitconv_register_unit (const gchar * domain_name,
if (is_domain_default) { if (is_domain_default) {
g_hash_table_insert (_gst_unit_domain_defaults, g_strdup (domain_name), g_hash_table_insert (_gst_unit_domain_defaults, g_strdup (domain_name),
unit); unit);
} }
return TRUE; return TRUE;

View file

@ -50,9 +50,9 @@ unsigned long _getbits_masks[] = {
#ifdef unused #ifdef unused
unsigned long _getbits_64_minus_index[] = { unsigned long _getbits_64_minus_index[] = {
64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46,
45, 44, 43, 42, 41, 45, 44, 43, 42, 41,
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22,
21, 20, 19, 18, 17, 21, 20, 19, 18, 17,
16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
}; };

View file

@ -69,9 +69,10 @@ gst_aggregator_sched_get_type (void)
{AGGREGATOR_CHAIN, "4", "Chain Based"}, {AGGREGATOR_CHAIN, "4", "Chain Based"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!aggregator_sched_type) { if (!aggregator_sched_type) {
aggregator_sched_type = aggregator_sched_type =
g_enum_register_static ("GstAggregatorSched", aggregator_sched); g_enum_register_static ("GstAggregatorSched", aggregator_sched);
} }
return aggregator_sched_type; return aggregator_sched_type;
} }
@ -117,17 +118,17 @@ gst_aggregator_class_init (GstAggregatorClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "Num pads", "The number of source pads", g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce messages", g_param_spec_boolean ("silent", "Silent", "Don't produce messages",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED,
g_param_spec_enum ("sched", "Scheduling", g_param_spec_enum ("sched", "Scheduling",
"The type of scheduling this element should use", "The type of scheduling this element should use",
GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last message", g_param_spec_string ("last_message", "Last message",
"The current state of the element", NULL, G_PARAM_READABLE)); "The current state of the element", NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
@ -192,7 +193,7 @@ gst_aggregator_update_functions (GstAggregator * aggregator)
if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { if (AGGREGATOR_IS_LOOP_BASED (aggregator)) {
gst_element_set_loop_function (GST_ELEMENT (aggregator), gst_element_set_loop_function (GST_ELEMENT (aggregator),
GST_DEBUG_FUNCPTR (gst_aggregator_loop)); GST_DEBUG_FUNCPTR (gst_aggregator_loop));
} else { } else {
gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL);
} }
@ -271,9 +272,9 @@ gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf,
g_free (aggregator->last_message); g_free (aggregator->last_message);
aggregator->last_message = aggregator->last_message =
g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %"
G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad), G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (aggregator), "last_message"); g_object_notify (G_OBJECT (aggregator), "last_message");
} }
@ -306,11 +307,11 @@ gst_aggregator_loop (GstElement * element)
* and that the peer pad is also enabled. * and that the peer pad is also enabled.
*/ */
if (GST_PAD_IS_USABLE (pad)) { if (GST_PAD_IS_USABLE (pad)) {
buf = GST_BUFFER (gst_pad_pull (pad)); buf = GST_BUFFER (gst_pad_pull (pad));
debug = "loop"; debug = "loop";
/* then push it forward */ /* then push it forward */
gst_aggregator_push (aggregator, pad, buf, debug); gst_aggregator_push (aggregator, pad, buf, debug);
} }
} }
} else { } else {

View file

@ -64,7 +64,7 @@ debug_buffers (GstBufferStore * store)
g_printerr ("BUFFERS in store:\n"); g_printerr ("BUFFERS in store:\n");
while (walk) { while (walk) {
g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data), g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data),
GST_BUFFER_SIZE (walk->data)); GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk); walk = g_list_next (walk);
} }
g_printerr ("\n"); g_printerr ("\n");
@ -127,14 +127,14 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* we assumed valid offsets, but suddenly they are not anymore */ /* we assumed valid offsets, but suddenly they are not anymore */
GST_DEBUG_OBJECT (store, GST_DEBUG_OBJECT (store,
"attempting to add buffer %p with invalid offset to store with valid offset, abort", "attempting to add buffer %p with invalid offset to store with valid offset, abort",
buffer); buffer);
return FALSE; return FALSE;
} else if (!store->buffers } else if (!store->buffers
|| !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* the starting buffer had an invalid offset, in that case we assume continuous buffers */ /* the starting buffer had an invalid offset, in that case we assume continuous buffers */
GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u", GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u",
buffer, GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_SIZE (buffer));
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
store->buffers = g_list_append (store->buffers, buffer); store->buffers = g_list_append (store->buffers, buffer);
return TRUE; return TRUE;
@ -145,9 +145,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer)); g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer));
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"attempting to add buffer %p with offset %" G_GUINT64_FORMAT "attempting to add buffer %p with offset %" G_GUINT64_FORMAT
" and size %u", buffer, GST_BUFFER_OFFSET (buffer), " and size %u", buffer, GST_BUFFER_OFFSET (buffer),
GST_BUFFER_SIZE (buffer)); GST_BUFFER_SIZE (buffer));
/* we keep a sorted list of non-overlapping buffers */ /* we keep a sorted list of non-overlapping buffers */
walk = store->buffers; walk = store->buffers;
while (walk) { while (walk) {
@ -155,88 +155,88 @@ gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
current_list = walk; current_list = walk;
walk = g_list_next (walk); walk = g_list_next (walk);
if (GST_BUFFER_OFFSET (current) < GST_BUFFER_OFFSET (buffer)) { if (GST_BUFFER_OFFSET (current) < GST_BUFFER_OFFSET (buffer)) {
continue; continue;
} else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) { } else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) {
guint needed_size; guint needed_size;
if (walk) { if (walk) {
needed_size = MIN (GST_BUFFER_SIZE (buffer), needed_size = MIN (GST_BUFFER_SIZE (buffer),
GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
} else { } else {
needed_size = GST_BUFFER_SIZE (buffer); needed_size = GST_BUFFER_SIZE (buffer);
} }
if (needed_size <= GST_BUFFER_SIZE (current)) { if (needed_size <= GST_BUFFER_SIZE (current)) {
buffer = NULL; buffer = NULL;
break; break;
} else { } else {
if (needed_size < GST_BUFFER_SIZE (buffer)) { if (needed_size < GST_BUFFER_SIZE (buffer)) {
/* need to create subbuffer to not have overlapping data */ /* need to create subbuffer to not have overlapping data */
GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size); GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size);
g_assert (sub); g_assert (sub);
buffer = sub; buffer = sub;
} else { } else {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
} }
/* replace current buffer with new one */ /* replace current buffer with new one */
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT
" and size %u", current_list->data, buffer, " and size %u", current_list->data, buffer,
GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
gst_data_unref (GST_DATA (current_list->data)); gst_data_unref (GST_DATA (current_list->data));
current_list->data = buffer; current_list->data = buffer;
buffer = NULL; buffer = NULL;
break; break;
} }
} else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) { } else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) {
GList *previous = g_list_previous (current_list); GList *previous = g_list_previous (current_list);
guint64 start_offset = previous ? guint64 start_offset = previous ?
GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_OFFSET (previous->data) +
GST_BUFFER_SIZE (previous->data) : 0; GST_BUFFER_SIZE (previous->data) : 0;
if (start_offset == GST_BUFFER_OFFSET (current)) { if (start_offset == GST_BUFFER_OFFSET (current)) {
buffer = NULL; buffer = NULL;
break; break;
} else { } else {
/* we have data to insert */ /* we have data to insert */
if (start_offset > GST_BUFFER_OFFSET (buffer) || if (start_offset > GST_BUFFER_OFFSET (buffer) ||
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) >
GST_BUFFER_OFFSET (current)) { GST_BUFFER_OFFSET (current)) {
GstBuffer *sub; GstBuffer *sub;
/* need a subbuffer */ /* need a subbuffer */
start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
start_offset - GST_BUFFER_OFFSET (buffer); start_offset - GST_BUFFER_OFFSET (buffer);
sub = gst_buffer_create_sub (buffer, start_offset, sub = gst_buffer_create_sub (buffer, start_offset,
MIN (GST_BUFFER_SIZE (buffer), MIN (GST_BUFFER_SIZE (buffer),
GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (current) - start_offset -
GST_BUFFER_OFFSET (buffer))); GST_BUFFER_OFFSET (buffer)));
g_assert (sub); g_assert (sub);
GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer); GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer);
buffer = sub; buffer = sub;
} else { } else {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
} }
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
store->buffers = store->buffers =
g_list_insert_before (store->buffers, current_list, buffer); g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL; buffer = NULL;
break; break;
} }
} }
} }
if (buffer) { if (buffer) {
gst_data_ref (GST_DATA (buffer)); gst_data_ref (GST_DATA (buffer));
GST_INFO_OBJECT (store, GST_INFO_OBJECT (store,
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
if (current_list) { if (current_list) {
g_list_append (current_list, buffer); g_list_append (current_list, buffer);
} else { } else {
g_assert (store->buffers == NULL); g_assert (store->buffers == NULL);
store->buffers = g_list_prepend (NULL, buffer); store->buffers = g_list_prepend (NULL, buffer);
} }
} }
return TRUE; return TRUE;
@ -352,47 +352,47 @@ gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size)
do_nothing_loop (); */ do_nothing_loop (); */
} else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) { } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) {
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"found matching buffer %p for offset %" G_GUINT64_FORMAT "found matching buffer %p for offset %" G_GUINT64_FORMAT
" and size %u", current, offset, size); " and size %u", current, offset, size);
ret = current; ret = current;
gst_data_ref (GST_DATA (ret)); gst_data_ref (GST_DATA (ret));
GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret)); GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret));
break; break;
} else if (cur_offset + GST_BUFFER_SIZE (current) > offset) { } else if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) { if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) {
ret = gst_buffer_create_sub (current, offset - cur_offset, size); ret = gst_buffer_create_sub (current, offset - cur_offset, size);
GST_LOG_OBJECT (store, GST_LOG_OBJECT (store,
"created subbuffer %p from buffer %p for offset %llu and size %u", "created subbuffer %p from buffer %p for offset %llu and size %u",
ret, current, offset, size); ret, current, offset, size);
break; break;
} }
/* uh, the requested data spans some buffers */ /* uh, the requested data spans some buffers */
ret = gst_buffer_new_and_alloc (size); ret = gst_buffer_new_and_alloc (size);
GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT
" and size %u, will fill with data now", ret, offset, size); " and size %u, will fill with data now", ret, offset, size);
data = GST_BUFFER_DATA (ret); data = GST_BUFFER_DATA (ret);
tmp = GST_BUFFER_SIZE (current) - offset + cur_offset; tmp = GST_BUFFER_SIZE (current) - offset + cur_offset;
memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp); memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp);
data += tmp; data += tmp;
size -= tmp; size -= tmp;
while (size) { while (size) {
if (walk == NULL || if (walk == NULL ||
(have_offset && (have_offset &&
GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) !=
GST_BUFFER_OFFSET (walk->data))) { GST_BUFFER_OFFSET (walk->data))) {
GST_DEBUG_OBJECT (store, GST_DEBUG_OBJECT (store,
"not all data for offset %" G_GUINT64_FORMAT "not all data for offset %" G_GUINT64_FORMAT
" and remaining size %u available, aborting", offset, size); " and remaining size %u available, aborting", offset, size);
gst_data_unref (GST_DATA (ret)); gst_data_unref (GST_DATA (ret));
ret = NULL; ret = NULL;
goto out; goto out;
} }
current = GST_BUFFER (walk->data); current = GST_BUFFER (walk->data);
walk = g_list_next (walk); walk = g_list_next (walk);
tmp = MIN (GST_BUFFER_SIZE (current), size); tmp = MIN (GST_BUFFER_SIZE (current), size);
memcpy (data, GST_BUFFER_DATA (current), tmp); memcpy (data, GST_BUFFER_DATA (current), tmp);
data += tmp; data += tmp;
size -= tmp; size -= tmp;
} }
} }
if (!have_offset) { if (!have_offset) {
@ -437,8 +437,8 @@ gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
} }
while (walk) { while (walk) {
if (have_offset && counting && if (have_offset && counting &&
cur_offset + GST_BUFFER_SIZE (current) != cur_offset + GST_BUFFER_SIZE (current) !=
GST_BUFFER_OFFSET (walk->data)) { GST_BUFFER_OFFSET (walk->data)) {
break; break;
} }
current = GST_BUFFER (walk->data); current = GST_BUFFER (walk->data);
@ -450,11 +450,11 @@ gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
ret += GST_BUFFER_SIZE (current); ret += GST_BUFFER_SIZE (current);
} else { } else {
if (cur_offset > offset) if (cur_offset > offset)
return 0; return 0;
if (cur_offset + GST_BUFFER_SIZE (current) > offset) { if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
/* we have at least some bytes */ /* we have at least some bytes */
ret = cur_offset + GST_BUFFER_SIZE (current) - offset; ret = cur_offset + GST_BUFFER_SIZE (current) - offset;
counting = TRUE; counting = TRUE;
} }
} }
if (!have_offset) { if (!have_offset) {

View file

@ -81,7 +81,7 @@ plugin_init (GstPlugin * plugin)
while ((*my_elements).name) { while ((*my_elements).name) {
if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank,
((*my_elements).type) ())) ((*my_elements).type) ()))
return FALSE; return FALSE;
my_elements++; my_elements++;
} }

View file

@ -70,22 +70,23 @@ gst_fakesink_state_error_get_type (void)
static GEnumValue fakesink_state_error[] = { static GEnumValue fakesink_state_error[] = {
{FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"},
{FAKESINK_STATE_ERROR_NULL_READY, "1", {FAKESINK_STATE_ERROR_NULL_READY, "1",
"Fail state change from NULL to READY"}, "Fail state change from NULL to READY"},
{FAKESINK_STATE_ERROR_READY_PAUSED, "2", {FAKESINK_STATE_ERROR_READY_PAUSED, "2",
"Fail state change from READY to PAUSED"}, "Fail state change from READY to PAUSED"},
{FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3",
"Fail state change from PAUSED to PLAYING"}, "Fail state change from PAUSED to PLAYING"},
{FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4",
"Fail state change from PLAYING to PAUSED"}, "Fail state change from PLAYING to PAUSED"},
{FAKESINK_STATE_ERROR_PAUSED_READY, "5", {FAKESINK_STATE_ERROR_PAUSED_READY, "5",
"Fail state change from PAUSED to READY"}, "Fail state change from PAUSED to READY"},
{FAKESINK_STATE_ERROR_READY_NULL, "6", {FAKESINK_STATE_ERROR_READY_NULL, "6",
"Fail state change from READY to NULL"}, "Fail state change from READY to NULL"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesink_state_error_type) { if (!fakesink_state_error_type) {
fakesink_state_error_type = fakesink_state_error_type =
g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error);
} }
return fakesink_state_error_type; return fakesink_state_error_type;
} }
@ -133,27 +134,27 @@ gst_fakesink_class_init (GstFakeSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
g_param_spec_int ("num_sinks", "Number of sinks", g_param_spec_int ("num_sinks", "Number of sinks",
"The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE)); "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR,
g_param_spec_enum ("state_error", "State Error", g_param_spec_enum ("state_error", "State Error",
"Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR, "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR,
FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last Message", g_param_spec_string ("last_message", "Last Message",
"The message describing current status", NULL, G_PARAM_READABLE)); "The message describing current status", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE, g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
"Send a signal before unreffing the buffer", FALSE, "Send a signal before unreffing the buffer", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", g_param_spec_boolean ("silent", "Silent",
"Don't produce last_message events", FALSE, G_PARAM_READWRITE)); "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -316,22 +317,22 @@ gst_fakesink_chain (GstPad * pad, GstData * _data)
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = fakesink->last_message =
g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
g_object_notify (G_OBJECT (fakesink), "last_message"); g_object_notify (G_OBJECT (fakesink), "last_message");
} }
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
if (fakesink->sync && fakesink->clock) { if (fakesink->sync && fakesink->clock) {
gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value;
gst_element_set_time (GST_ELEMENT (fakesink), value); gst_element_set_time (GST_ELEMENT (fakesink), value);
} }
default: default:
gst_pad_event_default (pad, event); gst_pad_event_default (pad, event);
break; break;
} }
return; return;
} }
@ -344,19 +345,19 @@ gst_fakesink_chain (GstPad * pad, GstData * _data)
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = fakesink->last_message =
g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %"
G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %" G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %"
G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad), G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf),
GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf), GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf),
GST_BUFFER_FLAGS (buf), buf); GST_BUFFER_FLAGS (buf), buf);
g_object_notify (G_OBJECT (fakesink), "last_message"); g_object_notify (G_OBJECT (fakesink), "last_message");
} }
if (fakesink->signal_handoffs) if (fakesink->signal_handoffs)
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
buf, pad); buf, pad);
if (fakesink->dump) { if (fakesink->dump) {
gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
@ -373,27 +374,27 @@ gst_fakesink_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
if (fakesink->state_error == FAKESINK_STATE_ERROR_NULL_READY) if (fakesink->state_error == FAKESINK_STATE_ERROR_NULL_READY)
goto error; goto error;
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_PAUSED) if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_PAUSED)
goto error; goto error;
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_PLAYING) if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_PLAYING)
goto error; goto error;
break; break;
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PLAYING_PAUSED) if (fakesink->state_error == FAKESINK_STATE_ERROR_PLAYING_PAUSED)
goto error; goto error;
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_READY) if (fakesink->state_error == FAKESINK_STATE_ERROR_PAUSED_READY)
goto error; goto error;
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL) if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL)
goto error; goto error;
g_free (fakesink->last_message); g_free (fakesink->last_message);
fakesink->last_message = NULL; fakesink->last_message = NULL;
break; break;

View file

@ -95,9 +95,10 @@ gst_fakesrc_output_get_type (void)
{FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_output_type) { if (!fakesrc_output_type) {
fakesrc_output_type = fakesrc_output_type =
g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
} }
return fakesrc_output_type; return fakesrc_output_type;
} }
@ -112,6 +113,7 @@ gst_fakesrc_data_get_type (void)
{FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_data_type) { if (!fakesrc_data_type) {
fakesrc_data_type = g_enum_register_static ("GstFakeSrcData", fakesrc_data); fakesrc_data_type = g_enum_register_static ("GstFakeSrcData", fakesrc_data);
} }
@ -127,12 +129,13 @@ gst_fakesrc_sizetype_get_type (void)
{FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"},
{FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"},
{FAKESRC_SIZETYPE_RANDOM, "3", {FAKESRC_SIZETYPE_RANDOM, "3",
"Random sized buffers (sizemin <= size <= sizemax)"}, "Random sized buffers (sizemin <= size <= sizemax)"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_sizetype_type) { if (!fakesrc_sizetype_type) {
fakesrc_sizetype_type = fakesrc_sizetype_type =
g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype);
} }
return fakesrc_sizetype_type; return fakesrc_sizetype_type;
} }
@ -148,12 +151,13 @@ gst_fakesrc_filltype_get_type (void)
{FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"},
{FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"},
{FAKESRC_FILLTYPE_PATTERN_CONT, "5", {FAKESRC_FILLTYPE_PATTERN_CONT, "5",
"Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, "Fill buffers with pattern 0x00 -> 0xff that spans buffers"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_filltype_type) { if (!fakesrc_filltype_type) {
fakesrc_filltype_type = fakesrc_filltype_type =
g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype);
} }
return fakesrc_filltype_type; return fakesrc_filltype_type;
} }
@ -201,56 +205,56 @@ gst_fakesrc_class_init (GstFakeSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int ("num-sources", "num-sources", "Number of sources", g_param_spec_int ("num-sources", "num-sources", "Number of sources",
1, G_MAXINT, 1, G_PARAM_READABLE)); 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
g_param_spec_boolean ("loop-based", "loop-based", g_param_spec_boolean ("loop-based", "loop-based",
"Enable loop-based operation", FALSE, G_PARAM_READWRITE)); "Enable loop-based operation", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
g_param_spec_enum ("output", "output", "Output method (currently unused)", g_param_spec_enum ("output", "output", "Output method (currently unused)",
GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
g_param_spec_enum ("data", "data", "Data allocation method", g_param_spec_enum ("data", "data", "Data allocation method",
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE,
g_param_spec_enum ("sizetype", "sizetype", g_param_spec_enum ("sizetype", "sizetype",
"How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE, "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE,
FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0, g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0,
G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0, g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0,
G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
g_param_spec_int ("parentsize", "parentsize", g_param_spec_int ("parentsize", "parentsize",
"Size of parent buffer for sub-buffered allocation", 0, G_MAXINT, "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT,
DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
g_param_spec_enum ("filltype", "filltype", g_param_spec_enum ("filltype", "filltype",
"How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE, "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE,
FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
g_param_spec_string ("pattern", "pattern", "pattern", NULL, g_param_spec_string ("pattern", "pattern", "pattern", NULL,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
g_param_spec_int ("num-buffers", "num-buffers", g_param_spec_int ("num-buffers", "num-buffers",
"Number of buffers to output before sending EOS", G_MININT, G_MAXINT, "Number of buffers to output before sending EOS", G_MININT, G_MAXINT,
0, G_PARAM_READWRITE)); 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE, g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", g_param_spec_string ("last-message", "last-message",
"The last status message", NULL, G_PARAM_READABLE)); "The last status message", NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", g_param_spec_boolean ("silent", "Silent",
"Don't produce last_message events", FALSE, G_PARAM_READWRITE)); "Don't produce last_message events", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", g_param_spec_boolean ("signal-handoffs", "Signal handoffs",
"Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE)); "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] = gst_fakesrc_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -334,6 +338,7 @@ gst_fakesrc_get_formats (GstPad * pad)
GST_FORMAT_DEFAULT, GST_FORMAT_DEFAULT,
0, 0,
}; };
return formats; return formats;
} }
@ -347,6 +352,7 @@ gst_fakesrc_get_query_types (GstPad * pad)
GST_QUERY_SEGMENT_END, GST_QUERY_SEGMENT_END,
0, 0,
}; };
return types; return types;
} }
@ -384,6 +390,7 @@ gst_fakesrc_get_event_mask (GstPad * pad)
{GST_EVENT_FLUSH, 0}, {GST_EVENT_FLUSH, 0},
{0, 0}, {0, 0},
}; };
return masks; return masks;
} }
@ -399,7 +406,7 @@ gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
src->buffer_count = GST_EVENT_SEEK_OFFSET (event); src->buffer_count = GST_EVENT_SEEK_OFFSET (event);
if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
break; break;
} }
/* else we do a flush too */ /* else we do a flush too */
case GST_EVENT_SEEK_SEGMENT: case GST_EVENT_SEEK_SEGMENT:
@ -407,7 +414,7 @@ gst_fakesrc_event_handler (GstPad * pad, GstEvent * event)
src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event); src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
src->buffer_count = src->segment_start; src->buffer_count = src->segment_start;
src->segment_loop = src->segment_loop =
GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
break; break;
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
src->need_flush = TRUE; src->need_flush = TRUE;
@ -427,7 +434,7 @@ gst_fakesrc_update_functions (GstFakeSrc * src)
if (src->loop_based) { if (src->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (src), gst_element_set_loop_function (GST_ELEMENT (src),
GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
} else { } else {
gst_element_set_loop_function (GST_ELEMENT (src), NULL); gst_element_set_loop_function (GST_ELEMENT (src), NULL);
} }
@ -485,13 +492,13 @@ gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value,
src->data = g_value_get_enum (value); src->data = g_value_get_enum (value);
if (src->data == FAKESRC_DATA_SUBBUFFER) { if (src->data == FAKESRC_DATA_SUBBUFFER) {
if (!src->parent) if (!src->parent)
gst_fakesrc_alloc_parent (src); gst_fakesrc_alloc_parent (src);
} else { } else {
if (src->parent) { if (src->parent) {
gst_buffer_unref (src->parent); gst_buffer_unref (src->parent);
src->parent = NULL; src->parent = NULL;
} }
} }
break; break;
case ARG_SIZETYPE: case ARG_SIZETYPE:
@ -614,7 +621,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
guint8 *ptr = GST_BUFFER_DATA (buf); guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) { for (i = GST_BUFFER_SIZE (buf); i; i--) {
*ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX)); *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX));
} }
break; break;
} }
@ -626,7 +633,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf)
guint8 *ptr = GST_BUFFER_DATA (buf); guint8 *ptr = GST_BUFFER_DATA (buf);
for (i = GST_BUFFER_SIZE (buf); i; i--) { for (i = GST_BUFFER_SIZE (buf); i; i--) {
*ptr++ = src->pattern_byte++; *ptr++ = src->pattern_byte++;
} }
break; break;
} }
@ -647,18 +654,18 @@ gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size)
if (size != 0) { if (size != 0) {
switch (src->filltype) { switch (src->filltype) {
case FAKESRC_FILLTYPE_NOTHING: case FAKESRC_FILLTYPE_NOTHING:
GST_BUFFER_DATA (buf) = g_malloc (size); GST_BUFFER_DATA (buf) = g_malloc (size);
break; break;
case FAKESRC_FILLTYPE_NULL: case FAKESRC_FILLTYPE_NULL:
GST_BUFFER_DATA (buf) = g_malloc0 (size); GST_BUFFER_DATA (buf) = g_malloc0 (size);
break; break;
case FAKESRC_FILLTYPE_RANDOM: case FAKESRC_FILLTYPE_RANDOM:
case FAKESRC_FILLTYPE_PATTERN: case FAKESRC_FILLTYPE_PATTERN:
case FAKESRC_FILLTYPE_PATTERN_CONT: case FAKESRC_FILLTYPE_PATTERN_CONT:
default: default:
GST_BUFFER_DATA (buf) = g_malloc (size); GST_BUFFER_DATA (buf) = g_malloc (size);
gst_fakesrc_prepare_buffer (src, buf); gst_fakesrc_prepare_buffer (src, buf);
break; break;
} }
} }
@ -676,9 +683,9 @@ gst_fakesrc_get_size (GstFakeSrc * src)
break; break;
case FAKESRC_SIZETYPE_RANDOM: case FAKESRC_SIZETYPE_RANDOM:
size = size =
src->sizemin + src->sizemin +
(guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX + (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX +
(gfloat) src->sizemin)); (gfloat) src->sizemin));
break; break;
case FAKESRC_SIZETYPE_NULL: case FAKESRC_SIZETYPE_NULL:
default: default:
@ -707,19 +714,19 @@ gst_fakesrc_create_buffer (GstFakeSrc * src)
case FAKESRC_DATA_SUBBUFFER: case FAKESRC_DATA_SUBBUFFER:
/* see if we have a parent to subbuffer */ /* see if we have a parent to subbuffer */
if (!src->parent) { if (!src->parent) {
gst_fakesrc_alloc_parent (src); gst_fakesrc_alloc_parent (src);
g_assert (src->parent); g_assert (src->parent);
} }
/* see if it's large enough */ /* see if it's large enough */
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) { if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
src->parentoffset += size; src->parentoffset += size;
} else { } else {
/* the parent is useless now */ /* the parent is useless now */
gst_buffer_unref (src->parent); gst_buffer_unref (src->parent);
src->parent = NULL; src->parent = NULL;
/* try again (this will allocate a new parent) */ /* try again (this will allocate a new parent) */
return gst_fakesrc_create_buffer (src); return gst_fakesrc_create_buffer (src);
} }
gst_fakesrc_prepare_buffer (src, buf); gst_fakesrc_prepare_buffer (src, buf);
break; break;
@ -781,9 +788,9 @@ gst_fakesrc_get (GstPad * pad)
g_free (src->last_message); g_free (src->last_message);
src->last_message = src->last_message =
g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %"
G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad), G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (src), "last_message"); g_object_notify (G_OBJECT (src), "last_message");
} }
@ -791,7 +798,7 @@ gst_fakesrc_get (GstPad * pad)
if (src->signal_handoffs) { if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit"); GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf, pad); buf, pad);
GST_LOG_OBJECT (src, "post handoff emit"); GST_LOG_OBJECT (src, "post handoff emit");
} }
@ -856,8 +863,8 @@ gst_fakesrc_change_state (GstElement * element)
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (fakesrc->parent) { if (fakesrc->parent) {
gst_buffer_unref (fakesrc->parent); gst_buffer_unref (fakesrc->parent);
fakesrc->parent = NULL; fakesrc->parent = NULL;
} }
g_free (fakesrc->last_message); g_free (fakesrc->last_message);
fakesrc->last_message = NULL; fakesrc->last_message = NULL;

View file

@ -82,7 +82,7 @@ gst_fdsink_class_init (GstFdSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to write to", g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
0, G_MAXINT, 1, G_PARAM_READWRITE)); 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property; gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property; gobject_class->get_property = gst_fdsink_get_property;
@ -114,7 +114,7 @@ gst_fdsink_chain (GstPad * pad, GstData * _data)
if (GST_BUFFER_DATA (buf)) { if (GST_BUFFER_DATA (buf)) {
GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf), GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf),
fdsink->fd); fdsink->fd);
write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
} }

View file

@ -92,14 +92,14 @@ gst_fdsrc_class_init (GstFdSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to read from", g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", g_param_spec_ulong ("blocksize", "Block size",
"Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT,
g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
gst_fdsrc_signals[SIGNAL_TIMEOUT] = gst_fdsrc_signals[SIGNAL_TIMEOUT] =
g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -204,11 +204,11 @@ gst_fdsrc_get (GstPad * pad)
do { do {
retval = select (1, &readfds, NULL, NULL, tp); retval = select (1, &readfds, NULL, NULL, tp);
} while (retval == -1 && errno == EINTR); /* retry if interrupted */ } while (retval == -1 && errno == EINTR); /* retry if interrupted */
if (retval == -1) { if (retval == -1) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("select on file descriptor: %s.", g_strerror (errno))); ("select on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else if (retval == 0) { } else if (retval == 0) {
@ -219,7 +219,7 @@ gst_fdsrc_get (GstPad * pad)
do { do {
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize); readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize);
} while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */
if (readbytes > 0) { if (readbytes > 0) {
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
@ -234,7 +234,7 @@ gst_fdsrc_get (GstPad * pad)
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else { } else {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("read on file descriptor: %s.", g_strerror (errno))); ("read on file descriptor: %s.", g_strerror (errno)));
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }

View file

@ -66,6 +66,7 @@ gst_filesink_get_formats (GstPad * pad)
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
0, 0,
}; };
return formats; return formats;
} }
@ -77,6 +78,7 @@ gst_filesink_get_query_types (GstPad * pad)
GST_QUERY_POSITION, GST_QUERY_POSITION,
0 0
}; };
return types; return types;
} }
@ -110,6 +112,7 @@ _do_init (GType filesink_type)
NULL, NULL,
NULL NULL
}; };
g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER,
&urihandler_info); &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0,
@ -136,7 +139,7 @@ gst_filesink_class_init (GstFileSinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "File Location", g_param_spec_string ("location", "File Location",
"Location of the file to write", NULL, G_PARAM_READWRITE)); "Location of the file to write", NULL, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] = gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -251,15 +254,15 @@ gst_filesink_open_file (GstFileSink * sink)
/* open the file */ /* open the file */
if (sink->filename == NULL || sink->filename[0] == '\0') { if (sink->filename == NULL || sink->filename[0] == '\0') {
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
(_("No file name specified for writing.")), (NULL)); (_("No file name specified for writing.")), (NULL));
return FALSE; return FALSE;
} }
sink->file = fopen (sink->filename, "w"); sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) { if (sink->file == NULL) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
(_("Could not open file \"%s\" for writing."), sink->filename), (_("Could not open file \"%s\" for writing."), sink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} }
@ -277,7 +280,7 @@ gst_filesink_close_file (GstFileSink * sink)
if (fclose (sink->file) != 0) { if (fclose (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
(_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM); (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
} else { } else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN); GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
} }
@ -292,25 +295,25 @@ gst_filesink_pad_query (GstPad * pad, GstQueryType type,
switch (type) { switch (type) {
case GST_QUERY_TOTAL: case GST_QUERY_TOTAL:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
*value = sink->data_written; /* FIXME - doesn't the kernel provide *value = sink->data_written; /* FIXME - doesn't the kernel provide
such a function? */ such a function? */
break; break;
} }
default: default:
return FALSE; return FALSE;
} }
break; break;
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) {
*value = ftell (sink->file); *value = ftell (sink->file);
break; break;
} }
default: default:
return FALSE; return FALSE;
} }
break; break;
default: default:
@ -336,27 +339,27 @@ gst_filesink_handle_event (GstPad * pad, GstEvent * event)
switch (type) { switch (type) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES, g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES,
FALSE); FALSE);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
if (fflush (filesink->file)) if (fflush (filesink->file))
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
switch (GST_EVENT_SEEK_METHOD (event)) { switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET: case GST_SEEK_METHOD_SET:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END);
break; break;
default: default:
g_warning ("unknown seek method!"); g_warning ("unknown seek method!");
break; break;
} }
break; break;
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
@ -364,16 +367,16 @@ gst_filesink_handle_event (GstPad * pad, GstEvent * event)
gint64 offset; gint64 offset;
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset)) if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset))
fseek (filesink->file, offset, SEEK_SET); fseek (filesink->file, offset, SEEK_SET);
gst_event_unref (event); gst_event_unref (event);
break; break;
} }
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
if (fflush (filesink->file)) { if (fflush (filesink->file)) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
} }
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
@ -419,15 +422,15 @@ gst_filesink_chain (GstPad * pad, GstData * _data)
back_pending = filesink->data_written - ftell (filesink->file); back_pending = filesink->data_written - ftell (filesink->file);
while (bytes_written < GST_BUFFER_SIZE (buf)) { while (bytes_written < GST_BUFFER_SIZE (buf)) {
size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
GST_BUFFER_SIZE (buf) - bytes_written, GST_BUFFER_SIZE (buf) - bytes_written,
filesink->file); filesink->file);
if (wrote <= 0) { if (wrote <= 0) {
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
(_("Error while writing to file \"%s\"."), filesink->filename), (_("Error while writing to file \"%s\"."), filesink->filename),
("Only %d of %d bytes written: %s", ("Only %d of %d bytes written: %s",
bytes_written, GST_BUFFER_SIZE (buf), strerror (errno))); bytes_written, GST_BUFFER_SIZE (buf), strerror (errno)));
break; break;
} }
bytes_written += wrote; bytes_written += wrote;
} }
@ -449,13 +452,13 @@ gst_filesink_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN))
gst_filesink_close_file (GST_FILESINK (element)); gst_filesink_close_file (GST_FILESINK (element));
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) {
if (!gst_filesink_open_file (GST_FILESINK (element))) if (!gst_filesink_open_file (GST_FILESINK (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
break; break;
} }
@ -477,6 +480,7 @@ static gchar **
gst_filesink_uri_get_protocols (void) gst_filesink_uri_get_protocols (void)
{ {
static gchar *protocols[] = { "file", NULL }; static gchar *protocols[] = { "file", NULL };
return protocols; return protocols;
} }
static const gchar * static const gchar *

View file

@ -107,11 +107,12 @@ gst_filesrc_get_event_mask (GstPad * pad)
{ {
static const GstEventMask masks[] = { static const GstEventMask masks[] = {
{GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
{GST_EVENT_FLUSH, 0}, {GST_EVENT_FLUSH, 0},
{GST_EVENT_SIZE, 0}, {GST_EVENT_SIZE, 0},
{0, 0} {0, 0}
}; };
return masks; return masks;
} }
@ -123,6 +124,7 @@ gst_filesrc_get_query_types (GstPad * pad)
GST_QUERY_POSITION, GST_QUERY_POSITION,
0 0
}; };
return types; return types;
} }
@ -133,6 +135,7 @@ gst_filesrc_get_formats (GstPad * pad)
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
0, 0,
}; };
return formats; return formats;
} }
@ -162,6 +165,7 @@ _do_init (GType filesrc_type)
NULL, NULL,
NULL NULL
}; };
g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER,
&urihandler_info); &urihandler_info);
GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element"); GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element");
@ -188,22 +192,22 @@ gst_filesrc_class_init (GstFileSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "File-descriptor", g_param_spec_int ("fd", "File-descriptor",
"File-descriptor for the file being mmap()d", 0, G_MAXINT, 0, "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "File Location", g_param_spec_string ("location", "File Location",
"Location of the file to read", NULL, G_PARAM_READWRITE)); "Location of the file to read", NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", g_param_spec_ulong ("blocksize", "Block size",
"Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
g_param_spec_ulong ("mmapsize", "mmap() Block Size", g_param_spec_ulong ("mmapsize", "mmap() Block Size",
"Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE, "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
g_param_spec_boolean ("touch", "Touch read data", g_param_spec_boolean ("touch", "Touch read data",
"Touch data to force disk read", FALSE, G_PARAM_READWRITE)); "Touch data to force disk read", FALSE, G_PARAM_READWRITE));
gobject_class->dispose = gst_filesrc_dispose; gobject_class->dispose = gst_filesrc_dispose;
gobject_class->set_property = gst_filesrc_set_property; gobject_class->set_property = gst_filesrc_set_property;
@ -235,7 +239,7 @@ gst_filesrc_init (GstFileSrc * src)
src->touch = FALSE; src->touch = FALSE;
src->mapbuf = NULL; src->mapbuf = NULL;
src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->seek_happened = FALSE; src->seek_happened = FALSE;
} }
@ -301,12 +305,12 @@ gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value,
break; break;
case ARG_MMAPSIZE: case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) { if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO_OBJECT (src, GST_INFO_OBJECT (src,
"invalid mapsize, must be a multiple of pagesize, which is %d", "invalid mapsize, must be a multiple of pagesize, which is %d",
src->pagesize); src->pagesize);
} }
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -390,7 +394,7 @@ gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size)
return NULL; return NULL;
} else if (mmapregion == MAP_FAILED) { } else if (mmapregion == MAP_FAILED) {
GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s", GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
(unsigned long) size, src->fd, offset, strerror (errno)); (unsigned long) size, src->fd, offset, strerror (errno));
return NULL; return NULL;
} }
GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
@ -435,7 +439,7 @@ gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size)
mapbase = offset - mod; mapbase = offset - mod;
mapsize = mapsize =
((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/ /* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
map = gst_filesrc_map_region (src, mapbase, mapsize); map = gst_filesrc_map_region (src, mapbase, mapsize);
if (map == NULL) if (map == NULL)
@ -468,10 +472,10 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* calculate end pointers so we don't have to do so repeatedly later */ /* calculate end pointers so we don't have to do so repeatedly later */
readsize = src->block_size; readsize = src->block_size;
readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
mapstart = GST_BUFFER_OFFSET (src->mapbuf); mapstart = GST_BUFFER_OFFSET (src->mapbuf);
mapsize = GST_BUFFER_SIZE (src->mapbuf); mapsize = GST_BUFFER_SIZE (src->mapbuf);
mapend = mapstart + mapsize; /* note this is the byte *after* the map */ mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */ /* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) { if (readend > src->filelen) {
@ -491,22 +495,22 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* ('cause by definition if readend is in the buffer, so's readstart) */ /* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) { if (readend <= mapend) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
src->curoffset, (int) readsize, mapstart, mapsize); src->curoffset, (int) readsize, mapstart, mapsize);
buf = buf =
gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
readsize); readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
/* if the start actually is within the current mmap region, map an overlap buffer */ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) { } else if (src->curoffset < mapend) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
(unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
(gint) mapsize); (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
} }
/* the only other option is that buffer is totally outside, which means we search for it */ /* the only other option is that buffer is totally outside, which means we search for it */
@ -518,9 +522,9 @@ gst_filesrc_get_mmap (GstFileSrc * src)
/* or the read buffer fully contains the current mmap region */ /* or the read buffer fully contains the current mmap region */
/* either way, it's really not relevant, we just create a new region anyway */ /* either way, it's really not relevant, we just create a new region anyway */
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
(unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart,
(gint) mapsize); (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -530,16 +534,16 @@ gst_filesrc_get_mmap (GstFileSrc * src)
if (buf == NULL) { if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */ /* first check to see if there's a map that covers the right region already */
GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d", GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",
src->curoffset, (int) readsize); src->curoffset, (int) readsize);
/* if the read buffer crosses a mmap region boundary, create a one-off region */ /* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d crosses a %d-byte boundary, creating a one-off", "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
src->curoffset, (int) readsize, (int) src->mapsize); src->curoffset, (int) readsize, (int) src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
/* otherwise we will create a new mmap region and set it to the default */ /* otherwise we will create a new mmap region and set it to the default */
} else { } else {
@ -548,29 +552,29 @@ gst_filesrc_get_mmap (GstFileSrc * src)
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
src->curoffset, readsize, nextmap, src->mapsize); src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */ /* first, we're done with the old mapbuf */
gst_buffer_unref (src->mapbuf); gst_buffer_unref (src->mapbuf);
mapsize = src->mapsize; mapsize = src->mapsize;
/* double the mapsize as long as the readsize is smaller */ /* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) { while (readsize - (src->curoffset - nextmap) > mapsize) {
GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d",
readsize, (int) mapsize); readsize, (int) mapsize);
mapsize <<= 1; mapsize <<= 1;
} }
/* create a new one */ /* create a new one */
src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize); src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize);
if (src->mapbuf == NULL) if (src->mapbuf == NULL)
return NULL; return NULL;
/* subbuffer it */ /* subbuffer it */
buf = buf =
gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap,
readsize); readsize);
GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (buf) =
GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap;
} }
} }
@ -598,7 +602,7 @@ gst_filesrc_get_read (GstFileSrc * src)
readsize = src->block_size; readsize = src->block_size;
if (src->curoffset + readsize > src->filelen) { if (src->curoffset + readsize > src->filelen) {
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| src->curoffset + readsize > src->filelen) { || src->curoffset + readsize > src->filelen) {
readsize = src->filelen - src->curoffset; readsize = src->filelen - src->curoffset;
} }
} }
@ -613,7 +617,7 @@ gst_filesrc_get_read (GstFileSrc * src)
} }
if (ret < readsize) { if (ret < readsize) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("unexpected end of file.")); ("unexpected end of file."));
return NULL; return NULL;
} }
@ -648,8 +652,8 @@ gst_filesrc_get (GstPad * pad)
src->seek_happened = FALSE; src->seek_happened = FALSE;
GST_DEBUG_OBJECT (src, "sending discont"); GST_DEBUG_OBJECT (src, "sending discont");
event = event =
gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset,
NULL); NULL);
return GST_DATA (event); return GST_DATA (event);
} }
@ -658,7 +662,7 @@ gst_filesrc_get (GstPad * pad)
if (src->curoffset == src->filelen) { if (src->curoffset == src->filelen) {
if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) { if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) {
GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT,
src->curoffset, src->filelen); src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
} }
@ -697,7 +701,7 @@ gst_filesrc_open_file (GstFileSrc * src)
if (src->filename == NULL || src->filename[0] == '\0') { if (src->filename == NULL || src->filename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
(_("No file name specified for reading.")), (NULL)); (_("No file name specified for reading.")), (NULL));
return FALSE; return FALSE;
} }
@ -711,8 +715,8 @@ gst_filesrc_open_file (GstFileSrc * src)
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL)); GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL));
else else
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open file \"%s\" for reading."), src->filename), (_("Could not open file \"%s\" for reading."), src->filename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} else { } else {
/* check if it is a regular file, otherwise bail out */ /* check if it is a regular file, otherwise bail out */
@ -722,7 +726,7 @@ gst_filesrc_open_file (GstFileSrc * src)
if (!S_ISREG (stat_results.st_mode)) { if (!S_ISREG (stat_results.st_mode)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("File \"%s\" isn't a regular file."), src->filename), (NULL)); (_("File \"%s\" isn't a regular file."), src->filename), (NULL));
close (src->fd); close (src->fd);
return FALSE; return FALSE;
} }
@ -780,13 +784,13 @@ gst_filesrc_change_state (GstElement * element)
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) {
if (!gst_filesrc_open_file (GST_FILESRC (element))) if (!gst_filesrc_open_file (GST_FILESRC (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN))
gst_filesrc_close_file (GST_FILESRC (element)); gst_filesrc_close_file (GST_FILESRC (element));
src->seek_happened = TRUE; src->seek_happened = TRUE;
break; break;
default: default:
@ -808,23 +812,23 @@ gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type,
switch (type) { switch (type) {
case GST_QUERY_TOTAL: case GST_QUERY_TOTAL:
if (*format != GST_FORMAT_BYTES) { if (*format != GST_FORMAT_BYTES) {
return FALSE; return FALSE;
} }
gst_filesrc_check_filesize (src); gst_filesrc_check_filesize (src);
*value = src->filelen; *value = src->filelen;
break; break;
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
switch (*format) { switch (*format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
*value = src->curoffset; *value = src->curoffset;
break; break;
case GST_FORMAT_PERCENT: case GST_FORMAT_PERCENT:
if (src->filelen == 0) if (src->filelen == 0)
return FALSE; return FALSE;
*value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen;
break; break;
default: default:
return FALSE; return FALSE;
} }
break; break;
default: default:
@ -847,44 +851,44 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
gint64 offset; gint64 offset;
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) { if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_BYTES) {
goto error; goto error;
} }
offset = GST_EVENT_SEEK_OFFSET (event); offset = GST_EVENT_SEEK_OFFSET (event);
switch (GST_EVENT_SEEK_METHOD (event)) { switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET: case GST_SEEK_METHOD_SET:
if (offset > src->filelen && (!gst_filesrc_check_filesize (src) if (offset > src->filelen && (!gst_filesrc_check_filesize (src)
|| offset > src->filelen)) { || offset > src->filelen)) {
goto error; goto error;
} }
src->curoffset = offset; src->curoffset = offset;
GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
if (offset + src->curoffset > src->filelen) if (offset + src->curoffset > src->filelen)
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| offset + src->curoffset > src->filelen) || offset + src->curoffset > src->filelen)
goto error; goto error;
src->curoffset += offset; src->curoffset += offset;
GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
if (ABS (offset) > src->filelen) { if (ABS (offset) > src->filelen) {
if (!gst_filesrc_check_filesize (src) if (!gst_filesrc_check_filesize (src)
|| ABS (offset) > src->filelen) || ABS (offset) > src->filelen)
goto error; goto error;
goto error; goto error;
} }
src->curoffset = src->filelen - ABS (offset); src->curoffset = src->filelen - ABS (offset);
GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT,
src->curoffset); src->curoffset);
break; break;
default: default:
goto error; goto error;
break; break;
} }
src->seek_happened = TRUE; src->seek_happened = TRUE;
src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
@ -892,7 +896,7 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
} }
case GST_EVENT_SIZE: case GST_EVENT_SIZE:
if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) { if (GST_EVENT_SIZE_FORMAT (event) != GST_FORMAT_BYTES) {
goto error; goto error;
} }
src->block_size = GST_EVENT_SIZE_VALUE (event); src->block_size = GST_EVENT_SIZE_VALUE (event);
g_object_notify (G_OBJECT (src), "blocksize"); g_object_notify (G_OBJECT (src), "blocksize");
@ -923,6 +927,7 @@ static gchar **
gst_filesrc_uri_get_protocols (void) gst_filesrc_uri_get_protocols (void)
{ {
static gchar *protocols[] = { "file", NULL }; static gchar *protocols[] = { "file", NULL };
return protocols; return protocols;
} }
static const gchar * static const gchar *

View file

@ -94,31 +94,31 @@ gst_identity_class_init (GstIdentityClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
g_param_spec_boolean ("loop-based", "Loop-based", g_param_spec_boolean ("loop-based", "Loop-based",
"Set to TRUE to use loop-based rather than chain-based scheduling", "Set to TRUE to use loop-based rather than chain-based scheduling",
TRUE, G_PARAM_READWRITE)); TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME,
g_param_spec_uint ("sleep-time", "Sleep time", g_param_spec_uint ("sleep-time", "Sleep time",
"Microseconds to sleep between processing", 0, G_MAXUINT, 0, "Microseconds to sleep between processing", 0, G_MAXUINT, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE,
g_param_spec_uint ("duplicate", "Duplicate Buffers", g_param_spec_uint ("duplicate", "Duplicate Buffers",
"Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE)); "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER,
g_param_spec_int ("error_after", "Error After", "Error after N buffers", g_param_spec_int ("error_after", "Error After", "Error after N buffers",
G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); G_MININT, G_MAXINT, -1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY,
g_param_spec_float ("drop_probability", "Drop Probability", g_param_spec_float ("drop_probability", "Drop Probability",
"The Probability a buffer is dropped", 0.0, 1.0, 0.0, "The Probability a buffer is dropped", 0.0, 1.0, 0.0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", FALSE, g_param_spec_boolean ("silent", "silent", "silent", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "last-message", NULL, g_param_spec_string ("last-message", "last-message", "last-message", NULL,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE, g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gst_identity_signals[SIGNAL_HANDOFF] = gst_identity_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -173,7 +173,7 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (identity->error_after == 0) { if (identity->error_after == 0) {
gst_buffer_unref (buf); gst_buffer_unref (buf);
GST_ELEMENT_ERROR (identity, CORE, FAILED, GST_ELEMENT_ERROR (identity, CORE, FAILED,
(_("Failed after iterations as requested.")), (NULL)); (_("Failed after iterations as requested.")), (NULL));
return; return;
} }
} }
@ -181,12 +181,12 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (identity->drop_probability > 0.0) { if (identity->drop_probability > 0.0) {
if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) { if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
if (identity->last_message != NULL) { if (identity->last_message != NULL) {
g_free (identity->last_message); g_free (identity->last_message);
} }
identity->last_message = identity->last_message =
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message"); g_object_notify (G_OBJECT (identity), "last-message");
gst_buffer_unref (buf); gst_buffer_unref (buf);
return; return;
@ -200,14 +200,14 @@ gst_identity_chain (GstPad * pad, GstData * _data)
if (!identity->silent) { if (!identity->silent) {
g_free (identity->last_message); g_free (identity->last_message);
identity->last_message = identity->last_message =
g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_object_notify (G_OBJECT (identity), "last-message"); g_object_notify (G_OBJECT (identity), "last-message");
} }
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf); buf);
if (i > 1) if (i > 1)
gst_buffer_ref (buf); gst_buffer_ref (buf);
@ -259,12 +259,12 @@ gst_identity_set_property (GObject * object, guint prop_id,
case ARG_LOOP_BASED: case ARG_LOOP_BASED:
identity->loop_based = g_value_get_boolean (value); identity->loop_based = g_value_get_boolean (value);
if (identity->loop_based) { if (identity->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (identity), gst_element_set_loop_function (GST_ELEMENT (identity),
gst_identity_loop); gst_identity_loop);
gst_pad_set_chain_function (identity->sinkpad, NULL); gst_pad_set_chain_function (identity->sinkpad, NULL);
} else { } else {
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
gst_element_set_loop_function (GST_ELEMENT (identity), NULL); gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
} }
break; break;
case ARG_SLEEP_TIME: case ARG_SLEEP_TIME:

View file

@ -397,7 +397,7 @@ gst_md5sink_class_init (GstMD5SinkClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5,
g_param_spec_string ("md5", "md5", "current value of the md5 sum", g_param_spec_string ("md5", "md5", "current value of the md5 sum",
"", G_PARAM_READABLE)); "", G_PARAM_READABLE));
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state);
} }
@ -467,7 +467,7 @@ gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value,
guchar *md5string = g_malloc0 (33); guchar *md5string = g_malloc0 (33);
for (i = 0; i < 16; ++i) for (i = 0; i < 16; ++i)
sprintf (md5string + i * 2, "%02x", sink->md5[i]); sprintf (md5string + i * 2, "%02x", sink->md5[i]);
g_value_set_string (value, md5string); g_value_set_string (value, md5string);
g_free (md5string); g_free (md5string);
} }

View file

@ -105,7 +105,7 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass * klass)
G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL,
g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->set_property = gst_multifilesrc_set_property;
gobject_class->get_property = gst_multifilesrc_get_property; gobject_class->get_property = gst_multifilesrc_get_property;
@ -149,11 +149,11 @@ gst_multifilesrc_set_property (GObject * object, guint prop_id,
/* clear the filename if we get a NULL */ /* clear the filename if we get a NULL */
if (g_value_get_pointer (value) == NULL) { if (g_value_get_pointer (value) == NULL) {
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->listptr = NULL; src->listptr = NULL;
/* otherwise set the new filenames */ /* otherwise set the new filenames */
} else { } else {
src->listptr = g_value_get_pointer (value); src->listptr = g_value_get_pointer (value);
} }
break; break;
default: default:
@ -244,7 +244,7 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
if (src->currentfilename == NULL || src->currentfilename[0] == '\0') { if (src->currentfilename == NULL || src->currentfilename[0] == '\0') {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
(_("No file name specified for reading.")), (NULL)); (_("No file name specified for reading.")), (NULL));
return FALSE; return FALSE;
} }
@ -252,8 +252,8 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
src->fd = open ((const char *) src->currentfilename, O_RDONLY); src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) { if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("Could not open file \"%s\" for reading."), src->currentfilename), (_("Could not open file \"%s\" for reading."), src->currentfilename),
GST_ERROR_SYSTEM); GST_ERROR_SYSTEM);
return FALSE; return FALSE;
} else { } else {
@ -267,7 +267,7 @@ gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad)
if (src->map == NULL) { if (src->map == NULL) {
close (src->fd); close (src->fd);
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL),
("mmap call failed.")); ("mmap call failed."));
return FALSE; return FALSE;
} }
GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN); GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN);

View file

@ -98,7 +98,7 @@ gst_pipefilter_class_init (GstPipefilterClass * klass)
gobject_class->set_property = gst_pipefilter_set_property; gobject_class->set_property = gst_pipefilter_set_property;
gobject_class->get_property = gst_pipefilter_get_property; gobject_class->get_property = gst_pipefilter_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_pipefilter_change_state; gstelement_class->change_state = gst_pipefilter_change_state;
} }
@ -134,9 +134,9 @@ gst_pipefilter_handle_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
if (close (pipefilter->fdin[1]) < 0) if (close (pipefilter->fdin[1]) < 0)
perror ("close"); perror ("close");
if (close (pipefilter->fdout[0]) < 0) if (close (pipefilter->fdout[0]) < 0)
perror ("close"); perror ("close");
break; break;
default: default:
break; break;
@ -279,8 +279,8 @@ gst_pipefilter_open_file (GstPipefilter * src)
close (src->fdin[1]); close (src->fdin[1]);
close (src->fdout[0]); close (src->fdout[0]);
/* child */ /* child */
dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */ dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */
dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
execvp (src->command[0], &src->command[0]); execvp (src->command[0], &src->command[0]);
/* will only be reached if execvp has an error */ /* will only be reached if execvp has an error */
GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM);
@ -327,7 +327,7 @@ gst_pipefilter_change_state (GstElement * element)
} else { } else {
if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) { if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) {
if (!gst_pipefilter_open_file (GST_PIPEFILTER (element))) if (!gst_pipefilter_open_file (GST_PIPEFILTER (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
} }

View file

@ -69,7 +69,8 @@ typedef struct _GstQueueEventResponse
{ {
GstEvent *event; GstEvent *event;
gboolean ret, handled; gboolean ret, handled;
} GstQueueEventResponse; }
GstQueueEventResponse;
static void gst_queue_base_init (GstQueueClass * klass); static void gst_queue_base_init (GstQueueClass * klass);
static void gst_queue_class_init (GstQueueClass * klass); static void gst_queue_class_init (GstQueueClass * klass);
@ -106,6 +107,7 @@ queue_leaky_get_type (void)
{GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"}, {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!queue_leaky_type) { if (!queue_leaky_type) {
queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky); queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
} }
@ -135,7 +137,7 @@ gst_queue_get_type (void)
}; };
queue_type = g_type_register_static (GST_TYPE_ELEMENT, queue_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstQueue", &queue_info, 0); "GstQueue", &queue_info, 0);
} }
return queue_type; return queue_type;
@ -174,56 +176,56 @@ gst_queue_class_init (GstQueueClass * klass)
/* properties */ /* properties */
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES,
g_param_spec_uint ("current-level-bytes", "Current level (kB)", g_param_spec_uint ("current-level-bytes", "Current level (kB)",
"Current amount of data in the queue (bytes)", "Current amount of data in the queue (bytes)",
0, G_MAXUINT, 0, G_PARAM_READABLE)); 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS,
g_param_spec_uint ("current-level-buffers", "Current level (buffers)", g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
"Current number of buffers in the queue", "Current number of buffers in the queue",
0, G_MAXUINT, 0, G_PARAM_READABLE)); 0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME, g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME,
g_param_spec_uint64 ("current-level-time", "Current level (ns)", g_param_spec_uint64 ("current-level-time", "Current level (ns)",
"Current amount of data in the queue (in ns)", "Current amount of data in the queue (in ns)",
0, G_MAXUINT64, 0, G_PARAM_READABLE)); 0, G_MAXUINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES,
g_param_spec_uint ("max-size-bytes", "Max. size (kB)", g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
"Max. amount of data in the queue (bytes, 0=disable)", "Max. amount of data in the queue (bytes, 0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS,
g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
"Max. number of buffers in the queue (0=disable)", "Max. number of buffers in the queue (0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME, g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME,
g_param_spec_uint64 ("max-size-time", "Max. size (ns)", g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
"Max. amount of data in the queue (in ns, 0=disable)", "Max. amount of data in the queue (in ns, 0=disable)",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES,
g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
"Min. amount of data in the queue to allow reading (bytes, 0=disable)", "Min. amount of data in the queue to allow reading (bytes, 0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS,
g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
"Min. number of buffers in the queue to allow reading (0=disable)", "Min. number of buffers in the queue to allow reading (0=disable)",
0, G_MAXUINT, 0, G_PARAM_READWRITE)); 0, G_MAXUINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME, g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME,
g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
"Min. amount of data in the queue to allow reading (in ns, 0=disable)", "Min. amount of data in the queue to allow reading (in ns, 0=disable)",
0, G_MAXUINT64, 0, G_PARAM_READWRITE)); 0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_LEAKY, g_object_class_install_property (gobject_class, ARG_LEAKY,
g_param_spec_enum ("leaky", "Leaky", g_param_spec_enum ("leaky", "Leaky",
"Where the queue leaks, if at all", "Where the queue leaks, if at all",
GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK, g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK,
g_param_spec_boolean ("may_deadlock", "May Deadlock", g_param_spec_boolean ("may_deadlock", "May Deadlock",
"The queue may deadlock if it's full and not PLAYING", "The queue may deadlock if it's full and not PLAYING",
TRUE, G_PARAM_READWRITE)); TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT, g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT,
g_param_spec_uint64 ("block_timeout", "Timeout for Block", g_param_spec_uint64 ("block_timeout", "Timeout for Block",
"Nanoseconds until blocked queue times out and returns filler event. " "Nanoseconds until blocked queue times out and returns filler event. "
"Value of -1 disables timeout", "Value of -1 disables timeout",
0, G_MAXUINT64, -1, G_PARAM_READWRITE)); 0, G_MAXUINT64, -1, G_PARAM_READWRITE));
/* set several parent class virtual functions */ /* set several parent class virtual functions */
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose);
@ -261,15 +263,15 @@ gst_queue_init (GstQueue * queue)
GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
gst_pad_set_active (queue->srcpad, TRUE); gst_pad_set_active (queue->srcpad, TRUE);
queue->cur_level.buffers = 0; /* no content */ queue->cur_level.buffers = 0; /* no content */
queue->cur_level.bytes = 0; /* no content */ queue->cur_level.bytes = 0; /* no content */
queue->cur_level.time = 0; /* no content */ queue->cur_level.time = 0; /* no content */
queue->max_size.buffers = 100; /* 100 buffers */ queue->max_size.buffers = 100; /* 100 buffers */
queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
queue->max_size.time = GST_SECOND; /* 1 s. */ queue->max_size.time = GST_SECOND; /* 1 s. */
queue->min_threshold.buffers = 0; /* no threshold */ queue->min_threshold.buffers = 0; /* no threshold */
queue->min_threshold.bytes = 0; /* no threshold */ queue->min_threshold.bytes = 0; /* no threshold */
queue->min_threshold.time = 0; /* no threshold */ queue->min_threshold.time = 0; /* no threshold */
queue->leaky = GST_QUEUE_NO_LEAK; queue->leaky = GST_QUEUE_NO_LEAK;
queue->may_deadlock = TRUE; queue->may_deadlock = TRUE;
@ -437,163 +439,163 @@ restart:
if (GST_IS_EVENT (data)) { if (GST_IS_EVENT (data)) {
switch (GST_EVENT_TYPE (data)) { switch (GST_EVENT_TYPE (data)) {
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
STATUS (queue, "received flush event"); STATUS (queue, "received flush event");
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
STATUS (queue, "after flush"); STATUS (queue, "after flush");
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
STATUS (queue, "received EOS"); STATUS (queue, "received EOS");
break; break;
default: default:
/* we put the event in the queue, we don't have to act ourselves */ /* we put the event in the queue, we don't have to act ourselves */
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding event %p of type %d", data, GST_EVENT_TYPE (data)); "adding event %p of type %d", data, GST_EVENT_TYPE (data));
break; break;
} }
} }
if (GST_IS_BUFFER (data)) if (GST_IS_BUFFER (data))
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding buffer %p of size %d", data, GST_BUFFER_SIZE (data)); "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
/* We make space available if we're "full" according to whatever /* We make space available if we're "full" according to whatever
* the user defined as "full". Note that this only applies to buffers. * the user defined as "full". Note that this only applies to buffers.
* We always handle events and they don't count in our statistics. */ * We always handle events and they don't count in our statistics. */
if (GST_IS_BUFFER (data) && if (GST_IS_BUFFER (data) &&
((queue->max_size.buffers > 0 && ((queue->max_size.buffers > 0 &&
queue->cur_level.buffers >= queue->max_size.buffers) || queue->cur_level.buffers >= queue->max_size.buffers) ||
(queue->max_size.bytes > 0 && (queue->max_size.bytes > 0 &&
queue->cur_level.bytes >= queue->max_size.bytes) || queue->cur_level.bytes >= queue->max_size.bytes) ||
(queue->max_size.time > 0 && (queue->max_size.time > 0 &&
queue->cur_level.time >= queue->max_size.time))) { queue->cur_level.time >= queue->max_size.time))) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
/* how are we going to make space for this buffer? */ /* how are we going to make space for this buffer? */
switch (queue->leaky) { switch (queue->leaky) {
/* leak current buffer */ /* leak current buffer */
case GST_QUEUE_LEAK_UPSTREAM: case GST_QUEUE_LEAK_UPSTREAM:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue is full, leaking buffer on upstream end"); "queue is full, leaking buffer on upstream end");
/* now we can clean up and exit right away */ /* now we can clean up and exit right away */
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
goto out_unref; goto out_unref;
/* leak first buffer in the queue */ /* leak first buffer in the queue */
case GST_QUEUE_LEAK_DOWNSTREAM:{ case GST_QUEUE_LEAK_DOWNSTREAM:{
/* this is a bit hacky. We'll manually iterate the list /* this is a bit hacky. We'll manually iterate the list
* and find the first buffer from the head on. We'll * and find the first buffer from the head on. We'll
* unref that and "fix up" the GQueue object... */ * unref that and "fix up" the GQueue object... */
GList *item; GList *item;
GstData *leak = NULL; GstData *leak = NULL;
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue is full, leaking buffer on downstream end"); "queue is full, leaking buffer on downstream end");
for (item = queue->queue->head; item != NULL; item = item->next) { for (item = queue->queue->head; item != NULL; item = item->next) {
if (GST_IS_BUFFER (item->data)) { if (GST_IS_BUFFER (item->data)) {
leak = item->data; leak = item->data;
break; break;
} }
} }
/* if we didn't find anything, it means we have no buffers /* if we didn't find anything, it means we have no buffers
* in here. That cannot happen, since we had >= 1 bufs */ * in here. That cannot happen, since we had >= 1 bufs */
g_assert (leak); g_assert (leak);
/* Now remove it from the list, fixing up the GQueue /* Now remove it from the list, fixing up the GQueue
* CHECKME: is a queue->head the first or the last item? */ * CHECKME: is a queue->head the first or the last item? */
item = g_list_delete_link (queue->queue->head, item); item = g_list_delete_link (queue->queue->head, item);
queue->queue->head = g_list_first (item); queue->queue->head = g_list_first (item);
queue->queue->tail = g_list_last (item); queue->queue->tail = g_list_last (item);
queue->queue->length--; queue->queue->length--;
/* and unref the data at the end. Twice, because we keep a ref /* and unref the data at the end. Twice, because we keep a ref
* to make things read-only. Also keep our list uptodate. */ * to make things read-only. Also keep our list uptodate. */
queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
queue->cur_level.buffers--; queue->cur_level.buffers--;
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time -= GST_BUFFER_DURATION (data); queue->cur_level.time -= GST_BUFFER_DURATION (data);
gst_data_unref (data); gst_data_unref (data);
gst_data_unref (data); gst_data_unref (data);
break; break;
} }
default: default:
g_warning ("Unknown leaky type, using default"); g_warning ("Unknown leaky type, using default");
/* fall-through */ /* fall-through */
/* don't leak. Instead, wait for space to be available */ /* don't leak. Instead, wait for space to be available */
case GST_QUEUE_NO_LEAK: case GST_QUEUE_NO_LEAK:
STATUS (queue, "pre-full wait"); STATUS (queue, "pre-full wait");
while ((queue->max_size.buffers > 0 && while ((queue->max_size.buffers > 0 &&
queue->cur_level.buffers >= queue->max_size.buffers) || queue->cur_level.buffers >= queue->max_size.buffers) ||
(queue->max_size.bytes > 0 && (queue->max_size.bytes > 0 &&
queue->cur_level.bytes >= queue->max_size.bytes) || queue->cur_level.bytes >= queue->max_size.bytes) ||
(queue->max_size.time > 0 && (queue->max_size.time > 0 &&
queue->cur_level.time >= queue->max_size.time)) { queue->cur_level.time >= queue->max_size.time)) {
/* if there's a pending state change for this queue /* if there's a pending state change for this queue
* or its manager, switch back to iterator so bottom * or its manager, switch back to iterator so bottom
* half of state change executes */ * half of state change executes */
if (queue->interrupt) { if (queue->interrupt) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
GST_ELEMENT (queue))) { GST_ELEMENT (queue))) {
goto out_unref; goto out_unref;
} }
/* if we got here because we were unlocked after a /* if we got here because we were unlocked after a
* flush, we don't need to add the buffer to the * flush, we don't need to add the buffer to the
* queue again */ * queue again */
if (queue->flush) { if (queue->flush) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"not adding pending buffer after flush"); "not adding pending buffer after flush");
goto out_unref; goto out_unref;
} }
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"adding pending buffer after interrupt"); "adding pending buffer after interrupt");
goto restart; goto restart;
} }
if (GST_STATE (queue) != GST_STATE_PLAYING) { if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down. Try to /* this means the other end is shut down. Try to
* signal to resolve the error */ * signal to resolve the error */
if (!queue->may_deadlock) { if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
gst_data_unref (data); gst_data_unref (data);
GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
("deadlock found, shutting down source pad elements")); ("deadlock found, shutting down source pad elements"));
/* we don't go to out_unref here, since we want to /* we don't go to out_unref here, since we want to
* unref the buffer *before* calling GST_ELEMENT_ERROR */ * unref the buffer *before* calling GST_ELEMENT_ERROR */
return; return;
} else { } else {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"%s: waiting for the app to restart " "%s: waiting for the app to restart "
"source pad elements", GST_ELEMENT_NAME (queue)); "source pad elements", GST_ELEMENT_NAME (queue));
} }
} }
/* OK, we've got a serious issue here. Imagine the situation /* OK, we've got a serious issue here. Imagine the situation
* where the puller (next element) is sending an event here, * where the puller (next element) is sending an event here,
* so it cannot pull events from the queue, and we cannot * so it cannot pull events from the queue, and we cannot
* push data further because the queue is 'full' and therefore, * push data further because the queue is 'full' and therefore,
* we wait here (and do not handle events): deadlock! to solve * we wait here (and do not handle events): deadlock! to solve
* that, we handle pending upstream events here, too. */ * that, we handle pending upstream events here, too. */
gst_queue_handle_pending_events (queue); gst_queue_handle_pending_events (queue);
STATUS (queue, "waiting for item_del signal"); STATUS (queue, "waiting for item_del signal");
g_cond_wait (queue->item_del, queue->qlock); g_cond_wait (queue->item_del, queue->qlock);
STATUS (queue, "received item_del signal"); STATUS (queue, "received item_del signal");
} }
STATUS (queue, "post-full wait"); STATUS (queue, "post-full wait");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
break; break;
} }
} }
@ -645,63 +647,63 @@ restart:
if (queue->queue->length == 0 || if (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 && (queue->min_threshold.buffers > 0 &&
queue->cur_level.buffers < queue->min_threshold.buffers) || queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 && (queue->min_threshold.bytes > 0 &&
queue->cur_level.bytes < queue->min_threshold.bytes) || queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 && (queue->min_threshold.time > 0 &&
queue->cur_level.time < queue->min_threshold.time)) { queue->cur_level.time < queue->min_threshold.time)) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
g_mutex_lock (queue->qlock); g_mutex_lock (queue->qlock);
STATUS (queue, "pre-empty wait"); STATUS (queue, "pre-empty wait");
while (queue->queue->length == 0 || while (queue->queue->length == 0 ||
(queue->min_threshold.buffers > 0 && (queue->min_threshold.buffers > 0 &&
queue->cur_level.buffers < queue->min_threshold.buffers) || queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 && (queue->min_threshold.bytes > 0 &&
queue->cur_level.bytes < queue->min_threshold.bytes) || queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 && (queue->min_threshold.time > 0 &&
queue->cur_level.time < queue->min_threshold.time)) { queue->cur_level.time < queue->min_threshold.time)) {
/* if there's a pending state change for this queue or its /* if there's a pending state change for this queue or its
* manager, switch back to iterator so bottom half of state * manager, switch back to iterator so bottom half of state
* change executes. */ * change executes. */
if (queue->interrupt) { if (queue->interrupt) {
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted");
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad),
GST_ELEMENT (queue))) GST_ELEMENT (queue)))
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
goto restart; goto restart;
} }
if (GST_STATE (queue) != GST_STATE_PLAYING) { if (GST_STATE (queue) != GST_STATE_PLAYING) {
/* this means the other end is shut down */ /* this means the other end is shut down */
if (!queue->may_deadlock) { if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL),
("deadlock found, shutting down sink pad elements")); ("deadlock found, shutting down sink pad elements"));
goto restart; goto restart;
} else { } else {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"%s: waiting for the app to restart " "%s: waiting for the app to restart "
"source pad elements", GST_ELEMENT_NAME (queue)); "source pad elements", GST_ELEMENT_NAME (queue));
} }
} }
STATUS (queue, "waiting for item_add"); STATUS (queue, "waiting for item_add");
if (queue->block_timeout != GST_CLOCK_TIME_NONE) { if (queue->block_timeout != GST_CLOCK_TIME_NONE) {
GTimeVal timeout; GTimeVal timeout;
g_get_current_time (&timeout); g_get_current_time (&timeout);
g_time_val_add (&timeout, queue->block_timeout / 1000); g_time_val_add (&timeout, queue->block_timeout / 1000);
if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) { if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) {
g_mutex_unlock (queue->qlock); g_mutex_unlock (queue->qlock);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"Sending filler event"); "Sending filler event");
return GST_DATA (gst_event_new_filler ()); return GST_DATA (gst_event_new_filler ());
} }
} else { } else {
g_cond_wait (queue->item_add, queue->qlock); g_cond_wait (queue->item_add, queue->qlock);
} }
STATUS (queue, "got item_add signal"); STATUS (queue, "got item_add signal");
} }
@ -746,12 +748,12 @@ restart:
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"queue \"%s\" eos", GST_ELEMENT_NAME (queue)); "queue \"%s\" eos", GST_ELEMENT_NAME (queue));
gst_element_set_eos (GST_ELEMENT (queue)); gst_element_set_eos (GST_ELEMENT (queue));
break; break;
default: default:
break; break;
} }
} }
@ -775,26 +777,26 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
er.handled = FALSE; er.handled = FALSE;
g_queue_push_tail (queue->events, &er); g_queue_push_tail (queue->events, &er);
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"Preparing for loop for event handler"); "Preparing for loop for event handler");
/* see the chain function on why this is here - it prevents a deadlock */ /* see the chain function on why this is here - it prevents a deadlock */
g_cond_signal (queue->item_del); g_cond_signal (queue->item_del);
while (!er.handled) { while (!er.handled) {
GTimeVal timeout; GTimeVal timeout;
g_get_current_time (&timeout); g_get_current_time (&timeout);
g_time_val_add (&timeout, 500 * 1000); /* half a second */ g_time_val_add (&timeout, 500 * 1000); /* half a second */
if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) && if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) &&
!er.handled) { !er.handled) {
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue,
"timeout in upstream event handling"); "timeout in upstream event handling");
/* remove ourselves from the pending list. Since we're /* remove ourselves from the pending list. Since we're
* locked, others cannot reference this anymore. */ * locked, others cannot reference this anymore. */
queue->queue->head = g_list_remove (queue->queue->head, &er); queue->queue->head = g_list_remove (queue->queue->head, &er);
queue->queue->head = g_list_first (queue->queue->head); queue->queue->head = g_list_first (queue->queue->head);
queue->queue->tail = g_list_last (queue->queue->head); queue->queue->tail = g_list_last (queue->queue->head);
queue->queue->length--; queue->queue->length--;
res = FALSE; res = FALSE;
goto handled; goto handled;
} }
} }
GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled"); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled");
@ -804,16 +806,16 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH:
GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue,
"FLUSH event, flushing queue\n"); "FLUSH event, flushing queue\n");
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
break; break;
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
} }
default: default:
break; break;
} }
} }
handled: handled:
@ -859,30 +861,30 @@ gst_queue_change_state (GstElement * element)
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
if (!GST_PAD_IS_LINKED (queue->sinkpad)) { if (!GST_PAD_IS_LINKED (queue->sinkpad)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
"queue %s is not linked", GST_ELEMENT_NAME (queue)); "queue %s is not linked", GST_ELEMENT_NAME (queue));
/* FIXME can this be? */ /* FIXME can this be? */
g_cond_signal (queue->item_add); g_cond_signal (queue->item_add);
ret = GST_STATE_FAILURE; ret = GST_STATE_FAILURE;
goto error; goto error;
} else { } else {
GstScheduler *src_sched, *sink_sched; GstScheduler *src_sched, *sink_sched;
src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad));
sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad));
if (src_sched == sink_sched) { if (src_sched == sink_sched) {
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue,
"queue %s does not connect different schedulers", "queue %s does not connect different schedulers",
GST_ELEMENT_NAME (queue)); GST_ELEMENT_NAME (queue));
g_warning ("queue %s does not connect different schedulers", g_warning ("queue %s does not connect different schedulers",
GST_ELEMENT_NAME (queue)); GST_ELEMENT_NAME (queue));
ret = GST_STATE_FAILURE; ret = GST_STATE_FAILURE;
goto error; goto error;
} }
} }
queue->interrupt = FALSE; queue->interrupt = FALSE;
break; break;

View file

@ -58,7 +58,8 @@ typedef struct
GstPad *sinkpad; GstPad *sinkpad;
GstPad *srcpad; GstPad *srcpad;
GstBuffer *buffer; GstBuffer *buffer;
} GstShaperConnection; }
GstShaperConnection;
GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
GST_PAD_SRC, GST_PAD_SRC,
@ -80,9 +81,10 @@ gst_shaper_policy_get_type (void)
{SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!shaper_policy_type) { if (!shaper_policy_type) {
shaper_policy_type = shaper_policy_type =
g_enum_register_static ("GstShaperPolicy", shaper_policy); g_enum_register_static ("GstShaperPolicy", shaper_policy);
} }
return shaper_policy_type; return shaper_policy_type;
} }
@ -128,13 +130,13 @@ gst_shaper_class_init (GstShaperClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY,
g_param_spec_enum ("policy", "Policy", "Shaper policy", g_param_spec_enum ("policy", "Policy", "Shaper policy",
GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "last-message", g_param_spec_string ("last-message", "last-message", "last-message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property);
@ -279,30 +281,30 @@ gst_shaper_loop (GstElement * element)
/* events are simply pushed ASAP */ /* events are simply pushed ASAP */
if (GST_IS_EVENT (buffer)) { if (GST_IS_EVENT (buffer)) {
/* save event type as it will be unreffed after the next push */ /* save event type as it will be unreffed after the next push */
GstEventType type = GST_EVENT_TYPE (buffer); GstEventType type = GST_EVENT_TYPE (buffer);
gst_pad_push (connection->srcpad, GST_DATA (buffer)); gst_pad_push (connection->srcpad, GST_DATA (buffer));
switch (type) { switch (type) {
/* on EOS we disable the pad so that we don't pull on /* on EOS we disable the pad so that we don't pull on
* it again and never get more data */ * it again and never get more data */
case GST_EVENT_EOS: case GST_EVENT_EOS:
gst_pad_set_active (connection->sinkpad, FALSE); gst_pad_set_active (connection->sinkpad, FALSE);
break; break;
default: default:
break; break;
} }
} else { } else {
/* we store the buffer */ /* we store the buffer */
connection->buffer = buffer; connection->buffer = buffer;
} }
} }
/* FIXME policy stuff goes here */ /* FIXME policy stuff goes here */
/* find connection with lowest timestamp */ /* find connection with lowest timestamp */
if (min == NULL || (connection->buffer != NULL && if (min == NULL || (connection->buffer != NULL &&
(GST_BUFFER_TIMESTAMP (connection->buffer) < (GST_BUFFER_TIMESTAMP (connection->buffer) <
GST_BUFFER_TIMESTAMP (min->buffer)))) { GST_BUFFER_TIMESTAMP (min->buffer)))) {
min = connection; min = connection;
} }
connections = g_slist_next (connections); connections = g_slist_next (connections);

View file

@ -95,34 +95,34 @@ gst_statistics_class_init (GstStatisticsClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS,
g_param_spec_int64 ("buffers", "buffers", "total buffers count", g_param_spec_int64 ("buffers", "buffers", "total buffers count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES,
g_param_spec_int64 ("bytes", "bytes", "total bytes count", g_param_spec_int64 ("bytes", "bytes", "total bytes count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS,
g_param_spec_int64 ("events", "events", "total event count", g_param_spec_int64 ("events", "events", "total event count",
0, G_MAXINT64, 0, G_PARAM_READABLE)); 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq", ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq",
"buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0, "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq", ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq",
"bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0, "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq", ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq",
"event update freq", "event update frequency", 0, G_MAXINT64, 0, "event update freq", "event update frequency", 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS,
g_param_spec_boolean ("update_on_eos", "update on EOS", g_param_spec_boolean ("update_on_eos", "update on EOS",
"update on EOS event", TRUE, G_PARAM_READWRITE)); "update on EOS event", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE,
g_param_spec_boolean ("update", "update", "update", TRUE, g_param_spec_boolean ("update", "update", "update", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", TRUE, g_param_spec_boolean ("silent", "silent", "silent", TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gst_statistics_signals[SIGNAL_UPDATE] = gst_statistics_signals[SIGNAL_UPDATE] =
g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -253,14 +253,14 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
gst_element_set_eos (GST_ELEMENT (statistics)); gst_element_set_eos (GST_ELEMENT (statistics));
if (statistics->update_on_eos) { if (statistics->update_on_eos) {
update = TRUE; update = TRUE;
} }
} }
if (statistics->update_freq.events) { if (statistics->update_freq.events) {
statistics->update_count.events += 1; statistics->update_count.events += 1;
if (statistics->update_count.events == statistics->update_freq.events) { if (statistics->update_count.events == statistics->update_freq.events) {
statistics->update_count.events = 0; statistics->update_count.events = 0;
update = TRUE; update = TRUE;
} }
} }
} else { } else {
@ -268,8 +268,8 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update_freq.buffers) { if (statistics->update_freq.buffers) {
statistics->update_count.buffers += 1; statistics->update_count.buffers += 1;
if (statistics->update_count.buffers == statistics->update_freq.buffers) { if (statistics->update_count.buffers == statistics->update_freq.buffers) {
statistics->update_count.buffers = 0; statistics->update_count.buffers = 0;
update = TRUE; update = TRUE;
} }
} }
@ -277,8 +277,8 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update_freq.bytes) { if (statistics->update_freq.bytes) {
statistics->update_count.bytes += GST_BUFFER_SIZE (buf); statistics->update_count.bytes += GST_BUFFER_SIZE (buf);
if (statistics->update_count.bytes >= statistics->update_freq.bytes) { if (statistics->update_count.bytes >= statistics->update_freq.bytes) {
statistics->update_count.bytes = 0; statistics->update_count.bytes = 0;
update = TRUE; update = TRUE;
} }
} }
} }
@ -287,7 +287,7 @@ gst_statistics_chain (GstPad * pad, GstData * _data)
if (statistics->update) { if (statistics->update) {
GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics)); GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics));
g_signal_emit (G_OBJECT (statistics), g_signal_emit (G_OBJECT (statistics),
gst_statistics_signals[SIGNAL_UPDATE], 0); gst_statistics_signals[SIGNAL_UPDATE], 0);
GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics)); GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics));
} }
if (!statistics->silent) { if (!statistics->silent) {

View file

@ -95,13 +95,13 @@ gst_tee_class_init (GstTeeClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "num_pads", "num_pads", g_param_spec_int ("num_pads", "num_pads", "num_pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "last_message", "last_message", g_param_spec_string ("last_message", "last_message", "last_message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
@ -134,7 +134,7 @@ name_pad_compare (gconstpointer a, gconstpointer b)
g_assert (GST_IS_PAD (pad)); g_assert (GST_IS_PAD (pad));
return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */
} }
static GstPad * static GstPad *
@ -163,7 +163,7 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
while (!name) { while (!name) {
name = g_strdup_printf ("src%d", i); name = g_strdup_printf ("src%d", i);
if (g_list_find_custom ((GList *) pads, (gconstpointer) name, if (g_list_find_custom ((GList *) pads, (gconstpointer) name,
name_pad_compare) != NULL) { name_pad_compare) != NULL) {
/* this name is taken, use the next one */ /* this name is taken, use the next one */
++i; ++i;
g_free (name); g_free (name);
@ -276,9 +276,9 @@ gst_tee_chain (GstPad * pad, GstData * _data)
if (!tee->silent) { if (!tee->silent) {
g_free (tee->last_message); g_free (tee->last_message);
tee->last_message = tee->last_message =
g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %"
G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad), G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad),
GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf);
g_object_notify (G_OBJECT (tee), "last_message"); g_object_notify (G_OBJECT (tee), "last_message");
} }

Some files were not shown because too many files have changed in this diff Show more