1 /* GStreamer DirectFB plugin
2  * Copyright (C) 2005 Julien MOUTTE <julien@moutte.net>
3  * Copyright (C) 2013 Kazunori Kobayashi <kkobayas@igel.co.jp>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef __GST_DFBVIDEOSINK_H__
22 #define __GST_DFBVIDEOSINK_H__
23 
24 #include <gst/video/gstvideosink.h>
25 
26 #include <directfb.h>
27 #include <directfb_version.h>
28 
29 #define GST_DFBVIDEOSINK_VER(a,b,c) (((a) << 16) | ((b) << 8) | (c))
30 #define DIRECTFB_VER GST_DFBVIDEOSINK_VER(DIRECTFB_MAJOR_VERSION,DIRECTFB_MINOR_VERSION,DIRECTFB_MICRO_VERSION)
31 
32 #define LAYER_MODE_INVALID          -1
33 #define LAYER_MODE_EXCLUSIVE        DLSCL_EXCLUSIVE
34 #define LAYER_MODE_ADMINISTRATIVE   DLSCL_ADMINISTRATIVE
35 
36 G_BEGIN_DECLS
37 
38 #define GST_TYPE_DFBVIDEOSINK              (gst_dfbvideosink_get_type())
39 #define GST_DFBVIDEOSINK(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DFBVIDEOSINK, GstDfbVideoSink))
40 #define GST_DFBVIDEOSINK_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DFBVIDEOSINK, GstDfbVideoSinkClass))
41 #define GST_IS_DFBVIDEOSINK(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DFBVIDEOSINK))
42 #define GST_IS_DFBVIDEOSINK_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DFBVIDEOSINK))
43 
44 typedef struct _GstDfbVideoSink GstDfbVideoSink;
45 typedef struct _GstDfbVideoSinkClass GstDfbVideoSinkClass;
46 
47 typedef struct _GstMetaDfbSurface GstMetaDfbSurface;
48 
49 GType gst_meta_dfbsurface_api_get_type (void);
50 const GstMetaInfo * gst_meta_dfbsurface_get_info (void);
51 
52 #define GST_TYPE_DFB_BUFFER_POOL     (gst_dfb_buffer_pool_get_type())
53 #define GST_META_DFBSURFACE_GET(buf) ((GstMetaDfbSurface *)gst_buffer_get_meta(buf,gst_meta_dfbsurface_api_get_type()))
54 #define GST_META_DFBSURFACE_ADD(buf) ((GstMetaDfbSurface *)gst_buffer_add_meta(buf,gst_meta_dfbsurface_get_info(),NULL))
55 #define GST_DFB_BUFFER_POOL_CAST(obj) ((GstDfbBufferPool*)(obj))
56 
57 struct _GstMetaDfbSurface {
58   GstMeta meta;
59 
60   IDirectFBSurface *surface;
61 
62   gint width;
63   gint height;
64 
65   gboolean locked;
66 
67   DFBSurfacePixelFormat pixel_format;
68 
69   GstDfbVideoSink *dfbvideosink;
70 };
71 
72 typedef struct _GstDfbBufferPool GstDfbBufferPool;
73 
74 struct _GstDfbBufferPool
75 {
76   GstBufferPool bufferpool;
77 
78   GstDfbVideoSink *dfbvideosink;
79 
80   GstCaps *caps;
81 };
82 
83 typedef struct _GstDfbBufferPoolClass GstDfbBufferPoolClass;
84 
85 struct _GstDfbBufferPoolClass
86 {
87   GstBufferPoolClass parent_class;
88 };
89 
90 typedef struct _GstDfbVMode GstDfbVMode;
91 
92 struct _GstDfbVMode {
93   gint width;
94   gint height;
95   gint bpp;
96 };
97 
98 /**
99  * GstDfbVideoSink:
100  *
101  * The opaque #GstDfbVideoSink structure.
102  */
103 struct _GstDfbVideoSink {
104   GstVideoSink videosink;
105 
106   /* for buffer pool */
107   GstBufferPool *pool;
108 
109   /* Framerate numerator and denominator */
110   gint fps_n;
111   gint fps_d;
112 
113   gint video_width, video_height; /* size of incoming video */
114   gint out_width, out_height;
115 
116   /* Standalone */
117   IDirectFB *dfb;
118 
119   GSList *vmodes; /* Video modes */
120 
121   gint layer_id;
122   IDirectFBDisplayLayer *layer;
123   IDirectFBSurface *primary;
124   IDirectFBEventBuffer *event_buffer;
125   GThread *event_thread;
126 
127   /* Embedded */
128   IDirectFBSurface *ext_surface;
129 
130   DFBSurfacePixelFormat pixel_format;
131 
132   gboolean hw_scaling;
133   gboolean backbuffer;
134   gboolean vsync;
135   gboolean setup;
136   gboolean running;
137 
138   /* Color balance */
139   GList *cb_channels;
140   gint brightness;
141   gint contrast;
142   gint hue;
143   gint saturation;
144   gboolean cb_changed;
145 
146   /* object-set pixel aspect ratio */
147   GValue *par;
148 
149   gint layer_mode;
150 };
151 
152 struct _GstDfbVideoSinkClass {
153   GstVideoSinkClass parent_class;
154 };
155 
156 GType gst_dfbvideosink_get_type (void);
157 GType gst_dfb_buffer_pool_get_type (void);
158 
159 G_END_DECLS
160 
161 #endif /* __GST_DFBVIDEOSINK_H__ */
162