faac: Add bitrate info to the tags output.
authorJan Schmidt <jan@centricular.com>
Sat, 5 Sep 2015 13:38:44 +0000 (23:38 +1000)
committerJan Schmidt <jan@centricular.com>
Sat, 5 Sep 2015 13:42:50 +0000 (23:42 +1000)
Makes it possible for muxers to know the target bitrate as soon
as encoding starts, which flvmux now uses.

ext/faac/gstfaac.c

index 9adc11fb8321756040fd136b5d72273bac346ca9..a4a7c36ae96ef622339ab2fe5dce69d38e7e7520 100644 (file)
@@ -341,6 +341,22 @@ gst_faac_enc_generate_sink_caps (void)
   return caps;
 }
 
+static void
+gst_faac_set_tags (GstFaac * faac)
+{
+  GstTagList *taglist;
+
+  /* create a taglist and add a bitrate tag to it */
+  taglist = gst_tag_list_new_empty ();
+  gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
+      GST_TAG_BITRATE, faac->bitrate, NULL);
+
+  gst_audio_encoder_merge_tags (GST_AUDIO_ENCODER (faac), taglist,
+      GST_TAG_MERGE_REPLACE);
+
+  gst_tag_list_unref (taglist);
+}
+
 static gboolean
 gst_faac_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
 {
@@ -375,6 +391,8 @@ gst_faac_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
   if (!result)
     goto done;
 
+  gst_faac_set_tags (faac);
+
   /* report needs to base class */
   gst_audio_encoder_set_frame_samples_min (enc, faac->samples);
   gst_audio_encoder_set_frame_samples_max (enc, faac->samples);