From: <tp...@fr...> - 2005-10-20 19:06:58
|
CVS Root: /cvs/gstreamer Module: gst-plugins-base Changes by: tpm Date: Thu Oct 20 2005 12:06:55 PDT Log message: * 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. Modified files: . : ChangeLog ext/vorbis : vorbisenc.c gst/playback : test3.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.2010&r2=1.2011 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ext/vorbis/vorbisenc.c.diff?r1=1.87&r2=1.88 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/test3.c.diff?r1=1.7&r2=1.8 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v retrieving revision 1.2010 retrieving revision 1.2011 diff -u -d -r1.2010 -r1.2011 --- ChangeLog 20 Oct 2005 17:42:57 -0000 1.2010 +++ ChangeLog 20 Oct 2005 19:06:42 -0000 1.2011 @@ -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 <wi...@fl...> * gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding), Index: vorbisenc.c RCS file: /cvs/gstreamer/gst-plugins-base/ext/vorbis/vorbisenc.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- vorbisenc.c 19 Oct 2005 17:02:46 -0000 1.87 +++ vorbisenc.c 20 Oct 2005 19:06:42 -0000 1.88 @@ -405,6 +405,8 @@ { static const GstQueryType gst_vorbisenc_src_query_types[] = { GST_QUERY_POSITION, + GST_QUERY_DURATION, + GST_QUERY_CONVERT, 0 }; @@ -416,52 +418,50 @@ gboolean res = TRUE; 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)) { 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; + } - peer_formats = - gst_pad_get_formats (GST_PAD_PEER (vorbisenc->sinkpad)); + fmt = GST_FORMAT_TIME; + if (!(res = gst_pad_query_position (peerpad, &fmt, &pos))) - while (peer_formats && *peer_formats && !res) { + if ((res = gst_pad_query_convert (peerpad, fmt, pos, &req_fmt, &val))) { + break; + } + case GST_QUERY_DURATION: + { + 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); - /* do the probe */ - if (gst_pad_query (GST_PAD_PEER (vorbisenc->sinkpad), - GST_QUERY_TOTAL, &peer_format, &peer_value)) { - GstFormat conv_format; + if (!(res = gst_pad_query_duration (peerpad, &fmt, &dur))) - /* convert to TIME */ - conv_format = GST_FORMAT_TIME; - res = gst_vorbisenc_convert_sink (vorbisenc->sinkpad, - peer_format, peer_value, &conv_format, value); - /* and to final format */ - res &= gst_vorbisenc_convert_src (pad, - GST_FORMAT_TIME, *value, format, value); - } - peer_formats++; - } - break; - } - default: + if ((res = gst_pad_query_convert (peerpad, fmt, dur, &req_fmt, &val))) { } -#endif - res = FALSE; break; } case GST_QUERY_CONVERT: @@ -483,6 +483,8 @@ } error: + gst_object_unref (peerpad); + gst_object_unref (vorbisenc); return res; } Index: test3.c RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/test3.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- test3.c 19 Oct 2005 15:55:33 -0000 1.7 +++ test3.c 20 Oct 2005 19:06:43 -0000 1.8 @@ -23,14 +23,26 @@ static gboolean update_scale (GstElement * element) - gint64 duration; - gint64 position; + gint64 duration = -1; + gint64 position = -1; GstFormat format = GST_FORMAT_TIME; + gchar dur_str[32], pos_str[32]; - gst_element_query_position (element, &format, &position); - gst_element_query_duration (element, &format, &duration); + if (gst_element_query_position (element, &format, &position) && + 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)); + g_snprintf (dur_str, 32, "-:--:--.---------"); + g_print ("%s / %s\n", pos_str, dur_str); return TRUE; @@ -49,7 +61,7 @@ g_object_set (G_OBJECT (player), "uri", argv[1], NULL); 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"); return -1; |