gst/elements/gstfilesrc.*: send NEW_MEDIA events correctly

Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get),
(gst_filesrc_change_state), (gst_filesrc_srcpad_event):
* gst/elements/gstfilesrc.h:
send NEW_MEDIA events correctly
* gst/elements/gsttypefindelement.c: (start_typefinding),
(gst_type_find_element_handle_event):
restart typefinding when we get a NEW_MEDIA event
* gst/gstbin.c: (gst_bin_remove_func), (gst_bin_change_state),
(gst_bin_dispose):
don't die when someone removes elements in callbacks
* gst/gstelement.c: (gst_element_change_state):
improve debugging
* gst/gstpad.c: (gst_pad_pull), (gst_pad_call_chain_function):
we need a NEW_MEDIA event to engage a link
* gst/gsttrace.c: (gst_trace_new), (gst_alloc_trace_set_flags_all):
don't g_print debugging stuff
* testsuite/caps/simplify.c: (check_caps):
This commit is contained in:
Benjamin Otte 2004-05-06 21:40:55 +00:00
parent c87049e9e2
commit f9bafab28f
11 changed files with 77 additions and 39 deletions

View file

@ -1,3 +1,23 @@
2004-05-06 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/elements/gstfilesrc.c: (gst_filesrc_get),
(gst_filesrc_change_state), (gst_filesrc_srcpad_event):
* gst/elements/gstfilesrc.h:
send NEW_MEDIA events correctly
* gst/elements/gsttypefindelement.c: (start_typefinding),
(gst_type_find_element_handle_event):
restart typefinding when we get a NEW_MEDIA event
* gst/gstbin.c: (gst_bin_remove_func), (gst_bin_change_state),
(gst_bin_dispose):
don't die when someone removes elements in callbacks
* gst/gstelement.c: (gst_element_change_state):
improve debugging
* gst/gstpad.c: (gst_pad_pull), (gst_pad_call_chain_function):
we need a NEW_MEDIA event to engage a link
* gst/gsttrace.c: (gst_trace_new), (gst_alloc_trace_set_flags_all):
don't g_print debugging stuff
* testsuite/caps/simplify.c: (check_caps):
2004-05-04 Benjamin Otte <otte@gnome.org> 2004-05-04 Benjamin Otte <otte@gnome.org>
* gst/parse/grammar.y: * gst/parse/grammar.y:

View file

@ -678,11 +678,11 @@ gst_filesrc_get (GstPad * pad)
if (src->need_discont) { if (src->need_discont) {
GstEvent *event; GstEvent *event;
src->need_discont = 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 (src->need_discont > 1, GST_FORMAT_BYTES,
NULL); src->curoffset, NULL);
src->need_discont = 0;
return GST_DATA (event); return GST_DATA (event);
} }
@ -837,12 +837,11 @@ gst_filesrc_change_state (GstElement * element)
if (!gst_filesrc_open_file (GST_FILESRC (element))) if (!gst_filesrc_open_file (GST_FILESRC (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
src->need_discont = TRUE; src->need_discont = 2;
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->need_discont = TRUE;
break; break;
default: default:
break; break;
@ -950,7 +949,7 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
goto error; goto error;
break; break;
} }
src->need_discont = TRUE; src->need_discont = 1;
src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
break; break;
} }

View file

@ -72,7 +72,7 @@ struct _GstFileSrc {
GstBuffer *mapbuf; GstBuffer *mapbuf;
size_t mapsize; size_t mapsize;
gboolean need_discont; gint need_discont;
gboolean need_flush; gboolean need_flush;
}; };

View file

@ -317,10 +317,13 @@ free_entry (TypeFindEntry * entry)
static void static void
start_typefinding (GstTypeFindElement * typefind) start_typefinding (GstTypeFindElement * typefind)
{ {
g_assert (typefind->caps == NULL);
g_assert (typefind->possibilities == NULL); g_assert (typefind->possibilities == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding"); GST_DEBUG_OBJECT (typefind, "starting typefinding");
gst_pad_unnegotiate (typefind->src);
if (typefind->caps) {
gst_caps_replace (&typefind->caps, NULL);
}
typefind->mode = MODE_TYPEFIND; typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE; typefind->stream_length_available = TRUE;
typefind->stream_length = 0; typefind->stream_length = 0;
@ -429,7 +432,13 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
break; break;
} }
} else { } else {
gst_pad_event_default (pad, event); if (GST_EVENT_TYPE (event) == GST_EVENT_DISCONTINUOUS &&
GST_EVENT_DISCONT_NEW_MEDIA (event)) {
start_typefinding (typefind);
gst_event_unref (event);
} else {
gst_pad_event_default (pad, event);
}
} }
} }
static guint8 * static guint8 *

