2005-08-23 19:29:38 +00:00
|
|
|
/* GStreamer
|
2005-08-24 14:08:58 +00:00
|
|
|
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
2005-08-23 19:29:38 +00:00
|
|
|
* Copyright (C) 2003,2004 David A. Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
/* Element-Checklist-Version: 5 */
|
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-audioresample
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* Audioresample resamples raw audio buffers to different sample rates using
|
|
|
|
* a configurable windowing function to enhance quality.
|
|
|
|
* <title>Example launch line</title>
|
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
|
|
|
* gst-launch -v filesrc location=sine.ogg ! oggdemux ! vorbisdec ! audioconvert ! audioresample ! audio/x-raw-int, rate=8000 ! alsasink
|
|
|
|
* </programlisting>
|
|
|
|
* Decode an Ogg/Vorbis downsample to 8Khz and play sound through alsa.
|
|
|
|
* To create the Ogg/Vorbis file refer to the documentation of vorbisenc.
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*
|
|
|
|
* Last reviewed on 2006-03-02 (0.10.4)
|
|
|
|
*/
|
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2005-08-24 14:08:58 +00:00
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
/*#define DEBUG_ENABLED */
|
|
|
|
#include "gstaudioresample.h"
|
|
|
|
#include <gst/audio/audio.h>
|
2005-08-24 14:08:58 +00:00
|
|
|
#include <gst/base/gstbasetransform.h>
|
2005-08-23 19:29:38 +00:00
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:02 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (audioresample_debug);
|
2005-08-23 19:29:38 +00:00
|
|
|
#define GST_CAT_DEFAULT audioresample_debug
|
|
|
|
|
|
|
|
/* elementfactory information */
|
2006-04-28 19:46:36 +00:00
|
|
|
static const GstElementDetails gst_audioresample_details =
|
2005-08-23 19:29:38 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Audio scaler",
|
|
|
|
"Filter/Converter/Audio",
|
|
|
|
"Resample audio",
|
|
|
|
"David Schleef <ds@schleef.org>");
|
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
#define DEFAULT_FILTERLEN 16
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
enum
|
|
|
|
{
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_FILTERLEN
|
2005-08-23 19:29:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SUPPORTED_CAPS \
|
2005-08-25 12:31:31 +00:00
|
|
|
GST_STATIC_CAPS ( \
|
2005-08-23 19:29:38 +00:00
|
|
|
"audio/x-raw-int, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"width = (int) 16, " \
|
|
|
|
"depth = (int) 16, " \
|
2006-04-28 14:17:00 +00:00
|
|
|
"signed = (boolean) true;" \
|
|
|
|
"audio/x-raw-int, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"width = (int) 32, " \
|
|
|
|
"depth = (int) 32, " \
|
|
|
|
"signed = (boolean) true;" \
|
|
|
|
"audio/x-raw-float, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"width = (int) 32; " \
|
|
|
|
"audio/x-raw-float, " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, MAX ], " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"width = (int) 64" \
|
2005-08-25 12:31:31 +00:00
|
|
|
)
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static GstStaticPadTemplate gst_audioresample_sink_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK, GST_PAD_ALWAYS, SUPPORTED_CAPS);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static GstStaticPadTemplate gst_audioresample_src_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC, GST_PAD_ALWAYS, SUPPORTED_CAPS);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static void gst_audioresample_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_audioresample_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
/* vmethods */
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean audioresample_get_unit_size (GstBaseTransform * base,
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
GstCaps * caps, guint * size);
|
2007-04-21 14:14:24 +00:00
|
|
|
static GstCaps *audioresample_transform_caps (GstBaseTransform * base,
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps);
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean audioresample_transform_size (GstBaseTransform * trans,
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
GstPadDirection direction, GstCaps * incaps, guint insize,
|
|
|
|
GstCaps * outcaps, guint * outsize);
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean audioresample_set_caps (GstBaseTransform * base,
|
|
|
|
GstCaps * incaps, GstCaps * outcaps);
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static GstFlowReturn audioresample_pushthrough (GstAudioresample *
|
|
|
|
audioresample);
|
|
|
|
static GstFlowReturn audioresample_transform (GstBaseTransform * base,
|
|
|
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
|
|
|
static gboolean audioresample_event (GstBaseTransform * base, GstEvent * event);
|
2006-06-16 15:17:44 +00:00
|
|
|
static gboolean audioresample_start (GstBaseTransform * base);
|
|
|
|
static gboolean audioresample_stop (GstBaseTransform * base);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2007-11-23 10:21:11 +00:00
|
|
|
static gboolean audioresample_query (GstPad * pad, GstQuery * query);
|
|
|
|
static const GstQueryType *audioresample_query_type (GstPad * pad);
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
#define DEBUG_INIT(bla) \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (audioresample_debug, "audioresample", 0, "audio resampling element");
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_BOILERPLATE_FULL (GstAudioresample, gst_audioresample, GstBaseTransform,
|
|
|
|
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static void
|
|
|
|
gst_audioresample_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_audioresample_src_template));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_audioresample_sink_template));
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
gst_element_class_set_details (gstelement_class, &gst_audioresample_details);
|
|
|
|
}
|
2005-08-24 14:08:58 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static void
|
|
|
|
gst_audioresample_class_init (GstAudioresampleClass * klass)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_audioresample_set_property;
|
|
|
|
gobject_class->get_property = gst_audioresample_get_property;
|
|
|
|
|
2006-06-22 10:10:51 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_FILTERLEN,
|
2008-03-22 15:00:47 +00:00
|
|
|
g_param_spec_int ("filter-length", "filter length",
|
|
|
|
"Length of the resample filter", 0, G_MAXINT, DEFAULT_FILTERLEN,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-06-16 15:17:44 +00:00
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->start =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_start);
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->stop =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_stop);
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_size =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_transform_size);
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_get_unit_size);
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_transform_caps);
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_set_caps);
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->transform =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_transform);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->event =
|
|
|
|
GST_DEBUG_FUNCPTR (audioresample_event);
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
|
|
|
|
GST_BASE_TRANSFORM_CLASS (klass)->passthrough_on_same_caps = TRUE;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
static void
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
gst_audioresample_init (GstAudioresample * audioresample,
|
2005-08-28 17:52:45 +00:00
|
|
|
GstAudioresampleClass * klass)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GstBaseTransform *trans;
|
|
|
|
|
|
|
|
trans = GST_BASE_TRANSFORM (audioresample);
|
|
|
|
|
|
|
|
/* buffer alloc passthrough is too impossible. FIXME, it
|
2006-10-28 16:00:51 +00:00
|
|
|
* is trivial in the passthrough case. */
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
gst_pad_set_bufferalloc_function (trans->sinkpad, NULL);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-06-16 15:17:44 +00:00
|
|
|
audioresample->filter_length = DEFAULT_FILTERLEN;
|
2007-03-14 17:16:30 +00:00
|
|
|
|
|
|
|
audioresample->need_discont = FALSE;
|
2007-11-23 10:21:11 +00:00
|
|
|
|
|
|
|
gst_pad_set_query_function (trans->srcpad, audioresample_query);
|
|
|
|
gst_pad_set_query_type_function (trans->srcpad, audioresample_query_type);
|
2006-06-16 15:17:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vmethods */
|
|
|
|
static gboolean
|
|
|
|
audioresample_start (GstBaseTransform * base)
|
|
|
|
{
|
|
|
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
|
|
|
|
|
|
|
audioresample->resample = resample_new ();
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
audioresample->ts_offset = -1;
|
|
|
|
audioresample->offset = -1;
|
|
|
|
audioresample->next_ts = -1;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-06-16 15:17:44 +00:00
|
|
|
resample_set_filter_length (audioresample->resample,
|
|
|
|
audioresample->filter_length);
|
|
|
|
|
|
|
|
return TRUE;
|
2005-08-24 14:08:58 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 15:17:44 +00:00
|
|
|
static gboolean
|
|
|
|
audioresample_stop (GstBaseTransform * base)
|
2005-08-24 14:08:58 +00:00
|
|
|
{
|
2006-06-16 15:17:44 +00:00
|
|
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
if (audioresample->resample) {
|
|
|
|
resample_free (audioresample->resample);
|
|
|
|
audioresample->resample = NULL;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
2005-08-24 14:08:58 +00:00
|
|
|
|
2006-07-28 17:17:24 +00:00
|
|
|
gst_caps_replace (&audioresample->sinkcaps, NULL);
|
|
|
|
gst_caps_replace (&audioresample->srccaps, NULL);
|
|
|
|
|
2006-06-16 15:17:44 +00:00
|
|
|
return TRUE;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
|
|
|
|
guint * size)
|
|
|
|
{
|
2005-08-24 14:08:58 +00:00
|
|
|
gint width, channels;
|
|
|
|
GstStructure *structure;
|
|
|
|
gboolean ret;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-08-20 13:05:43 +00:00
|
|
|
g_assert (size);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
/* this works for both float and int */
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
ret = gst_structure_get_int (structure, "width", &width);
|
|
|
|
ret &= gst_structure_get_int (structure, "channels", &channels);
|
|
|
|
g_return_val_if_fail (ret, FALSE);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
*size = width * channels / 8;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
return TRUE;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 14:14:24 +00:00
|
|
|
static GstCaps *
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_transform_caps (GstBaseTransform * base,
|
2005-08-24 14:08:58 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GstCaps *res;
|
2005-08-23 19:29:38 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
/* transform caps gives one single caps so we can just replace
|
|
|
|
* the rate property with our range. */
|
|
|
|
res = gst_caps_copy (caps);
|
|
|
|
structure = gst_caps_get_structure (res, 0);
|
|
|
|
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
return res;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
static gboolean
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
resample_set_state_from_caps (ResampleState * state, GstCaps * incaps,
|
2005-08-24 14:08:58 +00:00
|
|
|
GstCaps * outcaps, gint * channels, gint * inrate, gint * outrate)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
gboolean ret;
|
2005-08-24 14:08:58 +00:00
|
|
|
gint myinrate, myoutrate;
|
|
|
|
int mychannels;
|
2006-04-28 14:17:00 +00:00
|
|
|
gint width, depth;
|
|
|
|
ResampleFormat format;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_DEBUG ("incaps %" GST_PTR_FORMAT ", outcaps %"
|
|
|
|
GST_PTR_FORMAT, incaps, outcaps);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
structure = gst_caps_get_structure (incaps, 0);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-04-28 14:17:00 +00:00
|
|
|
/* get width */
|
|
|
|
ret = gst_structure_get_int (structure, "width", &width);
|
|
|
|
if (!ret)
|
|
|
|
goto no_width;
|
|
|
|
|
|
|
|
/* figure out the format */
|
2005-08-24 14:08:58 +00:00
|
|
|
if (g_str_equal (gst_structure_get_name (structure), "audio/x-raw-float")) {
|
2006-04-28 14:17:00 +00:00
|
|
|
if (width == 32)
|
|
|
|
format = RESAMPLE_FORMAT_F32;
|
|
|
|
else if (width == 64)
|
|
|
|
format = RESAMPLE_FORMAT_F64;
|
|
|
|
else
|
|
|
|
goto wrong_depth;
|
2005-08-24 14:08:58 +00:00
|
|
|
} else {
|
2006-04-28 14:17:00 +00:00
|
|
|
/* for int, depth and width must be the same */
|
|
|
|
ret = gst_structure_get_int (structure, "depth", &depth);
|
|
|
|
if (!ret || width != depth)
|
|
|
|
goto not_equal;
|
|
|
|
|
|
|
|
if (width == 16)
|
|
|
|
format = RESAMPLE_FORMAT_S16;
|
|
|
|
else if (width == 32)
|
|
|
|
format = RESAMPLE_FORMAT_S32;
|
|
|
|
else
|
|
|
|
goto wrong_depth;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
2005-08-24 14:08:58 +00:00
|
|
|
ret = gst_structure_get_int (structure, "rate", &myinrate);
|
|
|
|
ret &= gst_structure_get_int (structure, "channels", &mychannels);
|
2006-04-28 14:17:00 +00:00
|
|
|
if (!ret)
|
|
|
|
goto no_in_rate_channels;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
structure = gst_caps_get_structure (outcaps, 0);
|
|
|
|
ret = gst_structure_get_int (structure, "rate", &myoutrate);
|
2006-04-28 14:17:00 +00:00
|
|
|
if (!ret)
|
|
|
|
goto no_out_rate;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
if (channels)
|
|
|
|
*channels = mychannels;
|
|
|
|
if (inrate)
|
|
|
|
*inrate = myinrate;
|
|
|
|
if (outrate)
|
|
|
|
*outrate = myoutrate;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2006-04-28 14:17:00 +00:00
|
|
|
resample_set_format (state, format);
|
2005-08-24 14:08:58 +00:00
|
|
|
resample_set_n_channels (state, mychannels);
|
|
|
|
resample_set_input_rate (state, myinrate);
|
|
|
|
resample_set_output_rate (state, myoutrate);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
return TRUE;
|
2006-04-28 14:17:00 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_width:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("failed to get width from caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
not_equal:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("width %d and depth %d must be the same", width, depth);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wrong_depth:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("unknown depth %d found", depth);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
no_in_rate_channels:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("could not get input rate and channels");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
no_out_rate:
|
|
|
|
{
|
|
|
|
GST_DEBUG ("could not get output rate");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_transform_size (GstBaseTransform * base,
|
2005-08-24 14:08:58 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps,
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
guint * othersize)
|
|
|
|
{
|
2005-08-24 14:08:58 +00:00
|
|
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
|
|
|
ResampleState *state;
|
|
|
|
GstCaps *srccaps, *sinkcaps;
|
|
|
|
gboolean use_internal = FALSE; /* whether we use the internal state */
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
GST_LOG_OBJECT (base, "asked to transform size %d in direction %s",
|
2005-08-25 12:31:31 +00:00
|
|
|
size, direction == GST_PAD_SINK ? "SINK" : "SRC");
|
2005-08-24 14:08:58 +00:00
|
|
|
if (direction == GST_PAD_SINK) {
|
|
|
|
sinkcaps = caps;
|
|
|
|
srccaps = othercaps;
|
|
|
|
} else {
|
|
|
|
sinkcaps = othercaps;
|
|
|
|
srccaps = caps;
|
|
|
|
}
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
/* if the caps are the ones that _set_caps got called with; we can use
|
|
|
|
* our own state; otherwise we'll have to create a state */
|
|
|
|
if (gst_caps_is_equal (sinkcaps, audioresample->sinkcaps) &&
|
|
|
|
gst_caps_is_equal (srccaps, audioresample->srccaps)) {
|
|
|
|
use_internal = TRUE;
|
|
|
|
state = audioresample->resample;
|
|
|
|
} else {
|
2005-08-25 12:31:31 +00:00
|
|
|
GST_DEBUG_OBJECT (audioresample,
|
|
|
|
"caps are not the set caps, creating state");
|
2005-08-24 14:08:58 +00:00
|
|
|
state = resample_new ();
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
resample_set_filter_length (state, audioresample->filter_length);
|
2005-08-24 14:08:58 +00:00
|
|
|
resample_set_state_from_caps (state, sinkcaps, srccaps, NULL, NULL, NULL);
|
|
|
|
}
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
if (direction == GST_PAD_SINK) {
|
|
|
|
/* asked to convert size of an incoming buffer */
|
|
|
|
*othersize = resample_get_output_size_for_input (state, size);
|
|
|
|
} else {
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
/* asked to convert size of an outgoing buffer */
|
|
|
|
*othersize = resample_get_input_size_for_output (state, size);
|
2005-08-24 14:08:58 +00:00
|
|
|
}
|
2005-08-26 17:35:28 +00:00
|
|
|
g_assert (*othersize % state->sample_size == 0);
|
|
|
|
|
2005-08-25 12:31:31 +00:00
|
|
|
/* we make room for one extra sample, given that the resampling filter
|
|
|
|
* can output an extra one for non-integral i_rate/o_rate */
|
2007-03-14 17:16:30 +00:00
|
|
|
GST_LOG_OBJECT (base, "transformed size %d to %d", size, *othersize);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
if (!use_internal) {
|
|
|
|
resample_free (state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 14:14:24 +00:00
|
|
|
static gboolean
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
|
|
|
GstCaps * outcaps)
|
|
|
|
{
|
2005-08-24 14:08:58 +00:00
|
|
|
gboolean ret;
|
|
|
|
gint inrate, outrate;
|
|
|
|
int channels;
|
|
|
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_DEBUG_OBJECT (base, "incaps %" GST_PTR_FORMAT ", outcaps %"
|
|
|
|
GST_PTR_FORMAT, incaps, outcaps);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
ret = resample_set_state_from_caps (audioresample->resample, incaps, outcaps,
|
|
|
|
&channels, &inrate, &outrate);
|
|
|
|
|
|
|
|
g_return_val_if_fail (ret, FALSE);
|
|
|
|
|
|
|
|
audioresample->channels = channels;
|
|
|
|
GST_DEBUG_OBJECT (audioresample, "set channels to %d", channels);
|
|
|
|
audioresample->i_rate = inrate;
|
|
|
|
GST_DEBUG_OBJECT (audioresample, "set i_rate to %d", inrate);
|
|
|
|
audioresample->o_rate = outrate;
|
|
|
|
GST_DEBUG_OBJECT (audioresample, "set o_rate to %d", outrate);
|
|
|
|
|
|
|
|
/* save caps so we can short-circuit in the size_transform if the caps
|
|
|
|
* are the same */
|
|
|
|
gst_caps_replace (&audioresample->sinkcaps, incaps);
|
|
|
|
gst_caps_replace (&audioresample->srccaps, outcaps);
|
|
|
|
|
|
|
|
return TRUE;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static gboolean
|
|
|
|
audioresample_event (GstBaseTransform * base, GstEvent * event)
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
{
|
|
|
|
GstAudioresample *audioresample;
|
|
|
|
|
|
|
|
audioresample = GST_AUDIORESAMPLE (base);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_FLUSH_START:
|
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
resample_input_flush (audioresample->resample);
|
|
|
|
audioresample->ts_offset = -1;
|
|
|
|
audioresample->next_ts = -1;
|
|
|
|
audioresample->offset = -1;
|
|
|
|
break;
|
|
|
|
case GST_EVENT_NEWSEGMENT:
|
|
|
|
resample_input_pushthrough (audioresample->resample);
|
|
|
|
audioresample_pushthrough (audioresample);
|
|
|
|
audioresample->ts_offset = -1;
|
|
|
|
audioresample->next_ts = -1;
|
|
|
|
audioresample->offset = -1;
|
|
|
|
break;
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
resample_input_eos (audioresample->resample);
|
|
|
|
audioresample_pushthrough (audioresample);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
parent_class->event (base, event);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
static GstFlowReturn
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_do_output (GstAudioresample * audioresample, GstBuffer * outbuf)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
|
|
|
int outsize;
|
2005-08-25 15:44:58 +00:00
|
|
|
int outsamples;
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
ResampleState *r;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
r = audioresample->resample;
|
|
|
|
|
|
|
|
outsize = resample_get_output_size (r);
|
2007-03-14 17:16:30 +00:00
|
|
|
GST_LOG_OBJECT (audioresample, "audioresample can give me %d bytes", outsize);
|
2005-08-25 12:31:31 +00:00
|
|
|
|
|
|
|
/* protect against mem corruption */
|
|
|
|
if (outsize > GST_BUFFER_SIZE (outbuf)) {
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_WARNING_OBJECT (audioresample,
|
|
|
|
"overriding audioresample's outsize %d with outbuffer's size %d",
|
|
|
|
outsize, GST_BUFFER_SIZE (outbuf));
|
|
|
|
outsize = GST_BUFFER_SIZE (outbuf);
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
2005-08-25 12:31:31 +00:00
|
|
|
/* catch possibly wrong size differences */
|
|
|
|
if (GST_BUFFER_SIZE (outbuf) - outsize > r->sample_size) {
|
|
|
|
GST_WARNING_OBJECT (audioresample,
|
|
|
|
"audioresample's outsize %d too far from outbuffer's size %d",
|
|
|
|
outsize, GST_BUFFER_SIZE (outbuf));
|
|
|
|
}
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
outsize = resample_get_output_data (r, GST_BUFFER_DATA (outbuf), outsize);
|
2005-08-25 15:44:58 +00:00
|
|
|
outsamples = outsize / r->sample_size;
|
|
|
|
GST_LOG_OBJECT (audioresample, "resample gave me %d bytes or %d samples",
|
|
|
|
outsize, outsamples);
|
|
|
|
|
2005-08-25 17:20:02 +00:00
|
|
|
GST_BUFFER_OFFSET (outbuf) = audioresample->offset;
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = audioresample->next_ts;
|
|
|
|
|
|
|
|
if (audioresample->ts_offset != -1) {
|
|
|
|
audioresample->offset += outsamples;
|
|
|
|
audioresample->ts_offset += outsamples;
|
|
|
|
audioresample->next_ts =
|
|
|
|
gst_util_uint64_scale_int (audioresample->ts_offset, GST_SECOND,
|
|
|
|
audioresample->o_rate);
|
|
|
|
GST_BUFFER_OFFSET_END (outbuf) = audioresample->offset;
|
|
|
|
|
|
|
|
/* we calculate DURATION as the difference between "next" timestamp
|
|
|
|
* and current timestamp so we ensure a contiguous stream, instead of
|
|
|
|
* having rounding errors. */
|
|
|
|
GST_BUFFER_DURATION (outbuf) = audioresample->next_ts -
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf);
|
|
|
|
} else {
|
|
|
|
/* no valid offset know, we can still sortof calculate the duration though */
|
|
|
|
GST_BUFFER_DURATION (outbuf) =
|
|
|
|
gst_util_uint64_scale_int (outsamples, GST_SECOND,
|
|
|
|
audioresample->o_rate);
|
|
|
|
}
|
2005-08-25 17:20:02 +00:00
|
|
|
|
2005-08-25 12:31:31 +00:00
|
|
|
/* check for possible mem corruption */
|
|
|
|
if (outsize > GST_BUFFER_SIZE (outbuf)) {
|
|
|
|
/* this is an error that when it happens, would need fixing in the
|
2007-03-14 14:09:21 +00:00
|
|
|
* resample library; we told it we wanted only GST_BUFFER_SIZE (outbuf),
|
|
|
|
* and it gave us more ! */
|
2005-08-25 12:31:31 +00:00
|
|
|
GST_WARNING_OBJECT (audioresample,
|
|
|
|
"audioresample, you memory corrupting bastard. "
|
|
|
|
"you gave me outsize %d while my buffer was size %d",
|
|
|
|
outsize, GST_BUFFER_SIZE (outbuf));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
/* catch possibly wrong size differences */
|
|
|
|
if (GST_BUFFER_SIZE (outbuf) - outsize > r->sample_size) {
|
2005-08-24 14:08:58 +00:00
|
|
|
GST_WARNING_OBJECT (audioresample,
|
2005-08-25 12:31:31 +00:00
|
|
|
"audioresample's written outsize %d too far from outbuffer's size %d",
|
2005-08-24 14:08:58 +00:00
|
|
|
outsize, GST_BUFFER_SIZE (outbuf));
|
|
|
|
}
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = outsize;
|
2005-08-24 14:08:58 +00:00
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
if (G_UNLIKELY (audioresample->need_discont)) {
|
|
|
|
GST_DEBUG_OBJECT (audioresample,
|
|
|
|
"marking this buffer with the DISCONT flag");
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
audioresample->need_discont = FALSE;
|
|
|
|
}
|
|
|
|
|
2007-04-16 22:20:03 +00:00
|
|
|
GST_LOG_OBJECT (audioresample, "transformed to buffer of %d bytes, ts %"
|
2007-03-14 14:09:21 +00:00
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT ", offset %"
|
|
|
|
G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
|
|
|
|
outsize, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
|
|
|
|
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
|
|
|
|
|
|
|
|
|
2005-08-24 14:08:58 +00:00
|
|
|
return GST_FLOW_OK;
|
2005-08-23 19:29:38 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 10:52:21 +00:00
|
|
|
static gboolean
|
|
|
|
audioresample_check_discont (GstAudioresample * audioresample,
|
|
|
|
GstClockTime timestamp)
|
|
|
|
{
|
|
|
|
if (timestamp != GST_CLOCK_TIME_NONE &&
|
|
|
|
audioresample->prev_ts != GST_CLOCK_TIME_NONE &&
|
|
|
|
audioresample->prev_duration != GST_CLOCK_TIME_NONE &&
|
|
|
|
timestamp != audioresample->prev_ts + audioresample->prev_duration) {
|
|
|
|
/* Potentially a discontinuous buffer. However, it turns out that many
|
|
|
|
* elements generate imperfect streams due to rounding errors, so we permit
|
|
|
|
* a small error (up to one sample) without triggering a filter
|
|
|
|
* flush/restart (if triggered incorrectly, this will be audible) */
|
|
|
|
GstClockTimeDiff diff = timestamp -
|
|
|
|
(audioresample->prev_ts + audioresample->prev_duration);
|
|
|
|
|
2007-04-27 15:33:46 +00:00
|
|
|
if (ABS (diff) > GST_SECOND / audioresample->i_rate) {
|
2007-03-15 10:52:21 +00:00
|
|
|
GST_WARNING_OBJECT (audioresample,
|
|
|
|
"encountered timestamp discontinuity of %" G_GINT64_FORMAT, diff);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
static GstFlowReturn
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
GstBuffer * outbuf)
|
|
|
|
{
|
|
|
|
GstAudioresample *audioresample;
|
|
|
|
ResampleState *r;
|
2005-12-15 10:30:14 +00:00
|
|
|
guchar *data, *datacopy;
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
gulong size;
|
|
|
|
GstClockTime timestamp;
|
|
|
|
|
|
|
|
audioresample = GST_AUDIORESAMPLE (base);
|
|
|
|
r = audioresample->resample;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (inbuf);
|
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
|
2007-03-14 14:09:21 +00:00
|
|
|
GST_LOG_OBJECT (audioresample, "transforming buffer of %ld bytes, ts %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT ", offset %"
|
|
|
|
G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
|
|
|
|
size, GST_TIME_ARGS (timestamp),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (inbuf)),
|
|
|
|
GST_BUFFER_OFFSET (inbuf), GST_BUFFER_OFFSET_END (inbuf));
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
/* check for timestamp discontinuities and flush/reset if needed */
|
2007-03-15 10:52:21 +00:00
|
|
|
if (G_UNLIKELY (audioresample_check_discont (audioresample, timestamp))) {
|
|
|
|
/* Flush internal samples */
|
|
|
|
audioresample_pushthrough (audioresample);
|
|
|
|
/* Inform downstream element about discontinuity */
|
|
|
|
audioresample->need_discont = TRUE;
|
|
|
|
/* We want to recalculate the offset */
|
|
|
|
audioresample->ts_offset = -1;
|
2007-03-14 17:16:30 +00:00
|
|
|
}
|
|
|
|
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
if (audioresample->ts_offset == -1) {
|
|
|
|
/* if we don't know the initial offset yet, calculate it based on the
|
|
|
|
* input timestamp. */
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
|
|
|
GstClockTime stime;
|
|
|
|
|
2007-03-14 14:09:21 +00:00
|
|
|
/* offset used to calculate the timestamps. We use the sample offset for
|
|
|
|
* this to make it more accurate. We want the first buffer to have the
|
|
|
|
* same timestamp as the incoming timestamp. */
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
audioresample->next_ts = timestamp;
|
|
|
|
audioresample->ts_offset =
|
|
|
|
gst_util_uint64_scale_int (timestamp, r->o_rate, GST_SECOND);
|
2007-03-14 14:09:21 +00:00
|
|
|
/* offset used to set as the buffer offset, this offset is always
|
|
|
|
* relative to the stream time, note that timestamp is not... */
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
stime = (timestamp - base->segment.start) + base->segment.time;
|
|
|
|
audioresample->offset =
|
|
|
|
gst_util_uint64_scale_int (stime, r->o_rate, GST_SECOND);
|
|
|
|
}
|
|
|
|
}
|
2007-03-14 17:16:30 +00:00
|
|
|
audioresample->prev_ts = timestamp;
|
|
|
|
audioresample->prev_duration = GST_BUFFER_DURATION (inbuf);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
|
|
|
/* need to memdup, resample takes ownership. */
|
2005-12-15 10:30:14 +00:00
|
|
|
datacopy = g_memdup (data, size);
|
|
|
|
resample_add_input_data (r, datacopy, size, g_free, datacopy);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
|
|
|
return audioresample_do_output (audioresample, outbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* push remaining data in the buffers out */
|
|
|
|
static GstFlowReturn
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample_pushthrough (GstAudioresample * audioresample)
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
{
|
|
|
|
int outsize;
|
|
|
|
ResampleState *r;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
GstFlowReturn res = GST_FLOW_OK;
|
|
|
|
GstBaseTransform *trans;
|
|
|
|
|
|
|
|
r = audioresample->resample;
|
|
|
|
|
|
|
|
outsize = resample_get_output_size (r);
|
2007-03-14 17:16:30 +00:00
|
|
|
if (outsize == 0) {
|
|
|
|
GST_DEBUG_OBJECT (audioresample, "no internal buffers needing flush");
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
goto done;
|
2007-03-14 17:16:30 +00:00
|
|
|
}
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
trans = GST_BASE_TRANSFORM (audioresample);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
res = gst_pad_alloc_buffer (trans->srcpad, GST_BUFFER_OFFSET_NONE, outsize,
|
|
|
|
GST_PAD_CAPS (trans->srcpad), &outbuf);
|
|
|
|
if (G_UNLIKELY (res != GST_FLOW_OK)) {
|
|
|
|
GST_WARNING_OBJECT (audioresample, "failed allocating buffer of %d bytes",
|
|
|
|
outsize);
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
goto done;
|
2007-03-14 17:16:30 +00:00
|
|
|
}
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2007-03-14 17:16:30 +00:00
|
|
|
res = audioresample_do_output (audioresample, outbuf);
|
|
|
|
if (G_UNLIKELY (res != GST_FLOW_OK))
|
|
|
|
goto done;
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
|
|
|
res = gst_pad_push (trans->srcpad, outbuf);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-23 10:21:11 +00:00
|
|
|
static gboolean
|
|
|
|
audioresample_query (GstPad * pad, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstAudioresample *audioresample =
|
|
|
|
GST_AUDIORESAMPLE (gst_pad_get_parent (pad));
|
|
|
|
GstBaseTransform *trans = GST_BASE_TRANSFORM (audioresample);
|
|
|
|
gboolean res = TRUE;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:
|
|
|
|
{
|
|
|
|
GstClockTime min, max;
|
|
|
|
gboolean live;
|
|
|
|
guint64 latency;
|
|
|
|
GstPad *peer;
|
|
|
|
gint rate = audioresample->i_rate;
|
|
|
|
gint resampler_latency = audioresample->filter_length / 2;
|
|
|
|
|
|
|
|
if (gst_base_transform_is_passthrough (trans))
|
|
|
|
resampler_latency = 0;
|
|
|
|
|
|
|
|
if ((peer = gst_pad_get_peer (trans->sinkpad))) {
|
|
|
|
if ((res = gst_pad_query (peer, query))) {
|
|
|
|
gst_query_parse_latency (query, &live, &min, &max);
|
|
|
|
|
|
|
|
GST_DEBUG ("Peer latency: min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
|
|
|
|
|
|
|
/* add our own latency */
|
|
|
|
if (rate != 0 && resampler_latency != 0)
|
|
|
|
latency =
|
|
|
|
gst_util_uint64_scale (resampler_latency, GST_SECOND, rate);
|
|
|
|
else
|
|
|
|
latency = 0;
|
|
|
|
|
|
|
|
GST_DEBUG ("Our latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (latency));
|
|
|
|
|
|
|
|
min += latency;
|
|
|
|
if (max != GST_CLOCK_TIME_NONE)
|
|
|
|
max += latency;
|
|
|
|
|
|
|
|
GST_DEBUG ("Calculated total latency : min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
|
|
|
|
|
|
|
gst_query_set_latency (query, live, min, max);
|
|
|
|
}
|
|
|
|
gst_object_unref (peer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = gst_pad_query_default (pad, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_object_unref (audioresample);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GstQueryType *
|
|
|
|
audioresample_query_type (GstPad * pad)
|
|
|
|
{
|
|
|
|
static const GstQueryType types[] = {
|
|
|
|
GST_QUERY_LATENCY,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
return types;
|
|
|
|
}
|
gst/audioresample/: Fix audioresample, seek torture, new segments, reverse negotiation etc.. work fine.
Original commit message from CVS:
* gst/audioresample/buffer.c: (audioresample_buffer_queue_flush):
* gst/audioresample/buffer.h:
* gst/audioresample/gstaudioresample.c:
* gst/audioresample/gstaudioresample.h:
* gst/audioresample/resample.c: (resample_input_flush),
(resample_input_pushthrough), (resample_input_eos),
(resample_get_output_size_for_input),
(resample_get_input_size_for_output), (resample_get_output_size),
(resample_get_output_data):
* gst/audioresample/resample.h:
* gst/audioresample/resample_ref.c: (resample_scale_ref):
Fix audioresample, seek torture, new segments, reverse negotiation
etc.. work fine.
2005-12-02 11:34:50 +00:00
|
|
|
|
2005-08-23 19:29:38 +00:00
|
|
|
static void
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
gst_audioresample_set_property (GObject * object, guint prop_id,
|
2005-08-23 19:29:38 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-08-24 14:08:58 +00:00
|
|
|
GstAudioresample *audioresample;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
audioresample = GST_AUDIORESAMPLE (object);
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
case PROP_FILTERLEN:
|
2005-08-23 19:29:38 +00:00
|
|
|
audioresample->filter_length = g_value_get_int (value);
|
2005-08-25 12:31:31 +00:00
|
|
|
GST_DEBUG_OBJECT (GST_ELEMENT (audioresample), "new filter length %d",
|
2005-08-23 19:29:38 +00:00
|
|
|
audioresample->filter_length);
|
2006-06-16 15:17:44 +00:00
|
|
|
if (audioresample->resample) {
|
|
|
|
resample_set_filter_length (audioresample->resample,
|
|
|
|
audioresample->filter_length);
|
2007-11-23 10:21:11 +00:00
|
|
|
gst_element_post_message (GST_ELEMENT (audioresample),
|
|
|
|
gst_message_new_latency (GST_OBJECT (audioresample)));
|
2006-06-16 15:17:44 +00:00
|
|
|
}
|
2005-08-23 19:29:38 +00:00
|
|
|
break;
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2005-08-23 19:29:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
gst_audioresample_get_property (GObject * object, guint prop_id,
|
2005-08-23 19:29:38 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-08-24 14:08:58 +00:00
|
|
|
GstAudioresample *audioresample;
|
2005-08-23 19:29:38 +00:00
|
|
|
|
|
|
|
audioresample = GST_AUDIORESAMPLE (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
case PROP_FILTERLEN:
|
2005-08-23 19:29:38 +00:00
|
|
|
g_value_set_int (value, audioresample->filter_length);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
2005-08-23 19:29:38 +00:00
|
|
|
{
|
|
|
|
resample_init ();
|
|
|
|
|
|
|
|
if (!gst_element_register (plugin, "audioresample", GST_RANK_PRIMARY,
|
|
|
|
GST_TYPE_AUDIORESAMPLE)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"audioresample",
|
2005-10-16 13:54:38 +00:00
|
|
|
"Resamples audio", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN);
|