diff --git a/gst/flv/Makefile.am b/gst/flv/Makefile.am index b2d37ebbb5..ab08cdd9e7 100644 --- a/gst/flv/Makefile.am +++ b/gst/flv/Makefile.am @@ -1,9 +1,9 @@ plugin_LTLIBRARIES = libgstflv.la libgstflv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -libgstflv_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) \ - -lgstpbutils-@GST_MAJORMINOR@ -libgstflv_la_LDFLAGS = ${GST_PLUGIN_LDFLAGS} +libgstflv_la_LIBADD = -lgstpbutils-@GST_MAJORMINOR@ \ + $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) +libgstflv_la_LDFLAGS = ${GST_PLUGIN_LDFLAGS} libgstflv_la_SOURCES = gstflvdemux.c gstflvmux.c libgstflv_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c index 04d4b5b639..d976fedba2 100644 --- a/gst/flv/gstflvdemux.c +++ b/gst/flv/gstflvdemux.c @@ -40,6 +40,7 @@ #include #include #include +#include static GstStaticPadTemplate flv_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, @@ -575,6 +576,7 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag, GstCaps *caps = NULL; gchar *codec_name = NULL; gboolean ret = FALSE; + guint adjusted_rate = rate; switch (codec_tag) { 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); break; 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", "mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL); break; + } case 7: caps = gst_caps_new_simple ("audio/x-alaw", NULL); break; @@ -624,8 +646,8 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag, goto beach; } - gst_caps_set_simple (caps, - "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); + gst_caps_set_simple (caps, "rate", G_TYPE_INT, adjusted_rate, + "channels", G_TYPE_INT, channels, NULL); if (demux->audio_codec_data) { 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); if (G_LIKELY (ret)) { - /* Store the caps we have set */ + /* Store the caps we got from tags */ demux->audio_codec_tag = codec_tag; demux->rate = rate; demux->channels = channels; @@ -851,7 +873,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer) switch (aac_packet_type) { case 0: { - /* AudioSpecificConfic data */ + /* AudioSpecificConfig data */ GST_LOG_OBJECT (demux, "got an AAC codec data packet"); if (demux->audio_codec_data) { gst_buffer_unref (demux->audio_codec_data);