From: Wim Taymans Date: Fri, 31 May 2013 13:05:51 +0000 (+0200) Subject: Revert "rtpjpegpay/depay: Replace framerate caps field with fraction" X-Git-Tag: 1.1.1~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f870cef8bc4550e6e8b368b037d7dc84fe10c998;p=platform%2Fupstream%2Fgst-plugins-good.git Revert "rtpjpegpay/depay: Replace framerate caps field with fraction" This reverts commit 9fd25a810b859e0ec205176578735100d83de4af. We deal with sdp attributes in application/sdp, which are always strings. --- diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c index 0ba9c40..0dbc736 100644 --- a/gst/rtp/gstrtpjpegdepay.c +++ b/gst/rtp/gstrtpjpegdepay.c @@ -41,8 +41,6 @@ GST_STATIC_PAD_TEMPLATE ("src", /* * "width = (int) 0, " * "height = (int) 0, " - * "framerate = (fraction) 0/1, " - * "x-dimensions = (string) "0\,0", " */ ); @@ -58,7 +56,6 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = /* * "width = (int) 0, " * "height = (int) 0, " - * "framerate = (fraction) 0/1, " * "a-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, " * "x-dimensions = (string) "0\,0", " @@ -71,7 +68,6 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = /* * "width = (int) 0, " * "height = (int) 0, " - * "framerate = (fraction) 0/1, " * "a-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, " * "x-dimensions = (string) "0\,0", " @@ -443,7 +439,6 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) gint clock_rate; const gchar *media_attr; gint width = 0, height = 0; - gint num = 0, denom = 1; rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload); @@ -454,6 +449,14 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) clock_rate = 90000; depayload->clock_rate = clock_rate; + /* reset defaults */ + rtpjpegdepay->width = 0; + rtpjpegdepay->height = 0; + rtpjpegdepay->media_width = 0; + rtpjpegdepay->media_height = 0; + rtpjpegdepay->frate_num = 0; + rtpjpegdepay->frate_denom = 1; + /* check for optional SDP attributes */ if ((media_attr = gst_structure_get_string (structure, "x-dimensions"))) { if (sscanf (media_attr, "%d,%d", &width, &height) != 2 || width <= 0 || @@ -475,8 +478,9 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) media_attr = gst_structure_get_string (structure, "x-framerate"); if (media_attr) { + GValue src = { 0 }; + GValue dest = { 0 }; gchar *s; - gdouble rate; /* canonicalise floating point string so we can handle framerate strings * in the form "24.930" or "24,930" irrespective of the current locale */ @@ -484,25 +488,19 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) g_strdelimit (s, ",", '.'); /* convert the float to a fraction */ - rate = g_ascii_strtod (s, NULL); - gst_util_double_to_fraction (rate, &num, &denom); - g_free (s); - if (num < 0 || denom <= 0) { - goto invalid_framerate; - } - } + g_value_init (&src, G_TYPE_DOUBLE); + g_value_set_double (&src, g_ascii_strtod (s, NULL)); + g_value_init (&dest, GST_TYPE_FRACTION); + g_value_transform (&src, &dest); + + rtpjpegdepay->frate_num = gst_value_get_fraction_numerator (&dest); + rtpjpegdepay->frate_denom = gst_value_get_fraction_denominator (&dest); - if (gst_structure_get_fraction (structure, "framerate", &num, &denom) && - (num < 0 || denom <= 0)) { - goto invalid_framerate; + g_free (s); } - rtpjpegdepay->width = 0; - rtpjpegdepay->height = 0; rtpjpegdepay->media_width = width; rtpjpegdepay->media_height = height; - rtpjpegdepay->frate_num = num; - rtpjpegdepay->frate_denom = denom; return TRUE; @@ -511,11 +509,6 @@ invalid_dimension: GST_ERROR_OBJECT (rtpjpegdepay, "invalid width/height from caps"); return FALSE; } -invalid_framerate: - { - GST_ERROR_OBJECT (rtpjpegdepay, "invalid framerate from caps"); - return FALSE; - } } static GstBuffer * @@ -650,18 +643,15 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) { GstCaps *outcaps; - outcaps = gst_caps_new_empty_simple ("image/jpeg"); + outcaps = + gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION, + rtpjpegdepay->frate_num, rtpjpegdepay->frate_denom, NULL); if (width > 0 && height > 0) { gst_caps_set_simple (outcaps, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); } - if (rtpjpegdepay->frate_num > 0) { - gst_caps_set_simple (outcaps, "framerate", GST_TYPE_FRACTION, - rtpjpegdepay->frate_num, rtpjpegdepay->frate_denom, NULL); - } - gst_pad_set_caps (depayload->srcpad, outcaps); gst_caps_unref (outcaps); diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c index 0ff684b..bea26e6 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -48,18 +48,9 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template = GST_STATIC_CAPS ("image/jpeg, " " width = (int) [ 1, MAX ], " " height = (int) [ 1, MAX ]; " - /* optional SDP attributes */ - /* - * "framerate = (fraction) [ 0/1, MAX/1 ], " - */ " video/x-jpeg, " " width = (int) [ 1, MAX ], " - " height = (int) [ 1, MAX ]" - /* optional SDP attributes */ - /* - * "framerate = (fraction) [ 0/1, MAX/1 ] " - */ - ) + " height = (int) [ 1, MAX ]") ); static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template = @@ -308,7 +299,8 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) GstRtpJPEGPay *pay; gboolean res; gint width, height; - gint num = 0, denom = 1; + gint num = 0, denom; + gchar *rate = NULL; pay = GST_RTP_JPEG_PAY (basepayload); @@ -339,15 +331,25 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000); - if (num > 0) { + if (num > 0) + { + gdouble framerate; + gst_util_fraction_to_double (num, denom, &framerate); + rate = g_strdup_printf("%f", framerate); + } + + if (rate != NULL) { res = gst_rtp_base_payload_set_outcaps (basepayload, "width", G_TYPE_INT, - width, "height", G_TYPE_INT, height, "framerate", GST_TYPE_FRACTION, - num, denom, NULL); - } else { + width, "height", G_TYPE_INT, height, "a-framerate", G_TYPE_STRING, + rate, NULL); + } else if (rate == NULL) { res = gst_rtp_base_payload_set_outcaps (basepayload, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); } + if (rate != NULL) + g_free (rate); + return res; /* ERRORS */ diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c index b1dcc2c..3de1f91 100644 --- a/tests/check/elements/rtp-payloading.c +++ b/tests/check/elements/rtp-payloading.c @@ -781,8 +781,8 @@ static int rtp_jpeg_frame_count = 1; GST_START_TEST (rtp_jpeg) { rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size, - rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480,framerate=30/1", - "rtpjpegpay", "rtpjpegdepay", 0, 0, FALSE); + rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480", "rtpjpegpay", + "rtpjpegdepay", 0, 0, FALSE); } GST_END_TEST;