Index: gst/rtp/gstrtpjpegdepay.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/rtp/gstrtpjpegdepay.c,v
retrieving revision 1.2
diff -c -r1.2 gstrtpjpegdepay.c
*** gst/rtp/gstrtpjpegdepay.c	9 Dec 2008 14:19:16 -0000	1.2
--- gst/rtp/gstrtpjpegdepay.c	14 Dec 2008 11:37:29 -0000
***************
*** 24,29 ****
--- 24,30 ----
  #include <gst/rtp/gstrtpbuffer.h>
  
  #include <string.h>
+ #include <math.h>
  #include "gstrtpjpegdepay.h"
  
  GST_DEBUG_CATEGORY_STATIC (rtpjpegdepay_debug);
***************
*** 50,60 ****
      GST_STATIC_CAPS ("application/x-rtp, "
          "media = (string) \"video\", "
          "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
!         "clock-rate = (int) 90000, " "encoding-name = (string) \"JPEG\";"
          "application/x-rtp, "
          "media = (string) \"video\", "
          "payload = (int) " GST_RTP_PAYLOAD_JPEG_STRING ", "
!         "clock-rate = (int) 90000")
      );
  
  GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
--- 51,87 ----
      GST_STATIC_CAPS ("application/x-rtp, "
          "media = (string) \"video\", "
          "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
!         "clock-rate = (int) 90000, "
!         "encoding-name = (string) \"JPEG\"; "
! 	/* optional attributes */
! 	/*
! 	"width = (int) [16, 4096], " // FIXME: MAX_WIDTH too low in gstjpegdec
! 	"height = (int) [8, 4096], " // FIXME: MAX_HEIGHT too low
! 	*/
!         /* optional SDP media attributes */
!         /*
!         "x-width = (string) \"1234\", "
!         "x-height = (string) \"1234\", "
!         "x-dimensions = (string) \"1234,1234\", "
!         "x-framerate = (double) 0.00; "
!         */
          "application/x-rtp, "
          "media = (string) \"video\", "
          "payload = (int) " GST_RTP_PAYLOAD_JPEG_STRING ", "
!         "clock-rate = (int) 90000"
! 	/* optional attributes */
! 	/*
! 	"width = (int) [16, 4096], " // FIXME: MAX_WIDTH too low in gstjpegdec
! 	"height = (int) [8, 4096], " // FIXME: MAX_HEIGHT too low
! 	*/
!         /* optional SDP media attributes */
!         /*
!         "x-width = (string) \"1234\", "
!         "x-height = (string) \"1234\", "
!         "x-dimensions = (string) \"1234,1234\", "
!         "x-framerate = (double) 0.00; "
!         */
!         )
      );
  
  GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
***************
*** 392,409 ****
    GstCaps *outcaps;
    gint clock_rate;
    gboolean res;
  
    rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
  
    structure = gst_caps_get_structure (caps, 0);
  
    if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
      clock_rate = 90000;
    depayload->clock_rate = clock_rate;
  
    outcaps =
!       gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, 0, 1,
!       NULL);
    res = gst_pad_set_caps (depayload->srcpad, outcaps);
    gst_caps_unref (outcaps);
  
--- 419,489 ----
    GstCaps *outcaps;
    gint clock_rate;
    gboolean res;
+   const gchar *media_attr;
+   guint framerate;
+   guint div;
  
    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 (!media_attr) {
+     media_attr=gst_structure_get_string (structure, "x-width");
+     rtpjpegdepay->media_width = (media_attr) ? atoi(media_attr) : 0;
+     media_attr=gst_structure_get_string (structure, "x-height");
+     rtpjpegdepay->media_height = (media_attr) ? atoi(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, "x-framerate");
+   if (media_attr) {
+ 
+     double d_framerate;
+     d_framerate=atof(media_attr);
+ 
+     if (d_framerate-(round(d_framerate))) {
+       framerate=(guint)round(d_framerate*100.0);
+       div=100;
+ 
+     } else {
+       framerate=(guint)d_framerate;
+       div=1;
+     }
+ 
+   } else {
+     framerate=0;
+     div=1;
+   }
+ 
    outcaps =
!     gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, framerate, div,
!     NULL);
! 
    res = gst_pad_set_caps (depayload->srcpad, outcaps);
    gst_caps_unref (outcaps);
  
***************
*** 451,456 ****
--- 531,546 ----
    width = payload[6] * 8;
    height = payload[7] * 8;
  
+ /* allow frame dimensions > 2040, passed in SDP media attributes
+  * from gstrtspsrc.c (gst_rtpsrc_media_to_caps), or in caps
+  */
+ 
+   if (!width)
+     width=rtpjpegdepay->media_width;
+ 
+   if (!height)
+     height=rtpjpegdepay->media_height;
+ 
    GST_DEBUG_OBJECT (rtpjpegdepay, "frag %u, type %u, Q %d, width %u, height %u",
        frag_offset, type, Q, width, height);
  
