mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
ext/faac/gstfaac.c: Add decoder specific info on the caps.
Original commit message from CVS: * ext/faac/gstfaac.c: (gst_faac_configure_source_pad), (gst_faac_chain): Add decoder specific info on the caps. Some cleanups here and there.
This commit is contained in:
parent
1b8664b4c5
commit
2dec089aeb
2 changed files with 81 additions and 39 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-09-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/faac/gstfaac.c: (gst_faac_configure_source_pad),
|
||||||
|
(gst_faac_chain):
|
||||||
|
Add decoder specific info on the caps.
|
||||||
|
Some cleanups here and there.
|
||||||
|
|
||||||
2006-09019 Edgard Lima <edgard.lima@indt.org.br>
|
2006-09019 Edgard Lima <edgard.lima@indt.org.br>
|
||||||
|
|
||||||
Patch by: deadchip <internalerror@gmail.com> and
|
Patch by: deadchip <internalerror@gmail.com> and
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "gstfaac.h"
|
#include "gstfaac.h"
|
||||||
|
|
||||||
|
@ -354,9 +355,10 @@ static gboolean
|
||||||
gst_faac_configure_source_pad (GstFaac * faac)
|
gst_faac_configure_source_pad (GstFaac * faac)
|
||||||
{
|
{
|
||||||
GstCaps *allowed_caps;
|
GstCaps *allowed_caps;
|
||||||
GstCaps *src_caps;
|
GstCaps *srccaps;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gint n, ver, mpegversion;
|
gint n, ver, mpegversion;
|
||||||
|
faacEncConfiguration *conf;
|
||||||
|
|
||||||
mpegversion = FAAC_DEFAULT_MPEGVERSION;
|
mpegversion = FAAC_DEFAULT_MPEGVERSION;
|
||||||
|
|
||||||
|
@ -367,7 +369,7 @@ gst_faac_configure_source_pad (GstFaac * faac)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (gst_caps_is_empty (allowed_caps))
|
if (gst_caps_is_empty (allowed_caps))
|
||||||
goto done;
|
goto empty_caps;
|
||||||
|
|
||||||
if (!gst_caps_is_any (allowed_caps)) {
|
if (!gst_caps_is_any (allowed_caps)) {
|
||||||
for (n = 0; n < gst_caps_get_size (allowed_caps); n++) {
|
for (n = 0; n < gst_caps_get_size (allowed_caps); n++) {
|
||||||
|
@ -380,42 +382,66 @@ gst_faac_configure_source_pad (GstFaac * faac)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gst_caps_unref (allowed_caps);
|
||||||
|
|
||||||
src_caps = gst_caps_new_simple ("audio/mpeg",
|
/* 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",
|
||||||
"mpegversion", G_TYPE_INT, mpegversion,
|
"mpegversion", G_TYPE_INT, mpegversion,
|
||||||
"channels", G_TYPE_INT, faac->channels,
|
"channels", G_TYPE_INT, faac->channels,
|
||||||
"rate", G_TYPE_INT, faac->samplerate, NULL);
|
"rate", G_TYPE_INT, faac->samplerate, NULL);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (faac, "src pad caps: %" GST_PTR_FORMAT, src_caps);
|
if (mpegversion == 4) {
|
||||||
|
GstBuffer *codec_data;
|
||||||
|
guint8 *config = NULL;
|
||||||
|
gulong config_len = 0;
|
||||||
|
|
||||||
ret = gst_pad_set_caps (faac->srcpad, src_caps);
|
/* get the config string */
|
||||||
gst_caps_unref (src_caps);
|
GST_DEBUG_OBJECT (faac, "retrieving decoder info");
|
||||||
|
faacEncGetDecoderSpecificInfo (faac->handle, &config, &config_len);
|
||||||
|
|
||||||
if (ret) {
|
/* copy it into a buffer */
|
||||||
faacEncConfiguration *conf;
|
codec_data = gst_buffer_new_and_alloc (config_len);
|
||||||
|
memcpy (GST_BUFFER_DATA (codec_data), config, config_len);
|
||||||
|
|
||||||
/* new conf */
|
/* add to caps */
|
||||||
conf = faacEncGetCurrentConfiguration (faac->handle);
|
gst_caps_set_simple (srccaps,
|
||||||
conf->mpegVersion = (mpegversion == 4) ? MPEG4 : MPEG2;
|
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
||||||
conf->aacObjectType = faac->profile;
|
|
||||||
conf->allowMidside = faac->midside;
|
gst_buffer_unref (codec_data);
|
||||||
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)) {
|
|
||||||
GST_WARNING ("Faac doesn't support the current configuration");
|
|
||||||
ret = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
GST_DEBUG_OBJECT (faac, "src pad caps: %" GST_PTR_FORMAT, srccaps);
|
||||||
|
|
||||||
gst_caps_unref (allowed_caps);
|
ret = gst_pad_set_caps (faac->srcpad, srccaps);
|
||||||
|
gst_caps_unref (srccaps);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -480,22 +506,12 @@ gst_faac_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
|
|
||||||
faac = GST_FAAC (gst_pad_get_parent (pad));
|
faac = GST_FAAC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (!faac->handle) {
|
if (!faac->handle)
|
||||||
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
|
goto no_handle;
|
||||||
("format wasn't negotiated before chain function"));
|
|
||||||
gst_buffer_unref (inbuf);
|
|
||||||
result = GST_FLOW_ERROR;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GST_PAD_CAPS (faac->srcpad)) {
|
if (!GST_PAD_CAPS (faac->srcpad)) {
|
||||||
if (!gst_faac_configure_source_pad (faac)) {
|
if (!gst_faac_configure_source_pad (faac))
|
||||||
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
|
goto nego_failed;
|
||||||
("failed to negotiate MPEG/AAC format with next element"));
|
|
||||||
gst_buffer_unref (inbuf);
|
|
||||||
result = GST_FLOW_ERROR;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size = GST_BUFFER_SIZE (inbuf);
|
size = GST_BUFFER_SIZE (inbuf);
|
||||||
|
@ -607,7 +623,26 @@ gst_faac_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_object_unref (faac);
|
gst_object_unref (faac);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue