Tizen 2.1 base
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiwindow_drm.c
1 /*
2  *  gstvaapiwindow_drm.c - VA/DRM window abstraction
3  *
4  *  Copyright (C) 2012 Intel Corporation
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public License
8  *  as published by the Free Software Foundation; either version 2.1
9  *  of the License, or (at your option) any later version.
10  *
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  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * SECTION:gstvaapiwindow_drm
24  * @short_description: VA/DRM dummy window abstraction
25  */
26
27 #include "sysdeps.h"
28 #include "gstvaapiwindow_drm.h"
29
30 #define DEBUG 1
31 #include "gstvaapidebug.h"
32
33 G_DEFINE_TYPE(GstVaapiWindowDRM,
34               gst_vaapi_window_drm,
35               GST_VAAPI_TYPE_WINDOW);
36
37 static gboolean
38 gst_vaapi_window_drm_show(GstVaapiWindow *window)
39 {
40     return TRUE;
41 }
42
43 static gboolean
44 gst_vaapi_window_drm_hide(GstVaapiWindow *window)
45 {
46     return TRUE;
47 }
48
49 static gboolean
50 gst_vaapi_window_drm_create(
51     GstVaapiWindow *window,
52     guint          *width,
53     guint          *height
54 )
55 {
56     return TRUE;
57 }
58
59 static void
60 gst_vaapi_window_drm_destroy(GstVaapiWindow * window)
61 {
62 }
63
64 static gboolean
65 gst_vaapi_window_drm_resize(
66     GstVaapiWindow * window,
67     guint            width,
68     guint            height
69 )
70 {
71     return TRUE;
72 }
73
74 static gboolean
75 gst_vaapi_window_drm_render(
76     GstVaapiWindow          *window,
77     GstVaapiSurface         *surface,
78     const GstVaapiRectangle *src_rect,
79     const GstVaapiRectangle *dst_rect,
80     guint                    flags
81 )
82 {
83     return TRUE;
84 }
85
86 static void
87 gst_vaapi_window_drm_finalize(GObject *object)
88 {
89     G_OBJECT_CLASS(gst_vaapi_window_drm_parent_class)->finalize(object);
90 }
91
92 static void
93 gst_vaapi_window_drm_constructed(GObject *object)
94 {
95     GObjectClass *parent_class;
96
97     parent_class = G_OBJECT_CLASS(gst_vaapi_window_drm_parent_class);
98     if (parent_class->constructed)
99         parent_class->constructed(object);
100 }
101
102 static void
103 gst_vaapi_window_drm_class_init(GstVaapiWindowDRMClass * klass)
104 {
105     GObjectClass * const object_class = G_OBJECT_CLASS(klass);
106     GstVaapiWindowClass * const window_class = GST_VAAPI_WINDOW_CLASS(klass);
107
108     object_class->finalize      = gst_vaapi_window_drm_finalize;
109     object_class->constructed   = gst_vaapi_window_drm_constructed;
110
111     window_class->create        = gst_vaapi_window_drm_create;
112     window_class->destroy       = gst_vaapi_window_drm_destroy;
113     window_class->show          = gst_vaapi_window_drm_show;
114     window_class->hide          = gst_vaapi_window_drm_hide;
115     window_class->render        = gst_vaapi_window_drm_render;
116     window_class->resize        = gst_vaapi_window_drm_resize;
117 }
118
119 static void
120 gst_vaapi_window_drm_init(GstVaapiWindowDRM * window)
121 {
122 }
123
124 /**
125  * gst_vaapi_window_drm_new:
126  * @display: a #GstVaapiDisplay
127  * @width: the requested window width, in pixels (unused)
128  * @height: the requested windo height, in pixels (unused)
129  *
130  * Creates a dummy window. The window will be attached to the @display.
131  * All rendering functions will return success since VA/DRM is a
132  * renderless API.
133  *
134  * Note: this dummy window object is only necessary to fulfill cases
135  * where the client application wants to automatically determine the
136  * best display to use for the current system. As such, it provides
137  * utility functions with the same API (function arguments) to help
138  * implement uniform function tables.
139  *
140  * Return value: the newly allocated #GstVaapiWindow object
141  */
142 GstVaapiWindow *
143 gst_vaapi_window_drm_new(
144     GstVaapiDisplay *display,
145     guint            width,
146     guint            height
147 )
148 {
149     GST_DEBUG("new window, size %ux%u", width, height);
150
151     g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
152     g_return_val_if_fail(width  > 0, NULL);
153     g_return_val_if_fail(height > 0, NULL);
154
155     return g_object_new(GST_VAAPI_TYPE_WINDOW_DRM,
156                         "display", display,
157                         "id",      GST_VAAPI_ID(0),
158                         "width",   width,
159                         "height",  height,
160                         NULL);
161 }