wavparse: Add tags for container format and bitrate for uncompressed PCM
authorCarlos Rafael Giani <dv@pseudoterminal.org>
Tue, 2 Aug 2016 12:01:14 +0000 (14:01 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 2 Aug 2016 12:22:25 +0000 (15:22 +0300)
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
gst/wavparse/gstwavparse.c

index d3f1818..4d4247e 100644 (file)
@@ -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)
index a83b068..82294d0 100644 (file)
@@ -54,6 +54,7 @@
 #include "gstwavparse.h"
 #include "gst/riff/riff-media.h"
 #include <gst/base/gsttypefindhelper.h>
+#include <gst/pbutils/descriptions.h>
 #include <gst/gst-i18n-plugin.h>
 
 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);