2003-11-22 12:25:48 +00:00
|
|
|
/* GStreamer FAAC (Free AAC Encoder) plugin
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2006-09-21 13:41:42 +00:00
|
|
|
#include <string.h>
|
2003-11-22 12:25:48 +00:00
|
|
|
|
|
|
|
#include "gstfaac.h"
|
2005-10-12 13:54:34 +00:00
|
|
|
|
|
|
|
#define SINK_CAPS \
|
|
|
|
"audio/x-raw-int, " \
|
|
|
|
"endianness = (int) BYTE_ORDER, " \
|
|
|
|
"signed = (boolean) true, " \
|
|
|
|
"width = (int) 16, " \
|
|
|
|
"depth = (int) 16, " \
|
|
|
|
"rate = (int) [ 8000, 96000 ], " \
|
2006-08-10 17:09:10 +00:00
|
|
|
"channels = (int) [ 1, 6 ] "
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
|
|
|
|
/* these don't seem to work? */
|
|
|
|
#if 0
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"signed = (boolean) true, "
|
|
|
|
"width = (int) 32, "
|
|
|
|
"depth = (int) { 24, 32 }, "
|
|
|
|
"rate = (int) [ 8000, 96000], "
|
|
|
|
"channels = (int) [ 1, 6]; "
|
|
|
|
"audio/x-raw-float, "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) 32, "
|
|
|
|
"rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]"
|
|
|
|
#endif
|
2005-10-12 13:54:34 +00:00
|
|
|
#define SRC_CAPS \
|
|
|
|
"audio/mpeg, " \
|
|
|
|
"mpegversion = (int) { 4, 2 }, " \
|
|
|
|
"channels = (int) [ 1, 6 ], " \
|
|
|
|
"rate = (int) [ 8000, 96000 ]"
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2005-10-12 13:54:34 +00:00
|
|
|
GST_STATIC_CAPS (SRC_CAPS));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2005-10-12 13:54:34 +00:00
|
|
|
GST_STATIC_CAPS (SINK_CAPS));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails gst_faac_details =
|
|
|
|
GST_ELEMENT_DETAILS ("AAC audio encoder",
|
|
|
|
"Codec/Encoder/Audio",
|
|
|
|
"Free MPEG-2/4 AAC encoder",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-11-22 12:25:48 +00:00
|
|
|
ARG_0,
|
2005-01-07 10:15:20 +00:00
|
|
|
ARG_OUTPUTFORMAT,
|
2003-11-22 12:25:48 +00:00
|
|
|
ARG_BITRATE,
|
|
|
|
ARG_PROFILE,
|
|
|
|
ARG_TNS,
|
|
|
|
ARG_MIDSIDE,
|
|
|
|
ARG_SHORTCTL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_faac_base_init (GstFaacClass * klass);
|
|
|
|
static void gst_faac_class_init (GstFaacClass * klass);
|
|
|
|
static void gst_faac_init (GstFaac * faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_faac_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_faac_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
static gboolean gst_faac_sink_event (GstPad * pad, GstEvent * event);
|
2005-09-01 19:12:44 +00:00
|
|
|
static gboolean gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps);
|
|
|
|
static GstFlowReturn gst_faac_chain (GstPad * pad, GstBuffer * data);
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn gst_faac_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-11-15 16:50:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (faac_debug);
|
|
|
|
#define GST_CAT_DEFAULT faac_debug
|
|
|
|
|
|
|
|
#define FAAC_DEFAULT_MPEGVERSION 4
|
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
GType
|
|
|
|
gst_faac_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_faac_type = 0;
|
|
|
|
|
|
|
|
if (!gst_faac_type) {
|
|
|
|
static const GTypeInfo gst_faac_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstFaacClass),
|
2003-11-22 12:25:48 +00:00
|
|
|
(GBaseInitFunc) gst_faac_base_init,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_faac_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstFaac),
|
2003-11-22 12:25:48 +00:00
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_faac_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_faac_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2004-03-15 19:32:27 +00:00
|
|
|
"GstFaac", &gst_faac_info, 0);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_faac_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_faac_base_init (GstFaacClass * klass)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&src_template));
|
2003-11-22 12:25:48 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&sink_template));
|
2003-11-22 12:25:48 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &gst_faac_details);
|
2005-11-15 16:50:18 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (faac_debug, "faac", 0, "AAC encoding");
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_FAAC_PROFILE (gst_faac_profile_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_faac_profile_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_faac_profile_type = 0;
|
|
|
|
|
|
|
|
if (!gst_faac_profile_type) {
|
|
|
|
static GEnumValue gst_faac_profile[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{MAIN, "MAIN", "Main profile"},
|
|
|
|
{LOW, "LOW", "Low complexity profile"},
|
|
|
|
{SSR, "SSR", "Scalable sampling rate profile"},
|
|
|
|
{LTP, "LTP", "Long term prediction profile"},
|
|
|
|
{0, NULL, NULL},
|
2003-11-22 12:25:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gst_faac_profile_type = g_enum_register_static ("GstFaacProfile",
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_faac_profile);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_faac_profile_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_FAAC_SHORTCTL (gst_faac_shortctl_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_faac_shortctl_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_faac_shortctl_type = 0;
|
|
|
|
|
|
|
|
if (!gst_faac_shortctl_type) {
|
|
|
|
static GEnumValue gst_faac_shortctl[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{SHORTCTL_NORMAL, "SHORTCTL_NORMAL", "Normal block type"},
|
|
|
|
{SHORTCTL_NOSHORT, "SHORTCTL_NOSHORT", "No short blocks"},
|
|
|
|
{SHORTCTL_NOLONG, "SHORTCTL_NOLONG", "No long blocks"},
|
|
|
|
{0, NULL, NULL},
|
2003-11-22 12:25:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gst_faac_shortctl_type = g_enum_register_static ("GstFaacShortCtl",
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_faac_shortctl);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_faac_shortctl_type;
|
|
|
|
}
|
|
|
|
|
2005-01-07 10:15:20 +00:00
|
|
|
#define GST_TYPE_FAAC_OUTPUTFORMAT (gst_faac_outputformat_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_faac_outputformat_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_faac_outputformat_type = 0;
|
|
|
|
|
|
|
|
if (!gst_faac_outputformat_type) {
|
|
|
|
static GEnumValue gst_faac_outputformat[] = {
|
|
|
|
{0, "OUTPUTFORMAT_RAW", "Raw AAC"},
|
|
|
|
{1, "OUTPUTFORMAT_ADTS", "ADTS headers"},
|
|
|
|
{0, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_faac_outputformat_type = g_enum_register_static ("GstFaacOutputFormat",
|
|
|
|
gst_faac_outputformat);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_faac_outputformat_type;
|
|
|
|
}
|
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_faac_class_init (GstFaacClass * klass)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2005-09-01 19:12:44 +00:00
|
|
|
gobject_class->set_property = gst_faac_set_property;
|
|
|
|
gobject_class->get_property = gst_faac_get_property;
|
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
/* properties */
|
|
|
|
g_object_class_install_property (gobject_class, ARG_BITRATE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
|
2004-03-15 19:32:27 +00:00
|
|
|
8 * 1024, 320 * 1024, 128 * 1024, G_PARAM_READWRITE));
|
2003-11-22 12:25:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_PROFILE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_enum ("profile", "Profile", "MPEG/AAC encoding profile",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_FAAC_PROFILE, MAIN, G_PARAM_READWRITE));
|
2003-11-22 12:25:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_TNS,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
|
2004-03-15 19:32:27 +00:00
|
|
|
FALSE, G_PARAM_READWRITE));
|
2003-11-22 12:25:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MIDSIDE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_boolean ("midside", "Midside", "Allow mid/side encoding",
|
2004-03-15 19:32:27 +00:00
|
|
|
TRUE, G_PARAM_READWRITE));
|
2003-11-22 12:25:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_SHORTCTL,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_enum ("shortctl", "Block type",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Block type encorcing",
|
|
|
|
GST_TYPE_FAAC_SHORTCTL, MAIN, G_PARAM_READWRITE));
|
2005-01-07 10:15:20 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_OUTPUTFORMAT,
|
|
|
|
g_param_spec_enum ("outputformat", "Output format",
|
|
|
|
"Format of output frames",
|
|
|
|
GST_TYPE_FAAC_OUTPUTFORMAT, MAIN, G_PARAM_READWRITE));
|
2003-11-22 12:25:48 +00:00
|
|
|
|
|
|
|
/* virtual functions */
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_faac_change_state);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_faac_init (GstFaac * faac)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
faac->handle = NULL;
|
|
|
|
faac->samplerate = -1;
|
|
|
|
faac->channels = -1;
|
|
|
|
faac->cache = NULL;
|
|
|
|
faac->cache_time = GST_CLOCK_TIME_NONE;
|
|
|
|
faac->cache_duration = 0;
|
|
|
|
|
2007-06-22 10:46:33 +00:00
|
|
|
faac->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gst_pad_set_chain_function (faac->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_faac_chain));
|
|
|
|
gst_pad_set_setcaps_function (faac->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_faac_sink_setcaps));
|
|
|
|
gst_pad_set_event_function (faac->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_faac_sink_event));
|
2005-09-01 19:12:44 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (faac), faac->sinkpad);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2007-06-22 10:46:33 +00:00
|
|
|
faac->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gst_pad_use_fixed_caps (faac->srcpad);
|
2003-11-22 12:25:48 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (faac), faac->srcpad);
|
|
|
|
|
|
|
|
/* default properties */
|
|
|
|
faac->bitrate = 1024 * 128;
|
|
|
|
faac->profile = MAIN;
|
|
|
|
faac->shortctl = SHORTCTL_NORMAL;
|
2005-01-07 10:15:20 +00:00
|
|
|
faac->outputformat = 0;
|
2003-11-22 12:25:48 +00:00
|
|
|
faac->tns = FALSE;
|
|
|
|
faac->midside = TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-01 19:12:44 +00:00
|
|
|
static gboolean
|
|
|
|
gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
|
|
|
faacEncHandle *handle;
|
2005-10-12 13:54:34 +00:00
|
|
|
gint channels, samplerate, width;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
gulong samples, bytes, fmt = 0, bps = 0;
|
2005-10-12 12:53:07 +00:00
|
|
|
gboolean result = FALSE;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
if (!gst_caps_is_fixed (caps))
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
goto done;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_LOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
if (faac->handle) {
|
|
|
|
faacEncClose (faac->handle);
|
|
|
|
faac->handle = NULL;
|
|
|
|
}
|
|
|
|
if (faac->cache) {
|
|
|
|
gst_buffer_unref (faac->cache);
|
|
|
|
faac->cache = NULL;
|
|
|
|
}
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_UNLOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2005-10-12 13:54:34 +00:00
|
|
|
if (!gst_structure_get_int (structure, "channels", &channels) ||
|
|
|
|
!gst_structure_get_int (structure, "rate", &samplerate)) {
|
|
|
|
goto done;
|
|
|
|
}
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes)))
|
2005-10-12 12:53:07 +00:00
|
|
|
goto done;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
2005-10-12 13:54:34 +00:00
|
|
|
if (gst_structure_has_name (structure, "audio/x-raw-int")) {
|
|
|
|
gst_structure_get_int (structure, "width", &width);
|
|
|
|
switch (width) {
|
|
|
|
case 16:
|
|
|
|
fmt = FAAC_INPUT_16BIT;
|
|
|
|
bps = 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
fmt = FAAC_INPUT_32BIT;
|
|
|
|
bps = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
}
|
|
|
|
} else if (gst_structure_has_name (structure, "audio/x-raw-float")) {
|
|
|
|
fmt = FAAC_INPUT_FLOAT;
|
|
|
|
bps = 4;
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
}
|
2003-11-22 12:25:48 +00:00
|
|
|
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
if (!fmt) {
|
|
|
|
faacEncClose (handle);
|
2005-10-12 12:53:07 +00:00
|
|
|
goto done;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_LOCK (faac);
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
faac->format = fmt;
|
|
|
|
faac->bps = bps;
|
|
|
|
faac->handle = handle;
|
|
|
|
faac->bytes = bytes;
|
|
|
|
faac->samples = samples;
|
|
|
|
faac->channels = channels;
|
|
|
|
faac->samplerate = samplerate;
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_UNLOCK (faac);
|
Fix caps breakage after Dave's caps branch merge.
Original commit message from CVS:
2003-12-23 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/divx/gstdivxdec.c: (gst_divxdec_base_init),
(gst_divxdec_init), (gst_divxdec_negotiate):
* ext/divx/gstdivxdec.h:
* ext/divx/gstdivxenc.c: (gst_divxenc_base_init),
(gst_divxenc_init):
* ext/faac/gstfaac.c: (gst_faac_base_init), (gst_faac_init),
(gst_faac_sinkconnect), (gst_faac_srcconnect):
* ext/mpeg2enc/gstmpeg2enc.cc:
* ext/mpeg2enc/gstmpeg2encoder.cc:
* ext/mpeg2enc/gstmpeg2encpicturereader.cc:
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_base_init),
(dxr3audiosink_init), (dxr3audiosink_pcm_sinklink):
* sys/dxr3/dxr3spusink.c: (dxr3spusink_base_init),
(dxr3spusink_init):
* sys/dxr3/dxr3videosink.c: (dxr3videosink_base_init),
(dxr3videosink_init):
Fix caps breakage after Dave's caps branch merge.
2003-12-23 22:50:06 +00:00
|
|
|
|
2005-10-12 12:53:07 +00:00
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
gst_object_unref (faac);
|
|
|
|
return result;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-01 19:12:44 +00:00
|
|
|
static gboolean
|
2005-11-15 16:50:18 +00:00
|
|
|
gst_faac_configure_source_pad (GstFaac * faac)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
2005-11-15 16:50:18 +00:00
|
|
|
GstCaps *allowed_caps;
|
2006-09-21 13:41:42 +00:00
|
|
|
GstCaps *srccaps;
|
2005-11-15 16:50:18 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
gint n, ver, mpegversion;
|
2006-09-21 13:41:42 +00:00
|
|
|
faacEncConfiguration *conf;
|
2005-11-15 16:50:18 +00:00
|
|
|
|
|
|
|
mpegversion = FAAC_DEFAULT_MPEGVERSION;
|
|
|
|
|
|
|
|
allowed_caps = gst_pad_get_allowed_caps (faac->srcpad);
|
|
|
|
GST_DEBUG_OBJECT (faac, "allowed caps: %" GST_PTR_FORMAT, allowed_caps);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2005-11-15 16:50:18 +00:00
|
|
|
if (allowed_caps == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (gst_caps_is_empty (allowed_caps))
|
2006-09-21 13:41:42 +00:00
|
|
|
goto empty_caps;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2005-11-15 16:50:18 +00:00
|
|
|
if (!gst_caps_is_any (allowed_caps)) {
|
|
|
|
for (n = 0; n < gst_caps_get_size (allowed_caps); n++) {
|
|
|
|
GstStructure *s = gst_caps_get_structure (allowed_caps, n);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-11-15 16:50:18 +00:00
|
|
|
if (gst_structure_get_int (s, "mpegversion", &ver) &&
|
|
|
|
(ver == 4 || ver == 2)) {
|
|
|
|
mpegversion = ver;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
2006-09-21 13:41:42 +00:00
|
|
|
gst_caps_unref (allowed_caps);
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2006-09-21 13:41:42 +00:00
|
|
|
/* we negotiated caps update current configuration */
|
|
|
|
conf = faacEncGetCurrentConfiguration (faac->handle);
|
|
|
|
conf->mpegVersion = (mpegversion == 4) ? MPEG4 : MPEG2;
|
|
|
|
conf->aacObjectType = faac->profile;
|
|
|
|
conf->allowMidside = faac->midside;
|
|
|
|
conf->useLfe = 0;
|
|
|
|
conf->useTns = faac->tns;
|
|
|
|
conf->bitRate = faac->bitrate / faac->channels;
|
|
|
|
conf->inputFormat = faac->format;
|
|
|
|
conf->outputFormat = faac->outputformat;
|
|
|
|
conf->shortctl = faac->shortctl;
|
|
|
|
if (!faacEncSetConfiguration (faac->handle, conf))
|
|
|
|
goto set_failed;
|
|
|
|
|
|
|
|
/* now create a caps for it all */
|
|
|
|
srccaps = gst_caps_new_simple ("audio/mpeg",
|
2005-11-15 16:50:18 +00:00
|
|
|
"mpegversion", G_TYPE_INT, mpegversion,
|
|
|
|
"channels", G_TYPE_INT, faac->channels,
|
|
|
|
"rate", G_TYPE_INT, faac->samplerate, NULL);
|
|
|
|
|
2006-09-21 13:41:42 +00:00
|
|
|
if (mpegversion == 4) {
|
|
|
|
GstBuffer *codec_data;
|
|
|
|
guint8 *config = NULL;
|
|
|
|
gulong config_len = 0;
|
|
|
|
|
|
|
|
/* get the config string */
|
|
|
|
GST_DEBUG_OBJECT (faac, "retrieving decoder info");
|
|
|
|
faacEncGetDecoderSpecificInfo (faac->handle, &config, &config_len);
|
|
|
|
|
|
|
|
/* copy it into a buffer */
|
|
|
|
codec_data = gst_buffer_new_and_alloc (config_len);
|
|
|
|
memcpy (GST_BUFFER_DATA (codec_data), config, config_len);
|
|
|
|
|
|
|
|
/* add to caps */
|
|
|
|
gst_caps_set_simple (srccaps,
|
|
|
|
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
|
|
|
|
|
|
|
gst_buffer_unref (codec_data);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2006-09-21 13:41:42 +00:00
|
|
|
GST_DEBUG_OBJECT (faac, "src pad caps: %" GST_PTR_FORMAT, srccaps);
|
2005-11-15 16:50:18 +00:00
|
|
|
|
2006-09-21 13:41:42 +00:00
|
|
|
ret = gst_pad_set_caps (faac->srcpad, srccaps);
|
|
|
|
gst_caps_unref (srccaps);
|
2005-11-15 16:50:18 +00:00
|
|
|
|
|
|
|
return ret;
|
2006-09-21 13:41:42 +00:00
|
|
|
|
|
|
|
/* ERROR */
|
|
|
|
empty_caps:
|
|
|
|
{
|
|
|
|
gst_caps_unref (allowed_caps);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
set_failed:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (faac, "Faac doesn't support the current configuration");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
static gboolean
|
|
|
|
gst_faac_sink_event (GstPad * pad, GstEvent * event)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
GstFaac *faac;
|
|
|
|
gboolean ret;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
faac = GST_FAAC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
|
|
|
/* flush first */
|
|
|
|
ret = TRUE;
|
|
|
|
do {
|
2005-12-05 13:04:22 +00:00
|
|
|
if (gst_pad_alloc_buffer_and_set_caps (faac->srcpad,
|
|
|
|
GST_BUFFER_OFFSET_NONE, faac->bytes,
|
|
|
|
GST_PAD_CAPS (faac->srcpad), &outbuf) == GST_FLOW_OK) {
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gint ret_size;
|
|
|
|
|
|
|
|
if ((ret_size = faacEncEncode (faac->handle, NULL, 0,
|
|
|
|
GST_BUFFER_DATA (outbuf), faac->bytes)) > 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = ret_size;
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_CLOCK_TIME_NONE;
|
2005-09-01 19:12:44 +00:00
|
|
|
gst_pad_push (faac->srcpad, outbuf);
|
2004-03-15 19:32:27 +00:00
|
|
|
} else {
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
ret = FALSE;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
} while (ret);
|
2004-03-15 19:32:27 +00:00
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
case GST_EVENT_NEWSEGMENT:
|
|
|
|
ret = gst_pad_push_event (faac->srcpad, event);
|
|
|
|
break;
|
|
|
|
case GST_EVENT_TAG:
|
|
|
|
ret = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
gst_object_unref (faac);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_faac_chain (GstPad * pad, GstBuffer * inbuf)
|
|
|
|
{
|
|
|
|
GstFlowReturn result = GST_FLOW_OK;
|
|
|
|
GstBuffer *outbuf, *subbuf;
|
|
|
|
GstFaac *faac;
|
|
|
|
guint size, ret_size, in_size, frame_size;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
faac = GST_FAAC (gst_pad_get_parent (pad));
|
2003-11-22 12:25:48 +00:00
|
|
|
|
2006-09-21 13:41:42 +00:00
|
|
|
if (!faac->handle)
|
|
|
|
goto no_handle;
|
2003-11-22 12:25:48 +00:00
|
|
|
|
|
|
|
if (!GST_PAD_CAPS (faac->srcpad)) {
|
2006-09-21 13:41:42 +00:00
|
|
|
if (!gst_faac_configure_source_pad (faac))
|
|
|
|
goto nego_failed;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
in_size = size;
|
|
|
|
if (faac->cache)
|
|
|
|
in_size += GST_BUFFER_SIZE (faac->cache);
|
|
|
|
frame_size = faac->samples * faac->bps;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
/* do we have enough data for one frame? */
|
|
|
|
if (in_size / faac->bps < faac->samples) {
|
|
|
|
if (in_size > size) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GstBuffer *merge;
|
|
|
|
|
|
|
|
/* this is panic! we got a buffer, but still don't have enough
|
|
|
|
* data. Merge them and retry in the next cycle... */
|
|
|
|
merge = gst_buffer_merge (faac->cache, inbuf);
|
|
|
|
gst_buffer_unref (faac->cache);
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
faac->cache = merge;
|
2003-11-22 12:25:48 +00:00
|
|
|
} else if (in_size == size) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* this shouldn't happen, but still... */
|
|
|
|
faac->cache = inbuf;
|
2003-11-22 12:25:48 +00:00
|
|
|
} else if (in_size > 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
faac->cache = gst_buffer_create_sub (inbuf, size - in_size, in_size);
|
|
|
|
GST_BUFFER_DURATION (faac->cache) =
|
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (faac->cache) / size;
|
|
|
|
GST_BUFFER_TIMESTAMP (faac->cache) =
|
|
|
|
GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
|
|
|
|
(size - in_size) / size);
|
|
|
|
gst_buffer_unref (inbuf);
|
2003-11-22 12:25:48 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-10-12 12:53:07 +00:00
|
|
|
goto done;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create the frame */
|
|
|
|
if (in_size > size) {
|
2004-03-06 20:56:28 +00:00
|
|
|
GstBuffer *merge;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
/* merge */
|
|
|
|
subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size));
|
|
|
|
GST_BUFFER_DURATION (subbuf) =
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
|
2004-03-06 20:56:28 +00:00
|
|
|
merge = gst_buffer_merge (faac->cache, subbuf);
|
|
|
|
gst_buffer_unref (faac->cache);
|
|
|
|
gst_buffer_unref (subbuf);
|
|
|
|
subbuf = merge;
|
2003-11-22 12:25:48 +00:00
|
|
|
faac->cache = NULL;
|
|
|
|
} else {
|
|
|
|
subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size);
|
|
|
|
GST_BUFFER_DURATION (subbuf) =
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
|
2003-11-22 12:25:48 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (subbuf) =
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
|
|
|
|
(size - in_size) / size);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2005-12-05 13:04:22 +00:00
|
|
|
result =
|
|
|
|
gst_pad_alloc_buffer_and_set_caps (faac->srcpad, GST_BUFFER_OFFSET_NONE,
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
faac->bytes, GST_PAD_CAPS (faac->srcpad), &outbuf);
|
|
|
|
if (result != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
if ((ret_size = faacEncEncode (faac->handle,
|
2004-03-15 19:32:27 +00:00
|
|
|
(gint32 *) GST_BUFFER_DATA (subbuf),
|
|
|
|
GST_BUFFER_SIZE (subbuf) / faac->bps,
|
|
|
|
GST_BUFFER_DATA (outbuf), faac->bytes)) < 0) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
|
2003-11-22 12:25:48 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
gst_buffer_unref (subbuf);
|
2005-10-12 12:53:07 +00:00
|
|
|
result = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret_size > 0) {
|
|
|
|
GST_BUFFER_SIZE (outbuf) = ret_size;
|
|
|
|
if (faac->cache_time != GST_CLOCK_TIME_NONE) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = faac->cache_time;
|
|
|
|
faac->cache_time = GST_CLOCK_TIME_NONE;
|
2003-11-22 12:25:48 +00:00
|
|
|
} else
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
|
2003-11-22 12:25:48 +00:00
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (subbuf);
|
|
|
|
if (faac->cache_duration) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_DURATION (outbuf) += faac->cache_duration;
|
|
|
|
faac->cache_duration = 0;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
result = gst_pad_push (faac->srcpad, outbuf);
|
2003-11-22 12:25:48 +00:00
|
|
|
} else {
|
|
|
|
/* FIXME: what I'm doing here isn't fully correct, but there
|
|
|
|
* really isn't a better way yet.
|
|
|
|
* Problem is that libfaac caches buffers (for encoding
|
|
|
|
* purposes), so the timestamp of the outgoing buffer isn't
|
|
|
|
* the same as the timestamp of the data that I pushed in.
|
|
|
|
* However, I don't know the delay between those two so I
|
|
|
|
* cannot really say aything about it. This is a bad guess. */
|
|
|
|
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
if (faac->cache_time != GST_CLOCK_TIME_NONE)
|
2004-03-15 19:32:27 +00:00
|
|
|
faac->cache_time = GST_BUFFER_TIMESTAMP (subbuf);
|
2003-11-22 12:25:48 +00:00
|
|
|
faac->cache_duration += GST_BUFFER_DURATION (subbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
in_size -= frame_size;
|
|
|
|
gst_buffer_unref (subbuf);
|
|
|
|
}
|
2005-09-01 19:12:44 +00:00
|
|
|
|
2005-10-12 12:53:07 +00:00
|
|
|
done:
|
|
|
|
gst_object_unref (faac);
|
2006-09-21 13:41:42 +00:00
|
|
|
|
2005-09-01 19:12:44 +00:00
|
|
|
return result;
|
2006-09-21 13:41:42 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_handle:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
|
|
|
|
("format wasn't negotiated before chain function"));
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
result = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
nego_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
|
|
|
|
("failed to negotiate MPEG/AAC format with next element"));
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
result = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_faac_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
GstFaac *faac = GST_FAAC (object);
|
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_LOCK (faac);
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BITRATE:
|
|
|
|
faac->bitrate = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_PROFILE:
|
|
|
|
faac->profile = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case ARG_TNS:
|
|
|
|
faac->tns = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_MIDSIDE:
|
|
|
|
faac->midside = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_SHORTCTL:
|
|
|
|
faac->shortctl = g_value_get_enum (value);
|
|
|
|
break;
|
2005-01-07 10:15:20 +00:00
|
|
|
case ARG_OUTPUTFORMAT:
|
|
|
|
faac->outputformat = g_value_get_enum (value);
|
|
|
|
break;
|
2003-11-22 12:25:48 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_UNLOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_faac_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
|
|
|
GstFaac *faac = GST_FAAC (object);
|
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_LOCK (faac);
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
|
2003-11-22 12:25:48 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BITRATE:
|
|
|
|
g_value_set_int (value, faac->bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_PROFILE:
|
|
|
|
g_value_set_enum (value, faac->profile);
|
|
|
|
break;
|
|
|
|
case ARG_TNS:
|
|
|
|
g_value_set_boolean (value, faac->tns);
|
|
|
|
break;
|
|
|
|
case ARG_MIDSIDE:
|
|
|
|
g_value_set_boolean (value, faac->midside);
|
|
|
|
break;
|
|
|
|
case ARG_SHORTCTL:
|
|
|
|
g_value_set_enum (value, faac->shortctl);
|
|
|
|
break;
|
2005-01-07 10:15:20 +00:00
|
|
|
case ARG_OUTPUTFORMAT:
|
|
|
|
g_value_set_enum (value, faac->outputformat);
|
|
|
|
break;
|
2003-11-22 12:25:48 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_UNLOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_faac_change_state (GstElement * element, GstStateChange transition)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
2003-11-22 12:25:48 +00:00
|
|
|
GstFaac *faac = GST_FAAC (element);
|
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
/* upwards state changes */
|
|
|
|
switch (transition) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
/* downwards state changes */
|
2005-09-05 17:20:29 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
{
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_LOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
if (faac->handle) {
|
2004-03-15 19:32:27 +00:00
|
|
|
faacEncClose (faac->handle);
|
|
|
|
faac->handle = NULL;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
if (faac->cache) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_buffer_unref (faac->cache);
|
|
|
|
faac->cache = NULL;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
faac->cache_time = GST_CLOCK_TIME_NONE;
|
|
|
|
faac->cache_duration = 0;
|
|
|
|
faac->samplerate = -1;
|
|
|
|
faac->channels = -1;
|
2005-11-21 16:37:18 +00:00
|
|
|
GST_OBJECT_UNLOCK (faac);
|
2003-11-22 12:25:48 +00:00
|
|
|
break;
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
}
|
2003-11-22 12:25:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
ext/faac/gstfaac.c: Gst09-ize code a little bit more: use gst_pad_alloc_buffer(), move event handling from chain func...
Original commit message from CVS:
* ext/faac/gstfaac.c: (gst_faac_class_init), (gst_faac_init),
(gst_faac_sink_setcaps), (gst_faac_src_setcaps),
(gst_faac_sink_event), (gst_faac_chain), (gst_faac_set_property),
(gst_faac_get_property), (gst_faac_change_state):
Gst09-ize code a little bit more: use gst_pad_alloc_buffer(),
move event handling from chain function into an event function,
add some locks here and there, do some cleanups; disable 32-bit
integer and float input formats until we're sure that those
actually work (couldn't play back the produced files with
anything).
2005-10-13 11:37:39 +00:00
|
|
|
return ret;
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-11-22 12:25:48 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_element_register (plugin, "faac", GST_RANK_NONE, GST_TYPE_FAAC);
|
2003-11-22 12:25:48 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"faac",
|
|
|
|
"Free AAC Encoder (FAAC)",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|