mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:26:14 +00:00
ext/vorbis/vorbisenc.c: Implement position and duration queries.
Original commit message from CVS: * ext/vorbis/vorbisenc.c: (gst_vorbisenc_get_query_types), (gst_vorbisenc_src_query): Implement position and duration queries. * gst/playback/test3.c: (update_scale), (main): Fix for async state changes and print nicer output.
This commit is contained in:
parent
42f0462534
commit
a04b000bf4
3 changed files with 68 additions and 45 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-10-20 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_get_query_types),
|
||||||
|
(gst_vorbisenc_src_query):
|
||||||
|
Implement position and duration queries.
|
||||||
|
|
||||||
|
* gst/playback/test3.c: (update_scale), (main):
|
||||||
|
Fix for async state changes and print nicer output.
|
||||||
|
|
||||||
2005-10-20 Wim Taymans <wim@fluendo.com>
|
2005-10-20 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
|
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
|
||||||
|
|
|
@ -405,6 +405,8 @@ gst_vorbisenc_get_query_types (GstPad * pad)
|
||||||
{
|
{
|
||||||
static const GstQueryType gst_vorbisenc_src_query_types[] = {
|
static const GstQueryType gst_vorbisenc_src_query_types[] = {
|
||||||
GST_QUERY_POSITION,
|
GST_QUERY_POSITION,
|
||||||
|
GST_QUERY_DURATION,
|
||||||
|
GST_QUERY_CONVERT,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -416,52 +418,50 @@ gst_vorbisenc_src_query (GstPad * pad, GstQuery * query)
|
||||||
{
|
{
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
GstVorbisEnc *vorbisenc;
|
GstVorbisEnc *vorbisenc;
|
||||||
|
GstPad *peerpad;
|
||||||
|
|
||||||
vorbisenc = GST_VORBISENC (GST_PAD_PARENT (pad));
|
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
|
||||||
|
peerpad = gst_pad_get_peer (GST_PAD (vorbisenc->sinkpad));
|
||||||
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
switch (GST_QUERY_TYPE (query)) {
|
||||||
case GST_QUERY_POSITION:
|
case GST_QUERY_POSITION:
|
||||||
{
|
{
|
||||||
#if 0
|
GstFormat fmt, req_fmt;
|
||||||
switch (*format) {
|
gint64 pos, val;
|
||||||
case GST_FORMAT_BYTES:
|
|
||||||
case GST_FORMAT_TIME:
|
|
||||||
{
|
|
||||||
gint64 peer_value;
|
|
||||||
const GstFormat *peer_formats;
|
|
||||||
|
|
||||||
res = FALSE;
|
gst_query_parse_position (query, &req_fmt, NULL);
|
||||||
|
if ((res = gst_pad_query_position (peerpad, &req_fmt, &val))) {
|
||||||
peer_formats =
|
gst_query_set_position (query, req_fmt, val);
|
||||||
gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad));
|
break;
|
||||||
|
}
|
||||||
while (peer_formats && *peer_formats && !res) {
|
|
||||||
|
fmt = GST_FORMAT_TIME;
|
||||||
GstFormat peer_format = *peer_formats;
|
if (!(res = gst_pad_query_position (peerpad, &fmt, &pos)))
|
||||||
|
break;
|
||||||
/* do the probe */
|
|
||||||
if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad),
|
if ((res = gst_pad_query_convert (peerpad, fmt, pos, &req_fmt, &val))) {
|
||||||
GST_QUERY_TOTAL, &peer_format, &peer_value)) {
|
gst_query_set_position (query, req_fmt, val);
|
||||||
GstFormat conv_format;
|
}
|
||||||
|
break;
|
||||||
/* convert to TIME */
|
}
|
||||||
conv_format = GST_FORMAT_TIME;
|
case GST_QUERY_DURATION:
|
||||||
res = gst_vorbisenc_convert_sink (vorbisenc->sinkpad,
|
{
|
||||||
peer_format, peer_value, &conv_format, value);
|
GstFormat fmt, req_fmt;
|
||||||
/* and to final format */
|
gint64 dur, val;
|
||||||
res &= gst_vorbisenc_convert_src (pad,
|
|
||||||
GST_FORMAT_TIME, *value, format, value);
|
gst_query_parse_duration (query, &req_fmt, NULL);
|
||||||
}
|
if ((res = gst_pad_query_duration (peerpad, &req_fmt, &val))) {
|
||||||
peer_formats++;
|
gst_query_set_duration (query, req_fmt, val);
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
default:
|
fmt = GST_FORMAT_TIME;
|
||||||
res = FALSE;
|
if (!(res = gst_pad_query_duration (peerpad, &fmt, &dur)))
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case GST_QUERY_CONVERT:
|
case GST_QUERY_CONVERT:
|
||||||
|
@ -483,6 +483,8 @@ gst_vorbisenc_src_query (GstPad * pad, GstQuery * query)
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
gst_object_unref (peerpad);
|
||||||
|
gst_object_unref (vorbisenc);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,26 @@
|
||||||
static gboolean
|
static gboolean
|
||||||
update_scale (GstElement * element)
|
update_scale (GstElement * element)
|
||||||
{
|
{
|
||||||
gint64 duration;
|
gint64 duration = -1;
|
||||||
gint64 position;
|
gint64 position = -1;
|
||||||
GstFormat format = GST_FORMAT_TIME;
|
GstFormat format = GST_FORMAT_TIME;
|
||||||
|
gchar dur_str[32], pos_str[32];
|
||||||
|
|
||||||
gst_element_query_position (element, &format, &position);
|
if (gst_element_query_position (element, &format, &position) &&
|
||||||
gst_element_query_duration (element, &format, &duration);
|
position != -1) {
|
||||||
|
g_snprintf (pos_str, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (position));
|
||||||
|
} else {
|
||||||
|
g_snprintf (pos_str, 32, "-:--:--.---------");
|
||||||
|
}
|
||||||
|
|
||||||
g_print ("%" G_GINT64_FORMAT " %" G_GINT64_FORMAT "\n", duration, position);
|
if (gst_element_query_duration (element, &format, &duration) &&
|
||||||
|
duration != -1) {
|
||||||
|
g_snprintf (dur_str, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (duration));
|
||||||
|
} else {
|
||||||
|
g_snprintf (dur_str, 32, "-:--:--.---------");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print ("%s / %s\n", pos_str, dur_str);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +61,7 @@ main (gint argc, gchar * argv[])
|
||||||
g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
|
g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
|
||||||
|
|
||||||
res = gst_element_set_state (player, GST_STATE_PLAYING);
|
res = gst_element_set_state (player, GST_STATE_PLAYING);
|
||||||
if (res != GST_STATE_CHANGE_SUCCESS) {
|
if (res == GST_STATE_CHANGE_FAILURE) {
|
||||||
g_print ("could not play\n");
|
g_print ("could not play\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue