Initialize Tizen 2.3
[framework/multimedia/gst-plugins-ext0.10.git] / wearable / avsystem / src / gstavsysmemsink.c
1 /*
2  * avsystem
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23
24
25 #if defined(_MM_PROJECT_FLOATER) || defined(_MM_PROJECT_PROTECTOR) || defined(_MM_PROJECT_VOLANS)
26 #define VERSION "0.10.19" // sec
27 #define PACKAGE "gstreamer"
28 #elif defined(_MM_PROJECT_ADORA)
29 #define VERSION "0.10.9" // mavell
30 #define PACKAGE "gstreamer"
31 #else
32 #include <config.h>
33 #endif
34
35 #include <string.h>
36 #include <stdlib.h>
37
38 #include "gstavsysmemsink.h"
39
40 #define debug_enter g_print
41 #define debug_leave g_print
42 #define debug_fenter() g_print("enter: %s\n",__FUNCTION__)
43 #define debug_fleave() g_print("leave: %s\n",__FUNCTION__)
44 #define debug_msg g_print
45 #define debug_verbose g_print
46 #define debug_warning g_print
47 #define debug_error g_print
48
49 #define GST_CAT_DEFAULT avsysmemsink_debug
50
51 #define DISABLE_YUV_FORMAT_ON_SINK_CAPS
52
53 GST_DEBUG_CATEGORY_STATIC (avsysmemsink_debug);
54
55 enum 
56 {
57     SIGNAL_VIDEO_STREAM,
58     LAST_SIGNAL
59 };
60
61 enum 
62 {
63         PROP_0,
64         PROP_WIDTH,
65         PROP_HEIGHT,
66         PROP_ROTATE,
67 };
68
69 static GstStaticPadTemplate sink_factory =
70         GST_STATIC_PAD_TEMPLATE ("sink",
71                 GST_PAD_SINK, GST_PAD_ALWAYS,
72                 GST_STATIC_CAPS (
73 #ifndef DISABLE_YUV_FORMAT_ON_SINK_CAPS
74                         "video/x-raw-yuv, "
75                         "format = (fourcc){YV12}, "
76                         "framerate = (fraction) [ 0, MAX ], "
77                         "width = (int) [ 1, MAX ], "
78                         "height = (int) [ 1, MAX ]; "
79                         "video/x-raw-yuv, "
80                         "format = (fourcc){I420}, "
81                         "framerate = (fraction) [ 0, MAX ], "
82                         "width = (int) [ 1, MAX ], "
83                         "height = (int) [ 1, MAX ]; "
84                         "video/x-raw-rgb, "
85                         "bpp = (int)32, "
86                         "depth = (int)24; "
87 #else /* BGRA */
88                         "video/x-raw-rgb, "
89                         "bpp = (int)32, "
90                         "endianness = (int)4321, "
91                         "red_mask = (int)65280, "
92                         "green_mask = (int)16711680, "
93                         "blue_mask = (int)-16777216, "
94                         "alpha_mask = (int)255, "
95                         "width = (int) [ 1, MAX ], "
96                         "height = (int) [ 1, MAX ], "
97                         "framerate = (fraction) [ 0, MAX ]; "
98 #endif
99                 )
100         );
101
102 static GstElementDetails AvsysMemSink_details = {
103             "AV-system Stream callback",
104             "Sink/Video", 
105             "Stream sink for AV-System GStreamer Plug-in", 
106             ""
107 };
108
109 static guint gst_avsysmemsink_signals[LAST_SIGNAL] = { 0 };
110
111
112 #ifdef G_ENABLE_DEBUG
113 #define g_marshal_value_peek_int(v)      g_value_get_int (v)
114 #define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
115 #else /* !G_ENABLE_DEBUG */
116 #define g_marshal_value_peek_int(v)      (v)->data[0].v_int
117 #define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
118 #endif /* !G_ENABLE_DEBUG */
119
120
121 #define     GET_PIXEL(buf, x, y, stride)  (*((unsigned char*)(buf) + (x) + (y)*(stride)))
122
123 #define     GET_RED(Y,U,V)      ((9535 * (Y - 16) + 13074 * (V - 128)) >> 13)
124 #define     GET_GREEN(Y,U,V)  ((9535 * (Y - 16) - 6660 * (V - 128) - 3203 * (U - 128)) >> 13 )
125 #define     GET_BLUE(Y,U,V)   ((9535 * (Y - 16) + 16531 * (U - 128)) >> 13 )
126
127 #define     UCLIP(a) (((a)<0)?0:((a)>255)?255:(a))
128
129
130 static void
131 yuv420toargb(unsigned char *src, unsigned char *dst, int width, int height)
132 {
133     int h,w;
134     int y=0,u=0,v=0;
135     int a=0,r=0,g=0,b=0;
136     
137     unsigned char* pixel;
138
139     int index=0;
140
141     unsigned char       *pY;
142     unsigned char       *pU;
143     unsigned char       *pV;
144
145     GST_DEBUG ("converting yuv420 to argb");
146
147     pY = src ;
148     pU = src + (width * height) ;
149     pV = src + (width * height) + (width * height /4) ;
150
151     a = 255;
152
153     for(h = 0 ; h < height; h++)
154     {
155         for(w = 0 ; w < width; w++)
156         {
157             y = GET_PIXEL(pY,w,h,width);
158             u = GET_PIXEL(pU,w/2,h/2,width/2);
159             v = GET_PIXEL(pV,w/2,h/2,width/2);
160
161             r = GET_RED(y,u,v);
162             g = GET_GREEN(y,u,v);
163             b = GET_BLUE(y,u,v);
164
165             r = UCLIP(r);
166             g = UCLIP(g);
167             b = UCLIP(b);
168
169             index = (w + (h* width)) * 4;
170             dst[index] = r;
171             dst[index+1] = g;
172             dst[index+2] = b;
173             dst[index+3] = a;
174         }
175     }
176 }
177
178 static void
179 rotate_pure(unsigned char *src, unsigned char *dst, int width,int height,int angle,int bpp)
180 {
181
182     int     size;
183     int     new_x,new_y;
184     int     org_x,org_y;
185     int     dst_width;
186     int     src_idx, dst_idx;
187     
188     size = width * height * bpp;
189     
190     if(angle == 0)
191     {
192         memcpy(dst,src,size);
193         return;
194     }
195
196     for(org_y =0; org_y < height; org_y++)
197     {
198         for(org_x = 0; org_x < width ; org_x++)
199         {
200             if(angle == 90)
201             {
202                 new_x = height - org_y;
203                 new_y = org_x;
204
205                 dst_width = height;
206             }
207             else if(angle == 180)
208             {
209                 new_x = width - org_x;
210                 new_y = height - org_y;
211                 dst_width = width;
212             }
213             else if(angle == 270)
214             {
215                 new_x = org_y;
216                 new_y = width - org_x;
217                 dst_width = height;
218             }
219             else
220             {
221                 g_print("Not support Rotate : %d\n",angle);
222                 return;
223             }
224
225             src_idx = org_x + (org_y * width);
226             dst_idx = new_x + (new_y * dst_width);
227
228             memcpy(dst + (dst_idx*bpp), src+(src_idx *bpp),bpp);
229         }
230     }
231     
232 }
233
234 static void
235 resize_pure(unsigned char *src, unsigned char *dst, int src_width, int src_height, int dst_width,int dst_height, int bpp)
236 {
237     float       xFactor,yFactor;
238
239     float               org_fx,org_fy;
240     int         org_x,org_y;
241
242     int         x,y;
243
244     int         src_index,dst_index;
245
246     unsigned short *pshortSrc;
247     unsigned short *pshortDst;
248
249     if(bpp == 2)
250     {
251         pshortSrc = (unsigned short*)src;
252         pshortDst = (unsigned short*)dst;
253     }
254
255     xFactor = (float)((dst_width<<16) / src_width);
256     yFactor = (float)((dst_height<<16) / src_height);
257
258     for(y = 0; y < dst_height; y++)
259     {
260         for(x = 0; x < dst_width; x++)
261         {
262             org_fx = (float)((x<<16)/xFactor);
263             org_fy = (float)((y<<16)/yFactor);
264
265             org_x = (int)(org_fx);
266             org_y = (int)(org_fy);
267
268             src_index = org_x + (org_y * src_width);
269             dst_index = x + (y*dst_width);
270
271             memcpy(dst+(dst_index *bpp ),src+(src_index *bpp),bpp);
272         }
273     }
274 }
275
276 /* BOOLEAN:POINTER,INT,INT (avsysvideosink.c:1) */
277 void
278 gst_avsysmemsink_BOOLEAN__POINTER_INT_INT (GClosure         *closure,
279                                              GValue         *return_value G_GNUC_UNUSED,
280                                              guint          n_param_values,
281                                              const GValue   *param_values,
282                                              gpointer       invocation_hint G_GNUC_UNUSED,
283                                              gpointer       marshal_data)
284 {
285     typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_INT_INT) (gpointer     data1,
286                                                                 gpointer     arg_1,
287                                                                 gint         arg_2,
288                                                                 gint         arg_3,
289                                                                 gpointer     data2);
290     register GMarshalFunc_BOOLEAN__POINTER_INT_INT callback;
291     register GCClosure *cc = (GCClosure*) closure;
292     register gpointer data1, data2;
293
294     gboolean v_return;
295
296     g_return_if_fail (return_value != NULL);
297     g_return_if_fail (n_param_values == 4);
298
299     if (G_CCLOSURE_SWAP_DATA (closure))
300     {
301         data1 = closure->data;
302         data2 = g_value_peek_pointer (param_values + 0);
303     }
304     else
305     {
306         data1 = g_value_peek_pointer (param_values + 0);
307         data2 = closure->data;
308     }
309     callback = (GMarshalFunc_BOOLEAN__POINTER_INT_INT) (marshal_data ? marshal_data : cc->callback);
310
311     v_return = callback (data1,
312                         g_marshal_value_peek_pointer (param_values + 1),
313                         g_marshal_value_peek_int (param_values + 2),
314                         g_marshal_value_peek_int (param_values + 3),
315                         data2);
316
317     g_value_set_boolean (return_value, v_return);
318 }
319
320 static void gst_avsysmemsink_init_interfaces (GType type);
321
322
323 GST_BOILERPLATE_FULL (GstAvsysMemSink, gst_avsysmemsink, GstVideoSink, GST_TYPE_VIDEO_SINK, gst_avsysmemsink_init_interfaces);
324
325
326 static void 
327 gst_avsysmemsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
328 {
329         GstAvsysMemSink *AvsysMemSink = GST_AVSYS_MEM_SINK (object);
330         switch (prop_id) {
331                 case PROP_0:
332                         break;
333                 case PROP_WIDTH:
334                if(AvsysMemSink->dst_width != g_value_get_int (value))
335                {
336                                 AvsysMemSink->dst_width = g_value_get_int (value);
337                     AvsysMemSink->dst_changed = 1;
338                }
339                         break;
340                 case PROP_HEIGHT:
341                         if(AvsysMemSink->dst_height != g_value_get_int (value))
342                         {
343                                 AvsysMemSink->dst_height = g_value_get_int (value);
344                     AvsysMemSink->dst_changed = 1;
345                         }
346                         break;
347           case PROP_ROTATE:
348                if(AvsysMemSink->rotate != g_value_get_int(value))
349                {
350                    AvsysMemSink->rotate = g_value_get_int(value);
351                    AvsysMemSink->dst_changed = 1;
352                }
353                break;
354                 default:
355                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
356                         g_print ("invalid property id\n");
357                         break;
358         };
359 }
360
361 static void 
362 gst_avsysmemsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
363 {
364         GstAvsysMemSink *AvsysMemSink = GST_AVSYS_MEM_SINK (object);
365
366         switch (prop_id) {
367                 case PROP_0:
368                         break;
369                 case PROP_WIDTH:
370                         g_value_set_int (value, AvsysMemSink->dst_width);
371                         break;
372                 case PROP_HEIGHT:
373                         g_value_set_int (value, AvsysMemSink->dst_height);
374                         break;
375           case PROP_ROTATE:
376                g_value_set_int (value, AvsysMemSink->rotate);
377                break;
378                 default:
379                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
380                         debug_warning ("invalid property id\n");
381                         break;
382         }
383 }
384
385 static void
386 free_buffer(GstAvsysMemSink *AvsysMemSink)
387 {
388     if(AvsysMemSink->con_buf)
389         free(AvsysMemSink->con_buf);
390
391     if(AvsysMemSink->rot_buf)
392         free(AvsysMemSink->rot_buf);
393
394     if(AvsysMemSink->rsz_buf)
395         free(AvsysMemSink->rsz_buf);
396
397     AvsysMemSink->con_buf = NULL;
398     AvsysMemSink->rot_buf = NULL;
399     AvsysMemSink->rsz_buf = NULL;
400
401 }
402 static GstStateChangeReturn 
403 gst_avsysmemsink_change_state (GstElement *element, GstStateChange transition)
404 {
405         GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
406         GstAvsysMemSink *AvsysMemSink = GST_AVSYS_MEM_SINK (element);
407         switch (transition) {
408                 case GST_STATE_CHANGE_NULL_TO_READY:
409                         debug_msg ("GST AVSYS DISPLAY SINK: NULL -> READY\n");
410                         break;
411                 case GST_STATE_CHANGE_READY_TO_PAUSED:
412                         debug_msg ("GST AVSYS DISPLAY SINK: READY -> PAUSED\n");
413                         break;
414                 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
415                         debug_msg ("GST AVSYS DISPLAY SINK: PAUSED -> PLAYING\n");
416                         break;
417                 default:
418                         break;
419         }
420
421         ret = GST_ELEMENT_CLASS(parent_class)->change_state (element, transition);
422         if (ret == GST_STATE_CHANGE_FAILURE) {
423                 return ret;
424         }
425
426         switch (transition) {
427                 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
428                         debug_msg ("GST AVSYS MEM SINK: PLAYING -> PAUSED\n");
429                         break;
430                 case GST_STATE_CHANGE_PAUSED_TO_READY:
431                         debug_msg ("GST AVSYS MEM SINK: PAUSED -> READY\n");
432                free_buffer(AvsysMemSink);        
433                         break;
434                 case GST_STATE_CHANGE_READY_TO_NULL:
435                         debug_msg ("GST AVSYS MEM SINK: READY -> NULL\n");
436                         break;
437                 default:
438                         break;
439         }
440
441         return ret;
442
443
444 }
445
446
447 static gboolean
448 gst_avsysmemsink_set_caps (GstBaseSink * bs, GstCaps * caps)
449 {
450     GstAvsysMemSink *s = GST_AVSYS_MEM_SINK (bs);
451     GstStructure *structure;
452     gint width = 0;
453     gint height = 0;
454
455     if (caps != NULL)
456     {
457         guint32 fourcc;
458         char *name = NULL;
459         int bpp = 0, depth = 0;
460
461         structure = gst_caps_get_structure (caps, 0);
462
463         /**/
464         name = (char *) gst_structure_get_name (structure);
465         GST_DEBUG_OBJECT (s, "CAPS NAME: %s", name);
466
467                 if (gst_structure_has_name (structure, "video/x-raw-rgb"))
468                 {
469                         s->is_rgb = TRUE;
470                 }
471                 else if (gst_structure_has_name (structure, "video/x-raw-yuv")) 
472                 {
473                         s->is_rgb = FALSE;
474                 }
475
476         /* get source size */
477         gst_structure_get_int (structure, "height", &height);
478         gst_structure_get_int (structure, "width", &width);
479
480         if (gst_structure_get_fourcc (structure, "format", &fourcc)) 
481         {
482             switch (fourcc) 
483             {
484                 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
485                     debug_warning("set format AVSYS_VIDEO_FORMAT_UYVY\n");
486                     break;
487                 case GST_MAKE_FOURCC ('Y', 'V', '1', '6'):
488                 case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
489                     debug_warning("set format AVSYS_VIDEO_FORMAT_YUV422\n");
490                     break;
491                 case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
492                     debug_warning("set format AVSYS_VIDEO_FORMAT_YUV420\n");
493                     break;
494                 case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
495                     debug_warning("set format AVSYS_VIDEO_FORMAT_RGB565\n");
496                     break;
497                 default:
498                     debug_warning("set default format AVSYS_VIDEO_FORMAT_RGB565\n");
499                     break;
500             }
501         }
502
503         if( s->src_width != width || 
504             s->src_height != height) 
505         {
506             debug_warning ("DISPLAY: Video Source Changed! [%d x %d] -> [%d x %d]\n",
507                                     s->src_width, s->src_height, width, height);
508             s->src_changed = TRUE;
509         }
510
511         s->src_width = width;
512         s->src_height = height;
513
514         if(s->dst_width ==0)
515         {
516             s->dst_width = width;
517             s->dst_changed = 1;
518         }
519
520         if(s->dst_height == 0)
521         {
522             s->dst_height = height;
523             s->dst_changed = 1;            
524         }
525         debug_msg ("SRC CAPS: width:%d, height:%d \n", width, height);
526     } 
527     else 
528     {
529         debug_warning ("caps is NULL.\n");
530     }
531
532     debug_fleave ();
533
534     return TRUE;
535 }
536
537 static GstFlowReturn
538 gst_avsysmemsink_preroll (GstBaseSink * bsink, GstBuffer * buf)
539 {
540         GstAvsysMemSink *AvsysMemSink = GST_AVSYS_MEM_SINK (bsink);
541
542         AvsysMemSink->src_length = GST_BUFFER_SIZE (buf);
543         debug_msg ("SRC LENGTH: %d\n", AvsysMemSink->src_length);
544
545         return GST_FLOW_OK;
546 }
547
548 static GstFlowReturn
549 gst_avsysmemsink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
550 {
551         GstAvsysMemSink *s = GST_AVSYS_MEM_SINK (bsink);
552         gboolean res = FALSE;
553         int f_size;
554         f_size = GST_BUFFER_SIZE (buf);
555         unsigned char       *dst_buf;
556
557         if ( ! s->is_rgb )
558         {
559             GST_DEBUG_OBJECT (s, "src format is not rgb");
560             if (s->dst_changed == TRUE)
561             {
562                 if(s->con_buf)
563                 {
564                     free(s->con_buf);
565                     s->con_buf = NULL;
566                 }
567
568                 if(s->rot_buf)
569                 {
570                     free(s->rot_buf);
571                     s->rot_buf = NULL;
572                 }
573
574                 if(s->rsz_buf)
575                 {
576                     free(s->rsz_buf);
577                     s->rsz_buf = NULL;
578                 }
579
580                 s->con_buf = malloc(s->src_width * s->src_height * 4);
581                 if(s->rotate != 0)
582                 {
583                     s->rot_buf = malloc(s->src_width * s->src_height * 4);
584                 }
585
586                 s->rsz_buf = malloc(s->dst_width * s->dst_height *4);
587                 
588                 s->dst_changed = FALSE;
589             } 
590
591             yuv420toargb(GST_BUFFER_DATA (buf),s->con_buf,s->src_width, s->src_height);
592             if(s->rotate != 0)
593             {
594                 rotate_pure(s->con_buf,s->rot_buf,s->src_width, s->src_height,s->rotate,4);
595                 if(s->rotate == 90 || s->rotate == 270)
596                 {
597                     resize_pure(s->rot_buf,s->rsz_buf,s->src_height,s->src_width,
598                                 s->dst_width, s->dst_height,4);
599                 }
600                 else
601                 {
602                     resize_pure(s->rot_buf,s->rsz_buf,s->src_width,s->src_height,
603                                 s->dst_width, s->dst_height,4);
604                 }
605             }
606             else
607             {
608                 resize_pure(s->con_buf,s->rsz_buf,s->src_width,s->src_height,
609                                 s->dst_width, s->dst_height,4);
610             }
611
612             /* emit signal for video-stream */
613             g_signal_emit (s,gst_avsysmemsink_signals[SIGNAL_VIDEO_STREAM],
614                             0,s->rsz_buf,
615                             s->dst_width,s->dst_height,
616                             &res);
617         }
618         else
619         {
620                 GST_DEBUG_OBJECT (s, "src format is rgb");
621
622                 /* NOTE : video can be resized by convert plugin's set caps on running time. 
623                  * So, it should notice it to application through callback func.
624                  */
625                  g_signal_emit (s, gst_avsysmemsink_signals[SIGNAL_VIDEO_STREAM],
626                                     0, GST_BUFFER_DATA (buf),
627                                     s->src_width, s->src_height,
628                                     &res);
629
630          }
631          GST_DEBUG_OBJECT (s, "g_signal_emit : src_width=%d, src_height=%d, GST_BUFFER_SIZE=%d", s->src_width,s->src_height,GST_BUFFER_SIZE(buf));
632
633     /*check video stream callback result.*/
634     if (res) 
635     {
636         //debug_verbose("Video stream is called.\n");
637         return GST_FLOW_OK;
638     }
639
640     return GST_FLOW_OK;
641 }
642
643 static void
644 gst_avsysmemsink_init_interfaces (GType type)
645 {
646         /*void*/
647 }
648
649
650 static void 
651 gst_avsysmemsink_base_init (gpointer klass)
652 {
653         GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
654
655         gst_element_class_add_pad_template (element_class, 
656                                 gst_static_pad_template_get (&sink_factory));
657         gst_element_class_set_details (element_class, &AvsysMemSink_details);
658 }
659
660 static void 
661 gst_avsysmemsink_class_init (GstAvsysMemSinkClass *klass)
662 {
663         GObjectClass *gobject_class  = (GObjectClass*) klass;
664         GstElementClass *gstelement_class = (GstElementClass*) klass;
665         GstBaseSinkClass *gstbasesink_class = (GstBaseSinkClass *) klass;
666
667     
668         parent_class = g_type_class_peek_parent (klass);
669
670         gobject_class->set_property = gst_avsysmemsink_set_property;
671         gobject_class->get_property = gst_avsysmemsink_get_property;
672
673
674         g_object_class_install_property (gobject_class, PROP_WIDTH,
675                                                                                 g_param_spec_int ("width",
676                                                                                                         "Width",
677                                                                                                         "Width of display",
678                                                                                                         0, G_MAXINT, 176,
679                                                                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
680
681
682         g_object_class_install_property (gobject_class, PROP_HEIGHT,
683                                                                                 g_param_spec_int ("height",
684                                                                                                         "Height",
685                                                                                                         "Height of display",
686                                                                                                         0, G_MAXINT, 144,
687                                                                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
688
689         g_object_class_install_property (gobject_class, PROP_ROTATE,
690                                                                                 g_param_spec_int ("rotate",
691                                                                                                         "Rotate",
692                                                                                                         "Rotate of display",
693                                                                                                         0, G_MAXINT, 0,
694                                                                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
695
696
697         /**
698         * GstAvsysVideoSink::video-stream:
699         */
700         gst_avsysmemsink_signals[SIGNAL_VIDEO_STREAM] = g_signal_new (
701                                                         "video-stream",
702                                                         G_TYPE_FROM_CLASS (klass),
703                                                         G_SIGNAL_RUN_LAST,
704                                                         0,
705                                                         NULL,
706                                                         NULL,
707                                                         gst_avsysmemsink_BOOLEAN__POINTER_INT_INT,
708                                                         G_TYPE_BOOLEAN,
709                                                         3,
710                                                         G_TYPE_POINTER, G_TYPE_INT, G_TYPE_INT);
711
712     gstelement_class->change_state = gst_avsysmemsink_change_state;
713
714     gstbasesink_class->set_caps = gst_avsysmemsink_set_caps;
715     gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_avsysmemsink_preroll);
716     gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_avsysmemsink_show_frame);
717
718     
719     GST_DEBUG_CATEGORY_INIT (avsysmemsink_debug, 
720                             "avsysmemsink",
721                             0,
722                             "AV system based GStreamer Plug-in");
723 }
724
725
726 static void 
727 gst_avsysmemsink_init (GstAvsysMemSink *AvsysMemSink, GstAvsysMemSinkClass *klass)
728 {
729     /*private*/
730     AvsysMemSink->src_width = 0;
731     AvsysMemSink->src_height = 0;
732
733     AvsysMemSink->src_changed = 0;
734
735     /*property*/
736     AvsysMemSink->dst_width = 0;
737     AvsysMemSink->dst_height = 0;
738
739     AvsysMemSink->dst_changed = 0;
740
741     AvsysMemSink->rotate = 0;
742
743     AvsysMemSink->con_buf = NULL;
744     AvsysMemSink->rot_buf = NULL;
745     AvsysMemSink->rsz_buf = NULL;
746
747         AvsysMemSink->is_rgb = FALSE;
748 }
749
750
751 /* EOF */