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 =
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\", "
"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\""
*/
)
);
GstStructure *structure;
gint clock_rate;
const gchar *media_attr;
- gint width = 0, height = 0;
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
/* 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 */
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 *
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);
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 =
" 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);
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);
}
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 {
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;