From 9c596d20fe03896eb4817d11c35cfb45c83eaa94 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Tue, 2 Aug 2016 13:48:43 +0200 Subject: [PATCH] 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 --- gst/aiff/Makefile.am | 2 +- gst/aiff/aiffparse.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gst/aiff/Makefile.am b/gst/aiff/Makefile.am index ebe42305c2..ee13fcf721 100644 --- a/gst/aiff/Makefile.am +++ b/gst/aiff/Makefile.am @@ -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) diff --git a/gst/aiff/aiffparse.c b/gst/aiff/aiffparse.c index 27c8313d34..bde90fcd5d 100644 --- a/gst/aiff/aiffparse.c +++ b/gst/aiff/aiffparse.c @@ -59,6 +59,7 @@ #include "aiffparse.h" #include #include +#include #include 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;