summaryrefslogtreecommitdiff
path: root/libs/gst/base
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-05-10 18:36:33 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2011-05-10 18:36:33 +0200
commitcf4fbc005c5c530c2a509a943a05b91d6c9af3fb (patch)
tree93ae0a18b8929e902c2a5b2d10b29d02ab18eb94 /libs/gst/base
parentb905c4d21545ac3a3ef8473059e2f8c65f6e30df (diff)
query: allow _make_writable on query handlers
Pass a GstQuery ** to the query handlers so that they can make the query writable before using a setter on it. Port code to new API.
Diffstat (limited to 'libs/gst/base')
-rw-r--r--libs/gst/base/gstbaseparse.c41
-rw-r--r--libs/gst/base/gstbasesink.c32
-rw-r--r--libs/gst/base/gstbasesrc.c44
-rw-r--r--libs/gst/base/gstbasesrc.h2
-rw-r--r--libs/gst/base/gstbasetransform.c10
5 files changed, 72 insertions, 57 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
index a1bd393ee..6f70077f9 100644
--- a/libs/gst/base/gstbaseparse.c
+++ b/libs/gst/base/gstbaseparse.c
@@ -368,7 +368,7 @@ static void gst_base_parse_handle_tag (GstBaseParse * parse, GstEvent * event);
static gboolean gst_base_parse_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_base_parse_sink_event (GstPad * pad, GstEvent * event);
-static gboolean gst_base_parse_query (GstPad * pad, GstQuery * query);
+static gboolean gst_base_parse_query (GstPad * pad, GstQuery ** query);
static gboolean gst_base_parse_sink_setcaps (GstPad * pad, GstCaps * caps);
static const GstQueryType *gst_base_parse_get_querytypes (GstPad * pad);
@@ -1462,7 +1462,7 @@ gst_base_parse_check_seekability (GstBaseParse * parse)
guint idx_interval = 0;
query = gst_query_new_seeking (GST_FORMAT_BYTES);
- if (!gst_pad_peer_query (parse->sinkpad, query)) {
+ if (!gst_pad_peer_query (parse->sinkpad, &query)) {
GST_DEBUG_OBJECT (parse, "seeking query failed");
goto done;
}
@@ -3067,7 +3067,7 @@ gst_base_parse_get_querytypes (GstPad * pad)
}
static gboolean
-gst_base_parse_query (GstPad * pad, GstQuery * query)
+gst_base_parse_query (GstPad * pad, GstQuery ** query)
{
GstBaseParse *parse;
gboolean res = FALSE;
@@ -3076,14 +3076,14 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
GST_LOG_OBJECT (parse, "handling query: %" GST_PTR_FORMAT, query);
- switch (GST_QUERY_TYPE (query)) {
+ switch (GST_QUERY_TYPE (*query)) {
case GST_QUERY_POSITION:
{
gint64 dest_value;
GstFormat format;
GST_DEBUG_OBJECT (parse, "position query");
- gst_query_parse_position (query, &format, NULL);
+ gst_query_parse_position (*query, &format, NULL);
GST_OBJECT_LOCK (parse);
if (format == GST_FORMAT_BYTES) {
@@ -3096,9 +3096,10 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
}
GST_OBJECT_UNLOCK (parse);
- if (res)
- gst_query_set_position (query, format, dest_value);
- else {
+ if (res) {
+ *query = gst_query_make_writable (*query);
+ gst_query_set_position (*query, format, dest_value);
+ } else {
res = gst_pad_query_default (pad, query);
if (!res) {
/* no precise result, upstream no idea either, then best estimate */
@@ -3115,7 +3116,7 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
GstClockTime duration;
GST_DEBUG_OBJECT (parse, "duration query");
- gst_query_parse_duration (query, &format, NULL);
+ gst_query_parse_duration (*query, &format, NULL);
/* consult upstream */
res = gst_pad_query_default (pad, query);
@@ -3123,8 +3124,10 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
/* otherwise best estimate from us */
if (!res) {
res = gst_base_parse_get_duration (parse, format, &duration);
- if (res)
- gst_query_set_duration (query, format, duration);
+ if (res) {
+ *query = gst_query_make_writable (*query);
+ gst_query_set_duration (*query, format, duration);
+ }
}
break;
}
@@ -3135,14 +3138,14 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
gboolean seekable = FALSE;
GST_DEBUG_OBJECT (parse, "seeking query");
- gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
+ gst_query_parse_seeking (*query, &fmt, NULL, NULL, NULL);
/* consult upstream */
res = gst_pad_query_default (pad, query);
/* we may be able to help if in TIME */
if (fmt == GST_FORMAT_TIME && gst_base_parse_is_seekable (parse)) {
- gst_query_parse_seeking (query, &fmt, &seekable, NULL, NULL);
+ gst_query_parse_seeking (*query, &fmt, &seekable, NULL, NULL);
/* already OK if upstream takes care */
GST_LOG_OBJECT (parse, "upstream handled %d, seekable %d",
res, seekable);
@@ -3157,14 +3160,17 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
GST_LOG_OBJECT (parse, "already determine upstream seekabled: %d",
seekable);
}
- gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, 0, duration);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_seeking (*query, GST_FORMAT_TIME, seekable, 0,
+ duration);
res = TRUE;
}
}
break;
}
case GST_QUERY_FORMATS:
- gst_query_set_formatsv (query, 3, fmtlist);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_formatsv (*query, 3, fmtlist);
res = TRUE;
break;
case GST_QUERY_CONVERT:
@@ -3172,13 +3178,14 @@ gst_base_parse_query (GstPad * pad, GstQuery * query)
GstFormat src_format, dest_format;
gint64 src_value, dest_value;
- gst_query_parse_convert (query, &src_format, &src_value,
+ gst_query_parse_convert (*query, &src_format, &src_value,
&dest_format, &dest_value);
res = gst_base_parse_convert (parse, src_format, src_value,
dest_format, &dest_value);
if (res) {
- gst_query_set_convert (query, src_format, src_value,
+ *query = gst_query_make_writable (*query);
+ gst_query_set_convert (*query, src_format, src_value,
dest_format, dest_value);
}
break;
diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c
index 5f1b92da3..9fe4ea711 100644
--- a/libs/gst/base/gstbasesink.c
+++ b/libs/gst/base/gstbasesink.c
@@ -360,7 +360,7 @@ static void gst_base_sink_get_property (GObject * object, guint prop_id,
static gboolean gst_base_sink_send_event (GstElement * element,
GstEvent * event);
-static gboolean gst_base_sink_query (GstElement * element, GstQuery * query);
+static gboolean gst_base_sink_query (GstElement * element, GstQuery ** query);
static const GstQueryType *gst_base_sink_get_query_types (GstElement * element);
static GstCaps *gst_base_sink_get_caps (GstBaseSink * sink);
@@ -1090,7 +1090,7 @@ gst_base_sink_query_latency (GstBaseSink * sink, gboolean * live,
query = gst_query_new_latency ();
/* ask the peer for the latency */
- if ((res = gst_pad_peer_query (sink->sinkpad, query))) {
+ if ((res = gst_pad_peer_query (sink->sinkpad, &query))) {
/* get upstream min and max latency */
gst_query_parse_latency (query, &us_live, &us_min, &us_max);
@@ -4724,20 +4724,20 @@ gst_base_sink_get_query_types (GstElement * element)
}
static gboolean
-gst_base_sink_query (GstElement * element, GstQuery * query)
+gst_base_sink_query (GstElement * element, GstQuery ** query)
{
gboolean res = FALSE;
GstBaseSink *basesink = GST_BASE_SINK (element);
- switch (GST_QUERY_TYPE (query)) {
+ switch (GST_QUERY_TYPE (*query)) {
case GST_QUERY_POSITION:
{
gint64 cur = 0;
GstFormat format;
gboolean upstream = FALSE;
- gst_query_parse_position (query, &format, NULL);
+ gst_query_parse_position (*query, &format, NULL);
GST_DEBUG_OBJECT (basesink, "position query in format %s",
gst_format_get_name (format));
@@ -4745,7 +4745,8 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
/* first try to get the position based on the clock */
if ((res =
gst_base_sink_get_position (basesink, format, &cur, &upstream))) {
- gst_query_set_position (query, format, cur);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_position (*query, format, cur);
} else if (upstream) {
/* fallback to peer query */
res = gst_pad_peer_query (basesink->sinkpad, query);
@@ -4775,7 +4776,8 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
pos = gst_util_uint64_scale (100 * GST_FORMAT_PERCENT_SCALE, cur,
dur);
- gst_query_set_position (query, GST_FORMAT_PERCENT, pos);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_position (*query, GST_FORMAT_PERCENT, pos);
}
}
}
@@ -4787,14 +4789,15 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
GstFormat format;
gboolean upstream = FALSE;
- gst_query_parse_duration (query, &format, NULL);
+ gst_query_parse_duration (*query, &format, NULL);
GST_DEBUG_OBJECT (basesink, "duration query in format %s",
gst_format_get_name (format));
if ((res =
gst_base_sink_get_duration (basesink, format, &dur, &upstream))) {
- gst_query_set_duration (query, format, dur);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_duration (*query, format, dur);
} else if (upstream) {
/* fallback to peer query */
res = gst_pad_peer_query (basesink->sinkpad, query);
@@ -4802,7 +4805,8 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
if (!res) {
/* we can handle a few things if upstream failed */
if (format == GST_FORMAT_PERCENT) {
- gst_query_set_duration (query, GST_FORMAT_PERCENT,
+ *query = gst_query_make_writable (*query);
+ gst_query_set_duration (*query, GST_FORMAT_PERCENT,
GST_FORMAT_PERCENT_MAX);
res = TRUE;
}
@@ -4816,7 +4820,8 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
if ((res = gst_base_sink_query_latency (basesink, &live, &us_live, &min,
&max))) {
- gst_query_set_latency (query, live, min, max);
+ *query = gst_query_make_writable (*query);
+ gst_query_set_latency (*query, live, min, max);
}
break;
}
@@ -4829,7 +4834,8 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
case GST_QUERY_SEGMENT:
{
if (basesink->pad_mode == GST_ACTIVATE_PULL) {
- gst_query_set_segment (query, basesink->segment.rate,
+ *query = gst_query_make_writable (*query);
+ gst_query_set_segment (*query, basesink->segment.rate,
GST_FORMAT_TIME, basesink->segment.start, basesink->segment.stop);
res = TRUE;
} else {
@@ -4845,7 +4851,7 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
break;
}
GST_DEBUG_OBJECT (basesink, "query %s returns %d",
- GST_QUERY_TYPE_NAME (query), res);
+ GST_QUERY_TYPE_NAME (*query), res);
return res;
}
diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
index 5818b3505..5ab1462ad 100644
--- a/libs/gst/base/gstbasesrc.c
+++ b/libs/gst/base/gstbasesrc.c
@@ -297,12 +297,13 @@ static gboolean gst_base_src_send_event (GstElement * elem, GstEvent * event);
static gboolean gst_base_src_default_event (GstBaseSrc * src, GstEvent * event);
static const GstQueryType *gst_base_src_get_query_types (GstElement * element);
-static gboolean gst_base_src_query (GstPad * pad, GstQuery * query);
+static gboolean gst_base_src_query (GstPad * pad, GstQuery ** query);
static gboolean gst_base_src_default_negotiate (GstBaseSrc * basesrc);
static gboolean gst_base_src_default_do_seek (GstBaseSrc * src,
GstSegment * segment);
-static gboolean gst_base_src_default_query (GstBaseSrc * src, GstQuery * query);
+static gboolean gst_base_src_default_query (GstBaseSrc * src,
+ GstQuery ** query);
static gboolean gst_base_src_default_prepare_seek_segment (GstBaseSrc * src,
GstEvent * event, GstSegment * segment);
@@ -844,16 +845,16 @@ gst_base_src_fixate (GstPad * pad, GstCaps * caps)
}
static gboolean
-gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
+gst_base_src_default_query (GstBaseSrc * src, GstQuery ** query)
{
gboolean res;
- switch (GST_QUERY_TYPE (query)) {
+ switch (GST_QUERY_TYPE (*query)) {
case GST_QUERY_POSITION:
{
GstFormat format;
- gst_query_parse_position (query, &format, NULL);
+ gst_query_parse_position (*query, &format, NULL);
GST_DEBUG_OBJECT (src, "position query in format %s",
gst_format_get_name (format));
@@ -879,7 +880,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
} else
percent = -1;
- gst_query_set_position (query, GST_FORMAT_PERCENT, percent);
+ gst_query_set_position (*query, GST_FORMAT_PERCENT, percent);
res = TRUE;
break;
}
@@ -903,7 +904,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
} else
res = TRUE;
- gst_query_set_position (query, format, position);
+ gst_query_set_position (*query, format, position);
break;
}
}
@@ -913,14 +914,14 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
{
GstFormat format;
- gst_query_parse_duration (query, &format, NULL);
+ gst_query_parse_duration (*query, &format, NULL);
GST_DEBUG_OBJECT (src, "duration query in format %s",
gst_format_get_name (format));
switch (format) {
case GST_FORMAT_PERCENT:
- gst_query_set_duration (query, GST_FORMAT_PERCENT,
+ gst_query_set_duration (*query, GST_FORMAT_PERCENT,
GST_FORMAT_PERCENT_MAX);
res = TRUE;
break;
@@ -951,7 +952,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
* means that we cannot report the duration at all. */
res = TRUE;
}
- gst_query_set_duration (query, format, duration);
+ gst_query_set_duration (*query, format, duration);
break;
}
}
@@ -968,9 +969,9 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
seg_format = src->segment.format;
GST_OBJECT_UNLOCK (src);
- gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
+ gst_query_parse_seeking (*query, &format, NULL, NULL, NULL);
if (format == seg_format) {
- gst_query_set_seeking (query, seg_format,
+ gst_query_set_seeking (*query, seg_format,
gst_base_src_seekable (src), 0, duration);
res = TRUE;
} else {
@@ -999,7 +1000,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
stop -= src->segment.time;
}
- gst_query_set_segment (query, src->segment.rate, src->segment.format,
+ gst_query_set_segment (*query, src->segment.rate, src->segment.format,
start, stop);
GST_OBJECT_UNLOCK (src);
res = TRUE;
@@ -1008,7 +1009,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
case GST_QUERY_FORMATS:
{
- gst_query_set_formats (query, 3, GST_FORMAT_DEFAULT,
+ gst_query_set_formats (*query, 3, GST_FORMAT_DEFAULT,
GST_FORMAT_BYTES, GST_FORMAT_PERCENT);
res = TRUE;
break;
@@ -1018,7 +1019,8 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
GstFormat src_fmt, dest_fmt;
gint64 src_val, dest_val;
- gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ gst_query_parse_convert (*query, &src_fmt, &src_val, &dest_fmt,
+ &dest_val);
/* we can only convert between equal formats... */
if (src_fmt == dest_fmt) {
@@ -1027,7 +1029,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
} else
res = FALSE;
- gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ gst_query_set_convert (*query, src_fmt, src_val, dest_fmt, dest_val);
break;
}
case GST_QUERY_LATENCY:
@@ -1042,7 +1044,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
", max %" GST_TIME_FORMAT, live, GST_TIME_ARGS (min),
GST_TIME_ARGS (max));
- gst_query_set_latency (query, live, min, max);
+ gst_query_set_latency (*query, live, min, max);
break;
}
case GST_QUERY_JITTER:
@@ -1054,7 +1056,7 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
GstFormat format, seg_format;
gint64 start, stop, estimated;
- gst_query_parse_buffering_range (query, &format, NULL, NULL, NULL);
+ gst_query_parse_buffering_range (*query, &format, NULL, NULL, NULL);
GST_DEBUG_OBJECT (src, "buffering query in format %s",
gst_format_get_name (format));
@@ -1088,20 +1090,20 @@ gst_base_src_default_query (GstBaseSrc * src, GstQuery * query)
res = gst_pad_query_convert (src->srcpad, seg_format,
start, &format, &start);
- gst_query_set_buffering_range (query, format, start, stop, estimated);
+ gst_query_set_buffering_range (*query, format, start, stop, estimated);
break;
}
default:
res = FALSE;
break;
}
- GST_DEBUG_OBJECT (src, "query %s returns %d", GST_QUERY_TYPE_NAME (query),
+ GST_DEBUG_OBJECT (src, "query %s returns %d", GST_QUERY_TYPE_NAME (*query),
res);
return res;
}
static gboolean
-gst_base_src_query (GstPad * pad, GstQuery * query)
+gst_base_src_query (GstPad * pad, GstQuery ** query)
{
GstBaseSrc *src;
GstBaseSrcClass *bclass;
diff --git a/libs/gst/base/gstbasesrc.h b/libs/gst/base/gstbasesrc.h
index a492d105b..3e3891d4a 100644
--- a/libs/gst/base/gstbasesrc.h
+++ b/libs/gst/base/gstbasesrc.h
@@ -213,7 +213,7 @@ struct _GstBaseSrcClass {
gboolean (*unlock_stop) (GstBaseSrc *src);
/* notify subclasses of a query */
- gboolean (*query) (GstBaseSrc *src, GstQuery *query);
+ gboolean (*query) (GstBaseSrc *src, GstQuery ** query);
/* notify subclasses of an event */
gboolean (*event) (GstBaseSrc *src, GstEvent *event);
diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 1e37b7863..ab00048d7 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -328,7 +328,7 @@ static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps);
static gboolean gst_base_transform_setcaps (GstBaseTransform * trans,
GstPad * pad, GstCaps * caps, gboolean reconfigure);
-static gboolean gst_base_transform_query (GstPad * pad, GstQuery * query);
+static gboolean gst_base_transform_query (GstPad * pad, GstQuery ** query);
static const GstQueryType *gst_base_transform_query_type (GstPad * pad);
/* static guint gst_base_transform_signals[LAST_SIGNAL] = { 0 }; */
@@ -1209,7 +1209,7 @@ failed_configure:
}
static gboolean
-gst_base_transform_query (GstPad * pad, GstQuery * query)
+gst_base_transform_query (GstPad * pad, GstQuery ** query)
{
gboolean ret = FALSE;
GstBaseTransform *trans;
@@ -1220,11 +1220,11 @@ gst_base_transform_query (GstPad * pad, GstQuery * query)
return FALSE;
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
- switch (GST_QUERY_TYPE (query)) {
+ switch (GST_QUERY_TYPE (*query)) {
case GST_QUERY_POSITION:{
GstFormat format;
- gst_query_parse_position (query, &format, NULL);
+ gst_query_parse_position (*query, &format, NULL);
if (format == GST_FORMAT_TIME && trans->segment.format == GST_FORMAT_TIME) {
gint64 pos;
ret = TRUE;
@@ -1238,7 +1238,7 @@ gst_base_transform_query (GstPad * pad, GstQuery * query)
pos = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
trans->priv->last_stop_out);
}
- gst_query_set_position (query, format, pos);
+ gst_query_set_position (*query, format, pos);
} else {
ret = gst_pad_peer_query (otherpad, query);
}