mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
gst/gstbin.c: Position query should also take max of all streams.
Original commit message from CVS: * gst/gstbin.c: (gst_bin_handle_message_func), (bin_query_max_init), (bin_query_position_fold), (bin_query_position_done), (gst_bin_query): Position query should also take max of all streams.
This commit is contained in:
parent
b7edbd2caf
commit
f35fc7a902
2 changed files with 49 additions and 4 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-03-20 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/gstbin.c: (gst_bin_handle_message_func),
|
||||
(bin_query_max_init), (bin_query_position_fold),
|
||||
(bin_query_position_done), (gst_bin_query):
|
||||
Position query should also take max of all streams.
|
||||
|
||||
2006-03-20 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* plugins/elements/gstfakesrc.c: (gst_fake_src_class_init),
|
||||
|
|
46
gst/gstbin.c
46
gst/gstbin.c
|
@ -2203,10 +2203,10 @@ typedef struct
|
|||
typedef void (*QueryInitFunction) (GstBin * bin, QueryFold * fold);
|
||||
typedef void (*QueryDoneFunction) (GstBin * bin, QueryFold * fold);
|
||||
|
||||
/* for duration we collect all durations and take the MAX of
|
||||
* all valid results */
|
||||
/* for duration/position we collect all durations/positions and take
|
||||
* the MAX of all valid results */
|
||||
static void
|
||||
bin_query_duration_init (GstBin * bin, QueryFold * fold)
|
||||
bin_query_max_init (GstBin * bin, QueryFold * fold)
|
||||
{
|
||||
fold->max = -1;
|
||||
}
|
||||
|
@ -2250,6 +2250,37 @@ bin_query_duration_done (GstBin * bin, QueryFold * fold)
|
|||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bin_query_position_fold (GstElement * item, GValue * ret, QueryFold * fold)
|
||||
{
|
||||
if (gst_element_query (item, fold->query)) {
|
||||
gint64 position;
|
||||
|
||||
g_value_set_boolean (ret, TRUE);
|
||||
|
||||
gst_query_parse_position (fold->query, NULL, &position);
|
||||
|
||||
GST_DEBUG_OBJECT (item, "got position %" G_GINT64_FORMAT, position);
|
||||
|
||||
if (position > fold->max)
|
||||
fold->max = position;
|
||||
}
|
||||
|
||||
gst_object_unref (item);
|
||||
return TRUE;
|
||||
}
|
||||
static void
|
||||
bin_query_position_done (GstBin * bin, QueryFold * fold)
|
||||
{
|
||||
GstFormat format;
|
||||
|
||||
gst_query_parse_position (fold->query, &format, NULL);
|
||||
/* store max in query result */
|
||||
gst_query_set_position (fold->query, format, fold->max);
|
||||
|
||||
GST_DEBUG_OBJECT (bin, "max position %" G_GINT64_FORMAT, fold->max);
|
||||
}
|
||||
|
||||
/* generic fold, return first valid result */
|
||||
static gboolean
|
||||
bin_query_generic_fold (GstElement * item, GValue * ret, QueryFold * fold)
|
||||
|
@ -2315,10 +2346,17 @@ gst_bin_query (GstElement * element, GstQuery * query)
|
|||
GST_OBJECT_UNLOCK (bin);
|
||||
#endif
|
||||
fold_func = (GstIteratorFoldFunction) bin_query_duration_fold;
|
||||
fold_init = bin_query_duration_init;
|
||||
fold_init = bin_query_max_init;
|
||||
fold_done = bin_query_duration_done;
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
fold_func = (GstIteratorFoldFunction) bin_query_position_fold;
|
||||
fold_init = bin_query_max_init;
|
||||
fold_done = bin_query_position_done;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fold_func = (GstIteratorFoldFunction) bin_query_generic_fold;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue