Added handoff signals to fakesrc and fakesink

Original commit message from CVS:
Added handoff signals to fakesrc and fakesink
Added scheduling property to identity
Added GST_STATE_TRANSITION macro to check for state changes.
Modified gstbin and gstthread to the new state change macros
This commit is contained in:
Wim Taymans 2000-12-23 03:17:52 +00:00
parent 0062e168ca
commit 74598fdf6c
14 changed files with 76 additions and 43 deletions

View file

@ -296,8 +296,8 @@ gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size)
} else
GST_BUFFER_SIZE (buf) = size;
/* we're done, push the buffer off now */
gst_pad_push (pad,buf);
/* we're done, return the buffer off now */
return buf;
}

View file

@ -206,30 +206,30 @@ gst_disksrc_get (GstPad *pad)
GstBuffer *buf;
glong readbytes;
g_return_if_fail (pad != NULL);
g_return_val_if_fail (pad != NULL, NULL);
src = GST_DISKSRC(gst_pad_get_parent(pad));
g_return_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN));
g_return_if_fail (GST_STATE (src) >= GST_STATE_READY);
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
g_return_val_if_fail (GST_STATE (src) >= GST_STATE_READY, NULL);
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
buf = gst_buffer_new ();
g_return_if_fail (buf);
g_return_val_if_fail (buf, NULL);
/* allocate the space for the buffer data */
GST_BUFFER_DATA (buf) = g_malloc (src->bytes_per_read);
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
/* read it in from the file */
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
if (readbytes == -1) {
perror ("read()");
gst_buffer_unref (buf);
return;
return NULL;
} else if (readbytes == 0) {
gst_src_signal_eos (GST_SRC (src));
gst_buffer_unref (buf);
return;
return NULL;
}
/* if we didn't get as many bytes as we asked for, we're at EOF */

View file

@ -138,7 +138,7 @@ gst_fakesrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
gst_pad_set_get_function(pad,gst_fakesrc_get);
gst_element_add_pad(GST_ELEMENT(src),pad);
src->srcpads = g_slist_append(src->srcpads,pad);
src->numsrcpads;
src->numsrcpads++;
}
}
break;

View file

@ -132,9 +132,12 @@ gst_identity_loop (GstElement *element)
identity = GST_IDENTITY (element);
buf = gst_pad_pull (identity->sinkpad);
do {
buf = gst_pad_pull (identity->sinkpad);
gst_pad_push (identity->srcpad, buf);
gst_pad_push (identity->srcpad, buf);
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
}
static void

View file

@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*/
//#define GST_DEBUG_ENABLED
#define GST_DEBUG_ENABLED
#include "gstbin.h"
#include "gstdebug.h"
@ -247,13 +247,20 @@ gst_bin_change_state (GstElement *element)
}
// g_print("<-- \"%s\"\n",gst_object_get_name(GST_OBJECT(bin)));
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
GstObject *parent;
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
{
GstObject *parent;
parent = gst_object_get_parent (GST_OBJECT (element));
parent = gst_object_get_parent (GST_OBJECT (element));
if (!parent || !GST_IS_BIN (parent))
gst_bin_create_plan (bin);
if (!parent || !GST_IS_BIN (parent))
gst_bin_create_plan (bin);
break;
}
default:
break;
}
return gst_bin_change_state_norecurse (bin);

View file

