diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-05-24 17:36:24 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-05-24 17:39:56 +0200 |
commit | 7e6d579301b2db838e809f536ea9506ea48dfd61 (patch) | |
tree | 006f348696b5a73f2d6d82aae56574cc7c0c5dd4 | |
parent | 5fa3082e19bee9826c75319fd33ad703e00a0831 (diff) |
scheduling: port to new scheduling query
-rw-r--r-- | gst/gstghostpad.c | 29 | ||||
-rw-r--r-- | gst/gstghostpad.h | 1 | ||||
-rw-r--r-- | gst/gstpad.c | 100 | ||||
-rw-r--r-- | gst/gstpad.h | 17 | ||||
-rw-r--r-- | gst/gstquery.c | 1 | ||||
-rw-r--r-- | libs/gst/base/gstbaseparse.c | 14 | ||||
-rw-r--r-- | libs/gst/base/gstbasesink.c | 16 | ||||
-rw-r--r-- | libs/gst/base/gstbasesrc.c | 74 | ||||
-rw-r--r-- | libs/gst/base/gstbasesrc.h | 7 | ||||
-rw-r--r-- | libs/gst/base/gstbasetransform.c | 18 | ||||
-rw-r--r-- | libs/gst/base/gstpushsrc.c | 33 | ||||
-rw-r--r-- | plugins/elements/gstqueue2.c | 31 | ||||
-rw-r--r-- | plugins/elements/gsttee.c | 66 | ||||
-rw-r--r-- | plugins/elements/gsttypefindelement.c | 39 |
14 files changed, 147 insertions, 299 deletions
diff --git a/gst/gstghostpad.c b/gst/gstghostpad.c index 23ed3ba2b..2dc086753 100644 --- a/gst/gstghostpad.c +++ b/gst/gstghostpad.c @@ -283,30 +283,6 @@ gst_proxy_pad_getrange_default (GstPad * pad, guint64 offset, guint size, } /** - * gst_proxy_pad_checkgetrange_default: - * @pad: a src #GstPad, returns #GST_FLOW_ERROR if not. - * - * Invoke the default checkgetrange function of the proxy pad. - * - * Returns: a #gboolean from the pad. - * - * Since: 0.10.35 - */ -gboolean -gst_proxy_pad_checkgetrange_default (GstPad * pad) -{ - gboolean result; - GstPad *internal; - - g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE); - - internal = GST_PROXY_PAD_INTERNAL (pad); - result = gst_pad_check_pull_range (internal); - - return result; -} - -/** * gst_proxy_pad_getcaps_default: * @pad: a #GstPad to get the capabilities of. * @filter: a #GstCaps filter. @@ -615,7 +591,6 @@ gst_proxy_pad_class_init (GstProxyPadClass * klass) GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_default); GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_list_default); GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_getrange_default); - GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_checkgetrange_default); } static void @@ -1045,8 +1020,6 @@ gst_ghost_pad_construct (GstGhostPad * gpad) gst_pad_set_chain_list_function (pad, gst_proxy_pad_chain_list_default); } else { gst_pad_set_getrange_function (pad, gst_proxy_pad_getrange_default); - gst_pad_set_checkgetrange_function (pad, - gst_proxy_pad_checkgetrange_default); } /* link/unlink functions */ @@ -1075,8 +1048,6 @@ gst_ghost_pad_construct (GstGhostPad * gpad) gst_proxy_pad_chain_list_default); } else { gst_pad_set_getrange_function (internal, gst_proxy_pad_getrange_default); - gst_pad_set_checkgetrange_function (internal, - gst_proxy_pad_checkgetrange_default); } GST_PROXY_LOCK (pad); diff --git a/gst/gstghostpad.h b/gst/gstghostpad.h index 3225e2aa1..1fa2c187f 100644 --- a/gst/gstghostpad.h +++ b/gst/gstghostpad.h @@ -69,7 +69,6 @@ GstIterator* gst_proxy_pad_iterate_internal_links_default (GstPad *pad); GstFlowReturn gst_proxy_pad_chain_default (GstPad *pad, GstBuffer *buffer); GstFlowReturn gst_proxy_pad_chain_list_default (GstPad *pad, GstBufferList *list); GstFlowReturn gst_proxy_pad_getrange_default (GstPad *pad, guint64 offset, guint size, GstBuffer **buffer); -gboolean gst_proxy_pad_checkgetrange_default (GstPad *pad); GstCaps* gst_proxy_pad_getcaps_default (GstPad *pad, GstCaps * filter); gboolean gst_proxy_pad_acceptcaps_default (GstPad *pad, GstCaps *caps); void gst_proxy_pad_fixatecaps_default (GstPad *pad, GstCaps *caps); diff --git a/gst/gstpad.c b/gst/gstpad.c index 715ec632d..041944f66 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1402,27 +1402,6 @@ gst_pad_set_getrange_function (GstPad * pad, GstPadGetRangeFunction get) } /** - * gst_pad_set_checkgetrange_function: - * @pad: a source #GstPad. - * @check: the #GstPadCheckGetRangeFunction to set. - * - * Sets the given checkgetrange function for the pad. Implement this function - * on a pad if you dynamically support getrange based scheduling on the pad. - */ -void -gst_pad_set_checkgetrange_function (GstPad * pad, - GstPadCheckGetRangeFunction check) -{ - g_return_if_fail (GST_IS_PAD (pad)); - g_return_if_fail (GST_PAD_IS_SRC (pad)); - - GST_PAD_CHECKGETRANGEFUNC (pad) = check; - - GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "checkgetrangefunc set to %s", - GST_DEBUG_FUNCPTR_NAME (check)); -} - -/** * gst_pad_set_event_function: * @pad: a #GstPad of either direction. * @event: the #GstPadEventFunction to set. @@ -3412,14 +3391,16 @@ gst_pad_query (GstPad * pad, GstQuery * query) g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (GST_IS_QUERY (query), FALSE); - GST_DEBUG_OBJECT (pad, "sending query %p", query); + GST_DEBUG_OBJECT (pad, "sending query %p (%s)", query, + GST_QUERY_TYPE_NAME (query)); if ((func = GST_PAD_QUERYFUNC (pad)) == NULL) goto no_func; res = func (pad, query); - GST_DEBUG_OBJECT (pad, "sent query %p, result %d", query, res); + GST_DEBUG_OBJECT (pad, "sent query %p (%s), result %d", query, + GST_QUERY_TYPE_NAME (query), res); return res; @@ -3456,7 +3437,8 @@ gst_pad_peer_query (GstPad * pad, GstQuery * query) GST_OBJECT_LOCK (pad); - GST_DEBUG_OBJECT (pad, "peer query"); + GST_DEBUG_OBJECT (pad, "peer query %p (%s)", query, + GST_QUERY_TYPE_NAME (query)); peerpad = GST_PAD_PEER (pad); if (G_UNLIKELY (peerpad == NULL)) @@ -4363,76 +4345,6 @@ invalid: } } -/** - * gst_pad_check_pull_range: - * @pad: a sink #GstPad. - * - * Checks if a gst_pad_pull_range() can be performed on the peer - * source pad. This function is used by plugins that want to check - * if they can use random access on the peer source pad. - * - * The peer sourcepad can implement a custom #GstPadCheckGetRangeFunction - * if it needs to perform some logic to determine if pull_range is - * possible. - * - * Returns: a gboolean with the result. - * - * MT safe. - */ -gboolean -gst_pad_check_pull_range (GstPad * pad) -{ - GstPad *peer; - gboolean ret; - GstPadCheckGetRangeFunction checkgetrangefunc; - - g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - - GST_OBJECT_LOCK (pad); - if (!GST_PAD_IS_SINK (pad)) - goto wrong_direction; - - if (G_UNLIKELY ((peer = GST_PAD_PEER (pad)) == NULL)) - goto not_connected; - - gst_object_ref (peer); - GST_OBJECT_UNLOCK (pad); - - /* see note in above function */ - if (G_LIKELY ((checkgetrangefunc = peer->checkgetrangefunc) == NULL)) { - /* FIXME, kindoff ghetto */ - ret = GST_PAD_GETRANGEFUNC (peer) != NULL; - GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, - "no checkgetrangefunc, assuming %d", ret); - } else { - GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, - "calling checkgetrangefunc %s of peer pad %s:%s", - GST_DEBUG_FUNCPTR_NAME (checkgetrangefunc), GST_DEBUG_PAD_NAME (peer)); - - ret = checkgetrangefunc (peer); - } - - gst_object_unref (peer); - - return ret; - - /* ERROR recovery here */ -wrong_direction: - { - GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, - "checking pull range, but pad must be a sinkpad"); - GST_OBJECT_UNLOCK (pad); - return FALSE; - } -not_connected: - { - GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, - "checking pull range, but it was not linked"); - GST_OBJECT_UNLOCK (pad); - return FALSE; - } -} - static GstFlowReturn gst_pad_get_range_unchecked (GstPad * pad, guint64 offset, guint size, GstBuffer ** buffer) diff --git a/gst/gstpad.h b/gst/gstpad.h index f45106666..aaecf8caf 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -342,20 +342,6 @@ typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset, typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event); -/* FIXME: 0.11: deprecate me, check range should use seeking query */ -/** - * GstPadCheckGetRangeFunction: - * @pad: a #GstPad - * - * Check if @pad can be activated in pull mode. - * - * This function will be deprecated after 0.10; use the seeking query to check - * if a pad can support random access. - * - * Returns: TRUE if the pad can operate in pull mode. - */ -typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad); - /* internal links */ /** * GstPadIterIntLinkFunction: @@ -638,7 +624,6 @@ struct _GstPad { /* data transport functions */ GstPadChainFunction chainfunc; GstPadChainListFunction chainlistfunc; - GstPadCheckGetRangeFunction checkgetrangefunc; GstPadGetRangeFunction getrangefunc; GstPadEventFunction eventfunc; @@ -843,7 +828,6 @@ void gst_pad_set_activatepush_function (GstPad *pad, GstPadActivateModeFunctio void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain); void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist); void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get); -void gst_pad_set_checkgetrange_function (GstPad *pad, GstPadCheckGetRangeFunction check); void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event); /* pad links */ @@ -888,7 +872,6 @@ void gst_pad_set_offset (GstPad *pad, gi /* data passing functions to peer */ GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer); GstFlowReturn gst_pad_push_list (GstPad *pad, GstBufferList *list); -gboolean gst_pad_check_pull_range (GstPad *pad); GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size, GstBuffer **buffer); gboolean gst_pad_push_event (GstPad *pad, GstEvent *event); diff --git a/gst/gstquery.c b/gst/gstquery.c index ad31fb081..7efa34cb0 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -104,6 +104,7 @@ static GstQueryTypeDefinition standard_definitions[] = { {GST_QUERY_CUSTOM, "custom", "Custom query", 0}, {GST_QUERY_URI, "uri", "URI of the source or sink", 0}, {GST_QUERY_ALLOCATION, "allocation", "Allocation properties", 0}, + {GST_QUERY_SCHEDULING, "scheduling", "Scheduling properties", 0}, {0, NULL, NULL, 0} }; diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 15a0b06f4..d6d49a1b9 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -2749,12 +2749,24 @@ gst_base_parse_sink_activate (GstPad * sinkpad) { GstBaseParse *parse; gboolean result = TRUE; + GstQuery *query; + gboolean pull_mode; parse = GST_BASE_PARSE (gst_pad_get_parent (sinkpad)); GST_DEBUG_OBJECT (parse, "sink activate"); - if (gst_pad_check_pull_range (sinkpad)) { + query = gst_query_new_scheduling (); + result = gst_pad_peer_query (sinkpad, query); + if (result) { + gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, + NULL); + } else { + pull_mode = FALSE; + } + gst_query_unref (query); + + if (pull_mode) { GST_DEBUG_OBJECT (parse, "trying to activate in pull mode"); result = gst_pad_activate_pull (sinkpad, TRUE); } else { diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index fd9f94917..ce664fbc8 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -4098,6 +4098,8 @@ gst_base_sink_pad_activate (GstPad * pad) { gboolean result = FALSE; GstBaseSink *basesink; + GstQuery *query; + gboolean pull_mode; basesink = GST_BASE_SINK (gst_pad_get_parent (pad)); @@ -4112,7 +4114,19 @@ gst_base_sink_pad_activate (GstPad * pad) } /* check if downstreams supports pull mode at all */ - if (!gst_pad_check_pull_range (pad)) { + query = gst_query_new_scheduling (); + + if (!gst_pad_peer_query (pad, query)) { + gst_query_unref (query); + GST_DEBUG_OBJECT (basesink, "peer query faild, no pull mode"); + goto fallback; + } + + /* parse result of the query */ + gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL); + gst_query_unref (query); + + if (!pull_mode) { GST_DEBUG_OBJECT (basesink, "pull mode not supported"); goto fallback; } diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index b68fd0224..d13105c37 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -283,6 +283,7 @@ gst_base_src_get_type (void) static GstCaps *gst_base_src_getcaps (GstPad * pad, GstCaps * filter); static void gst_base_src_fixate (GstPad * pad, GstCaps * caps); +static gboolean gst_base_src_is_random_access (GstBaseSrc * src); static gboolean gst_base_src_activate_push (GstPad * pad, gboolean active); static gboolean gst_base_src_activate_pull (GstPad * pad, gboolean active); static void gst_base_src_set_property (GObject * object, guint prop_id, @@ -312,8 +313,6 @@ static GstStateChangeReturn gst_base_src_change_state (GstElement * element, GstStateChange transition); static void gst_base_src_loop (GstPad * pad); -static gboolean gst_base_src_pad_check_get_range (GstPad * pad); -static gboolean gst_base_src_default_check_get_range (GstBaseSrc * bsrc); static GstFlowReturn gst_base_src_pad_get_range (GstPad * pad, guint64 offset, guint length, GstBuffer ** buf); static GstFlowReturn gst_base_src_get_range (GstBaseSrc * src, guint64 offset, @@ -369,8 +368,6 @@ gst_base_src_class_init (GstBaseSrcClass * klass) klass->event = GST_DEBUG_FUNCPTR (gst_base_src_default_event); klass->do_seek = GST_DEBUG_FUNCPTR (gst_base_src_default_do_seek); klass->query = GST_DEBUG_FUNCPTR (gst_base_src_default_query); - klass->check_get_range = - GST_DEBUG_FUNCPTR (gst_base_src_default_check_get_range); klass->prepare_seek_segment = GST_DEBUG_FUNCPTR (gst_base_src_default_prepare_seek_segment); @@ -380,7 +377,6 @@ gst_base_src_class_init (GstBaseSrcClass * klass) GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_event_handler); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_query); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_pad_get_range); - GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_pad_check_get_range); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_getcaps); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_fixate); } @@ -414,7 +410,6 @@ gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class) gst_pad_set_activatepull_function (pad, gst_base_src_activate_pull); gst_pad_set_event_function (pad, gst_base_src_event_handler); gst_pad_set_query_function (pad, gst_base_src_query); - gst_pad_set_checkgetrange_function (pad, gst_base_src_pad_check_get_range); gst_pad_set_getrange_function (pad, gst_base_src_pad_get_range); gst_pad_set_getcaps_function (pad, gst_base_src_getcaps); gst_pad_set_fixatecaps_function (pad, gst_base_src_fixate); @@ -1077,6 +1072,20 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query) gst_query_set_buffering_range (query, format, start, stop, estimated); break; } + case GST_QUERY_SCHEDULING: + { + gboolean random_access; + + random_access = gst_base_src_is_random_access (src); + + /* we can operate in getrange mode if the native format is bytes + * and we are seekable, this condition is set in the random_access + * flag and is set in the _start() method. */ + gst_query_set_scheduling (query, random_access, TRUE, FALSE, 1, -1, 1); + + res = TRUE; + break; + } default: res = FALSE; break; @@ -2240,60 +2249,16 @@ flushing: } static gboolean -gst_base_src_default_check_get_range (GstBaseSrc * src) +gst_base_src_is_random_access (GstBaseSrc * src) { - gboolean res; - + /* we need to start the basesrc to check random access */ if (!GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_STARTED)) { GST_LOG_OBJECT (src, "doing start/stop to check get_range support"); if (G_LIKELY (gst_base_src_start (src))) gst_base_src_stop (src); } - /* we can operate in getrange mode if the native format is bytes - * and we are seekable, this condition is set in the random_access - * flag and is set in the _start() method. */ - res = src->random_access; - - return res; -} - -static gboolean -gst_base_src_check_get_range (GstBaseSrc * src) -{ - GstBaseSrcClass *bclass; - gboolean res; - - bclass = GST_BASE_SRC_GET_CLASS (src); - - if (bclass->check_get_range == NULL) - goto no_function; - - res = bclass->check_get_range (src); - GST_LOG_OBJECT (src, "%s() returned %d", - GST_DEBUG_FUNCPTR_NAME (bclass->check_get_range), (gint) res); - - return res; - - /* ERRORS */ -no_function: - { - GST_WARNING_OBJECT (src, "no check_get_range function set"); - return FALSE; - } -} - -static gboolean -gst_base_src_pad_check_get_range (GstPad * pad) -{ - GstBaseSrc *src; - gboolean res; - - src = GST_BASE_SRC (GST_OBJECT_PARENT (pad)); - - res = gst_base_src_check_get_range (src); - - return res; + return src->random_access; } static void @@ -2316,6 +2281,7 @@ gst_base_src_loop (GstPad * pad) reconfigure = GST_PAD_NEEDS_RECONFIGURE (pad); GST_OBJECT_FLAG_UNSET (pad, GST_PAD_NEED_RECONFIGURE); GST_OBJECT_UNLOCK (pad); + /* check if we need to renegotiate */ if (reconfigure) { if (!gst_base_src_negotiate (src)) @@ -2976,7 +2942,7 @@ gst_base_src_activate_pull (GstPad * pad, gboolean active) goto error_start; /* if not random_access, we cannot operate in pull mode for now */ - if (G_UNLIKELY (!gst_base_src_check_get_range (basesrc))) + if (G_UNLIKELY (!gst_base_src_is_random_access (basesrc))) goto no_get_range; /* stop flushing now but for live sources, still block in the LIVE lock when diff --git a/libs/gst/base/gstbasesrc.h b/libs/gst/base/gstbasesrc.h index f1fb7e523..6cd85087d 100644 --- a/libs/gst/base/gstbasesrc.h +++ b/libs/gst/base/gstbasesrc.h @@ -191,13 +191,6 @@ struct _GstBaseSrcClass { /* check if the resource is seekable */ gboolean (*is_seekable) (GstBaseSrc *src); - /* check whether the source would support pull-based operation if - * it were to be opened now. This vfunc is optional, but should be - * implemented if possible to avoid unnecessary start/stop cycles. - * The default implementation will open and close the resource to - * find out whether get_range is supported and that is usually - * undesirable. */ - gboolean (*check_get_range) (GstBaseSrc *src); /* Prepare the segment on which to perform do_seek(), converting to the * current basesrc format. */ diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 3a57bac2b..f5423d737 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -309,7 +309,6 @@ static gboolean gst_base_transform_src_eventfunc (GstBaseTransform * trans, static gboolean gst_base_transform_sink_event (GstPad * pad, GstEvent * event); static gboolean gst_base_transform_sink_eventfunc (GstBaseTransform * trans, GstEvent * event); -static gboolean gst_base_transform_check_get_range (GstPad * pad); static GstFlowReturn gst_base_transform_getrange (GstPad * pad, guint64 offset, guint length, GstBuffer ** buffer); static GstFlowReturn gst_base_transform_chain (GstPad * pad, @@ -409,8 +408,6 @@ gst_base_transform_init (GstBaseTransform * trans, GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps)); gst_pad_set_event_function (trans->srcpad, GST_DEBUG_FUNCPTR (gst_base_transform_src_event)); - gst_pad_set_checkgetrange_function (trans->srcpad, - GST_DEBUG_FUNCPTR (gst_base_transform_check_get_range)); gst_pad_set_getrange_function (trans->srcpad, GST_DEBUG_FUNCPTR (gst_base_transform_getrange)); gst_pad_set_activatepull_function (trans->srcpad, @@ -1945,21 +1942,6 @@ no_buffer: } } -static gboolean -gst_base_transform_check_get_range (GstPad * pad) -{ - GstBaseTransform *trans; - gboolean ret; - - trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); - - ret = gst_pad_check_pull_range (trans->sinkpad); - - gst_object_unref (trans); - - return ret; -} - /* FIXME, getrange is broken, need to pull range from the other * end based on the transform_size result. */ diff --git a/libs/gst/base/gstpushsrc.c b/libs/gst/base/gstpushsrc.c index 19eb37f90..6fcd50ba5 100644 --- a/libs/gst/base/gstpushsrc.c +++ b/libs/gst/base/gstpushsrc.c @@ -69,7 +69,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_push_src_debug); #define gst_push_src_parent_class parent_class G_DEFINE_TYPE_WITH_CODE (GstPushSrc, gst_push_src, GST_TYPE_BASE_SRC, _do_init); -static gboolean gst_push_src_check_get_range (GstBaseSrc * src); +static gboolean gst_push_src_query (GstBaseSrc * src, GstQuery * query); static GstFlowReturn gst_push_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer ** ret); @@ -79,8 +79,7 @@ gst_push_src_class_init (GstPushSrcClass * klass) GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass; gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_push_src_create); - gstbasesrc_class->check_get_range = - GST_DEBUG_FUNCPTR (gst_push_src_check_get_range); + gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_push_src_query); } static void @@ -90,13 +89,33 @@ gst_push_src_init (GstPushSrc * pushsrc) } static gboolean -gst_push_src_check_get_range (GstBaseSrc * src) +gst_push_src_query (GstBaseSrc * src, GstQuery * query) { - /* a pushsrc can by default never operate in pull mode override - * if you want something different. */ - return FALSE; + gboolean ret; + GstBaseSrcClass *bclass; + + bclass = GST_BASE_SRC_GET_CLASS (src); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_SCHEDULING: + { + /* a pushsrc can by default never operate in pull mode override + * if you want something different. */ + gst_query_set_scheduling (query, FALSE, FALSE, TRUE, 1, -1, 1); + ret = TRUE; + break; + } + default: + if (bclass->query) + ret = bclass->query (src, query); + else + ret = FALSE; + break; + } + return ret; } + static GstFlowReturn gst_push_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, GstBuffer ** ret) diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 65f3613f6..0b7ca8cae 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -239,7 +239,6 @@ static gboolean gst_queue2_acceptcaps (GstPad * pad, GstCaps * caps); static GstFlowReturn gst_queue2_get_range (GstPad * pad, guint64 offset, guint length, GstBuffer ** buffer); -static gboolean gst_queue2_src_checkgetrange_function (GstPad * pad); static gboolean gst_queue2_src_activate_pull (GstPad * pad, gboolean active); static gboolean gst_queue2_src_activate_push (GstPad * pad, gboolean active); @@ -394,8 +393,6 @@ gst_queue2_init (GstQueue2 * queue) GST_DEBUG_FUNCPTR (gst_queue2_src_activate_push)); gst_pad_set_getrange_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue2_get_range)); - gst_pad_set_checkgetrange_function (queue->srcpad, - GST_DEBUG_FUNCPTR (gst_queue2_src_checkgetrange_function)); gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue2_getcaps)); gst_pad_set_acceptcaps_function (queue->srcpad, @@ -2598,6 +2595,16 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) } break; } + case GST_QUERY_SCHEDULING: + { + gboolean pull_mode; + + /* we can operate in pull mode when we are using a tempfile */ + pull_mode = !QUEUE_IS_USING_QUEUE (queue); + + gst_query_set_scheduling (query, pull_mode, pull_mode, FALSE, 0, -1, 1); + break; + } default: /* peer handled other queries */ if (!gst_queue2_peer_query (queue, queue->sinkpad, query)) @@ -2698,22 +2705,6 @@ out_unexpected: } } -static gboolean -gst_queue2_src_checkgetrange_function (GstPad * pad) -{ - GstQueue2 *queue; - gboolean ret; - - queue = GST_QUEUE2 (gst_pad_get_parent (pad)); - - /* we can operate in pull mode when we are using a tempfile */ - ret = !QUEUE_IS_USING_QUEUE (queue); - - gst_object_unref (GST_OBJECT (queue)); - - return ret; -} - /* sink currently only operates in push mode */ static gboolean gst_queue2_sink_activate_push (GstPad * pad, gboolean active) @@ -2802,7 +2793,7 @@ gst_queue2_src_activate_pull (GstPad * pad, gboolean active) result = gst_queue2_open_temp_location_file (queue); } else if (!queue->ring_buffer) { queue->ring_buffer = g_malloc (queue->ring_buffer_max_size); - result = ! !queue->ring_buffer; + result = !!queue->ring_buffer; } else { result = TRUE; } diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index 699f10c92..4f2c8f119 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -139,7 +139,7 @@ static GstFlowReturn gst_tee_chain (GstPad * pad, GstBuffer * buffer); static GstFlowReturn gst_tee_chain_list (GstPad * pad, GstBufferList * list); static gboolean gst_tee_sink_acceptcaps (GstPad * pad, GstCaps * caps); static gboolean gst_tee_sink_activate_push (GstPad * pad, gboolean active); -static gboolean gst_tee_src_check_get_range (GstPad * pad); +static gboolean gst_tee_src_query (GstPad * pad, GstQuery * query); static gboolean gst_tee_src_activate_pull (GstPad * pad, gboolean active); static GstFlowReturn gst_tee_src_get_range (GstPad * pad, guint64 offset, guint length, GstBuffer ** buf); @@ -333,8 +333,7 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); gst_pad_set_activatepull_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_activate_pull)); - gst_pad_set_checkgetrange_function (srcpad, - GST_DEBUG_FUNCPTR (gst_tee_src_check_get_range)); + gst_pad_set_query_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_query)); gst_pad_set_getrange_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_get_range)); /* Forward sticky events to the new srcpad */ @@ -827,7 +826,7 @@ sink_activate_failed: } static gboolean -gst_tee_src_check_get_range (GstPad * pad) +gst_tee_src_query (GstPad * pad, GstQuery * query) { GstTee *tee; gboolean res; @@ -835,42 +834,43 @@ gst_tee_src_check_get_range (GstPad * pad) tee = GST_TEE (gst_pad_get_parent (pad)); - GST_OBJECT_LOCK (tee); - - if (tee->pull_mode == GST_TEE_PULL_MODE_NEVER) - goto cannot_pull; - - if (tee->pull_mode == GST_TEE_PULL_MODE_SINGLE && tee->pull_pad) - goto cannot_pull_multiple_srcs; + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_SCHEDULING: + { + gboolean pull_mode; - sinkpad = gst_object_ref (tee->sinkpad); + GST_OBJECT_LOCK (tee); + pull_mode = TRUE; + if (tee->pull_mode == GST_TEE_PULL_MODE_NEVER) { + GST_INFO_OBJECT (tee, "Cannot activate in pull mode, pull-mode " + "set to NEVER"); + pull_mode = FALSE; + } else if (tee->pull_mode == GST_TEE_PULL_MODE_SINGLE && tee->pull_pad) { + GST_INFO_OBJECT (tee, "Cannot activate multiple src pads in pull mode, " + "pull-mode set to SINGLE"); + pull_mode = FALSE; + } - GST_OBJECT_UNLOCK (tee); + sinkpad = gst_object_ref (tee->sinkpad); + GST_OBJECT_UNLOCK (tee); - res = gst_pad_check_pull_range (sinkpad); - gst_object_unref (sinkpad); + if (pull_mode) { + /* ask peer if we can operate in pull mode */ + res = gst_pad_peer_query (sinkpad, query); + } else { + res = TRUE; + } + gst_object_unref (sinkpad); + break; + } + default: + res = gst_pad_query_default (pad, query); + break; + } gst_object_unref (tee); return res; - - /* ERRORS */ -cannot_pull: - { - GST_OBJECT_UNLOCK (tee); - GST_INFO_OBJECT (tee, "Cannot activate in pull mode, pull-mode " - "set to NEVER"); - gst_object_unref (tee); - return FALSE; - } -cannot_pull_multiple_srcs: - { - GST_OBJECT_UNLOCK (tee); - GST_INFO_OBJECT (tee, "Cannot activate multiple src pads in pull mode, " - "pull-mode set to SINGLE"); - gst_object_unref (tee); - return FALSE; - } } static void diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index b34c3bd5b..7438c5267 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -151,7 +151,6 @@ static GstFlowReturn gst_type_find_element_chain (GstPad * sinkpad, GstBuffer * buffer); static GstFlowReturn gst_type_find_element_getrange (GstPad * srcpad, guint64 offset, guint length, GstBuffer ** buffer); -static gboolean gst_type_find_element_checkgetrange (GstPad * srcpad); static GstStateChangeReturn gst_type_find_element_change_state (GstElement * element, @@ -273,8 +272,6 @@ gst_type_find_element_init (GstTypeFindElement * typefind) gst_pad_set_activatepull_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_element_activate_src_pull)); - gst_pad_set_checkgetrange_function (typefind->src, - GST_DEBUG_FUNCPTR (gst_type_find_element_checkgetrange)); gst_pad_set_getrange_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_element_getrange)); gst_pad_set_event_function (typefind->src, @@ -851,16 +848,6 @@ low_probability: } } -static gboolean -gst_type_find_element_checkgetrange (GstPad * srcpad) -{ - GstTypeFindElement *typefind; - - typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (srcpad)); - - return gst_pad_check_pull_range (typefind->sink); -} - static GstFlowReturn gst_type_find_element_getrange (GstPad * srcpad, guint64 offset, guint length, GstBuffer ** buffer) @@ -891,6 +878,8 @@ gst_type_find_element_activate (GstPad * pad) GstTypeFindProbability probability = 0; GstCaps *found_caps = NULL; GstTypeFindElement *typefind; + GstQuery *query; + gboolean pull_mode; typefind = GST_TYPE_FIND_ELEMENT (GST_OBJECT_PARENT (pad)); @@ -917,14 +906,25 @@ gst_type_find_element_activate (GstPad * pad) */ /* 1 */ - if (!gst_pad_check_pull_range (pad) || !gst_pad_activate_pull (pad, TRUE)) { - start_typefinding (typefind); - return gst_pad_activate_push (pad, TRUE); + query = gst_query_new_scheduling (); + + if (!gst_pad_peer_query (pad, query)) { + gst_query_unref (query); + goto typefind_push; } - GST_DEBUG_OBJECT (typefind, "find type in pull mode"); + gst_query_parse_scheduling (query, &pull_mode, NULL, NULL, NULL, NULL, NULL); + gst_query_unref (query); + + if (!pull_mode) + goto typefind_push; + + if (!gst_pad_activate_pull (pad, TRUE)) + goto typefind_push; /* 2 */ + GST_DEBUG_OBJECT (typefind, "find type in pull mode"); + { GstPad *peer; @@ -1010,6 +1010,11 @@ really_done: ret &= gst_pad_activate_push (pad, TRUE); return ret; } +typefind_push: + { + start_typefinding (typefind); + return gst_pad_activate_push (pad, TRUE); + } } static GstStateChangeReturn |