diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2005-10-21 17:00:58 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2005-10-21 17:00:58 +0000 |
commit | 512eb8ab25fd06d9442a8d9a72a6b172551afddb (patch) | |
tree | 769fc3d3f98a143fc90b1980cd33adeb866a63ce /ext/speex/gstspeexenc.c | |
parent | bee54790e70e3ddf147b95a541cfc439e6caee0b (diff) |
ext/speex/gstspeexenc.c: Add position and duration query, fix query type function.
Original commit message from CVS:
* ext/speex/gstspeexenc.c: (gst_speexenc_get_query_types),
(gst_speexenc_src_query):
Add position and duration query, fix query type function.
* gst/matroska/matroska-demux.c: (gst_matroska_demux_add_stream),
(gst_matroska_demux_video_caps), (gst_matroska_demux_audio_caps):
Let's not set non-fixed caps on source pads.
Diffstat (limited to 'ext/speex/gstspeexenc.c')
-rw-r--r-- | ext/speex/gstspeexenc.c | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/ext/speex/gstspeexenc.c b/ext/speex/gstspeexenc.c index 8825c742..bd84ea7f 100644 --- a/ext/speex/gstspeexenc.c +++ b/ext/speex/gstspeexenc.c @@ -368,6 +368,8 @@ gst_speexenc_get_query_types (GstPad * pad) { static const GstQueryType gst_speexenc_src_query_types[] = { GST_QUERY_POSITION, + GST_QUERY_DURATION, + GST_QUERY_CONVERT, 0 }; @@ -379,48 +381,50 @@ gst_speexenc_src_query (GstPad * pad, GstQuery * query) { gboolean res = TRUE; GstSpeexEnc *speexenc; + GstPad *peerpad; - speexenc = GST_SPEEXENC (GST_PAD_PARENT (pad)); + speexenc = GST_SPEEXENC (gst_pad_get_parent (pad)); + peerpad = gst_pad_get_peer (GST_PAD (speexenc->sinkpad)); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { -#if 0 - switch (*format) { - case GST_FORMAT_BYTES: - case GST_FORMAT_TIME: - { - gint64 peer_value; - const GstFormat *peer_formats; + GstFormat fmt, req_fmt; + gint64 pos, val; - res = FALSE; + gst_query_parse_position (query, &req_fmt, NULL); + if ((res = gst_pad_query_position (peerpad, &req_fmt, &val))) { + gst_query_set_position (query, req_fmt, val); + break; + } + + fmt = GST_FORMAT_TIME; + if (!(res = gst_pad_query_position (peerpad, &fmt, &pos))) + break; - peer_formats = gst_pad_get_formats (GST_PAD_PEER (speexenc->sinkpad)); + if ((res = gst_pad_query_convert (peerpad, fmt, pos, &req_fmt, &val))) + gst_query_set_position (query, req_fmt, val); - while (peer_formats && *peer_formats && !res) { + break; + } + case GST_QUERY_DURATION: + { + GstFormat fmt, req_fmt; + gint64 dur, val; - GstFormat peer_format = *peer_formats; + gst_query_parse_duration (query, &req_fmt, NULL); + if ((res = gst_pad_query_duration (peerpad, &req_fmt, &val))) { + gst_query_set_duration (query, req_fmt, val); + break; + } - /* do the probe */ - if (gst_pad_query (GST_PAD_PEER (speexenc->sinkpad), - GST_QUERY_TOTAL, &peer_format, &peer_value)) { - GstFormat conv_format; + fmt = GST_FORMAT_TIME; + if (!(res = gst_pad_query_duration (peerpad, &fmt, &dur))) + break; - /* convert to TIME */ - conv_format = GST_FORMAT_TIME; - res = gst_pad_convert (speexenc->sinkpad, - peer_format, peer_value, &conv_format, value); - /* and to final format */ - res &= gst_pad_convert (pad, - GST_FORMAT_TIME, *value, format, value); - } - peer_formats++; - } - break; - } + if ((res = gst_pad_query_convert (peerpad, fmt, dur, &req_fmt, &val))) { + gst_query_set_duration (query, req_fmt, val); } -#endif - res = FALSE; break; } case GST_QUERY_CONVERT: @@ -441,6 +445,8 @@ gst_speexenc_src_query (GstPad * pad, GstQuery * query) } error: + gst_object_unref (peerpad); + gst_object_unref (speexenc); return res; } |