From 91e302e00de45ac8ccfc64ea34ab952d2040acf0 Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Tue, 2 Aug 2016 14:01:14 +0200 Subject: [PATCH] wavparse: Add tags for container format and bitrate for uncompressed PCM The PCM bitrate is added to help downstream elements (like uridecodebin) figure out a proper network buffer size https://bugzilla.gnome.org/show_bug.cgi?id=769390 --- gst/wavparse/Makefile.am | 1 + gst/wavparse/gstwavparse.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gst/wavparse/Makefile.am b/gst/wavparse/Makefile.am index d3f1818a32..4d4247e27e 100644 --- a/gst/wavparse/Makefile.am +++ b/gst/wavparse/Makefile.am @@ -10,6 +10,7 @@ libgstwavparse_la_LIBADD = \ -lgstriff-@GST_API_VERSION@ \ -lgstaudio-@GST_API_VERSION@ \ -lgsttag-@GST_API_VERSION@ \ + -lgstpbutils-@GST_API_VERSION@ \ $(GST_BASE_LIBS) \ $(GST_LIBS) \ $(LIBM) diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index a83b06879f..82294d0547 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -54,6 +54,7 @@ #include "gstwavparse.h" #include "gst/riff/riff-media.h" #include +#include #include GST_DEBUG_CATEGORY_STATIC (wavparse_debug); @@ -1223,9 +1224,25 @@ gst_wavparse_stream_headers (GstWavParse * wav) wav->got_fmt = TRUE; - if (codec_name) { + if (wav->tags == NULL) wav->tags = gst_tag_list_new_empty (); + { + GstCaps *templ_caps = gst_pad_get_pad_template_caps (wav->sinkpad); + gst_pb_utils_add_codec_description_to_tag_list (wav->tags, + GST_TAG_CONTAINER_FORMAT, templ_caps); + gst_caps_unref (templ_caps); + } + + /* If bps is nonzero, then we do have a valid bitrate that can be + * announced in a tag list. */ + if (wav->bps) { + guint bitrate = wav->bps * 8; + gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE, + GST_TAG_BITRATE, bitrate, NULL); + } + + if (codec_name) { gst_tag_list_add (wav->tags, GST_TAG_MERGE_REPLACE, GST_TAG_AUDIO_CODEC, codec_name, NULL);