/*
* "width = (int) 0, "
* "height = (int) 0, "
- * "framerate = (fraction) 0/1, "
- * "x-dimensions = (string) "0\,0", "
*/
);
/*
* "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", "
/*
* "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", "
gint clock_rate;
const gchar *media_attr;
gint width = 0, height = 0;
- gint num = 0, denom = 1;
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
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 ||
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 */
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;
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 *
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);