diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c
index 01216ad..a72c66e 100644
--- a/gst/rtp/gstrtpjpegdepay.c
+++ b/gst/rtp/gstrtpjpegdepay.c
@@ -26,6 +26,8 @@
 #include <string.h>
 #include "gstrtpjpegdepay.h"
 
+extern double round(double x);
+
 GST_DEBUG_CATEGORY_STATIC (rtpjpegdepay_debug);
 #define GST_CAT_DEFAULT (rtpjpegdepay_debug)
 
@@ -50,11 +52,35 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) \"video\", "
         "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
-        "clock-rate = (int) 90000, " "encoding-name = (string) \"JPEG\";"
+        "clock-rate = (int) 90000, "
+        "encoding-name = (string) \"JPEG\"; "
+	/* optional caps */
+	/*
+	"width = (int) [16, 4096], " // FIXME: MAX_WIDTH too low in gstjpegdec
+	"height = (int) [8, 4096], " // FIXME: MAX_HEIGHT too low
+	"framerate = (fraction) [ 0/1, MAX ], "
+	*/
+        /* optional SDP attributes */
+        /*
+        "a-framerate = (double) 0.00; "
+        "x-dimensions = (string) \"1234,1234\", "
+        */
         "application/x-rtp, "
         "media = (string) \"video\", "
         "payload = (int) " GST_RTP_PAYLOAD_JPEG_STRING ", "
-        "clock-rate = (int) 90000")
+        "clock-rate = (int) 90000"
+	/* optional caps */
+	/*
+	"width = (int) [16, 4096], " // FIXME: MAX_WIDTH too low in gstjpegdec
+	"height = (int) [8, 4096], " // FIXME: MAX_HEIGHT too low
+	"framerate = (fraction) [ 0/1, MAX ], "
+	*/
+        /* optional SDP attributes */
+        /*
+        "a-framerate = (double) 0.0, "
+        "x-dimensions = (string) \"1234,1234\""
+        */
+        )
     );
 
 GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
@@ -383,19 +409,64 @@ gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstRtpJPEGDepay *rtpjpegdepay;
   GstStructure *structure;
   gint clock_rate;
+  
+  const gchar *media_attr;
 
+  
   rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
 
   structure = gst_caps_get_structure (caps, 0);
+  GST_DEBUG_OBJECT(rtpjpegdepay,"Caps set: %" GST_PTR_FORMAT, caps);
 
   if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
     clock_rate = 90000;
   depayload->clock_rate = clock_rate;
+  media_attr=gst_structure_get_string (structure, "x-dimensions");
+  if (media_attr) {
+    gchar *c;
+    c=strchr(media_attr,',');
+    if (c) {
+      *c=0;
+      rtpjpegdepay->media_width = atoi(media_attr);
+      rtpjpegdepay->media_height = atoi(c+1);
+      /* the string should not be modified but nobody noticed */ 
+      *c=',';
+    } else {
+      media_attr=0;
+    }
+  }
+
+  if (!rtpjpegdepay->media_width)
+    gst_structure_get_int (structure, "width", &rtpjpegdepay->media_width);
+
+  if (!rtpjpegdepay->media_height)
+    gst_structure_get_int (structure, "height", &rtpjpegdepay->media_height);
+
+  media_attr=gst_structure_get_string (structure, "a-framerate");
+  if (media_attr) {
+
+    double d_framerate;
+    d_framerate=atof(media_attr);
+
+    if (d_framerate-(round(d_framerate))) {
+      rtpjpegdepay->framerate=(gint)round(d_framerate*100.0);
+      rtpjpegdepay->denom=100;
+
+    } else {
+      rtpjpegdepay->framerate=(gint)d_framerate;
+      rtpjpegdepay->denom=1;
+    }
+  } else {
+    if (!gst_structure_get_fraction(structure,"framerate",&rtpjpegdepay->framerate,&rtpjpegdepay->denom)) {
+      rtpjpegdepay->framerate=0;
+      rtpjpegdepay->denom=1;
+    }
+  }
 
   rtpjpegdepay->width = 0;
   rtpjpegdepay->height = 0;
 
-  return TRUE;
+      return TRUE;
 }
 
 static GstBuffer *
@@ -439,6 +510,16 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   width = payload[6] * 8;
   height = payload[7] * 8;
 
