mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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:
parent
0062e168ca
commit
74598fdf6c
14 changed files with 76 additions and 43 deletions
|
@ -296,8 +296,8 @@ gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size)
|
||||||
} else
|
} else
|
||||||
GST_BUFFER_SIZE (buf) = size;
|
GST_BUFFER_SIZE (buf) = size;
|
||||||
|
|
||||||
/* we're done, push the buffer off now */
|
/* we're done, return the buffer off now */
|
||||||
gst_pad_push (pad,buf);
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -206,30 +206,30 @@ gst_disksrc_get (GstPad *pad)
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
glong readbytes;
|
glong readbytes;
|
||||||
|
|
||||||
g_return_if_fail (pad != NULL);
|
g_return_val_if_fail (pad != NULL, NULL);
|
||||||
src = GST_DISKSRC(gst_pad_get_parent(pad));
|
src = GST_DISKSRC(gst_pad_get_parent(pad));
|
||||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN));
|
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
|
||||||
g_return_if_fail (GST_STATE (src) >= GST_STATE_READY);
|
g_return_val_if_fail (GST_STATE (src) >= GST_STATE_READY, NULL);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
// FIXME: should eventually use a bufferpool for this
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
g_return_if_fail (buf);
|
g_return_val_if_fail (buf, NULL);
|
||||||
|
|
||||||
/* allocate the space for the buffer data */
|
/* allocate the space for the buffer data */
|
||||||
GST_BUFFER_DATA (buf) = g_malloc (src->bytes_per_read);
|
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 */
|
/* read it in from the file */
|
||||||
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
|
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
|
||||||
if (readbytes == -1) {
|
if (readbytes == -1) {
|
||||||
perror ("read()");
|
perror ("read()");
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return NULL;
|
||||||
} else if (readbytes == 0) {
|
} else if (readbytes == 0) {
|
||||||
gst_src_signal_eos (GST_SRC (src));
|
gst_src_signal_eos (GST_SRC (src));
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||||
|
|
|
@ -138,7 +138,7 @@ gst_fakesrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||||
gst_pad_set_get_function(pad,gst_fakesrc_get);
|
gst_pad_set_get_function(pad,gst_fakesrc_get);
|
||||||
gst_element_add_pad(GST_ELEMENT(src),pad);
|
gst_element_add_pad(GST_ELEMENT(src),pad);
|
||||||
src->srcpads = g_slist_append(src->srcpads,pad);
|
src->srcpads = g_slist_append(src->srcpads,pad);
|
||||||
src->numsrcpads;
|
src->numsrcpads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -132,9 +132,12 @@ gst_identity_loop (GstElement *element)
|
||||||
|
|
||||||
identity = GST_IDENTITY (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
|
static void
|
||||||
|
|
19
gst/gstbin.c
19
gst/gstbin.c
|
@ -17,7 +17,7 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define GST_DEBUG_ENABLED
|
#define GST_DEBUG_ENABLED
|
||||||
|
|
||||||
#include "gstbin.h"
|
#include "gstbin.h"
|
||||||
#include "gstdebug.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)));
|
// g_print("<-- \"%s\"\n",gst_object_get_name(GST_OBJECT(bin)));
|
||||||
|
|
||||||
if (GST_STATE_PENDING (element) == GST_STATE_READY) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
GstObject *parent;
|
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))
|
if (!parent || !GST_IS_BIN (parent))
|
||||||
gst_bin_create_plan (bin);
|
gst_bin_create_plan (bin);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gst_bin_change_state_norecurse (bin);
|
return gst_bin_change_state_norecurse (bin);
|
||||||
|
|
|
@ -619,14 +619,14 @@ gst_element_load_thyself (xmlNodePtr parent,
|
||||||
}
|
}
|
||||||
children = children->next;
|
children = children->next;
|
||||||
}
|
}
|
||||||
g_assert (name != NULL);
|
g_return_val_if_fail (name != NULL, NULL);
|
||||||
g_assert (type != NULL);
|
g_return_val_if_fail (type != NULL, NULL);
|
||||||
|
|
||||||
g_print ("gstelement: loading \"%s\" of type \"%s\"\n", name, type);
|
g_print ("gstelement: loading \"%s\" of type \"%s\"\n", name, type);
|
||||||
|
|
||||||
element = gst_elementfactory_make (type, name);
|
element = gst_elementfactory_make (type, name);
|
||||||
|
|
||||||
g_assert (element != NULL);
|
g_return_val_if_fail (element != NULL, NULL);
|
||||||
|
|
||||||
g_hash_table_insert (elements, g_strdup (gst_element_get_name (element)), element);
|
g_hash_table_insert (elements, g_strdup (gst_element_get_name (element)), element);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,14 @@ static inline char *_gst_print_statename(int state) {
|
||||||
#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
|
#define GST_STATE(obj) (GST_ELEMENT(obj)->current_state)
|
||||||
#define GST_STATE_PENDING(obj) (GST_ELEMENT(obj)->pending_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 \
|
#define GST_TYPE_ELEMENT \
|
||||||
(gst_element_get_type())
|
(gst_element_get_type())
|
||||||
#define GST_ELEMENT(obj) \
|
#define GST_ELEMENT(obj) \
|
||||||
|
|
|
@ -63,6 +63,8 @@ gst_elementfactory_find (gchar *name)
|
||||||
GList *walk;
|
GList *walk;
|
||||||
GstElementFactory *factory;
|
GstElementFactory *factory;
|
||||||
|
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
DEBUG("gstelementfactory: find \"%s\"\n", name);
|
DEBUG("gstelementfactory: find \"%s\"\n", name);
|
||||||
|
|
||||||
walk = _gst_elementfactories;
|
walk = _gst_elementfactories;
|
||||||
|
@ -107,6 +109,8 @@ gst_elementfactory_new (gchar *name, GtkType type,
|
||||||
{
|
{
|
||||||
GstElementFactory *factory = g_new0(GstElementFactory, 1);
|
GstElementFactory *factory = g_new0(GstElementFactory, 1);
|
||||||
|
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
factory->name = g_strdup(name);
|
factory->name = g_strdup(name);
|
||||||
factory->type = type;
|
factory->type = type;
|
||||||
factory->details = details;
|
factory->details = details;
|
||||||
|
@ -136,6 +140,7 @@ gst_elementfactory_create (GstElementFactory *factory,
|
||||||
GstElementClass *oclass;
|
GstElementClass *oclass;
|
||||||
|
|
||||||
g_return_val_if_fail(factory != NULL, NULL);
|
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);
|
DEBUG("gstelementfactory: create \"%s\" \"%s\"\n", factory->name, name);
|
||||||
|
|
||||||
|
@ -180,6 +185,9 @@ gst_elementfactory_make (gchar *factoryname, gchar *name)
|
||||||
GstElementFactory *factory;
|
GstElementFactory *factory;
|
||||||
GstElement *element;
|
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);
|
DEBUG("gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name);
|
||||||
|
|
||||||
//gst_plugin_load_elementfactory(factoryname);
|
//gst_plugin_load_elementfactory(factoryname);
|
||||||
|
@ -269,6 +277,8 @@ gst_elementfactory_save_thyself (GstElementFactory *factory,
|
||||||
{
|
{
|
||||||
GList *pads;
|
GList *pads;
|
||||||
|
|
||||||
|
g_return_val_if_fail(factory != NULL, NULL);
|
||||||
|
|
||||||
xmlNewChild(parent,NULL,"name",factory->name);
|
xmlNewChild(parent,NULL,"name",factory->name);
|
||||||
xmlNewChild(parent,NULL,"longname", factory->details->longname);
|
xmlNewChild(parent,NULL,"longname", factory->details->longname);
|
||||||
xmlNewChild(parent,NULL,"class", factory->details->klass);
|
xmlNewChild(parent,NULL,"class", factory->details->klass);
|
||||||
|
|
|
@ -486,8 +486,8 @@ gst_pipeline_change_state (GstElement *element)
|
||||||
|
|
||||||
pipeline = GST_PIPELINE (element);
|
pipeline = GST_PIPELINE (element);
|
||||||
|
|
||||||
switch (GST_STATE_PENDING (pipeline)) {
|
switch (GST_STATE_TRANSITION (pipeline)) {
|
||||||
case GST_STATE_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
// we need to set up internal state
|
// we need to set up internal state
|
||||||
gst_pipeline_prepare (pipeline);
|
gst_pipeline_prepare (pipeline);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -200,7 +200,7 @@ gst_thread_change_state (GstElement *element)
|
||||||
{
|
{
|
||||||
GstThread *thread;
|
GstThread *thread;
|
||||||
gboolean stateset = GST_STATE_SUCCESS;
|
gboolean stateset = GST_STATE_SUCCESS;
|
||||||
gint pending;
|
gint pending, transition;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_THREAD(element), FALSE);
|
g_return_val_if_fail (GST_IS_THREAD(element), FALSE);
|
||||||
DEBUG_ENTER("(\"%s\")",gst_element_get_name(element));
|
DEBUG_ENTER("(\"%s\")",gst_element_get_name(element));
|
||||||
|
@ -212,6 +212,7 @@ gst_thread_change_state (GstElement *element)
|
||||||
GST_STATE_PENDING (element));
|
GST_STATE_PENDING (element));
|
||||||
|
|
||||||
pending = GST_STATE_PENDING (element);
|
pending = GST_STATE_PENDING (element);
|
||||||
|
transition = GST_STATE_TRANSITION (element);
|
||||||
|
|
||||||
if (pending == GST_STATE (element)) return GST_STATE_SUCCESS;
|
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)
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||||
stateset = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
stateset = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||||
|
|
||||||
gst_info("gstthread: stateset %d %d %d\n", GST_STATE (element), stateset,
|
gst_info("gstthread: stateset %d %d %d %02x\n", GST_STATE (element), stateset,
|
||||||
GST_STATE_PENDING (element));
|
GST_STATE_PENDING (element), GST_STATE_TRANSITION (element));
|
||||||
|
|
||||||
switch (pending) {
|
switch (transition) {
|
||||||
case GST_STATE_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
if (!stateset) return FALSE;
|
if (!stateset) return FALSE;
|
||||||
// we want to prepare our internal state for doing the iterations
|
// we want to prepare our internal state for doing the iterations
|
||||||
gst_info("gstthread: preparing thread \"%s\" for iterations:\n",
|
gst_info("gstthread: preparing thread \"%s\" for iterations:\n",
|
||||||
|
@ -247,7 +248,8 @@ gst_thread_change_state (GstElement *element)
|
||||||
}
|
}
|
||||||
return GST_STATE_ASYNC;
|
return GST_STATE_ASYNC;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
|
case GST_STATE_READY_TO_PLAYING:
|
||||||
if (!stateset) return FALSE;
|
if (!stateset) return FALSE;
|
||||||
gst_info("gstthread: starting thread \"%s\"\n",
|
gst_info("gstthread: starting thread \"%s\"\n",
|
||||||
gst_element_get_name (GST_ELEMENT (element)));
|
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_FLAG_SET (thread, GST_THREAD_STATE_SPINNING);
|
||||||
gst_thread_signal_thread (thread);
|
gst_thread_signal_thread (thread);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
gst_info("gstthread: pausing thread \"%s\"\n",
|
gst_info("gstthread: pausing thread \"%s\"\n",
|
||||||
gst_element_get_name (GST_ELEMENT (element)));
|
gst_element_get_name (GST_ELEMENT (element)));
|
||||||
|
|
||||||
//GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
|
//GST_FLAG_UNSET(thread,GST_THREAD_STATE_SPINNING);
|
||||||
gst_thread_signal_thread (thread);
|
gst_thread_signal_thread (thread);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
gst_info("gstthread: stopping thread \"%s\"\n",
|
gst_info("gstthread: stopping thread \"%s\"\n",
|
||||||
gst_element_get_name (GST_ELEMENT (element)));
|
gst_element_get_name (GST_ELEMENT (element)));
|
||||||
|
|
||||||
|
|
|
@ -296,8 +296,8 @@ gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size)
|
||||||
} else
|
} else
|
||||||
GST_BUFFER_SIZE (buf) = size;
|
GST_BUFFER_SIZE (buf) = size;
|
||||||
|
|
||||||
/* we're done, push the buffer off now */
|
/* we're done, return the buffer off now */
|
||||||
gst_pad_push (pad,buf);
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -206,30 +206,30 @@ gst_disksrc_get (GstPad *pad)
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
glong readbytes;
|
glong readbytes;
|
||||||
|
|
||||||
g_return_if_fail (pad != NULL);
|
g_return_val_if_fail (pad != NULL, NULL);
|
||||||
src = GST_DISKSRC(gst_pad_get_parent(pad));
|
src = GST_DISKSRC(gst_pad_get_parent(pad));
|
||||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN));
|
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
|
||||||
g_return_if_fail (GST_STATE (src) >= GST_STATE_READY);
|
g_return_val_if_fail (GST_STATE (src) >= GST_STATE_READY, NULL);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
// FIXME: should eventually use a bufferpool for this
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
g_return_if_fail (buf);
|
g_return_val_if_fail (buf, NULL);
|
||||||
|
|
||||||
/* allocate the space for the buffer data */
|
/* allocate the space for the buffer data */
|
||||||
GST_BUFFER_DATA (buf) = g_malloc (src->bytes_per_read);
|
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 */
|
/* read it in from the file */
|
||||||
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
|
readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->bytes_per_read);
|
||||||
if (readbytes == -1) {
|
if (readbytes == -1) {
|
||||||
perror ("read()");
|
perror ("read()");
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return NULL;
|
||||||
} else if (readbytes == 0) {
|
} else if (readbytes == 0) {
|
||||||
gst_src_signal_eos (GST_SRC (src));
|
gst_src_signal_eos (GST_SRC (src));
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||||
|
|
|
@ -138,7 +138,7 @@ gst_fakesrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||||
gst_pad_set_get_function(pad,gst_fakesrc_get);
|
gst_pad_set_get_function(pad,gst_fakesrc_get);
|
||||||
gst_element_add_pad(GST_ELEMENT(src),pad);
|
gst_element_add_pad(GST_ELEMENT(src),pad);
|
||||||
src->srcpads = g_slist_append(src->srcpads,pad);
|
src->srcpads = g_slist_append(src->srcpads,pad);
|
||||||
src->numsrcpads;
|
src->numsrcpads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -132,9 +132,12 @@ gst_identity_loop (GstElement *element)
|
||||||
|
|
||||||
identity = GST_IDENTITY (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
|
static void
|
||||||
|
|
Loading…
Reference in a new issue