rtpvrawpay: make chunks per frame configurable
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpvrawpay.c
1 /* GStreamer
2  * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <string.h>
25
26 #include <gst/rtp/gstrtpbuffer.h>
27
28 #include "gstrtpvrawpay.h"
29
30 enum
31 {
32   PROP_CHUNKS_PER_FRAME = 1
33 };
34
35 #define DEFAULT_CHUNKS_PER_FRAME 10
36
37 GST_DEBUG_CATEGORY_STATIC (rtpvrawpay_debug);
38 #define GST_CAT_DEFAULT (rtpvrawpay_debug)
39
40 static GstStaticPadTemplate gst_rtp_vraw_pay_sink_template =
41     GST_STATIC_PAD_TEMPLATE ("sink",
42     GST_PAD_SINK,
43     GST_PAD_ALWAYS,
44     GST_STATIC_CAPS ("video/x-raw, "
45         "format = (string) { RGB, RGBA, BGR, BGRA, AYUV, UYVY, I420, Y41B, UYVP }, "
46         "width = (int) [ 1, 32767 ], " "height = (int) [ 1, 32767 ]; ")
47     );
48
49 static GstStaticPadTemplate gst_rtp_vraw_pay_src_template =
50 GST_STATIC_PAD_TEMPLATE ("src",
51     GST_PAD_SRC,
52     GST_PAD_ALWAYS,
53     GST_STATIC_CAPS ("application/x-rtp, "
54         "media = (string) \"video\", "
55         "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
56         "clock-rate = (int) 90000, "
57         "encoding-name = (string) \"RAW\","
58         "sampling = (string) { \"RGB\", \"RGBA\", \"BGR\", \"BGRA\", "
59         "\"YCbCr-4:4:4\", \"YCbCr-4:2:2\", \"YCbCr-4:2:0\", "
60         "\"YCbCr-4:1:1\" },"
61         /* we cannot express these as strings 
62          * "width = (string) [1 32767],"
63          * "height = (string) [1 32767],"
64          */
65         "depth = (string) { \"8\", \"10\", \"12\", \"16\" },"
66         "colorimetry = (string) { \"BT601-5\", \"BT709-2\", \"SMPTE240M\" }"
67         /* optional 
68          * interlace = 
69          * top-field-first = 
70          * chroma-position = (string) 
71          * gamma = (float)
72          */
73     )
74     );
75
76 static gboolean gst_rtp_vraw_pay_setcaps (GstRTPBasePayload * payload,
77     GstCaps * caps);
78 static GstFlowReturn gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload *
79     payload, GstBuffer * buffer);
80 static void gst_rtp_vraw_pay_get_property (GObject * object, guint prop_id,
81     GValue * value, GParamSpec * pspec);
82 static void gst_rtp_vraw_pay_set_property (GObject * object, guint prop_id,
83     const GValue * value, GParamSpec * pspec);
84
85 G_DEFINE_TYPE (GstRtpVRawPay, gst_rtp_vraw_pay, GST_TYPE_RTP_BASE_PAYLOAD)
86
87      static void gst_rtp_vraw_pay_class_init (GstRtpVRawPayClass * klass)
88 {
89   GstRTPBasePayloadClass *gstrtpbasepayload_class;
90   GstElementClass *gstelement_class;
91   GObjectClass *gobject_class;
92
93   gobject_class = (GObjectClass *) klass;
94   gstelement_class = (GstElementClass *) klass;
95   gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
96
97   gobject_class->set_property = gst_rtp_vraw_pay_set_property;
98   gobject_class->get_property = gst_rtp_vraw_pay_get_property;
99
100   g_object_class_install_property (gobject_class,
101       PROP_CHUNKS_PER_FRAME,
102       g_param_spec_int ("chunks-per-frame", "Chunks per Frame",
103           "Split and send out each frame in multiple chunks to reduce overhead",
104           1, G_MAXINT, DEFAULT_CHUNKS_PER_FRAME,
105           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
106       );
107
108   gstrtpbasepayload_class->set_caps = gst_rtp_vraw_pay_setcaps;
109   gstrtpbasepayload_class->handle_buffer = gst_rtp_vraw_pay_handle_buffer;
110
111   gst_element_class_add_pad_template (gstelement_class,
112       gst_static_pad_template_get (&gst_rtp_vraw_pay_src_template));
113   gst_element_class_add_pad_template (gstelement_class,
114       gst_static_pad_template_get (&gst_rtp_vraw_pay_sink_template));
115
116   gst_element_class_set_static_metadata (gstelement_class,
117       "RTP Raw Video payloader", "Codec/Payloader/Network/RTP",
118       "Payload raw video as RTP packets (RFC 4175)",
119       "Wim Taymans <wim.taymans@gmail.com>");
120
121   GST_DEBUG_CATEGORY_INIT (rtpvrawpay_debug, "rtpvrawpay", 0,
122       "Raw video RTP Payloader");
123 }
124
125 static void
126 gst_rtp_vraw_pay_init (GstRtpVRawPay * rtpvrawpay)
127 {
128   rtpvrawpay->chunks_per_frame = DEFAULT_CHUNKS_PER_FRAME;
129 }
130
131 static gboolean
132 gst_rtp_vraw_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
133 {
134   GstRtpVRawPay *rtpvrawpay;
135   gboolean res;
136   gint pgroup, xinc, yinc;
137   const gchar *depthstr, *samplingstr, *colorimetrystr;
138   gchar *wstr, *hstr;
139   GstVideoInfo info;
140
141   rtpvrawpay = GST_RTP_VRAW_PAY (payload);
142
143   if (!gst_video_info_from_caps (&info, caps))
144     goto invalid_caps;
145
146   rtpvrawpay->vinfo = info;
147
148   if (gst_video_colorimetry_matches (&info.colorimetry,
149           GST_VIDEO_COLORIMETRY_BT601)) {
150     colorimetrystr = "BT601-5";
151   } else if (gst_video_colorimetry_matches (&info.colorimetry,
152           GST_VIDEO_COLORIMETRY_BT709)) {
153     colorimetrystr = "BT709-2";
154   } else if (gst_video_colorimetry_matches (&info.colorimetry,
155           GST_VIDEO_COLORIMETRY_SMPTE240M)) {
156     colorimetrystr = "SMPTE240M";
157   } else {
158     colorimetrystr = "SMPTE240M";
159   }
160
161   xinc = yinc = 1;
162
163   /* these values are the only thing we can do */
164   depthstr = "8";
165
166   switch (GST_VIDEO_INFO_FORMAT (&info)) {
167     case GST_VIDEO_FORMAT_RGBA:
168       samplingstr = "RGBA";
169       pgroup = 4;
170       break;
171     case GST_VIDEO_FORMAT_BGRA:
172       samplingstr = "BGRA";
173       pgroup = 4;
174       break;
175     case GST_VIDEO_FORMAT_RGB:
176       samplingstr = "RGB";
177       pgroup = 3;
178       break;
179     case GST_VIDEO_FORMAT_BGR:
180       samplingstr = "BGR";
181       pgroup = 3;
182       break;
183     case GST_VIDEO_FORMAT_AYUV:
184       samplingstr = "YCbCr-4:4:4";
185       pgroup = 3;
186       break;
187     case GST_VIDEO_FORMAT_UYVY:
188       samplingstr = "YCbCr-4:2:2";
189       pgroup = 4;
190       xinc = 2;
191       break;
192     case GST_VIDEO_FORMAT_Y41B:
193       samplingstr = "YCbCr-4:1:1";
194       pgroup = 6;
195       xinc = 4;
196       break;
197     case GST_VIDEO_FORMAT_I420:
198       samplingstr = "YCbCr-4:2:0";
199       pgroup = 6;
200       xinc = yinc = 2;
201       break;
202     case GST_VIDEO_FORMAT_UYVP:
203       samplingstr = "YCbCr-4:2:2";
204       pgroup = 5;
205       xinc = 2;
206       depthstr = "10";
207       break;
208     default:
209       goto unknown_format;
210       break;
211   }
212
213   if (GST_VIDEO_INFO_IS_INTERLACED (&info)) {
214     yinc *= 2;
215   }
216
217   rtpvrawpay->pgroup = pgroup;
218   rtpvrawpay->xinc = xinc;
219   rtpvrawpay->yinc = yinc;
220
221   GST_DEBUG_OBJECT (payload, "width %d, height %d, sampling %s",
222       GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info), samplingstr);
223   GST_DEBUG_OBJECT (payload, "xinc %d, yinc %d, pgroup %d", xinc, yinc, pgroup);
224
225   wstr = g_strdup_printf ("%d", GST_VIDEO_INFO_WIDTH (&info));
226   hstr = g_strdup_printf ("%d", GST_VIDEO_INFO_HEIGHT (&info));
227
228   gst_rtp_base_payload_set_options (payload, "video", TRUE, "RAW", 90000);
229   if (GST_VIDEO_INFO_IS_INTERLACED (&info)) {
230     res = gst_rtp_base_payload_set_outcaps (payload, "sampling", G_TYPE_STRING,
231         samplingstr, "depth", G_TYPE_STRING, depthstr, "width", G_TYPE_STRING,
232         wstr, "height", G_TYPE_STRING, hstr, "colorimetry", G_TYPE_STRING,
233         colorimetrystr, "interlace", G_TYPE_STRING, "true", NULL);
234   } else {
235     res = gst_rtp_base_payload_set_outcaps (payload, "sampling", G_TYPE_STRING,
236         samplingstr, "depth", G_TYPE_STRING, depthstr, "width", G_TYPE_STRING,
237         wstr, "height", G_TYPE_STRING, hstr, "colorimetry", G_TYPE_STRING,
238         colorimetrystr, NULL);
239   }
240   g_free (wstr);
241   g_free (hstr);
242
243   return res;
244
245   /* ERRORS */
246 invalid_caps:
247   {
248     GST_ERROR_OBJECT (payload, "could not parse caps");
249     return FALSE;
250   }
251 unknown_format:
252   {
253     GST_ERROR_OBJECT (payload, "unknown caps format");
254     return FALSE;
255   }
256 }
257
258 static GstFlowReturn
259 gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
260 {
261   GstRtpVRawPay *rtpvrawpay;
262   GstFlowReturn ret = GST_FLOW_OK;
263   gfloat packets_per_packline;
264   guint pgroups_per_packet;
265   guint packlines_per_list, buffers_per_list;
266   guint lines_delay;            /* after how many packed lines we push out a buffer list */
267   guint last_line;              /* last pack line number we pushed out a buffer list     */
268   guint line, offset;
269   guint8 *p0, *yp, *up, *vp;
270   guint ystride, uvstride;
271   guint xinc, yinc;
272   guint pgroup;
273   guint mtu;
274   guint width, height;
275   gint field, fields;
276   GstVideoFormat format;
277   GstVideoFrame frame;
278   gint interlaced;
279   gboolean use_buffer_lists;
280   GstBufferList *list = NULL;
281   GstRTPBuffer rtp = { NULL, };
282
283   rtpvrawpay = GST_RTP_VRAW_PAY (payload);
284
285   gst_video_frame_map (&frame, &rtpvrawpay->vinfo, buffer, GST_MAP_READ);
286
287   GST_LOG_OBJECT (rtpvrawpay, "new frame of %" G_GSIZE_FORMAT " bytes",
288       gst_buffer_get_size (buffer));
289
290   /* get pointer and strides of the planes */
291   p0 = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
292   yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
293   up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
294   vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
295
296   ystride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
297   uvstride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 1);
298
299   mtu = GST_RTP_BASE_PAYLOAD_MTU (payload);
300
301   /* amount of bytes for one pixel */
302   pgroup = rtpvrawpay->pgroup;
303   width = GST_VIDEO_INFO_WIDTH (&rtpvrawpay->vinfo);
304   height = GST_VIDEO_INFO_HEIGHT (&rtpvrawpay->vinfo);
305
306   interlaced = GST_VIDEO_INFO_IS_INTERLACED (&rtpvrawpay->vinfo);
307
308   format = GST_VIDEO_INFO_FORMAT (&rtpvrawpay->vinfo);
309
310   yinc = rtpvrawpay->yinc;
311   xinc = rtpvrawpay->xinc;
312
313   /* after how many packed lines we push out a buffer list */
314   lines_delay = GST_ROUND_UP_4 (height / rtpvrawpay->chunks_per_frame);
315
316   /* calculate how many buffers we expect to store in a single buffer list */
317   pgroups_per_packet = (mtu - (12 + 14)) / pgroup;
318   packets_per_packline = width / (xinc * pgroups_per_packet * 1.0);
319   packlines_per_list = height / (yinc * rtpvrawpay->chunks_per_frame);
320   buffers_per_list = packlines_per_list * packets_per_packline;
321   buffers_per_list = GST_ROUND_UP_8 (buffers_per_list);
322
323   use_buffer_lists = (rtpvrawpay->chunks_per_frame < (height / yinc));
324
325   fields = 1 + interlaced;
326
327   /* start with line 0, offset 0 */
328   for (field = 0; field < fields; field++) {
329     line = field;
330     offset = 0;
331     last_line = 0;
332
333     if (use_buffer_lists)
334       list = gst_buffer_list_new_sized (buffers_per_list);
335
336     /* write all lines */
337     while (line < height) {
338       guint left, pack_line;
339       GstBuffer *out;
340       guint8 *outdata, *headers;
341       gboolean next_line, complete = FALSE;
342       guint length, cont, pixels;
343
344       /* get the max allowed payload length size, we try to fill the complete MTU */
345       left = gst_rtp_buffer_calc_payload_len (mtu, 0, 0);
346       out = gst_rtp_buffer_new_allocate (left, 0, 0);
347
348       if (field == 0) {
349         GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (buffer);
350       } else {
351         GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (buffer) +
352             GST_BUFFER_DURATION (buffer) / 2;
353       }
354
355       gst_rtp_buffer_map (out, GST_MAP_WRITE, &rtp);
356       outdata = gst_rtp_buffer_get_payload (&rtp);
357
358       GST_LOG_OBJECT (rtpvrawpay, "created buffer of size %u for MTU %u", left,
359           mtu);
360
361       /*
362        *   0                   1                   2                   3
363        *   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
364        *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365        *  |   Extended Sequence Number    |            Length             |
366        *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367        *  |F|          Line No            |C|           Offset            |
368        *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369        *  |            Length             |F|          Line No            |
370        *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371        *  |C|           Offset            |                               .
372        *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               .
373        *  .                                                               .
374        *  .                 Two (partial) lines of video data             .
375        *  .                                                               .
376        *  +---------------------------------------------------------------+
377        */
378
379       /* need 2 bytes for the extended sequence number */
380       *outdata++ = 0;
381       *outdata++ = 0;
382       left -= 2;
383
384       /* the headers start here */
385       headers = outdata;
386
387       /* make sure we can fit at least *one* header and pixel */
388       if (!(left > (6 + pgroup))) {
389         gst_rtp_buffer_unmap (&rtp);
390         gst_buffer_unref (out);
391         goto too_small;
392       }
393
394       /* while we can fit at least one header and one pixel */
395       while (left > (6 + pgroup)) {
396         /* we need a 6 bytes header */
397         left -= 6;
398
399         /* get how may bytes we need for the remaining pixels */
400         pixels = width - offset;
401         length = (pixels * pgroup) / xinc;
402
403         if (left >= length) {
404           /* pixels and header fit completely, we will write them and skip to the
405            * next line. */
406           next_line = TRUE;
407         } else {
408           /* line does not fit completely, see how many pixels fit */
409           pixels = (left / pgroup) * xinc;
410           length = (pixels * pgroup) / xinc;
411           next_line = FALSE;
412         }
413         GST_LOG_OBJECT (rtpvrawpay, "filling %u bytes in %u pixels", length,
414             pixels);
415         left -= length;
416
417         /* write length */
418         *outdata++ = (length >> 8) & 0xff;
419         *outdata++ = length & 0xff;
420
421         /* write line no */
422         *outdata++ = ((line >> 8) & 0x7f) | ((field << 7) & 0x80);
423         *outdata++ = line & 0xff;
424
425         if (next_line) {
426           /* go to next line we do this here to make the check below easier */
427           line += yinc;
428         }
429
430         /* calculate continuation marker */
431         cont = (left > (6 + pgroup) && line < height) ? 0x80 : 0x00;
432
433         /* write offset and continuation marker */
434         *outdata++ = ((offset >> 8) & 0x7f) | cont;
435         *outdata++ = offset & 0xff;
436
437         if (next_line) {
438           /* reset offset */
439           offset = 0;
440           GST_LOG_OBJECT (rtpvrawpay, "go to next line %u", line);
441         } else {
442           offset += pixels;
443           GST_LOG_OBJECT (rtpvrawpay, "next offset %u", offset);
444         }
445
446         if (!cont)
447           break;
448       }
449       GST_LOG_OBJECT (rtpvrawpay, "consumed %u bytes",
450           (guint) (outdata - headers));
451
452       /* second pass, read headers and write the data */
453       while (TRUE) {
454         guint offs, lin;
455
456         /* read length and cont */
457         length = (headers[0] << 8) | headers[1];
458         lin = ((headers[2] & 0x7f) << 8) | headers[3];
459         offs = ((headers[4] & 0x7f) << 8) | headers[5];
460         cont = headers[4] & 0x80;
461         pixels = length / pgroup;
462         headers += 6;
463
464         GST_LOG_OBJECT (payload,
465             "writing length %u, line %u, offset %u, cont %d", length, lin, offs,
466             cont);
467
468         switch (format) {
469           case GST_VIDEO_FORMAT_RGB:
470           case GST_VIDEO_FORMAT_RGBA:
471           case GST_VIDEO_FORMAT_BGR:
472           case GST_VIDEO_FORMAT_BGRA:
473           case GST_VIDEO_FORMAT_UYVY:
474           case GST_VIDEO_FORMAT_UYVP:
475             offs /= xinc;
476             memcpy (outdata, p0 + (lin * ystride) + (offs * pgroup), length);
477             outdata += length;
478             break;
479           case GST_VIDEO_FORMAT_AYUV:
480           {
481             gint i;
482             guint8 *datap;
483
484             datap = p0 + (lin * ystride) + (offs * 4);
485
486             for (i = 0; i < pixels; i++) {
487               *outdata++ = datap[2];
488               *outdata++ = datap[1];
489               *outdata++ = datap[3];
490               datap += 4;
491             }
492             break;
493           }
494           case GST_VIDEO_FORMAT_I420:
495           {
496             gint i;
497             guint uvoff;
498             guint8 *yd1p, *yd2p, *udp, *vdp;
499
500             yd1p = yp + (lin * ystride) + (offs);
501             yd2p = yd1p + ystride;
502             uvoff = (lin / yinc * uvstride) + (offs / xinc);
503             udp = up + uvoff;
504             vdp = vp + uvoff;
505
506             for (i = 0; i < pixels; i++) {
507               *outdata++ = *yd1p++;
508               *outdata++ = *yd1p++;
509               *outdata++ = *yd2p++;
510               *outdata++ = *yd2p++;
511               *outdata++ = *udp++;
512               *outdata++ = *vdp++;
513             }
514             break;
515           }
516           case GST_VIDEO_FORMAT_Y41B:
517           {
518             gint i;
519             guint uvoff;
520             guint8 *ydp, *udp, *vdp;
521
522             ydp = yp + (lin * ystride) + offs;
523             uvoff = (lin / yinc * uvstride) + (offs / xinc);
524             udp = up + uvoff;
525             vdp = vp + uvoff;
526
527             for (i = 0; i < pixels; i++) {
528               *outdata++ = *udp++;
529               *outdata++ = *ydp++;
530               *outdata++ = *ydp++;
531               *outdata++ = *vdp++;
532               *outdata++ = *ydp++;
533               *outdata++ = *ydp++;
534             }
535             break;
536           }
537           default:
538             gst_rtp_buffer_unmap (&rtp);
539             gst_buffer_unref (out);
540             goto unknown_sampling;
541         }
542
543         if (!cont)
544           break;
545       }
546
547       if (line >= height) {
548         GST_LOG_OBJECT (rtpvrawpay, "field/frame complete, set marker");
549         gst_rtp_buffer_set_marker (&rtp, TRUE);
550         complete = TRUE;
551       }
552       gst_rtp_buffer_unmap (&rtp);
553       if (left > 0) {
554         GST_LOG_OBJECT (rtpvrawpay, "we have %u bytes left", left);
555         gst_buffer_resize (out, 0, gst_buffer_get_size (out) - left);
556       }
557
558       /* Now either push out the buffer directly */
559       if (!use_buffer_lists) {
560         ret = gst_rtp_base_payload_push (payload, out);
561         continue;
562       }
563
564       /* or add the buffer to buffer list ... */
565       gst_buffer_list_add (list, out);
566
567       /* .. and check if we need to push out the list */
568       pack_line = (line - field) / fields;
569       if (complete || (pack_line > last_line && pack_line % lines_delay == 0)) {
570         GST_LOG_OBJECT (rtpvrawpay, "pushing list of %u buffers up to pack "
571             "line %u", gst_buffer_list_length (list), pack_line);
572         ret = gst_rtp_base_payload_push_list (payload, list);
573         list = NULL;
574         if (!complete)
575           list = gst_buffer_list_new_sized (buffers_per_list);
576         last_line = pack_line;
577       }
578     }
579
580   }
581
582   gst_video_frame_unmap (&frame);
583   gst_buffer_unref (buffer);
584
585   return ret;
586
587   /* ERRORS */
588 unknown_sampling:
589   {
590     GST_ELEMENT_ERROR (payload, STREAM, FORMAT,
591         (NULL), ("unimplemented sampling"));
592     gst_video_frame_unmap (&frame);
593     gst_buffer_unref (buffer);
594     return GST_FLOW_NOT_SUPPORTED;
595   }
596 too_small:
597   {
598     GST_ELEMENT_ERROR (payload, RESOURCE, NO_SPACE_LEFT,
599         (NULL), ("not enough space to send at least one pixel"));
600     gst_video_frame_unmap (&frame);
601     gst_buffer_unref (buffer);
602     return GST_FLOW_NOT_SUPPORTED;
603   }
604 }
605
606 static void
607 gst_rtp_vraw_pay_set_property (GObject * object, guint prop_id,
608     const GValue * value, GParamSpec * pspec)
609 {
610   GstRtpVRawPay *rtpvrawpay;
611
612   rtpvrawpay = GST_RTP_VRAW_PAY (object);
613
614   switch (prop_id) {
615     case PROP_CHUNKS_PER_FRAME:
616       rtpvrawpay->chunks_per_frame = g_value_get_int (value);
617       break;
618     default:
619       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
620       break;
621   }
622 }
623
624 static void
625 gst_rtp_vraw_pay_get_property (GObject * object, guint prop_id,
626     GValue * value, GParamSpec * pspec)
627 {
628   GstRtpVRawPay *rtpvrawpay;
629
630   rtpvrawpay = GST_RTP_VRAW_PAY (object);
631
632   switch (prop_id) {
633     case PROP_CHUNKS_PER_FRAME:
634       g_value_set_int (value, rtpvrawpay->chunks_per_frame);
635       break;
636     default:
637       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
638       break;
639   }
640 }
641
642 gboolean
643 gst_rtp_vraw_pay_plugin_init (GstPlugin * plugin)
644 {
645   return gst_element_register (plugin, "rtpvrawpay",
646       GST_RANK_SECONDARY, GST_TYPE_RTP_VRAW_PAY);
647 }