View file

@ -739,10 +739,11 @@ gst_bin_change_state (GstElement * element)
GstElementState old_child_state; GstElementState old_child_state;
child = GST_ELEMENT (children->data); child = GST_ELEMENT (children->data);
children = g_list_next (children);
if (GST_FLAG_IS_SET (child, GST_ELEMENT_LOCKED_STATE)) if (GST_FLAG_IS_SET (child, GST_ELEMENT_LOCKED_STATE)) {
children = g_list_next (children);
continue; continue;
}
old_child_state = GST_STATE (child); old_child_state = GST_STATE (child);
@ -780,6 +781,10 @@ gst_bin_change_state (GstElement * element)
gst_element_state_get_name (pending)); gst_element_state_get_name (pending));
break; break;
} }
/* we need to do this down here, because there might be elements removed
* from this bin during state changes, so g_list_next (children) might
* change as well */
children = g_list_next (children);
} }
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
@ -818,26 +823,17 @@ static void
gst_bin_dispose (GObject * object) gst_bin_dispose (GObject * object)
{ {
GstBin *bin = GST_BIN (object); GstBin *bin = GST_BIN (object);
GList *children, *orig;
GstElement *child;
GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose"); GST_CAT_DEBUG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose");
if (gst_element_get_state (GST_ELEMENT (object)) == GST_STATE_PLAYING) if (gst_element_get_state (GST_ELEMENT (object)) == GST_STATE_PLAYING)
gst_element_set_state (GST_ELEMENT (object), GST_STATE_PAUSED); gst_element_set_state (GST_ELEMENT (object), GST_STATE_PAUSED);
if (bin->children) { while (bin->children) {
orig = children = g_list_copy (bin->children); gst_bin_remove (bin, GST_ELEMENT (bin->children->data));
while (children) {
child = GST_ELEMENT (children->data);
gst_bin_remove (bin, child);
children = g_list_next (children);
}
g_list_free (bin->children);
g_list_free (orig);
} }
bin->children = NULL; g_assert (bin->children == NULL);
bin->numchildren = 0; g_assert (bin->numchildren == 0);
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }

View file

@ -2870,7 +2870,7 @@ gst_element_change_state (GstElement * element)
} }
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
"default handler sets state from %s to %s %04x", "default handler tries setting state from %s to %s %04x",
gst_element_state_get_name (old_state), gst_element_state_get_name (old_state),
gst_element_state_get_name (old_pending), old_transition); gst_element_state_get_name (old_pending), old_transition);
@ -2903,8 +2903,11 @@ gst_element_change_state (GstElement * element)
/* 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)) {
GST_CAT_INFO_OBJECT (GST_CAT_STATES, element,
"failed state change, could not negotiate pads");
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 */

View file

