mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
faac: make template pad caps more accurate and remove custom getcaps
Allows reusing baseclass caps query handling and simplifying negotiation code.
This commit is contained in:
parent
f3b18a29bf
commit
ba4e6ee1be
1 changed files with 50 additions and 63 deletions
|
@ -55,12 +55,6 @@
|
||||||
"64000, " \
|
"64000, " \
|
||||||
"88200, " \
|
"88200, " \
|
||||||
"96000"
|
"96000"
|
||||||
#define SINK_CAPS \
|
|
||||||
"audio/x-raw, " \
|
|
||||||
"format = (string) "GST_AUDIO_NE (S16) ", " \
|
|
||||||
"layout = (string) interleaved, " \
|
|
||||||
"rate = (int) {" SAMPLE_RATES "}, " \
|
|
||||||
"channels = (int) [ 1, 6 ] "
|
|
||||||
|
|
||||||
/* these don't seem to work? */
|
/* these don't seem to work? */
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -96,11 +90,6 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (SRC_CAPS));
|
GST_STATIC_CAPS (SRC_CAPS));
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (SINK_CAPS));
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -124,9 +113,9 @@ static void gst_faac_set_property (GObject * object,
|
||||||
static void gst_faac_get_property (GObject * object,
|
static void gst_faac_get_property (GObject * object,
|
||||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
|
static GstCaps *gst_faac_enc_generate_sink_caps (void);
|
||||||
static gboolean gst_faac_configure_source_pad (GstFaac * faac,
|
static gboolean gst_faac_configure_source_pad (GstFaac * faac,
|
||||||
GstAudioInfo * info);
|
GstAudioInfo * info);
|
||||||
static GstCaps *gst_faac_getcaps (GstAudioEncoder * enc, GstCaps * filter);
|
|
||||||
|
|
||||||
static gboolean gst_faac_stop (GstAudioEncoder * enc);
|
static gboolean gst_faac_stop (GstAudioEncoder * enc);
|
||||||
static gboolean gst_faac_set_format (GstAudioEncoder * enc,
|
static gboolean gst_faac_set_format (GstAudioEncoder * enc,
|
||||||
|
@ -194,14 +183,20 @@ gst_faac_class_init (GstFaacClass * klass)
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
|
GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
|
||||||
|
GstCaps *sink_caps;
|
||||||
|
GstPadTemplate *sink_templ;
|
||||||
|
|
||||||
gobject_class->set_property = gst_faac_set_property;
|
gobject_class->set_property = gst_faac_set_property;
|
||||||
gobject_class->get_property = gst_faac_get_property;
|
gobject_class->get_property = gst_faac_get_property;
|
||||||
|
|
||||||
gst_element_class_add_pad_template (gstelement_class,
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
gst_static_pad_template_get (&src_template));
|
gst_static_pad_template_get (&src_template));
|
||||||
gst_element_class_add_pad_template (gstelement_class,
|
|
||||||
gst_static_pad_template_get (&sink_template));
|
sink_caps = gst_faac_enc_generate_sink_caps ();
|
||||||
|
sink_templ = gst_pad_template_new ("sink",
|
||||||
|
GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
|
||||||
|
gst_element_class_add_pad_template (gstelement_class, sink_templ);
|
||||||
|
gst_caps_unref (sink_caps);
|
||||||
|
|
||||||
gst_element_class_set_static_metadata (gstelement_class, "AAC audio encoder",
|
gst_element_class_set_static_metadata (gstelement_class, "AAC audio encoder",
|
||||||
"Codec/Encoder/Audio",
|
"Codec/Encoder/Audio",
|
||||||
|
@ -211,7 +206,6 @@ gst_faac_class_init (GstFaacClass * klass)
|
||||||
base_class->stop = GST_DEBUG_FUNCPTR (gst_faac_stop);
|
base_class->stop = GST_DEBUG_FUNCPTR (gst_faac_stop);
|
||||||
base_class->set_format = GST_DEBUG_FUNCPTR (gst_faac_set_format);
|
base_class->set_format = GST_DEBUG_FUNCPTR (gst_faac_set_format);
|
||||||
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_faac_handle_frame);
|
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_faac_handle_frame);
|
||||||
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_faac_getcaps);
|
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
g_object_class_install_property (gobject_class, PROP_QUALITY,
|
g_object_class_install_property (gobject_class, PROP_QUALITY,
|
||||||
|
@ -299,12 +293,9 @@ static const GstAudioChannelPosition aac_channel_positions[][8] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_faac_getcaps (GstAudioEncoder * enc, GstCaps * filter)
|
gst_faac_enc_generate_sink_caps (void)
|
||||||
{
|
{
|
||||||
static volatile gsize sinkcaps = 0;
|
GstCaps *caps = gst_caps_new_empty ();
|
||||||
|
|
||||||
if (g_once_init_enter (&sinkcaps)) {
|
|
||||||
GstCaps *tmp = gst_caps_new_empty ();
|
|
||||||
GstStructure *s, *t;
|
GstStructure *s, *t;
|
||||||
gint i, c;
|
gint i, c;
|
||||||
static const int rates[] = {
|
static const int rates[] = {
|
||||||
|
@ -327,30 +318,26 @@ gst_faac_getcaps (GstAudioEncoder * enc, GstCaps * filter)
|
||||||
"layout", G_TYPE_STRING, "interleaved", NULL);
|
"layout", G_TYPE_STRING, "interleaved", NULL);
|
||||||
gst_structure_set_value (s, "rate", &rates_arr);
|
gst_structure_set_value (s, "rate", &rates_arr);
|
||||||
|
|
||||||
for (i = 1; i <= 6; i++) {
|
t = gst_structure_copy (s);
|
||||||
|
gst_structure_set (t, "channels", G_TYPE_INT, 1, NULL);
|
||||||
|
gst_caps_append_structure (caps, t);
|
||||||
|
|
||||||
|
for (i = 2; i <= 6; i++) {
|
||||||
guint64 channel_mask = 0;
|
guint64 channel_mask = 0;
|
||||||
t = gst_structure_copy (s);
|
t = gst_structure_copy (s);
|
||||||
|
|
||||||
gst_structure_set (t, "channels", G_TYPE_INT, i, NULL);
|
gst_structure_set (t, "channels", G_TYPE_INT, i, NULL);
|
||||||
if (i > 1) {
|
|
||||||
for (c = 0; c < i; c++)
|
for (c = 0; c < i; c++)
|
||||||
channel_mask |=
|
channel_mask |= G_GUINT64_CONSTANT (1) << aac_channel_positions[i - 1][c];
|
||||||
G_GUINT64_CONSTANT (1) << aac_channel_positions[i - 1][c];
|
|
||||||
|
|
||||||
gst_structure_set (t, "channel-mask", GST_TYPE_BITMASK, channel_mask,
|
gst_structure_set (t, "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
|
||||||
NULL);
|
gst_caps_append_structure (caps, t);
|
||||||
}
|
|
||||||
gst_caps_append_structure (tmp, t);
|
|
||||||
}
|
}
|
||||||
gst_structure_free (s);
|
gst_structure_free (s);
|
||||||
g_value_unset (&rates_arr);
|
g_value_unset (&rates_arr);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (enc, "Generated sinkcaps: %" GST_PTR_FORMAT, tmp);
|
GST_DEBUG ("Generated sinkcaps: %" GST_PTR_FORMAT, caps);
|
||||||
|
return caps;
|
||||||
g_once_init_leave (&sinkcaps, (gsize) tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return gst_audio_encoder_proxy_getcaps (enc, (GstCaps *) sinkcaps, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue