changeset 3080:1f13c07c4d80

aac: report stream bitrate if available
author William Pitcock <nenolod@atheme.org>
date Mon, 27 Apr 2009 05:45:43 -0500
parents 1637a04513dd
children 4e3712e142b4
files src/aac/libmp4.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/libmp4.c	Mon Apr 27 05:43:28 2009 -0500
+++ b/src/aac/libmp4.c	Mon Apr 27 05:45:43 2009 -0500
@@ -654,6 +654,7 @@
     gchar       *ttemp = NULL, *stemp = NULL;
     gchar       *temp = g_strdup(filename);
     gchar       *xmmstitle = NULL;
+    gint        bitrate;
     gboolean    remote = aud_str_has_prefix_nocase(filename, "http:") ||
 			 aud_str_has_prefix_nocase(filename, "https:");
 
@@ -696,6 +697,15 @@
     else
         xmmstitle = g_strdup(g_basename(temp));
 
+    ttemp = aud_vfs_get_metadata(file, "content-bitrate");
+    if (ttemp != NULL && *ttemp != '0')
+    {
+        bitrate = atoi(ttemp);
+        g_free(ttemp);
+    }
+    else
+        bitrate = -1;
+
     bufferconsumed = aac_probe(streambuffer, buffervalid);
     if(bufferconsumed) {
       buffervalid -= bufferconsumed;
@@ -724,7 +734,7 @@
         return;
     }
 
-    playback->set_params(playback, xmmstitle, -1, -1, samplerate, channels);
+    playback->set_params(playback, xmmstitle, -1, bitrate, samplerate, channels);
     playback->output->flush(0);
 
     while(buffer_playing && buffervalid > 0 && streambuffer != NULL)
@@ -762,7 +772,7 @@
 
                     ostmp = stemp;
 
-                    playback->set_params(playback, xmmstitle, -1, -1, samplerate, channels);
+                    playback->set_params(playback, xmmstitle, -1, bitrate, samplerate, channels);
                 }
             }