2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-20 22:30:14 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-20 22:30:14 +00:00
|
|
|
*/
|
|
|
|
|
2005-09-15 15:28:36 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-vorbisenc
|
|
|
|
* @see_also: vorbisdec, oggmux
|
|
|
|
*
|
|
|
|
* This element encodes raw float audio into a Vorbis stream.
|
|
|
|
* <ulink url="http://www.vorbis.com/">Vorbis</ulink> is a royalty-free
|
|
|
|
* audio codec maintained by the <ulink url="http://www.xiph.org/">Xiph.org
|
|
|
|
* Foundation</ulink>.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
2005-09-15 15:28:36 +00:00
|
|
|
* <title>Example pipelines</title>
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2005-11-23 15:36:58 +00:00
|
|
|
* gst-launch -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! vorbisenc ! oggmux ! filesink location=sine.ogg
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| Encode a test sine signal to Ogg/Vorbis. Note that the resulting file
|
|
|
|
* will be really small because a sine signal compresses very well.
|
|
|
|
* |[
|
2005-09-15 15:28:36 +00:00
|
|
|
* gst-launch -v alsasrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=alsasrc.ogg
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| Record from a sound card using ALSA and encode to Ogg/Vorbis.
|
2006-03-01 17:39:28 +00:00
|
|
|
* </refsect2>
|
2005-08-20 20:40:25 +00:00
|
|
|
*
|
2006-03-01 17:39:28 +00:00
|
|
|
* Last reviewed on 2006-03-01 (0.10.4)
|
2005-08-20 20:40:25 +00:00
|
|
|
*/
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2009-02-24 13:36:39 +00:00
|
|
|
|
2001-12-20 22:30:14 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-11-02 08:07:22 +00:00
|
|
|
#include <time.h>
|
2001-12-20 22:30:14 +00:00
|
|
|
#include <vorbis/vorbisenc.h>
|
|
|
|
|
2005-09-07 13:55:08 +00:00
|
|
|
#include <gst/gsttagsetter.h>
|
2004-02-22 15:14:25 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2009-05-06 12:19:34 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2009-02-24 13:36:39 +00:00
|
|
|
#include "gstvorbisenc.h"
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2010-01-14 09:05:35 +00:00
|
|
|
#include "gstvorbiscommon.h"
|
|
|
|
|
ext/: remove explicit newmedia support from oggmux and vorbisenc add debug category to vorbisenc
Original commit message from CVS:
2004-09-22 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/ogg/gstoggmux.c: (gst_ogg_mux_init),
(gst_ogg_mux_next_buffer), (gst_ogg_mux_loop):
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_init),
(gst_vorbisenc_chain):
* ext/vorbis/vorbisenc.h:
remove explicit newmedia support from oggmux and vorbisenc
add debug category to vorbisenc
* gst/multifilesink/gstmultifilesink.c:
(gst_multifilesink_class_init), (gst_multifilesink_init),
(gst_multifilesink_dispose), (gst_multifilesink_set_location),
(gst_multifilesink_set_property), (gst_multifilesink_next_file),
(gst_multifilesink_handle_event), (gst_multifilesink_chain),
(plugin_init):
* gst/multifilesink/gstmultifilesink.h:
add support for streamheader in multifilesink
2004-09-22 14:35:13 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (vorbisenc_debug);
|
|
|
|
#define GST_CAT_DEFAULT vorbisenc_debug
|
|
|
|
|
2008-12-12 07:17:21 +00:00
|
|
|
static GstStaticPadTemplate vorbis_enc_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-08-19 15:41:22 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw, "
|
|
|
|
"format = (string) " GST_AUDIO_NE (F32) ", "
|
2011-12-31 13:25:09 +00:00
|
|
|
"layout = (string) interleaved, "
|
2011-11-26 12:12:59 +00:00
|
|
|
"rate = (int) [ 1, 200000 ], " "channels = (int) [ 1, 255 ]")
|
2008-12-12 07:17:21 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate vorbis_enc_src_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-01-26 10:01:12 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-vorbis, "
|
|
|
|
"rate = (int) [ 1, 200000 ], " "channels = (int) [ 1, 255 ]")
|
2008-12-12 07:17:21 +00:00
|
|
|
);
|
|
|
|
|
2001-12-21 01:14:21 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-20 22:30:14 +00:00
|
|
|
ARG_0,
|
2002-10-20 01:55:28 +00:00
|
|
|
ARG_MAX_BITRATE,
|
2001-12-20 22:30:14 +00:00
|
|
|
ARG_BITRATE,
|
2002-10-20 01:55:28 +00:00
|
|
|
ARG_MIN_BITRATE,
|
|
|
|
ARG_QUALITY,
|
|
|
|
ARG_MANAGED,
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_LAST_MESSAGE
|
2001-12-20 22:30:14 +00:00
|
|
|
};
|
|
|
|
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
static GstFlowReturn gst_vorbis_enc_output_buffers (GstVorbisEnc * vorbisenc);
|
2005-09-15 19:59:50 +00:00
|
|
|
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
#define MAX_BITRATE_DEFAULT -1
|
|
|
|
#define BITRATE_DEFAULT -1
|
|
|
|
#define MIN_BITRATE_DEFAULT -1
|
|
|
|
#define QUALITY_DEFAULT 0.3
|
|
|
|
#define LOWEST_BITRATE 6000 /* lowest allowed for a 8 kHz stream */
|
|
|
|
#define HIGHEST_BITRATE 250001 /* highest allowed for a 44 kHz stream */
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
static gboolean gst_vorbis_enc_start (GstAudioEncoder * enc);
|
|
|
|
static gboolean gst_vorbis_enc_stop (GstAudioEncoder * enc);
|
|
|
|
static gboolean gst_vorbis_enc_set_format (GstAudioEncoder * enc,
|
|
|
|
GstAudioInfo * info);
|
|
|
|
static GstFlowReturn gst_vorbis_enc_handle_frame (GstAudioEncoder * enc,
|
|
|
|
GstBuffer * in_buf);
|
2011-10-08 08:19:06 +00:00
|
|
|
static GstCaps *gst_vorbis_enc_getcaps (GstAudioEncoder * enc,
|
|
|
|
GstCaps * filter);
|
2011-10-05 13:43:35 +00:00
|
|
|
static gboolean gst_vorbis_enc_sink_event (GstAudioEncoder * enc,
|
|
|
|
GstEvent * event);
|
|
|
|
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
static gboolean gst_vorbis_enc_setup (GstVorbisEnc * vorbisenc);
|
2002-10-20 01:55:28 +00:00
|
|
|
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
static void gst_vorbis_enc_dispose (GObject * object);
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
static void gst_vorbis_enc_get_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:34 +00:00
|
|
|
GValue * value, GParamSpec * pspec);
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
static void gst_vorbis_enc_set_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:34 +00:00
|
|
|
const GValue * value, GParamSpec * pspec);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
#define gst_vorbis_enc_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstVorbisEnc, gst_vorbis_enc,
|
2011-10-08 08:19:06 +00:00
|
|
|
GST_TYPE_AUDIO_ENCODER, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
static void
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_class_init (GstVorbisEncClass * klass)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2011-10-05 13:43:35 +00:00
|
|
|
GstAudioEncoderClass *base_class;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2001-12-21 01:14:21 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2011-10-05 13:43:35 +00:00
|
|
|
base_class = (GstAudioEncoderClass *) (klass);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gobject_class->set_property = gst_vorbis_enc_set_property;
|
|
|
|
gobject_class->get_property = gst_vorbis_enc_get_property;
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
gobject_class->dispose = gst_vorbis_enc_dispose;
|
2005-03-31 09:43:49 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_BITRATE,
|
2004-06-24 14:56:21 +00:00
|
|
|
g_param_spec_int ("max-bitrate", "Maximum Bitrate",
|
2004-10-18 13:55:48 +00:00
|
|
|
"Specify a maximum bitrate (in bps). Useful for streaming "
|
|
|
|
"applications. (-1 == disabled)",
|
2008-03-22 15:00:53 +00:00
|
|
|
-1, HIGHEST_BITRATE, MAX_BITRATE_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
|
2004-06-24 14:56:21 +00:00
|
|
|
g_param_spec_int ("bitrate", "Target Bitrate",
|
2004-10-18 13:55:48 +00:00
|
|
|
"Attempt to encode at a bitrate averaging this (in bps). "
|
|
|
|
"This uses the bitrate management engine, and is not recommended for most users. "
|
2008-03-22 15:00:53 +00:00
|
|
|
"Quality is a better alternative. (-1 == disabled)", -1,
|
|
|
|
HIGHEST_BITRATE, BITRATE_DEFAULT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MIN_BITRATE,
|
2008-03-22 15:00:53 +00:00
|
|
|
g_param_spec_int ("min-bitrate", "Minimum Bitrate",
|
2004-10-18 13:55:48 +00:00
|
|
|
"Specify a minimum bitrate (in bps). Useful for encoding for a "
|
2008-03-22 15:00:53 +00:00
|
|
|
"fixed-size channel. (-1 == disabled)", -1, HIGHEST_BITRATE,
|
|
|
|
MIN_BITRATE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
|
|
|
|
g_param_spec_float ("quality", "Quality",
|
2008-03-22 15:00:53 +00:00
|
|
|
"Specify quality instead of specifying a particular bitrate.", -0.1,
|
|
|
|
1.0, QUALITY_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:34 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MANAGED,
|
|
|
|
g_param_spec_boolean ("managed", "Managed",
|
2008-03-22 15:00:53 +00:00
|
|
|
"Enable bitrate management engine", FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2002-10-20 01:55:28 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
|
2004-03-14 22:34:34 +00:00
|
|
|
g_param_spec_string ("last-message", "last-message",
|
2008-03-22 15:00:53 +00:00
|
|
|
"The last status message", NULL,
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&vorbis_enc_src_factory));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&vorbis_enc_sink_factory));
|
2011-10-08 08:19:06 +00:00
|
|
|
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2011-04-19 12:11:32 +00:00
|
|
|
"Vorbis audio encoder", "Codec/Encoder/Audio",
|
|
|
|
"Encodes audio in Vorbis format",
|
|
|
|
"Monty <monty@xiph.org>, " "Wim Taymans <wim@fluendo.com>");
|
|
|
|
|
2011-10-08 08:19:06 +00:00
|
|
|
base_class->start = GST_DEBUG_FUNCPTR (gst_vorbis_enc_start);
|
|
|
|
base_class->stop = GST_DEBUG_FUNCPTR (gst_vorbis_enc_stop);
|
|
|
|
base_class->set_format = GST_DEBUG_FUNCPTR (gst_vorbis_enc_set_format);
|
|
|
|
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_vorbis_enc_handle_frame);
|
|
|
|
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_vorbis_enc_getcaps);
|
2012-03-30 10:16:57 +00:00
|
|
|
base_class->sink_event = GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_event);
|
2011-10-05 13:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-10-08 08:19:06 +00:00
|
|
|
gst_vorbis_enc_init (GstVorbisEnc * vorbisenc)
|
2011-10-05 13:43:35 +00:00
|
|
|
{
|
|
|
|
GstAudioEncoder *enc = GST_AUDIO_ENCODER (vorbisenc);
|
|
|
|
|
|
|
|
vorbisenc->channels = -1;
|
|
|
|
vorbisenc->frequency = -1;
|
|
|
|
|
|
|
|
vorbisenc->managed = FALSE;
|
|
|
|
vorbisenc->max_bitrate = MAX_BITRATE_DEFAULT;
|
|
|
|
vorbisenc->bitrate = BITRATE_DEFAULT;
|
|
|
|
vorbisenc->min_bitrate = MIN_BITRATE_DEFAULT;
|
|
|
|
vorbisenc->quality = QUALITY_DEFAULT;
|
|
|
|
vorbisenc->quality_set = FALSE;
|
|
|
|
vorbisenc->last_message = NULL;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* arrange granulepos marking (and required perfect ts) */
|
|
|
|
gst_audio_encoder_set_mark_granule (enc, TRUE);
|
|
|
|
gst_audio_encoder_set_perfect_timestamp (enc, TRUE);
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
static void
|
|
|
|
gst_vorbis_enc_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstVorbisEnc *vorbisenc = GST_VORBISENC (object);
|
|
|
|
|
|
|
|
if (vorbisenc->sinkcaps) {
|
|
|
|
gst_caps_unref (vorbisenc->sinkcaps);
|
|
|
|
vorbisenc->sinkcaps = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vorbis_enc_start (GstAudioEncoder * enc)
|
|
|
|
{
|
|
|
|
GstVorbisEnc *vorbisenc = GST_VORBISENC (enc);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (enc, "start");
|
2011-10-30 11:09:10 +00:00
|
|
|
vorbisenc->tags = gst_tag_list_new_empty ();
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc->header_sent = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_vorbis_enc_stop (GstAudioEncoder * enc)
|
|
|
|
{
|
|
|
|
GstVorbisEnc *vorbisenc = GST_VORBISENC (enc);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (enc, "stop");
|
|
|
|
vorbis_block_clear (&vorbisenc->vb);
|
|
|
|
vorbis_dsp_clear (&vorbisenc->vd);
|
|
|
|
vorbis_info_clear (&vorbisenc->vi);
|
|
|
|
g_free (vorbisenc->last_message);
|
|
|
|
vorbisenc->last_message = NULL;
|
2012-09-14 15:53:21 +00:00
|
|
|
gst_tag_list_unref (vorbisenc->tags);
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc->tags = NULL;
|
|
|
|
|
2011-11-16 18:00:44 +00:00
|
|
|
gst_tag_setter_reset_tags (GST_TAG_SETTER (enc));
|
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_vorbis_enc_generate_sink_caps (void)
|
|
|
|
{
|
|
|
|
GstCaps *caps = gst_caps_new_empty ();
|
|
|
|
int i, c;
|
|
|
|
|
2011-08-19 15:41:22 +00:00
|
|
|
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw",
|
|
|
|
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
2011-12-31 13:25:09 +00:00
|
|
|
"layout", G_TYPE_STRING, "interleaved",
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
"rate", GST_TYPE_INT_RANGE, 1, 200000,
|
2011-08-19 15:41:22 +00:00
|
|
|
"channels", G_TYPE_INT, 1, NULL));
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
|
2011-12-20 11:08:53 +00:00
|
|
|
for (i = 2; i <= 8; i++) {
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
GstStructure *structure;
|
2011-12-20 11:08:53 +00:00
|
|
|
guint64 channel_mask = 0;
|
|
|
|
const GstAudioChannelPosition *pos = gst_vorbis_channel_positions[i - 1];
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
|
|
|
|
for (c = 0; c < i; c++) {
|
2012-04-11 15:40:04 +00:00
|
|
|
channel_mask |= G_GUINT64_CONSTANT (1) << pos[c];
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 15:41:22 +00:00
|
|
|
structure = gst_structure_new ("audio/x-raw",
|
|
|
|
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
2011-12-31 13:25:09 +00:00
|
|
|
"layout", G_TYPE_STRING, "interleaved",
|
2011-12-20 11:08:53 +00:00
|
|
|
"rate", GST_TYPE_INT_RANGE, 1, 200000, "channels", G_TYPE_INT, i,
|
|
|
|
"channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
|
|
|
|
gst_caps_append_structure (caps, structure);
|
|
|
|
}
|
|
|
|
|
2011-08-19 15:41:22 +00:00
|
|
|
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw",
|
|
|
|
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
2011-12-31 13:25:09 +00:00
|
|
|
"layout", G_TYPE_STRING, "interleaved",
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
"rate", GST_TYPE_INT_RANGE, 1, 200000,
|
2011-12-20 11:08:53 +00:00
|
|
|
"channels", GST_TYPE_INT_RANGE, 9, 255,
|
|
|
|
"channel-mask", GST_TYPE_BITMASK, G_GUINT64_CONSTANT (0), NULL));
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
2011-10-08 08:19:06 +00:00
|
|
|
gst_vorbis_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
{
|
2011-10-05 13:43:35 +00:00
|
|
|
GstVorbisEnc *vorbisenc = GST_VORBISENC (enc);
|
2011-11-10 14:37:02 +00:00
|
|
|
GstCaps *caps;
|
ext/vorbis/vorbisenc.*: Multi-channel caps negotiation, so we can do proper multichannel vorbis encoding, negotiated ...
Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (raw_caps_factory),
(gst_vorbis_enc_class_init), (gst_vorbis_enc_dispose),
(gst_vorbis_enc_generate_sink_caps), (gst_vorbis_enc_sink_getcaps),
(gst_vorbis_enc_init), (gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_chain), (gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Multi-channel caps negotiation, so we can do proper multichannel
vorbis encoding, negotiated through audioconvert.
2006-05-30 13:22:58 +00:00
|
|
|
|
|
|
|
if (vorbisenc->sinkcaps == NULL)
|
|
|
|
vorbisenc->sinkcaps = gst_vorbis_enc_generate_sink_caps ();
|
|
|
|
|
2011-11-10 14:37:02 +00:00
|
|
|
if (filter) {
|
|
|
|
GstCaps *int_caps = gst_caps_intersect_full (filter, vorbisenc->sinkcaps,
|
|
|
|
GST_CAPS_INTERSECT_FIRST);
|
2012-07-25 12:56:35 +00:00
|
|
|
caps = gst_audio_encoder_proxy_getcaps (enc, int_caps, filter);
|
2011-11-10 14:37:02 +00:00
|
|
|
gst_caps_unref (int_caps);
|
|
|
|
} else {
|
2012-07-25 12:56:35 +00:00
|
|
|
caps = gst_audio_encoder_proxy_getcaps (enc, vorbisenc->sinkcaps, filter);
|
2011-11-10 14:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
2002-10-20 17:11:10 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 09:25:44 +00:00
|
|
|
static gint64
|
|
|
|
gst_vorbis_enc_get_latency (GstVorbisEnc * vorbisenc)
|
|
|
|
{
|
|
|
|
/* FIXME, this probably depends on the bitrate and other setting but for now
|
|
|
|
* we return this value, which was obtained by totally unscientific
|
|
|
|
* measurements */
|
|
|
|
return 58 * GST_MSECOND;
|
|
|
|
}
|
|
|
|
|
2002-10-20 17:11:10 +00:00
|
|
|
static gboolean
|
2011-10-05 13:43:35 +00:00
|
|
|
gst_vorbis_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
|
2002-10-20 17:11:10 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *vorbisenc;
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc = GST_VORBISENC (enc);
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc->channels = GST_AUDIO_INFO_CHANNELS (info);
|
|
|
|
vorbisenc->frequency = GST_AUDIO_INFO_RATE (info);
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* if re-configured, we were drained and cleared already */
|
|
|
|
if (!gst_vorbis_enc_setup (vorbisenc))
|
|
|
|
return FALSE;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* feedback to base class */
|
|
|
|
gst_audio_encoder_set_latency (enc,
|
|
|
|
gst_vorbis_enc_get_latency (vorbisenc),
|
|
|
|
gst_vorbis_enc_get_latency (vorbisenc));
|
2002-10-20 01:55:28 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
return TRUE;
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 04:08:48 +00:00
|
|
|
static void
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_metadata_set1 (const GstTagList * list, const gchar * tag,
|
2004-03-14 22:34:34 +00:00
|
|
|
gpointer vorbisenc)
|
2002-10-20 01:55:28 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *enc = GST_VORBISENC (vorbisenc);
|
2006-08-21 16:39:25 +00:00
|
|
|
GList *vc_list, *l;
|
2003-11-24 04:08:48 +00:00
|
|
|
|
2006-08-21 16:39:25 +00:00
|
|
|
vc_list = gst_tag_to_vorbis_comments (list, tag);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2006-08-21 16:39:25 +00:00
|
|
|
for (l = vc_list; l != NULL; l = l->next) {
|
|
|
|
const gchar *vc_string = (const gchar *) l->data;
|
|
|
|
gchar *key = NULL, *val = NULL;
|
2006-02-05 22:44:55 +00:00
|
|
|
|
2006-09-23 13:21:07 +00:00
|
|
|
GST_LOG_OBJECT (vorbisenc, "vorbis comment: %s", vc_string);
|
2006-08-21 16:39:25 +00:00
|
|
|
if (gst_tag_parse_extended_comment (vc_string, &key, NULL, &val, TRUE)) {
|
|
|
|
vorbis_comment_add_tag (&enc->vc, key, val);
|
|
|
|
g_free (key);
|
|
|
|
g_free (val);
|
2003-11-24 04:08:48 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-21 16:39:25 +00:00
|
|
|
|
|
|
|
g_list_foreach (vc_list, (GFunc) g_free, NULL);
|
|
|
|
g_list_free (vc_list);
|
2003-11-24 04:08:48 +00:00
|
|
|
}
|
2004-02-22 15:14:25 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void
|
2006-08-21 16:39:25 +00:00
|
|
|
gst_vorbis_enc_set_metadata (GstVorbisEnc * enc)
|
2003-11-24 04:08:48 +00:00
|
|
|
{
|
2006-08-21 16:39:25 +00:00
|
|
|
GstTagList *merged_tags;
|
2003-11-24 04:08:48 +00:00
|
|
|
const GstTagList *user_tags;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2006-08-21 16:39:25 +00:00
|
|
|
vorbis_comment_init (&enc->vc);
|
|
|
|
|
|
|
|
user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (enc));
|
2002-10-20 01:55:28 +00:00
|
|
|
|
2006-08-21 16:39:25 +00:00
|
|
|
GST_DEBUG_OBJECT (enc, "upstream tags = %" GST_PTR_FORMAT, enc->tags);
|
|
|
|
GST_DEBUG_OBJECT (enc, "user-set tags = %" GST_PTR_FORMAT, user_tags);
|
|
|
|
|
|
|
|
/* gst_tag_list_merge() will handle NULL for either or both lists fine */
|
|
|
|
merged_tags = gst_tag_list_merge (user_tags, enc->tags,
|
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (enc)));
|
|
|
|
|
|
|
|
if (merged_tags) {
|
|
|
|
GST_DEBUG_OBJECT (enc, "merged tags = %" GST_PTR_FORMAT, merged_tags);
|
|
|
|
gst_tag_list_foreach (merged_tags, gst_vorbis_enc_metadata_set1, enc);
|
2012-09-14 15:53:21 +00:00
|
|
|
gst_tag_list_unref (merged_tags);
|
2006-08-21 16:39:25 +00:00
|
|
|
}
|
2002-10-20 01:55:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static gchar *
|
2005-08-20 20:40:25 +00:00
|
|
|
get_constraints_string (GstVorbisEnc * vorbisenc)
|
2002-10-20 01:55:28 +00:00
|
|
|
{
|
|
|
|
gint min = vorbisenc->min_bitrate;
|
|
|
|
gint max = vorbisenc->max_bitrate;
|
|
|
|
gchar *result;
|
|
|
|
|
|
|
|
if (min > 0 && max > 0)
|
2004-03-14 22:34:34 +00:00
|
|
|
result = g_strdup_printf ("(min %d bps, max %d bps)", min, max);
|
2002-10-20 01:55:28 +00:00
|
|
|
else if (min > 0)
|
|
|
|
result = g_strdup_printf ("(min %d bps, no max)", min);
|
|
|
|
else if (max > 0)
|
|
|
|
result = g_strdup_printf ("(no min, max %d bps)", max);
|
|
|
|
else
|
|
|
|
result = g_strdup_printf ("(no min or max)");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-12-20 22:30:14 +00:00
|
|
|
static void
|
2005-08-20 20:40:25 +00:00
|
|
|
update_start_message (GstVorbisEnc * vorbisenc)
|
2002-10-20 01:55:28 +00:00
|
|
|
{
|
|
|
|
gchar *constraints;
|
|
|
|
|
|
|
|
g_free (vorbisenc->last_message);
|
|
|
|
|
|
|
|
if (vorbisenc->bitrate > 0) {
|
|
|
|
if (vorbisenc->managed) {
|
|
|
|
constraints = get_constraints_string (vorbisenc);
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbisenc->last_message =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_strdup_printf ("encoding at average bitrate %d bps %s",
|
|
|
|
vorbisenc->bitrate, constraints);
|
2002-10-20 01:55:28 +00:00
|
|
|
g_free (constraints);
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
|
|
|
vorbisenc->last_message =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_strdup_printf
|
|
|
|
("encoding at approximate bitrate %d bps (VBR encoding enabled)",
|
|
|
|
vorbisenc->bitrate);
|
2002-10-20 01:55:28 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2002-10-20 01:55:28 +00:00
|
|
|
if (vorbisenc->quality_set) {
|
|
|
|
if (vorbisenc->managed) {
|
2004-03-15 19:32:28 +00:00
|
|
|
constraints = get_constraints_string (vorbisenc);
|
|
|
|
vorbisenc->last_message =
|
|
|
|
g_strdup_printf
|
|
|
|
("encoding at quality level %2.2f using constrained VBR %s",
|
|
|
|
vorbisenc->quality, constraints);
|
|
|
|
g_free (constraints);
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->last_message =
|
|
|
|
g_strdup_printf ("encoding at quality level %2.2f",
|
|
|
|
vorbisenc->quality);
|
2002-10-20 01:55:28 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2002-10-20 01:55:28 +00:00
|
|
|
constraints = get_constraints_string (vorbisenc);
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbisenc->last_message =
|
2004-03-15 19:32:28 +00:00
|
|
|
g_strdup_printf ("encoding using bitrate management %s", constraints);
|
2002-10-20 01:55:28 +00:00
|
|
|
g_free (constraints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (vorbisenc), "last_message");
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_setup (GstVorbisEnc * vorbisenc)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
2011-10-05 13:43:35 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (vorbisenc, "setup");
|
2004-05-24 19:19:29 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0
|
|
|
|
&& vorbisenc->max_bitrate < 0) {
|
2002-10-20 01:55:28 +00:00
|
|
|
vorbisenc->quality_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_start_message (vorbisenc);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2001-12-20 22:30:14 +00:00
|
|
|
/* choose an encoding mode */
|
|
|
|
/* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
|
2001-12-21 01:14:21 +00:00
|
|
|
vorbis_info_init (&vorbisenc->vi);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (vorbisenc->quality_set) {
|
|
|
|
if (vorbis_encode_setup_vbr (&vorbisenc->vi,
|
2004-05-24 19:19:29 +00:00
|
|
|
vorbisenc->channels, vorbisenc->frequency,
|
|
|
|
vorbisenc->quality) != 0) {
|
|
|
|
GST_ERROR_OBJECT (vorbisenc,
|
|
|
|
"vorbisenc: initialisation failed: invalid parameters for quality");
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_info_clear (&vorbisenc->vi);
|
|
|
|
return FALSE;
|
2002-10-20 01:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* do we have optional hard quality restrictions? */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (vorbisenc->max_bitrate > 0 || vorbisenc->min_bitrate > 0) {
|
2002-10-20 01:55:28 +00:00
|
|
|
struct ovectl_ratemanage_arg ai;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2002-10-20 01:55:28 +00:00
|
|
|
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_GET, &ai);
|
|
|
|
|
2005-11-21 15:16:29 +00:00
|
|
|
ai.bitrate_hard_min = vorbisenc->min_bitrate;
|
|
|
|
ai.bitrate_hard_max = vorbisenc->max_bitrate;
|
2002-10-20 01:55:28 +00:00
|
|
|
ai.management_active = 1;
|
|
|
|
|
|
|
|
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai);
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2004-06-24 15:44:53 +00:00
|
|
|
long min_bitrate, max_bitrate;
|
|
|
|
|
|
|
|
min_bitrate = vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1;
|
|
|
|
max_bitrate = vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (vorbis_encode_setup_managed (&vorbisenc->vi,
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->channels,
|
|
|
|
vorbisenc->frequency,
|
2004-06-24 15:44:53 +00:00
|
|
|
max_bitrate, vorbisenc->bitrate, min_bitrate) != 0) {
|
2004-05-24 19:19:29 +00:00
|
|
|
GST_ERROR_OBJECT (vorbisenc,
|
2004-06-24 15:44:53 +00:00
|
|
|
"vorbis_encode_setup_managed "
|
2006-10-05 15:55:21 +00:00
|
|
|
"(c %d, rate %d, max br %ld, br %d, min br %ld) failed",
|
2004-06-24 15:44:53 +00:00
|
|
|
vorbisenc->channels, vorbisenc->frequency, max_bitrate,
|
|
|
|
vorbisenc->bitrate, min_bitrate);
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_info_clear (&vorbisenc->vi);
|
2002-10-20 01:55:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (vorbisenc->managed && vorbisenc->bitrate < 0) {
|
|
|
|
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_AVG, NULL);
|
|
|
|
} else if (!vorbisenc->managed) {
|
2002-10-20 01:55:28 +00:00
|
|
|
/* Turn off management entirely (if it was turned on). */
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, NULL);
|
2002-10-20 01:55:28 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_encode_setup_init (&vorbisenc->vi);
|
2002-10-20 01:55:28 +00:00
|
|
|
|
2001-12-20 22:30:14 +00:00
|
|
|
/* set up the analysis state and auxiliary encoding storage */
|
2001-12-21 01:14:21 +00:00
|
|
|
vorbis_analysis_init (&vorbisenc->vd, &vorbisenc->vi);
|
|
|
|
vorbis_block_init (&vorbisenc->vd, &vorbisenc->vb);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* samples == granulepos start at 0 again */
|
|
|
|
vorbisenc->samples_out = 0;
|
2005-11-11 16:35:39 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* fresh encoder available */
|
2001-12-21 01:14:21 +00:00
|
|
|
vorbisenc->setup = TRUE;
|
2002-10-20 01:55:28 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 10:09:16 +00:00
|
|
|
static GstFlowReturn
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_clear (GstVorbisEnc * vorbisenc)
|
2005-09-22 14:35:57 +00:00
|
|
|
{
|
2005-11-21 10:09:16 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
|
2005-09-22 14:35:57 +00:00
|
|
|
if (vorbisenc->setup) {
|
|
|
|
vorbis_analysis_wrote (&vorbisenc->vd, 0);
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
ret = gst_vorbis_enc_output_buffers (vorbisenc);
|
2005-09-22 14:35:57 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/* marked EOS to encoder, recreate if needed */
|
2005-09-22 14:35:57 +00:00
|
|
|
vorbisenc->setup = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up and exit. vorbis_info_clear() must be called last */
|
|
|
|
vorbis_block_clear (&vorbisenc->vb);
|
|
|
|
vorbis_dsp_clear (&vorbisenc->vd);
|
|
|
|
vorbis_info_clear (&vorbisenc->vi);
|
|
|
|
|
2005-11-21 10:09:16 +00:00
|
|
|
return ret;
|
2005-09-22 14:35:57 +00:00
|
|
|
}
|
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
static GstBuffer *
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_buffer_from_header_packet (GstVorbisEnc * vorbisenc,
|
2006-01-30 15:01:28 +00:00
|
|
|
ogg_packet * packet)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
2012-07-23 08:30:40 +00:00
|
|
|
outbuf =
|
|
|
|
gst_audio_encoder_allocate_output_buffer (GST_AUDIO_ENCODER (vorbisenc),
|
|
|
|
packet->bytes);
|
2011-03-28 08:20:06 +00:00
|
|
|
gst_buffer_fill (outbuf, 0, packet->packet, packet->bytes);
|
2006-01-30 15:01:28 +00:00
|
|
|
GST_BUFFER_OFFSET (outbuf) = vorbisenc->bytes_out;
|
|
|
|
GST_BUFFER_OFFSET_END (outbuf) = 0;
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_CLOCK_TIME_NONE;
|
2013-03-03 17:42:50 +00:00
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_HEADER);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
2011-11-22 01:21:04 +00:00
|
|
|
GST_DEBUG ("created header packet buffer, %" G_GSIZE_FORMAT " bytes",
|
2011-03-28 08:20:06 +00:00
|
|
|
gst_buffer_get_size (outbuf));
|
2006-01-30 15:01:28 +00:00
|
|
|
return outbuf;
|
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static gboolean
|
2011-10-05 13:43:35 +00:00
|
|
|
gst_vorbis_enc_sink_event (GstAudioEncoder * enc, GstEvent * event)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *vorbisenc;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc = GST_VORBISENC (enc);
|
2005-03-31 09:43:49 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_TAG:
|
|
|
|
if (vorbisenc->tags) {
|
examples/seeking/seek.c: Update seek example.
Original commit message from CVS:
* examples/seeking/seek.c: (setup_dynamic_link),
(make_dv_pipeline), (make_vorbis_theora_pipeline), (query_rates),
(query_positions_elems), (query_positions_pads), (do_seek):
Update seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_event),
(gst_ogg_pad_typefind), (gst_ogg_demux_chain_elem_pad),
(gst_ogg_demux_queue_data), (gst_ogg_demux_chain_peer),
(gst_ogg_pad_submit_packet), (gst_ogg_pad_submit_page),
(gst_ogg_demux_handle_event),
(gst_ogg_demux_deactivate_current_chain),
(gst_ogg_demux_activate_chain), (gst_ogg_demux_perform_seek),
(gst_ogg_demux_collect_chain_info), (gst_ogg_demux_collect_info),
(gst_ogg_demux_chain), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
* ext/ogg/gstoggmux.c: (gst_ogg_mux_collected):
* ext/theora/theoradec.c: (theora_dec_src_event),
(theora_dec_src_getcaps), (theora_dec_sink_event),
(theora_dec_push), (theora_dec_chain):
* ext/vorbis/Makefile.am:
* ext/vorbis/vorbisdec.c: (vorbis_dec_src_event),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_sink_event),
(gst_vorbisenc_chain):
* gst/playback/gststreaminfo.c: (cb_probe):
* gst/subparse/gstsubparse.c: (gst_subparse_src_event):
* gst/videorate/gstvideorate.c: (gst_videorate_event):
* gst/videoscale/gstvideoscale.c:
(gst_videoscale_handle_src_event):
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_event):
* sys/ximage/ximagesink.c: (gst_ximagesink_show_frame),
(gst_ximagesink_navigation_send_event):
* sys/xvimage/xvimagesink.c:
(gst_xvimagesink_navigation_send_event):
Various event updates and cleanups
2005-07-27 18:34:29 +00:00
|
|
|
GstTagList *list;
|
|
|
|
|
|
|
|
gst_event_parse_tag (event, &list);
|
|
|
|
gst_tag_list_insert (vorbisenc->tags, list,
|
2005-11-22 12:34:27 +00:00
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (vorbisenc)));
|
2005-03-31 09:43:49 +00:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
break;
|
2008-10-08 12:08:01 +00:00
|
|
|
/* fall through */
|
2005-03-31 09:43:49 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-05 13:43:35 +00:00
|
|
|
|
|
|
|
/* we only peeked, let base class handle it */
|
2012-03-30 10:16:57 +00:00
|
|
|
return GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
2005-03-31 09:43:49 +00:00
|
|
|
}
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
/*
|
|
|
|
* (really really) FIXME: move into core (dixit tpm)
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* _gst_caps_set_buffer_array:
|
|
|
|
* @caps: a #GstCaps
|
|
|
|
* @field: field in caps to set
|
|
|
|
* @buf: header buffers
|
|
|
|
*
|
|
|
|
* Adds given buffers to an array of buffers set as the given @field
|
|
|
|
* on the given @caps. List of buffer arguments must be NULL-terminated.
|
|
|
|
*
|
|
|
|
* Returns: input caps with a streamheader field added, or NULL if some error
|
|
|
|
*/
|
|
|
|
static GstCaps *
|
|
|
|
_gst_caps_set_buffer_array (GstCaps * caps, const gchar * field,
|
|
|
|
GstBuffer * buf, ...)
|
|
|
|
{
|
|
|
|
GstStructure *structure = NULL;
|
|
|
|
va_list va;
|
|
|
|
GValue array = { 0 };
|
|
|
|
GValue value = { 0 };
|
|
|
|
|
|
|
|
g_return_val_if_fail (caps != NULL, NULL);
|
|
|
|
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
|
|
|
|
g_return_val_if_fail (field != NULL, NULL);
|
|
|
|
|
|
|
|
caps = gst_caps_make_writable (caps);
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
g_value_init (&array, GST_TYPE_ARRAY);
|
|
|
|
|
|
|
|
va_start (va, buf);
|
|
|
|
/* put buffers in a fixed list */
|
|
|
|
while (buf) {
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
gst_value_set_buffer (&value, buf);
|
|
|
|
gst_value_array_append_value (&array, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
|
|
|
buf = va_arg (va, GstBuffer *);
|
2006-07-28 12:48:21 +00:00
|
|
|
}
|
|
|
|
|
2013-03-03 17:42:50 +00:00
|
|
|
gst_structure_take_value (structure, field, &array);
|
2006-07-28 12:48:21 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
return caps;
|
2006-07-28 12:48:21 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static GstFlowReturn
|
2011-10-05 13:43:35 +00:00
|
|
|
gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
2005-03-31 09:43:49 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *vorbisenc;
|
2005-11-21 10:09:16 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
gfloat *ptr;
|
2006-01-30 15:01:28 +00:00
|
|
|
gulong size;
|
|
|
|
gulong i, j;
|
|
|
|
float **vorbis_buffer;
|
2006-04-07 13:24:54 +00:00
|
|
|
GstBuffer *buf1, *buf2, *buf3;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
vorbisenc = GST_VORBISENC (enc);
|
2005-03-31 09:43:49 +00:00
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
if (G_UNLIKELY (!vorbisenc->setup)) {
|
|
|
|
if (buffer) {
|
|
|
|
GST_DEBUG_OBJECT (vorbisenc, "forcing setup");
|
|
|
|
/* should not fail, as setup before same way */
|
|
|
|
if (!gst_vorbis_enc_setup (vorbisenc))
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
} else {
|
|
|
|
/* end draining */
|
|
|
|
GST_LOG_OBJECT (vorbisenc, "already drained");
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2009-05-06 12:19:34 +00:00
|
|
|
}
|
2011-10-05 13:43:35 +00:00
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
if (!vorbisenc->header_sent) {
|
|
|
|
/* Vorbis streams begin with three headers; the initial header (with
|
|
|
|
most of the codec setup parameters) which is mandated by the Ogg
|
|
|
|
bitstream spec. The second header holds any comment fields. The
|
|
|
|
third header holds the bitstream codebook. We merely need to
|
|
|
|
make the headers, then pass them to libvorbis one at a time;
|
|
|
|
libvorbis handles the additional Ogg bitstream constraints */
|
|
|
|
ogg_packet header;
|
|
|
|
ogg_packet header_comm;
|
|
|
|
ogg_packet header_code;
|
|
|
|
GstCaps *caps;
|
2012-03-30 10:51:11 +00:00
|
|
|
GList *headers;
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (vorbisenc, "creating and sending header packets");
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_set_metadata (vorbisenc);
|
2006-01-30 15:01:28 +00:00
|
|
|
vorbis_analysis_headerout (&vorbisenc->vd, &vorbisenc->vc, &header,
|
|
|
|
&header_comm, &header_code);
|
2006-02-05 23:31:05 +00:00
|
|
|
vorbis_comment_clear (&vorbisenc->vc);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* create header buffers */
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
buf1 = gst_vorbis_enc_buffer_from_header_packet (vorbisenc, &header);
|
|
|
|
buf2 = gst_vorbis_enc_buffer_from_header_packet (vorbisenc, &header_comm);
|
|
|
|
buf3 = gst_vorbis_enc_buffer_from_header_packet (vorbisenc, &header_code);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* mark and put on caps */
|
2012-01-26 10:01:12 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-vorbis",
|
|
|
|
"rate", G_TYPE_INT, vorbisenc->frequency,
|
|
|
|
"channels", G_TYPE_INT, vorbisenc->channels, NULL);
|
2011-10-05 13:43:35 +00:00
|
|
|
caps = _gst_caps_set_buffer_array (caps, "streamheader",
|
|
|
|
buf1, buf2, buf3, NULL);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* negotiate with these caps */
|
2011-10-05 13:43:35 +00:00
|
|
|
GST_DEBUG_OBJECT (vorbisenc, "here are the caps: %" GST_PTR_FORMAT, caps);
|
2012-02-01 15:04:03 +00:00
|
|
|
gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (vorbisenc), caps);
|
2011-10-05 13:43:35 +00:00
|
|
|
gst_caps_unref (caps);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
2011-10-09 19:19:32 +00:00
|
|
|
/* store buffers for later pre_push sending */
|
2012-03-30 10:51:11 +00:00
|
|
|
headers = NULL;
|
2011-10-09 19:19:32 +00:00
|
|
|
GST_DEBUG_OBJECT (vorbisenc, "storing header buffers");
|
2012-03-30 10:51:11 +00:00
|
|
|
headers = g_list_prepend (headers, buf3);
|
|
|
|
headers = g_list_prepend (headers, buf2);
|
|
|
|
headers = g_list_prepend (headers, buf1);
|
|
|
|
gst_audio_encoder_set_headers (enc, headers);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
vorbisenc->header_sent = TRUE;
|
2006-07-28 12:48:21 +00:00
|
|
|
}
|
|
|
|
|
2011-10-05 13:43:35 +00:00
|
|
|
if (!buffer)
|
|
|
|
return gst_vorbis_enc_clear (vorbisenc);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
2007-03-20 11:49:55 +00:00
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
/* data to encode */
|
2012-01-20 15:11:54 +00:00
|
|
|
size = map.size / (vorbisenc->channels * sizeof (float));
|
|
|
|
ptr = (gfloat *) map.data;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
/* expose the buffer to submit data */
|
|
|
|
vorbis_buffer = vorbis_analysis_buffer (&vorbisenc->vd, size);
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
/* deinterleave samples, write the buffer data */
|
2011-12-20 11:08:53 +00:00
|
|
|
if (vorbisenc->channels < 2 || vorbisenc->channels > 8) {
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
for (j = 0; j < vorbisenc->channels; j++) {
|
|
|
|
vorbis_buffer[j][i] = *ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
/* Reorder */
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
for (j = 0; j < vorbisenc->channels; j++) {
|
|
|
|
vorbis_buffer[gst_vorbis_reorder_map[vorbisenc->channels - 1][j]][i] =
|
|
|
|
ptr[j];
|
|
|
|
}
|
|
|
|
ptr += vorbisenc->channels;
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
2006-01-30 15:01:28 +00:00
|
|
|
}
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
/* tell the library how much we actually submitted */
|
|
|
|
vorbis_analysis_wrote (&vorbisenc->vd, size);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2002-10-20 17:11:10 +00:00
|
|
|
|
2008-06-20 09:25:44 +00:00
|
|
|
GST_LOG_OBJECT (vorbisenc, "wrote %lu samples to vorbis", size);
|
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
vorbisenc->samples_in += size;
|
2001-12-21 01:14:21 +00:00
|
|
|
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
ret = gst_vorbis_enc_output_buffers (vorbisenc);
|
2005-09-15 19:59:50 +00:00
|
|
|
|
2005-11-21 10:09:16 +00:00
|
|
|
return ret;
|
2005-09-15 19:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 10:09:16 +00:00
|
|
|
static GstFlowReturn
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_output_buffers (GstVorbisEnc * vorbisenc)
|
2005-09-15 19:59:50 +00:00
|
|
|
{
|
2005-11-21 10:09:16 +00:00
|
|
|
GstFlowReturn ret;
|
|
|
|
|
ext/vorbis/: Added a raw vorbis encoder to be used with the oggmuxer.
Original commit message from CVS:
* ext/vorbis/Makefile.am:
* ext/vorbis/README:
* ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_get_formats),
(oggvorbisenc_get_type), (vorbis_caps_factory), (raw_caps_factory),
(gst_oggvorbisenc_base_init), (gst_oggvorbisenc_class_init),
(gst_oggvorbisenc_sinkconnect), (gst_oggvorbisenc_convert_src),
(gst_oggvorbisenc_convert_sink),
(gst_oggvorbisenc_get_query_types), (gst_oggvorbisenc_src_query),
(gst_oggvorbisenc_init), (gst_oggvorbisenc_get_tag_value),
(gst_oggvorbisenc_metadata_set1), (gst_oggvorbisenc_set_metadata),
(get_constraints_string), (update_start_message),
(gst_oggvorbisenc_setup), (gst_oggvorbisenc_write_page),
(gst_oggvorbisenc_chain), (gst_oggvorbisenc_get_property),
(gst_oggvorbisenc_set_property), (gst_oggvorbisenc_change_state):
* ext/vorbis/oggvorbisenc.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisenc.c: (vorbis_caps_factory),
(raw_caps_factory), (gst_vorbisenc_class_init),
(gst_vorbisenc_init), (gst_vorbisenc_setup),
(gst_vorbisenc_push_packet), (gst_vorbisenc_chain),
(gst_vorbisenc_get_property), (gst_vorbisenc_set_property):
* ext/vorbis/vorbisenc.h:
Added a raw vorbis encoder to be used with the oggmuxer.
We still need the old encoder for some gnome applications,
read the README to find out how that works.
The raw encoder is called "rawvorbisenc" until 0.9.
2004-05-10 17:44:07 +00:00
|
|
|
/* vorbis does some data preanalysis, then divides up blocks for
|
2001-12-20 22:30:14 +00:00
|
|
|
more involved (potentially parallel) processing. Get a single
|
|
|
|
block for encoding now */
|
2001-12-21 01:14:21 +00:00
|
|
|
while (vorbis_analysis_blockout (&vorbisenc->vd, &vorbisenc->vb) == 1) {
|
ext/vorbis/: Added a raw vorbis encoder to be used with the oggmuxer.
Original commit message from CVS:
* ext/vorbis/Makefile.am:
* ext/vorbis/README:
* ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_get_formats),
(oggvorbisenc_get_type), (vorbis_caps_factory), (raw_caps_factory),
(gst_oggvorbisenc_base_init), (gst_oggvorbisenc_class_init),
(gst_oggvorbisenc_sinkconnect), (gst_oggvorbisenc_convert_src),
(gst_oggvorbisenc_convert_sink),
(gst_oggvorbisenc_get_query_types), (gst_oggvorbisenc_src_query),
(gst_oggvorbisenc_init), (gst_oggvorbisenc_get_tag_value),
(gst_oggvorbisenc_metadata_set1), (gst_oggvorbisenc_set_metadata),
(get_constraints_string), (update_start_message),
(gst_oggvorbisenc_setup), (gst_oggvorbisenc_write_page),
(gst_oggvorbisenc_chain), (gst_oggvorbisenc_get_property),
(gst_oggvorbisenc_set_property), (gst_oggvorbisenc_change_state):
* ext/vorbis/oggvorbisenc.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisenc.c: (vorbis_caps_factory),
(raw_caps_factory), (gst_vorbisenc_class_init),
(gst_vorbisenc_init), (gst_vorbisenc_setup),
(gst_vorbisenc_push_packet), (gst_vorbisenc_chain),
(gst_vorbisenc_get_property), (gst_vorbisenc_set_property):
* ext/vorbis/vorbisenc.h:
Added a raw vorbis encoder to be used with the oggmuxer.
We still need the old encoder for some gnome applications,
read the README to find out how that works.
The raw encoder is called "rawvorbisenc" until 0.9.
2004-05-10 17:44:07 +00:00
|
|
|
ogg_packet op;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
2005-08-20 20:40:25 +00:00
|
|
|
GST_LOG_OBJECT (vorbisenc, "analysed to a block");
|
|
|
|
|
2001-12-20 22:30:14 +00:00
|
|
|
/* analysis */
|
2002-04-15 09:27:03 +00:00
|
|
|
vorbis_analysis (&vorbisenc->vb, NULL);
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_bitrate_addblock (&vorbisenc->vb);
|
|
|
|
|
ext/vorbis/: Added a raw vorbis encoder to be used with the oggmuxer.
Original commit message from CVS:
* ext/vorbis/Makefile.am:
* ext/vorbis/README:
* ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_get_formats),
(oggvorbisenc_get_type), (vorbis_caps_factory), (raw_caps_factory),
(gst_oggvorbisenc_base_init), (gst_oggvorbisenc_class_init),
(gst_oggvorbisenc_sinkconnect), (gst_oggvorbisenc_convert_src),
(gst_oggvorbisenc_convert_sink),
(gst_oggvorbisenc_get_query_types), (gst_oggvorbisenc_src_query),
(gst_oggvorbisenc_init), (gst_oggvorbisenc_get_tag_value),
(gst_oggvorbisenc_metadata_set1), (gst_oggvorbisenc_set_metadata),
(get_constraints_string), (update_start_message),
(gst_oggvorbisenc_setup), (gst_oggvorbisenc_write_page),
(gst_oggvorbisenc_chain), (gst_oggvorbisenc_get_property),
(gst_oggvorbisenc_set_property), (gst_oggvorbisenc_change_state):
* ext/vorbis/oggvorbisenc.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisenc.c: (vorbis_caps_factory),
(raw_caps_factory), (gst_vorbisenc_class_init),
(gst_vorbisenc_init), (gst_vorbisenc_setup),
(gst_vorbisenc_push_packet), (gst_vorbisenc_chain),
(gst_vorbisenc_get_property), (gst_vorbisenc_set_property):
* ext/vorbis/vorbisenc.h:
Added a raw vorbis encoder to be used with the oggmuxer.
We still need the old encoder for some gnome applications,
read the README to find out how that works.
The raw encoder is called "rawvorbisenc" until 0.9.
2004-05-10 17:44:07 +00:00
|
|
|
while (vorbis_bitrate_flushpacket (&vorbisenc->vd, &op)) {
|
2011-10-05 13:43:35 +00:00
|
|
|
GstBuffer *buf;
|
|
|
|
|
2005-08-20 20:40:25 +00:00
|
|
|
GST_LOG_OBJECT (vorbisenc, "pushing out a data packet");
|
2012-07-23 08:30:40 +00:00
|
|
|
buf =
|
|
|
|
gst_audio_encoder_allocate_output_buffer (GST_AUDIO_ENCODER
|
|
|
|
(vorbisenc), op.bytes);
|
2011-10-08 08:19:06 +00:00
|
|
|
gst_buffer_fill (buf, 0, op.packet, op.bytes);
|
2011-10-05 13:43:35 +00:00
|
|
|
/* tracking granulepos should tell us samples accounted for */
|
|
|
|
ret =
|
|
|
|
gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER
|
|
|
|
(vorbisenc), buf, op.granulepos - vorbisenc->samples_out);
|
|
|
|
vorbisenc->samples_out = op.granulepos;
|
2005-11-21 10:09:16 +00:00
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
return ret;
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-21 10:09:16 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2001-12-20 22:30:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
2004-03-14 22:34:34 +00:00
|
|
|
GParamSpec * pspec)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *vorbisenc;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VORBISENC (object));
|
|
|
|
|
|
|
|
vorbisenc = GST_VORBISENC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-10-20 01:55:28 +00:00
|
|
|
case ARG_MAX_BITRATE:
|
|
|
|
g_value_set_int (value, vorbisenc->max_bitrate);
|
|
|
|
break;
|
2001-12-20 22:30:14 +00:00
|
|
|
case ARG_BITRATE:
|
|
|
|
g_value_set_int (value, vorbisenc->bitrate);
|
|
|
|
break;
|
2002-10-20 01:55:28 +00:00
|
|
|
case ARG_MIN_BITRATE:
|
|
|
|
g_value_set_int (value, vorbisenc->min_bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_QUALITY:
|
|
|
|
g_value_set_float (value, vorbisenc->quality);
|
|
|
|
break;
|
|
|
|
case ARG_MANAGED:
|
|
|
|
g_value_set_boolean (value, vorbisenc->managed);
|
|
|
|
break;
|
|
|
|
case ARG_LAST_MESSAGE:
|
|
|
|
g_value_set_string (value, vorbisenc->last_message);
|
|
|
|
break;
|
2001-12-20 22:30:14 +00:00
|
|
|
default:
|
2002-10-20 17:11:10 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-20 22:30:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ext/vorbis/: Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make vorbisenc adhere to the official nomenclature; u...
Original commit message from CVS:
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_class_init),
(gst_vorbis_dec_init), (vorbis_dec_finalize):
* ext/vorbis/vorbisdec.h:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_add_interfaces),
(gst_vorbis_enc_base_init), (gst_vorbis_enc_class_init),
(gst_vorbis_enc_sink_setcaps), (gst_vorbis_enc_convert_src),
(gst_vorbis_enc_convert_sink), (gst_vorbis_enc_get_query_types),
(gst_vorbis_enc_src_query), (gst_vorbis_enc_sink_query),
(gst_vorbis_enc_init), (gst_vorbis_enc_get_tag_value),
(gst_vorbis_enc_metadata_set1), (gst_vorbis_enc_set_metadata),
(gst_vorbis_enc_setup), (gst_vorbis_enc_clear),
(gst_vorbis_enc_buffer_from_packet),
(gst_vorbis_enc_buffer_from_header_packet),
(gst_vorbis_enc_push_buffer), (gst_vorbis_enc_push_packet),
(gst_vorbis_enc_set_header_on_caps), (gst_vorbis_enc_sink_event),
(gst_vorbis_enc_chain), (gst_vorbis_enc_output_buffers),
(gst_vorbis_enc_get_property), (gst_vorbis_enc_set_property),
(gst_vorbis_enc_change_state):
* ext/vorbis/vorbisenc.h:
Remove left-over 0.8 cruft; use GST_DEBUG_FUNCPTR; make
vorbisenc adhere to the official nomenclature; use boilerplate
macro.
2006-04-05 13:05:25 +00:00
|
|
|
gst_vorbis_enc_set_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:34 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-20 22:30:14 +00:00
|
|
|
{
|
2005-08-20 20:40:25 +00:00
|
|
|
GstVorbisEnc *vorbisenc;
|
2001-12-20 22:30:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_VORBISENC (object));
|
|
|
|
|
|
|
|
vorbisenc = GST_VORBISENC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-10-20 01:55:28 +00:00
|
|
|
case ARG_MAX_BITRATE:
|
|
|
|
{
|
|
|
|
gboolean old_value = vorbisenc->managed;
|
|
|
|
|
|
|
|
vorbisenc->max_bitrate = g_value_get_int (value);
|
2004-06-24 15:51:24 +00:00
|
|
|
if (vorbisenc->max_bitrate >= 0
|
|
|
|
&& vorbisenc->max_bitrate < LOWEST_BITRATE) {
|
|
|
|
g_warning ("Lowest allowed bitrate is %d", LOWEST_BITRATE);
|
|
|
|
vorbisenc->max_bitrate = LOWEST_BITRATE;
|
|
|
|
}
|
2002-10-20 01:55:28 +00:00
|
|
|
if (vorbisenc->min_bitrate > 0 && vorbisenc->max_bitrate > 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->managed = TRUE;
|
2002-10-20 01:55:28 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->managed = FALSE;
|
2002-10-20 01:55:28 +00:00
|
|
|
|
|
|
|
if (old_value != vorbisenc->managed)
|
2004-03-15 19:32:28 +00:00
|
|
|
g_object_notify (object, "managed");
|
2002-10-20 01:55:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-20 22:30:14 +00:00
|
|
|
case ARG_BITRATE:
|
|
|
|
vorbisenc->bitrate = g_value_get_int (value);
|
2004-06-24 15:51:24 +00:00
|
|
|
if (vorbisenc->bitrate >= 0 && vorbisenc->bitrate < LOWEST_BITRATE) {
|
|
|
|
g_warning ("Lowest allowed bitrate is %d", LOWEST_BITRATE);
|
|
|
|
vorbisenc->bitrate = LOWEST_BITRATE;
|
|
|
|
}
|
2001-12-20 22:30:14 +00:00
|
|
|
break;
|
2002-10-20 01:55:28 +00:00
|
|
|
case ARG_MIN_BITRATE:
|
|
|
|
{
|
|
|
|
gboolean old_value = vorbisenc->managed;
|
|
|
|
|
|
|
|
vorbisenc->min_bitrate = g_value_get_int (value);
|
2004-06-24 15:51:24 +00:00
|
|
|
if (vorbisenc->min_bitrate >= 0
|
|
|
|
&& vorbisenc->min_bitrate < LOWEST_BITRATE) {
|
|
|
|
g_warning ("Lowest allowed bitrate is %d", LOWEST_BITRATE);
|
|
|
|
vorbisenc->min_bitrate = LOWEST_BITRATE;
|
|
|
|
}
|
2002-10-20 01:55:28 +00:00
|
|
|
if (vorbisenc->min_bitrate > 0 && vorbisenc->max_bitrate > 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->managed = TRUE;
|
2002-10-20 01:55:28 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->managed = FALSE;
|
2002-10-20 01:55:28 +00:00
|
|
|
|
|
|
|
if (old_value != vorbisenc->managed)
|
2004-03-15 19:32:28 +00:00
|
|
|
g_object_notify (object, "managed");
|
2002-10-20 01:55:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ARG_QUALITY:
|
|
|
|
vorbisenc->quality = g_value_get_float (value);
|
|
|
|
if (vorbisenc->quality >= 0.0)
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->quality_set = TRUE;
|
2002-10-20 01:55:28 +00:00
|
|
|
else
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbisenc->quality_set = FALSE;
|
2002-10-20 01:55:28 +00:00
|
|
|
break;
|
|
|
|
case ARG_MANAGED:
|
|
|
|
vorbisenc->managed = g_value_get_boolean (value);
|
|
|
|
break;
|
2001-12-20 22:30:14 +00:00
|
|
|
default:
|
2002-10-20 17:11:10 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-20 22:30:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|