+/* allow frame dimensions > 2040, passed in SDP session or media attributes
+ * from gstrtspsrc.c (gst_rtspsrc_sdp_attributes_to_caps), or in caps
+ */
+
+  if (!width)
+    width=rtpjpegdepay->media_width;
+
+  if (!height)
+    height=rtpjpegdepay->media_height;
+
   if (width == 0 || height == 0)
     goto invalid_dimension;
 
@@ -515,12 +596,16 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (frag_offset == 0) {
     guint size;
 
+// i cant see the use for rtpjpegdepay->width and ->height,
+// they are referenced nowhere but here and in gst_rtp_jpeg_depay_setcaps where they are set to 0
+// so maybe we could replace "media_width" and "media_height" with "width" and "height" ?
+
     if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
       GstCaps *outcaps;
 
       outcaps =
-          gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, 0,
-          1, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
+          gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, rtpjpegdepay->framerate,
+          rtpjpegdepay->denom, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
       gst_pad_set_caps (depayload->srcpad, outcaps);
       gst_caps_unref (outcaps);
 
diff --git a/gst/rtp/gstrtpjpegdepay.h b/gst/rtp/gstrtpjpegdepay.h
index 7e0c918..4b7a43c 100644
--- a/gst/rtp/gstrtpjpegdepay.h
+++ b/gst/rtp/gstrtpjpegdepay.h
@@ -48,7 +48,10 @@ struct _GstRtpJPEGDepay
 
   /* cached quant tables */
   guint8 * qtables[255];
-
+  gint framerate;
+  gint denom;
+  gint media_width;
+  gint media_height;
   gint width, height;
 };
 
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 5b0b6c8..908766f 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -217,6 +217,10 @@ static void gst_rtspsrc_get_property (GObject * object, guint prop_id,
 
 static void gst_rtspsrc_uri_handler_init (gpointer g_iface,
     gpointer iface_data);
+
+static void gst_rtspsrc_sdp_attributes_to_caps(GArray *attributes,
+    GstCaps *caps);
+
 static GstCaps *gst_rtspsrc_media_to_caps (gint pt, const GstSDPMedia * media);
 
 static GstStateChangeReturn gst_rtspsrc_change_state (GstElement * element,
@@ -785,6 +789,11 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx)
     stream->pt = atoi (payload);
     /* convert caps */
     stream->caps = gst_rtspsrc_media_to_caps (stream->pt, media);
+    
+    GST_DEBUG ( "mapping sdp session level attributes to caps");
+    gst_rtspsrc_sdp_attributes_to_caps(sdp->attributes,stream->caps);
+    GST_DEBUG ( "mapping sdp media level attributes to caps");
+    gst_rtspsrc_sdp_attributes_to_caps(media->attributes,stream->caps);
 
     if (stream->pt >= 96) {
       /* If we have a dynamic payload type, see if we have a stream with the
@@ -1002,6 +1011,45 @@ gst_rtspsrc_parse_rtpmap (const gchar * rtpmap, gint * payload, gchar ** name,
 }
 
 /*
+ * Mapping SDP attributes to caps
+ *
+ * prepend 'a-' to IANA registered sdp attributes names
+ * (ie: not prefixed with 'x-') in order to avoid
+ * collision with gstreamer standard caps properties names
+ *
+ */
+static void
+gst_rtspsrc_sdp_attributes_to_caps(GArray *attributes, GstCaps *caps) {
+
+  if (attributes->len > 0) {
+    GstStructure *s;
+    guint i;
+
+    s = gst_caps_get_structure (caps, 0);
+
+    for (i = 0; i < attributes->len; i++) {
+      GstSDPAttribute *attr =
+        &g_array_index (attributes, GstSDPAttribute, i);
+   
+      if ( (attr->key[0]!='x') || (attr->key[1]!='-') ) {
+        gchar *key;
+
+        key=g_malloc(strlen(attr->key)+2);
+        strcpy(key,"a-");
+        strcpy(key+2,attr->key);
+        GST_DEBUG ("adding caps: %s=%s", key, attr->value); 
+        gst_structure_set (s, key, G_TYPE_STRING, attr->value, NULL);
+        g_free(key);
+
+      } else {
+        GST_DEBUG ("adding caps: %s=%s", attr->key, attr->value); 
+        gst_structure_set (s, attr->key, G_TYPE_STRING, attr->value, NULL);
+      }
+    }
+  }
+}
+
+/*
  *  Mapping of caps to and from SDP fields:
  *
  *   m=<media> <UDP port> RTP/AVP <payload> 
