From: <tho...@fr...> - 2005-11-21 22:57:01
|
CVS Root: /cvs/gstreamer Module: gst-plugins-base Changes by: thomasvs Date: Mon Nov 21 2005 14:56:46 PST Log message: add a method that returns a proper GstClockTime Modified files: . : ChangeLog check : Makefile.am gst-libs/gst/audio: audio.c audio.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.2115&r2=1.2116 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/check/Makefile.am.diff?r1=1.16&r2=1.17 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/audio/audio.c.diff?r1=1.23&r2=1.24 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/audio/audio.h.diff?r1=1.20&r2=1.21 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v retrieving revision 1.2115 retrieving revision 1.2116 diff -u -d -r1.2115 -r1.2116 --- ChangeLog 21 Nov 2005 20:28:22 -0000 1.2115 +++ ChangeLog 21 Nov 2005 22:56:33 -0000 1.2116 @@ -1,3 +1,10 @@ +2005-11-21 Thomas Vander Stichele <thomas at apestaart dot org> + + * check/Makefile.am: + * gst-libs/gst/audio/audio.c: (gst_audio_duration_from_pad_buffer): + * gst-libs/gst/audio/audio.h: + add a method that returns a proper GstClockTime 2005-11-21 Tim-Philipp Müller <tim at centricular dot net> * gst-libs/gst/interfaces/xoverlay.c: (gst_x_overlay_base_init), Index: Makefile.am RCS file: /cvs/gstreamer/gst-plugins-base/check/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Makefile.am 18 Oct 2005 11:13:34 -0000 1.16 +++ Makefile.am 21 Nov 2005 22:56:33 -0000 1.17 @@ -31,6 +31,7 @@ elements/audioconvert \ elements/audioresample \ elements/volume \ + generic/states \ pipelines/simple_launch_lines \ clocks/selection \ $(check_vorbis) @@ -38,12 +39,11 @@ # tests to fix leaks in VALGRIND_TO_FIX = \ pipelines/simple_launch_lines # these tests don't even pass -# generic/states: elements need state fixin' before this can be added -noinst_PROGRAMS = \ - generic/states +noinst_PROGRAMS = AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) Index: audio.c RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/audio/audio.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- audio.c 19 Oct 2005 17:02:46 -0000 1.23 +++ audio.c 21 Nov 2005 22:56:33 -0000 1.24 @@ -147,6 +147,49 @@ return length; } +double +gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf) +{ +/* calculate length in nanoseconds + * of audio buffer buf + * based on capabilities of pad + */ + long bytes = 0; + int width = 0; + int channels = 0; + int rate = 0; + GstClockTime length; + const GstCaps *caps = NULL; + GstStructure *structure; + g_assert (GST_IS_BUFFER (buf)); + /* get caps of pad */ + caps = GST_PAD_CAPS (pad); + if (caps == NULL) { + /* ERROR: could not get caps of pad */ + g_warning ("gstaudio: could not get caps of pad %s:%s\n", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); + length = GST_CLOCK_TIME_NONE; + } else { + structure = gst_caps_get_structure (caps, 0); + bytes = GST_BUFFER_SIZE (buf); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "channels", &channels); + gst_structure_get_int (structure, "rate", &rate); + g_assert (bytes != 0); + g_assert (width != 0); + g_assert (channels != 0); + g_assert (rate != 0); + length = (bytes * 8.0 * GST_SECOND) / (rate * channels * width); + } + /* g_print ("DEBUG: audio: returning length of %f\n", length); */ + return length; +} long gst_audio_highest_sample_value (GstPad * pad) /* calculate highest possible sample value Index: audio.h RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/audio/audio.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- audio.h 19 Oct 2005 17:02:46 -0000 1.20 +++ audio.h 21 Nov 2005 22:56:33 -0000 1.21 @@ -110,6 +110,8 @@ /* calculate length in seconds of audio buffer buf based on caps of pad */ double gst_audio_length (GstPad* pad, GstBuffer* buf); +double gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf); /* calculate highest possible sample value based on capabilities of pad */ long gst_audio_highest_sample_value (GstPad* pad); |