mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
rtpjpegpay: Add optional framerate caps for use in SDP
The format of the value adheres to RFC4566 and it is meant to be parsed and included in the SDP sent by gst-rtsp-server to its clients. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=700748
This commit is contained in:
parent
2d3910fc79
commit
919eed0787
1 changed files with 34 additions and 3 deletions
|
@ -291,6 +291,9 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
GstRtpJPEGPay *pay;
|
GstRtpJPEGPay *pay;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
gint width = -1, height = -1;
|
gint width = -1, height = -1;
|
||||||
|
gint num = 0, denom;
|
||||||
|
gchar *rate = NULL;
|
||||||
|
gchar *dim = NULL;
|
||||||
|
|
||||||
pay = GST_RTP_JPEG_PAY (basepayload);
|
pay = GST_RTP_JPEG_PAY (basepayload);
|
||||||
|
|
||||||
|
@ -308,6 +311,11 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gst_structure_get_fraction (caps_structure, "framerate", &num, &denom) &&
|
||||||
|
(num < 0 || denom <= 0)) {
|
||||||
|
goto invalid_framerate;
|
||||||
|
}
|
||||||
|
|
||||||
if (height > 2040 || width > 2040) {
|
if (height > 2040 || width > 2040) {
|
||||||
pay->height = 0;
|
pay->height = 0;
|
||||||
pay->width = 0;
|
pay->width = 0;
|
||||||
|
@ -318,19 +326,37 @@ 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 (pay->width == 0) {
|
if (num > 0)
|
||||||
gchar *dim;
|
{
|
||||||
|
gdouble framerate;
|
||||||
|
gst_util_fraction_to_double (num, denom, &framerate);
|
||||||
|
rate = g_strdup_printf("%f", framerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pay->width == 0) {
|
||||||
GST_DEBUG_OBJECT (pay,
|
GST_DEBUG_OBJECT (pay,
|
||||||
"width or height are greater than 2040, adding x-dimensions to caps");
|
"width or height are greater than 2040, adding x-dimensions to caps");
|
||||||
dim = g_strdup_printf ("%d,%d", width, height);
|
dim = g_strdup_printf ("%d,%d", width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate != NULL && dim != NULL) {
|
||||||
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framerate",
|
||||||
|
G_TYPE_STRING, rate, "x-dimensions", G_TYPE_STRING, dim, NULL);
|
||||||
|
} else if (rate != NULL && dim == NULL) {
|
||||||
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framerate",
|
||||||
|
G_TYPE_STRING, rate, NULL);
|
||||||
|
} else if (rate == NULL && dim != NULL) {
|
||||||
res = gst_rtp_base_payload_set_outcaps (basepayload, "x-dimensions",
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "x-dimensions",
|
||||||
G_TYPE_STRING, dim, NULL);
|
G_TYPE_STRING, dim, NULL);
|
||||||
g_free (dim);
|
|
||||||
} else {
|
} else {
|
||||||
res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
|
res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dim != NULL)
|
||||||
|
g_free (dim);
|
||||||
|
if (rate != NULL)
|
||||||
|
g_free (rate);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -339,6 +365,11 @@ invalid_dimension:
|
||||||
GST_ERROR_OBJECT (pay, "Invalid width/height from caps");
|
GST_ERROR_OBJECT (pay, "Invalid width/height from caps");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
invalid_framerate:
|
||||||
|
{
|
||||||
|
GST_ERROR_OBJECT (pay, "Invalid framerate from caps");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
|
|
Loading…
Reference in a new issue