2 * Copyright (C) 2008 Axis Communications <dev-gstreamer@axis.com>
3 * @author Bjorn Ostby <bjorn.ostby@axis.com>
4 * @author Peter Kjellerstedt <peter.kjellerstedt@axis.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * SECTION:element-rtpjpegpay
25 * Payload encode JPEG pictures into RTP packets according to RFC 2435.
26 * For detailed information see: http://www.rfc-editor.org/rfc/rfc2435.txt
28 * The payloader takes a JPEG picture, scans the header for quantization
29 * tables (if needed) and constructs the RTP packet header followed by
30 * the actual JPEG entropy scan.
32 * The payloader assumes that correct width and height is found in the caps.
40 #include <gst/rtp/gstrtpbuffer.h>
42 #include "gstrtpjpegpay.h"
44 static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template =
45 GST_STATIC_PAD_TEMPLATE ("sink",
48 GST_STATIC_CAPS ("image/jpeg; " "video/x-jpeg")
51 static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
52 GST_STATIC_PAD_TEMPLATE ("src",
55 GST_STATIC_CAPS ("application/x-rtp, "
56 " media = (string) \"video\", "
57 " payload = (int) 26 , "
58 " clock-rate = (int) 90000, " " encoding-name = (string) \"JPEG\"")
61 GST_DEBUG_CATEGORY_STATIC (rtpjpegpay_debug);
62 #define GST_CAT_DEFAULT (rtpjpegpay_debug)
67 * Prefix length in the header before the quantization tables:
68 * Two size bytes and one byte for precision
70 #define QUANT_PREFIX_LEN 3
73 typedef enum _RtpJpegMarker RtpJpegMarker;
77 * @JPEG_MARKER: Prefix for JPEG marker
78 * @JPEG_MARKER_SOI: Start of Image marker
79 * @JPEG_MARKER_JFIF: JFIF marker
80 * @JPEG_MARKER_CMT: Comment marker
81 * @JPEG_MARKER_DQT: Define Quantization Table marker
82 * @JPEG_MARKER_SOF: Start of Frame marker
83 * @JPEG_MARKER_DHT: Define Huffman Table marker
84 * @JPEG_MARKER_SOS: Start of Scan marker
85 * @JPEG_MARKER_EOI: End of Image marker
86 * @JPEG_MARKER_DRI: Define Restart Interval marker
87 * @JPEG_MARKER_H264: H264 marker
89 * Identifers for markers in JPEG header
94 JPEG_MARKER_SOI = 0xD8,
95 JPEG_MARKER_JFIF = 0xE0,
96 JPEG_MARKER_CMT = 0xFE,
97 JPEG_MARKER_DQT = 0xDB,
98 JPEG_MARKER_SOF = 0xC0,
99 JPEG_MARKER_DHT = 0xC4,
100 JPEG_MARKER_SOS = 0xDA,
101 JPEG_MARKER_EOI = 0xD9,
102 JPEG_MARKER_DRI = 0xDD,
103 JPEG_MARKER_H264 = 0xE4
106 #define DEFAULT_JPEG_QUANT 255
108 #define DEFAULT_JPEG_QUALITY 255
109 #define DEFAULT_JPEG_TYPE 1
123 Q_TABLE_MAX /* only support for two tables at the moment */
126 typedef struct _RtpJpegHeader RtpJpegHeader;
130 * @type_spec: type specific
131 * @offset: fragment offset
133 * @q: quantization table for this frame
134 * @width: width of image in 8-pixel multiples
135 * @height: height of image in 8-pixel multiples
138 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
139 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 * | Type-specific | Fragment Offset |
141 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
142 * | Type | Q | Width | Height |
143 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 struct _RtpJpegHeader
158 * @precision: specify size of quantization tables
159 * @length: length of quantization data
162 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
163 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
164 * | MBZ | Precision | Length |
165 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
166 * | Quantization Table Data |
168 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
184 * RtpRestartMarkerHeader:
185 * @restartInterval: number of MCUs that appear between restart markers
186 * @restartFirstLastCount: a combination of the first packet mark in the chunk
187 * last packet mark in the chunk and the position of the
188 * first restart interval in the current "chunk"
191 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193 * | Restart Interval |F|L| Restart Count |
194 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 * The restart marker header is implemented according to the following
197 * methodology specified in section 3.1.7 of rfc2435.txt.
199 * "If the restart intervals in a frame are not guaranteed to be aligned
200 * with packet boundaries, the F (first) and L (last) bits MUST be set
201 * to 1 and the Restart Count MUST be set to 0x3FFF. This indicates
202 * that a receiver MUST reassemble the entire frame before decoding it."
208 guint16 restart_interval;
209 guint16 restart_count;
210 } RtpRestartMarkerHeader;
219 /* FIXME: restart marker header currently unsupported */
221 static void gst_rtp_jpeg_pay_set_property (GObject * object, guint prop_id,
222 const GValue * value, GParamSpec * pspec);
224 static void gst_rtp_jpeg_pay_get_property (GObject * object, guint prop_id,
225 GValue * value, GParamSpec * pspec);
227 static gboolean gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload,
230 static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * pad,
233 #define gst_rtp_jpeg_pay_parent_class parent_class
234 G_DEFINE_TYPE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GST_TYPE_RTP_BASE_PAYLOAD);
237 gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
239 GObjectClass *gobject_class;
240 GstElementClass *gstelement_class;
241 GstRTPBasePayloadClass *gstrtpbasepayload_class;
243 gobject_class = (GObjectClass *) klass;
244 gstelement_class = (GstElementClass *) klass;
245 gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
247 gobject_class->set_property = gst_rtp_jpeg_pay_set_property;
248 gobject_class->get_property = gst_rtp_jpeg_pay_get_property;
250 gst_element_class_add_pad_template (gstelement_class,
251 gst_static_pad_template_get (&gst_rtp_jpeg_pay_src_template));
252 gst_element_class_add_pad_template (gstelement_class,
253 gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
255 gst_element_class_set_static_metadata (gstelement_class, "RTP JPEG payloader",
256 "Codec/Payloader/Network/RTP",
257 "Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
258 "Axis Communications <dev-gstreamer@axis.com>");
260 gstrtpbasepayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
261 gstrtpbasepayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
263 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_JPEG_QUALITY,
264 g_param_spec_int ("quality", "Quality",
265 "Quality factor on JPEG data (unused)", 0, 255, 255,
266 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
268 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_JPEG_TYPE,
269 g_param_spec_int ("type", "Type",
270 "Default JPEG Type, overwritten by SOF when present", 0, 255,
271 DEFAULT_JPEG_TYPE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
273 GST_DEBUG_CATEGORY_INIT (rtpjpegpay_debug, "rtpjpegpay", 0,
274 "Motion JPEG RTP Payloader");
278 gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay)
280 pay->quality = DEFAULT_JPEG_QUALITY;
281 pay->quant = DEFAULT_JPEG_QUANT;
282 pay->type = DEFAULT_JPEG_TYPE;
286 gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
288 GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
291 gint width = 0, height = 0;
293 pay = GST_RTP_JPEG_PAY (basepayload);
295 /* these properties are not mandatory, we can get them from the SOF, if there
297 if (gst_structure_get_int (caps_structure, "height", &height)) {
298 if (height <= 0 || height > 2040)
299 goto invalid_dimension;
301 pay->height = GST_ROUND_UP_8 (height) / 8;
303 if (gst_structure_get_int (caps_structure, "width", &width)) {
304 if (width <= 0 || width > 2040)
305 goto invalid_dimension;
307 pay->width = GST_ROUND_UP_8 (width) / 8;
309 gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000);
310 res = gst_rtp_base_payload_set_outcaps (basepayload, NULL);
317 GST_ERROR_OBJECT (pay, "Invalid width/height from caps");
323 gst_rtp_jpeg_pay_header_size (const guint8 * data, guint offset)
325 return data[offset] << 8 | data[offset + 1];
329 gst_rtp_jpeg_pay_read_quant_table (const guint8 * data, guint size,
330 guint offset, RtpQuantTable tables[])
332 guint quant_size, tab_size;
336 if (offset + 2 > size)
339 quant_size = gst_rtp_jpeg_pay_header_size (data, offset);
341 goto small_quant_size;
343 /* clamp to available data */
344 if (offset + quant_size > size)
345 quant_size = size - offset;
350 while (quant_size > 0) {
351 /* not enough to read the id */
352 if (offset + 1 > size)
355 id = data[offset] & 0x0f;
357 /* invalid id received - corrupt data */
360 prec = (data[offset] & 0xf0) >> 4;
366 /* there is not enough for the table */
367 if (quant_size < tab_size + 1)
370 GST_LOG ("read quant table %d, tab_size %d, prec %02x", id, tab_size, prec);
372 tables[id].size = tab_size;
373 tables[id].data = &data[offset + 1];
376 quant_size -= tab_size;
380 return offset + quant_size;
385 GST_WARNING ("not enough data");
390 GST_WARNING ("quant_size too small (%u < 2)", quant_size);
395 GST_WARNING ("invalid id");
400 GST_WARNING ("not enough data for table (%u < %u)", quant_size,
407 gst_rtp_jpeg_pay_read_sof (GstRtpJPEGPay * pay, const guint8 * data,
408 guint size, guint * offset, CompInfo info[], RtpQuantTable tables[],
409 gulong tables_elements)
412 guint width, height, infolen;
418 /* we need at least 17 bytes for the SOF */
422 sof_size = gst_rtp_jpeg_pay_header_size (data, off);
431 /* precision should be 8 */
432 if (data[off++] != 8)
435 /* read dimensions */
436 height = data[off] << 8 | data[off + 1];
437 width = data[off + 2] << 8 | data[off + 3];
440 GST_LOG_OBJECT (pay, "got dimensions %ux%u", height, width);
442 if (height == 0 || height > 2040)
443 goto invalid_dimension;
444 if (width == 0 || width > 2040)
445 goto invalid_dimension;
447 pay->height = GST_ROUND_UP_8 (height) / 8;
448 pay->width = GST_ROUND_UP_8 (width) / 8;
450 /* we only support 3 components */
451 if (data[off++] != 3)
455 for (i = 0; i < 3; i++) {
456 elem.id = data[off++];
457 elem.samp = data[off++];
458 elem.qt = data[off++];
459 GST_LOG_OBJECT (pay, "got comp %d, samp %02x, qt %d", elem.id, elem.samp,
461 /* insertion sort from the last element to the first */
462 for (j = infolen; j > 1; j--) {
463 if (G_LIKELY (info[j - 1].id < elem.id))
465 info[j] = info[j - 1];
471 /* see that the components are supported */
472 if (info[0].samp == 0x21)
474 else if (info[0].samp == 0x22)
479 if (!(info[1].samp == 0x11))
482 if (!(info[2].samp == 0x11))
485 /* the other components are free to use any quant table but they have to
486 * have the same table id */
487 if (info[1].qt != info[2].qt) {
488 /* Some MJPG (like the one from the Logitech C-920 camera) uses different
489 * quant tables for component 1 and 2 but both tables contain the exact
490 * same data, so we could consider them as being the same tables */
491 if (!(info[1].qt < tables_elements &&
492 info[2].qt < tables_elements &&
493 tables[info[1].qt].size > 0 &&
494 tables[info[1].qt].size == tables[info[2].qt].size &&
495 memcmp (tables[info[1].qt].data, tables[info[2].qt].data,
496 tables[info[1].qt].size) == 0))
505 GST_ELEMENT_ERROR (pay, STREAM, FORMAT,
506 ("Wrong size %u (needed %u).", size, off + 17), (NULL));
511 GST_ELEMENT_ERROR (pay, STREAM, FORMAT,
512 ("Wrong SOF length %u.", sof_size), (NULL));
517 GST_ELEMENT_ERROR (pay, STREAM, FORMAT,
518 ("Wrong precision, expecting 8."), (NULL));
523 GST_ELEMENT_ERROR (pay, STREAM, FORMAT,
524 ("Wrong dimension, size %ux%u", width, height), (NULL));
529 GST_ELEMENT_ERROR (pay, STREAM, FORMAT,
530 ("Wrong number of components"), (NULL));
535 GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid component"), (NULL));
541 gst_rtp_jpeg_pay_read_dri (GstRtpJPEGPay * pay, const guint8 * data,
542 guint size, guint * offset, RtpRestartMarkerHeader * dri)
548 /* we need at least 4 bytes for the DRI */
552 dri_size = gst_rtp_jpeg_pay_header_size (data, off);
559 dri->restart_interval = g_htons ((data[off] << 8) | (data[off + 1]));
560 dri->restart_count = g_htons (0xFFFF);
562 return dri->restart_interval > 0;
566 GST_WARNING ("not enough data for DRI");
572 GST_WARNING ("DRI size too small (%u)", dri_size);
579 gst_rtp_jpeg_pay_scan_marker (const guint8 * data, guint size, guint * offset)
581 while ((data[(*offset)++] != JPEG_MARKER) && ((*offset) < size));
583 if (G_UNLIKELY ((*offset) >= size)) {
584 GST_LOG ("found EOI marker");
585 return JPEG_MARKER_EOI;
589 marker = data[*offset];
590 GST_LOG ("found 0x%02x marker at offset %u", marker, *offset);
597 gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
601 GstClockTime timestamp;
602 GstFlowReturn ret = GST_FLOW_ERROR;
603 RtpJpegHeader jpeg_header;
604 RtpQuantHeader quant_header;
605 RtpRestartMarkerHeader restart_marker_header;
606 RtpQuantTable tables[15] = { {0, NULL}, };
607 CompInfo info[3] = { {0,}, };
608 guint quant_data_size;
614 guint jpeg_header_size = 0;
617 gboolean sos_found, sof_found, dqt_found, dri_found;
619 GstBufferList *list = NULL;
621 pay = GST_RTP_JPEG_PAY (basepayload);
622 mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
624 gst_buffer_map (buffer, &map, GST_MAP_READ);
627 timestamp = GST_BUFFER_TIMESTAMP (buffer);
630 GST_LOG_OBJECT (pay, "got buffer size %" G_GSIZE_FORMAT
631 " , timestamp %" GST_TIME_FORMAT, size, GST_TIME_ARGS (timestamp));
633 /* parse the jpeg header for 'start of scan' and read quant tables if needed */
639 while (!sos_found && (offset < size)) {
640 GST_LOG_OBJECT (pay, "checking from offset %u", offset);
641 switch (gst_rtp_jpeg_pay_scan_marker (data, size, &offset)) {
642 case JPEG_MARKER_JFIF:
643 case JPEG_MARKER_CMT:
644 case JPEG_MARKER_DHT:
645 case JPEG_MARKER_H264:
646 GST_LOG_OBJECT (pay, "skipping marker");
647 offset += gst_rtp_jpeg_pay_header_size (data, offset);
649 case JPEG_MARKER_SOF:
650 if (!gst_rtp_jpeg_pay_read_sof (pay, data, size, &offset, info, tables,
651 G_N_ELEMENTS (tables)))
655 case JPEG_MARKER_DQT:
656 GST_LOG ("DQT found");
657 offset = gst_rtp_jpeg_pay_read_quant_table (data, size, offset, tables);
660 case JPEG_MARKER_SOS:
662 GST_LOG_OBJECT (pay, "SOS found");
663 jpeg_header_size = offset + gst_rtp_jpeg_pay_header_size (data, offset);
665 case JPEG_MARKER_EOI:
666 GST_WARNING_OBJECT (pay, "EOI reached before SOS!");
668 case JPEG_MARKER_SOI:
669 GST_LOG_OBJECT (pay, "SOI found");
671 case JPEG_MARKER_DRI:
672 GST_LOG_OBJECT (pay, "DRI found");
673 if (gst_rtp_jpeg_pay_read_dri (pay, data, size, &offset,
674 &restart_marker_header))
681 if (!dqt_found || !sof_found)
682 goto unsupported_jpeg;
684 /* by now we should either have negotiated the width/height or the SOF header
685 * should have filled us in */
686 if (pay->width == 0 || pay->height == 0)
689 GST_LOG_OBJECT (pay, "header size %u", jpeg_header_size);
691 size -= jpeg_header_size;
692 data += jpeg_header_size;
698 /* prepare stuff for the jpeg header */
699 jpeg_header.type_spec = 0;
700 jpeg_header.type = pay->type;
701 jpeg_header.q = pay->quant;
702 jpeg_header.width = pay->width;
703 jpeg_header.height = pay->height;
705 /* collect the quant headers sizes */
706 quant_header.mbz = 0;
707 quant_header.precision = 0;
708 quant_header.length = 0;
711 if (pay->quant > 127) {
712 /* for the Y and U component, look up the quant table and its size. quant
713 * tables for U and V should be the same */
714 for (i = 0; i < 2; i++) {
719 if (qt >= G_N_ELEMENTS (tables))
722 qsize = tables[qt].size;
726 quant_header.precision |= (qsize == 64 ? 0 : (1 << i));
727 quant_data_size += qsize;
729 quant_header.length = g_htons (quant_data_size);
730 quant_data_size += sizeof (quant_header);
733 GST_LOG_OBJECT (pay, "quant_data size %u", quant_data_size);
735 list = gst_buffer_list_new ();
737 bytes_left = sizeof (jpeg_header) + quant_data_size + size;
740 bytes_left += sizeof (restart_marker_header);
746 guint payload_size = (bytes_left < mtu ? bytes_left : mtu);
749 GstRTPBuffer rtp = { NULL };
751 header_size = sizeof (jpeg_header) + quant_data_size;
753 header_size += sizeof (restart_marker_header);
755 outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
757 gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
759 if (payload_size == bytes_left) {
760 GST_LOG_OBJECT (pay, "last packet of frame");
762 gst_rtp_buffer_set_marker (&rtp, 1);
765 payload = gst_rtp_buffer_get_payload (&rtp);
768 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
769 jpeg_header.offset = ((offset & 0x0000FF) << 16) |
770 ((offset & 0xFF0000) >> 16) | (offset & 0x00FF00);
772 jpeg_header.offset = offset;
774 memcpy (payload, &jpeg_header, sizeof (jpeg_header));
775 payload += sizeof (jpeg_header);
776 payload_size -= sizeof (jpeg_header);
779 memcpy (payload, &restart_marker_header, sizeof (restart_marker_header));
780 payload += sizeof (restart_marker_header);
781 payload_size -= sizeof (restart_marker_header);
784 /* only send quant table with first packet */
785 if (G_UNLIKELY (quant_data_size > 0)) {
786 memcpy (payload, &quant_header, sizeof (quant_header));
787 payload += sizeof (quant_header);
789 /* copy the quant tables for luma and chrominance */
790 for (i = 0; i < 2; i++) {
795 qsize = tables[qt].size;
796 memcpy (payload, tables[qt].data, qsize);
798 GST_LOG_OBJECT (pay, "component %d using quant %d, size %d", i, qt,
803 payload_size -= quant_data_size;
804 bytes_left -= quant_data_size;
807 GST_LOG_OBJECT (pay, "sending payload size %d", payload_size);
808 gst_rtp_buffer_unmap (&rtp);
810 /* create a new buf to hold the payload */
811 paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
812 jpeg_header_size + offset, payload_size);
814 /* join memory parts */
815 outbuf = gst_buffer_append (outbuf, paybuf);
817 GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
819 /* and add to list */
820 gst_buffer_list_insert (list, -1, outbuf);
822 bytes_left -= payload_size;
823 offset += payload_size;
824 data += payload_size;
828 /* push the whole buffer list at once */
829 ret = gst_rtp_base_payload_push_list (basepayload, list);
831 gst_buffer_unmap (buffer, &map);
832 gst_buffer_unref (buffer);
839 GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
840 gst_buffer_unmap (buffer, &map);
841 gst_buffer_unref (buffer);
842 return GST_FLOW_NOT_SUPPORTED;
846 GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));
847 gst_buffer_unmap (buffer, &map);
848 gst_buffer_unref (buffer);
849 return GST_FLOW_NOT_NEGOTIATED;
853 /* error was posted */
854 gst_buffer_unmap (buffer, &map);
855 gst_buffer_unref (buffer);
856 return GST_FLOW_ERROR;
860 GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
861 gst_buffer_unmap (buffer, &map);
862 gst_buffer_unref (buffer);
863 return GST_FLOW_ERROR;
868 gst_rtp_jpeg_pay_set_property (GObject * object, guint prop_id,
869 const GValue * value, GParamSpec * pspec)
871 GstRtpJPEGPay *rtpjpegpay;
873 rtpjpegpay = GST_RTP_JPEG_PAY (object);
876 case PROP_JPEG_QUALITY:
877 rtpjpegpay->quality = g_value_get_int (value);
878 GST_DEBUG_OBJECT (object, "quality = %d", rtpjpegpay->quality);
881 rtpjpegpay->type = g_value_get_int (value);
882 GST_DEBUG_OBJECT (object, "type = %d", rtpjpegpay->type);
885 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
891 gst_rtp_jpeg_pay_get_property (GObject * object, guint prop_id,
892 GValue * value, GParamSpec * pspec)
894 GstRtpJPEGPay *rtpjpegpay;
896 rtpjpegpay = GST_RTP_JPEG_PAY (object);
899 case PROP_JPEG_QUALITY:
900 g_value_set_int (value, rtpjpegpay->quality);
903 g_value_set_int (value, rtpjpegpay->type);
906 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
912 gst_rtp_jpeg_pay_plugin_init (GstPlugin * plugin)
914 return gst_element_register (plugin, "rtpjpegpay", GST_RANK_SECONDARY,
915 GST_TYPE_RTP_JPEG_PAY);