@ -3211,6 +3211,7 @@ gst_pad_pull (GstPad * pad)
data = (peer->gethandler) (GST_PAD (peer)); data = (peer->gethandler) (GST_PAD (peer));
/* refetch - we might have been relinked */ /* refetch - we might have been relinked */
link = GST_RPAD_LINK (pad); link = GST_RPAD_LINK (pad);
peer = GST_RPAD_PEER (pad);
} }
if (data) { if (data) {
@ -3221,7 +3222,8 @@ gst_pad_pull (GstPad * pad)
link->engaged = TRUE; link->engaged = TRUE;
data = _invent_event (pad, GST_BUFFER (data)); data = _invent_event (pad, GST_BUFFER (data));
} else if (GST_IS_EVENT (data) && } else if (GST_IS_EVENT (data) &&
GST_EVENT_TYPE (data) == GST_EVENT_DISCONTINUOUS) { GST_EVENT_TYPE (data) == GST_EVENT_DISCONTINUOUS &&
GST_EVENT_DISCONT_NEW_MEDIA (data)) {
link->engaged = TRUE; link->engaged = TRUE;
GST_CAT_LOG (GST_CAT_DATAFLOW, GST_CAT_LOG (GST_CAT_DATAFLOW,
"link engaged by discont event for pad %s:%s", "link engaged by discont event for pad %s:%s",
@ -4307,7 +4309,8 @@ gst_pad_call_chain_function (GstPad * pad, GstData * data)
g_assert (link->temp_store == data); g_assert (link->temp_store == data);
link->temp_store = NULL; link->temp_store = NULL;
} else if (GST_IS_EVENT (data) && } else if (GST_IS_EVENT (data) &&
GST_EVENT_TYPE (data) == GST_EVENT_DISCONTINUOUS) { GST_EVENT_TYPE (data) == GST_EVENT_DISCONTINUOUS &&
GST_EVENT_DISCONT_NEW_MEDIA (data)) {
link->engaged = TRUE; link->engaged = TRUE;
GST_CAT_LOG (GST_CAT_DATAFLOW, GST_CAT_LOG (GST_CAT_DATAFLOW,
"link engaged by discont event for pad %s:%s", "link engaged by discont event for pad %s:%s",

View file

@ -69,7 +69,7 @@ gst_trace_new (gchar * filename, gint size)
g_return_val_if_fail (trace != NULL, NULL); g_return_val_if_fail (trace != NULL, NULL);
trace->filename = g_strdup (filename); trace->filename = g_strdup (filename);
g_print ("opening '%s'\n", trace->filename); GST_DEBUG ("opening '%s'\n", trace->filename);
#ifndef S_IWUSR #ifndef S_IWUSR
#define S_IWUSR S_IWRITE #define S_IWUSR S_IWRITE
#endif #endif
@ -287,7 +287,7 @@ gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags)
while (walk) { while (walk) {
GstAllocTrace *trace = (GstAllocTrace *) walk->data; GstAllocTrace *trace = (GstAllocTrace *) walk->data;
g_print ("set flags on %p\n", trace); GST_DEBUG ("set flags on %p\n", trace);
gst_alloc_trace_set_flags (trace, flags); gst_alloc_trace_set_flags (trace, flags);
walk = g_list_next (walk); walk = g_list_next (walk);

View file

@ -678,11 +678,11 @@ gst_filesrc_get (GstPad * pad)
if (src->need_discont) { if (src->need_discont) {
GstEvent *event; GstEvent *event;
src->need_discont = 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 (src->need_discont > 1, GST_FORMAT_BYTES,
NULL); src->curoffset, NULL);
src->need_discont = 0;
return GST_DATA (event); return GST_DATA (event);
} }
@ -837,12 +837,11 @@ gst_filesrc_change_state (GstElement * element)
if (!gst_filesrc_open_file (GST_FILESRC (element))) if (!gst_filesrc_open_file (GST_FILESRC (element)))
return GST_STATE_FAILURE; return GST_STATE_FAILURE;
} }
src->need_discont = TRUE; src->need_discont = 2;
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->need_discont = TRUE;
break; break;
default: default:
break; break;
@ -950,7 +949,7 @@ gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event)
goto error; goto error;
break; break;
} }
src->need_discont = TRUE; src->need_discont = 1;
src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
break; break;
} }

View file

@ -72,7 +72,7 @@ struct _GstFileSrc {
GstBuffer *mapbuf; GstBuffer *mapbuf;
size_t mapsize; size_t mapsize;
gboolean need_discont; gint need_discont;
gboolean need_flush; gboolean need_flush;
}; };

View file

@ -317,10 +317,13 @@ free_entry (TypeFindEntry * entry)
static void static void
start_typefinding (GstTypeFindElement * typefind) start_typefinding (GstTypeFindElement * typefind)
{ {
g_assert (typefind->caps == NULL);
g_assert (typefind->possibilities == NULL); g_assert (typefind->possibilities == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding"); GST_DEBUG_OBJECT (typefind, "starting typefinding");
gst_pad_unnegotiate (typefind->src);
if (typefind->caps) {
gst_caps_replace (&typefind->caps, NULL);
}
typefind->mode = MODE_TYPEFIND; typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE; typefind->stream_length_available = TRUE;
typefind->stream_length = 0; typefind->stream_length = 0;
@ -429,7 +432,13 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
break; break;
} }
} else { } else {
gst_pad_event_default (pad, event); if (GST_EVENT_TYPE (event) == GST_EVENT_DISCONTINUOUS &&
GST_EVENT_DISCONT_NEW_MEDIA (event)) {
start_typefinding (typefind);
gst_event_unref (event);
} else {
gst_pad_event_default (pad, event);
}
} }
} }
static guint8 * static guint8 *