From 190b3d66888ddf6cb5310d1149740004307e906c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 31 May 2013 15:08:16 +0200 Subject: [PATCH] Revert "rtpjpegpay/depay: Replace framesize caps with width/height" This reverts commit 0075d111b475ca27895ee9476154260b6902940b. Extra application/x-rtp are SDP fields, which are strings. --- gst/rtp/gstrtpjpegdepay.c | 57 +++++++++++++-------------------------- gst/rtp/gstrtpjpegpay.c | 48 ++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 56 deletions(-) diff --git a/gst/rtp/gstrtpjpegdepay.c b/gst/rtp/gstrtpjpegdepay.c index 0dbc736345..f10bf464f7 100644 --- a/gst/rtp/gstrtpjpegdepay.c +++ b/gst/rtp/gstrtpjpegdepay.c @@ -37,11 +37,6 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("image/jpeg") - /* optional SDP attributes */ - /* - * "width = (int) 0, " - * "height = (int) 0, " - */ ); static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = @@ -50,15 +45,13 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = GST_PAD_ALWAYS, GST_STATIC_CAPS ("application/x-rtp, " "media = (string) \"video\", " - "clock-rate = (int) 90000, " - "encoding-name = (string) \"JPEG\"; " + "clock-rate = (int) 90000, " "encoding-name = (string) \"JPEG\"; " /* optional SDP attributes */ /* - * "width = (int) 0, " - * "height = (int) 0, " * "a-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, " - * "x-dimensions = (string) "0\,0", " + * "a-framesize = (string) 1234-1234, " + * "x-dimensions = (string) \"1234,1234\", " */ "application/x-rtp, " "media = (string) \"video\", " @@ -66,11 +59,10 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template = "clock-rate = (int) 90000" /* optional SDP attributes */ /* - * "width = (int) 0, " - * "height = (int) 0, " * "a-framerate = (string) 0.00, " * "x-framerate = (string) 0.00, " - * "x-dimensions = (string) "0\,0", " + * "a-framesize = (string) 1234-1234, " + * "x-dimensions = (string) \"1234,1234\"" */ ) ); @@ -438,7 +430,6 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) GstStructure *structure; gint clock_rate; const gchar *media_attr; - gint width = 0, height = 0; rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload); @@ -459,17 +450,21 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) /* 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 || - height <= 0) { - goto invalid_dimension; + gint w, h; + + if (sscanf (media_attr, "%d,%d", &w, &h) == 2) { + rtpjpegdepay->media_width = w; + rtpjpegdepay->media_height = h; } } - if (gst_structure_get_int (structure, "width", &width) && width <= 0) { - goto invalid_dimension; - } - if (gst_structure_get_int (structure, "height", &height) && height <= 0) { - goto invalid_dimension; + if ((media_attr = gst_structure_get_string (structure, "a-framesize"))) { + gint w, h; + + if (sscanf (media_attr, "%d-%d", &w, &h) == 2) { + rtpjpegdepay->media_width = w; + rtpjpegdepay->media_height = h; + } } /* try to get a framerate */ @@ -499,16 +494,7 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) g_free (s); } - rtpjpegdepay->media_width = width; - rtpjpegdepay->media_height = height; - return TRUE; - -invalid_dimension: - { - GST_ERROR_OBJECT (rtpjpegdepay, "invalid width/height from caps"); - return FALSE; - } } static GstBuffer * @@ -645,13 +631,8 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) 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); - } - + rtpjpegdepay->frate_num, rtpjpegdepay->frate_denom, "width", + G_TYPE_INT, width, "height", G_TYPE_INT, height, 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 bea26e6170..859d16b16c 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -45,12 +45,7 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("image/jpeg, " - " width = (int) [ 1, MAX ], " - " height = (int) [ 1, MAX ]; " - " video/x-jpeg, " - " width = (int) [ 1, MAX ], " - " height = (int) [ 1, MAX ]") + GST_STATIC_CAPS ("image/jpeg; " "video/x-jpeg") ); static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template = @@ -62,8 +57,8 @@ GST_STATIC_PAD_TEMPLATE ("src", " payload = (int) 26 , " " clock-rate = (int) 90000, " " encoding-name = (string) \"JPEG\", " - " width = (int) [ 1, MAX ], " - " height = (int) [ 1, MAX ]") + " width = (int) [ 1, 65536 ], " + " height = (int) [ 1, 65536 ]") ); GST_DEBUG_CATEGORY_STATIC (rtpjpegpay_debug); @@ -298,9 +293,11 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) GstStructure *caps_structure = gst_caps_get_structure (caps, 0); GstRtpJPEGPay *pay; gboolean res; - gint width, height; + gint width = -1, height = -1; gint num = 0, denom; gchar *rate = NULL; + gchar *dim = NULL; + gchar *size; pay = GST_RTP_JPEG_PAY (basepayload); @@ -320,8 +317,6 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) } if (height > 2040 || width > 2040) { - GST_DEBUG_OBJECT (pay, - "width or height > 2040, need to rely on caps instead of RTP header"); pay->height = 0; pay->width = 0; } else { @@ -338,17 +333,34 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) 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, "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); + size = g_strdup_printf("%d-%d", width, height); + + if (pay->width == 0) { + GST_DEBUG_OBJECT (pay, + "width or height are greater than 2040, adding x-dimensions to caps"); + 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, "a-framesize", G_TYPE_STRING, size, + "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, "a-framesize", G_TYPE_STRING, size, NULL); + } else if (rate == NULL && dim != NULL) { + res = gst_rtp_base_payload_set_outcaps (basepayload, "x-dimensions", + G_TYPE_STRING, dim, "a-framesize", G_TYPE_STRING, size, NULL); + } else { + res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framesize", + G_TYPE_STRING, size, NULL); + } + + if (dim != NULL) + g_free (dim); if (rate != NULL) g_free (rate); + g_free (size); return res;