Index: ext/lame/gstlame.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-ugly/ext/lame/gstlame.c,v
retrieving revision 1.102
diff -u -r1.102 gstlame.c
--- ext/lame/gstlame.c	30 Dec 2006 20:01:35 -0000	1.102
+++ ext/lame/gstlame.c	1 Jan 2007 15:52:36 -0000
@@ -263,6 +263,7 @@
   ARG_NO_SHORT_BLOCKS,
   ARG_EMPHASIS,
   ARG_VBR_QUALITY,
+  ARG_OUT_SAMPLERATE,
 #ifdef GSTLAME_PRESET
   ARG_XINGHEADER,               /* FIXME: remove in 0.11 */
   ARG_PRESET
@@ -480,6 +481,10 @@
       g_param_spec_boolean ("xingheader", "Output Xing Header",
           "Output Xing Header (BROKEN, use xingmux instead)",
           FALSE, G_PARAM_READWRITE));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUT_SAMPLERATE,
+      g_param_spec_int ("out-samplerate", "Output sample rate (Hz)",
+          "Force an output sample rate (0 for autoselect)",
+          0, 48000, 0, G_PARAM_READWRITE));
 #ifdef GSTLAME_PRESET
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PRESET,
       g_param_spec_enum ("preset", "Lame Preset", "Lame Preset",
@@ -510,7 +515,13 @@
     goto setup_failed;
 
 
-  out_samplerate = lame_get_out_samplerate (lame->lgf);
+  if (!lame->out_samplerate) {
+    out_samplerate = lame_get_out_samplerate (lame->lgf);
+  }
+  else {
+  	lame_set_out_samplerate (lame->lgf, lame->out_samplerate);
+  	out_samplerate = lame_get_out_samplerate (lame->lgf);
+  }
   if (out_samplerate == 0)
     goto zero_output_rate;
   if (out_samplerate != lame->samplerate) {
@@ -525,6 +536,11 @@
       "layer", G_TYPE_INT, 3,
       "channels", G_TYPE_INT, lame->num_channels,
       "rate", G_TYPE_INT, out_samplerate, NULL);
+      
+  if (!lame->vbr) {
+  	gst_caps_set_simple (othercaps, "bitrate", G_TYPE_INT,
+  	    lame->bitrate, NULL);
+  }
 
   /* and use these caps */
   gst_pad_set_caps (lame->srcpad, othercaps);
@@ -629,6 +645,7 @@
   lame->no_short_blocks = TRUE; /* lame_get_no_short_blocks (lame->lgf); */
   lame->emphasis = lame_get_emphasis (lame->lgf);
   lame->preset = 0;
+  lame->out_samplerate = 0;
   lame_close (lame->lgf);
   lame->lgf = NULL;
 
@@ -653,11 +670,11 @@
   gint ___rate = rate;                                                    \
   if (rate <= 64 && (rate % 8) != 0) {                                    \
     ___rate = GST_ROUND_UP_8 (rate);                                      \
-  } else if (rate <= 128 && (rate % 16) != 0) {                           \
+  } else if (rate > 64 && rate <= 128 && (rate % 16) != 0) {              \
     ___rate = GST_ROUND_UP_16 (rate);                                     \
-  } else if (rate <= 256 && (rate % 32) != 0) {                           \
+  } else if (rate > 128 && rate <= 256 && (rate % 32) != 0) {             \
     ___rate = GST_ROUND_UP_32 (rate);                                     \
-  } else if (rate <= 320 && (rate % 64) != 0) {                           \
+  } else if (rate > 256 && rate <= 320 && (rate % 64) != 0) {             \
     ___rate = GST_ROUND_UP_64 (rate);                                     \
   }                                                                       \
   if (___rate != rate) {                                                  \
@@ -775,6 +792,9 @@
       break;
     case ARG_XINGHEADER:
       break;
+    case ARG_OUT_SAMPLERATE:
+      lame->out_samplerate = g_value_get_int (value);
+      break;
 #ifdef GSTLAME_PRESET
     case ARG_PRESET:
       lame->preset = g_value_get_enum (value);
@@ -890,6 +910,9 @@
       break;
     case ARG_XINGHEADER:
       break;
+    case ARG_OUT_SAMPLERATE:
+      g_value_set_int (value, lame->out_samplerate);
+      break;
 #ifdef GSTLAME_PRESET
     case ARG_PRESET:
       g_value_set_enum (value, lame->preset);
Index: ext/lame/gstlame.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-ugly/ext/lame/gstlame.h,v
retrieving revision 1.26
diff -u -r1.26 gstlame.h
--- ext/lame/gstlame.h	14 Dec 2006 10:15:24 -0000	1.26
+++ ext/lame/gstlame.h	1 Jan 2007 15:52:36 -0000
@@ -92,6 +92,7 @@
   gboolean no_short_blocks;
   gboolean emphasis;
   gint preset;
+  gint out_samplerate;
 
   lame_global_flags *lgf;
 
