Commit f870cef8 authored by Wim Taymans's avatar Wim Taymans
Browse files

Revert "rtpjpegpay/depay: Replace framerate caps field with fraction"

This reverts commit 9fd25a81.

We deal with sdp attributes in application/sdp, which are always strings.
parent 25082a50
...@@ -41,8 +41,6 @@ GST_STATIC_PAD_TEMPLATE ("src", ...@@ -41,8 +41,6 @@ GST_STATIC_PAD_TEMPLATE ("src",
/* /*
* "width = (int) 0, " * "width = (int) 0, "
* "height = (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 = ...@@ -58,7 +56,6 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
/* /*
* "width = (int) 0, " * "width = (int) 0, "
* "height = (int) 0, " * "height = (int) 0, "
* "framerate = (fraction) 0/1, "
* "a-framerate = (string) 0.00, " * "a-framerate = (string) 0.00, "
* "x-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, "
* "x-dimensions = (string) "0\,0", " * "x-dimensions = (string) "0\,0", "
...@@ -71,7 +68,6 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = ...@@ -71,7 +68,6 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
/* /*
* "width = (int) 0, " * "width = (int) 0, "
* "height = (int) 0, " * "height = (int) 0, "
* "framerate = (fraction) 0/1, "
* "a-framerate = (string) 0.00, " * "a-framerate = (string) 0.00, "
* "x-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, "
* "x-dimensions = (string) "0\,0", " * "x-dimensions = (string) "0\,0", "
...@@ -443,7 +439,6 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) ...@@ -443,7 +439,6 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
gint clock_rate; gint clock_rate;
const gchar *media_attr; const gchar *media_attr;
gint width = 0, height = 0; gint width = 0, height = 0;
gint num = 0, denom = 1;
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload); rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
...@@ -454,6 +449,14 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) ...@@ -454,6 +449,14 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
clock_rate = 90000; clock_rate = 90000;
depayload->clock_rate = clock_rate; 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 */ /* check for optional SDP attributes */
if ((media_attr = gst_structure_get_string (structure, "x-dimensions"))) { if ((media_attr = gst_structure_get_string (structure, "x-dimensions"))) {
if (sscanf (media_attr, "%d,%d", &width, &height) != 2 || width <= 0 || if (sscanf (media_attr, "%d,%d", &width, &height) != 2 || width <= 0 ||
...@@ -475,8 +478,9 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) ...@@ -475,8 +478,9 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
media_attr = gst_structure_get_string (structure, "x-framerate"); media_attr = gst_structure_get_string (structure, "x-framerate");
if (media_attr) { if (media_attr) {
GValue src = { 0 };
GValue dest = { 0 };
gchar *s; gchar *s;
gdouble rate;
/* canonicalise floating point string so we can handle framerate strings /* canonicalise floating point string so we can handle framerate strings
* in the form "24.930" or "24,930" irrespective of the current locale */ * 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) ...@@ -484,25 +488,19 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
g_strdelimit (s, ",", '.'); g_strdelimit (s, ",", '.');
/* convert the float to a fraction */ /* convert the float to a fraction */
rate = g_ascii_strtod (s, NULL); g_value_init (&src, G_TYPE_DOUBLE);
gst_util_double_to_fraction (rate, &num, &denom); g_value_set_double (&src, g_ascii_strtod (s, NULL));
g_free (s); g_value_init (&dest, GST_TYPE_FRACTION);
if (num < 0 || denom <= 0) { g_value_transform (&src, &dest);
goto invalid_framerate;
} 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) && g_free (s);
(num < 0 || denom <= 0)) {
goto invalid_framerate;
} }
rtpjpegdepay->width = 0;
rtpjpegdepay->height = 0;
rtpjpegdepay->media_width = width; rtpjpegdepay->media_width = width;
rtpjpegdepay->media_height = height; rtpjpegdepay->media_height = height;
rtpjpegdepay->frate_num = num;
rtpjpegdepay->frate_denom = denom;
return TRUE; return TRUE;
...@@ -511,11 +509,6 @@ invalid_dimension: ...@@ -511,11 +509,6 @@ invalid_dimension:
GST_ERROR_OBJECT (rtpjpegdepay, "invalid width/height from caps"); GST_ERROR_OBJECT (rtpjpegdepay, "invalid width/height from caps");
return FALSE; return FALSE;
} }
invalid_framerate:
{
GST_ERROR_OBJECT (rtpjpegdepay, "invalid framerate from caps");
return FALSE;
}
} }
static GstBuffer * static GstBuffer *
...@@ -650,18 +643,15 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) ...@@ -650,18 +643,15 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) { if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
GstCaps *outcaps; 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) { if (width > 0 && height > 0) {
gst_caps_set_simple (outcaps, "width", G_TYPE_INT, width, "height", gst_caps_set_simple (outcaps, "width", G_TYPE_INT, width, "height",
G_TYPE_INT, height, NULL); 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_pad_set_caps (depayload->srcpad, outcaps);
gst_caps_unref (outcaps); gst_caps_unref (outcaps);
......
...@@ -48,18 +48,9 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template = ...@@ -48,18 +48,9 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template =
GST_STATIC_CAPS ("image/jpeg, " GST_STATIC_CAPS ("image/jpeg, "
" width = (int) [ 1, MAX ], " " width = (int) [ 1, MAX ], "
" height = (int) [ 1, MAX ]; " " height = (int) [ 1, MAX ]; "
/* optional SDP attributes */
/*
* "framerate = (fraction) [ 0/1, MAX/1 ], "
*/
" video/x-jpeg, " " video/x-jpeg, "
" width = (int) [ 1, MAX ], " " width = (int) [ 1, MAX ], "
" height = (int) [ 1, MAX ]" " height = (int) [ 1, MAX ]")
/* optional SDP attributes */
/*
* "framerate = (fraction) [ 0/1, MAX/1 ] "
*/
)
); );
static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template = static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
...@@ -308,7 +299,8 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) ...@@ -308,7 +299,8 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
GstRtpJPEGPay *pay; GstRtpJPEGPay *pay;
gboolean res; gboolean res;
gint width, height; gint width, height;
gint num = 0, denom = 1; gint num = 0, denom;
gchar *rate = NULL;
pay = GST_RTP_JPEG_PAY (basepayload); pay = GST_RTP_JPEG_PAY (basepayload);
...@@ -339,15 +331,25 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) ...@@ -339,15 +331,25 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000); 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, res = gst_rtp_base_payload_set_outcaps (basepayload, "width", G_TYPE_INT,
width, "height", G_TYPE_INT, height, "framerate", GST_TYPE_FRACTION, width, "height", G_TYPE_INT, height, "a-framerate", G_TYPE_STRING,
num, denom, NULL); rate, NULL);
} else { } else if (rate == NULL) {
res = gst_rtp_base_payload_set_outcaps (basepayload, "width", res = gst_rtp_base_payload_set_outcaps (basepayload, "width",
G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
} }
if (rate != NULL)
g_free (rate);
return res; return res;
/* ERRORS */ /* ERRORS */
......
...@@ -781,8 +781,8 @@ static int rtp_jpeg_frame_count = 1; ...@@ -781,8 +781,8 @@ static int rtp_jpeg_frame_count = 1;
GST_START_TEST (rtp_jpeg) GST_START_TEST (rtp_jpeg)
{ {
rtp_pipeline_test (rtp_jpeg_frame_data, rtp_jpeg_frame_data_size, 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", rtp_jpeg_frame_count, "video/x-jpeg,height=640,width=480", "rtpjpegpay",
"rtpjpegpay", "rtpjpegdepay", 0, 0, FALSE); "rtpjpegdepay", 0, 0, FALSE);
} }
GST_END_TEST; GST_END_TEST;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment