aiffparse: Add tags for container format and bitrate

The bitrate is added to help downstream elements (like uridecodebin)
figure out a proper network buffer size

https://bugzilla.gnome.org/show_bug.cgi?id=769389
This commit is contained in:
Carlos Rafael Giani 2016-08-02 13:48:43 +02:00 committed by Sebastian Dröge
parent dc6e4ccbf9
commit 9c596d20fe
2 changed files with 28 additions and 1 deletions

View file

@ -9,7 +9,7 @@ libgstaiff_la_CFLAGS = \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS)
libgstaiff_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_API_VERSION) -lgstaudio-$(GST_API_VERSION)\
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_API_VERSION) -lgstaudio-$(GST_API_VERSION) -lgstpbutils-$(GST_API_VERSION) \
$(GST_BASE_LIBS) \
$(LIBM)
libgstaiff_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -59,6 +59,7 @@
#include "aiffparse.h"
#include <gst/audio/audio.h>
#include <gst/tag/tag.h>
#include <gst/pbutils/descriptions.h>
#include <gst/gst-i18n-plugin.h>
GST_DEBUG_CATEGORY (aiffparse_debug);
@ -995,6 +996,32 @@ gst_aiff_parse_stream_headers (GstAiffParse * aiff)
aiff->bytes_per_sample = aiff->channels * aiff->width / 8;
aiff->bps = aiff->bytes_per_sample * aiff->rate;
if (!aiff->tags)
aiff->tags = gst_tag_list_new_empty ();
{
GstCaps *templ_caps = gst_pad_get_pad_template_caps (aiff->sinkpad);
gst_pb_utils_add_codec_description_to_tag_list (aiff->tags,
GST_TAG_CONTAINER_FORMAT, templ_caps);
gst_caps_unref (templ_caps);
}
if (aiff->bps) {
guint bitrate = aiff->bps * 8;
GST_DEBUG_OBJECT (aiff, "adding bitrate of %u bps to tag list",
bitrate);
/* At the moment, aiffparse only supports uncompressed PCM data.
* Therefore, nominal, actual, minimum, maximum bitrate are the same.
* XXX: If AIFF-C support is extended to include compression,
* make sure that aiff->bps is set properly. */
gst_tag_list_add (aiff->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_BITRATE, bitrate, GST_TAG_NOMINAL_BITRATE, bitrate,
GST_TAG_MINIMUM_BITRATE, bitrate, GST_TAG_MAXIMUM_BITRATE,
bitrate, NULL);
}
if (aiff->bytes_per_sample <= 0)
goto no_bytes_per_sample;