mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-13 17:55:30 +00:00
Revert "rtpjpegpay/depay: Replace framesize caps with width/height"
This reverts commit 0075d111b4
.
Extra application/x-rtp are SDP fields, which are strings.
This commit is contained in:
parent
f870cef8bc
commit
190b3d6688
2 changed files with 49 additions and 56 deletions
|
@ -37,11 +37,6 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("image/jpeg")
|
GST_STATIC_CAPS ("image/jpeg")
|
||||||
/* optional SDP attributes */
|
|
||||||
/*
|
|
||||||
* "width = (int) 0, "
|
|
||||||
* "height = (int) 0, "
|
|
||||||
*/
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
|
static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
|
||||||
|
@ -50,15 +45,13 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("application/x-rtp, "
|
GST_STATIC_CAPS ("application/x-rtp, "
|
||||||
"media = (string) \"video\", "
|
"media = (string) \"video\", "
|
||||||
"clock-rate = (int) 90000, "
|
"clock-rate = (int) 90000, " "encoding-name = (string) \"JPEG\"; "
|
||||||
"encoding-name = (string) \"JPEG\"; "
|
|
||||||
/* optional SDP attributes */
|
/* optional SDP attributes */
|
||||||
/*
|
/*
|
||||||
* "width = (int) 0, "
|
|
||||||
* "height = (int) 0, "
|
|
||||||
* "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", "
|
* "a-framesize = (string) 1234-1234, "
|
||||||
|
* "x-dimensions = (string) \"1234,1234\", "
|
||||||
*/
|
*/
|
||||||
"application/x-rtp, "
|
"application/x-rtp, "
|
||||||
"media = (string) \"video\", "
|
"media = (string) \"video\", "
|
||||||
|
@ -66,11 +59,10 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
|
||||||
"clock-rate = (int) 90000"
|
"clock-rate = (int) 90000"
|
||||||
/* optional SDP attributes */
|
/* optional SDP attributes */
|
||||||
/*
|
/*
|
||||||
* "width = (int) 0, "
|
|
||||||
* "height = (int) 0, "
|
|
||||||
* "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", "
|
* "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;
|
GstStructure *structure;
|
||||||
gint clock_rate;
|
gint clock_rate;
|
||||||
const gchar *media_attr;
|
const gchar *media_attr;
|
||||||
gint width = 0, height = 0;
|
|
||||||
|
|
||||||
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
|
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
|
||||||
|
|
||||||
|
@ -459,17 +450,21 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
|
|
||||||
/* 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 ||
|
gint w, h;
|
||||||
height <= 0) {
|
|
||||||
goto invalid_dimension;
|
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) {
|
if ((media_attr = gst_structure_get_string (structure, "a-framesize"))) {
|
||||||
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, "height", &height) && height <= 0) {
|
|
||||||
goto invalid_dimension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to get a framerate */
|
/* try to get a framerate */
|
||||||
|
@ -499,16 +494,7 @@ gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtpjpegdepay->media_width = width;
|
|
||||||
rtpjpegdepay->media_height = height;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
invalid_dimension:
|
|
||||||
{
|
|
||||||
GST_ERROR_OBJECT (rtpjpegdepay, "invalid width/height from caps");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
|
@ -645,13 +631,8 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
|
|
||||||
outcaps =
|
outcaps =
|
||||||
gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION,
|
gst_caps_new_simple ("image/jpeg", "framerate", GST_TYPE_FRACTION,
|
||||||
rtpjpegdepay->frate_num, rtpjpegdepay->frate_denom, NULL);
|
rtpjpegdepay->frate_num, rtpjpegdepay->frate_denom, "width",
|
||||||
|
G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
|
||||||
if (width > 0 && height > 0) {
|
|
||||||
gst_caps_set_simple (outcaps, "width", G_TYPE_INT, width, "height",
|
|
||||||
G_TYPE_INT, height, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_pad_set_caps (depayload->srcpad, outcaps);
|
gst_pad_set_caps (depayload->srcpad, outcaps);
|
||||||
gst_caps_unref (outcaps);
|
gst_caps_unref (outcaps);
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,7 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("image/jpeg, "
|
GST_STATIC_CAPS ("image/jpeg; " "video/x-jpeg")
|
||||||
" width = (int) [ 1, MAX ], "
|
|
||||||
" height = (int) [ 1, MAX ]; "
|
|
||||||
" video/x-jpeg, "
|
|
||||||
" width = (int) [ 1, MAX ], "
|
|
||||||
" height = (int) [ 1, MAX ]")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
|
static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
|
||||||
|
@ -62,8 +57,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
" payload = (int) 26 , "
|
" payload = (int) 26 , "
|
||||||
" clock-rate = (int) 90000, "
|
" clock-rate = (int) 90000, "
|
||||||
" encoding-name = (string) \"JPEG\", "
|
" encoding-name = (string) \"JPEG\", "
|
||||||
" width = (int) [ 1, MAX ], "
|
" width = (int) [ 1, 65536 ], "
|
||||||
" height = (int) [ 1, MAX ]")
|
" height = (int) [ 1, 65536 ]")
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (rtpjpegpay_debug);
|
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);
|
GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
|
||||||
GstRtpJPEGPay *pay;
|
GstRtpJPEGPay *pay;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
gint width, height;
|
gint width = -1, height = -1;
|
||||||
gint num = 0, denom;
|
gint num = 0, denom;
|
||||||
gchar *rate = NULL;
|
gchar *rate = NULL;
|
||||||
|
gchar *dim = NULL;
|
||||||
|
gchar *size;
|
||||||
|
|
||||||
pay = GST_RTP_JPEG_PAY (basepayload);
|
pay = GST_RTP_JPEG_PAY (basepayload);
|
||||||
|
|
||||||
|
@ -320,8 +317,6 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > 2040 || width > 2040) {
|
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->height = 0;
|
||||||
pay->width = 0;
|
pay->width = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -338,17 +333,34 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
rate = g_strdup_printf("%f", framerate);
|
rate = g_strdup_printf("%f", framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rate != NULL) {
|
size = g_strdup_printf("%d-%d", width, height);
|
||||||
res = gst_rtp_base_payload_set_outcaps (basepayload, "width", G_TYPE_INT,
|
|
||||||
width, "height", G_TYPE_INT, height, "a-framerate", G_TYPE_STRING,
|
if (pay->width == 0) {
|
||||||
rate, NULL);
|
GST_DEBUG_OBJECT (pay,
|
||||||
} else if (rate == NULL) {
|
"width or height are greater than 2040, adding x-dimensions to caps");
|
||||||
res = gst_rtp_base_payload_set_outcaps (basepayload, "width",
|
dim = g_strdup_printf ("%d,%d", width, height);
|
||||||
G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
if (rate != NULL)
|
||||||
g_free (rate);
|
g_free (rate);
|
||||||
|
g_free (size);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue