mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-04 16:39:39 +00:00
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:
parent
c87049e9e2
commit
f9bafab28f
11 changed files with 77 additions and 39 deletions
20
ChangeLog
20
ChangeLog
|
@ -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:
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -428,9 +431,15 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
|
||||||
gst_data_unref (GST_DATA (event));
|
gst_data_unref (GST_DATA (event));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_DISCONTINUOUS &&
|
||||||
|
GST_EVENT_DISCONT_NEW_MEDIA (event)) {
|
||||||
|
start_typefinding (typefind);
|
||||||
|
gst_event_unref (event);
|
||||||
} else {
|
} else {
|
||||||
gst_pad_event_default (pad, event);
|
gst_pad_event_default (pad, event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static guint8 *
|
static guint8 *
|
||||||
find_peek (gpointer data, gint64 offset, guint size)
|
find_peek (gpointer data, gint64 offset, guint size)
|
||||||
|
|
26
gst/gstbin.c
26
gst/gstbin.c
|
@ -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_assert (bin->children == NULL);
|
||||||
g_list_free (orig);
|
g_assert (bin->numchildren == 0);
|
||||||
}
|
|
||||||
bin->children = NULL;
|
|
||||||
bin->numchildren = 0;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -428,9 +431,15 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
|
||||||
gst_data_unref (GST_DATA (event));
|
gst_data_unref (GST_DATA (event));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_DISCONTINUOUS &&
|
||||||
|
GST_EVENT_DISCONT_NEW_MEDIA (event)) {
|
||||||
|
start_typefinding (typefind);
|
||||||
|
gst_event_unref (event);
|
||||||
} else {
|
} else {
|
||||||
gst_pad_event_default (pad, event);
|
gst_pad_event_default (pad, event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static guint8 *
|
static guint8 *
|
||||||
find_peek (gpointer data, gint64 offset, guint size)
|
find_peek (gpointer data, gint64 offset, guint size)
|
||||||
|
|
Loading…
Reference in a new issue