@ -619,14 +619,14 @@ gst_element_load_thyself (xmlNodePtr parent,
}
children = children->next;
}
g_assert (name != NULL);
g_assert (type != NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (type != NULL, NULL);
g_print ("gstelement: loading \"%s\" of type \"%s\"\n", name, type);
element = gst_elementfactory_make (type, name);
g_assert (element != NULL);
g_return_val_if_fail (element != NULL, NULL);
g_hash_table_insert (elements, g_strdup (gst_element_get_name (element)), element);

View file

@ -63,6 +63,14 @@ static inline char *_gst_print_statename(int state) {
#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
#define GST_STATE_PENDING(obj) (GST_ELEMENT(obj)->pending_state)
#define GST_STATE_TRANSITION(obj) ((GST_STATE(obj)<<4) | GST_STATE_PENDING(obj))
#define GST_STATE_NULL_TO_READY ((GST_STATE_NULL<<4) | GST_STATE_READY)
#define GST_STATE_READY_TO_PLAYING ((GST_STATE_READY<<4) | GST_STATE_PLAYING)
#define GST_STATE_PLAYING_TO_PAUSED ((GST_STATE_PLAYING<<4) | GST_STATE_PAUSED)
#define GST_STATE_PAUSED_TO_PLAYING ((GST_STATE_PAUSED<<4) | GST_STATE_PLAYING)
#define GST_STATE_PLAYING_TO_READY ((GST_STATE_PLAYING<<4) | GST_STATE_READY)
#define GST_STATE_READY_TO_NULL ((GST_STATE_READY<<4) | GST_STATE_NULL)
#define GST_TYPE_ELEMENT \
(gst_element_get_type())
#define GST_ELEMENT(obj) \

View file

@ -63,6 +63,8 @@ gst_elementfactory_find (gchar *name)
GList *walk;
GstElementFactory *factory;
g_return_val_if_fail(name != NULL, NULL);
DEBUG("gstelementfactory: find \"%s\"\n", name);
walk = _gst_elementfactories;
@ -107,6 +109,8 @@ gst_elementfactory_new (gchar *name, GtkType type,
{
GstElementFactory *factory = g_new0(GstElementFactory, 1);
g_return_val_if_fail(name != NULL, NULL);
factory->name = g_strdup(name);
factory->type = type;
factory->details = details;
@ -136,6 +140,7 @@ gst_elementfactory_create (GstElementFactory *factory,
GstElementClass *oclass;
g_return_val_if_fail(factory != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
DEBUG("gstelementfactory: create \"%s\" \"%s\"\n", factory->name, name);
@ -180,6 +185,9 @@ gst_elementfactory_make (gchar *factoryname, gchar *name)
GstElementFactory *factory;
GstElement *element;
g_return_val_if_fail(factoryname != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
DEBUG("gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name);
//gst_plugin_load_elementfactory(factoryname);
@ -269,6 +277,8 @@ gst_elementfactory_save_thyself (GstElementFactory *factory,
{
GList *pads;
g_return_val_if_fail(factory != NULL, NULL);
xmlNewChild(parent,NULL,"name",factory->name);
xmlNewChild(parent,NULL,"longname", factory->details->longname);
xmlNewChild(parent,NULL,"class", factory->details->klass);

View file

@ -486,8 +486,8 @@ gst_pipeline_change_state (GstElement *element)
pipeline = GST_PIPELINE (element);
switch (GST_STATE_PENDING (pipeline)) {
case GST_STATE_READY:
switch (GST_STATE_TRANSITION (pipeline)) {
case GST_STATE_NULL_TO_READY:
// we need to set up internal state
gst_pipeline_prepare (pipeline);
break;

View file

@ -200,7 +200,7 @@ gst_thread_change_state (GstElement *element)
{
GstThread *thread;
gboolean stateset = GST_STATE_SUCCESS;
gint pending;
gint pending, transition;
g_return_val_if_fail (GST_IS_THREAD(element), FALSE);
DEBUG_ENTER("(\"%s\")",gst_element_get_name(element));
@ -212,6 +212,7 @@ gst_thread_change_state (GstElement *element)
GST_STATE_PENDING (element));
pending = GST_STATE_PENDING (element);
transition = GST_STATE_TRANSITION (element);
if (pending == GST_STATE (element)) return GST_STATE_SUCCESS;
@ -220,11 +221,11 @@ gst_thread_change_state (GstElement *element)
if (GST_ELEMENT_CLASS (parent_class)->change_state)
stateset = GST_ELEMENT_CLASS (parent_class)->change_state (element);
gst_info("gstthread: stateset %d %d %d\n", GST_STATE (element), stateset,
GST_STATE_PENDING (element));
gst_info("gstthread: stateset %d %d %d %02x\n", GST_STATE (element), stateset,
GST_STATE_PENDING (element), GST_STATE_TRANSITION (element));
switch (pending) {
case GST_STATE_READY:
switch (transition) {
case GST_STATE_NULL_TO_READY:
if (!stateset) return FALSE;
// we want to prepare our internal state for doing the iterations
gst_info("gstthread: preparing thread \"%s\" for iterations:\n",
@ -247,7 +248,8 @@ gst_thread_change_state (GstElement *element)
}
return GST_STATE_ASYNC;
break;
case GST_STATE_PLAYING:
case GST_STATE_PAUSED_TO_PLAYING:
case GST_STATE_READY_TO_PLAYING:
if (!stateset) return FALSE;
gst_info("gstthread: starting thread \"%s\"\n",
gst_element_get_name (GST_ELEMENT (element)));
@ -255,14 +257,14 @@ gst_thread_change_state (GstElement *element)
GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
gst_thread_signal_thread (thread);
break;
case GST_STATE_PAUSED:
case GST_STATE_PLAYING_TO_PAUSED:
gst_info("gstthread: pausing thread \"%s\"\n",
gst_element_get_name (GST_ELEMENT (element)));
//GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
gst_thread_signal_thread (thread);
break;
case GST_STATE_NULL:
case GST_STATE_READY_TO_NULL:
gst_info("gstthread: stopping thread \"%s\"\n",
gst_element_get_name (GST_ELEMENT (element)));

View file

@ -296,8 +296,8 @@ gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size)
} else
GST_BUFFER_SIZE (buf) = size;
/* we're done, push the buffer off now */
gst_pad_push (pad,buf);
/* we're done, return the buffer off now */
return buf;
}

View file

@ -206,30 +206,30 @@ gst_disksrc_get (GstPad *pad)
GstBuffer *buf;
glong readbytes;
g_return_if_fail (pad != NULL);
g_return_val_if_fail (pad != NULL, NULL);
src = GST_DISKSRC(gst_pad_get_parent(pad));
g_return_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN));
g_return_if_fail (GST_STATE (src) >= GST_STATE_READY);
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
g_return_val_if_fail (GST_STATE (src) >= GST_STATE_READY, NULL);
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
buf = gst_buffer_new ();
g_return_if_fail (buf);
g_return_val_if_fail (buf, NULL);
/* allocate the space for the buffer data */
GST_BUFFER_DATA (buf) = g_malloc (src->bytes_per_read);
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
/* read it in from the file */
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
if (readbytes == -1) {
perror ("read()");
gst_buffer_unref (buf);
return;
return NULL;
} else if (readbytes == 0) {
gst_src_signal_eos (GST_SRC (src));
gst_buffer_unref (buf);
return;
return NULL;
}
/* if we didn't get as many bytes as we asked for, we're at EOF */

View file

@ -138,7 +138,7 @@ gst_fakesrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
gst_pad_set_get_function(pad,gst_fakesrc_get);
gst_element_add_pad(GST_ELEMENT(src),pad);
src->srcpads = g_slist_append(src->srcpads,pad);
src->numsrcpads;
src->numsrcpads++;
}
}
break;

View file

@ -132,9 +132,12 @@ gst_identity_loop (GstElement *element)
identity = GST_IDENTITY (element);
buf = gst_pad_pull (identity->sinkpad);
do {
buf = gst_pad_pull (identity->sinkpad);
gst_pad_push (identity->srcpad, buf);
gst_pad_push (identity->srcpad, buf);
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
}
static void