mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
flvdemux: use aac codec-data to adjust samplerate if needed
Based on patch by Fabien Lebaillif-Delamare <fabien@arq-media.com> Fixes #636621.
This commit is contained in:
parent
8ca094795a
commit
6f8ce30c20
2 changed files with 29 additions and 7 deletions
|
@ -1,9 +1,9 @@
|
||||||
plugin_LTLIBRARIES = libgstflv.la
|
plugin_LTLIBRARIES = libgstflv.la
|
||||||
|
|
||||||
libgstflv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
libgstflv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||||
libgstflv_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) \
|
libgstflv_la_LIBADD = -lgstpbutils-@GST_MAJORMINOR@ \
|
||||||
-lgstpbutils-@GST_MAJORMINOR@
|
$(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS)
|
||||||
libgstflv_la_LDFLAGS = ${GST_PLUGIN_LDFLAGS}
|
libgstflv_la_LDFLAGS = ${GST_PLUGIN_LDFLAGS}
|
||||||
libgstflv_la_SOURCES = gstflvdemux.c gstflvmux.c
|
libgstflv_la_SOURCES = gstflvdemux.c gstflvmux.c
|
||||||
libgstflv_la_LIBTOOLFLAGS = --tag=disable-static
|
libgstflv_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/base/gstbytereader.h>
|
#include <gst/base/gstbytereader.h>
|
||||||
#include <gst/pbutils/descriptions.h>
|
#include <gst/pbutils/descriptions.h>
|
||||||
|
#include <gst/pbutils/pbutils.h>
|
||||||
|
|
||||||
static GstStaticPadTemplate flv_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate flv_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
|
@ -575,6 +576,7 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
gchar *codec_name = NULL;
|
gchar *codec_name = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
guint adjusted_rate = rate;
|
||||||
|
|
||||||
switch (codec_tag) {
|
switch (codec_tag) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -603,9 +605,29 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
caps = gst_caps_new_simple ("audio/x-nellymoser", NULL);
|
caps = gst_caps_new_simple ("audio/x-nellymoser", NULL);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
{
|
||||||
|
/* use codec-data to extract and verify samplerate */
|
||||||
|
if (demux->audio_codec_data &&
|
||||||
|
GST_BUFFER_SIZE (demux->audio_codec_data) >= 2) {
|
||||||
|
gint freq_index;
|
||||||
|
|
||||||
|
freq_index =
|
||||||
|
((GST_READ_UINT16_BE (GST_BUFFER_DATA (demux->audio_codec_data))));
|
||||||
|
freq_index = (freq_index & 0x0780) >> 7;
|
||||||
|
adjusted_rate =
|
||||||
|
gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
|
||||||
|
|
||||||
|
if (adjusted_rate && (rate != adjusted_rate)) {
|
||||||
|
GST_LOG_OBJECT (demux, "Ajusting AAC sample rate %d -> %d", rate,
|
||||||
|
adjusted_rate);
|
||||||
|
} else {
|
||||||
|
adjusted_rate = rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
caps = gst_caps_new_simple ("audio/mpeg",
|
caps = gst_caps_new_simple ("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
|
"mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 7:
|
case 7:
|
||||||
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
|
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -624,8 +646,8 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_caps_set_simple (caps,
|
gst_caps_set_simple (caps, "rate", G_TYPE_INT, adjusted_rate,
|
||||||
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
|
"channels", G_TYPE_INT, channels, NULL);
|
||||||
|
|
||||||
if (demux->audio_codec_data) {
|
if (demux->audio_codec_data) {
|
||||||
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER,
|
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER,
|
||||||
|
@ -635,7 +657,7 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
ret = gst_pad_set_caps (demux->audio_pad, caps);
|
ret = gst_pad_set_caps (demux->audio_pad, caps);
|
||||||
|
|
||||||
if (G_LIKELY (ret)) {
|
if (G_LIKELY (ret)) {
|
||||||
/* Store the caps we have set */
|
/* Store the caps we got from tags */
|
||||||
demux->audio_codec_tag = codec_tag;
|
demux->audio_codec_tag = codec_tag;
|
||||||
demux->rate = rate;
|
demux->rate = rate;
|
||||||
demux->channels = channels;
|
demux->channels = channels;
|
||||||
|
@ -851,7 +873,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
switch (aac_packet_type) {
|
switch (aac_packet_type) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
/* AudioSpecificConfic data */
|
/* AudioSpecificConfig data */
|
||||||
GST_LOG_OBJECT (demux, "got an AAC codec data packet");
|
GST_LOG_OBJECT (demux, "got an AAC codec data packet");
|
||||||
if (demux->audio_codec_data) {
|
if (demux->audio_codec_data) {
|
||||||
gst_buffer_unref (demux->audio_codec_data);
|
gst_buffer_unref (demux->audio_codec_data);
|
||||||
|
|
Loading…
Reference in a new issue