• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef __GST_D3D11_PLUGIN_UTILS_H__
22 #define __GST_D3D11_PLUGIN_UTILS_H__
23 
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/d3d11/gstd3d11.h>
27 
28 G_BEGIN_DECLS
29 
30 typedef struct _GstDxgiColorSpace GstDxgiColorSpace;
31 
32 typedef enum
33 {
34   GST_D3D11_DEVICE_VENDOR_UNKNOWN = 0,
35   GST_D3D11_DEVICE_VENDOR_AMD,
36   GST_D3D11_DEVICE_VENDOR_INTEL,
37   GST_D3D11_DEVICE_VENDOR_NVIDIA,
38   GST_D3D11_DEVICE_VENDOR_QUALCOMM,
39   GST_D3D11_DEVICE_VENDOR_XBOX,
40 } GstD3D11DeviceVendor;
41 
42 struct _GstDxgiColorSpace
43 {
44   guint dxgi_color_space_type;
45   GstVideoColorRange range;
46   GstVideoColorMatrix matrix;
47   GstVideoTransferFunction transfer;
48   GstVideoColorPrimaries primaries;
49 };
50 
51 #define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \
52     if (obj) { \
53       (obj)->Release (); \
54       (obj) = NULL; \
55     } \
56   } G_STMT_END
57 
58 void            gst_d3d11_plugin_utils_init         (D3D_FEATURE_LEVEL feature_level);
59 
60 GstCaps *       gst_d3d11_get_updated_template_caps (GstStaticCaps * template_caps);
61 
62 gboolean        gst_d3d11_is_windows_8_or_greater   (void);
63 
64 GstD3D11DeviceVendor gst_d3d11_get_device_vendor    (GstD3D11Device * device);
65 
66 #if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
67 gboolean        gst_d3d11_hdr_meta_data_to_dxgi     (GstVideoMasteringDisplayInfo * minfo,
68                                                      GstVideoContentLightLevel * cll,
69                                                      DXGI_HDR_METADATA_HDR10 * dxgi_hdr10);
70 #endif
71 
72 #if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
73 const GstDxgiColorSpace * gst_d3d11_video_info_to_dxgi_color_space (GstVideoInfo * info);
74 
75 const GstDxgiColorSpace * gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
76                                                                  IDXGISwapChain3 * swapchain);
77 #endif
78 
79 GstBuffer *     gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer,
80                                                        const GstVideoInfo * info,
81                                                        gboolean add_videometa);
82 
83 gboolean        gst_d3d11_buffer_copy_into          (GstBuffer * dst,
84                                                      GstBuffer * src,
85                                                      const GstVideoInfo * info);
86 
87 gboolean        gst_is_d3d11_buffer                 (GstBuffer * buffer);
88 
89 gboolean        gst_d3d11_buffer_can_access_device  (GstBuffer * buffer,
90                                                      ID3D11Device * device);
91 
92 gboolean        gst_d3d11_buffer_map                (GstBuffer * buffer,
93                                                      ID3D11Device * device,
94                                                      GstMapInfo info[GST_VIDEO_MAX_PLANES],
95                                                      GstMapFlags flags);
96 
97 gboolean        gst_d3d11_buffer_unmap              (GstBuffer * buffer,
98                                                      GstMapInfo info[GST_VIDEO_MAX_PLANES]);
99 
100 guint           gst_d3d11_buffer_get_shader_resource_view (GstBuffer * buffer,
101                                                            ID3D11ShaderResourceView * view[GST_VIDEO_MAX_PLANES]);
102 
103 guint           gst_d3d11_buffer_get_render_target_view   (GstBuffer * buffer,
104                                                            ID3D11RenderTargetView * view[GST_VIDEO_MAX_PLANES]);
105 
106 GstBufferPool * gst_d3d11_buffer_pool_new_with_options  (GstD3D11Device * device,
107                                                          GstCaps * caps,
108                                                          GstD3D11AllocationParams * alloc_params,
109                                                          guint min_buffers,
110                                                          guint max_buffers);
111 
112 G_END_DECLS
113 
114 #endif /* __GST_D3D11_PLUGIN_UTILS_H__ */
115