d3d11: Update library doc
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / d3d11 / gstd3d11device.h
1 /* GStreamer
2  * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
3  * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
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 #pragma once
22
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25 #include <gst/d3d11/gstd3d11_fwd.h>
26
27 G_BEGIN_DECLS
28
29 #define GST_TYPE_D3D11_DEVICE             (gst_d3d11_device_get_type())
30 #define GST_D3D11_DEVICE(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3D11_DEVICE,GstD3D11Device))
31 #define GST_D3D11_DEVICE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3D11_DEVICE,GstD3D11DeviceClass))
32 #define GST_D3D11_DEVICE_GET_CLASS(obj)   (GST_D3D11_DEVICE_CLASS(G_OBJECT_GET_CLASS(obj)))
33 #define GST_IS_D3D11_DEVICE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3D11_DEVICE))
34 #define GST_IS_D3D11_DEVICE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D11_DEVICE))
35 #define GST_D3D11_DEVICE_CAST(obj)        ((GstD3D11Device*)(obj))
36
37 #define GST_TYPE_D3D11_FENCE              (gst_d3d11_fence_get_type())
38 #define GST_IS_D3D11_FENCE(obj)           (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_D3D11_FENCE))
39 #define GST_D3D11_FENCE(obj)              ((GstD3D11Fence *)obj)
40 #define GST_D3D11_FENCE_CAST(obj)         (GST_D3D11_FENCE(obj))
41
42 /**
43  * GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE:
44  *
45  * The name used in #GstContext queries for requesting a #GstD3D11Device
46  *
47  * Since: 1.22
48  */
49 #define GST_D3D11_DEVICE_HANDLE_CONTEXT_TYPE "gst.d3d11.device.handle"
50
51 /**
52  * GstD3D11Device:
53  *
54  * Opaque GstD3D11Device struct
55  *
56  * Since: 1.22
57  */
58 struct _GstD3D11Device
59 {
60   GstObject parent;
61
62   /*< private >*/
63   GstD3D11DevicePrivate *priv;
64   gpointer _gst_reserved[GST_PADDING];
65 };
66
67 /**
68  * GstD3D11DeviceClass:
69  *
70  * Opaque GstD3D11DeviceClass struct
71  *
72  * Since: 1.22
73  */
74 struct _GstD3D11DeviceClass
75 {
76   GstObjectClass parent_class;
77
78   /*< private >*/
79   gpointer _gst_reserved[GST_PADDING];
80 };
81
82 GST_D3D11_API
83 GType                 gst_d3d11_device_get_type           (void);
84
85 GST_D3D11_API
86 GstD3D11Device *      gst_d3d11_device_new                (guint adapter_index,
87                                                            guint flags);
88
89 GST_D3D11_API
90 GstD3D11Device *      gst_d3d11_device_new_for_adapter_luid (gint64 adapter_luid,
91                                                              guint flags);
92
93 GST_D3D11_API
94 GstD3D11Device *      gst_d3d11_device_new_wrapped        (ID3D11Device * device);
95
96 GST_D3D11_API
97 ID3D11Device *        gst_d3d11_device_get_device_handle  (GstD3D11Device * device);
98
99 GST_D3D11_API
100 ID3D11DeviceContext * gst_d3d11_device_get_device_context_handle (GstD3D11Device * device);
101
102 GST_D3D11_API
103 IDXGIFactory1 *       gst_d3d11_device_get_dxgi_factory_handle (GstD3D11Device * device);
104
105 GST_D3D11_API
106 ID3D11VideoDevice *   gst_d3d11_device_get_video_device_handle (GstD3D11Device * device);
107
108 GST_D3D11_API
109 ID3D11VideoContext *  gst_d3d11_device_get_video_context_handle (GstD3D11Device * device);
110
111 GST_D3D11_API
112 void                  gst_d3d11_device_lock               (GstD3D11Device * device);
113
114 GST_D3D11_API
115 void                  gst_d3d11_device_unlock             (GstD3D11Device * device);
116
117 GST_D3D11_API
118 gboolean              gst_d3d11_device_get_format         (GstD3D11Device * device,
119                                                            GstVideoFormat format,
120                                                            GstD3D11Format * device_format);
121
122 /**
123  * GstD3D11Fence:
124  *
125  * An abstraction of the ID3D11Fence interface
126  *
127  * Since: 1.22
128  */
129 struct _GstD3D11Fence
130 {
131   GstMiniObject parent;
132
133   GstD3D11Device *device;
134
135   /*< private >*/
136   GstD3D11FencePrivate *priv;
137   gpointer _gst_reserved[GST_PADDING];
138 };
139
140 GST_D3D11_API
141 GType           gst_d3d11_fence_get_type      (void);
142
143 GST_D3D11_API
144 GstD3D11Fence * gst_d3d11_device_create_fence (GstD3D11Device * device);
145
146 GST_D3D11_API
147 gboolean        gst_d3d11_fence_signal        (GstD3D11Fence * fence);
148
149 GST_D3D11_API
150 gboolean        gst_d3d11_fence_wait          (GstD3D11Fence * fence);
151
152 static inline void
153 gst_d3d11_fence_unref (GstD3D11Fence * fence)
154 {
155   gst_mini_object_unref (GST_MINI_OBJECT_CAST (fence));
156 }
157
158 static inline void
159 gst_clear_d3d11_fence (GstD3D11Fence ** fence)
160 {
161   if (fence && *fence) {
162     gst_d3d11_fence_unref (*fence);
163     *fence = NULL;
164   }
165 }
166
167 G_END_DECLS
168