--- gstsouphttpsrc.h.org	2009-08-11 00:15:55.000000000 +0200
+++ gstsouphttpsrc.h	2010-12-21 14:09:32.174875003 +0100
@@ -87,6 +87,8 @@
   GstStructure *extra_headers;
 
   guint timeout;
+
+  guint64 datarate_min, datarate_max, datarate_cur, datarate_tmp;
 };
 
 struct _GstSoupHTTPSrcClass {
--- gstsouphttpsrc.c.org	2010-05-14 02:40:16.000000000 +0200
+++ gstsouphttpsrc.c	2010-12-21 14:55:02.787248002 +0100
@@ -113,7 +113,10 @@
   PROP_IRADIO_URL,
   PROP_IRADIO_TITLE,
   PROP_TIMEOUT,
-  PROP_EXTRA_HEADERS
+  PROP_EXTRA_HEADERS,
+  PROP_DATARATE_MIN,
+  PROP_DATARATE_MAX,
+  PROP_DATARATE_CUR
 };
 
 #define DEFAULT_USER_AGENT           "GStreamer souphttpsrc "
@@ -264,6 +267,18 @@
       g_param_spec_boxed ("extra-headers", "Extra Headers",
           "Extra headers to append to the HTTP request",
           GST_TYPE_STRUCTURE, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, PROP_DATARATE_MIN,
+      g_param_spec_uint64 ("datarate-min", "min. Datarate",
+          "Value in bytes for minimal datarate", 0,
+          G_MAXUINT64, 0, G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class, PROP_DATARATE_MAX,
+      g_param_spec_uint64 ("datarate-max", "max. Datarate",
+          "Value in bytes for maximal datarate", 0,
+          G_MAXUINT64, 0, G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class, PROP_DATARATE_CUR,
+      g_param_spec_uint64 ("datarate-cur", "cur. Datarate",
+          "Value in bytes for current datarate", 0,
+          G_MAXUINT64, 0, G_PARAM_READABLE));
 
   /* icecast stuff */
   g_object_class_install_property (gobject_class,
@@ -539,6 +554,15 @@
     case PROP_EXTRA_HEADERS:
       gst_value_set_structure (value, src->extra_headers);
       break;
+    case PROP_DATARATE_MIN:
+      g_value_set_uint64 (value, src->datarate_min);
+      break;
+    case PROP_DATARATE_MAX:
+      g_value_set_uint64 (value, src->datarate_max);
+      break;
+    case PROP_DATARATE_CUR:
+      g_value_set_uint64 (value, src->datarate_cur);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -990,6 +1014,9 @@
   GstBaseSrc *basesrc;
   guint64 new_position;
 
+  GTimeVal now;
+  static GTimeVal lst = { 0, 0 };
+
   if (G_UNLIKELY (msg != src->msg)) {
     GST_DEBUG_OBJECT (src, "got chunk, but not for current message");
     return;
@@ -1003,6 +1030,30 @@
   GST_DEBUG_OBJECT (src, "got chunk of %" G_GSIZE_FORMAT " bytes",
       chunk->length);
 
+  /* calculate datarate */
+  g_get_current_time(&now);
+
+  if(((double)now.tv_sec - lst.tv_sec) + (now.tv_usec - lst.tv_usec) / 1000000.0 >= 1.0)
+  {
+    if(src->datarate_tmp && src->datarate_tmp < src->datarate_min)
+    {
+	src->datarate_min = src->datarate_tmp;
+    }
+
+    if(src->datarate_tmp > src->datarate_max)
+    {
+	src->datarate_max = src->datarate_tmp;
+    }
+
+    src->datarate_cur = src->datarate_tmp;
+    src->datarate_tmp = 0;
+    lst = now;
+  }
+  else
+  {
+    src->datarate_tmp += chunk->length;
+  }
+
   /* Extract the GstBuffer from the SoupBuffer and set its fields. */
   *src->outbuf = GST_BUFFER_CAST (soup_buffer_get_owner (chunk));
 
@@ -1221,6 +1272,11 @@
 {
   GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
 
+  src->datarate_min = G_MAXUINT64;
+  src->datarate_max = 0;
+  src->datarate_cur = 0;
+  src->datarate_tmp = 0;
+
   GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location);
 
   if (!src->location) {
